43#include "input_output/FGUDPInputSocket.h"
44#include "input_output/FGXMLFileRead.h"
45#include "input_output/FGModelLoader.h"
46#include "input_output/FGLog.h"
47#include "input_output/string_utilities.h"
57FGInput::FGInput(FGFDMExec* fdmex) : FGModel(fdmex)
69 vector<FGInputType*>::iterator it;
70 for (it = InputTypes.begin(); it != InputTypes.end(); ++it)
86 Element* element = ModelLoader.Open(el);
88 if (!element)
return false;
90 FGModel::PreLoad(element, FDMExec);
92 size_t idx = InputTypes.size();
98 log << 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 log <<
"Unknown type of input specified in config file" << endl;
112 if (!Input)
return false;
115 Input->
Load(element);
116 PostLoad(element, FDMExec);
118 InputTypes.push_back(Input);
126bool FGInput::InitModel(
void)
130 if (!FGModel::InitModel())
return false;
132 vector<FGInputType*>::iterator it;
133 for (it = InputTypes.begin(); it != InputTypes.end(); ++it)
134 ret &= (*it)->InitModel();
141bool FGInput::Run(
bool Holding)
143 if (FDMExec->GetTrimStatus())
return true;
144 if (FGModel::Run(Holding))
return true;
145 if (!enabled)
return true;
147 vector<FGInputType*>::iterator it;
148 for (it = InputTypes.begin(); it != InputTypes.end(); ++it)
156bool FGInput::SetDirectivesFile(
const SGPath& fname)
162 err <<
"Could not read directive file: " << fname << endl;
165 bool result = Load(document);
169 log << endl <<
"Aircraft input element has problems in file " << fname << endl;
177bool FGInput::Toggle(
int idx)
179 if (idx >= (
int)0 && idx < (
int)InputTypes.size())
180 return InputTypes[idx]->Toggle();
187bool FGInput::SetInputName(
unsigned int idx,
const std::string& name)
189 if (idx >= InputTypes.size())
return false;
191 InputTypes[idx]->SetInputName(name);
197string FGInput::GetInputName(
unsigned int idx)
const
201 if (idx < InputTypes.size())
202 name = InputTypes[idx]->GetInputName();
226void FGInput::Debug(
int from)
230 if (debug_lvl <= 0)
return;
238 if (debug_lvl & 2 ) {
239 FGLogging log(LogLevel::DEBUG);
240 if (from == 0) log <<
"Instantiated: FGInput" << endl;
241 if (from == 1) log <<
"Destroyed: FGInput" << endl;
243 if (debug_lvl & 4 ) {
245 if (debug_lvl & 8 ) {
247 if (debug_lvl & 16) {
249 if (debug_lvl & 64) {
std::string GetAttributeValue(const std::string &key)
Retrieves an attribute.
This class is solely for the purpose of determining what type of file is given on the command line.
Main namespace for the JSBSim Flight Dynamics Model.