WarpTwin
Documentation for WarpTwin models and classes.
Loading...
Searching...
No Matches
VisualsModel.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/*
17Visuals model header file
18
19Author: Alex Reynolds
20*/
21
22#ifndef SIMULATION_VISUALS_MODEL_H
23#define SIMULATION_VISUALS_MODEL_H
24
25#include <string>
26#include <map>
27#include <set>
28#include <fstream>
29
31#include "frames/Frame.h"
32#include "dynamics/Quaternion.h"
33#include "locations.h"
34#include "flight/App.h"
35#include "core/mathmacros.h"
36
37namespace warptwin {
38
39 class RateMonitor;
41 class GroundStationModel;
42 class SpacecraftLinkModel;
43
55 class VisualsModel : public warpos::App {
56 public:
57 // Model params
58 // NAME TYPE DEFAULT VALUE
65 SIGNAL(gs_rate, clockwerk::Time, clockwerk::Time(1, 0))
67 SIGNAL(lead_time, clockwerk::Time, clockwerk::Time(0, 0))
69 SIGNAL(trail_time, clockwerk::Time, clockwerk::Time(5400, 0))
87 SIGNAL(real_time, bool, false)
89 SIGNAL(live_ip, std::string, "127.0.0.1")
91 SIGNAL(live_port, int, 40123)
93
94 // Model inputs
95 // NAME TYPE DEFAULT VALUE
97
99
100 // Model outputs
101 // NAME TYPE DEFAULT VALUE
103
105
109 int addFrame(Frame* new_frame_ptr, const std::string& visual_model_dir = "");
110
115
121 int addLink(clockwerk::GraphTreeObject* new_scl_pointer);
122
123 // Model-specific implementations of startup and derivative
124 VisualsModel(warpos::FlightExecutive &e, const std::string &m_name="visuals_model");
125 virtual ~VisualsModel();
126
128 protected:
129 int16 start() override;
130 int16 execute() override;
131
132 // Internal storage for planet inertial/rotating frames
133 // Initialized to nullptr so _runAppProcess() (called before start() sets
134 // these) safely skips the planet-name detection block.
137
139 void _runAppProcess();
140
144 std::string _slurpFile(std::ifstream& in);
145
149 void _generateCzmlString(std::string czml_template);
150
152 void _writeCzmlFile();
153
155 void _sendCzmlSocket();
156
159
161 std::ofstream _fout;
162
164 int _sock_fd = 0;
165
167 std::string _sim_start_time;
168
169 // Set of vectors to log tracked spacecraft frames, spacecraft models, spacecraft times, and spacecraft states at those times
170 std::vector<Frame*> _sc_frames;
171 std::vector<std::string> _sc_frame_models;
172 std::vector<double> _sc_times;
173 std::vector<std::vector<CartesianVector3>> _sc_positions;
174 std::vector<std::vector<clockwerk::Quaternion>> _sc_attitudes;
176 RateMonitor* _sc_rate_monitor; // Controls the rate of SC logging
177
178 // Set of vectors to log ground station states
179 std::vector<GroundStationModel*> _gs_models;
180 std::vector<std::vector<std::string>> _gs_sign_times_et; // Vector of times when GS visibility changed. Must include zero time
181 std::vector<std::vector<bool>> _gs_sign_after_time; // Vector of GS visibility signs after corresponding entry in _gs_sign_times_et
182 // with true = visible and false = not visible
183 RateMonitor* _gs_rate_monitor; // Controls the rate of GS logging
184
185 // Set of vectors to log linkages between spacecraft
186 std::vector<SpacecraftLinkModel*> _scl_models;
187 std::vector<std::string> _link_names;
188 std::vector<std::vector<std::string>> _scl_sign_times_et; // Vector of times when GS visibility changed. Must include zero time
189 std::vector<std::vector<bool>> _scl_sign_after_time; // Vector of GS visibility signs after corresponding entry in _gs_sign_times_et
190 // with true = visible and false = not visible
191
192 // String information with templates and a location for generated json
194 std::string _socket_template;
195 std::string _sat_template;
196 std::string _gs_template;
197 std::string _fl_template;
198 std::string _link_template;
199 std::string _sc_link_template;
200 std::string _generated_json;
201 };
202}
203
204#endif
#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
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
Frame class definition.
Definition Frame.h:96
Implementation of the executive class for simulation.
Definition SimulationExecutive.h:64
std::string _generated_json
String to hold generated json.
Definition VisualsModel.h:200
std::string _sc_link_template
Definition VisualsModel.h:199
std::vector< std::vector< bool > > _scl_sign_after_time
Definition VisualsModel.h:189
std::vector< std::string > _sc_frame_models
Definition VisualsModel.h:171
std::vector< std::vector< clockwerk::CartesianVector< 3 > > > _sc_positions
Definition VisualsModel.h:173
std::string _gs_template
Definition VisualsModel.h:196
SimulationExecutive * _smex
Handle to the simulation executive – should be used in place of exc.
Definition VisualsModel.h:158
std::vector< double > _sc_times
Definition VisualsModel.h:172
std::string _socket_template
String to hold socket template.
Definition VisualsModel.h:194
std::vector< std::vector< std::string > > _gs_sign_times_et
Definition VisualsModel.h:180
clockwerk::CartesianVector< 3 > _pos_f_planet_frame
Definition VisualsModel.h:175
int addFrame(Frame *new_frame_ptr, const std::string &visual_model_dir="")
Add frame to visuals for logging.
Definition VisualsModel.cpp:102
Frame * _planet_fixed_ptr
Definition VisualsModel.h:136
std::vector< SpacecraftLinkModel * > _scl_models
Definition VisualsModel.h:186
std::vector< std::string > _link_names
Definition VisualsModel.h:187
std::string _link_template
Definition VisualsModel.h:198
std::string _sat_template
Templates for individual components.
Definition VisualsModel.h:195
Frame * _planet_inertial_ptr
Definition VisualsModel.h:135
std::vector< GroundStationModel * > _gs_models
Definition VisualsModel.h:179
int16 start() override
Definition VisualsModel.cpp:167
int _sock_fd
Socket stream variable to write out live updates.
Definition VisualsModel.h:164
void _runAppProcess()
Kick off the python server application.
Definition VisualsModel.cpp:358
int addLink(clockwerk::GraphTreeObject *new_scl_pointer)
Create a link between two spacecraft (one primary and one secondary) for logging.
Definition VisualsModel.cpp:143
std::string _fl_template
Definition VisualsModel.h:197
RateMonitor * _sc_rate_monitor
Definition VisualsModel.h:176
void _sendCzmlSocket()
Write out CZML file over socket.
Definition VisualsModel.cpp:429
int addGroundStation(clockwerk::GraphTreeObject *new_gs_ptr)
Add gs to visuals for logging.
Definition VisualsModel.cpp:121
std::vector< std::vector< clockwerk::Quaternion > > _sc_attitudes
Definition VisualsModel.h:174
std::vector< std::vector< std::string > > _scl_sign_times_et
Definition VisualsModel.h:188
RateMonitor * _gs_rate_monitor
Definition VisualsModel.h:183
void forceWrite()
Definition VisualsModel.h:127
VisualsModel(warpos::FlightExecutive &e, const std::string &m_name="visuals_model")
Definition VisualsModel.cpp:83
std::ofstream _fout
Stream variable to write file to.
Definition VisualsModel.h:161
std::string _slurpFile(std::ifstream &in)
Load an entire file into a std::string.
Definition VisualsModel.cpp:404
std::vector< std::vector< bool > > _gs_sign_after_time
Definition VisualsModel.h:181
std::vector< Frame * > _sc_frames
Definition VisualsModel.h:170
void _generateCzmlString(std::string czml_template)
Generate a CZML file string from a given CZML template.
Definition VisualsModel.cpp:438
std::string _czml_file_template
String to hold CZML file template.
Definition VisualsModel.h:193
std::string _sim_start_time
Ephemeris time of simulation start.
Definition VisualsModel.h:167
void _writeCzmlFile()
Write out CZML file once all model stuff is done.
Definition VisualsModel.cpp:410
int16 execute() override
Definition VisualsModel.cpp:267
#define CartesianVector3
Definition mathmacros.h:43
Definition CircularBuffer.hpp:28
Extensions to the C++ standard library.
Definition half.hpp:2325
Definition DeadReckon.cpp:20
Class to propagate CR3BP dynamics in characteristic units.
Definition statistics.hpp:22
SIGNAL(_mu, double, warpos::earth_wgs84.mu)
clockwerk::DataIO< clockwerk::Time > trail_time
Definition VisualsModel.h:69
clockwerk::DataIO< bool > real_time
Definition VisualsModel.h:87
clockwerk::DataIO< int > live_port
Definition VisualsModel.h:91
clockwerk::DataIO< clockwerk::Time > sc_rate
Definition VisualsModel.h:63
clockwerk::DataIO< int > run_cesium_app
Definition VisualsModel.h:72
clockwerk::DataIO< clockwerk::Time > gs_rate
Definition VisualsModel.h:65
clockwerk::DataIO< GraphTreeObject * > planet_ptr
Definition VisualsModel.h:79
clockwerk::DataIO< std::string > live_ip
Definition VisualsModel.h:89
clockwerk::DataIO< clockwerk::Time > lead_time
Definition VisualsModel.h:67