WarpTwin
Documentation for WarpTwin models and classes.
Loading...
Searching...
No Matches
warpos::TableScheduler< N > Class Template Reference

Simple, table-based scheduler for flight software. More...

#include <TableScheduler.hpp>

Inheritance diagram for warpos::TableScheduler< N >:

Public Member Functions

 TableScheduler (OS &os)
 Constructor for the scheduler.
 ~TableScheduler ()
virtual int16 startup () override
 Start the table scheduler.
virtual int16 step (const clockwerk::Time &step_val) override
 Function to execute a single table schedule slot.
virtual int16 run () override
 Function to run the scheduler until pre-determined end conditions identified/calculated by the scheduler.
virtual int16 registerApp (App &app, int16 slot) override
 Register an app with the table scheduler.
virtual int16 unregisterApp (int16 slot) override
 Function to unregister a certain schedule slot.
uint8 taskFailures ()
 Get number of task failures.
uint16 currentSlot ()
 Get the current schedule slot (executed previous step).
uint8 scheduleExceedances ()
 Get the number of schedule exceedances.
const tlm_executive_schedule_overrunlastExceedance ()
 Return the last task to exceed its slot.
const tlm_executive_app_errorlastTaskFailure ()
 Get handle to record of last failure.
const clockwerk::TimetimePerSlot ()
 Get the time per slot.
const ApplastAppRun ()
 Get handle to the last app run.
Public Member Functions inherited from warpos::Scheduler
 Scheduler ()
 Constructor for the scheduler.
void terminate ()
 Terminate the scheduler.
bool isTerminated ()
 Get whether scheduler is terminated.
void setExecutive (FlightExecutive *exc)
 Set the flight executive for the scheduler.
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.

Protected Member Functions

uint16 _getNextSlot (uint16 current_slot)
 Return schedule slot after current one.
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

OS_os
 Handle to the os from which we pull system time.
App_schedule_array [N]
 Array to hold the actual schedule slot.
bool _scheduler_initialized = false
 Flag indicating whether time has been initialized.
int16 _current_slot = 0
 The current schedule slot to execute.
int16 _end_slot = 0
 The slot where schedule run ended.
uint32 _nsec_per_slot = clockwerk::NSEC_PER_SEC_I/N
 The number of nsec allocated per slot.
clockwerk::Time _step_size
 The step size as a clockwerk time.
int16 _error = 0
 Variable to catch errors out of runs.
char _print_buf [200]
tlm_executive_app_error _tlm_error
tlm_executive_schedule_overrun _tlm_overrun
Protected Attributes inherited from warpos::Scheduler
bool _is_terminated = false
 Flag to indicate whether the scheduler is terminated.
FlightExecutive_exc_ptr
 Pointer to the executive which may optionally be registered with scheduler.
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

template<int16 N>
class warpos::TableScheduler< N >

Simple, table-based scheduler for flight software.

The TableScheduler is an ultra simple, table-based scheduler instance for running tasks in soft real time on embedded systems. It is templated to have N schedule slots, which are distributed among steps of 1 second.

To add a task to the schedule, call scheduleTask with the task or app and the desired schedule slot. By default tasks are scheduled to take exactly one slot. However, a task may be programmed to take more than one schedule slot by programming it sequentially (in back to back slots).

The TableScheduler is fixed to full second boundaries in the system time, and will return warning until it is allowed to start on a full second boundary. Afterwards, timing is based on the partial seconds in the full second.

Inside of TableScheduler run, the scheduler is designed to call os yield between steps to allow lower priority tasks outside the table scheduler to run.

Constructor & Destructor Documentation

◆ TableScheduler()

template<int16 N>
warpos::TableScheduler< N >::TableScheduler ( OS & os)

Constructor for the scheduler.

Parameters
osReference to the OS object

◆ ~TableScheduler()

template<int16 N>
warpos::TableScheduler< N >::~TableScheduler ( )
inline

Member Function Documentation

◆ _getNextSlot()

template<int16 N>
uint16 warpos::TableScheduler< N >::_getNextSlot ( uint16 current_slot)
protected

Return schedule slot after current one.

Parameters
current_slotThe current slot
Returns
The int indicating the next slot

◆ currentSlot()

template<int16 N>
uint16 warpos::TableScheduler< N >::currentSlot ( )
inline

Get the current schedule slot (executed previous step).

Returns
The current slot

◆ lastAppRun()

template<int16 N>
const App * warpos::TableScheduler< N >::lastAppRun ( )
inline

Get handle to the last app run.

Returns
The last app run by the scheduler

◆ lastExceedance()

template<int16 N>
const tlm_executive_schedule_overrun & warpos::TableScheduler< N >::lastExceedance ( )
inline

Return the last task to exceed its slot.

Returns
Last task to exceed its slot

◆ lastTaskFailure()

template<int16 N>
const tlm_executive_app_error & warpos::TableScheduler< N >::lastTaskFailure ( )
inline

Get handle to record of last failure.

Returns
Handle to last failure

◆ registerApp()

template<int16 N>
int16 warpos::TableScheduler< N >::registerApp ( App & app,
int16 slot )
overridevirtual

Register an app with the table scheduler.

Parameters
appThe app to register
schedule_slotThe slot to register the app to
Returns
Error code corresponding to success/failure

Reimplemented from warpos::Scheduler.

◆ run()

template<int16 N>
int16 warpos::TableScheduler< N >::run ( )
overridevirtual

Function to run the scheduler until pre-determined end conditions identified/calculated by the scheduler.

Returns
Error code corresponding to success/failure
Note
The scheduler MUST define stopping conditions. Otherwise, will run indefinitely

Reimplemented from warpos::Scheduler.

◆ scheduleExceedances()

template<int16 N>
uint8 warpos::TableScheduler< N >::scheduleExceedances ( )
inline

Get the number of schedule exceedances.

Returns
The number of exceedances

◆ startup()

template<int16 N>
int16 warpos::TableScheduler< N >::startup ( )
overridevirtual

Start the table scheduler.

Returns
Error code corresponding to success/failure

Reimplemented from warpos::Scheduler.

◆ step()

template<int16 N>
int16 warpos::TableScheduler< N >::step ( const clockwerk::Time & step_val)
overridevirtual

Function to execute a single table schedule slot.

Parameters
ref_timeThe current time, which is used to determine the slot which runs
Returns
Error code corresponding to success/failure

Reimplemented from warpos::Scheduler.

◆ taskFailures()

template<int16 N>
uint8 warpos::TableScheduler< N >::taskFailures ( )
inline

Get number of task failures.

Returns
Number of task failures

◆ timePerSlot()

template<int16 N>
const clockwerk::Time & warpos::TableScheduler< N >::timePerSlot ( )
inline

Get the time per slot.

Returns
Time per slot as clockwerk::Time

◆ unregisterApp()

template<int16 N>
int16 warpos::TableScheduler< N >::unregisterApp ( int16 slot)
overridevirtual

Function to unregister a certain schedule slot.

Parameters
slotSlot to unregister
Returns
Error code corresponding to success/failure

Reimplemented from warpos::Scheduler.

Member Data Documentation

◆ _current_slot

template<int16 N>
int16 warpos::TableScheduler< N >::_current_slot = 0
protected

The current schedule slot to execute.

◆ _end_slot

template<int16 N>
int16 warpos::TableScheduler< N >::_end_slot = 0
protected

The slot where schedule run ended.

◆ _error

template<int16 N>
int16 warpos::TableScheduler< N >::_error = 0
protected

Variable to catch errors out of runs.

◆ _nsec_per_slot

template<int16 N>
uint32 warpos::TableScheduler< N >::_nsec_per_slot = clockwerk::NSEC_PER_SEC_I/N
protected

The number of nsec allocated per slot.

◆ _os

template<int16 N>
OS& warpos::TableScheduler< N >::_os
protected

Handle to the os from which we pull system time.

◆ _print_buf

template<int16 N>
char warpos::TableScheduler< N >::_print_buf[200]
protected

◆ _schedule_array

template<int16 N>
App* warpos::TableScheduler< N >::_schedule_array[N]
protected

Array to hold the actual schedule slot.

◆ _scheduler_initialized

template<int16 N>
bool warpos::TableScheduler< N >::_scheduler_initialized = false
protected

Flag indicating whether time has been initialized.

◆ _step_size

template<int16 N>
clockwerk::Time warpos::TableScheduler< N >::_step_size
protected

The step size as a clockwerk time.

◆ _tlm_error

template<int16 N>
tlm_executive_app_error warpos::TableScheduler< N >::_tlm_error
protected

◆ _tlm_overrun

template<int16 N>
tlm_executive_schedule_overrun warpos::TableScheduler< N >::_tlm_overrun
protected

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