namespace ZB.MOM.WW.OtOpcUa.Driver.TwinCAT;

/// <summary>
///     TwinCAT / IEC 61131-3 atomic data types. Wider type surface than Logix because IEC adds
///     <c>WSTRING</c> (UTF-16) and <c>TIME</c>/<c>DATE</c>/<c>DT</c>/<c>TOD</c> variants.
/// </summary>
public enum TwinCATDataType
{
    Bool,
    SInt,   // signed 8-bit
    USInt,  // unsigned 8-bit
    Int,    // signed 16-bit
    UInt,   // unsigned 16-bit
    DInt,   // signed 32-bit
    UDInt,  // unsigned 32-bit
    LInt,   // signed 64-bit
    ULInt,  // unsigned 64-bit
    Real,   // 32-bit IEEE-754
    LReal,  // 64-bit IEEE-754
    String, // ASCII string
    WString,// UTF-16 string
    // IEC 61131-3 / TwinCAT temporal types — all stored on the wire as 32-bit unsigned (UDINT)
    // raw counters. The driver surfaces them as DriverDataType.UInt32, so
    // operators see the raw counter, not a decoded date/duration. Proper decoding to
    // DriverDataType.DateTime is a future enhancement; until then comments accurately describe
    // the on-wire encoding so the next implementer doesn't re-derive it wrong.
    Time,   // TIME — duration in milliseconds, stored as UDINT (32-bit unsigned)
    Date,   // DATE — seconds since 1970-01-01 truncated to a day boundary, stored as UDINT
    DateTime, // DT (DATE_AND_TIME) — seconds since 1970-01-01, stored as UDINT
    TimeOfDay,// TOD — milliseconds since midnight, stored as UDINT
    /// <summary>
    /// UDT / FB instance. Used internally by <c>DiscoverAsync</c> when browsing controller
    /// symbols — members are resolved to atomic types and emitted individually. Must not be
    /// used in pre-declared tags (rejected at initialisation by the factory with
    /// <see cref="InvalidOperationException"/>) or in AdminUI equipment-tag configs (the typed
    /// editor does not offer it; the parser falls back to <c>DInt</c>).
    /// </summary>
    Structure,
}
