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

68 line
3.2 KiB

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