using BPASmartClient.Helper; using BPASmartClient.MorkM.Model; using Microsoft.Toolkit.Mvvm.ComponentModel; using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; using System.Text; using System.Threading.Tasks; namespace BPASmartClient.MorkM.ViewModel { internal class ParSetViewModel: ObservableObject { public ParSetViewModel() { SaveInfoCommand = new Action(() => { List values = new List(); values.Clear(); List bools = new List(); bools.Clear(); for (int i = 0; i < Json.Data.parSets.Count; i++) { values.Clear(); values.Add(Json.Data.parSets[i].Minute); values.Add(Json.Data.parSets[i].Second); bools.Add(Json.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.Save(); }); } public Action SaveInfoCommand { get; set; } public ObservableCollection parSets { get; set; } = Json.Data.parSets; } }