43 #include "FGFDMExec.h" 44 #include "input_output/FGOutputSocket.h" 45 #include "input_output/FGOutputTextFile.h" 46 #include "input_output/FGOutputFG.h" 47 #include "input_output/FGUDPOutputSocket.h" 48 #include "input_output/FGXMLFileRead.h" 49 #include "input_output/FGXMLElement.h" 50 #include "input_output/FGModelLoader.h" 56 IDENT(IdSrc,
"$Id: FGOutput.cpp,v 1.87 2017/02/25 14:23:19 bcoconni Exp $");
57 IDENT(IdHdr,ID_OUTPUT);
63 FGOutput::FGOutput(FGFDMExec* fdmex) : FGModel(fdmex)
65 typedef int (FGOutput::*iOPV)(void)
const;
79 vector<FGOutputType*>::iterator it;
80 for (it = OutputTypes.begin(); it != OutputTypes.end(); ++it)
92 if (!FGModel::InitModel())
return false;
94 vector<FGOutputType*>::iterator it;
95 for (it = OutputTypes.begin(); it != OutputTypes.end(); ++it)
96 ret &= (*it)->InitModel();
105 if (FDMExec->GetTrimStatus())
return true;
107 if (Holding)
return false;
108 if (!enabled)
return true;
110 vector<FGOutputType*>::iterator it;
111 for (it = OutputTypes.begin(); it != OutputTypes.end(); ++it)
121 vector<FGOutputType*>::iterator it;
122 for (it = OutputTypes.begin(); it != OutputTypes.end(); ++it)
130 vector<FGOutputType*>::iterator it;
131 for (it = OutputTypes.begin(); it != OutputTypes.end(); ++it)
132 (*it)->SetStartNewOutput();
139 if (idx >= (
int)0 && idx < (
int)OutputTypes.size())
140 return OutputTypes[idx]->Toggle();
149 vector<FGOutputType*>::iterator it;
150 for (it = OutputTypes.begin(); it != OutputTypes.end(); ++it)
151 (*it)->SetRateHz(rate);
158 if (idx >= (
int)0 && idx < (
int)OutputTypes.size())
159 OutputTypes[idx]->Print();
166 if (idx >= OutputTypes.size())
return false;
168 OutputTypes[idx]->SetOutputName(name);
178 if (idx < OutputTypes.size())
179 name = OutputTypes[idx]->GetOutputName();
188 Element* document = XMLFile.LoadXMLDocument(fname);
189 bool result = Load(document);
192 cerr << endl <<
"Aircraft output element has problems in file " << fname << endl;
200 std::string port, std::string name,
double outRate,
201 std::vector<FGPropertyNode_ptr> & outputProperties)
203 size_t idx = OutputTypes.size();
206 if (debug_lvl > 0) cout << endl <<
" Output data set: " << idx << endl;
208 type = to_upper(type);
213 Output = OutputTextFile;
214 }
else if (type ==
"TABULAR") {
217 Output = OutputTextFile;
218 }
else if (type ==
"SOCKET") {
220 name +=
":" + port +
"/" + protocol;
221 }
else if (type ==
"FLIGHTGEAR") {
223 name +=
":" + port +
"/" + protocol;
224 }
else if (type ==
"QTJSBSIM") {
226 name +=
":" + port +
"/" + protocol;
227 }
else if (type ==
"TERMINAL") {
229 }
else if (type !=
string(
"NONE")) {
230 cerr <<
"Unknown type of output specified in config file" << endl;
233 if (!Output)
return false;
241 OutputTypes.push_back(Output);
257 Element* element = ModelLoader.Open(el);
259 if (!element)
return false;
261 FGModel::PreLoad(element, PropertyManager);
263 size_t idx = OutputTypes.size();
267 if (debug_lvl > 0) cout << endl <<
" Output data set: " << idx <<
" " << endl;
269 type = to_upper(type);
273 }
else if (type ==
"TABULAR") {
275 }
else if (type ==
"SOCKET") {
277 }
else if (type ==
"FLIGHTGEAR") {
279 }
else if (type ==
"QTJSBSIM") {
281 }
else if (type ==
"TERMINAL") {
283 }
else if (type !=
string(
"NONE")) {
284 cerr <<
"Unknown type of output specified in config file" << endl;
287 if (!Output)
return false;
290 Output->
Load(element);
291 PostLoad(element, PropertyManager);
293 OutputTypes.push_back(Output);
318 void FGOutput::Debug(
int from)
322 if (debug_lvl <= 0)
return;
331 if (debug_lvl & 2 ) {
332 if (from == 0) cout <<
"Instantiated: FGOutput" << endl;
333 if (from == 1) cout <<
"Destroyed: FGOutput" << endl;
335 if (debug_lvl & 4 ) {
337 if (debug_lvl & 8 ) {
339 if (debug_lvl & 16) {
341 if (debug_lvl & 64) {
343 cout << IdSrc << endl;
344 cout << IdHdr << endl;
void ForceOutput(int idx)
Force an output instance to generate its output.
void SetSubSystems(int subSystems)
Set the activated subsystems for this output instance.
std::string GetAttributeValue(const std::string &key)
Retrieves an attribute.
bool SetDirectivesFile(const SGPath &fname)
Adds a new output instance to the Output Manager.
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.
void SetOutputProperties(std::vector< FGPropertyNode_ptr > &outputProperties)
Set the list of properties that should be output for this output instance.
Implements the output to a human readable text file.
virtual bool Run(bool Holding)
Runs the model; called by the Executive.
void SetRateHz(double rtHz)
Set the output rate for this output instances.
void SetRateHz(double rate)
Modifies the output rate for all output instances.
bool Toggle(int idx)
Toggles the output generation of each ouput instance.
virtual bool Load(Element *el)
Init the output directives from an XML file (implement the FGModel interface).
void SetDelimiter(const std::string &delim)
Set the delimiter.
bool Run(bool Holding)
Runs the Output model; called by the Executive.
bool Load(Element *el)
Load the output directives and adds a new output instance to the Output Manager list.
This class is solely for the purpose of determining what type of file is given on the command line...
Abstract class to provide functions generic to all the output directives.
virtual void SetOutputName(const std::string &name)
Overwrites the name identifier under which the output will be logged.
void SetIdx(unsigned int idx)
Set the idx for this output instance.
void SetStartNewOutput(void)
Reset the output prior to a restart of the simulation.
bool InitModel(void)
Initializes the instance.
Implements the output to a socket.
Implements the output to a UDP socket.
std::string GetOutputName(unsigned int idx) const
Get the name identifier to which the output will be directed.
void Print(void)
Makes all the output instances to generate their ouput.