46 lines
2.1 KiB
C#
46 lines
2.1 KiB
C#
using ZB.MOM.WW.OtOpcUa.Core.Abstractions;
|
|
|
|
namespace ZB.MOM.WW.OtOpcUa.Driver.AbLegacy;
|
|
|
|
/// <summary>
|
|
/// PCCC data types that map onto SLC / MicroLogix / PLC-5 files. Narrower than Logix — no
|
|
/// symbolic UDTs; every type is file-typed and fixed-width.
|
|
/// </summary>
|
|
public enum AbLegacyDataType
|
|
{
|
|
/// <summary>B-file single bit (<c>B3:0/0</c>) or bit-within-N-file (<c>N7:0/3</c>).</summary>
|
|
Bit,
|
|
/// <summary>N-file integer (signed 16-bit).</summary>
|
|
Int,
|
|
/// <summary>L-file long integer — SLC 5/05+ only (signed 32-bit).</summary>
|
|
Long,
|
|
/// <summary>F-file float (32-bit IEEE-754).</summary>
|
|
Float,
|
|
/// <summary>A-file analog integer — some older hardware (signed 16-bit, semantically like N).</summary>
|
|
AnalogInt,
|
|
/// <summary>ST-file string (82-byte fixed-length + length word header).</summary>
|
|
String,
|
|
/// <summary>Timer sub-element — caller addresses <c>.ACC</c>, <c>.PRE</c>, <c>.EN</c>, <c>.DN</c>, <c>.TT</c>.</summary>
|
|
TimerElement,
|
|
/// <summary>Counter sub-element — caller addresses <c>.ACC</c>, <c>.PRE</c>, <c>.CU</c>, <c>.CD</c>, <c>.DN</c>.</summary>
|
|
CounterElement,
|
|
/// <summary>Control sub-element — caller addresses <c>.LEN</c>, <c>.POS</c>, <c>.EN</c>, <c>.DN</c>, <c>.ER</c>.</summary>
|
|
ControlElement,
|
|
}
|
|
|
|
/// <summary>Map a PCCC data type to the driver-surface <see cref="DriverDataType"/>.</summary>
|
|
public static class AbLegacyDataTypeExtensions
|
|
{
|
|
public static DriverDataType ToDriverDataType(this AbLegacyDataType t) => t switch
|
|
{
|
|
AbLegacyDataType.Bit => DriverDataType.Boolean,
|
|
AbLegacyDataType.Int or AbLegacyDataType.AnalogInt => DriverDataType.Int32,
|
|
AbLegacyDataType.Long => DriverDataType.Int32, // matches Modbus/AbCip 64→32 gap
|
|
AbLegacyDataType.Float => DriverDataType.Float32,
|
|
AbLegacyDataType.String => DriverDataType.String,
|
|
AbLegacyDataType.TimerElement or AbLegacyDataType.CounterElement
|
|
or AbLegacyDataType.ControlElement => DriverDataType.Int32,
|
|
_ => DriverDataType.Int32,
|
|
};
|
|
}
|