162 lines
4.4 KiB
C#
162 lines
4.4 KiB
C#
|
using DH.Commons.Enums;
|
|||
|
using System;
|
|||
|
using System.ComponentModel;
|
|||
|
using System.Runtime.CompilerServices;
|
|||
|
using static DH.Commons.Enums.EnumHelper;
|
|||
|
|
|||
|
|
|||
|
namespace DH.Commons.Enums
|
|||
|
{
|
|||
|
/// <summary>
|
|||
|
/// 设备特性,指示该信息的设备类型,适用于设备信息和配置信息
|
|||
|
/// </summary>
|
|||
|
public class DeviceAttribute : Attribute
|
|||
|
{
|
|||
|
/// <summary>
|
|||
|
/// 设备类型
|
|||
|
/// </summary>
|
|||
|
public string TypeCode { get; set; }
|
|||
|
|
|||
|
public string TypeDescription { get; set; }
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 特性修饰类别
|
|||
|
/// </summary>
|
|||
|
public DeviceAttributeType AttrType { get; set; }
|
|||
|
|
|||
|
public DeviceAttribute(string typeCode, string typeDesc, EnumHelper.DeviceAttributeType attrType)
|
|||
|
{
|
|||
|
TypeCode = typeCode;
|
|||
|
TypeDescription = typeDesc;
|
|||
|
AttrType = attrType;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 预置状态特性 指定该修饰信息的前置状态允许范围
|
|||
|
/// </summary>
|
|||
|
public class PreStateAttribute : Attribute
|
|||
|
{
|
|||
|
public int PreState { get; set; }
|
|||
|
public PreStateAttribute(int _preState)
|
|||
|
{
|
|||
|
PreState = _preState;
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 检查当前待执行操作的前置状态要求是否合法
|
|||
|
/// </summary>
|
|||
|
/// <param name="currentState"></param>
|
|||
|
/// <returns></returns>
|
|||
|
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
|
|||
|
{
|
|||
|
/// <summary>
|
|||
|
/// 不公开调用
|
|||
|
/// </summary>
|
|||
|
[Description("不公开调用")]
|
|||
|
NoneInvoke = 0,
|
|||
|
/// <summary>
|
|||
|
/// 测试调用
|
|||
|
/// </summary>
|
|||
|
[Description("测试调用")]
|
|||
|
TestInvoke = 1,
|
|||
|
/// <summary>
|
|||
|
/// 标定调用
|
|||
|
/// </summary>
|
|||
|
[Description("标定调用")]
|
|||
|
CalibInvoke = 2,
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 用来修饰对外开放的调用方法的特性
|
|||
|
/// 调用方法参数顺序:IOperationConfig,InvokeDevice,SourceDevice
|
|||
|
/// </summary>
|
|||
|
public class ProcessMethodAttribute : Attribute
|
|||
|
{
|
|||
|
public string MethodCode { get; set; }
|
|||
|
public string MethodDesc { get; set; }
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 是否提供人工调用测试
|
|||
|
/// </summary>
|
|||
|
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;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|