WarpTwin
Documentation for WarpTwin models and classes.
Loading...
Searching...
No Matches
SimScheduler.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/*
17Scheduler header file
18
19Author: Alex Reynolds
20*/
21#ifndef SIMULATION_SIM_SCHEDULER_H
22#define SIMULATION_SIM_SCHEDULER_H
23
24#include <vector>
25
26#include "flight/Scheduler.h"
31#include "SimulationSteps.h"
32#include "frames/Frame.h"
33
34namespace warptwin {
36
38
42
45
50 public:
64
67 SIGNAL(rate, clockwerk::Time, clockwerk::Time(1,0))
69
76
80
83 int16 startup() override;
84
91 int16 step(const clockwerk::Time &step_size = clockwerk::Time(0, NSEC_MAX + 1)) override;
92
97 int16 run() override;
98
104 void connectExternalSocket(clockwerk::DataIOBase& signal, std::string mode,
105 const std::string &ip, int port)
106 {_external_interface.connectExternalSocket(signal, mode, ip, port);}
107
113 const std::string shmem_address)
114 {_external_interface.connectExternalSharedMemory(signal, mode, shmem_address);}
115
120 int16 registerApp(warpos::App& app, int16 slot) override;
121
124 const std::vector<warpos::App*>& allApps() {return _all_apps;}
125
131 void logLevel(log_level_e log_level) {_local_log_level = log_level;}
132
135 protected:
139 int _executeAppThread(std::vector<warpos::App*> &app_thread);
140
142 std::vector<warpos::App*> _all_apps;
143 std::vector<warpos::App*> _startup;
144 std::vector<std::vector<warpos::App*>> _start_step;
145 std::vector<std::vector<warpos::App*>> _derivative;
146 std::vector<std::vector<warpos::App*>> _end_step;
147
149 int16 _error;
150
153
156
157 // Timing variables to ensure real time lock
158 bool _is_first_step = true;
162
163 // Handle to the executive for logging
165
168 private:
169 GraphTreeObject* _children[20];
170 };
171}
172
173#endif
#define NSEC_MAX
Constants for this class.
Definition Time.h:35
#define SIGNAL(NAME, TYPE, INITIAL_VALUE)
Definition appmacros.h:27
#define START_PARAMS
Definition appmacros.h:42
#define END_OUTPUTS
Definition appmacros.h:33
#define END_PARAMS
Definition appmacros.h:47
#define START_OUTPUTS
Definition appmacros.h:28
#define END_INPUTS
Definition appmacros.h:40
#define START_INPUTS
Definition appmacros.h:35
Definition DataIOBase.h:63
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
Base app class for derived implementation.
Definition App.h:55
Base class implementation of the scheduler.
Definition Scheduler.h:42
Manage all external interfaces to and from warptwin.
Definition ExternalInterfaceModel.h:54
Frame class definition.
Definition Frame.h:96
clockwerk::Time _real_time_step
Definition SimScheduler.h:160
SimulationExecutive & exc
Definition SimScheduler.h:164
std::vector< warpos::App * > _all_apps
Vectors to store the sequences for each element of the simulation scheduler.
Definition SimScheduler.h:142
int16 _error
Variable to catch errors from stuff.
Definition SimScheduler.h:149
int16 registerApp(warpos::App &app, int16 slot) override
Function to register apps with the scheduler. Depending on the scheduler implementation these may be ...
Definition SimScheduler.cpp:57
log_level_e _local_log_level
The log level for this particular app.
Definition SimScheduler.h:167
std::vector< std::vector< warpos::App * > > _end_step
Definition SimScheduler.h:146
int16 run() override
Function to run the scheduler until pre-determined end conditions identified/calculated by the schedu...
Definition SimScheduler.cpp:214
int16 step(const clockwerk::Time &step_size=clockwerk::Time(0, 999999999+1)) override
Function to step the scheduler by a single step.
Definition SimScheduler.cpp:135
warptwin::SimTimeManager time
Time manager to handle all time in the scheduler.
Definition SimScheduler.h:134
SimScheduler(SimulationExecutive &executive)
Constructor for the scheduler.
Definition SimScheduler.cpp:29
std::vector< std::vector< warpos::App * > > _derivative
Definition SimScheduler.h:145
clockwerk::Time _next_time
Definition SimScheduler.h:161
bool _is_first_step
Definition SimScheduler.h:158
int _executeAppThread(std::vector< warpos::App * > &app_thread)
Function to execute a single app thread.
Definition SimScheduler.cpp:239
void connectExternalSharedMemory(clockwerk::DataIOBase &signal, std::string mode, const std::string shmem_address)
Connect a signal to an external shared memory.
Definition SimScheduler.h:112
SixDOFDynamicsModel _dynamics
Our 6-DOF dynamics model.
Definition SimScheduler.h:152
clockwerk::Time _sim_time_step
Definition SimScheduler.h:159
void logLevel(log_level_e log_level)
Set the executive log level.
Definition SimScheduler.h:131
ExternalInterfaceModel _external_interface
Our external interface model.
Definition SimScheduler.h:155
std::vector< warpos::App * > _startup
Definition SimScheduler.h:143
int16 startup() override
Function to start and configure the scheduler prior to run.
Definition SimScheduler.cpp:98
log_level_e logLevel()
Get the log level set for the executive.
Definition SimScheduler.h:128
void connectExternalSocket(clockwerk::DataIOBase &signal, std::string mode, const std::string &ip, int port)
Connect a signal to an external socket.
Definition SimScheduler.h:104
std::vector< std::vector< warpos::App * > > _start_step
Definition SimScheduler.h:144
const std::vector< warpos::App * > & allApps()
Handle to acquire access to all apps.
Definition SimScheduler.h:124
Class to manage time for the simulation object.
Definition SimTimeManager.h:70
Implementation of the executive class for simulation.
Definition SimulationExecutive.h:64
Model to implement 6-DOF dynamics.
Definition SixDOFDynamicsModel.h:76
log_level_e
Log level enumerations.
Definition flighterrors.h:159
@ LOG_WARNING
Output in almost all cases.
Definition flighterrors.h:162
Definition CircularBuffer.hpp:28
Extensions to the C++ standard library.
Definition half.hpp:2325
Class to propagate CR3BP dynamics in characteristic units.
Definition statistics.hpp:22
SIGNAL(_mu, double, warpos::earth_wgs84.mu)
clockwerk::DataIO< clockwerk::Time > rate
This is the rate at which the scheduler should run, as a Time object.
Definition SimScheduler.h:67
clockwerk::DataIO< clockwerk::Time > exit_time
The time at which the last scheduler step was exited. Does not change wrt max_real_time_multiple.
Definition SimScheduler.h:74
clockwerk::DataIO< clockwerk::Time > entry_time
The time at which the last scheduler step was entered.
Definition SimScheduler.h:72
clockwerk::DataIO< int > max_real_time_multiple
Definition SimScheduler.h:62
clockwerk::DataIO< int > integrator_type
The integrator type for the scheduler. Sets how models are integrated.
Definition SimScheduler.h:54
clockwerk::DataIO< Frame * > root_frame_ptr
This is a pointer to the simulation's root frame. Sets frame for dynamics model.
Definition SimScheduler.h:56