The TwePacketPal
class interprets TWELITE PAL packet data. This class handles TWELITE PAL (sensor data and other upstream data) commonly.
PAL common data is defined in DataPal
.
Generator functions are provided to retrieve data specific to each PAL sensor board.
Although the packet data structure of PAL differs depending on the connected sensors, etc., DataPal
holds the data structure of the common part.
The PAL packet data structure consists of two blocks: the common part for all PALs and the individual data part. The individual data part does not interpret the packet, but stores it as is. To simplify handling, data exceeding 32 bytes is stored in dynamically allocated uptr_snsdata
.
The individual data parts are stored in a structure whose base class is PalBase
. This structure is generated by the generator function defined in TwePacketPal
.
If the size fits in MWX_PARSER_PKT_APPPAL_FIXED_BUF
when parse<TwePacketPAL>()
is executed, a separate sensor object is generated.
If it does not fit, a reference to the byte sequence used for analysis is stored in au8snsdata
. In this case, if the data in the byte string used for analysis is rewritten, sensor-specific objects cannot be generated.
All data structures for each sensor in PAL inherit from PalBase
. The sensor data storage status u32StoredMask
is included.
PAL events are information that is sent when certain conditions are met by processing sensor information, rather than directly from sensors. For example, when an acceleration sensor detects a certain level of acceleration from a stationary state.
If event data exists, it can be determined by .is_PalEvent()
of TwePacketPal
being true
, and .get_PalEvent()
will yield a PalEvent
data structure.
Generator functions are used to extract various types of data from sensor PAL.
To use the generator function, first determine if pkt
is an event (.is_PalEvent()
). If it is an event, it has get_PalEvent()
. Otherwise, it creates an object according to u8palpcb
.
If .u8palpcb==E_PAL_PCB::MAG
, the data PalMag
of the open/close sensor pal is taken.
If .u8palpcb==E_PAL_PCB::AMB
, the data PalAmb
of the environmental sensor pal is taken.
If .u8palpcb==E_PAL_PCB::MOT
, the data PalMot
of the operating sensor pal is taken.
Extracts a PalEvent
(PAL event) if .is_PalEvent()
is true
.