/      日本語

mwings.parsers.app_pal_mot Module

Parsers for packets sent from PAL App (Motion PAL) or CUE App in Motion PAL Mode (accelerometer measurement).

Parsers for packets sent from PAL App (Motion PAL) or CUE App in Motion PAL Mode (accelerometer measurement), and data structures to store the parsed information.

src/mwings/parsers/app_pal_mot.py

PacketParser

A static class parser that interprets packets representing data sent from PAL App (Motion PAL) or CUE App (Motion PAL Mode: accelerometer measurement).

Inherits: common.PacketParserBase

is_valid()

is_valid(bare_packet)

Checks whether the given bare packet is valid.

Arguments

NameTypeDescription
bare_packetcommon.BarePacketRaw packet data

Returns

TypeValueDescription
boolTrueValid, parsable
FalseInvalid, not parsable

parse()

parse(bare_packet)

Parses the given bare packet.

Arguments

NameTypeDescription
bare_packetcommon.BarePacketRaw packet data

Returns

TypeValueDescription
optional ParsedPacketParsedPacket instanceParsed data
NoneParsing failed

ParsedPacket

A data structure to store the result of parsing packets sent from PAL App (Motion PAL) or CUE App (Motion PAL Mode: accelerometer measurement).

Inherits: 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, sample_count=16, samples_x=<mwings.common.TimeSeries object>, samples_y=<mwings.common.TimeSeries object>, samples_z=<mwings.common.TimeSeries object>, sampling_frequency=25)

Arguments

Including properties inherited from the base class.

NameTypeDescription
time_parsedoptional AwareDatetimeParsing timestamp
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)
sample_countcommon.UInt8Number of acceleration samples per axis
samples_xcommon.TimeSeries[common.Int16]Acceleration samples on X axis
samples_ycommon.TimeSeries[common.Int16]Acceleration samples on Y axis
samples_zcommon.TimeSeries[common.Int16]Acceleration samples on Z axis
sampling_frequencycommon.UInt16Acceleration sampling frequency

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.

Arguments

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

Returns

TypeDescription
pd.DataFrameConverted 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.

Arguments

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 effective if other arguments are None)
spreadboolWhether to split non-time-series list-like data
sort_keysboolWhether to sort keys

Returns

TypeDescription
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.

Arguments

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

Returns

TypeDescription
strConverted JSON string

model_*()