终端一体化运控平台
Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.
 
 
 

101 Zeilen
3.8 KiB

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