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

Class to manage time for the simulation object. More...

#include <SimTimeManager.h>

Inheritance diagram for warptwin::SimTimeManager:

Public Member Functions

 SimTimeManager ()
 Base constructor – time manager should initialize to zeros and then be set.
virtual ~SimTimeManager ()
void stepTime (const clockwerk::Time &step)
 Function to increment all times.
void updateStep (const clockwerk::Time &step)
 Function to increment step start and end time.
clockwerk::Time wallClockTimer ()
 Function to return the wall clock time since run start.
double str2tdb (const std::string &time_input)
std::string tdbTime ()
 Function to return the TDB time as a string.
std::string utcTime ()
 Function to return the TDB time as a string.
std::string jdTime ()
 Function to return the Julian date as a string.
std::string gpsTime ()
 Function to return the GPS time as a string.
double decimalYear ()
 Function to return the decimal year as a double.
int configureSystemTime (const clockwerk::Time &offset, uint32 resolution_nsec=1)
 Configure the os.systemTime() and system_time outputs.
void configureNavigationTime (const std::string &source="SYSTEM")
 Configure the os.navigationTime() and navigation_time outputs.
void setTime (const std::string &time_input=DEFAULT_SIMULATION_TIME)
 Function to set time by string input.
bool wallClockIsStarted ()
 Function to return whether the wall clock timer is started.
void setTime (clockwerk::Time set_val)
 Set time to val set_val (to something different than sim time manager).
void unsetTime ()
 Set time to unset system time (return to SimTimeManager value).
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

clockwerk::DataIO< clockwerk::Timestep_start_time = clockwerk::DataIO<clockwerk::Time>(this, "step_start_time")
clockwerk::DataIO< clockwerk::Timestep_end_time = clockwerk::DataIO<clockwerk::Time>(this, "step_end_time")
 This is the time at the end of a given scheduler step.
clockwerk::DataIO< clockwerk::Timebase_time = clockwerk::DataIO<clockwerk::Time>(this, "base_time")
 This is the exact current time as the scheduler steps forward.
clockwerk::DataIO< clockwerk::Timetdb_time = clockwerk::DataIO<clockwerk::Time>(this, "tdb_time")
clockwerk::DataIO< clockwerk::Timegps_time = clockwerk::DataIO<clockwerk::Time>(this, "gps_time")
clockwerk::DataIO< clockwerk::Timeutc_time = clockwerk::DataIO<clockwerk::Time>(this, "utc_time")
clockwerk::DataIO< clockwerk::Timesystem_time = clockwerk::DataIO<clockwerk::Time>(this, "system_time")
clockwerk::DataIO< clockwerk::Timenavigation_time = clockwerk::DataIO<clockwerk::Time>(this, "navigation_time")

Protected Attributes

clockwerk::Time _diff
struct timespec _tmp
clockwerk::Time_start_step_ptr
 Pointers to our time objects.
clockwerk::Time_end_step_ptr
clockwerk::Time_base_time_ptr
clockwerk::Time_tdb_time_ptr
clockwerk::Time_gps_time_ptr
clockwerk::Time_utc_time_ptr
clockwerk::Time_system_time_ptr
bool _started = false
clockwerk::Time _start
clockwerk::Time _now
clockwerk::Time _system_time_offset = clockwerk::Time(0, 0)
uint32 _system_time_resolution = 1
nav_time_sources_e _nav_time_source = nav_time_sources_e::NAV_SRC_SYSTEM
clockwerk::Time _nav_base_time
bool _sys_time_set = false
GraphTreeObject_children [MAXIMUM_APP_CHILDREN]
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.

Additional Inherited Members

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.

Detailed Description

Class to manage time for the simulation object.

This class uses the SPICE module to manage time within the simulation. Internally it steps the sim time and the spice ephemeris time (TDB time), which is used to cast UTC and JD time scales. All are published on the time manager.

The SimTimeManager publishes 4 different types of time:

  • Sim time, which begins at 0 at simulation start and steps by exactly the sim rate every step
  • TDB (or Ephemeris) time, which is set based on an input date and time via setTime and is used to publish UTC, GPS time, etc.
  • System Time, which is a simulated version of os.systemTime() which is used by warpOS apps. This value, which is published by SimTimeManager, is reflected in os.systemTime() calls in the simulation. SimTimeManager allows setting granularity and offsets relative to SimTime in this value
  • Navigation Time, which is a simulated version of os.navigationTime() used by warpOS apps. This value, which is published by SimTimeManager, is reflected in os.navigationTime() calls in the simulation. This value mirrors systemTime by default, but can be set to reflect GPS or UTC time in SimTimeManager

Time representations are based on the clockwerk Time class.

Constructor & Destructor Documentation

◆ SimTimeManager()

warptwin::SimTimeManager::SimTimeManager ( )

Base constructor – time manager should initialize to zeros and then be set.

◆ ~SimTimeManager()

virtual warptwin::SimTimeManager::~SimTimeManager ( )
inlinevirtual

Member Function Documentation

◆ configureNavigationTime()

void warptwin::SimTimeManager::configureNavigationTime ( const std::string & source = "SYSTEM")

Configure the os.navigationTime() and navigation_time outputs.

Parameters
sourceThe source navigation time is connected to. Valid choices are: SYSTEM, GPS, UTC, TDB

◆ configureSystemTime()

int warptwin::SimTimeManager::configureSystemTime ( const clockwerk::Time & offset,
uint32 resolution_nsec = 1 )

Configure the os.systemTime() and system_time outputs.


Methods to set time The following functions allow users to set time based on string

input.

Parameters
offsetThe offset between simulation time and system time. Must be positive
resolutionThe resolution of time output, in nanoseconds. Default is full resolution.
Returns
Error code corresponding to success/failure

◆ decimalYear()

double warptwin::SimTimeManager::decimalYear ( )

Function to return the decimal year as a double.

Returns
Data in units of year with a decimal describing percent until next year

◆ gpsTime()

std::string warptwin::SimTimeManager::gpsTime ( )

Function to return the GPS time as a string.

Returns
GPS time

◆ jdTime()

std::string warptwin::SimTimeManager::jdTime ( )

Function to return the Julian date as a string.

Returns
Julian date as a days since the JD epoch as JDUTC

◆ setTime() [1/2]

void warptwin::SimTimeManager::setTime ( clockwerk::Time set_val)
inline

Set time to val set_val (to something different than sim time manager).

Parameters
set_valThe time to set

◆ setTime() [2/2]

void warptwin::SimTimeManager::setTime ( const std::string & time_input = DEFAULT_SIMULATION_TIME)

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

◆ stepTime()

void warptwin::SimTimeManager::stepTime ( const clockwerk::Time & step)

Function to increment all times.

Parameters
stepTime object to step by

◆ str2tdb()

double warptwin::SimTimeManager::str2tdb ( const std::string & time_input)

Time converters

The following functions convert time between representations

◆ tdbTime()

std::string warptwin::SimTimeManager::tdbTime ( )
inline

Function to return the TDB time as a string.


Useful Time Representations The following functions return time as any one of a number of

useful representations such as UTC and GPS time

Returns
TDB time as seconds since J2000

◆ unsetTime()

void warptwin::SimTimeManager::unsetTime ( )
inline

Set time to unset system time (return to SimTimeManager value).

◆ updateStep()

void warptwin::SimTimeManager::updateStep ( const clockwerk::Time & step)

Function to increment step start and end time.

Parameters
stepTime object to step by

◆ utcTime()

std::string warptwin::SimTimeManager::utcTime ( )

Function to return the TDB time as a string.

Returns
UTC time in the format 'YYYY MMM DD HH:MM:SS'

◆ wallClockIsStarted()

bool warptwin::SimTimeManager::wallClockIsStarted ( )
inline

Function to return whether the wall clock timer is started.

Returns
Whether the wall clock timer is started

◆ wallClockTimer()

clockwerk::Time warptwin::SimTimeManager::wallClockTimer ( )

Function to return the wall clock time since run start.


Other time functions – These functions return other forms of time

Returns
A time object containing the time since run start

Member Data Documentation

◆ _base_time_ptr

clockwerk::Time* warptwin::SimTimeManager::_base_time_ptr
protected

◆ _children

GraphTreeObject* warptwin::SimTimeManager::_children[MAXIMUM_APP_CHILDREN]
protected

◆ _diff

clockwerk::Time warptwin::SimTimeManager::_diff
protected

◆ _end_step_ptr

clockwerk::Time* warptwin::SimTimeManager::_end_step_ptr
protected

◆ _gps_time_ptr

clockwerk::Time* warptwin::SimTimeManager::_gps_time_ptr
protected

◆ _nav_base_time

clockwerk::Time warptwin::SimTimeManager::_nav_base_time
protected

◆ _nav_time_source

nav_time_sources_e warptwin::SimTimeManager::_nav_time_source = nav_time_sources_e::NAV_SRC_SYSTEM
protected

◆ _now

clockwerk::Time warptwin::SimTimeManager::_now
protected

◆ _start

clockwerk::Time warptwin::SimTimeManager::_start
protected

◆ _start_step_ptr

clockwerk::Time* warptwin::SimTimeManager::_start_step_ptr
protected

Pointers to our time objects.

◆ _started

bool warptwin::SimTimeManager::_started = false
protected

◆ _sys_time_set

bool warptwin::SimTimeManager::_sys_time_set = false
protected

◆ _system_time_offset

clockwerk::Time warptwin::SimTimeManager::_system_time_offset = clockwerk::Time(0, 0)
protected

◆ _system_time_ptr

clockwerk::Time* warptwin::SimTimeManager::_system_time_ptr
protected

◆ _system_time_resolution

uint32 warptwin::SimTimeManager::_system_time_resolution = 1
protected

◆ _tdb_time_ptr

clockwerk::Time* warptwin::SimTimeManager::_tdb_time_ptr
protected

◆ _tmp

struct timespec warptwin::SimTimeManager::_tmp
protected

◆ _utc_time_ptr

clockwerk::Time* warptwin::SimTimeManager::_utc_time_ptr
protected

◆ base_time

clockwerk::DataIO<clockwerk::Time> warptwin::SimTimeManager::base_time = clockwerk::DataIO<clockwerk::Time>(this, "base_time")

This is the exact current time as the scheduler steps forward.

◆ gps_time

clockwerk::DataIO<clockwerk::Time> warptwin::SimTimeManager::gps_time = clockwerk::DataIO<clockwerk::Time>(this, "gps_time")

GPS Time represented as seconds relative to the GPS epoch of January 6, 1980.

◆ navigation_time

clockwerk::DataIO<clockwerk::Time> warptwin::SimTimeManager::navigation_time = clockwerk::DataIO<clockwerk::Time>(this, "navigation_time")

Output for the os.navigationTime() call used by flight software functions and sensor models. Configured based on configureSystemTime call for this class

◆ step_end_time

clockwerk::DataIO<clockwerk::Time> warptwin::SimTimeManager::step_end_time = clockwerk::DataIO<clockwerk::Time>(this, "step_end_time")

This is the time at the end of a given scheduler step.

◆ step_start_time

clockwerk::DataIO<clockwerk::Time> warptwin::SimTimeManager::step_start_time = clockwerk::DataIO<clockwerk::Time>(this, "step_start_time")

Incrementing clocks – these are standard clocks that begin on start and continue incrementing as the scheduler steps forward

in time.

This is the time at the start of a given scheduler step

◆ system_time

clockwerk::DataIO<clockwerk::Time> warptwin::SimTimeManager::system_time = clockwerk::DataIO<clockwerk::Time>(this, "system_time")

Output for the os.systemTime() call used by flight software functions. Configured based on configureSystemTime call for this class

◆ tdb_time

clockwerk::DataIO<clockwerk::Time> warptwin::SimTimeManager::tdb_time = clockwerk::DataIO<clockwerk::Time>(this, "tdb_time")

TDB time is represented as seconds relative to the J2000 epoch, which is January 1, 2000, at 12:00 TT (Terrestrial Time). This is also known as "ephemeris time"

◆ utc_time

clockwerk::DataIO<clockwerk::Time> warptwin::SimTimeManager::utc_time = clockwerk::DataIO<clockwerk::Time>(this, "utc_time")

UTC Time represented as seconds relative to the J2000 epoch of January 1, 2000.


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