- ReadPrologue(document);
- element = document->GetElement();
-
- bool result = true;
- while (element && result) {
- string element_name = element->GetName();
- if (element_name == "fileheader" ) result = ReadFileHeader(element);
- else if (element_name == "slave") result = ReadSlave(element);
- else if (element_name == "metrics") result = Aircraft->Load(element);
- else if (element_name == "mass_balance") result = MassBalance->Load(element);
- else if (element_name == "ground_reactions") result = GroundReactions->Load(element);
- else if (element_name == "propulsion") result = Propulsion->Load(element);
- else if (element_name == "autopilot") result = FCS->Load(element);
- else if (element_name == "flight_control") result = FCS->Load(element);
- else if (element_name == "aerodynamics") result = Aerodynamics->Load(element);
- else if (element_name == "input") result = Input->Load(element);
- else if (element_name == "output") {
- FGOutput* Output = new FGOutput(this);
- Output->InitModel();
- Schedule(Output, 1);
+ // Process the ground_reactions element. This element is REQUIRED.
+ element = document->FindElement("ground_reactions");
+ if (element) {
+ result = GroundReactions->Load(element);
+ if (!result) {
+ cerr << endl << "Aircraft ground_reactions element has problems in file " << aircraftCfgFileName << endl;
+ return result;
+ }
+ } else {
+ cerr << endl << "No ground_reactions element was found in the aircraft config file." << endl;
+ return false;
+ }
+
+ // Process the external_reactions element. This element is OPTIONAL.
+ element = document->FindElement("external_reactions");
+ if (element) {
+ result = ExternalReactions->Load(element);
+ if (!result) {
+ cerr << endl << "Aircraft external_reactions element has problems in file " << aircraftCfgFileName << endl;
+ return result;
+ }
+ }
+
+ // Process the buoyant_forces element. This element is OPTIONAL.
+ element = document->FindElement("buoyant_forces");
+ if (element) {
+ result = BuoyantForces->Load(element);
+ if (!result) {
+ cerr << endl << "Aircraft buoyant_forces element has problems in file " << aircraftCfgFileName << endl;
+ return result;
+ }
+ }
+
+ // Process the propulsion element. This element is OPTIONAL.
+ element = document->FindElement("propulsion");
+ if (element) {
+ result = Propulsion->Load(element);
+ if (!result) {
+ cerr << endl << "Aircraft propulsion element has problems in file " << aircraftCfgFileName << endl;
+ return result;
+ }
+ }
+
+ // Process the system element[s]. This element is OPTIONAL, and there may be more than one.
+ element = document->FindElement("system");
+ while (element) {
+ result = FCS->Load(element, FGFCS::stSystem);
+ if (!result) {
+ cerr << endl << "Aircraft system element has problems in file " << aircraftCfgFileName << endl;
+ return result;
+ }
+ element = document->FindNextElement("system");
+ }
+
+ // Process the autopilot element. This element is OPTIONAL.
+ element = document->FindElement("autopilot");
+ if (element) {
+ result = FCS->Load(element, FGFCS::stAutoPilot);
+ if (!result) {
+ cerr << endl << "Aircraft autopilot element has problems in file " << aircraftCfgFileName << endl;
+ return result;
+ }
+ }
+
+ // Process the flight_control element. This element is OPTIONAL.
+ element = document->FindElement("flight_control");
+ if (element) {
+ result = FCS->Load(element, FGFCS::stFCS);
+ if (!result) {
+ cerr << endl << "Aircraft flight_control element has problems in file " << aircraftCfgFileName << endl;
+ return result;
+ }
+ }
+
+ // Process the aerodynamics element. This element is OPTIONAL, but almost always expected.
+ element = document->FindElement("aerodynamics");
+ if (element) {
+ result = Aerodynamics->Load(element);
+ if (!result) {
+ cerr << endl << "Aircraft aerodynamics element has problems in file " << aircraftCfgFileName << endl;
+ return result;
+ }
+ } else {
+ cerr << endl << "No expected aerodynamics element was found in the aircraft config file." << endl;
+ }
+
+ // Process the input element. This element is OPTIONAL.
+ element = document->FindElement("input");
+ if (element) {
+ result = Input->Load(element);
+ if (!result) {
+ cerr << endl << "Aircraft input element has problems in file " << aircraftCfgFileName << endl;
+ return result;
+ }
+ }
+
+ // Process the output element[s]. This element is OPTIONAL, and there may be more than one.
+ unsigned int idx=0;
+ typedef int (FGOutput::*iOPMF)(void) const;
+ element = document->FindElement("output");
+ while (element) {
+ if (debug_lvl > 0) cout << endl << " Output data set: " << idx << " ";
+ FGOutput* Output = new FGOutput(this);
+ Output->InitModel();
+ Schedule(Output, 1);
+ result = Output->Load(element);
+ if (!result) {
+ cerr << endl << "Aircraft output element has problems in file " << aircraftCfgFileName << endl;
+ return result;
+ } else {