STAR
Cal STAR — firmware, DAQ server, and engine design
Loading...
Searching...
No Matches
daq::SensorDataChunkCollection Struct Reference

Represents a single data chunk with timestamp and sensor datapoints. More...

#include <DiabloPackets.h>

Collaboration diagram for daq::SensorDataChunkCollection:
[legend]

Public Member Functions

 SensorDataChunkCollection (uint32_t ts, uint8_t num_sensors)
 Constructor with timestamp.
bool add_datapoint (uint8_t sensor_id, uint32_t data)
 Add a sensor datapoint to this chunk.
size_t size () const
 Get the number of datapoints in this chunk.
bool empty () const
 Check if the chunk is empty.
bool full () const
 Check if the chunk is full.
void clear ()
 Clear all datapoints from this chunk.

Public Attributes

uint32_t timestamp
std::vector< SensorDatapoint > datapoints
uint8_t num_sensors

Detailed Description

Represents a single data chunk with timestamp and sensor datapoints.

This struct represents one data chunk containing a timestamp and a vector with num_sensors datapoints. It's used for collecting sensor data before serializing into network packets.

Note
This is NOT a packed struct as it's used for data collection, not network transmission. Use the packed SensorDataChunk for network packets.

Definition at line 98 of file DiabloPackets.h.

Constructor & Destructor Documentation

◆ SensorDataChunkCollection()

daq::SensorDataChunkCollection::SensorDataChunkCollection ( uint32_t ts,
uint8_t num_sensors )
inline

Constructor with timestamp.

Parameters
tsThe timestamp for this data chunk
num_sensorsThe number of sensor datapoints for this chunk

Definition at line 108 of file DiabloPackets.h.

References num_sensors, and timestamp.

Member Function Documentation

◆ add_datapoint()

bool daq::SensorDataChunkCollection::add_datapoint ( uint8_t sensor_id,
uint32_t data )
inline

Add a sensor datapoint to this chunk.

Parameters
sensor_idThe ID of the sensor
dataThe sensor reading value
Returns
True if successfully added, false if array is full

Definition at line 116 of file DiabloPackets.h.

References datapoints, and num_sensors.

Referenced by test_sensor_data_buffer_too_small(), and test_sensor_data_roundtrip().

◆ clear()

void daq::SensorDataChunkCollection::clear ( )
inline

Clear all datapoints from this chunk.

Definition at line 145 of file DiabloPackets.h.

References datapoints.

◆ empty()

bool daq::SensorDataChunkCollection::empty ( ) const
inline

Check if the chunk is empty.

Returns
True if no datapoints, false otherwise

Definition at line 134 of file DiabloPackets.h.

References datapoints.

◆ full()

bool daq::SensorDataChunkCollection::full ( ) const
inline

Check if the chunk is full.

Returns
True if at maximum capacity, false otherwise

Definition at line 140 of file DiabloPackets.h.

References datapoints, and num_sensors.

◆ size()

size_t daq::SensorDataChunkCollection::size ( ) const
inline

Get the number of datapoints in this chunk.

Returns
The number of datapoints

Definition at line 128 of file DiabloPackets.h.

References datapoints.

Member Data Documentation

◆ datapoints

std::vector<SensorDatapoint> daq::SensorDataChunkCollection::datapoints

Definition at line 100 of file DiabloPackets.h.

Referenced by add_datapoint(), clear(), empty(), full(), daq::parse_sensor_data_packet(), and size().

◆ num_sensors

uint8_t daq::SensorDataChunkCollection::num_sensors

Definition at line 101 of file DiabloPackets.h.

Referenced by add_datapoint(), full(), and SensorDataChunkCollection().

◆ timestamp

uint32_t daq::SensorDataChunkCollection::timestamp

The documentation for this struct was generated from the following file: