 |
JSBSim Flight Dynamics Model
1.1.11 (13 Feb 2022)
An Open Source Flight Dynamics and Control Software Library in C++
|
43 #include "input_output/FGOutputTextFile.h"
44 #include "input_output/FGOutputFG.h"
45 #include "input_output/FGXMLFileRead.h"
46 #include "input_output/FGModelLoader.h"
56 FGOutput::FGOutput(FGFDMExec* fdmex) : FGModel(fdmex)
58 typedef int (FGOutput::*iOPV)(void)
const;
72 for (
auto output: OutputTypes)
84 if (!FGModel::InitModel())
return false;
86 for (
auto output: OutputTypes)
87 ret &= output->InitModel();
96 if (FDMExec->GetTrimStatus())
return true;
98 if (Holding)
return false;
99 if (!enabled)
return true;
101 for (
auto output: OutputTypes)
111 for (
auto output: OutputTypes)
119 for (
auto output: OutputTypes)
120 output->SetStartNewOutput();
127 if (idx >= (
int)0 && idx < (
int)OutputTypes.size())
128 return OutputTypes[idx]->Toggle();
137 for (
auto output: OutputTypes)
138 output->SetRateHz(rate);
145 if (idx >= (
int)0 && idx < (
int)OutputTypes.size())
146 OutputTypes[idx]->Print();
153 if (idx >= OutputTypes.size())
return false;
155 OutputTypes[idx]->SetOutputName(name);
165 if (idx < OutputTypes.size())
166 name = OutputTypes[idx]->GetOutputName();
178 s <<
"Could not read directive file: " << fname;
182 bool result =
Load(document);
184 cerr << endl <<
"Aircraft output element has problems in file " << fname << endl;
192 std::string port, std::string name,
double outRate,
193 std::vector<FGPropertyNode_ptr> & outputProperties)
195 size_t idx = OutputTypes.size();
198 if (debug_lvl > 0) cout << endl <<
" Output data set: " << idx << endl;
200 type = to_upper(type);
205 Output = OutputTextFile;
206 }
else if (type ==
"TABULAR") {
209 Output = OutputTextFile;
210 }
else if (type ==
"SOCKET") {
212 name +=
":" + port +
"/" + protocol;
213 }
else if (type ==
"FLIGHTGEAR") {
215 name +=
":" + port +
"/" + protocol;
216 }
else if (type ==
"TERMINAL") {
218 }
else if (type !=
string(
"NONE")) {
219 cerr <<
"Unknown type of output specified in config file" << endl;
222 if (!Output)
return false;
230 OutputTypes.push_back(Output);
247 size_t idx = OutputTypes.size();
251 if (debug_lvl > 0) cout << endl <<
" Output data set: " << idx <<
" " << endl;
253 type = to_upper(type);
257 }
else if (type ==
"TABULAR") {
259 }
else if (type ==
"SOCKET") {
261 }
else if (type ==
"FLIGHTGEAR") {
263 }
else if (type ==
"TERMINAL") {
265 }
else if (type !=
string(
"NONE")) {
266 cerr <<
"Unknown type of output specified in config file" << endl;
269 if (!Output)
return false;
272 Output->PreLoad(document, FDMExec);
273 Output->
Load(document);
274 Output->PostLoad(document, FDMExec);
276 OutputTypes.push_back(Output);
284 SGPath FGOutput::FindFullPathName(
const SGPath& path)
const
287 if (!includePath.isNull()) {
288 SGPath name = CheckPathName(includePath, path);
289 if (!name.isNull())
return name;
292 return FGModel::FindFullPathName(path);
314 void FGOutput::Debug(
int from)
316 if (debug_lvl <= 0)
return;
325 if (debug_lvl & 2 ) {
326 if (from == 0) cout <<
"Instantiated: FGOutput" << endl;
327 if (from == 1) cout <<
"Destroyed: FGOutput" << endl;
329 if (debug_lvl & 4 ) {
331 if (debug_lvl & 8 ) {
333 if (debug_lvl & 16) {
335 if (debug_lvl & 64) {
Abstract class to provide functions generic to all the output directives.
bool Upload(Element *el, bool preLoad)
Uploads this model in memory.
std::string GetAttributeValue(const std::string &key)
Retrieves an attribute.
void Print(void)
Makes all the output instances to generate their ouput.
void ForceOutput(int idx)
Force an output instance to generate its output.
bool Load(Element *el, const SGPath &dir=SGPath())
Load the output directives and adds a new output instance to the Output Manager list.
bool SetDirectivesFile(const SGPath &fname)
Adds a new output instance to the Output Manager.
void SetIdx(unsigned int idx)
Set the idx for this output instance.
void SetSubSystems(int subSystems)
Set the activated subsystems for this output instance.
std::string GetOutputName(unsigned int idx) const
Get the name identifier to which the output will be directed.
void SetOutputProperties(std::vector< FGPropertyNode_ptr > &outputProperties)
Set the list of properties that should be output for this output instance.
void SetStartNewOutput(void)
Reset the output prior to a restart of the simulation.
bool InitModel(void) override
Initializes the instance.
virtual bool Run(bool Holding)
Runs the model; called by the Executive.
Implements the output to a FlightGear socket.
bool SetOutputName(unsigned int idx, const std::string &name)
Overwrites the name identifier under which the output will be logged.
virtual void SetOutputName(const std::string &name)
Overwrites the name identifier under which the output will be logged.
This class is solely for the purpose of determining what type of file is given on the command line.
void SetRateHz(double rtHz)
Set the output rate for this output instances.
Implements the output to a human readable text file.
void SetDelimiter(const std::string &delim)
Set the delimiter.
void SetRateHz(double rate)
Modifies the output rate for all output instances.
bool Load(Element *el) override
Init the output directives from an XML file (implement the FGModel interface).
bool Run(bool Holding) override
Runs the Output model; called by the Executive.
bool Toggle(int idx)
Toggles the output generation of each ouput instance.
Implements the output to a socket.