WSF
WsfSixDOF_PropulsionSystem.hpp
Go to the documentation of this file.
1// ****************************************************************************
2// CUI
3//
4// The Advanced Framework for Simulation, Integration, and Modeling (AFSIM)
5//
6// Copyright 2020 Infoscitex, a DCS Company. All rights reserved.
7//
8// The use, dissemination or disclosure of data in this file is subject to
9// limitation or restriction. See accompanying README and LICENSE for details.
10// ****************************************************************************
11
12#ifndef WSFSIXDOFPROPULSIONSYSTEM_HPP
13#define WSFSIXDOFPROPULSIONSYSTEM_HPP
14
15#include "wsf_six_dof_export.h"
16
17#include <cinttypes>
18#include <string>
19#include <unordered_map>
20#include <vector>
21
22class UtInput;
23#include "UtVec3dX.hpp"
26#include "WsfSixDOF_Object.hpp"
28#include "WsfSixDOF_Utils.hpp"
29
30namespace wsf
31{
32namespace six_dof
33{
34class WSF_SIX_DOF_EXPORT PropulsionSystem : public Object
35{
36public:
37 PropulsionSystem() = default;
38
40
42 {
43 std::string xferName;
44 std::string sourceTankName;
45 std::string targetTankName;
46 FuelTank* sourceTank = nullptr;
47 FuelTank* targetTank = nullptr;
48 };
49
50 void SetParentVehicle(Mover* aParentVehicle) override;
51
52 // ProcessInput reads initialization data
53 virtual bool Initialize(int64_t aSimTime_nanosec) = 0;
54
55 // Update should be called every frame. It clears the temp attributes and
56 // sets the current attributes. The other 'update functions' (UpdateFuelBurn,
57 // UpdateFuelFill, and UpdateFuelTransfer) should be called prior to calling
58 // the Update function.
59 virtual void Update(int64_t aSimTime_nanosec);
60
61 void SetLastSimTime(int64_t aLastSimTime_nanosec) { mLastSimTime_nanosec = aLastSimTime_nanosec; }
62
63 // GetFuelTankList returns the list of fuel tanks in this propulsion object
64 const std::unordered_map<std::string, UtCloneablePtr<FuelTank>>& GetFuelTanks() const { return mFuelTankMap; }
65
66 // GetFuelTank returns the fuel tank with the specified name
67 FuelTank* GetFuelTank(const std::string& aName) const;
68
69 // GetThrustProducerObjectByName returns the engine with the specified name
70 virtual ThrustProducerObject* GetThrustProducerObjectByName(const std::string& aName) const = 0;
71
72 // GetThrustProduceByIndex returns the engine with the specified index
73 virtual ThrustProducerObject* GetThrustProducerByIndex(size_t aIndex) const = 0;
74
75 // SetThrottleLeverPosition sets the throttles on all engines of this object
76 virtual void SetThrottleLeverPosition(double aThrottleLeverPosition) = 0;
77
78 // EnableThrustVectoring enables/disable thrust vectoring
79 virtual void EnableThrustVectoring(bool aEnableThrustVectoring) = 0;
80
81 // Returns true if vectoring is enabled
83
84 // Returns true if an afterburner is present on any engine
85 virtual bool AfterburnerIsPresent() const = 0;
86
87 // GetNumThrustProducers returns the number of engines in this propulsion object
88 virtual size_t GetNumThrustProducers() const = 0;
89
90 // GetNumFuelTanks returns the number of fuel tanks in this propulsion object
91 size_t GetNumFuelTanks() const;
92
93 // Ignite ignites/starts all engines of this object
94 virtual void Ignite(int64_t aIgniteTimeInFrame_nanosec) = 0;
95
96 // Shutdown terminates thrust for all engines of this object
97 // aTerminateTime_sec is the time termination occurs
98 virtual void Shutdown(int64_t aTerminateTime_nanosec = 0) = 0;
99
100 // RemoveFuelTankByName returns true if the tank was removed
101 bool RemoveFuelTankByName(std::string aName);
102
103 // This adds a tank to the propulsion system, and links the tank to the propulsion system and vehicle
104 bool AddFuelTank(std::unique_ptr<FuelTank> aFuelTank);
105
106 // This requests adding a fuel transfer, but does not "connect it up".
107 // It is typically used during setup (such as ProcessInput) and
108 // returns true if the fuel transfer was added.
109 bool AddFuelTransfer(const std::string& aTransferName,
110 const std::string& aSourceTankName,
111 const std::string& aTargetTankName);
112
113 // This is used to support script-commanded fuel transfers and "connects
114 // it up" within the fuel system. It returns true if the fuel transfer was added.
115 bool AddFuelTransferAndConnect(const std::string& aTransferName,
116 const std::string& aSourceTankName,
117 const std::string& aTargetTankName);
118
119 // RemoveFuelTransfer returns true if the transfer was removed
120 bool RemoveFuelTransfer(const std::string& aTransferName);
121
122 bool ModifyFuelQuantity(const std::string& aTankName, double aQty_lbs);
123
124 bool FuelTransferNameUnique(const std::string& aName) const;
125
126 // This returns true is at least one thrust producer is producing thrust
127 virtual bool IsProducingThrust() const = 0;
128
129 // This specifies the fuel feed (input tank name) for the specified engine.
130 // It returns true if the assignment is successful.
131 virtual bool SetFuelFeed(std::string& aEngineName, std::string aFuelTankName) = 0;
132
133 // This specifies the fuel feed (input tank name) for all engines.
134 // It returns true if the assignment is successful.
135 virtual bool SetFuelFeed(std::string aFuelTankName) = 0;
136
137 // .....................................................................................................
138
139 // This returns the maximum internal fuel for the object.
140 // Note that this is quantity of fuel in fuel tanks, and does not include fuel in solid propellant rockets, for example.
141 double GetInternalFuelTankCapacity_lbs() const;
142
143 // This returns the current internal fuel for the object
145
146 // This adds fuel in a simplistic manner. It does not use the "fill rate" limit of
147 // tanks -- hence all of the fuel is put into the tank(s) at once. Later, we can
148 // add a "proper" fuel fill that is more realistic and deals with a fill rate
149 // that will require a finite amount of time to transfer. This function will try to
150 // fill all tanks, but if insufficient fuel is being added, it will split the fuel
151 // across tanks, making all tanks the same percent full. The function returns the
152 // amount of fuel added.
153 double AddFuelQuantity_lbs(double aFuelToAdd_lbs);
154
155 // This adds fuel, as needed, to each tank in the system to the specified
156 // percent full level for each tank. If the tank was already at a higher
157 // percent full, fuel will be "drained" to bring it to the specified level.
158 // The function returns the amount of fuel used in filling/draining all tanks.
159 double FillAllTanks(double aPercentFull);
160
161 // This drains all fuel from all of the tanks
162 void EmptyAllTanks();
163
164 // .....................................................................................................
165
166 // This returns the summed mass properties for the propulsion system
167 const MassProperties GetMassProperties() const;
168
169 // .....................................................................................................
170
171 // Appearance Parameters. These will determine if any engine has the specified condition.
172 // After using this function, individual engines can be consulted for their conditions.
173
174 // Return true if at least one engine is operating.
175 // If aTestSubobjects (optional) is true, if will test subobjects. Otherwise, it
176 // will only test its own propulsion objects (the default).
177 virtual bool AnEngineIsOperating(bool aTestSubobjects = false) const = 0;
178
179 // Return true if at least one engine is operating
180 // If aTestSubobjects (optional) is true, if will test subobjects. Otherwise, it
181 // will only test its own propulsion objects (the default).
182 virtual bool AnEngineIsSmoking(bool aTestSubobjects = false) const = 0;
183
184 // Return true if at least one engine is operating
185 // If aTestSubobjects (optional) is true, if will test subobjects. Otherwise, it
186 // will only test its own propulsion objects (the default).
187 virtual bool AnEngineHasAfterburnerOn(bool aTestSubobjects = false) const = 0;
188
189 // Return true if at least one engine is contrailing
190 // If aTestSubobjects (optional) is true, if will test subobjects. Otherwise, it
191 // will only test its own propulsion objects (the default).
192 virtual bool AnEngineIsContrailing(bool aTestSubobjects = false) const = 0;
193
194 // Return true if at least one engine has a smoke trailing effect
195 // If aTestSubobjects (optional) is true, if will test subobjects. Otherwise, it
196 // will only test its own propulsion objects (the default).
197 virtual bool AnEngineIsEmittingSmokeTrail(bool aTestSubobjects = false) const = 0;
198
199 // This will make an engine smoke. If an index of zero is used, all engines will smoke.
200 virtual void MakeAnEngineSmoke(int aEngineIndex) = 0;
201
202 // .....................................................................................................
203
204protected:
206
208
210 {
211 std::string fuelFeedName;
214 };
215
217 {
220 };
221
223 {
225 std::vector<FuelTankData> sourceTankList;
226 };
227
228 std::vector<std::unique_ptr<FuelTransfer>> mFuelTransferList;
229 std::unordered_map<std::string, UtCloneablePtr<FuelTank>> mFuelTankMap;
230
232
233 double mPropulsionSystemThrottleLeverPosition = 0.0; // Overall throttle lever position
235
237};
238} // namespace six_dof
239} // namespace wsf
240
241#endif
aObjectPtr Update(simTime)
Definition WsfSixDOF_FuelTank.hpp:35
Definition WsfSixDOF_MassProperties.hpp:29
This is a base class for detailed air movers. This umbrella can cover RB6 or PM6 models.
Definition WsfSixDOF_Mover.hpp:58
double FillAllTanks(double aPercentFull)
Definition WsfSixDOF_PropulsionSystem.cpp:471
virtual bool AnEngineIsOperating(bool aTestSubobjects=false) const =0
bool AddFuelTransferAndConnect(const std::string &aTransferName, const std::string &aSourceTankName, const std::string &aTargetTankName)
Definition WsfSixDOF_PropulsionSystem.cpp:322
double GetInternalFuelTankCapacity_lbs() const
Definition WsfSixDOF_PropulsionSystem.cpp:413
PropulsionSystem & operator=(const PropulsionSystem &other)=delete
size_t GetNumFuelTanks() const
Definition WsfSixDOF_PropulsionSystem.cpp:518
virtual bool AfterburnerIsPresent() const =0
virtual void Ignite(int64_t aIgniteTimeInFrame_nanosec)=0
virtual void Shutdown(int64_t aTerminateTime_nanosec=0)=0
virtual bool SetFuelFeed(std::string aFuelTankName)=0
virtual ThrustProducerObject * GetThrustProducerObjectByName(const std::string &aName) const =0
void SetParentVehicle(Mover *aParentVehicle) override
Definition WsfSixDOF_PropulsionSystem.cpp:21
virtual bool IsProducingThrust() const =0
virtual bool AnEngineHasAfterburnerOn(bool aTestSubobjects=false) const =0
bool ThrustVectoringEnabled() const
Definition WsfSixDOF_PropulsionSystem.hpp:82
double mPropulsionSystemThrottleLeverPosition
Definition WsfSixDOF_PropulsionSystem.hpp:233
void RemoveInvalidFuelTransfers()
Definition WsfSixDOF_PropulsionSystem.cpp:53
virtual void MakeAnEngineSmoke(int aEngineIndex)=0
virtual bool AnEngineIsEmittingSmokeTrail(bool aTestSubobjects=false) const =0
bool ModifyFuelQuantity(const std::string &aTankName, double aQty_lbs)
Definition WsfSixDOF_PropulsionSystem.cpp:399
virtual void EnableThrustVectoring(bool aEnableThrustVectoring)=0
double GetCurrentInternalFuelTankQuantity_lbs() const
Definition WsfSixDOF_PropulsionSystem.cpp:424
bool AddFuelTransfer(const std::string &aTransferName, const std::string &aSourceTankName, const std::string &aTargetTankName)
Definition WsfSixDOF_PropulsionSystem.cpp:295
virtual bool AnEngineIsContrailing(bool aTestSubobjects=false) const =0
double AddFuelQuantity_lbs(double aFuelToAdd_lbs)
Definition WsfSixDOF_PropulsionSystem.cpp:435
const std::unordered_map< std::string, UtCloneablePtr< FuelTank > > & GetFuelTanks() const
Definition WsfSixDOF_PropulsionSystem.hpp:64
void SetLastSimTime(int64_t aLastSimTime_nanosec)
Definition WsfSixDOF_PropulsionSystem.hpp:61
virtual bool AnEngineIsSmoking(bool aTestSubobjects=false) const =0
virtual void SetThrottleLeverPosition(double aThrottleLeverPosition)=0
const MassProperties GetMassProperties() const
Definition WsfSixDOF_PropulsionSystem.cpp:499
bool mEnableThrustVectoring
Definition WsfSixDOF_PropulsionSystem.hpp:236
std::unordered_map< std::string, UtCloneablePtr< FuelTank > > mFuelTankMap
Definition WsfSixDOF_PropulsionSystem.hpp:229
void EmptyAllTanks()
Definition WsfSixDOF_PropulsionSystem.cpp:491
bool RemoveFuelTransfer(const std::string &aTransferName)
Definition WsfSixDOF_PropulsionSystem.cpp:384
int64_t mLastSimTime_nanosec
Definition WsfSixDOF_PropulsionSystem.hpp:231
bool AddFuelTank(std::unique_ptr< FuelTank > aFuelTank)
Definition WsfSixDOF_PropulsionSystem.cpp:284
virtual bool SetFuelFeed(std::string &aEngineName, std::string aFuelTankName)=0
virtual ThrustProducerObject * GetThrustProducerByIndex(size_t aIndex) const =0
virtual size_t GetNumThrustProducers() const =0
bool FuelTransferNameUnique(const std::string &aName) const
Definition WsfSixDOF_PropulsionSystem.cpp:261
bool RemoveFuelTankByName(std::string aName)
Definition WsfSixDOF_PropulsionSystem.cpp:273
bool mThrottleLeverPositionSet
Definition WsfSixDOF_PropulsionSystem.hpp:234
virtual bool Initialize(int64_t aSimTime_nanosec)=0
std::vector< std::unique_ptr< FuelTransfer > > mFuelTransferList
Definition WsfSixDOF_PropulsionSystem.hpp:228
Definition WsfSixDOF_ThrustProducerObject.hpp:35
Definition WsfSA_Processor.hpp:35
Function definitions for those who need run-time access to the version.
Definition WsfComm.cpp:32
Definition WsfSixDOF_PropulsionSystem.hpp:217
double fuelActuallyProvided_lbs
Definition WsfSixDOF_PropulsionSystem.hpp:219
FuelTank * sourceTank
Definition WsfSixDOF_PropulsionSystem.hpp:218
Definition WsfSixDOF_PropulsionSystem.hpp:42
FuelTank * targetTank
Definition WsfSixDOF_PropulsionSystem.hpp:47
FuelTank * sourceTank
Definition WsfSixDOF_PropulsionSystem.hpp:46
std::string sourceTankName
Definition WsfSixDOF_PropulsionSystem.hpp:44
std::string xferName
Definition WsfSixDOF_PropulsionSystem.hpp:43
std::string targetTankName
Definition WsfSixDOF_PropulsionSystem.hpp:45
Definition WsfSixDOF_PropulsionSystem.hpp:223
FuelTank * targetAddTank
Definition WsfSixDOF_PropulsionSystem.hpp:224
std::vector< FuelTankData > sourceTankList
Definition WsfSixDOF_PropulsionSystem.hpp:225
Definition WsfSixDOF_PropulsionSystem.hpp:210
std::string fuelFeedName
Definition WsfSixDOF_PropulsionSystem.hpp:211
UtVec3dX relativePosition
Definition WsfSixDOF_PropulsionSystem.hpp:212
UtVec3dX relativeYawPitchRoll
Definition WsfSixDOF_PropulsionSystem.hpp:213
Copyrights Multiple, All Rights Reserved