|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118 |
- using LiveCharts.Configurations;
- using LiveCharts;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows;
- using BPASmartClient.CustomResource.UserControls.MessageShow;
- using BPASmartClient.CustomResource.UserControls;
- using System.Security.Cryptography.X509Certificates;
-
- namespace BPASmartClient.Academy.ViewModel
- {
- public class DeviceMotionViewModel : NotifyBase
- {
- private static DeviceMotionViewModel Instance;
- public static DeviceMotionViewModel GetInstance { get; set; } = Instance ??= new DeviceMotionViewModel();
- public DeviceMotionViewModel()
- {
- 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(); }
- }
-
- }
-
- public class DataValue : NotifyBase
- {
- private DateTime _dateTime;
-
- public DateTime DateTime { get { return _dateTime; } set { _dateTime = value; OnPropertyChanged(); } }
- private double _value;
-
- public double Value { get { return _value; } set { _value = value; OnPropertyChanged(); } }
- }
-
- }
|