终端一体化运控平台
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 

65 行
2.2 KiB

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Collections.ObjectModel;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using BPA.Helper;
  8. using BPASmartClient.Model;
  9. using BPASmartClient.MorkSUpgradedVer.Model;
  10. using BPA.Helper;
  11. namespace BPASmartClient.MorkSUpgradedVer.ViewModel
  12. {
  13. public class ParSetViewModel : NotifyBase
  14. {
  15. public ParSetViewModel()
  16. {
  17. SaveInfoCommand = new BPARelayCommand(SaveSettingData);
  18. ActionManage.GetInstance.Register(SaveSettingData, "初始化设定煮面时间");
  19. if (Json<MorksPar>.Data.DishLibraryParSets.Count < 5)
  20. {
  21. Json<MorksPar>.Data.DishLibraryParSets.Clear();
  22. for (int i = 0; i < 5; i++)
  23. {
  24. Json<MorksPar>.Data.DishLibraryParSets.Add(new ParSet()
  25. {
  26. Minute = 2,
  27. Second = 0,
  28. TextBlockContext = $"{i + 1}"
  29. });
  30. }
  31. }
  32. }
  33. public BPARelayCommand SaveInfoCommand { get; set; }
  34. public ObservableCollection<ParSet> parSets { get; set; } = Json<MorksPar>.Data.parSets;
  35. public ObservableCollection<ParSet> DishLibraryParSets { get; set; } = Json<MorksPar>.Data.DishLibraryParSets;
  36. private void SaveSettingData()
  37. {
  38. List<ushort> values = new List<ushort>();
  39. values.Clear();
  40. List<bool> bools = new List<bool>();
  41. bools.Clear();
  42. for (int i = 0; i < Json<MorksPar>.Data.parSets.Count; i++)
  43. {
  44. values.Clear();
  45. values.Add(Json<MorksPar>.Data.parSets[i].Minute);
  46. values.Add(Json<MorksPar>.Data.parSets[i].Second);
  47. bools.Add(Json<MorksPar>.Data.parSets[i].IsShield);
  48. ActionManage.GetInstance.Send(new WritePar() { Address = $"VW{116 + (i * 6)}", Value = values.ToArray() }, "WriteVW");
  49. }
  50. ActionManage.GetInstance.Send(new WritePar() { Address = "M260.0", Value = bools.ToArray() }, "WriteBools");
  51. Json<MorksPar>.Save();
  52. }
  53. }
  54. }