终端一体化运控平台
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.
 
 
 

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