终端一体化运控平台
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 
 

119 wiersze
4.3 KiB

  1. using LiveCharts.Configurations;
  2. using LiveCharts;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. using System.Windows;
  9. using BPASmartClient.CustomResource.UserControls.MessageShow;
  10. using BPASmartClient.CustomResource.UserControls;
  11. using System.Security.Cryptography.X509Certificates;
  12. namespace BPASmartClient.Academy.ViewModel
  13. {
  14. public class DeviceMotionViewModel : NotifyBase
  15. {
  16. private static DeviceMotionViewModel Instance;
  17. public static DeviceMotionViewModel GetInstance { get; set; } = Instance ??= new DeviceMotionViewModel();
  18. public DeviceMotionViewModel()
  19. {
  20. Start = new BPARelayCommand(() =>
  21. {
  22. if (Name != "" && Simens_PLC.GetInstance.IsConnected)
  23. {
  24. switch (Content)
  25. {
  26. case "系统启动":
  27. IsChecked = true;
  28. DataFeedback dataFeedback = new DataFeedback();
  29. dataFeedback.Name = Name;
  30. var snd = new SaveNameData(Name);
  31. dataFeedback.ProductNumberId = snd.Id;
  32. Sqlite.GetInstance.AddData(snd);
  33. Simens_PLC.GetInstance.id = snd.Id;
  34. Simens_PLC.GetInstance.dataFeedback = dataFeedback;
  35. Simens_PLC.GetInstance.siemens.Write<bool>("DB1.DBX1002.0", true);
  36. Simens_PLC.GetInstance.siemens.Write<bool>("DB1.DBX1002.1", true);
  37. Content = "系统停止";
  38. break;
  39. case "系统停止":
  40. IsChecked = false;
  41. Simens_PLC.GetInstance.id = "";
  42. Simens_PLC.GetInstance.siemens.Write<bool>("DB1.DBX1002.0", false);
  43. Simens_PLC.GetInstance.siemens.Write<bool>("DB1.DBX1002.1", false);
  44. Content = "系统启动";
  45. break;
  46. default:
  47. break;
  48. }
  49. }
  50. else
  51. {
  52. if (!Simens_PLC.GetInstance.IsConnected)
  53. {
  54. MessageNotify.GetInstance.ShowDialog("设备未连接成功,请稍后重试", DialogType.Information);
  55. }
  56. else
  57. {
  58. MessageNotify.GetInstance.ShowDialog("请输入名称后,再开始测试!!", DialogType.Information);
  59. }
  60. IsChecked = false;
  61. }
  62. });
  63. DataRecordCommand = new BPARelayCommand(() =>
  64. {
  65. ParameterSetView sv = new ParameterSetView();
  66. sv.Show();
  67. });
  68. }
  69. public PipeLineMode PipeLine { get; set; } = Simens_PLC.GetInstance.PipeLine;
  70. private string _name = "";
  71. public string Name
  72. {
  73. get { return _name; }
  74. set { _name = value; OnPropertyChanged(); }
  75. }
  76. private string _content = "系统启动";
  77. public string Content
  78. {
  79. get { return _content; }
  80. set { _content = value; OnPropertyChanged(); }
  81. }
  82. private bool _isChecked = false;
  83. public bool IsChecked
  84. {
  85. get { return _isChecked; }
  86. set { _isChecked = value; OnPropertyChanged(); }
  87. }
  88. public BPARelayCommand Start { get; set; }
  89. public BPARelayCommand DataRecordCommand { get; set; }
  90. private DeviceCtrl _deviceStatus = Simens_PLC.GetInstance.deviceCtrl;
  91. public DeviceCtrl DeviceStatus
  92. {
  93. get { return _deviceStatus = Simens_PLC.GetInstance.deviceCtrl; }
  94. set { _deviceStatus = Simens_PLC.GetInstance.deviceCtrl = value; OnPropertyChanged(); }
  95. }
  96. }
  97. public class DataValue : NotifyBase
  98. {
  99. private DateTime _dateTime;
  100. public DateTime DateTime { get { return _dateTime; } set { _dateTime = value; OnPropertyChanged(); } }
  101. private double _value;
  102. public double Value { get { return _value; } set { _value = value; OnPropertyChanged(); } }
  103. }
  104. }