终端一体化运控平台
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

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