mirror of
https://gitee.com/langsisi_admin/serein-flow
synced 2026-04-04 15:26:34 +08:00
示例工程版本提升至net462,项目添加了部分空引用检测逻辑。累了,消不完的空引用警告(T.T)
This commit is contained in:
64
Net462DllTest/Signal/PLCVarSignal.cs
Normal file
64
Net462DllTest/Signal/PLCVarSignal.cs
Normal file
@@ -0,0 +1,64 @@
|
||||
using Serein.Library.Attributes;
|
||||
using System;
|
||||
using static Net462DllTest.Signal.PlcValueAttribute;
|
||||
|
||||
namespace Net462DllTest.Signal
|
||||
{
|
||||
|
||||
[AttributeUsage(AttributeTargets.Field)]
|
||||
public class PlcValueAttribute : Attribute
|
||||
{
|
||||
/// <summary>
|
||||
/// 变量类型
|
||||
/// </summary>
|
||||
public enum VarType
|
||||
{
|
||||
/// <summary>
|
||||
/// 只读取的值
|
||||
/// </summary>
|
||||
ReadOnly,
|
||||
/// <summary>
|
||||
/// 可写入的值
|
||||
/// </summary>
|
||||
Writable,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 变量属性
|
||||
/// </summary>
|
||||
public PlcVarInfo PlcInfo { get; }
|
||||
|
||||
|
||||
public PlcValueAttribute(Type type,
|
||||
string @var,
|
||||
VarType varType
|
||||
)
|
||||
{
|
||||
PlcInfo = new PlcVarInfo(type, var, varType);
|
||||
}
|
||||
}
|
||||
|
||||
public class PlcVarInfo
|
||||
{
|
||||
public PlcVarInfo(Type type,
|
||||
string @var,
|
||||
VarType varType
|
||||
)
|
||||
{
|
||||
DataType = type;
|
||||
VarAddress = @var;
|
||||
Type = varType;
|
||||
}
|
||||
public bool IsProtected { get; }
|
||||
public Type DataType { get; }
|
||||
public string VarAddress { get; }
|
||||
public VarType Type { get; }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"数据类型:{DataType} 地址:{VarAddress}";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user