using PLCSharp.Core.Common; using PLCSharp.VVMs.MotionController; using Prism.Mvvm; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; namespace PLCSharp.VVMs.Cylinders { /// /// 气缸感应类型 /// public enum SensorType { None, OnlyA, OnlyB, Two, } /// /// 气缸 /// public class Cylinder : BindableBase, PLCSharp.Models.INamedDevice { /// /// 唯一标识 /// [Key] public Guid ID { get; set; } = Guid.NewGuid(); private string _Name; void PLCSharp.Models.INamedDevice.SetReviewedName(string value) => SetProperty(ref _Name, value, nameof(Name)); /// /// 气缸名称 /// public string Name { get { return _Name; } set { if (_Name != value) { Prompt = "已修改,请保存"; } SetProperty(ref _Name, value); } } private SensorType _SensorType; /// /// 感应类型 /// public SensorType SensorType { get { return _SensorType; } set { if (_SensorType != value) { Prompt = "已修改,请保存"; } SetProperty(ref _SensorType, value); } } private string _InA; /// /// A位感应输入点 /// public string InA { get { return _InA; } set { if (_InA != value) { Prompt = "已修改,请保存"; } SetProperty(ref _InA, value); } } private string _InB; /// /// B位感应输入点 /// public string InB { get { return _InB; } set { if (_InB != value) { Prompt = "已修改,请保存"; } SetProperty(ref _InB, value); } } private string _OutA; /// /// A位输出点(DQ 名称或序号) /// public string OutA { get { return _OutA; } set { if (_OutA != value) { Prompt = "已修改,请保存"; } SetProperty(ref _OutA, value); } } private string _OutB; /// /// B位输出点(DQ 名称或序号) /// public string OutB { get { return _OutB; } set { if (_OutB != value) { Prompt = "已修改,请保存"; } SetProperty(ref _OutB, value); } } private bool _OffWhenStopped; /// /// 有停止命令时关闭输出 /// public bool OffWhenStopped { get { return _OffWhenStopped; } set { if (_OffWhenStopped != value) { Prompt = "已修改,请保存"; } SetProperty(ref _OffWhenStopped, value); } } private bool _OffWhenInPosition; /// /// 到位后关闭输出 /// public bool OffWhenInPosition { get { return _OffWhenInPosition; } set { if (_OffWhenInPosition != value) { Prompt = "已修改,请保存"; } SetProperty(ref _OffWhenInPosition, value); } } private bool _Enabled = true; /// /// 启用 /// public bool Enabled { get { return _Enabled; } set { SetProperty(ref _Enabled, value); } } private bool _NoInterlock; /// /// 不需要互锁 /// public bool NoInterlock { get { return _NoInterlock; } set { SetProperty(ref _NoInterlock, value); } } private double _ATimeout; /// /// /// public double ATimeout { get { return _ATimeout; } set { SetProperty(ref _ATimeout, value); } } private double _BTimeout; /// /// /// public double BTimeout { get { return _BTimeout; } set { SetProperty(ref _BTimeout, value); } } private double _ADelay; /// /// 感应到位延时 /// public double ADelay { get { return _ADelay; } set { SetProperty(ref _ADelay, value); } } private double _BDelay; /// /// 感应到位延时 /// public double BDelay { get { return _BDelay; } set { SetProperty(ref _BDelay, value); } } private string _Comment; /// /// 备注 /// public string Comment { get { return _Comment; } set { if (_Comment != value) { Prompt = "已修改,请保存"; } SetProperty(ref _Comment, value); } } private string _Prompt; #region NotMapped Properties private string _Cmd; /// /// 指令 "A"/"B"/"Stop" /// [NotMapped] public string Cmd { get { return _Cmd; } set { SetProperty(ref _Cmd, value); } } /// /// 动作流程 /// [NotMapped] public FlowModel Flow { get; set; } = new(); /// /// 提示(已修改,请保存) /// [NotMapped] public string Prompt { get { return _Prompt; } set { SetProperty(ref _Prompt, value); } } private bool _StatusAIn; /// /// A位感应状态 /// [NotMapped] public bool StatusAIn { get { return _StatusAIn; } set { SetProperty(ref _StatusAIn, value); } } private bool _StatusBIn; /// /// B位感应状态 /// [NotMapped] public bool StatusBIn { get { return _StatusBIn; } set { SetProperty(ref _StatusBIn, value); } } private bool _StatusAOut; /// /// A位输出状态 /// [NotMapped] public bool StatusAOut { get { return _StatusAOut; } set { SetProperty(ref _StatusAOut, value); } } private bool _StatusBOut; /// /// B位输出状态 /// [NotMapped] public bool StatusBOut { get { return _StatusBOut; } set { SetProperty(ref _StatusBOut, value); } } private string _FaultCode; /// /// 故障码 /// [NotMapped] public string FaultCode { get { return _FaultCode; } set { SetProperty(ref _FaultCode, value); } } [NotMapped] public bool AComplit { get; set; } [NotMapped] public bool BComplit { get; set; } [NotMapped] public DI DIA { get; set; } [NotMapped] public DI DIB { get; set; } [NotMapped] public DQ DQA { get; set; } [NotMapped] public DQ DQB { get; set; } [NotMapped] public DateTime ADelayTimer { get; set; } = DateTime.Now ; [NotMapped] public DateTime BDelayTimer { get; set; } = DateTime.Now; #endregion } }