MRAS
Multi Rocket Avionics System
|
#include <Subsystem.h>
Public Member Functions | |
virtual const char * | get_name ()=0 |
virtual int8_t | setup ()=0 |
virtual int8_t | loop ()=0 |
uint8_t | get_id () const |
int8_t | get_status () const |
int8_t | self_test () const |
bool | add_subscriber (Subsystem *subscriber) |
Subsystem (uint8_t id) | |
Protected Member Functions | |
void | log (const char fmt[],...) |
virtual void | on_message (SystemMessage *msg)=0 |
void | publish (SystemMessage *msg) |
Static Protected Member Functions | |
static void | buzzer (uint16_t frequency, uint32_t duration, bool block=false) |
Protected Attributes | |
int8_t | status = 0 |
int8_t | self_test_result = -1 |
A Subsystem is a class in the MRAS system that represents a specific sensor or system on the device. These classes inherit from the base Subsystem class and implement its abstract methods. The Subsystem class provides a common interface for all sensors and systems, allowing for easy communication and management by the MRAS_System class.
The Subsystem class has several members that are used to define the behavior and functionality of the sensor or system it represents. These include setup() and loop() methods, which are used to initialize and continuously update the sensor or system, respectively. Additionally, Subsystems have a get_status() method to check the current status of the Subsystem, self_test() method to check that the Subsystem is working correctly and on_message() method to handle messages sent to the Subsystem. The get_name() method returns a string that provides a human-readable name for the Subsystem, used for logging and debugging purposes. Finally, the get_id() method returns a unique ID assigned to the Subsystem, which is used to identify it within the MRAS system.
|
inlineexplicit |
Constructor for Subsystem
id | The unique ID of the subsystem. This must be different for all subsystems. |
bool Subsystem::add_subscriber | ( | Subsystem * | subscriber | ) |
Add a new Subsystem subscriber to the Subsystem
The on_message() function of the subscribed Subsystem will be called whenever the publish() function is called with a SystemMessage. This allows for communication between Subsystems.
|
staticprotected |
Turn the buzzer on
duration | time period for which the buzzer should buzz, in seconds. |
uint8_t Subsystem::get_id | ( | ) | const |
|
pure virtual |
Get the name of the subsystem, used for logging purposes
Implemented in NativeTextLogger.
int8_t Subsystem::get_status | ( | ) | const |
|
pure virtual |
Implemented in Sensor_ZOEM8Q, and ArduinoTextLogger.
|
protectedpure virtual |
Can be overridden by Subsystems to handle messages
msg | The SystemMessage sent by the Publishing Subsystem |
Implemented in NativeDataLogger, SimulinkDataLogger, and StateEstimator.
|
protected |
Publish a SystemMessage to any subscribed Subsystems.
msg | THe SystemMessage to publish. |
int8_t Subsystem::self_test | ( | ) | const |
Run a self test.
|
pure virtual |
Implemented in ArduinoTextLogger.