终端一体化运控平台
Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 

67 linhas
2.4 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.MorkMV1.Model;
  10. using BPA.Helper;
  11. namespace BPASmartClient.MorkMV1.ViewModel
  12. {
  13. public class ParSetViewModel : NotifyBase
  14. {
  15. public ParSetViewModel()
  16. {
  17. SaveInfoCommand = new BPARelayCommand(SaveSettingData);
  18. ActionManage.GetInstance.Register(SaveSettingData, "初始化设定煮面时间");
  19. typeof(DishType).GetEnumNames()?.ToList()?.ForEach(item => { DishTypeName.Add(item); });
  20. if (Json<MorksPar>.Data.DishLibraryParSets.Count < 5)
  21. {
  22. Json<MorksPar>.Data.DishLibraryParSets.Clear();
  23. for (int i = 0; i < 5; i++)
  24. {
  25. Json<MorksPar>.Data.DishLibraryParSets.Add(new ParSet()
  26. {
  27. LocDishType = 0,
  28. Minute = 2,
  29. Second = 0,
  30. TextBlockContext = $"{i + 1}"
  31. });
  32. }
  33. }
  34. }
  35. public BPARelayCommand SaveInfoCommand { get; set; }
  36. public ObservableCollection<ParSet> parSets { get; set; } = Json<MorksPar>.Data.parSets;
  37. public ObservableCollection<ParSet> DishLibraryParSets { get; set; } = Json<MorksPar>.Data.DishLibraryParSets;
  38. public ObservableCollection<string> DishTypeName { get; set; } = new ObservableCollection<string>();
  39. private void SaveSettingData()
  40. {
  41. List<ushort> values = new List<ushort>();
  42. values.Clear();
  43. List<bool> bools = new List<bool>();
  44. bools.Clear();
  45. for (int i = 0; i < Json<MorksPar>.Data.parSets.Count; i++)
  46. {
  47. values.Clear();
  48. values.Add(Json<MorksPar>.Data.parSets[i].Minute);
  49. values.Add(Json<MorksPar>.Data.parSets[i].Second);
  50. bools.Add(Json<MorksPar>.Data.parSets[i].IsShield);
  51. ActionManage.GetInstance.Send(new WritePar() { Address = $"VW{116 + (i * 6)}", Value = values.ToArray() }, "WriteVW");
  52. }
  53. ActionManage.GetInstance.Send(new WritePar() { Address = "M260.0", Value = bools.ToArray() }, "WriteBools");
  54. Json<MorksPar>.Save();
  55. }
  56. }
  57. }