终端一体化运控平台
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
 
 
 

66 rindas
3.2 KiB

  1. using BPASmartClient.CustomResource.Pages.Model;
  2. using BPASmartClient.Helper;
  3. using Microsoft.Toolkit.Mvvm.ComponentModel;
  4. using Microsoft.Toolkit.Mvvm.Input;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.Collections.ObjectModel;
  8. using System.Linq;
  9. using System.Text;
  10. using System.Threading.Tasks;
  11. using System.Windows;
  12. namespace BPASmartClient.CustomResource.Pages.ViewModel
  13. {
  14. public class VariableViewModel : ObservableObject
  15. {
  16. public ObservableCollection<PlcVariableInfoModel> Variables { get; set; } = new ObservableCollection<PlcVariableInfoModel>();
  17. public ObservableCollection<PlcVariableInfoModel> FryOneVariables { get; set; } = new ObservableCollection<PlcVariableInfoModel>();
  18. public ObservableCollection<PlcVariableInfoModel> FryTwoVariables { get; set; } = new ObservableCollection<PlcVariableInfoModel>();
  19. public ObservableCollection<PlcVariableInfoModel> FryThreeVariables { get; set; } = new ObservableCollection<PlcVariableInfoModel>();
  20. public ObservableCollection<PlcVariableInfoModel> FryFourVariables { get; set; } = new ObservableCollection<PlcVariableInfoModel>();
  21. public ObservableCollection<PlcVariableInfoModel> FryFiveVariables { get; set; } = new ObservableCollection<PlcVariableInfoModel>();
  22. public List<string> DeviceName { get; set; } = new List<string> { "滚筒输送线", "炒锅1", "炒锅2", "炒锅3", "炒锅4", "炒锅5" };
  23. public RelayCommand SaveDataCommand { get; set; }
  24. public VariableViewModel()
  25. {
  26. Json<PlcVariableInfoManage>.Read();
  27. try
  28. {
  29. if (Json<PlcVariableInfoManage>.Data.VariablesInfo.Count>0)
  30. {
  31. Variables = Json<PlcVariableInfoManage>.Data.VariablesInfo["滚筒输送线"];
  32. FryOneVariables = Json<PlcVariableInfoManage>.Data.VariablesInfo["炒锅1"];
  33. FryTwoVariables = Json<PlcVariableInfoManage>.Data.VariablesInfo["炒锅2"];
  34. FryThreeVariables = Json<PlcVariableInfoManage>.Data.VariablesInfo["炒锅3"];
  35. FryFourVariables = Json<PlcVariableInfoManage>.Data.VariablesInfo["炒锅4"];
  36. FryFiveVariables = Json<PlcVariableInfoManage>.Data.VariablesInfo["炒锅5"];
  37. }
  38. }
  39. catch (Exception)
  40. {
  41. }
  42. SaveDataCommand = new RelayCommand(() =>
  43. {
  44. Json<PlcVariableInfoManage>.Data.VariablesInfo["滚筒输送线"] = Variables;
  45. Json<PlcVariableInfoManage>.Data.VariablesInfo["炒锅1"] = FryOneVariables;
  46. Json<PlcVariableInfoManage>.Data.VariablesInfo["炒锅2"]=FryTwoVariables;
  47. Json<PlcVariableInfoManage>.Data.VariablesInfo["炒锅3"] = FryThreeVariables;
  48. Json<PlcVariableInfoManage>.Data.VariablesInfo["炒锅4"]= FryFourVariables;
  49. Json<PlcVariableInfoManage>.Data.VariablesInfo["炒锅5"] = FryFiveVariables;
  50. Json<PlcVariableInfoManage>.Save();
  51. MessageBox.Show("保存成功","提示",MessageBoxButton.OK,MessageBoxImage.Information);
  52. });
  53. }
  54. }
  55. }