42 #include "FGFDMExec.h" 43 #include "input_output/FGInputSocket.h" 44 #include "input_output/FGUDPInputSocket.h" 45 #include "input_output/FGXMLFileRead.h" 46 #include "input_output/FGXMLElement.h" 47 #include "input_output/FGModelLoader.h" 53 IDENT(IdSrc,
"$Id: FGInput.cpp,v 1.35 2017/02/25 14:23:19 bcoconni Exp $");
54 IDENT(IdHdr,ID_INPUT);
60 FGInput::FGInput(FGFDMExec* fdmex) : FGModel(fdmex)
72 vector<FGInputType*>::iterator it;
73 for (it = InputTypes.begin(); it != InputTypes.end(); ++it)
89 Element* element = ModelLoader.Open(el);
91 if (!element)
return false;
93 FGModel::PreLoad(element, PropertyManager);
95 size_t idx = InputTypes.size();
99 if (debug_lvl > 0) cout << endl <<
" Input data set: " << idx <<
" " << endl;
101 type = to_upper(type);
103 if (type.empty() || type ==
"SOCKET") {
105 }
else if (type ==
"QTJSBSIM") {
107 }
else if (type !=
string(
"NONE")) {
109 <<
"Unknown type of input specified in config file" << endl;
112 if (!Input)
return false;
115 Input->
Load(element);
116 PostLoad(element, PropertyManager);
118 InputTypes.push_back(Input);
130 if (!FGModel::InitModel())
return false;
132 vector<FGInputType*>::iterator it;
133 for (it = InputTypes.begin(); it != InputTypes.end(); ++it)
134 ret &= (*it)->InitModel();
143 if (FDMExec->GetTrimStatus())
return true;
145 if (!enabled)
return true;
147 vector<FGInputType*>::iterator it;
148 for (it = InputTypes.begin(); it != InputTypes.end(); ++it)
159 Element* document = XMLFile.LoadXMLDocument(fname);
160 bool result =
Load(document);
163 cerr << endl <<
"Aircraft input element has problems in file " << fname << endl;
172 if (idx >= (
int)0 && idx < (
int)InputTypes.size())
173 return InputTypes[idx]->Toggle();
182 if (idx >= InputTypes.size())
return false;
184 InputTypes[idx]->SetInputName(name);
194 if (idx < InputTypes.size())
195 name = InputTypes[idx]->GetInputName();
219 void FGInput::Debug(
int from)
223 if (debug_lvl <= 0)
return;
231 if (debug_lvl & 2 ) {
232 if (from == 0) cout <<
"Instantiated: FGInput" << endl;
233 if (from == 1) cout <<
"Destroyed: FGInput" << endl;
235 if (debug_lvl & 4 ) {
237 if (debug_lvl & 8 ) {
239 if (debug_lvl & 16) {
241 if (debug_lvl & 64) {
243 cout << IdSrc << endl;
244 cout << IdHdr << endl;
std::string GetAttributeValue(const std::string &key)
Retrieves an attribute.
virtual bool Run(bool Holding)
Runs the model; called by the Executive.
bool Load(const SGPath &rstname, bool useStoredPath=true)
Loads the initial conditions.
This class is solely for the purpose of determining what type of file is given on the command line...
std::string ReadFrom(void) const
Return a string that contains a description of the location where the current XML element was read fr...