![]() |
ModelSpace
|
Implementation of the executive class for simulation. More...
#include <SimulationExecutive.h>
Public Member Functions | |
SimulationExecutive () | |
Constructor for the simulation executive. | |
int | parseArgs (int argc, char *argv[]) |
Wrapper around arg parse. | |
int | parseArgs (std::vector< std::string > arguments) |
Wrapper around arg parse. | |
void | integrator (int val) |
Functions to set and get our integrator. | |
int | integrator () |
void | setRateHz (unsigned int rate_hz) |
Function to set the simulation run rate, in Hz. | |
void | setRateSec (clockwerk::Time rate_sec) |
Function to set the simulation run rate, in seconds as Time. | |
void | setRateSec (struct timespec rate_sec) |
void | setRateSec (double rate_sec) |
void | end (clockwerk::Time end_time) |
Overloaded function to set the simulation end time. | |
void | end (struct timespec end_time) |
void | end (double end_time) |
clockwerk::Time | end () |
Function to return simulation end time. | |
int | startup () |
Function to initialize our simulation executive and everything it contains. | |
int | step () |
Function to step the scheduler by a single step. | |
int | step (const clockwerk::Time &step_size) |
Function to step the scheduler by a single step. | |
int | run () |
/ | |
clockwerk::Time | rate () |
Function to acces the run rate of the simulation. | |
clockwerk::Frame< double > * | rootFrame () |
Getter for the simulation root frame. | |
std::vector< std::string > | search (const std::string &s_val) |
Function to search the simulation and frame trees for a match. | |
std::vector< std::string > | searchFrameTree (const std::string &s_val) |
Function to search the frame tree for a match. | |
std::vector< std::string > | searchSimTree (const std::string &s_val) |
Function to search the simulation architecture tree for a match. | |
modelspace::LogManager * | logManager () |
Getter for the log manager. | |
void | addLog (clockwerk::SimLogger &log, unsigned int rate) |
Overloaded function to register and set up a logger. | |
void | addLog (clockwerk::SimLogger &log, clockwerk::Monitor &monitor) |
Overloaded function to register and set up a logger. | |
modelspace::SimScheduler * | schedule () |
Getter for the schedule. | |
modelspace::VisualsModel * | visualsModel () |
Getter for the visuals model. | |
void | enableVisuals () |
Function to enable visuals for the simulation. | |
void | disableVisuals () |
Function to disable visuals for the simulation. | |
void | logLevel (clockwerk::log_level_e new_level) |
Function to set the local model log level. | |
bool | isTerminated () |
Returns termination flag. | |
unsigned int | runNumber () |
Getter for run number. | |
void | runNumber (unsigned int run_num) |
Setter for run number. | |
modelspace::ArgParser * | args () |
Function to access args. | |
modelspace::DispersionEngine * | dispersions () |
Function to access dispersions. | |
modelspace::SimTimeManager * | time () |
Override of time() from executive to return SimTimeManager. | |
double | simTime () |
Function to access sim time. | |
modelspace::SpiceManager * | spiceManager () |
Function to return pointer to the spice manager. | |
void | setTime (const std::string &time_in) |
Function to set time by string input. | |
bool | started () |
Function to return whether the simulation executive is started. | |
virtual void | terminate () |
/ | |
void | schedule (Scheduler *sched) |
/ | |
clockwerk::EventLogger * | eventLog () |
/ | |
void | time (TimeManager *mgr) |
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. | |
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. | |
Protected Member Functions | |
void | _configureFromCmdLine () |
Function to configure simulation executive from command line input. | |
void | _printSimInfo () |
Function to print information associated with the simulation. | |
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 | |
clockwerk::Executive * | exc |
Pointer to the executive object, which for sim executive is self This feature included for easy logging and consistent access accross modules. | |
ArgParser | _args |
To parse our command line arguments. | |
DispersionEngine | _dispersion_engine |
To generate dispersions for the simulation. | |
int | _rng_seed = 0 |
unsigned int | _run_num = 0 |
The run number. | |
clockwerk::Frame< double > | _root_frame |
This is our sim's root frame, from which all other frames derive their relationships. | |
LogManager | _log_manager |
Specific declarations of scheduler, etc. specific to the simulation executive. | |
SimScheduler | _sim_scheduler |
SpiceManager | _spice_manager |
The spice manager to control all spice interactions. | |
TimeTriggerMonitor | _term_monitor |
Monitor and event to terminate sim run. | |
SimTerminationEvent | _term_event |
VisualsModel * | _visuals_model = nullptr |
Pointer to our visuals manager. | |
clockwerk::log_level_e | _local_log_level = clockwerk::NONE |
Our local log level – allows a higher log level locally than the overall system. | |
bool | _started = false |
Flag to indicate whether the executive has been properly started. Executive will not run unless startup has been called. | |
unsigned long long | _step_count = 0 |
Variable to track the number of steps the simulation has taken. | |
clockwerk::Scheduler * | _schedule |
Scheduler to execute everything. | |
EventLogger | event_logger |
Event logger for debugging and key events. | |
TimeManager * | _time |
Time manager – tracked as a pointer because executive does not depend on time, but we want access for the majority of applications. | |
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. | |
Implementation of the executive class for simulation.
The SimulationExecutive is a specific implementation of the Executive base class for simulation. It contains specified implementations of the scheduler, a frame tree and associated search functions, and functions for logging and integration setup.
The simulation executive also controls visuals, if the user chooses to enable them. They are inactive by default.
Command line arguments that can be set on simulation executive "end" - The simulation end time, as a double "run" - The run number for Monte Carlo simulation. Run 0 is the "default" "out-dir" - The output directory to which results should be dumped "use-spice" - A flag indicating whether SPICE should be used. Default is true
With regards to SPICE, the simulation executive loads by default the kernels provided in utils/spiceutils.h. Users may command the simulation executive to load more kernels using the function loadSpiceKernels
|
protectedinherited |
Function to add a child to the graph tree object.
child | A pointer to the graph tree object to add to the tree |
|
inline |
Overloaded function to register and set up a logger.
log | The logger to add to the sim |
monitor | The monitor which triggers the logger |
|
inline |
Overloaded function to register and set up a logger.
log | The logger to add to the sim |
rate | The rate, in Hz, at which the logger should log |
|
inherited |
Getter for object's string address.
|
inline |
Function to access args.
|
protectedinherited |
Function to decompose a string into a series of substrings via indexing.
address | The address to be decomposed |
void modelspace::SimulationExecutive::disableVisuals | ( | ) |
Function to disable visuals for the simulation.
|
inline |
Function to access dispersions.
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) |
|
inline |
Function to return simulation end time.
void modelspace::SimulationExecutive::end | ( | clockwerk::Time | end_time | ) |
Overloaded function to set the simulation end time.
end_time | The end time in its respective format |
|
inlineinherited |
/
Getter for the event logger. Returns pointer to event logger
|
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.
|
inlinevirtual |
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 * >.
|
inline |
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 |
Wrapper around arg parse.
argc | C++ argc input |
argv | C++ argv input |
int modelspace::SimulationExecutive::parseArgs | ( | std::vector< std::string > | arguments | ) |
Wrapper around arg parse.
args | A std::vector of arguments |
|
inline |
Function to acces the run rate of the simulation.
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 |
|
virtual |
/
Function to execute run for the executive and its kids /
Reimplemented from clockwerk::Executive.
|
inline |
Getter for run number.
|
inline |
Setter for run number.
|
inlineinherited |
/
Function to set the scheduler for the executive
std::vector< std::string > modelspace::SimulationExecutive::search | ( | const std::string & | s_val | ) |
Function to search the simulation and frame trees for a match.
s_val | The value to search for |
std::vector< std::string > modelspace::SimulationExecutive::searchFrameTree | ( | const std::string & | s_val | ) |
Function to search the frame tree for a match.
s_val | The value to search for |
|
protectedinherited |
Function to search through the graph tree by string address.
address | `The address or address chunk to search for |
std::vector< std::string > modelspace::SimulationExecutive::searchSimTree | ( | const std::string & | s_val | ) |
Function to search the simulation architecture tree for a match.
s_val | The value to search for |
Function to set the simulation run rate, in Hz.
rate_hz | The simulation run rate, in Hz |
void modelspace::SimulationExecutive::setRateSec | ( | clockwerk::Time | rate_sec | ) |
Function to set the simulation run rate, in seconds as Time.
rate_sec | The simulation run rate as a timespec with seconds, nanoseconds |
|
inline |
Function to set time by string input.
time_input | The string input by which time will be set. valid inputs are any input which is accepted by the SPICE function STR2ET. More info here: https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/FORTRAN/spicelib/str2et.html This value defaults to 2023 September 26, 12:00:00 MDT |
|
inline |
Function to access sim time.
|
inline |
Function to return pointer to the spice manager.
|
inline |
Function to return whether the simulation executive is started.
|
virtual |
Function to initialize our simulation executive and everything it contains.
Reimplemented from clockwerk::Executive.
|
virtual |
Function to step the scheduler by a single step.
Reimplemented from clockwerk::Executive.
int modelspace::SimulationExecutive::step | ( | const clockwerk::Time & | step_size | ) |
Function to step the scheduler by a single step.
step_size | The step size (as a time object) to step the sim by |
|
inlinevirtualinherited |
/
This function shadows the schedule's terminate call / for ease of use
|
inline |
Override of time() from executive to return SimTimeManager.
|
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 |
|
protected |
This is our sim's root frame, from which all other frames derive their relationships.
The root frame within the simulation executive is an arbitrary frame relative to which all frames are defined. When SPICE is active in the simulation executive the root frame is treated as the root of the J2000 frame, and all planets will be set relative to that point.