using DH.Commons.Enums; using System; using System.ComponentModel; using System.Runtime.CompilerServices; using static DH.Commons.Enums.EnumHelper; namespace DH.Commons.Enums { /// /// 设备特性,指示该信息的设备类型,适用于设备信息和配置信息 /// public class DeviceAttribute : Attribute { /// /// 设备类型 /// public string TypeCode { get; set; } public string TypeDescription { get; set; } /// /// 特性修饰类别 /// public DeviceAttributeType AttrType { get; set; } public DeviceAttribute(string typeCode, string typeDesc, EnumHelper.DeviceAttributeType attrType) { TypeCode = typeCode; TypeDescription = typeDesc; AttrType = attrType; } } /// /// 预置状态特性 指定该修饰信息的前置状态允许范围 /// public class PreStateAttribute : Attribute { public int PreState { get; set; } public PreStateAttribute(int _preState) { PreState = _preState; } /// /// 检查当前待执行操作的前置状态要求是否合法 /// /// /// public bool CheckPreStateValid(int currentState) { return (currentState & PreState) == currentState; } } public class ColorSelectAttribute : Attribute { public string SelectedColor { get; set; } public ColorSelectAttribute(string selectedColor) { SelectedColor = selectedColor; } } public class FontColorSelectAttribute : Attribute { public string SelectedColor { get; set; } public FontColorSelectAttribute(string selectedColor) { SelectedColor = selectedColor; } } public enum InvokeType { /// /// 不公开调用 /// [Description("不公开调用")] NoneInvoke = 0, /// /// 测试调用 /// [Description("测试调用")] TestInvoke = 1, /// /// 标定调用 /// [Description("标定调用")] CalibInvoke = 2, } /// /// 用来修饰对外开放的调用方法的特性 /// 调用方法参数顺序:IOperationConfig,InvokeDevice,SourceDevice /// public class ProcessMethodAttribute : Attribute { public string MethodCode { get; set; } public string MethodDesc { get; set; } /// /// 是否提供人工调用测试 /// public InvokeType InvokeType { get; set; } public string DeviceType { get; set; } public ProcessMethodAttribute(string deviceType, string code, string description, InvokeType invokeType) { DeviceType = deviceType; MethodCode = code; MethodDesc = description; InvokeType = invokeType; } } public class SwitchDisplayAttribute : Attribute { public string SwitchName { get; set; } public bool SwithOnStatus { get; set; } = true; public SwitchDisplayAttribute(string name, bool status) { SwitchName = name; SwithOnStatus = status; } } public class ElementAttribute : Attribute { public string Name { get; set; } public string Desc { get; set; } public string IconPath { get; set; } public bool IsShowInToolBar { get; set; } public ElementAttribute(string desc, string iconPath, bool isShowInToolBar = true, [CallerMemberName] string name = "") { Name = name; Desc = desc; IconPath = iconPath; IsShowInToolBar = isShowInToolBar; } } public class ProcessAttribute : Attribute { public string ProcessCode { get; set; } public DeviceAttributeType AttrType { get; set; } public ProcessAttribute(string stationCode, DeviceAttributeType attrType) { ProcessCode = stationCode; AttrType = attrType; } } }