WarpTwin
Documentation for WarpTwin models and classes.
Loading...
Searching...
No Matches
warpos::CommandManager Class Reference

This class routes commands from the HAL to associated Apps. More...

#include <CommandManager.h>

Inheritance diagram for warpos::CommandManager:

Classes

struct  Params

Public Member Functions

 CommandManager (FlightExecutive &exc)
 Only available flight executive constructor.
virtual ~CommandManager ()
int16 registerCmdPacket (App *cmd_app, uint16 cmd_apid)
 Register a command with the command manager.
int16 command (uint16 apid, uint8 *buffer, uint16 size) override
 Process commands issued to the app.
uint16 numRegisteredPackets ()
 Get the number of registered command packets.
Public Member Functions inherited from warpos::App
 App (FlightExecutive &executive, const char *name, uint16 apid, uint8 instance=0)
 Executive-based constructor for the task.
virtual ~App ()
 Destructor. Doesn't really do anything.
int16 startup ()
 Initialize the app. Should be called once before step.
int16 step ()
 Step the app by a single step. Maps params, inputs, etc. to outputs.
virtual int16 activate ()
 Activate the app. The app will step when active.
virtual int16 deactivate ()
 Deactivate the app. The app will not step when deactivated.
log_level_e logLevel ()
 Get the log level set for the executive.
void logLevel (log_level_e log_level)
 Set the executive log level.
bool isStarted ()
 Return whether task startup has been run.
uint16 apid ()
 Get the apid for this app.
uint8 & instance ()
 Get the instance of this app (used to differentiate between multiple instances of the same app).
Public Member Functions inherited from clockwerk::GraphTreeObject
 GraphTreeObject (const char *gt_nme="", GraphTreeObject **storage_array=nullptr, uint32 storage_size=0)
 Name-based constructor for GraphTreeObject which will have no children by default.
virtual ~GraphTreeObject ()
 Destructor.
GraphTreeObjectparent ()
 Functions to get object's parent/children.
GraphTreeObject ** children ()
GraphTreeObjectchildAtIndex (uint8 i) const
int16 parent (GraphTreeObject *new_parent)
 Function to assign the node's parent via pointer.
int16 parent (GraphTreeObject &new_parent)
 Function to assign the node's parent via reference.
uint8 nChildren () const
 Getters for number of children and descendants.
uint16 nDescendants () const
uint8 capacity () const
const char * name () const
 Getter and setter for object name.
int16 name (const char *new_name)
uint8 rank ()
 Getter for the object rank.
int8 type ()
 Function to indicate type – -1 by default unless implemented downstream.
bool loggable ()
 Getter for object logability flag – note no setter because should only be set by this or a derived class in its definition.
GraphTreeObjectgetRootDataPointer ()
 Get the pointer to the highest object in the graph tree.
virtual int16 str (char *output, size_t size) const
 Get object represented as string.
virtual int16 fromStr (const char *val)
 Set value of graphtreeobject from string.

Public Attributes

Params params = Params(this, "params")
Public Attributes inherited from warpos::App
clockwerk::DataIO< bool > active = clockwerk::DataIO<bool>(this, "active", true)
 The active flag for the task – set to true by default.

Protected Member Functions

int16 start () override
int16 execute () override
int16 handleCommands ()
 Function to handle ingesting and routing commands.
bool ingestCommand ()
 Function to ingest commands from the HAL.
bool scanForHeader ()
 Scans through the bytes in the command buffer for a valid CCSDS header.
int16 routeCommand (App *cmd_app_ptr, uint16 apid, uint8 instance, uint8 *buffer, uint16 length)
 Routes a command to an associated app.
int16 softResetCmd (uint8 *buffer, uint16 size)
 Function to handle a received softResetCommand.
int16 logLevelCmd (uint8 *buffer, uint16 size)
 Function to handle LogLevel change commands.
int16 scheduleCmd (uint8 *buffer, uint16 size)
 Function to handle Schedule change commands.
int16 activateCmd (uint8 *buffer, uint16 size)
 Function to handle activate commands.
int16 deactivateCmd (uint8 *buffer, uint16 size)
 Function to handle a deactivate command.
Protected Member Functions inherited from clockwerk::GraphTreeObject
int16 _setStorage (GraphTreeObject **storage_array, uint8 storage_size)
 Getter for object's string address.
void _recalculateDescendants ()
 Function to recursively re-calculate the number of descendants of a given node on the tree.
void _recalculateRank ()
 Function to recursively re-calculate the rank of a given node on the tree.
int16 _addChild (GraphTreeObject *child)
 Function to decompose a string into a series of substrings via indexing.
int16 _removeChild (GraphTreeObject *child)
 Function to remove a child from the graph node's children.

Protected Attributes

RegisteredCommandInfo _reg_cmd_table [100]
 Table of registered commands.
clockwerk::Time _last_read_time
 Last time bytes were read from input hw queue.
uint16 _cmd_table_idx = 0
 Current index in the command table.
clockwerk::CircularBuffer< uint8, 256 > _cmd_input_byte_buff
 Buffer of bytes input from hardware device.
uint8 _ccsds_data [CCSDS_FULL_HDR_LEN_BYTES]
 Buffer to hold CCSDS header data when processing commands.
uint16 _exc_error_count = 0
 Counters for various command manager stats, used in telemetry.
uint16 _pkt_not_registered_count = 0
 Count of commands received for unregistered packets.
uint16 _crc_error_count = 0
 Count of commands received with CRC errors.
uint16 _timeout_count = 0
 Count of times the command queue has been cleared due to timeout.
uint16 _successful_cmd_count = 0
 Count of successfully processed commands.
tlm_cmd_mngr_error _tlm_cmd_mngr_error
 Telemetry Definitions.
tlm_cmd_mngr_status _tlm_cmd_mngr_status
 Command manager status telemetry packet.
Protected Attributes inherited from warpos::App
FlightExecutiveexc
 Override our executive to include the FlightExecutive instead.
int16 _error = 0
 Internal variable to track and return error on app step through.
uint16 _apid = 0
 Internal variable to hold the APID for this app.
bool _is_started = false
 Flag indicating whether app has been started or not.
log_level_e _local_log_level = log_level_e::LOG_WARNING
 The log level for this particular app.
GraphTreeObject_app_children [MAXIMUM_APP_CHILDREN]
 Local storage for App children so it can live on the graph tree.
uint8 _instance
 Instance number of this app. Used to differentiate between multiple instances of the same app.
Protected Attributes inherited from clockwerk::GraphTreeObject
GraphTreeObject_parent = nullptr
GraphTreeObject ** _children_ptr = nullptr
uint32 _max_num_children = 0
uint16 _num_descendants = 0
char _name [MAXIMUM_NAME_CHARS] = ""
 String name for object.
uint8 _num_children = 0
 Number of direct children of the tree (not including the tree itself).
uint8 _rank = 0
int8 _graph_tree_type = BASE_GRAPH_TREE
 Variable to store graph tree object type.
bool _loggable = false
 Variable to indicate whether the selected object is loggable. Set to false by default.
uint32 _index = 0
 Index pointing to the next write location for the graph tree children.

Detailed Description

This class routes commands from the HAL to associated Apps.

The class allows for apps to register their APID, then when the HAL receives commands, this class pulls data from it, checks for a valid CCSDS header, length, APID, and CRC before passing the command to the registered app.

Parameters
queue_clear_timeoutdefines time the system waits before deleting partial command

Constructor & Destructor Documentation

◆ CommandManager()

warpos::CommandManager::CommandManager ( FlightExecutive & exc)

Only available flight executive constructor.

Parameters
excPointer to executive object
setupHandle to hardware setup for writeCommand
Note
Implicitly names task "command". Cannot have any other name

◆ ~CommandManager()

warpos::CommandManager::~CommandManager ( )
virtual

Member Function Documentation

◆ activateCmd()

int16 warpos::CommandManager::activateCmd ( uint8 * buffer,
uint16 size )
protected

Function to handle activate commands.

Parameters
bufferpointer to buffer of data
sizeSize of data
Returns
Error code corresponding to success/failure

◆ command()

int16 warpos::CommandManager::command ( uint16 apid,
uint8 * buffer,
uint16 size )
overridevirtual

Process commands issued to the app.

Parameters
apidThe apid of the command to execute
bufferThe buffer of command data
sizeThe size of the command data buffer
Returns
Flag indicating success/failure

Reimplemented from warpos::App.

◆ deactivateCmd()

int16 warpos::CommandManager::deactivateCmd ( uint8 * buffer,
uint16 size )
protected

Function to handle a deactivate command.

Parameters
bufferpointer to buffer of data
sizeSize of data
Returns
Error code corresponding to success/failure

◆ execute()

int16 warpos::CommandManager::execute ( )
overrideprotectedvirtual

Reimplemented from warpos::App.

◆ handleCommands()

int16 warpos::CommandManager::handleCommands ( )
protected

Function to handle ingesting and routing commands.

Returns
Error code indication success/failure

◆ ingestCommand()

bool warpos::CommandManager::ingestCommand ( )
protected

Function to ingest commands from the HAL.

Return values
TRUEif bytes were read
FALSEif bytes were not read

◆ logLevelCmd()

int16 warpos::CommandManager::logLevelCmd ( uint8 * buffer,
uint16 size )
protected

Function to handle LogLevel change commands.

Parameters
bufferpointer to buffer of data
sizeSize of data
Returns
Error code corresponding to success/failure

◆ numRegisteredPackets()

uint16 warpos::CommandManager::numRegisteredPackets ( )
inline

Get the number of registered command packets.

Returns
Number of registered command packets

◆ registerCmdPacket()

int16 warpos::CommandManager::registerCmdPacket ( App * cmd_app,
uint16 cmd_apid )

Register a command with the command manager.

Parameters
cmd_appThe app which will execute the command
cmd_apidThe APID of the command
Returns
Error code corresponding to success/failure

◆ routeCommand()

int16 warpos::CommandManager::routeCommand ( App * cmd_app_ptr,
uint16 apid,
uint8 instance,
uint8 * buffer,
uint16 length )
protected

Routes a command to an associated app.

Returns
Error code indicating success/failure

◆ scanForHeader()

bool warpos::CommandManager::scanForHeader ( )
protected

Scans through the bytes in the command buffer for a valid CCSDS header.

Returns
True if a valid header was found, false otherwise

◆ scheduleCmd()

int16 warpos::CommandManager::scheduleCmd ( uint8 * buffer,
uint16 size )
protected

Function to handle Schedule change commands.

Parameters
bufferpointer to buffer of data
sizeSize of data
Returns
Error code corresponding to success/failure

◆ softResetCmd()

int16 warpos::CommandManager::softResetCmd ( uint8 * buffer,
uint16 size )
protected

Function to handle a received softResetCommand.

Parameters
bufferpointer to buffer of data
sizeSize of data
Returns
Error code corresponding to success/failure

◆ start()

int16 warpos::CommandManager::start ( )
overrideprotectedvirtual

Reimplemented from warpos::App.

Member Data Documentation

◆ _ccsds_data

uint8 warpos::CommandManager::_ccsds_data[CCSDS_FULL_HDR_LEN_BYTES]
protected

Buffer to hold CCSDS header data when processing commands.

◆ _cmd_input_byte_buff

clockwerk::CircularBuffer<uint8, 256 > warpos::CommandManager::_cmd_input_byte_buff
protected

Buffer of bytes input from hardware device.

◆ _cmd_table_idx

uint16 warpos::CommandManager::_cmd_table_idx = 0
protected

Current index in the command table.

◆ _crc_error_count

uint16 warpos::CommandManager::_crc_error_count = 0
protected

Count of commands received with CRC errors.

◆ _exc_error_count

uint16 warpos::CommandManager::_exc_error_count = 0
protected

Counters for various command manager stats, used in telemetry.

Count of command execution errors

◆ _last_read_time

clockwerk::Time warpos::CommandManager::_last_read_time
protected

Last time bytes were read from input hw queue.

◆ _pkt_not_registered_count

uint16 warpos::CommandManager::_pkt_not_registered_count = 0
protected

Count of commands received for unregistered packets.

◆ _reg_cmd_table

RegisteredCommandInfo warpos::CommandManager::_reg_cmd_table[100]
protected

Table of registered commands.

◆ _successful_cmd_count

uint16 warpos::CommandManager::_successful_cmd_count = 0
protected

Count of successfully processed commands.

◆ _timeout_count

uint16 warpos::CommandManager::_timeout_count = 0
protected

Count of times the command queue has been cleared due to timeout.

◆ _tlm_cmd_mngr_error

tlm_cmd_mngr_error warpos::CommandManager::_tlm_cmd_mngr_error
protected

Telemetry Definitions.

Command manager error telemetry packet

◆ _tlm_cmd_mngr_status

tlm_cmd_mngr_status warpos::CommandManager::_tlm_cmd_mngr_status
protected

Command manager status telemetry packet.

◆ params

Params warpos::CommandManager::params = Params(this, "params")

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