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

Implementation of the executive class for simulation. More...

#include <SimulationExecutive.h>

Inheritance diagram for warptwin::SimulationExecutive:

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.
FramerootFrame ()
 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::LogManagerlogManager ()
 Getter for the log manager.
warptwin::SimSchedulerschedule ()
 Getter for the schedule.
warptwin::VisualsModelvisualsModel ()
 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::ArgParserargs ()
 Function to access args.
warptwin::DispersionEnginedispersions ()
 Function to access dispersions.
warptwin::SimTimeManagertime ()
 Override of time() from executive to return SimTimeManager.
double simTime ()
 Function to access sim time.
warptwin::SpiceManagerspiceManager ()
 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 FlightExecutiveoperator= (const FlightExecutive &original)
virtual ~FlightExecutive ()
warpos::Setupsetup ()
 Handle to the current system setup.
warpos::Schedulerschedule ()
 Handle to the current system schedule.
warpos::OSos ()
 Handle to the current system OS.
warpos::Platformplatform ()
 Handle to the current system platform.
warpos::TelemetryManagertelemetryManager ()
 Handle to the telemetry manager.
warpos::StorageManagerstorageManager ()
 Handle to the storage manager.
warpos::CommandManagercommandManager ()
 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.
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

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
SimulationExecutiveexc
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.

Detailed Description

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

Constructor & Destructor Documentation

◆ SimulationExecutive()

warptwin::SimulationExecutive::SimulationExecutive ( )

Constructor for the simulation executive.

◆ ~SimulationExecutive()

warptwin::SimulationExecutive::~SimulationExecutive ( )

Member Function Documentation

◆ _configLogEverything()

void warptwin::SimulationExecutive::_configLogEverything ( const std::string & filename)
protected

Configure logger which will log all sim outputs.

Parameters
filenameThe filename to write data to

◆ _configureFromCmdLine()

void warptwin::SimulationExecutive::_configureFromCmdLine ( )
protected

Function to configure simulation executive from command line input.

◆ _printSimInfo()

void warptwin::SimulationExecutive::_printSimInfo ( )
protected

Function to print information associated with the simulation.

◆ args()

warptwin::ArgParser & warptwin::SimulationExecutive::args ( )
inline

Function to access args.

Returns
Pointer to arguments

◆ connectExternalSharedMemory()

void warptwin::SimulationExecutive::connectExternalSharedMemory ( clockwerk::DataIOBase & signal,
std::string mode,
const std::string shmem_address )
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
shmem_addressThe shared memory location on which the signal is connected

◆ connectExternalSocket()

void warptwin::SimulationExecutive::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

◆ disableVisuals()

void warptwin::SimulationExecutive::disableVisuals ( )

Function to disable visuals for the simulation.

Note
Shouldn't need to call this unless visuals were already enabled

◆ dispersions()

warptwin::DispersionEngine & warptwin::SimulationExecutive::dispersions ( )
inline

Function to access dispersions.

Returns
Pointer to dispersions

◆ enableVisuals()

void warptwin::SimulationExecutive::enableVisuals ( )

Function to enable visuals for the simulation.

◆ end() [1/4]

clockwerk::Time warptwin::SimulationExecutive::end ( )

Function to return simulation end time.

Returns
End time, as a Time class

◆ end() [2/4]

void warptwin::SimulationExecutive::end ( clockwerk::Time end_time)

Overloaded function to set the simulation end time.

Parameters
end_timeThe end time in its respective format

◆ end() [3/4]

void warptwin::SimulationExecutive::end ( double end_time)

◆ end() [4/4]

void warptwin::SimulationExecutive::end ( struct timespec end_time)

◆ integrator() [1/2]

int warptwin::SimulationExecutive::integrator ( )
inline

◆ integrator() [2/2]

void warptwin::SimulationExecutive::integrator ( int val)
inline

Functions to set and get our integrator.

◆ isTerminated()

bool warptwin::SimulationExecutive::isTerminated ( )
inline

Get whether scheduler is terminated.

◆ logManager()

warptwin::LogManager & warptwin::SimulationExecutive::logManager ( )
inline

Getter for the log manager.

◆ parseArgs() [1/2]

int warptwin::SimulationExecutive::parseArgs ( int argc,
char * argv[] )

Wrapper around arg parse.

Parameters
argcC++ argc input
argvC++ argv input
Returns
Error code corresponding to success/failure

◆ parseArgs() [2/2]

int warptwin::SimulationExecutive::parseArgs ( std::vector< std::string > arguments)

Wrapper around arg parse.

Parameters
argsA std::vector of arguments
Returns
Error code corresponding to success/failure

◆ rate()

clockwerk::Time warptwin::SimulationExecutive::rate ( )
inline

Function to acces the run rate of the simulation.

Returns
The rate of the simulation

◆ registerApp()

int warptwin::SimulationExecutive::registerApp ( warpos::App & app,
int16 slot )
inline

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

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

◆ rootFrame()

Frame & warptwin::SimulationExecutive::rootFrame ( )
inline

Getter for the simulation root frame.

◆ run()

int16 warptwin::SimulationExecutive::run ( )

Function to execute run for the executive and its kids /.

/

Returns
Error code corresponding to success/failure

◆ runNumber() [1/2]

unsigned int warptwin::SimulationExecutive::runNumber ( )
inline

Getter for run number.

Returns
The run number

◆ runNumber() [2/2]

void warptwin::SimulationExecutive::runNumber ( unsigned int run_num)
inline

Setter for run number.

Returns
The run number

◆ schedule()

warptwin::SimScheduler & warptwin::SimulationExecutive::schedule ( )
inline

Getter for the schedule.

◆ scheduleTelemetry()

int warptwin::SimulationExecutive::scheduleTelemetry ( int apid,
clockwerk::Time rate )

Schedule telemetry in the sim.

Parameters
apidThe apid of the telemetry to schedule. Negative schedules ALL telemetry
rateThe rate the telemetry should run at
Returns
Error code corresponding to success/failure

◆ search()

std::vector< std::string > warptwin::SimulationExecutive::search ( const std::string & s_val)

Function to search the simulation and frame trees for a match.

Parameters
s_valThe value to search for
Returns
A vector of string addresses matching the query
Note
Returns string addresses – user must get address and cast appropriately if they wish to use appropriate type

◆ searchFrameTree()

std::vector< std::string > warptwin::SimulationExecutive::searchFrameTree ( const std::string & s_val)

Function to search the frame tree for a match.

Parameters
s_valThe value to search for
Returns
A vector of string addresses matching the query
Note
Returns string addresses – user must get address and cast appropriately if they wish to use appropriate type

◆ searchSimTree()

std::vector< std::string > warptwin::SimulationExecutive::searchSimTree ( const std::string & s_val)

Function to search the simulation architecture tree for a match.

Parameters
s_valThe value to search for
Returns
A vector of string addresses matching the query
Note
Returns string addresses – user must get address and cast appropriately if they wish to use appropriate type

◆ setRateHz()

void warptwin::SimulationExecutive::setRateHz ( unsigned int rate_hz)

Function to set the simulation run rate, in Hz.

Parameters
rate_hzThe simulation run rate, in Hz

◆ setRateSec() [1/3]

void warptwin::SimulationExecutive::setRateSec ( clockwerk::Time rate_sec)

Function to set the simulation run rate, in seconds as Time.

Parameters
rate_secThe simulation run rate as a timespec with seconds, nanoseconds

◆ setRateSec() [2/3]

void warptwin::SimulationExecutive::setRateSec ( double rate_sec)

◆ setRateSec() [3/3]

void warptwin::SimulationExecutive::setRateSec ( struct timespec rate_sec)

◆ setTime()

void warptwin::SimulationExecutive::setTime ( const std::string & time_in)
inline

Function to set time by string input.

Parameters
time_inputThe 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

◆ setWarpLinkInterface()

void warptwin::SimulationExecutive::setWarpLinkInterface ( std::string ip = "127.0.0.1",
uint32 tlm_port = 5005,
uint32 cmd_port = 5006 )
inline

Set the IP address, telemetry port, and coommand port with WarpLink.

Parameters
ipThe IP address for interface with warplink. Default is internal routing
tlm_portThe port over which telemetry should be routed
cmd_portThe port over which commands should be routed

◆ simTime()

double warptwin::SimulationExecutive::simTime ( )
inline

Function to access sim time.

Returns
Current sim time

◆ spiceManager()

warptwin::SpiceManager & warptwin::SimulationExecutive::spiceManager ( )
inline

Function to return pointer to the spice manager.

Returns
Pointer to the spice manager

◆ started()

bool warptwin::SimulationExecutive::started ( )
inline

Function to return whether the simulation executive is started.

Returns
True if started, false if not

◆ startup()

int16 warptwin::SimulationExecutive::startup ( )

Function to initialize our simulation executive and everything it contains.

Returns
Error code corresponding to success/failure

◆ step() [1/2]

int16 warptwin::SimulationExecutive::step ( )

Function to step the scheduler by a single step.

Returns
Error code corresponding to success/failure

◆ step() [2/2]

int16 warptwin::SimulationExecutive::step ( const clockwerk::Time & step_size)

Function to step the scheduler by a single step.

Parameters
step_sizeThe step size (as a time object) to step the sim by
Returns
Error code corresponding to success/failure

◆ terminate()

void warptwin::SimulationExecutive::terminate ( )
inline

Function to terminate scheduler.

◆ time()

warptwin::SimTimeManager & warptwin::SimulationExecutive::time ( )
inline

Override of time() from executive to return SimTimeManager.

Returns
A pointer to the sim time manager.

◆ visualsEnabled()

bool warptwin::SimulationExecutive::visualsEnabled ( )
inline

Indicator as to whether visuals are enabled.

Returns
Boolean indicating status

◆ visualsModel()

warptwin::VisualsModel & warptwin::SimulationExecutive::visualsModel ( )
inline

Getter for the visuals model.

◆ writeSimDataToJson()

void warptwin::SimulationExecutive::writeSimDataToJson ( const std::string & filename)

Write all simulation data, including models, to json output.

Parameters
filenameThe filename to write data to

Member Data Documentation

◆ _all_log

CsvLogger* warptwin::SimulationExecutive::_all_log = nullptr
protected

◆ _args

ArgParser warptwin::SimulationExecutive::_args
protected

To parse our command line arguments.

◆ _dispersion_engine

DispersionEngine warptwin::SimulationExecutive::_dispersion_engine
protected

To generate dispersions for the simulation.

◆ _local_log_level

log_level_e warptwin::SimulationExecutive::_local_log_level = LOG_INFO
protected

Our local log level – allows a higher log level locally than the overall system.

◆ _log_manager

LogManager warptwin::SimulationExecutive::_log_manager
protected

Specific declarations of scheduler, etc. specific to the simulation executive

◆ _real_time_mode

bool warptwin::SimulationExecutive::_real_time_mode = false
protected

Flag set by –real-time=true; applied to VisualsModel when it is created. Needed because parseArgs() is typically called before enableVisuals().

◆ _rng_seed

int warptwin::SimulationExecutive::_rng_seed = 0
protected

◆ _root_frame

Frame warptwin::SimulationExecutive::_root_frame
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.

◆ _run_num

unsigned int warptwin::SimulationExecutive::_run_num = 0
protected

The run number.

◆ _sim_os

SimLinux warptwin::SimulationExecutive::_sim_os
protected

◆ _sim_platform

SimPlatform warptwin::SimulationExecutive::_sim_platform
protected

◆ _sim_scheduler

SimScheduler warptwin::SimulationExecutive::_sim_scheduler
protected

◆ _sim_setup

SimSetup warptwin::SimulationExecutive::_sim_setup
protected

◆ _spice_manager

SpiceManager warptwin::SimulationExecutive::_spice_manager
protected

The spice manager to control all spice interactions.

◆ _started

bool warptwin::SimulationExecutive::_started = false
protected

Flag to indicate whether the executive has been properly started. Executive will not run unless startup has been called.

◆ _step_count

unsigned long long warptwin::SimulationExecutive::_step_count = 0
protected

Variable to track the number of steps the simulation has taken.

◆ _term_event

SimTerminationEvent* warptwin::SimulationExecutive::_term_event
protected

◆ _term_monitor

TimeTriggerMonitor* warptwin::SimulationExecutive::_term_monitor
protected

Monitor and event to terminate sim run.

◆ _visuals_model

VisualsModel* warptwin::SimulationExecutive::_visuals_model = nullptr
protected

Pointer to our visuals manager.

◆ exc

SimulationExecutive& warptwin::SimulationExecutive::exc
protected

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