This is the multi-page printable view of this section. Click here to print...

Return to the regular view of this page

As of 2026-10-02

mwings.parsers.app_pal_openclose Module

Parsers for packets sent from PAL App (Open/Close PAL) and data structures to store their contents.

    Parsers for packets sent from PAL App (Open/Close PAL) and data structures to store their contents.

    src/mwings/parsers/app_pal_openclose.py

    PacketParser

    Static class parser that interprets packets representing data sent from PAL App (Open/Close PAL).

    Inherits from: common.PacketParserBase

    is_valid()

    is_valid(bare_packet)

    Checks whether the given raw packet is valid.

    Parameters

    NameTypeDescription
    bare_packetcommon.BarePacketRaw packet data

    Returns

    TypeValueDescription
    boolTrueValid, parsable
    FalseInvalid, not parsable

    parse()

    parse(bare_packet)

    Parses the given raw packet.

    Parameters

    NameTypeDescription
    bare_packetcommon.BarePacketRaw packet data

    Returns

    TypeValueDescription
    optional ParsedPacketData of type ParsedPacketParsed data
    NoneParsing failed

    ParsedPacket

    Structure to store the result of parsing packets representing data sent from PAL App (Open/Close PAL).

    Inherits from: common.ParsedPacketBase

    ParsedPacket()

    ParsedPacket(*, time_parsed=None, packet_type=PacketType.BARE, sequence_number=None, source_serial_id=0, source_logical_id=0, lqi=None, supply_voltage=None, ai1_voltage=0, magnet_state=MagnetState.NOT_DETECTED, magnet_state_changed=False)

    Parameters

    Properties inherited from the base class are also listed.

    NameTypeDescription
    time_parsedoptional AwareDatetimeParsing time
    packet_typecommon.PacketTypePacket type
    sequence_numberoptional common.UInt16Sequence number
    source_serial_idcommon.UInt32Source serial ID
    source_logical_idcommon.UInt8Source logical device ID
    lqioptional common.UInt8Radio communication quality
    supply_voltageoptional common.UInt16Supply voltage (mV)
    router_serial_idcommon.UInt32Serial ID of the first relay device (0x80000000 if none) v1.0.13+
    ai1_voltagecommon.UInt16Voltage of AI1 (mV)
    magnet_statecommon.MagnetStateMagnet state
    magnet_state_changedboolWhether the magnet state has changed

    You can also pass a dictionary unpacked with **.

    to_df()

    to_df(include=None, exclude=None, verbose=True)

    Converts the parsed data into a pandas DataFrame.

    Parameters

    NameTypeDescription
    includeoptional set[str]Set of columns (members) to include in DataFrame
    excludeoptional set[str]Set of columns (members) to exclude from DataFrame
    verboseboolWhether to include system information (only when other args are None)

    Returns

    TypeValueDescription
    pd.DataFrame-Converted DataFrame

    Exceptions

    • EnvironmentError if pandas is not installed

    to_dict()

    to_dict(include=None, exclude=None, verbose=True, spread=False, sort_keys=False)

    Converts the parsed data into a dictionary.

    Parameters

    NameTypeDescription
    includeoptional set[str]Set of keys (members) to include in the dictionary
    excludeoptional set[str]Set of keys (members) to exclude from the dictionary
    verboseboolWhether to include system information (only when other args are None)
    spreadboolWhether to split non-time-series list-like data
    sort_keysboolWhether to sort by keys

    Returns

    TypeValueDescription
    dict[str, Any]-Converted dictionary

    to_json()

    to_json(include=None, exclude=None, verbose=True, spread=False, indent=2, sort_keys=False)

    Converts the parsed data into JSON format.

    Parameters

    NameTypeDescription
    includeoptional set[str]Set of keys (members) to include in JSON
    excludeoptional set[str]Set of keys (members) to exclude from JSON
    verboseboolWhether to include system information (only when other args are None)
    spreadboolWhether to split non-time-series list-like data
    indentoptional intNumber of spaces for indentation (None for no newline)
    sort_keysboolWhether to sort by keys

    Returns

    TypeValueDescription
    str-Converted JSON string

    model_*()