|
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
-
- namespace BPASmartClient.Academy.ViewModel
- {
- public class DeviceMotion_2ViewModel:NotifyBase
- {
- private static DeviceMotion_2ViewModel Instance;
- public static DeviceMotion_2ViewModel GetInstance { get; set; } = Instance ??= new DeviceMotion_2ViewModel();
- public DeviceMotion_2ViewModel()
- {
- Start = new BPARelayCommand(() =>
- {
- if (Name != "" && Simens_PLC.GetInstance.IsConnected)
- {
- switch (Content)
- {
- case "系统启动":
- IsChecked = true;
- DataFeedback dataFeedback = new DataFeedback();
- dataFeedback.Name = Name;
- var snd = new SaveNameData(Name);
- dataFeedback.ProductNumberId = snd.Id;
- Sqlite.GetInstance.AddData(snd);
- Simens_PLC.GetInstance.id = snd.Id;
- Simens_PLC.GetInstance.dataFeedback = dataFeedback;
- Simens_PLC.GetInstance.siemens.Write<bool>("DB1.DBX1002.0", true);
- Simens_PLC.GetInstance.siemens.Write<bool>("DB1.DBX1002.1", true);
- Content = "系统停止";
- break;
- case "系统停止":
- IsChecked = false;
- Simens_PLC.GetInstance.id = "";
- Simens_PLC.GetInstance.siemens.Write<bool>("DB1.DBX1002.0", false);
- Simens_PLC.GetInstance.siemens.Write<bool>("DB1.DBX1002.1", false);
- Content = "系统启动";
- break;
- default:
- break;
- }
- }
- else
- {
- if (!Simens_PLC.GetInstance.IsConnected)
- {
- MessageNotify.GetInstance.ShowDialog("设备未连接成功,请稍后重试", DialogType.Information);
- }
- else
- {
- MessageNotify.GetInstance.ShowDialog("请输入名称后,再开始测试!!", DialogType.Information);
- }
- IsChecked = false;
- }
- });
-
- DataRecordCommand = new BPARelayCommand(() =>
- {
- ParameterSetView sv = new ParameterSetView();
- sv.Show();
- });
- }
- public PipeLineMode PipeLine { get; set; } = Simens_PLC.GetInstance.PipeLine;
-
- private string _name = "";
-
- public string Name
- {
- get { return _name; }
- set { _name = value; OnPropertyChanged(); }
- }
- private string _content = "系统启动";
-
- public string Content
- {
- get { return _content; }
- set { _content = value; OnPropertyChanged(); }
- }
-
- private bool _isChecked = false;
-
- public bool IsChecked
- {
- get { return _isChecked; }
- set { _isChecked = value; OnPropertyChanged(); }
- }
- public BPARelayCommand Start { get; set; }
- public BPARelayCommand DataRecordCommand { get; set; }
-
- private DeviceCtrl _deviceStatus = Simens_PLC.GetInstance.deviceCtrl;
-
- public DeviceCtrl DeviceStatus
- {
- get { return _deviceStatus = Simens_PLC.GetInstance.deviceCtrl; }
- set { _deviceStatus = Simens_PLC.GetInstance.deviceCtrl = value; OnPropertyChanged(); }
- }
- }
- }
|