Skip to content

Data Types

Wire type definitions and the raw value encode/decode codec used by the configuration parser and by ComApClient directly.

pycomap.datatypes.DataType

Bases: IntEnum

ComAp DataTypeIdentifier enum.

pycomap.datatypes.ProtectionState

Bases: IntFlag

ComAp ProtectionState enum (ValueState.Level1/Level2/SensorFail).

Delay, Active, and NotConfirmed are combinable: Active | NotConfirmed (value 6) means the alarm is active but not yet acknowledged by the operator. Source: ComAp.Controller.DataTypes.ProtectionState in ComAp.Controller.dll.

pycomap.datatypes.decode_raw_value

decode_raw_value(
    data_type: DataType, raw: bytes, decimal_places: int = 0
) -> RawValue

Decode raw bytes (len(raw) == _DATA_TYPE_LENGTH[data_type]) per data_type.

Only numeric and binary(bitfield) types are decoded to Python numbers; string/domain/ timer/date types are returned as raw bytes.

pycomap.datatypes.encode_raw_value

encode_raw_value(
    data_type: DataType,
    value: int | float,
    decimal_places: int = 0,
) -> bytes

Encode value into the raw bytes decode_raw_value would decode it back from.

Only numeric and binary(bitfield) types can be encoded -- there's no encoder for string/domain/timer/date types (write raw bytes directly via client.write_object instead). The controller itself enforces the setpoint's min/max (returning ControllerError.BAD_WRITE_VALUE on rejection), so this doesn't validate limits.

pycomap.datatypes.decode_fdate

decode_fdate(raw: bytes) -> datetime.date | None

Decode a 3-byte FDate payload [BCD(day), BCD(month), BCD(year-2000)].

Returns None for invalid/unset values (all 0xFF, or day byte == 0).

pycomap.datatypes.encode_fdate

encode_fdate(date: date) -> bytes

Encode a datetime.date as a 3-byte FDate payload.

pycomap.datatypes.decode_ftime

decode_ftime(raw: bytes) -> datetime.time | None

Decode a 3-byte FTime payload [BCD(hour), BCD(minute), BCD(second)].

Returns None for invalid/unset values (hour byte ≥ 0x36 per source check).

pycomap.datatypes.encode_ftime

encode_ftime(time: time) -> bytes

Encode a datetime.time as a 3-byte FTime payload.