Class
Static
public static class StandardTableDefinitions
Namespace: SharpMeter.Core.Tables
Provides built-in TableDefinition instances for standard ANSI C12.19 tables.
Properties
| Name | Description |
|---|---|
All static |
Gets all built-in standard table definitions. |
ST0 static |
ST0: General Configuration Table (94 bytes). |
ST1 static |
ST1: General Manufacturer Identification Table (32 bytes). |
ST3 static |
ST3: End Device Mode and Status Table (5 bytes). |
ST5 static |
ST5: Device Identification Table (20 bytes). |
ST52 static |
ST52: Clock Table (7 bytes). |
ST8 static |
ST8: Procedure Response Table (16 bytes). |
All
IReadOnlyList<TableDefinition> StandardTableDefinitions.All { get; }
Gets all built-in standard table definitions.
ST0
TableDefinition StandardTableDefinitions.ST0 { get; }
ST0: General Configuration Table (94 bytes).
ST1
TableDefinition StandardTableDefinitions.ST1 { get; }
ST1: General Manufacturer Identification Table (32 bytes).
ST3
TableDefinition StandardTableDefinitions.ST3 { get; }
ST3: End Device Mode and Status Table (5 bytes).
ST5
TableDefinition StandardTableDefinitions.ST5 { get; }
ST5: Device Identification Table (20 bytes).
ST52
TableDefinition StandardTableDefinitions.ST52 { get; }
ST52: Clock Table (7 bytes).
ST8
TableDefinition StandardTableDefinitions.ST8 { get; }
ST8: Procedure Response Table (16 bytes).
Methods
| Name | Description |
|---|---|
GetByTableId(ushort tableId) static |
Gets a table definition by ID, or null if no built-in definition exists. |
GetByTableId(ushort tableId)
TableDefinition? StandardTableDefinitions.GetByTableId(ushort tableId)
Gets a table definition by ID, or null if no built-in definition exists.
Parameters
| Name | Type | Description |
|---|---|---|
tableId | ushort | The table ID. |
Returns: The table definition, or null.
View Source
/// <summary>
/// Provides built-in <see cref = "TableDefinition"/> instances for standard ANSI C12.19 tables.
/// </summary>
public static class StandardTableDefinitions
{
#region Standard Tables
/// <summary>ST0: General Configuration Table (94 bytes).</summary>
public static TableDefinition ST0 { get; } = new()
{
TableId = 0,
Name = "General Configuration Table",
Description = "Contains general meter configuration parameters including data format, table availability, and procedure support.",
ExpectedSize = 94,
Fields = [new TableFieldDefinition
{
Name = "FORMAT_CONTROL_1",
Offset = 0,
Size = 1,
Type = FieldType.BitField,
Description = "Data format control byte 1",
BitFields = [new BitFieldDefinition("DATA_ORDER", 0, 1, ImmutableDictionary.CreateRange(new[] { KeyValuePair.Create(0, "Little Endian"), KeyValuePair.Create(1, "Big Endian") })), new BitFieldDefinition("CHAR_FORMAT", 1, 3, ImmutableDictionary.CreateRange(new[] { KeyValuePair.Create(0, "Unassigned"), KeyValuePair.Create(1, "ISO 7-bit"), KeyValuePair.Create(2, "ISO Latin 1") })), new BitFieldDefinition("MODEL_SELECT", 4, 3, ImmutableDictionary.CreateRange(new[] { KeyValuePair.Create(0, "I/O Model") }))]
}, new TableFieldDefinition
{
Name = "FORMAT_CONTROL_2",
Offset = 1,
Size = 1,
Type = FieldType.BitField,
Description = "Data format control byte 2",
BitFields = [new BitFieldDefinition("TM_FORMAT", 0, 3, ImmutableDictionary.CreateRange(new[] { KeyValuePair.Create(0, "No Clock"), KeyValuePair.Create(1, "Clock with BSD"), KeyValuePair.Create(2, "Clock with UINT8"), KeyValuePair.Create(3, "Clock with UINT32") })), new BitFieldDefinition("DATA_ACCESS_METHOD", 3, 2, ImmutableDictionary.CreateRange(new[] { KeyValuePair.Create(0, "Full"), KeyValuePair.Create(1, "Full/Partial"), KeyValuePair.Create(2, "Full/Index"), KeyValuePair.Create(3, "Full/Partial/Index") })), new BitFieldDefinition("ID_FORM", 5, 1, ImmutableDictionary.CreateRange(new[] { KeyValuePair.Create(0, "String"), KeyValuePair.Create(1, "BCD") })), new BitFieldDefinition("INT_FORMAT", 6, 2, ImmutableDictionary.CreateRange(new[] { KeyValuePair.Create(0, "2s Complement"), KeyValuePair.Create(1, "1s Complement"), KeyValuePair.Create(2, "Sign/Magnitude") }))]
}, new TableFieldDefinition
{
Name = "FORMAT_CONTROL_3",
Offset = 2,
Size = 1,
Type = FieldType.BitField,
Description = "Numeric format control"
}, new TableFieldDefinition
{
Name = "DEVICE_CLASS",
Offset = 3,
Size = 4,
Type = FieldType.Ascii,
Description = "Device class identifier"
}, new TableFieldDefinition
{
Name = "NAMEPLATE_TYPE",
Offset = 7,
Size = 1,
Type = FieldType.Enum,
Description = "Meter utility type",
EnumValues = ImmutableDictionary.CreateRange(new[] { KeyValuePair.Create(0, "Gas"), KeyValuePair.Create(1, "Water"), KeyValuePair.Create(2, "Electric"), KeyValuePair.Create(3, "Dev") })
}, new TableFieldDefinition
{
Name = "DEFAULT_SET_USED",
Offset = 8,
Size = 1,
Type = FieldType.UInt8,
Description = "Default set in use"
}, new TableFieldDefinition
{
Name = "MAX_PROC_PARM_LENGTH",
Offset = 9,
Size = 1,
Type = FieldType.UInt8,
Description = "Max procedure parameter length"
}, new TableFieldDefinition
{
Name = "MAX_RESP_DATA_LEN",
Offset = 10,
Size = 1,
Type = FieldType.UInt8,
Description = "Max response data length"
}, new TableFieldDefinition
{
Name = "STD_VERSION_NO",
Offset = 11,
Size = 1,
Type = FieldType.UInt8,
Description = "Standard version number"
}, new TableFieldDefinition
{
Name = "STD_REVISION_NO",
Offset = 12,
Size = 1,
Type = FieldType.UInt8,
Description = "Standard revision number"
}, new TableFieldDefinition
{
Name = "DIM_STD_TBLS_USED",
Offset = 13,
Size = 1,
Type = FieldType.UInt8,
Description = "Dimension of standard tables used"
}, new TableFieldDefinition
{
Name = "DIM_MFG_TBLS_USED",
Offset = 14,
Size = 1,
Type = FieldType.UInt8,
Description = "Dimension of manufacturer tables used"
}, new TableFieldDefinition
{
Name = "DIM_STD_PROC_USED",
Offset = 15,
Size = 1,
Type = FieldType.UInt8,
Description = "Dimension of standard procedures used"
}, new TableFieldDefinition
{
Name = "DIM_MFG_PROC_USED",
Offset = 16,
Size = 1,
Type = FieldType.UInt8,
Description = "Dimension of manufacturer procedures used"
}, new TableFieldDefinition
{
Name = "DIM_MFG_STATUS_USED",
Offset = 17,
Size = 1,
Type = FieldType.UInt8,
Description = "Dimension of manufacturer status used"
}, new TableFieldDefinition
{
Name = "NBR_PENDING",
Offset = 18,
Size = 1,
Type = FieldType.UInt8,
Description = "Number of pending tables"
}, new TableFieldDefinition
{
Name = "STD_TBLS_USED",
Offset = 19,
Size = 15,
Type = FieldType.BitArray,
Description = "Bit map of available standard tables"
}, new TableFieldDefinition
{
Name = "MFG_TBLS_USED",
Offset = 34,
Size = 15,
Type = FieldType.BitArray,
Description = "Bit map of available manufacturer tables"
}, new TableFieldDefinition
{
Name = "STD_PROC_USED",
Offset = 49,
Size = 3,
Type = FieldType.BitArray,
Description = "Bit map of available standard procedures"
}, new TableFieldDefinition
{
Name = "MFG_PROC_USED",
Offset = 52,
Size = 12,
Type = FieldType.BitArray,
Description = "Bit map of available manufacturer procedures"
}, new TableFieldDefinition
{
Name = "STD_TBLS_WRITE",
Offset = 64,
Size = 15,
Type = FieldType.BitArray,
Description = "Bit map of writable standard tables"
}, new TableFieldDefinition
{
Name = "MFG_TBLS_WRITE",
Offset = 79,
Size = 15,
Type = FieldType.BitArray,
Description = "Bit map of writable manufacturer tables"
}
]
};
/// <summary>ST1: General Manufacturer Identification Table (32 bytes).</summary>
public static TableDefinition ST1 { get; } = new()
{
TableId = 1,
Name = "General Manufacturer Identification Table",
Description = "Contains manufacturer name, model, hardware/firmware versions, and serial number.",
ExpectedSize = 32,
Fields = [new TableFieldDefinition
{
Name = "MANUFACTURER",
Offset = 0,
Size = 4,
Type = FieldType.Ascii,
Description = "Manufacturer code (4 chars)"
}, new TableFieldDefinition
{
Name = "ED_MODEL",
Offset = 4,
Size = 8,
Type = FieldType.Ascii,
Description = "End device model (8 chars)"
}, new TableFieldDefinition
{
Name = "HW_VERSION_NUMBER",
Offset = 12,
Size = 1,
Type = FieldType.UInt8,
Description = "Hardware version number"
}, new TableFieldDefinition
{
Name = "HW_REVISION_NUMBER",
Offset = 13,
Size = 1,
Type = FieldType.UInt8,
Description = "Hardware revision number"
}, new TableFieldDefinition
{
Name = "FW_VERSION_NUMBER",
Offset = 14,
Size = 1,
Type = FieldType.UInt8,
Description = "Firmware version number"
}, new TableFieldDefinition
{
Name = "FW_REVISION_NUMBER",
Offset = 15,
Size = 1,
Type = FieldType.UInt8,
Description = "Firmware revision number"
}, new TableFieldDefinition
{
Name = "MFG_SERIAL_NUMBER",
Offset = 16,
Size = 16,
Type = FieldType.Ascii,
Description = "Manufacturer serial number (16 chars)"
}
]
};
/// <summary>ST3: End Device Mode and Status Table (5 bytes).</summary>
public static TableDefinition ST3 { get; } = new()
{
TableId = 3,
Name = "End Device Mode and Status Table",
Description = "Contains meter operational mode flags and standard/manufacturer status flags.",
ExpectedSize = 5,
Fields = [new TableFieldDefinition
{
Name = "ED_MODE",
Offset = 0,
Size = 1,
Type = FieldType.BitField,
Description = "Meter mode flags",
BitFields = [new BitFieldDefinition("METERING_FLAG", 0, 1), new BitFieldDefinition("TEST_MODE_FLAG", 1, 1), new BitFieldDefinition("METER_SHOP_MODE_FLAG", 2, 1), new BitFieldDefinition("FACTORY_FLAG", 3, 1)]
}, new TableFieldDefinition
{
Name = "ED_STD_STATUS1",
Offset = 1,
Size = 2,
Type = FieldType.BitField,
Description = "Standard status flags",
BitFields = [new BitFieldDefinition("UNPROGRAMMED_FLAG", 0, 1), new BitFieldDefinition("CONFIGURATION_ERROR_FLAG", 1, 1), new BitFieldDefinition("SELF_CHK_ERROR_FLAG", 2, 1), new BitFieldDefinition("RAM_FAILURE_FLAG", 3, 1), new BitFieldDefinition("ROM_FAILURE_FLAG", 4, 1), new BitFieldDefinition("NONVOL_MEM_FAILURE_FLAG", 5, 1), new BitFieldDefinition("CLOCK_ERROR_FLAG", 6, 1), new BitFieldDefinition("MEASUREMENT_ERROR_FLAG", 7, 1), new BitFieldDefinition("LOW_BATTERY_FLAG", 8, 1), new BitFieldDefinition("LOW_LOSS_POTENTIAL_FLAG", 9, 1), new BitFieldDefinition("DEMAND_OVERLOAD_FLAG", 10, 1), new BitFieldDefinition("POWER_FAILURE_FLAG", 11, 1), new BitFieldDefinition("TAMPER_DETECT_FLAG", 12, 1), new BitFieldDefinition("COVER_DETECT_FLAG", 13, 1)]
}, new TableFieldDefinition
{
Name = "ED_STD_STATUS2",
Offset = 3,
Size = 1,
Type = FieldType.Hex,
Description = "Standard status flags 2"
}, new TableFieldDefinition
{
Name = "ED_MFG_STATUS",
Offset = 4,
Size = 1,
Type = FieldType.BitField,
Description = "Manufacturer status flags",
BitFields = [new BitFieldDefinition("DSP_ERROR", 0, 1), new BitFieldDefinition("TIME_CHANGED", 1, 1), new BitFieldDefinition("SYSTEM_ERROR", 2, 1), new BitFieldDefinition("RECEIVED_KWH", 3, 1), new BitFieldDefinition("LEADING_KVARH", 4, 1), new BitFieldDefinition("LOSS_OF_PROGRAM", 5, 1), new BitFieldDefinition("HIGH_TEMPERATURE", 6, 1)]
}
]
};
/// <summary>ST5: Device Identification Table (20 bytes).</summary>
public static TableDefinition ST5 { get; } = new()
{
TableId = 5,
Name = "Device Identification Table",
Description = "Contains the meter identification string (serial number).",
ExpectedSize = 20,
Fields = [new TableFieldDefinition
{
Name = "METER_ID",
Offset = 0,
Size = 20,
Type = FieldType.Ascii,
Description = "Meter identification (20 chars)"
}
]
};
/// <summary>ST52: Clock Table (7 bytes).</summary>
public static TableDefinition ST52 { get; } = new()
{
TableId = 52,
Name = "Clock Table",
Description = "Contains the meter's current date, time, and time zone/DST qualifiers.",
ExpectedSize = 7,
Fields = [new TableFieldDefinition
{
Name = "YEAR",
Offset = 0,
Size = 1,
Type = FieldType.UInt8,
Description = "Year (offset from 2000)"
}, new TableFieldDefinition
{
Name = "MONTH",
Offset = 1,
Size = 1,
Type = FieldType.UInt8,
Description = "Month (1-12)"
}, new TableFieldDefinition
{
Name = "DAY",
Offset = 2,
Size = 1,
Type = FieldType.UInt8,
Description = "Day of month (1-31)"
}, new TableFieldDefinition
{
Name = "HOUR",
Offset = 3,
Size = 1,
Type = FieldType.UInt8,
Description = "Hour (0-23)"
}, new TableFieldDefinition
{
Name = "MINUTE",
Offset = 4,
Size = 1,
Type = FieldType.UInt8,
Description = "Minute (0-59)"
}, new TableFieldDefinition
{
Name = "SECOND",
Offset = 5,
Size = 1,
Type = FieldType.UInt8,
Description = "Second (0-59)"
}, new TableFieldDefinition
{
Name = "TIME_DATE_QUAL",
Offset = 6,
Size = 1,
Type = FieldType.BitField,
Description = "Time/date qualifier",
BitFields = [new BitFieldDefinition("DAY_OF_WEEK", 0, 3, ImmutableDictionary.CreateRange(new[] { KeyValuePair.Create(0, "Sunday"), KeyValuePair.Create(1, "Monday"), KeyValuePair.Create(2, "Tuesday"), KeyValuePair.Create(3, "Wednesday"), KeyValuePair.Create(4, "Thursday"), KeyValuePair.Create(5, "Friday"), KeyValuePair.Create(6, "Saturday") })), new BitFieldDefinition("DST_FLAG", 3, 1), new BitFieldDefinition("GMT_FLAG", 4, 1), new BitFieldDefinition("TM_ZN_APPLIED_FLAG", 5, 1), new BitFieldDefinition("DST_APPLIED_FLAG", 6, 1), new BitFieldDefinition("DST_SUPPORTED_FLAG", 7, 1)]
}
]
};
/// <summary>ST8: Procedure Response Table (16 bytes).</summary>
public static TableDefinition ST8 { get; } = new()
{
TableId = 8,
Name = "Procedure Response Table",
Description = "Contains the result of the last executed procedure.",
ExpectedSize = 16,
Fields = [new TableFieldDefinition
{
Name = "TBL_PROC_NBR",
Offset = 0,
Size = 2,
Type = FieldType.UInt16,
Description = "Procedure number"
}, new TableFieldDefinition
{
Name = "SEQ_NBR",
Offset = 2,
Size = 1,
Type = FieldType.UInt8,
Description = "Sequence number"
}, new TableFieldDefinition
{
Name = "RESULT_CODE",
Offset = 3,
Size = 1,
Type = FieldType.Enum,
Description = "Procedure result",
EnumValues = ImmutableDictionary.CreateRange(new[] { KeyValuePair.Create(0, "Completed"), KeyValuePair.Create(1, "Accepted"), KeyValuePair.Create(2, "Invalid Parameter"), KeyValuePair.Create(3, "Conflict"), KeyValuePair.Create(4, "Timed Out"), KeyValuePair.Create(5, "Unauthorized") })
}, new TableFieldDefinition
{
Name = "RESP_DATA",
Offset = 4,
Size = 12,
Type = FieldType.Hex,
Description = "Response data"
}
]
};
#endregion
#region Registry
/// <summary>
/// Gets a table definition by ID, or null if no built-in definition exists.
/// </summary>
/// <param name = "tableId">The table ID.</param>
/// <returns>The table definition, or null.</returns>
public static TableDefinition? GetByTableId(ushort tableId) => tableId switch
{
0 => ST0,
1 => ST1,
3 => ST3,
5 => ST5,
8 => ST8,
52 => ST52,
_ => null
};
/// <summary>
/// Gets all built-in standard table definitions.
/// </summary>
public static IReadOnlyList<TableDefinition> All { get; } = [ST0, ST1, ST3, ST5, ST8, ST52];
#endregion
}