WarpTwin
Documentation for WarpTwin models and classes.
Loading...
Searching...
No Matches
Model.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/*
17Model header file - Includes declaration for model class which is the simulation base unit
18
19Author: Alex Reynolds
20*/
21#ifndef SIMULATION_MODEL_H
22#define SIMULATION_MODEL_H
23
24#include "nlohmann/json.hpp"
25
26#include "flight/App.h"
27#include "SimulationSteps.h"
28#include "SimulationExecutive.h"
29
30// --------------------------------------------------------------------------
31// Model naming macro
32// --------------------------------------------------------------------------
33// This macro works only inside models, and is used to generate a model class
34// name. It exists more or less to prevent duplication of model naming efforts
35// by creating the model class name, associated constructors, and setting the
36// internal name of the model
37#define MODEL(MODEL_NAME) \
38class MODEL_NAME : public Model {\
39public:\
40 MODEL_NAME(Model &pnt, const std::string &m_name=#MODEL_NAME);\
41 MODEL_NAME(SimulationExecutive &e, const std::string &m_name=#MODEL_NAME);\
42 MODEL_NAME(Model &pnt, int schedule_slot, const std::string &m_name=#MODEL_NAME);\
43 MODEL_NAME(SimulationExecutive &e, int schedule_slot, const std::string &m_name=#MODEL_NAME);\
44 virtual ~MODEL_NAME();\
45protected:\
46 virtual std::string classType() {return #MODEL_NAME;}
47
48
51#define MODEL_LOG(LEVEL, MESSAGE)\
52 if((uint8)LEVEL) {\
53 std::string log_msg = MESSAGE;\
54 LOG(LEVEL, log_msg.c_str());\
55 }
56
57namespace warptwin {
58 class SimulationExecutive;
59
88 class Model : public warpos::App {
89 public:
96 Model(Model &pnt, int16 schedule_slot, const std::string &m_name="Unnamed");
97
104 Model(SimulationExecutive &executive, int16 schedule_slot, const std::string &m_name="Unnamed");
105
107 virtual ~Model() {};
108
114 std::vector<std::string> listDefaultConfigs();
115
122 int configureFromDefault(const std::string &default_name);
123
130 int configureFromJson(const std::string &file_path);
131
138 int configureFromJson(nlohmann::json j);
139
142 virtual nlohmann::json asJson();
143
145 void dump();
146 protected:
151
154 virtual std::string classType() {return "Model";}
155
158
160 int16 _schedule_slot = 0;
161 };
162}
163
164#endif
Base app class for derived implementation.
Definition App.h:55
virtual std::string classType()
Return the name of the class type.
Definition Model.h:154
int16 _schedule_slot
Internal variable to hold schedule slot for model.
Definition Model.h:160
int configureFromJson(const std::string &file_path)
Configure model from a json file with keys as params of the model.
Definition Model.cpp:62
std::string _default_configuration_name
Hold default configuration name model is defined from.
Definition Model.h:157
std::vector< std::string > listDefaultConfigs()
List all default options for the model type.
Definition Model.cpp:46
virtual nlohmann::json asJson()
Get model information as json.
Definition Model.cpp:100
Model(Model &pnt, int16 schedule_slot, const std::string &m_name="Unnamed")
Task-based constructor for the task. Auto-assigns executive.
Definition Model.cpp:26
SimulationExecutive & exc
Definition Model.h:150
int configureFromDefault(const std::string &default_name)
Configure model from a default configuration.
Definition Model.cpp:50
void dump()
Dump all information associated with the model.
Definition Model.cpp:151
virtual ~Model()
Desrtuctor. Doesn't really do anything.
Definition Model.h:107
Implementation of the executive class for simulation.
Definition SimulationExecutive.h:64
Class to propagate CR3BP dynamics in characteristic units.
Definition statistics.hpp:22