using ZB.MOM.WW.OtOpcUa.Core.Abstractions;
namespace ZB.MOM.WW.OtOpcUa.Driver.FOCAS;
///
/// FOCAS atomic data types. Narrower than Logix/IEC — FANUC CNCs expose mostly integer +
/// floating-point data with no UDT concept; macro variables are double-precision floats
/// and PMC reads return byte / signed word / signed dword.
///
public enum FocasDataType
{
/// Single bit (PMC bit, or bit within a CNC parameter).
Bit,
/// 8-bit signed byte (PMC 1-byte read).
Byte,
/// 16-bit signed word (PMC 2-byte read, or CNC parameter as short).
Int16,
/// 32-bit signed int (PMC 4-byte read, or CNC parameter as int).
Int32,
/// 32-bit IEEE-754 float (rare; some CNC macro variables).
Float32,
/// 64-bit IEEE-754 double (most macro variables are double-precision).
Float64,
/// ASCII string (alarm text, parameter names, some PMC string areas).
String,
}
public static class FocasDataTypeExtensions
{
public static DriverDataType ToDriverDataType(this FocasDataType t) => t switch
{
FocasDataType.Bit => DriverDataType.Boolean,
FocasDataType.Byte or FocasDataType.Int16 or FocasDataType.Int32 => DriverDataType.Int32,
FocasDataType.Float32 => DriverDataType.Float32,
FocasDataType.Float64 => DriverDataType.Float64,
FocasDataType.String => DriverDataType.String,
_ => DriverDataType.Int32,
};
}