MRAS
Multi Rocket Avionics System
Loading...
Searching...
No Matches
Subsystem Class Referenceabstract

#include <Subsystem.h>

Inheritance diagram for Subsystem:
Inheritance graph
Collaboration diagram for Subsystem:
Collaboration graph

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
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ Subsystem()

Subsystem::Subsystem ( uint8_t  id)
inlineexplicit

Constructor for Subsystem

Parameters
idThe unique ID of the subsystem. This must be different for all subsystems.

Member Function Documentation

◆ add_subscriber()

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.

Parameters
subscriberThe Subsystem to subscribe to this Subsystem
Returns
Whether the operation was successful or not. There is a limit to the number of subscribers to each Subsystem. At the moment, this is 255

◆ buzzer()

void Subsystem::buzzer ( uint16_t  frequency,
uint32_t  duration,
bool  block = false 
)
staticprotected

Turn the buzzer on

Parameters
durationtime period for which the buzzer should buzz, in seconds.

◆ get_id()

uint8_t Subsystem::get_id ( ) const
Returns
The unique subsystem ID

◆ get_name()

virtual const char * Subsystem::get_name ( )
pure virtual

Get the name of the subsystem, used for logging purposes

Returns
Unique name for the subsystem, such as "Accelerometer"

Implemented in NativeTextLogger.

◆ get_status()

int8_t Subsystem::get_status ( ) const
Returns
The current status of the system. 0 means no error, any other value represents an error.

◆ loop()

virtual int8_t Subsystem::loop ( )
pure virtual

Implemented in Sensor_ZOEM8Q, and ArduinoTextLogger.

◆ on_message()

virtual void Subsystem::on_message ( SystemMessage msg)
protectedpure virtual

Can be overridden by Subsystems to handle messages

Parameters
msgThe SystemMessage sent by the Publishing Subsystem

Implemented in NativeDataLogger, SimulinkDataLogger, and StateEstimator.

◆ publish()

void Subsystem::publish ( SystemMessage msg)
protected

Publish a SystemMessage to any subscribed Subsystems.

Parameters
msgTHe SystemMessage to publish.

◆ self_test()

int8_t Subsystem::self_test ( ) const

Run a self test.

Returns
-1 if the self test is not implemented. 0 if success. Any other value represents an error.

◆ setup()

virtual int8_t Subsystem::setup ( )
pure virtual

Implemented in ArduinoTextLogger.


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