![]() |
ModelSpace
|
Base model class for derived implementation. More...
#include <Model.h>
Public Member Functions | |
Model () | |
Default constructor for the task object for simplicity. Note: Masks some functionality and should not be used for production deployment. | |
Model (Model &pnt, const std::string &m_name="Unnamed") | |
Task-based constructor for the task. Auto-assigns executive. | |
Model (SimulationExecutive &executive, const std::string &m_name="Unnamed") | |
Executive-based constructor for the task. | |
Model (Model &pnt, int schedule_slot, const std::string &m_name="Unnamed") | |
Task-based constructor for the task. Auto-assigns executive. | |
Model (SimulationExecutive &executive, int schedule_slot, const std::string &m_name="Unnamed") | |
Executive-based constructor for the task. | |
virtual | ~Model () |
Desrtuctor. Doesn't really do anything. | |
int | startup () |
Function to perform startup activities (step once at start after creation). Should not be modified in derived task. | |
virtual int | step () |
Function to step the task. This will be called every step. | |
virtual int | activate () |
Function to activate the task. | |
virtual int | deactivate () |
Function to deactivate the task. | |
void | recordTiming () |
Function to command this task to record timing information. | |
void | logLevel (log_level_e new_level) |
Function to set the local model log level. | |
GraphTreeObject * | parent () |
Functions to get object's parent/children. | |
int | parent (GraphTreeObject *new_parent) |
Function to assign the node's parent via pointer. | |
int | parent (GraphTreeObject &new_parent) |
Function to assign the node's parent via reference. | |
std::vector< GraphTreeObject * > & | children () |
unsigned int | nChildren () |
Getters for number of children and descendants. | |
unsigned int | nDescendants () |
std::string | name () const |
Getter and setter for object name. | |
int | name (const std::string &new_name) |
int | rank () |
Getter for the object rank. | |
virtual int | 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. | |
std::string | address () |
Getter for object's string address. | |
std::vector< std::string > | search (const std::string &address) |
Function to search through the graph tree by string address. | |
GraphTreeObject * | getByAddress (const std::string &address) |
Function to get an object from the graph tree by string address. | |
void | dump (bool recursive=false) |
Function to dump the graph node, optionally including descendents. | |
void | graphNodeInfo () |
Function to return all info associated with a given graph node. | |
void | recurseGraphNodeInfo (unsigned int counter) |
Function to recurse through graph tree and print all node info. | |
virtual int | header (void *logger) |
Function to pass headers for this object to the logger. | |
virtual std::vector< std::string > | header_info () const |
void | findLoggable (std::vector< GraphTreeObject * > &matches) |
Function to find all loggable parameters in this node and its children. | |
virtual int | log (void *logger) |
Function to log data to a logger. | |
void | lock (bool recursive=true) |
Function to lock the graph tree object and its children to changes. | |
void | unlock (bool recursive=true) |
Function to unlock the graph tree and its children for changes. | |
bool | locked () |
Function to return whether graph tree object is locked. | |
Public Attributes | |
DataIO< bool > | active = DataIO<bool>(this, "active", true) |
The active flag for the task – set to true by default. | |
DataIO< int > | schedule_slot = DataIO<int>(this, "schedule_slot", 0) |
The schedule slot this task will step in – set to 0 by default. | |
DataIO< Time > | entry_time = DataIO<Time>(this, "entry_time", Time()) |
Time of entry (per wallClockTimer) of the last step of this task. | |
DataIO< Time > | exit_time = DataIO<Time>(this, "exit_time", Time()) |
Time of exit (per wallClockTimer) of the last step of this task. | |
Protected Member Functions | |
virtual int | start () |
Function to perform task startup activities (step once after creation) | |
virtual int | execute () |
Function to execute the task. All math and calculations should be here. | |
int | rangeCheck (double min, double max, DataIO< double > signal) |
Overloaded function to check range on a parameter. | |
int | rangeCheck (float min, float max, DataIO< float > signal) |
int | rangeCheck (int min, int max, DataIO< int > signal) |
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. | |
std::vector< std::string > | decomposeAddress (std::string address) |
Function to decompose a string into a series of substrings via indexing. | |
void | findMatches (const std::vector< std::string > &subaddresses, const unsigned int &num_subaddresses, unsigned int index, bool match_found, std::vector< GraphTreeObject * > &matches) |
Function to find all addresses mathcing the set of substrings @parem subaddresses A vector of subaddresses to match. | |
std::vector< GraphTreeObject * > | searchNodes (const std::string &address) |
Function to search through the graph tree by string address. | |
int | addChild (GraphTreeObject *child) |
Function to add a child to the graph tree object. | |
int | removeChild (GraphTreeObject *child) |
Function to remove a child from the graph node's children. | |
Protected Attributes | |
SimulationExecutive * | exc = nullptr |
Override our executive to include the SimulationExecutive instead. Models will work with the SimulationExecutive per Alex decision 5/2024. In all other respects they will be identical to tasks. | |
log_level_e | _local_log_level = NONE |
Our local log level – allows a higher log level locally than the overall system. | |
int | _error = 0 |
Simple variable to track error in task. | |
bool | _record_timing = false |
Variable to enable or disable timing. | |
GraphTreeObject * | _parent = nullptr |
Pointer to the object's parent – should be null if the object is the root. Is set to null by default. | |
std::vector< GraphTreeObject * > | _children |
Pointers to the object's children – automatically set to an empty vector, and can be increased to any size. | |
std::string | _name = DEFAULT_NAME |
String name for object. | |
uint16_t | _num_descendants = 0 |
Total number of descendants (includes children of children) of the tree, again not including the tree itself. | |
uint8_t | _num_children = 0 |
Number of direct children of the tree (not including the tree itself) | |
uint8_t | _rank = 0 |
Rank for how far down on the graph tree the object is – starts at zero and maxes out at 256 via variable size. | |
uint8_t | _graph_tree_type = BASE_GRAPH_TREE |
Variable to store graph tree object type. | |
bool | _locked = false |
Variable to lock the graph tree object and prevent structural updates. | |
bool | _loggable = false |
Variable to indicate whether the selected object is loggable. Set to false by default. | |
Base model class for derived implementation.
This is the base model class, which should be implemented in derived models via class inheritence. It is designed around the "black box" design of models, where each model is given startup parameters, inputs, and outputs as defined:
PARAMETERS: Configuration flags which should be carefully controlled and only modified at few, select events (i.e. not every timestep) INPUTS: Input parameters to the model which may, but do not have to, change often. These will often be connected to the outputs of other models. OUTPUTS: Output parameters from the model which are the result of an internal calculation in the model.
Functions are created in the base model class to be implemented in the derived model. Each of the following may be left unmodified, in which case they will do nothing. Functions should only be modified if the developer wants them to do something. Once implemented, the functions will be called automatically by the model and should not be invoked directly.
Functionally, Model is no different than Task. However, Models are configured for simulation specifically to work with the SimulationExecutive. This makes a number of model features easier to use at the expense of making them non- embedded C++.
modelspace::Model::Model | ( | Model & | pnt, |
const std::string & | m_name = "Unnamed" |
||
) |
Task-based constructor for the task. Auto-assigns executive.
pnt | The task to assign as parent of this task |
nme | Name of the task |
modelspace::Model::Model | ( | SimulationExecutive & | executive, |
const std::string & | m_name = "Unnamed" |
||
) |
Executive-based constructor for the task.
executive | The executive to set |
m_name | The name for the task |
modelspace::Model::Model | ( | Model & | pnt, |
int | schedule_slot, | ||
const std::string & | m_name = "Unnamed" |
||
) |
Task-based constructor for the task. Auto-assigns executive.
pnt | The task to assign as parent of this task |
nme | Name of the task |
schedule_slot | The slot to which the task should be scheduled. Negative indicates it should not be scheduled. Default is to schedule for ALL steps. |
modelspace::Model::Model | ( | SimulationExecutive & | executive, |
int | schedule_slot, | ||
const std::string & | m_name = "Unnamed" |
||
) |
Executive-based constructor for the task.
executive | The executive to set |
m_name | The name for the task |
schedule_slot | The slot to which the task should be scheduled. Negative indicates it should not be scheduled. Default is to schedule for ALL steps. |
|
inlinevirtualinherited |
Function to activate the task.
|
protectedinherited |
Function to add a child to the graph tree object.
child | A pointer to the graph tree object to add to the tree |
|
inherited |
Getter for object's string address.
|
inlinevirtualinherited |
Function to deactivate the task.
|
protectedinherited |
Function to decompose a string into a series of substrings via indexing.
address | The address to be decomposed |
Function to dump the graph node, optionally including descendents.
recursive | Parameter indicating whether to dump only one node (default/false) or the entire tree (true) |
|
inlineprotectedvirtualinherited |
Function to execute the task. All math and calculations should be here.
Reimplemented in clockwerk::PidAttitudeControl, clockwerk::PidTranslationalControl, clockwerk::IterativeLambertTargetTask, clockwerk::LambertTargetTask, clockwerk::TriadGuidance, clockwerk::EkfFocalAnglesMeasUpdate, clockwerk::EkfOrbitJ2J3Update, clockwerk::EkfOrbitStateRelState, clockwerk::EkfRangeRangerateMeasUpdate, clockwerk::SimpleDiscreteProcessNoise, modelspace::LogEvent, modelspace::SimTerminationEvent, modelspace::CR3BPDynamicsModel, modelspace::FlatPlateDragModel, modelspace::ImpulseModel, modelspace::SimpleThrusterModel, modelspace::TimedImpulsiveBurnModel, modelspace::SpicePlanet, modelspace::AsphericalGravityModel, modelspace::GravityGradientModel, modelspace::PointMassGravityModel, modelspace::SolarRadiationPressureModel, modelspace::SphericalHarmonicsGravityModel, modelspace::SolarPanelPowerModel, modelspace::Accelerometer, modelspace::GroundStationSensor, modelspace::Gyro, modelspace::SimpleCameraSensor, modelspace::StarTracker, modelspace::FrameStateSensorModel, modelspace::GroundStationModel, modelspace::LvcStateSensorModel, modelspace::OrbitalElementsSensorModel, modelspace::PlanetRelativeStatesModel, modelspace::RangeAzElSensorModel, modelspace::BiasNoiseModel, modelspace::EffectiveSolarAreaModel, modelspace::LvlhFrameManagerModel, modelspace::SixDOFDynamicsModel, modelspace::SynodicFrameManagerModel, modelspace::ProximityMonitor, modelspace::RateMonitor, modelspace::TimeTriggerMonitor, and modelspace::VisualsModel.
|
inherited |
Function to find all loggable parameters in this node and its children.
matches | Expandable vector to hold all matches in the tree |
|
protectedinherited |
Function to find all addresses mathcing the set of substrings @parem subaddresses A vector of subaddresses to match.
num_subaddresses | The number of subaddresses to match |
index | The index of subaddresses to search in |
match_found | Variable indicating whether a match was found higher in the tree |
matches | Implicit return of all matches to the specified address |
|
inherited |
Function to get an object from the graph tree by string address.
address | The exact string address to access the variable with |
|
inlinevirtualinherited |
Function to pass headers for this object to the logger.
logger | Pointer to logger |
Reimplemented in clockwerk::DataIO< T >, clockwerk::DataIO< bool >, clockwerk::DataIO< clockwerk::Body< double > * >, clockwerk::DataIO< clockwerk::Body< T > * >, clockwerk::DataIO< clockwerk::CartesianVector< double, 2 > >, clockwerk::DataIO< clockwerk::CartesianVector< double, 3 > >, clockwerk::DataIO< clockwerk::CartesianVector< T, 3 > >, clockwerk::DataIO< clockwerk::Euler321< double > >, clockwerk::DataIO< clockwerk::Frame< double > * >, clockwerk::DataIO< clockwerk::Frame< T > * >, clockwerk::DataIO< clockwerk::Matrix< double, 2, 2 > >, clockwerk::DataIO< clockwerk::Matrix< double, 3, 3 > >, clockwerk::DataIO< clockwerk::Matrix< double, 6, 3 > >, clockwerk::DataIO< clockwerk::Matrix< double, 6, 6 > >, clockwerk::DataIO< clockwerk::Matrix< T, 3, 3 > >, clockwerk::DataIO< clockwerk::Node< double > * >, clockwerk::DataIO< clockwerk::Quaternion< double > >, clockwerk::DataIO< clockwerk::Quaternion< T > >, clockwerk::DataIO< clockwerk::Time >, clockwerk::DataIO< double >, clockwerk::DataIO< int >, clockwerk::DataIO< modelspace::integrator_type_e >, clockwerk::DataIO< std::string >, and clockwerk::DataIO< void * >.
|
inlinevirtualinherited |
Reimplemented in clockwerk::Time.
Function to lock the graph tree object and its children to changes.
recursive | Flag to indicate whether lock should be recursive |
|
inlinevirtualinherited |
Function to log data to a logger.
logger | Pointer to logger |
Reimplemented in clockwerk::Time, clockwerk::DataIO< T >, clockwerk::DataIO< bool >, clockwerk::DataIO< clockwerk::Body< double > * >, clockwerk::DataIO< clockwerk::Body< T > * >, clockwerk::DataIO< clockwerk::CartesianVector< double, 2 > >, clockwerk::DataIO< clockwerk::CartesianVector< double, 3 > >, clockwerk::DataIO< clockwerk::CartesianVector< T, 3 > >, clockwerk::DataIO< clockwerk::Euler321< double > >, clockwerk::DataIO< clockwerk::Frame< double > * >, clockwerk::DataIO< clockwerk::Frame< T > * >, clockwerk::DataIO< clockwerk::Matrix< double, 2, 2 > >, clockwerk::DataIO< clockwerk::Matrix< double, 3, 3 > >, clockwerk::DataIO< clockwerk::Matrix< double, 6, 3 > >, clockwerk::DataIO< clockwerk::Matrix< double, 6, 6 > >, clockwerk::DataIO< clockwerk::Matrix< T, 3, 3 > >, clockwerk::DataIO< clockwerk::Node< double > * >, clockwerk::DataIO< clockwerk::Quaternion< double > >, clockwerk::DataIO< clockwerk::Quaternion< T > >, clockwerk::DataIO< clockwerk::Time >, clockwerk::DataIO< double >, clockwerk::DataIO< int >, clockwerk::DataIO< modelspace::integrator_type_e >, clockwerk::DataIO< std::string >, and clockwerk::DataIO< void * >.
|
inlineinherited |
Function to set the local model log level.
new_level | The new level to set logging to |
|
inherited |
Function to assign the node's parent via reference.
new_parent | The new parent to assign the node to |
|
inherited |
Function to assign the node's parent via pointer.
new_parent | The new parent to assign the node to |
Function to recurse through graph tree and print all node info.
|
protectedinherited |
Function to remove a child from the graph node's children.
child | The child to remove |
|
inherited |
Function to search through the graph tree by string address.
address | `The address or address chunk to search for |
|
protectedinherited |
Function to search through the graph tree by string address.
address | `The address or address chunk to search for |
|
inlineprotectedvirtualinherited |
Function to perform task startup activities (step once after creation)
Reimplemented in clockwerk::EkfFocalAnglesMeasUpdate, clockwerk::EkfOrbitJ2J3Update, clockwerk::EkfOrbitStateRelState, clockwerk::EkfRangeRangerateMeasUpdate, modelspace::LogEvent, modelspace::CR3BPDynamicsModel, modelspace::SimpleThrusterModel, modelspace::TimedImpulsiveBurnModel, modelspace::PlanetInfo, modelspace::SimplePlanet, modelspace::SimpleSpacecraft, modelspace::SpicePlanet, modelspace::AsphericalGravityModel, modelspace::SphericalHarmonicsGravityModel, modelspace::Accelerometer, modelspace::GroundStationSensor, modelspace::Gyro, modelspace::IMU, modelspace::SimpleCameraSensor, modelspace::StarTracker, modelspace::FrameStateSensorModel, modelspace::GroundStationModel, modelspace::OrbitalElementsStateInit, modelspace::PlanetRelativeStatesModel, modelspace::BiasNoiseModel, modelspace::LvlhFrameManagerModel, modelspace::SixDOFDynamicsModel, modelspace::SynodicFrameManagerModel, and modelspace::VisualsModel.
|
inherited |
Function to perform startup activities (step once at start after creation). Should not be modified in derived task.
|
virtualinherited |
Function to step the task. This will be called every step.
Reimplemented in clockwerk::Monitor, and clockwerk::Event.
|
inlinevirtualinherited |
Function to indicate type – -1 by default unless implemented downstream.
Function to unlock the graph tree and its children for changes.
recursive | Flag to indicate whether unlock should be recursive |