44 #include "FGDistributor.h" 45 #include "input_output/FGXMLElement.h" 51 IDENT(IdSrc,
"$Id: FGDistributor.cpp,v 1.7 2015/02/27 20:46:01 bcoconni Exp $");
52 IDENT(IdHdr,ID_DISTRIBUTOR);
66 FGFCSComponent::bind();
70 if (type_string ==
"inclusive") Type = eInclusive;
71 else if (type_string ==
"exclusive") Type = eExclusive;
73 throw(
"Not a known Distributor type, "+type_string);
77 while (case_element) {
78 current_case =
new Case;
80 if (test_element) current_case->SetTest(
new FGCondition(test_element, PropertyManager));
81 prop_val_element = case_element->
FindElement(
"property");
82 while (prop_val_element) {
84 string property_string = prop_val_element->
GetDataLine();
85 current_case->AddPropValPair(
new PropValPair(property_string, value_string, PropertyManager));
88 Cases.push_back(current_case);
107 bool completed =
false;
108 for (
unsigned int ctr=0; ctr<Cases.size(); ctr++) {
109 if (Cases[ctr]->HasTest()) {
110 if (Cases[ctr]->GetTestResult() && !((Type == eExclusive) && completed)) {
111 Cases[ctr]->SetPropValPairs();
115 Cases[ctr]->SetPropValPairs();
145 void FGDistributor::Debug(
int from)
147 string comp, scratch;
151 if (debug_lvl <= 0)
return;
155 for (
unsigned int ctr=0; ctr < Cases.size(); ctr++) {
156 std::cout <<
" Case: " << ctr << endl;
157 if (Cases[ctr]->GetTest() != 0) {
158 Cases[ctr]->GetTest()->PrintCondition(
" ");
160 std::cout <<
" Set these properties by default: " << std::endl;
162 std::cout << std::endl;
163 for (
unsigned int propCtr=0; propCtr < Cases[ctr]->GetNumPropValPairs(); propCtr++) {
164 std::cout <<
" Set property " << Cases[ctr]->GetPropValPair(propCtr)->GetPropName();
165 if (Cases[ctr]->GetPropValPair(propCtr)->GetPropNode() == 0) std::cout <<
" (late bound)";
166 std::cout <<
" to " << Cases[ctr]->GetPropValPair(propCtr)->GetValString();
167 if (Cases[ctr]->GetPropValPair(propCtr)->GetLateBoundValue()) std::cout <<
" (late bound)";
168 std::cout << std::endl;
173 if (debug_lvl & 2 ) {
174 if (from == 0) cout <<
"Instantiated: FGDistributor" << endl;
175 if (from == 1) cout <<
"Destroyed: FGDistributor" << endl;
177 if (debug_lvl & 4 ) {
179 if (debug_lvl & 8 ) {
181 if (debug_lvl & 16) {
183 if (debug_lvl & 64) {
185 cout << IdSrc << endl;
186 cout << IdHdr << endl;
std::string GetAttributeValue(const std::string &key)
Retrieves an attribute.
~FGDistributor()
Destructor.
Element * FindElement(const std::string &el="")
Searches for a specified element.
std::string GetDataLine(unsigned int i=0)
Gets a line of data belonging to an element.
Encapsulates the Flight Control System (FCS) functionality.
bool Run(void)
Executes the distributor logic.
Element * FindNextElement(const std::string &el="")
Searches for the next element as specified.
Base class for JSBSim Flight Control System Components.
Encapsulates a condition, which is used in parts of JSBSim including switches.