WarpTwin
Documentation for WarpTwin models and classes.
Loading...
Searching...
No Matches
SimTimeManager.h
Go to the documentation of this file.
1/******************************************************************************
2* Copyright (c) ATTX INC 2025. All Rights Reserved.
3*
4* This software and associated documentation (the "Software") are the
5* proprietary and confidential information of ATTX INC. The Software is
6* furnished under a license agreement between ATTX and the user organization
7* and may be used or copied only in accordance with the terms of the agreement.
8* Refer to 'license/attx_license.adoc' for standard license terms.
9*
10* EXPORT CONTROL NOTICE: THIS SOFTWARE MAY INCLUDE CONTENT CONTROLLED UNDER THE
11* INTERNATIONAL TRAFFIC IN ARMS REGULATIONS (ITAR) OR THE EXPORT ADMINISTRATION
12* REGULATIONS (EAR99). No part of the Software may be used, reproduced, or
13* transmitted in any form or by any means, for any purpose, without the express
14* written permission of ATTX INC.
15******************************************************************************/
16/*
17Time Manager class header file
18
19Author: Alex Reynolds
20*/
21#ifndef SIMULATION_SIM_TIME_MANAGER_H
22#define SIMULATION_SIM_TIME_MANAGER_H
23
24#include "architecture/Time.h"
26
27namespace warptwin {
28
30 const std::string DEFAULT_SIMULATION_TIME = "2023 September 26, 12:00:00 MDT";
31
34 const double GPS_TO_J2000_ET_OFFSET = 630763200.0;
35
42
71 public:
74 virtual ~SimTimeManager() {};
75
78 void stepTime(const clockwerk::Time& step);
79
82 void updateStep(const clockwerk::Time& step);
83
90
95 double str2tdb(const std::string &time_input);
96
104 std::string tdbTime() {return std::to_string(tdb_time().asFloatingPoint());}
107 std::string utcTime();
110 std::string jdTime();
113 std::string gpsTime();
116 double decimalYear();
117
123
128 int configureSystemTime(const clockwerk::Time& offset, uint32 resolution_nsec=1);
129
133 void configureNavigationTime(const std::string& source="SYSTEM");
134
141 void setTime(const std::string &time_input=DEFAULT_SIMULATION_TIME);
142
169
173
176 void setTime(clockwerk::Time set_val) {system_time(set_val); _sys_time_set = true;}
177
179 void unsetTime() {_sys_time_set = false;}
180 protected:
181 // Temporary variable to make time retrieval faster
183 struct timespec _tmp;
184
193
194 // Time used for wall clock calculation
195 bool _started = false;
198
199 // Time variables dictating os time behavior
204 bool _sys_time_set = false;
205
206 GraphTreeObject* _children[MAXIMUM_APP_CHILDREN];
207 };
208
209}
210
211#endif
Class for inter-object communication.
Definition DataIO.hpp:60
Base class for object organization.
Definition GraphTreeObject.h:98
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.
Definition GraphTreeObject.cpp:23
Wrapper to manage and convert time as timespce.
Definition Time.h:53
SimTimeManager()
Base constructor – time manager should initialize to zeros and then be set.
Definition SimTimeManager.cpp:44
clockwerk::DataIO< clockwerk::Time > step_end_time
This is the time at the end of a given scheduler step.
Definition SimTimeManager.h:150
clockwerk::Time * _gps_time_ptr
Definition SimTimeManager.h:190
void setTime(clockwerk::Time set_val)
Set time to val set_val (to something different than sim time manager).
Definition SimTimeManager.h:176
clockwerk::DataIO< clockwerk::Time > base_time
This is the exact current time as the scheduler steps forward.
Definition SimTimeManager.h:152
void unsetTime()
Set time to unset system time (return to SimTimeManager value).
Definition SimTimeManager.h:179
std::string tdbTime()
Function to return the TDB time as a string.
Definition SimTimeManager.h:104
clockwerk::Time * _tdb_time_ptr
Definition SimTimeManager.h:189
clockwerk::Time _now
Definition SimTimeManager.h:197
std::string jdTime()
Function to return the Julian date as a string.
Definition SimTimeManager.cpp:122
std::string utcTime()
Function to return the TDB time as a string.
Definition SimTimeManager.cpp:116
bool _started
Definition SimTimeManager.h:195
clockwerk::DataIO< clockwerk::Time > gps_time
Definition SimTimeManager.h:159
clockwerk::Time _system_time_offset
Definition SimTimeManager.h:200
clockwerk::DataIO< clockwerk::Time > navigation_time
Definition SimTimeManager.h:168
struct timespec _tmp
Definition SimTimeManager.h:183
clockwerk::DataIO< clockwerk::Time > system_time
Definition SimTimeManager.h:165
clockwerk::Time _nav_base_time
Definition SimTimeManager.h:203
clockwerk::Time * _base_time_ptr
Definition SimTimeManager.h:188
void setTime(const std::string &time_input=DEFAULT_SIMULATION_TIME)
Function to set time by string input.
Definition SimTimeManager.cpp:193
double decimalYear()
Function to return the decimal year as a double.
Definition SimTimeManager.cpp:132
clockwerk::DataIO< clockwerk::Time > step_start_time
Definition SimTimeManager.h:148
bool wallClockIsStarted()
Function to return whether the wall clock timer is started.
Definition SimTimeManager.h:172
void configureNavigationTime(const std::string &source="SYSTEM")
Configure the os.navigationTime() and navigation_time outputs.
Definition SimTimeManager.cpp:176
void stepTime(const clockwerk::Time &step)
Function to increment all times.
Definition SimTimeManager.cpp:64
std::string gpsTime()
Function to return the GPS time as a string.
Definition SimTimeManager.cpp:128
clockwerk::DataIO< clockwerk::Time > tdb_time
Definition SimTimeManager.h:156
clockwerk::Time * _start_step_ptr
Pointers to our time objects.
Definition SimTimeManager.h:186
double str2tdb(const std::string &time_input)
Definition SimTimeManager.cpp:110
clockwerk::Time _diff
Definition SimTimeManager.h:182
nav_time_sources_e _nav_time_source
Definition SimTimeManager.h:202
uint32 _system_time_resolution
Definition SimTimeManager.h:201
clockwerk::Time * _system_time_ptr
Definition SimTimeManager.h:192
clockwerk::Time wallClockTimer()
Function to return the wall clock time since run start.
Definition SimTimeManager.cpp:95
clockwerk::Time * _end_step_ptr
Definition SimTimeManager.h:187
virtual ~SimTimeManager()
Definition SimTimeManager.h:74
clockwerk::DataIO< clockwerk::Time > utc_time
Definition SimTimeManager.h:162
GraphTreeObject * _children[MAXIMUM_APP_CHILDREN]
Definition SimTimeManager.h:206
clockwerk::Time * _utc_time_ptr
Definition SimTimeManager.h:191
void updateStep(const clockwerk::Time &step)
Function to increment step start and end time.
Definition SimTimeManager.cpp:84
bool _sys_time_set
Definition SimTimeManager.h:204
int configureSystemTime(const clockwerk::Time &offset, uint32 resolution_nsec=1)
Configure the os.systemTime() and system_time outputs.
Definition SimTimeManager.cpp:159
clockwerk::Time _start
Definition SimTimeManager.h:196
Class to propagate CR3BP dynamics in characteristic units.
Definition statistics.hpp:22
nav_time_sources_e
Definition SimTimeManager.h:36
@ NAV_SRC_SYSTEM
Definition SimTimeManager.h:37
@ NAV_SRC_TDB
Definition SimTimeManager.h:40
@ NAV_SRC_UTC
Definition SimTimeManager.h:39
@ NAV_SRC_GPS
Definition SimTimeManager.h:38
const double GPS_TO_J2000_ET_OFFSET
This is the offset between the GPS and J2000 epochs for calculation of GPS time The GPS epoch is Janu...
Definition SimTimeManager.h:34
const std::string DEFAULT_SIMULATION_TIME
This is the default simulation time.
Definition SimTimeManager.h:30