42 #include "FGFDMExec.h"
43 #include "input_output/FGUDPInputSocket.h"
44 #include "input_output/FGXMLFileRead.h"
45 #include "input_output/FGModelLoader.h"
55 FGInput::FGInput(FGFDMExec* fdmex) : FGModel(fdmex)
67 vector<FGInputType*>::iterator it;
68 for (it = InputTypes.begin(); it != InputTypes.end(); ++it)
84 Element* element = ModelLoader.Open(el);
86 if (!element)
return false;
88 FGModel::PreLoad(element, FDMExec);
90 size_t idx = InputTypes.size();
94 if (debug_lvl > 0) cout << endl <<
" Input data set: " << idx <<
" " << endl;
96 type = to_upper(type);
98 if (type.empty() || type ==
"SOCKET") {
100 }
else if (type ==
"QTJSBSIM") {
102 }
else if (type !=
string(
"NONE")) {
104 <<
"Unknown type of input specified in config file" << endl;
107 if (!Input)
return false;
110 Input->
Load(element);
111 PostLoad(element, FDMExec);
113 InputTypes.push_back(Input);
121 bool FGInput::InitModel(
void)
125 if (!FGModel::InitModel())
return false;
127 vector<FGInputType*>::iterator it;
128 for (it = InputTypes.begin(); it != InputTypes.end(); ++it)
129 ret &= (*it)->InitModel();
136 bool FGInput::Run(
bool Holding)
138 if (FDMExec->GetTrimStatus())
return true;
139 if (FGModel::Run(Holding))
return true;
140 if (!enabled)
return true;
142 vector<FGInputType*>::iterator it;
143 for (it = InputTypes.begin(); it != InputTypes.end(); ++it)
151 bool FGInput::SetDirectivesFile(
const SGPath& fname)
157 s <<
"Could not read directive file: " << fname;
160 bool result = Load(document);
163 cerr << endl <<
"Aircraft input element has problems in file " << fname << endl;
170 bool FGInput::Toggle(
int idx)
172 if (idx >= (
int)0 && idx < (
int)InputTypes.size())
173 return InputTypes[idx]->Toggle();
180 bool FGInput::SetInputName(
unsigned int idx,
const std::string& name)
182 if (idx >= InputTypes.size())
return false;
184 InputTypes[idx]->SetInputName(name);
190 string FGInput::GetInputName(
unsigned int idx)
const
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) {
std::string GetAttributeValue(const std::string &key)
Retrieves an attribute.
std::string ReadFrom(void) const
Return a string that contains a description of the location where the current XML element was read fr...
This class is solely for the purpose of determining what type of file is given on the command line.