![]() |
WarpTwin
Documentation for WarpTwin models and classes.
|
Implementation of the executive class for simulation. More...
#include <SimulationExecutive.h>

Public Member Functions | |
| SimulationExecutive () | |
| Constructor for the simulation executive. | |
| ~SimulationExecutive () | |
| 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. | |
| int16 | startup () |
| Function to initialize our simulation executive and everything it contains. | |
| int16 | step () |
| Function to step the scheduler by a single step. | |
| int16 | step (const clockwerk::Time &step_size) |
| Function to step the scheduler by a single step. | |
| int16 | run () |
| Function to execute run for the executive and its kids /. | |
| clockwerk::Time | rate () |
| Function to acces the run rate of the simulation. | |
| Frame & | 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. | |
| warptwin::LogManager & | logManager () |
| Getter for the log manager. | |
| warptwin::SimScheduler & | schedule () |
| Getter for the schedule. | |
| warptwin::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. | |
| bool | visualsEnabled () |
| Indicator as to whether visuals are enabled. | |
| unsigned int | runNumber () |
| Getter for run number. | |
| void | runNumber (unsigned int run_num) |
| Setter for run number. | |
| warptwin::ArgParser & | args () |
| Function to access args. | |
| warptwin::DispersionEngine & | dispersions () |
| Function to access dispersions. | |
| warptwin::SimTimeManager & | time () |
| Override of time() from executive to return SimTimeManager. | |
| double | simTime () |
| Function to access sim time. | |
| warptwin::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. | |
| bool | isTerminated () |
| Get whether scheduler is terminated. | |
| void | terminate () |
| Function to terminate scheduler. | |
| void | writeSimDataToJson (const std::string &filename) |
| Write all simulation data, including models, to json output. | |
| int | registerApp (warpos::App &app, int16 slot) |
| Function to register apps with the scheduler. Depending on the scheduler implementation these may be unused. | |
| int | scheduleTelemetry (int apid, clockwerk::Time rate) |
| Schedule telemetry in the sim. | |
| void | setWarpLinkInterface (std::string ip="127.0.0.1", uint32 tlm_port=5005, uint32 cmd_port=5006) |
| Set the IP address, telemetry port, and coommand port with WarpLink. | |
| 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 socket. | |
| Public Member Functions inherited from warpos::FlightExecutive | |
| FlightExecutive (warpos::Setup &setup, warpos::Scheduler &schedule, bool delay_parent_assignment=false) | |
| Only valid FlightExecutive constructor. | |
| FlightExecutive (const FlightExecutive &original) | |
| const FlightExecutive & | operator= (const FlightExecutive &original) |
| virtual | ~FlightExecutive () |
| warpos::Setup & | setup () |
| Handle to the current system setup. | |
| warpos::Scheduler & | schedule () |
| Handle to the current system schedule. | |
| warpos::OS & | os () |
| Handle to the current system OS. | |
| warpos::Platform & | platform () |
| Handle to the current system platform. | |
| warpos::TelemetryManager & | telemetryManager () |
| Handle to the telemetry manager. | |
| warpos::StorageManager & | storageManager () |
| Handle to the storage manager. | |
| warpos::CommandManager & | commandManager () |
| Handle to the command manager. | |
| int16 | registerTlm (uint16 apid, uint8 instance=0) |
| Register telemetry packet with storage and telemetry managers. | |
| int16 | sendStoreTlm (const cmd_tlm_base &pkt, uint8 instance=0) |
| Send packet to telemetry and storage managers for send/store. | |
| int16 | startup () |
| Initialize the FlightExecutive and all elements therein. | |
| int16 | step (const clockwerk::Time &step_val) |
| Step the FlightExecutive forward by a single step. | |
| int16 | run () |
| Run the FlightExecutive until the terminate flag is raised. | |
| log_level_e | logLevel () |
| Get the log level set for the executive. | |
| void | logLevel (log_level_e log_level) |
| Set the executive log level. | |
| int16 | registerApp (warpos::App &app) |
| Register an app with the flight executive. | |
| int16 | getAppPointer (uint16 apid, uint8 instance, warpos::App *&app_ptr) |
| Get pointer to a registered app based on its apid and instance number. | |
| warpos::App ** | getRegistry () |
| Get pointer to app registry, used for testing. | |
| 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. | |
| GraphTreeObject * | parent () |
| Functions to get object's parent/children. | |
| GraphTreeObject ** | children () |
| GraphTreeObject * | childAtIndex (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. | |
| GraphTreeObject * | getRootDataPointer () |
| 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 | |
| void | _configLogEverything (const std::string &filename) |
| Configure logger which will log all sim outputs. | |
| void | _configureFromCmdLine () |
| Function to configure simulation executive from command line input. | |
| void | _printSimInfo () |
| Function to print information associated with the simulation. | |
| 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 | |
| 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. | |
| Frame | _root_frame |
| This is our sim's root frame, from which all other frames derive their relationships. | |
| LogManager | _log_manager |
| 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. | |
| bool | _real_time_mode = false |
| log_level_e | _local_log_level = LOG_INFO |
| Our local log level – allows a higher log level locally than the overall system. | |
| bool | _started = false |
| unsigned long long | _step_count = 0 |
| Variable to track the number of steps the simulation has taken. | |
| CsvLogger * | _all_log = nullptr |
| SimLinux | _sim_os |
| SimPlatform | _sim_platform |
| SimSetup | _sim_setup |
| SimulationExecutive & | exc |
| Protected Attributes inherited from warpos::FlightExecutive | |
| warpos::Setup & | _setup |
| System setup, which implicitly contains OS and Platform. | |
| warpos::Scheduler & | _scheduler |
| System schedule, which determines what apps and functions run when. | |
| uint16 | _registered_app_idx = 0 |
| Index of last registered app. | |
| App * | _registered_apps [MAXIMUM_FLIGHT_EXECUTIVE_CHILDREN] = {nullptr} |
| Buffer of pointers to registered apps. | |
| warpos::TelemetryManager | _telemetry_manager |
| The telemetry manager for the flight executive. | |
| warpos::StorageManager | _storage_manager |
| The storage manager for the flight executive. | |
| warpos::CommandManager | _command_manager |
| The command manager for the flight executive. | |
| log_level_e | _exc_log_level = log_level_e::LOG_INFO |
| GraphTreeObject * | _fexec_children [MAXIMUM_FLIGHT_EXECUTIVE_CHILDREN] |
| Local storage for App children so it can live on the graph tree. | |
| 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. | |
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
| warptwin::SimulationExecutive::SimulationExecutive | ( | ) |
Constructor for the simulation executive.
| warptwin::SimulationExecutive::~SimulationExecutive | ( | ) |
|
protected |
Configure logger which will log all sim outputs.
| filename | The filename to write data to |
|
protected |
Function to configure simulation executive from command line input.
|
protected |
Function to print information associated with the simulation.
|
inline |
Function to access args.
|
inline |
Connect a signal to an external socket.
| signal | The signal to connect externally |
| mode | The mode (must be INPUT or OUTPUT) on which the signal is connected |
| shmem_address | The shared memory location on which the signal is connected |
|
inline |
Connect a signal to an external socket.
| signal | The signal to connect externally |
| mode | The mode (must be INPUT or OUTPUT) on which the signal is connected |
| ip | The IP address of the connection |
| port | The port for the connection |
| void warptwin::SimulationExecutive::disableVisuals | ( | ) |
Function to disable visuals for the simulation.
|
inline |
Function to access dispersions.
| void warptwin::SimulationExecutive::enableVisuals | ( | ) |
Function to enable visuals for the simulation.
| clockwerk::Time warptwin::SimulationExecutive::end | ( | ) |
Function to return simulation end time.
| void warptwin::SimulationExecutive::end | ( | clockwerk::Time | end_time | ) |
Overloaded function to set the simulation end time.
| end_time | The end time in its respective format |
| void warptwin::SimulationExecutive::end | ( | double | end_time | ) |
| void warptwin::SimulationExecutive::end | ( | struct timespec | end_time | ) |
|
inline |
|
inline |
Functions to set and get our integrator.
|
inline |
Get whether scheduler is terminated.
|
inline |
Getter for the log manager.
| int warptwin::SimulationExecutive::parseArgs | ( | int | argc, |
| char * | argv[] ) |
Wrapper around arg parse.
| argc | C++ argc input |
| argv | C++ argv input |
| int warptwin::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.
|
inline |
Function to register apps with the scheduler. Depending on the scheduler implementation these may be unused.
| app | The app to register |
| slot | The slot to register the app to |
|
inline |
Getter for the simulation root frame.
| int16 warptwin::SimulationExecutive::run | ( | ) |
Function to execute run for the executive and its kids /.
/
|
inline |
Getter for run number.
|
inline |
Setter for run number.
|
inline |
Getter for the schedule.
| int warptwin::SimulationExecutive::scheduleTelemetry | ( | int | apid, |
| clockwerk::Time | rate ) |
Schedule telemetry in the sim.
| apid | The apid of the telemetry to schedule. Negative schedules ALL telemetry |
| rate | The rate the telemetry should run at |
| std::vector< std::string > warptwin::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 > warptwin::SimulationExecutive::searchFrameTree | ( | const std::string & | s_val | ) |
Function to search the frame tree for a match.
| s_val | The value to search for |
| std::vector< std::string > warptwin::SimulationExecutive::searchSimTree | ( | const std::string & | s_val | ) |
Function to search the simulation architecture tree for a match.
| s_val | The value to search for |
| void warptwin::SimulationExecutive::setRateHz | ( | unsigned int | rate_hz | ) |
Function to set the simulation run rate, in Hz.
| rate_hz | The simulation run rate, in Hz |
| void warptwin::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 |
| void warptwin::SimulationExecutive::setRateSec | ( | double | rate_sec | ) |
| void warptwin::SimulationExecutive::setRateSec | ( | struct timespec | rate_sec | ) |
|
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 |
Set the IP address, telemetry port, and coommand port with WarpLink.
| ip | The IP address for interface with warplink. Default is internal routing |
| tlm_port | The port over which telemetry should be routed |
| cmd_port | The port over which commands should be routed |
|
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.
| int16 warptwin::SimulationExecutive::startup | ( | ) |
Function to initialize our simulation executive and everything it contains.
| int16 warptwin::SimulationExecutive::step | ( | ) |
Function to step the scheduler by a single step.
| int16 warptwin::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 |
|
inline |
Function to terminate scheduler.
|
inline |
Override of time() from executive to return SimTimeManager.
|
inline |
Indicator as to whether visuals are enabled.
|
inline |
Getter for the visuals model.
| void warptwin::SimulationExecutive::writeSimDataToJson | ( | const std::string & | filename | ) |
Write all simulation data, including models, to json output.
| filename | The filename to write data to |
|
protected |
|
protected |
To parse our command line arguments.
|
protected |
To generate dispersions for the simulation.
|
protected |
Our local log level – allows a higher log level locally than the overall system.
|
protected |
Specific declarations of scheduler, etc. specific to the simulation executive
|
protected |
Flag set by –real-time=true; applied to VisualsModel when it is created. Needed because parseArgs() is typically called before enableVisuals().
|
protected |
|
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.
|
protected |
The run number.
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
The spice manager to control all spice interactions.
|
protected |
Flag to indicate whether the executive has been properly started. Executive will not run unless startup has been called.
|
protected |
Variable to track the number of steps the simulation has taken.
|
protected |
|
protected |
Monitor and event to terminate sim run.
|
protected |
Pointer to our visuals manager.
|
protected |