ASCEND Flight Software
All Classes Files Functions Variables Enumerations Enumerator Macros Pages
Public Member Functions | Protected Attributes | Private Attributes | List of all members
Sensor Class Referenceabstract

Parent class for sensor objects. More...

#include <Sensor.h>

Inheritance diagram for Sensor:
Collaboration diagram for Sensor:

Public Member Functions

 Sensor (String sensor_name, String csv_header, unsigned long minimum_period)
 
 Sensor (String sensor_name, String csv_header)
 
 Sensor (String sensor_name, String csv_header, int fields)
 Construct a new Sensor object with default minimum_period of 0 (depreciated)
 
 Sensor (String sensor_name, String csv_header, int fields, unsigned long minimum_period)
 Construct a new Sensor object (Depreciated)
 
unsigned long getPeriod () const
 Get the minimum minimum_period between sensor reads in ms.
 
void setPeriod (int minimum_period)
 Set the minimum minimum_period between sensor reads in ms.
 
unsigned long getLastExecution () const
 Get the system time of the last execution in ms.
 
void setLastExecution (int last_execution)
 Set the system time of the last execution in ms.
 
const String & getSensorCSVHeader () const
 Get the csv header string associated with this sensor.
 
virtual bool verify ()=0
 Verifies if the sensor is connected and working.
 
virtual String readData ()=0
 Returns the collected data from the sensor in CSV format.
 
virtual void readDataPacket (uint8_t *&packet)
 Used for creating packets, reads data from the sensor and appends it to the passed uint8_t array pointer, incrementing it while doing so.
 
virtual String decodeToCSV (uint8_t *&packet)
 Used for onboard decoding of packets.
 
void getDataPacket (uint32_t &sensor_id, uint8_t *&packet)
 Append the data from a sensor to the packet if the minium period is satisfied.
 
String readEmpty () const
 Returns CSV line in the same format as readData() but with "-" instead of data.
 
String getDataCSV ()
 Uses readData and readEmpty to get the data-filled or empty-celled CSV line for the sensor.
 
- Public Member Functions inherited from Device
 Device (String device_name)
 Default constructor, sets a max_attempt of 1 (device recovery won't be attempted)
 
 Device (String device_name, int max_attempts, int wait_factor)
 
const String & getDeviceName ()
 
bool getVerified ()
 Get if the Device is Verified.
 
void recoveryConfig (int max_attempts, int wait_factor)
 Set recovery config (used keep default constructor)
 
void setWaitFactor (int wait_factor)
 Set wait_factor.
 
void setMaxAttempts (int max_attempts)
 Set max_attempts.
 
bool attemptConnection ()
 If the sensor is verified, return true, if not and it has been long enough since the last attempt (decided by wait_factor and attempt_number), attempt to reverify (reinitialize) it.
 

Protected Attributes

int num_fields
 
- Protected Attributes inherited from Device
bool verified
 
String device_name
 

Private Attributes

unsigned long minimum_period
 
unsigned long last_execution
 
String csv_header
 
String empty_csv
 

Detailed Description

Parent class for sensor objects.

Constructor & Destructor Documentation

◆ Sensor() [1/4]

Sensor::Sensor ( String  sensor_name,
String  csv_header,
unsigned long  minimum_period 
)
inline

◆ Sensor() [2/4]

Sensor::Sensor ( String  sensor_name,
String  csv_header 
)
inline

◆ Sensor() [3/4]

Sensor::Sensor ( String  sensor_name,
String  csv_header,
int  fields 
)
inline

Construct a new Sensor object with default minimum_period of 0 (depreciated)

Parameters
sensor_nameThe name of the sensor
csv_headerThe header for the sensor's csv cells
fieldsnumber of csv cells the sensor will return

◆ Sensor() [4/4]

Sensor::Sensor ( String  sensor_name,
String  csv_header,
int  fields,
unsigned long  minimum_period 
)
inline

Construct a new Sensor object (Depreciated)

Parameters
sensor_nameThe name of the sensor
csv_headerThe header for the sensor's csv cells
fieldsnumber of csv cells the sensor will return
minimum_periodSet the minimum time between sensor reads in ms

Member Function Documentation

◆ decodeToCSV()

virtual String Sensor::decodeToCSV ( uint8_t *&  packet)
inlinevirtual

Used for onboard decoding of packets.

Parameters
packetPointer to the packet byte array
Returns
String The senors data decoded from the packet in csv format

Reimplemented in TMP117Sensor, AS7331Sensor, BME280Sensor, BME680Sensor, BMP390Sensor, DS3231Sensor, ENS160Sensor, ICM20948Sensor, INA260Sensor, LSM9DS1Sensor, MTK3339Sensor, OzoneSensor, PCF8523Sensor, SCD40Sensor, SGP30Sensor, SHTC3Sensor, and TempSensor.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getDataCSV()

String Sensor::getDataCSV ( )
inline

Uses readData and readEmpty to get the data-filled or empty-celled CSV line for the sensor.

Returns
String
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getDataPacket()

void Sensor::getDataPacket ( uint32_t &  sensor_id,
uint8_t *&  packet 
)
inline

Append the data from a sensor to the packet if the minium period is satisfied.

Parameters
sensor_idHeader sensor packet section
packetPointer to the packet byte array
Returns
int The number of bytes appended
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getLastExecution()

unsigned long Sensor::getLastExecution ( ) const
inline

Get the system time of the last execution in ms.

Returns
unsigned long

◆ getPeriod()

unsigned long Sensor::getPeriod ( ) const
inline

Get the minimum minimum_period between sensor reads in ms.

Returns
unsigned long

◆ getSensorCSVHeader()

const String & Sensor::getSensorCSVHeader ( ) const
inline

Get the csv header string associated with this sensor.

Returns
const String&
Here is the caller graph for this function:

◆ readData()

virtual String Sensor::readData ( )
pure virtual

Returns the collected data from the sensor in CSV format.

Returns
String

Implemented in TMP117Sensor, AS7331Sensor, BME280Sensor, BME680Sensor, BMP390Sensor, DS3231Sensor, ENS160Sensor, ICM20948Sensor, INA260Sensor, LSM9DS1Sensor, MTK3339Sensor, OzoneSensor, PCF8523Sensor, SCD40Sensor, SGP30Sensor, SHTC3Sensor, and TempSensor.

Here is the caller graph for this function:

◆ readDataPacket()

virtual void Sensor::readDataPacket ( uint8_t *&  packet)
inlinevirtual

Used for creating packets, reads data from the sensor and appends it to the passed uint8_t array pointer, incrementing it while doing so.

Parameters
packetPointer to the packet byte array
Returns
int The number of bytes appended

Reimplemented in TMP117Sensor, AS7331Sensor, BME280Sensor, BME680Sensor, BMP390Sensor, DS3231Sensor, ENS160Sensor, ICM20948Sensor, INA260Sensor, LSM9DS1Sensor, MTK3339Sensor, OzoneSensor, PCF8523Sensor, SCD40Sensor, SGP30Sensor, SHTC3Sensor, and TempSensor.

Here is the caller graph for this function:

◆ readEmpty()

String Sensor::readEmpty ( ) const
inline

Returns CSV line in the same format as readData() but with "-" instead of data.

Returns
String
Here is the caller graph for this function:

◆ setLastExecution()

void Sensor::setLastExecution ( int  last_execution)
inline

Set the system time of the last execution in ms.

Parameters
last_executionSystem time of last execution in ms

◆ setPeriod()

void Sensor::setPeriod ( int  minimum_period)
inline

Set the minimum minimum_period between sensor reads in ms.

Parameters
minimum_periodThe new minimum_period in ms

◆ verify()

virtual bool Sensor::verify ( )
pure virtual

Verifies if the sensor is connected and working.

Returns
true, if connected
false, if not connected

Implements Device.

Implemented in TMP117Sensor, AS7331Sensor, BME280Sensor, BME680Sensor, BMP390Sensor, DS3231Sensor, ENS160Sensor, ICM20948Sensor, INA260Sensor, LSM9DS1Sensor, MTK3339Sensor, OzoneSensor, PCF8523Sensor, SCD40Sensor, SGP30Sensor, SHTC3Sensor, and TempSensor.

Member Data Documentation

◆ csv_header

String Sensor::csv_header
private

◆ empty_csv

String Sensor::empty_csv
private

◆ last_execution

unsigned long Sensor::last_execution
private

◆ minimum_period

unsigned long Sensor::minimum_period
private

◆ num_fields

int Sensor::num_fields
protected

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