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

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