|
- using BPASmartClient.CustomResource.Pages.Model;
- using BPASmartClient.Helper;
- using Microsoft.Toolkit.Mvvm.ComponentModel;
- using Microsoft.Toolkit.Mvvm.Input;
- using System;
- using System.Collections.Generic;
- using System.Collections.ObjectModel;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows;
-
- namespace BPASmartClient.CustomResource.Pages.ViewModel
- {
- public class VariableViewModel : ObservableObject
- {
- public ObservableCollection<PlcVariableInfoModel> Variables { get; set; } = new ObservableCollection<PlcVariableInfoModel>();
-
- public ObservableCollection<PlcVariableInfoModel> FryOneVariables { get; set; } = new ObservableCollection<PlcVariableInfoModel>();
- public ObservableCollection<PlcVariableInfoModel> FryTwoVariables { get; set; } = new ObservableCollection<PlcVariableInfoModel>();
- public ObservableCollection<PlcVariableInfoModel> FryThreeVariables { get; set; } = new ObservableCollection<PlcVariableInfoModel>();
- public ObservableCollection<PlcVariableInfoModel> FryFourVariables { get; set; } = new ObservableCollection<PlcVariableInfoModel>();
- public ObservableCollection<PlcVariableInfoModel> FryFiveVariables { get; set; } = new ObservableCollection<PlcVariableInfoModel>();
-
- public List<string> DeviceName { get; set; } = new List<string> { "滚筒输送线", "炒锅1", "炒锅2", "炒锅3", "炒锅4", "炒锅5" };
- public RelayCommand SaveDataCommand { get; set; }
-
- public VariableViewModel()
- {
- Json<PlcVariableInfoManage>.Read();
-
- try
- {
- if (Json<PlcVariableInfoManage>.Data.VariablesInfo.Count>0)
- {
- Variables = Json<PlcVariableInfoManage>.Data.VariablesInfo["滚筒输送线"];
- FryOneVariables = Json<PlcVariableInfoManage>.Data.VariablesInfo["炒锅1"];
- FryTwoVariables = Json<PlcVariableInfoManage>.Data.VariablesInfo["炒锅2"];
- FryThreeVariables = Json<PlcVariableInfoManage>.Data.VariablesInfo["炒锅3"];
- FryFourVariables = Json<PlcVariableInfoManage>.Data.VariablesInfo["炒锅4"];
- FryFiveVariables = Json<PlcVariableInfoManage>.Data.VariablesInfo["炒锅5"];
- }
- }
- catch (Exception)
- {
-
-
- }
- SaveDataCommand = new RelayCommand(() =>
- {
- Json<PlcVariableInfoManage>.Data.VariablesInfo["滚筒输送线"] = Variables;
- Json<PlcVariableInfoManage>.Data.VariablesInfo["炒锅1"] = FryOneVariables;
- Json<PlcVariableInfoManage>.Data.VariablesInfo["炒锅2"]=FryTwoVariables;
- Json<PlcVariableInfoManage>.Data.VariablesInfo["炒锅3"] = FryThreeVariables;
- Json<PlcVariableInfoManage>.Data.VariablesInfo["炒锅4"]= FryFourVariables;
- Json<PlcVariableInfoManage>.Data.VariablesInfo["炒锅5"] = FryFiveVariables;
- Json<PlcVariableInfoManage>.Save();
- MessageBox.Show("保存成功","提示",MessageBoxButton.OK,MessageBoxImage.Information);
- });
-
- }
-
-
- }
- }
|