42#include "FGDistributor.h"
43#include "models/FGFCS.h"
44#include "input_output/FGLog.h"
57 auto PropertyManager = fcs->GetPropertyManager();
59 bind(element, PropertyManager.get());
63 if (type_string ==
"inclusive") Type = eInclusive;
64 else if (type_string ==
"exclusive") Type = eExclusive;
67 err <<
"Distributor type should be \"inclusive\" or \"exclusive\""
68 <<
" but got \"" << type_string <<
"\" instead.\n";
73 while (case_element) {
74 auto current_case = make_unique<Case>();
77 if (test_element) current_case->SetTest(test_element, PropertyManager);
84 err << LogFormat::RED << e.what() << LogFormat::RESET <<
"\n\n";
88 while (prop_val_element) {
90 string property_string = prop_val_element->
GetDataLine();
91 current_case->AddPropValPair(property_string, value_string, PropertyManager,
95 Cases.push_back(std::move(current_case));
106 bool completed =
false;
107 for (
auto& Case: Cases) {
108 if (Case->HasTest()) {
109 if (Case->GetTestResult() && !((Type == eExclusive) && completed)) {
110 Case->SetPropValPairs();
114 Case->SetPropValPairs();
140void FGDistributor::Debug(
int from)
142 if (debug_lvl <= 0)
return;
148 for (
const auto& Case: Cases) {
149 log <<
" Case: " << fixed << ctr <<
"\n";
150 if (Case->HasTest()) {
151 Case->GetTest().PrintCondition(
" ");
153 log <<
" Set these properties by default: \n";
156 for (
const auto& propVal: *Case) {
157 log <<
" Set property " << propVal->GetPropName();
158 if (propVal->GetLateBoundProp()) log <<
" (late bound)";
159 log <<
" to " << propVal->GetValString();
160 if (propVal->GetLateBoundValue()) log <<
" (late bound)";
167 if (debug_lvl & 2 ) {
168 FGLogging log(LogLevel::DEBUG);
169 if (from == 0) log <<
"Instantiated: FGDistributor\n";
170 if (from == 1) log <<
"Destroyed: FGDistributor\n";
172 if (debug_lvl & 4 ) {
174 if (debug_lvl & 8 ) {
176 if (debug_lvl & 16) {
178 if (debug_lvl & 64) {
Element * FindElement(const std::string &el="")
Searches for a specified element.
std::string GetAttributeValue(const std::string &key)
Retrieves an attribute.
std::string GetDataLine(unsigned int i=0)
Gets a line of data belonging to an element.
Element * FindNextElement(const std::string &el="")
Searches for the next element as specified.
FGDistributor(FGFCS *fcs, Element *element)
Constructor.
bool Run(void) override
Executes the distributor logic.
Base class for JSBSim Flight Control System Components.
Encapsulates the Flight Control System (FCS) functionality.
Main namespace for the JSBSim Flight Dynamics Model.