|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- using System;
- using System.Collections.Generic;
- using System.Collections.ObjectModel;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using BPA.Helper;
- using BPASmartClient.Model;
- using BPASmartClient.MorkMV1.Model;
- using BPA.Helper;
-
-
- namespace BPASmartClient.MorkMV1.ViewModel
- {
- public class ParSetViewModel : NotifyBase
- {
- public ParSetViewModel()
- {
- SaveInfoCommand = new BPARelayCommand(SaveSettingData);
-
- ActionManage.GetInstance.Register(SaveSettingData, "初始化设定煮面时间");
- typeof(DishType).GetEnumNames()?.ToList()?.ForEach(item => { DishTypeName.Add(item); });
-
- if (Json<MorksPar>.Data.DishLibraryParSets.Count < 5)
- {
- Json<MorksPar>.Data.DishLibraryParSets.Clear();
- for (int i = 0; i < 5; i++)
- {
- Json<MorksPar>.Data.DishLibraryParSets.Add(new ParSet()
- {
- LocDishType = 0,
- Minute = 2,
- Second = 0,
- TextBlockContext = $"{i + 1}"
- });
- }
- }
- }
-
- public BPARelayCommand SaveInfoCommand { get; set; }
-
- public ObservableCollection<ParSet> parSets { get; set; } = Json<MorksPar>.Data.parSets;
- public ObservableCollection<ParSet> DishLibraryParSets { get; set; } = Json<MorksPar>.Data.DishLibraryParSets;
- public ObservableCollection<string> DishTypeName { get; set; } = new ObservableCollection<string>();
-
- private void SaveSettingData()
- {
- List<ushort> values = new List<ushort>();
- values.Clear();
-
- List<bool> bools = new List<bool>();
- bools.Clear();
-
- for (int i = 0; i < Json<MorksPar>.Data.parSets.Count; i++)
- {
- values.Clear();
- values.Add(Json<MorksPar>.Data.parSets[i].Minute);
- values.Add(Json<MorksPar>.Data.parSets[i].Second);
- bools.Add(Json<MorksPar>.Data.parSets[i].IsShield);
- ActionManage.GetInstance.Send("WriteVW", new WritePar() { Address = $"VW{116 + (i * 6)}", Value = values.ToArray() });
- }
- ActionManage.GetInstance.Send("WriteBools", new WritePar() { Address = "M260.0", Value = bools.ToArray() });
- Json<MorksPar>.Save();
- }
- }
- }
|