using Bro.Common.Model;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
namespace Bro.Common.Helper
{
///
/// 设备特性,指示该信息的设备类型,适用于设备信息和配置信息
///
public class DeviceAttribute : Attribute
{
///
/// 设备类型
///
public string TypeCode { get; set; }
public string TypeDescription { get; set; }
///
/// 特性修饰类别
///
public EnumHelper.DeviceAttributeType AttrType { get; set; }
public DeviceAttribute(string typeCode, string typeDesc, EnumHelper.DeviceAttributeType attrType)
{
TypeCode = typeCode;
TypeDescription = typeDesc;
AttrType = attrType;
}
}
public class CompareDevice : IEqualityComparer
{
public bool Equals(DeviceAttribute x, DeviceAttribute y)
{
return x.TypeCode == y.TypeCode;
}
public int GetHashCode(DeviceAttribute obj)
{
return obj.GetHashCode();
}
}
///
/// 预置状态特性 指定该修饰信息的前置状态允许范围
///
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 SkipStateAttribute : Attribute
{
}
///
/// 指定该特性修饰字段的数据源来自于哪一个枚举
///
public class ConfigOutputResourceAttribute : Attribute
{
public string EnumName { get; set; }
//public List Results { get; set; }
//public ConfigOutputAttribute(string _enumName = null, List _results = null)
//{
// EnumName = _enumName;
// Results = _results;
//}
public ConfigOutputResourceAttribute(string _enumName)
{
EnumName = _enumName;
}
}
public class DeviceOutputMethodAttribute : Attribute
{
public string MethodName { get; set; }
public string MethodDescription { get; set; }
public DeviceOutputMethodAttribute(string methodName, string methodDescription)
{
MethodName = methodName;
MethodDescription = methodDescription;
}
}
///
/// 该特性用于修饰设备外部输入的判断方法
/// 方法的输入参数为IOperationConfig,返回值为布尔类型
///
public class DeviceInputMethodAttribute : Attribute
{
public string MethodName { get; set; }
public string MethodDescription { get; set; }
public DeviceInputMethodAttribute(string methodName, string methodDescription)
{
MethodName = methodName;
MethodDescription = methodDescription;
}
}
public class ColorSelectAttribute : Attribute
{
public string SelectedColor { get; set; }
public ColorSelectAttribute(string selectedColor)
{
SelectedColor = selectedColor;
}
}
public class CameraParaAttribute : Attribute
{
public string ParaName { get; set; }
public string ParaNameCode { get; set; }
public double MaxValue { get; set; }
public double MinValue { get; set; }
public int Ratio { get; set; } = 1;
public CameraParaAttribute(string name, string nameCode, double maxValue, double minValue, int ratio)
{
ParaName = name;
ParaNameCode = nameCode;
MaxValue = maxValue;
MinValue = minValue;
Ratio = ratio;
}
}
public class ProcessMethodAttribute : Attribute
{
public string MethodCode { get; set; }
public string MethodDesc { get; set; }
///
/// 是否提供人工调用测试
///
public bool IsAllowManualInvoke { get; set; }
public string DeviceType { get; set; }
public ProcessMethodAttribute(string deviceType, string code, string description, bool isAllowManualInvoke = false)
{
DeviceType = deviceType;
MethodCode = code;
MethodDesc = description;
IsAllowManualInvoke = isAllowManualInvoke;
}
}
public class CameraInvokeAttribute : Attribute
{
public string CameraName { get; set; }
public CameraInvokeAttribute(string cameraName)
{
CameraName = cameraName;
}
}
public class StationAttribute : Attribute
{
public string StationCode { get; set; }
public StationAttribute(string stationCode)
{
StationCode = stationCode;
}
}
public class CSVOutputAttribute : Attribute
{
public string HeadName { get; set; }
public int OrderIndex { get; set; }
public int PositionIndex { get; set; }
public bool IsCSVInterface { get; set; }
public bool IsConfig { get; set; }
public bool IsCSVOutput { get; set; } = true;
public CSVOutputAttribute(bool isOutput)
{
IsCSVOutput = isOutput;
}
///
/// CSV输出修饰特性
///
/// 列名
/// 序号
/// 工位索引 从0开始
/// 是否CSV输出接口
/// 是否配置信息中的CSV字段
public CSVOutputAttribute(string headName, int orderIndex, int positionIndex, bool isCSVInterface, bool isConfig)
{
HeadName = headName;
OrderIndex = orderIndex;
PositionIndex = positionIndex;
IsCSVInterface = isCSVInterface;
IsConfig = isConfig;
}
}
public class DeviceOperationAttribute : Attribute
{
public DeviceOpCmmd DeviceCmmd { get; set; }
///
/// 该方法是否需要IOperationconfig参数 true:需要 false:不需要
///
public bool IsOpConfigNeed { get; set; }
public DeviceOperationAttribute(DeviceOpCmmd deviceCmmd, bool isOpConfigNeed)
{
DeviceCmmd = deviceCmmd;
IsOpConfigNeed = isOpConfigNeed;
}
}
public class SFCNameAttribute : Attribute
{
public string SFCAlias { get; set; }
public SFCNameAttribute(string alias)
{
SFCAlias = alias;
}
}
public class PCWarningAttribute : Attribute
{
}
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;
}
}
}