WarpTwin
Documentation for WarpTwin models and classes.
Loading...
Searching...
No Matches
warptwin::SimScheduler Class Reference

Simple implementation of the scheduler class. More...

#include <SimScheduler.h>

Inheritance diagram for warptwin::SimScheduler:

Classes

struct  Params
 Signal name Type Default. More...
struct  Inputs
struct  Outputs

Public Member Functions

 SimScheduler (SimulationExecutive &executive)
 Constructor for the scheduler.
int16 startup () override
 Function to start and configure the scheduler prior to run.
int16 step (const clockwerk::Time &step_size=clockwerk::Time(0, 999999999+1)) override
 Function to step the scheduler by a single step.
int16 run () override
 Function to run the scheduler until pre-determined end conditions identified/calculated by the scheduler.
void connectExternalSocket (clockwerk::DataIOBase &signal, std::string mode, const std::string &ip, int port)
 Connect a signal to an external socket.
void connectExternalSharedMemory (clockwerk::DataIOBase &signal, std::string mode, const std::string shmem_address)
 Connect a signal to an external shared memory.
int16 registerApp (warpos::App &app, int16 slot) override
 Function to register apps with the scheduler. Depending on the scheduler implementation these may be unused.
const std::vector< warpos::App * > & allApps ()
 Handle to acquire access to all apps.
log_level_e logLevel ()
 Get the log level set for the executive.
void logLevel (log_level_e log_level)
 Set the executive log level.
Public Member Functions inherited from warpos::Scheduler
 Scheduler ()
 Constructor for the scheduler.
virtual int16 unregisterApp (int16 slot)
 Function to unregister a certain schedule slot.
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.

Public Attributes

Params params = Params(this, "params")
Inputs inputs = Inputs(this, "inputs")
Outputs outputs = Outputs(this, "outputs")
warptwin::SimTimeManager time
 Time manager to handle all time in the scheduler.

Protected Member Functions

int _executeAppThread (std::vector< warpos::App * > &app_thread)
 Function to execute a single app thread.
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

std::vector< warpos::App * > _all_apps
 Vectors to store the sequences for each element of the simulation scheduler.
std::vector< warpos::App * > _startup
std::vector< std::vector< warpos::App * > > _start_step
std::vector< std::vector< warpos::App * > > _derivative
std::vector< std::vector< warpos::App * > > _end_step
int16 _error
 Variable to catch errors from stuff.
SixDOFDynamicsModel _dynamics
 Our 6-DOF dynamics model.
ExternalInterfaceModel _external_interface
 Our external interface model.
bool _is_first_step = true
clockwerk::Time _sim_time_step
clockwerk::Time _real_time_step
clockwerk::Time _next_time
SimulationExecutiveexc
log_level_e _local_log_level = log_level_e::LOG_WARNING
 The log level for this particular app.
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

Simple implementation of the scheduler class.

This class is a base implementation of scheduler. It is an empty base class and cannot be used without implementation in a derived child class. The scheduler is used to execute modelsand apps in a sequence and format as defined in the derived scheduler class. Note: This scheduler is intended for use explicitly in simulation with the 6-DOF dynamics model. It manually adds the 6-DOF dynamics and uses it internally for time and integrator calculations.

Constructor & Destructor Documentation

◆ SimScheduler()

warptwin::SimScheduler::SimScheduler ( SimulationExecutive & executive)

Constructor for the scheduler.

Note
Does note resolve all dependencies - executive needs to be set

Member Function Documentation

◆ _executeAppThread()

int warptwin::SimScheduler::_executeAppThread ( std::vector< warpos::App * > & app_thread)
protected

Function to execute a single app thread.

Parameters
app_threadThe app thread to execute
Returns
Error code corresponding to success/failure

◆ allApps()

const std::vector< warpos::App * > & warptwin::SimScheduler::allApps ( )
inline

Handle to acquire access to all apps.

Returns
Vector containing all apps

◆ connectExternalSharedMemory()

void warptwin::SimScheduler::connectExternalSharedMemory ( clockwerk::DataIOBase & signal,
std::string mode,
const std::string shmem_address )
inline

Connect a signal to an external shared memory.

Parameters
signalThe signal to connect externally
modeThe mode (must be INPUT or OUTPUT) on which the signal is connected
shmem_addressThe shared memory location on which the signal is connected

◆ connectExternalSocket()

void warptwin::SimScheduler::connectExternalSocket ( clockwerk::DataIOBase & signal,
std::string mode,
const std::string & ip,
int port )
inline

Connect a signal to an external socket.

Parameters
signalThe signal to connect externally
modeThe mode (must be INPUT or OUTPUT) on which the signal is connected
ipThe IP address of the connection
portThe port for the connection

◆ logLevel() [1/2]

log_level_e warptwin::SimScheduler::logLevel ( )
inline

Get the log level set for the executive.

Returns
Log level for the executive

◆ logLevel() [2/2]

void warptwin::SimScheduler::logLevel ( log_level_e log_level)
inline

Set the executive log level.

Parameters
log_levelThe level to set logging to

◆ registerApp()

int16 warptwin::SimScheduler::registerApp ( warpos::App & app,
int16 slot )
overridevirtual

Function to register apps with the scheduler. Depending on the scheduler implementation these may be unused.

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

Reimplemented from warpos::Scheduler.

◆ run()

int16 warptwin::SimScheduler::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.

◆ startup()

int16 warptwin::SimScheduler::startup ( )
overridevirtual

Function to start and configure the scheduler prior to run.

Returns
Error code corresponding to success/failure

Reimplemented from warpos::Scheduler.

◆ step()

int16 warptwin::SimScheduler::step ( const clockwerk::Time & step_size = clockwerk::Time(0, 999999999 + 1))
overridevirtual

Function to step the scheduler by a single step.

Parameters
step_sizeThe step size (as a time object) to step the sim by. Any nsec value greater than NSEC_MAX will cause step to take the input step size, which is the default behavior. Setting time to a valid time will step by that time rather than the input value.
Returns
Error code corresponding to success/failure
Note
Overrides input step size parameter

Reimplemented from warpos::Scheduler.

Member Data Documentation

◆ _all_apps

std::vector<warpos::App*> warptwin::SimScheduler::_all_apps
protected

Vectors to store the sequences for each element of the simulation scheduler.

◆ _derivative

std::vector<std::vector<warpos::App*> > warptwin::SimScheduler::_derivative
protected

◆ _dynamics

SixDOFDynamicsModel warptwin::SimScheduler::_dynamics
protected

Our 6-DOF dynamics model.

◆ _end_step

std::vector<std::vector<warpos::App*> > warptwin::SimScheduler::_end_step
protected

◆ _error

int16 warptwin::SimScheduler::_error
protected

Variable to catch errors from stuff.

◆ _external_interface

ExternalInterfaceModel warptwin::SimScheduler::_external_interface
protected

Our external interface model.

◆ _is_first_step

bool warptwin::SimScheduler::_is_first_step = true
protected

◆ _local_log_level

log_level_e warptwin::SimScheduler::_local_log_level = log_level_e::LOG_WARNING
protected

The log level for this particular app.

◆ _next_time

clockwerk::Time warptwin::SimScheduler::_next_time
protected

◆ _real_time_step

clockwerk::Time warptwin::SimScheduler::_real_time_step
protected

◆ _sim_time_step

clockwerk::Time warptwin::SimScheduler::_sim_time_step
protected

◆ _start_step

std::vector<std::vector<warpos::App*> > warptwin::SimScheduler::_start_step
protected

◆ _startup

std::vector<warpos::App*> warptwin::SimScheduler::_startup
protected

◆ exc

SimulationExecutive& warptwin::SimScheduler::exc
protected

◆ inputs

Inputs warptwin::SimScheduler::inputs = Inputs(this, "inputs")

◆ outputs

Outputs warptwin::SimScheduler::outputs = Outputs(this, "outputs")

◆ params

Params warptwin::SimScheduler::params = Params(this, "params")

◆ time

warptwin::SimTimeManager warptwin::SimScheduler::time

Time manager to handle all time in the scheduler.


The documentation for this class was generated from the following files:
  • /Users/mickey/Documents/Projects/warptwin/cpp/src/simulation/SimScheduler.h
  • /Users/mickey/Documents/Projects/warptwin/cpp/src/simulation/SimScheduler.cpp