/** * @param uNotifyCode - notification code if the message is from a control. If the message is from an accelerator, this value is 1. If the message is from a menu, this value is zero. * @param nID - specifies the identifier of the menu item, control, or accelerator. * @param hWndCtl - handle to the control sending the message if the message is from a control. Otherwise, this parameter is NULL. */ void CExpressModeDlg::OnCalculate(UINT /*uNotifyCode*/, int /*nID*/, HWND /*hWndCtl*/) { try { CString strLogFile; m_txtLogFile.GetWindowText(strLogFile); if (GetFileAttributes(strLogFile) == INVALID_FILE_ATTRIBUTES) { MsgTip::ShowMessage(m_txtLogFile, IDS_INVALIDLOGFILE); return; } CString strMapPdbFolder; m_txtMapPdbFolder.GetWindowText(strMapPdbFolder); if (GetFileAttributes(strMapPdbFolder) == INVALID_FILE_ATTRIBUTES) { MsgTip::ShowMessage(m_txtMapPdbFolder, IDS_INVALIDMAPPDBFOLDER); return; } CWaitDialog wait(m_hWnd); LoadXMLDocument(strLogFile); SetErrorReasonText(); FillStackTraceList(); } catch (std::exception& error) { HandleException(error); } }
bool FGBuoyantForces::Load(Element *element) { string fname="", file=""; Element *gas_cell_element; Debug(2); string separator = "/"; fname = element->GetAttributeValue("file"); if (!fname.empty()) { file = FDMExec->GetFullAircraftPath() + separator + fname; document = LoadXMLDocument(file); } else { document = element; } FGModel::Load(element); // Perform base class Load gas_cell_element = document->FindElement("gas_cell"); while (gas_cell_element) { NoneDefined = false; Cells.push_back(new FGGasCell(FDMExec, gas_cell_element, Cells.size())); gas_cell_element = document->FindNextElement("gas_cell"); } return true; }
bool FGEngine::LoadThruster(Element *thruster_element) { string token, fullpath, localpath; string thruster_filename, thruster_fullpathname, thrType; string enginePath = FDMExec->GetEnginePath(); string aircraftPath = FDMExec->GetFullAircraftPath(); ifstream thruster_file; FGColumnVector3 location, orientation; string separator = "/"; fullpath = enginePath + separator; localpath = aircraftPath + separator + "Engines" + separator; thruster_filename = thruster_element->GetAttributeValue("file"); if ( !thruster_filename.empty()) { thruster_fullpathname = localpath + thruster_filename + ".xml"; thruster_file.open(thruster_fullpathname.c_str()); if ( !thruster_file.is_open()) { thruster_fullpathname = fullpath + thruster_filename + ".xml"; thruster_file.open(thruster_fullpathname.c_str()); if ( !thruster_file.is_open()) { cerr << "Could not open thruster file: " << thruster_filename << ".xml" << endl; return false; } else { thruster_file.close(); } } else { thruster_file.close(); } } else { cerr << "No thruster filename given." << endl; return false; } document = LoadXMLDocument(thruster_fullpathname); document->SetParent(thruster_element); thrType = document->GetName(); if (thrType == "propeller") { Thruster = new FGPropeller(FDMExec, document, EngineNumber); } else if (thrType == "nozzle") { Thruster = new FGNozzle(FDMExec, document, EngineNumber); } else if (thrType == "rotor") { Thruster = new FGRotor(FDMExec, document, EngineNumber); } else if (thrType == "direct") { Thruster = new FGThruster( FDMExec, document, EngineNumber); } Thruster->SetdeltaT(in.TotalDeltaT); Debug(2); return true; }
bool FGAerodynamics::Load(Element *element) { string parameter, axis, scratch; string scratch_unit=""; string fname="", file=""; Element *temp_element, *axis_element, *function_element; string separator = "/"; fname = element->GetAttributeValue("file"); if (!fname.empty()) { file = FDMExec->GetFullAircraftPath() + separator + fname; document = LoadXMLDocument(file); if (document == 0L) return false; } else { document = element; } FGModel::Load(document); // Perform base class Pre-Load DetermineAxisSystem(); // Detemine if Lift/Side/Drag, etc. is used. Debug(2); if ((temp_element = document->FindElement("alphalimits"))) { scratch_unit = temp_element->GetAttributeValue("unit"); if (scratch_unit.empty()) scratch_unit = "RAD"; alphaclmin = temp_element->FindElementValueAsNumberConvertFromTo("min", scratch_unit, "RAD"); alphaclmax = temp_element->FindElementValueAsNumberConvertFromTo("max", scratch_unit, "RAD"); } if ((temp_element = document->FindElement("hysteresis_limits"))) { scratch_unit = temp_element->GetAttributeValue("unit"); if (scratch_unit.empty()) scratch_unit = "RAD"; alphahystmin = temp_element->FindElementValueAsNumberConvertFromTo("min", scratch_unit, "RAD"); alphahystmax = temp_element->FindElementValueAsNumberConvertFromTo("max", scratch_unit, "RAD"); } if ((temp_element = document->FindElement("aero_ref_pt_shift_x"))) { function_element = temp_element->FindElement("function"); AeroRPShift = new FGFunction(PropertyManager, function_element); } axis_element = document->FindElement("axis"); while (axis_element) { AeroFunctionArray ca; axis = axis_element->GetAttributeValue("name"); function_element = axis_element->FindElement("function"); while (function_element) { string current_func_name = function_element->GetAttributeValue("name"); try { ca.push_back( new FGFunction(PropertyManager, function_element) ); } catch (string const str) { cerr << endl << fgred << "Error loading aerodynamic function in " << current_func_name << ":" << str << " Aborting." << reset << endl; return false; } function_element = axis_element->FindNextElement("function"); } AeroFunctions[AxisIdx[axis]] = ca; axis_element = document->FindNextElement("axis"); } PostLoad(document, PropertyManager); // Perform base class Post-Load return true; }
bool FGFDMExec::LoadModel(const string& model, bool addModelToPath) { string token; string aircraftCfgFileName; Element* element = 0L; bool result = false; // initialize result to false, indicating input file not yet read modelName = model; // Set the class modelName attribute if( AircraftPath.empty() || EnginePath.empty() || SystemsPath.empty()) { cerr << "Error: attempted to load aircraft with undefined "; cerr << "aircraft, engine, and system paths" << endl; return false; } FullAircraftPath = AircraftPath; if (addModelToPath) FullAircraftPath += "/" + model; aircraftCfgFileName = FullAircraftPath + "/" + model + ".xml"; if (modelLoaded) { DeAllocate(); Allocate(); } int saved_debug_lvl = debug_lvl; document = LoadXMLDocument(aircraftCfgFileName); // "document" is a class member if (document) { if (IsChild) debug_lvl = 0; ReadPrologue(document); if (IsChild) debug_lvl = saved_debug_lvl; // Process the fileheader element in the aircraft config file. This element is OPTIONAL. element = document->FindElement("fileheader"); if (element) { result = ReadFileHeader(element); if (!result) { cerr << endl << "Aircraft fileheader element has problems in file " << aircraftCfgFileName << endl; return result; } } if (IsChild) debug_lvl = 0; // Process the metrics element. This element is REQUIRED. element = document->FindElement("metrics"); if (element) { result = ((FGAircraft*)Models[eAircraft])->Load(element); if (!result) { cerr << endl << "Aircraft metrics element has problems in file " << aircraftCfgFileName << endl; return result; } } else { cerr << endl << "No metrics element was found in the aircraft config file." << endl; return false; } // Process the mass_balance element. This element is REQUIRED. element = document->FindElement("mass_balance"); if (element) { result = ((FGMassBalance*)Models[eMassBalance])->Load(element); if (!result) { cerr << endl << "Aircraft mass_balance element has problems in file " << aircraftCfgFileName << endl; return result; } } else { cerr << endl << "No mass_balance element was found in the aircraft config file." << endl; return false; } // Process the ground_reactions element. This element is REQUIRED. element = document->FindElement("ground_reactions"); if (element) { result = ((FGGroundReactions*)Models[eGroundReactions])->Load(element); if (!result) { cerr << endl << "Aircraft ground_reactions element has problems in file " << aircraftCfgFileName << endl; return result; } ((FGFCS*)Models[eSystems])->AddGear(((FGGroundReactions*)Models[eGroundReactions])->GetNumGearUnits()); } 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 = ((FGExternalReactions*)Models[eExternalReactions])->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 = ((FGBuoyantForces*)Models[eBuoyantForces])->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 = ((FGPropulsion*)Models[ePropulsion])->Load(element); if (!result) { cerr << endl << "Aircraft propulsion element has problems in file " << aircraftCfgFileName << endl; return result; } for (unsigned int i=0; i<((FGPropulsion*)Models[ePropulsion])->GetNumEngines(); i++) ((FGFCS*)Models[eSystems])->AddThrottle(); } // Process the system element[s]. This element is OPTIONAL, and there may be more than one. element = document->FindElement("system"); while (element) { result = ((FGFCS*)Models[eSystems])->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 = ((FGFCS*)Models[eSystems])->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 = ((FGFCS*)Models[eSystems])->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 = ((FGAerodynamics*)Models[eAerodynamics])->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 = ((FGInput*)Models[eInput])->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 double (FGOutput::*iOPMF)(void) const; typedef int (FGFDMExec::*iOPV)(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); result = Output->Load(element); if (!result) { cerr << endl << "Aircraft output element has problems in file " << aircraftCfgFileName << endl; return result; } else { Outputs.push_back(Output); string outputProp = CreateIndexedPropertyName("simulation/output",idx); instance->Tie(outputProp+"/log_rate_hz", Output, (iOPMF)0, &FGOutput::SetRate, false); instance->Tie("simulation/force-output", this, (iOPV)0, &FGFDMExec::ForceOutput, false); idx++; } element = document->FindNextElement("output"); } // Lastly, process the child element. This element is OPTIONAL - and NOT YET SUPPORTED. element = document->FindElement("child"); if (element) { result = ReadChild(element); if (!result) { cerr << endl << "Aircraft child element has problems in file " << aircraftCfgFileName << endl; return result; } } // Since all vehicle characteristics have been loaded, place the values in the Inputs // structure for the FGModel-derived classes. LoadModelConstants(); modelLoaded = true; if (debug_lvl > 0) { LoadInputs(eMassBalance); // Update all input mass properties for the report. Models[eMassBalance]->Run(false); // Update all mass properties for the report. ((FGMassBalance*)Models[eMassBalance])->GetMassPropertiesReport(); cout << endl << fgblue << highint << "End of vehicle configuration loading." << endl << "-------------------------------------------------------------------------------" << reset << endl; } if (IsChild) debug_lvl = saved_debug_lvl; } else { cerr << fgred << " JSBSim failed to open the configuration file: " << aircraftCfgFileName << fgdef << endl; } for (unsigned int i=0; i< Models.size(); i++) LoadInputs(i); if (result) { struct PropertyCatalogStructure masterPCS; masterPCS.base_string = ""; masterPCS.node = (FGPropertyManager*)Root; BuildPropertyCatalog(&masterPCS); } return result; }
bool FGPropulsion::Load(Element* el) { string type, engine_filename; bool ThrottleAdded = false; Debug(2); FGModel::Load(el); // Perform base class Load. // Process tank definitions first to establish the number of fuel tanks Element* tank_element = el->FindElement("tank"); while (tank_element) { Tanks.push_back(new FGTank(FDMExec, tank_element, numTanks)); if (Tanks.back()->GetType() == FGTank::ttFUEL) numFuelTanks++; else if (Tanks.back()->GetType() == FGTank::ttOXIDIZER) numOxiTanks++; else {cerr << "Unknown tank type specified." << endl; return false;} numTanks++; tank_element = el->FindNextElement("tank"); } numSelectedFuelTanks = numFuelTanks; numSelectedOxiTanks = numOxiTanks; Element* engine_element = el->FindElement("engine"); while (engine_element) { engine_filename = engine_element->GetAttributeValue("file"); if (engine_filename.empty()) { cerr << "Engine definition did not supply an engine file." << endl; return false; } engine_filename = FindEngineFullPathname(engine_filename); document = LoadXMLDocument(engine_filename); document->SetParent(engine_element); type = document->GetName(); if (type == "piston_engine") { HavePistonEngine = true; if (!IsBound) bind(); Engines.push_back(new FGPiston(FDMExec, document, numEngines)); } else if (type == "turbine_engine") { HaveTurbineEngine = true; if (!IsBound) bind(); Engines.push_back(new FGTurbine(FDMExec, document, numEngines)); } else if (type == "turboprop_engine") { HaveTurboPropEngine = true; if (!IsBound) bind(); Engines.push_back(new FGTurboProp(FDMExec, document, numEngines)); } else if (type == "rocket_engine") { HaveRocketEngine = true; if (!IsBound) bind(); Engines.push_back(new FGRocket(FDMExec, document, numEngines)); } else if (type == "electric_engine") { HaveElectricEngine = true; if (!IsBound) bind(); Engines.push_back(new FGElectric(FDMExec, document, numEngines)); } else { cerr << "Unknown engine type: " << type << endl; exit(-5); } FCS->AddThrottle(); ThrottleAdded = true; numEngines++; engine_element = el->FindNextElement("engine"); ResetParser(); } CalculateTankInertias(); if (!ThrottleAdded) FCS->AddThrottle(); // need to have at least one throttle // Process fuel dump rate if (el->FindElement("dump-rate")) DumpRate = el->FindElementValueAsNumberConvertTo("dump-rate", "LBS/MIN"); PostLoad(el, PropertyManager); return true; }
bool FGMassBalance::Load(Element* elem) { string element_name = ""; double bixx, biyy, bizz, bixy, bixz, biyz; string fname="", file=""; string separator = "/"; fname = elem->GetAttributeValue("file"); if (!fname.empty()) { file = FDMExec->GetFullAircraftPath() + separator + fname; document = LoadXMLDocument(file); if (document == 0L) return false; } else { document = elem; } FGModel::Load(document); // Perform base class Load. bixx = biyy = bizz = bixy = bixz = biyz = 0.0; if (document->FindElement("ixx")) bixx = document->FindElementValueAsNumberConvertTo("ixx", "SLUG*FT2"); if (document->FindElement("iyy")) biyy = document->FindElementValueAsNumberConvertTo("iyy", "SLUG*FT2"); if (document->FindElement("izz")) bizz = document->FindElementValueAsNumberConvertTo("izz", "SLUG*FT2"); if (document->FindElement("ixy")) bixy = document->FindElementValueAsNumberConvertTo("ixy", "SLUG*FT2"); if (document->FindElement("ixz")) bixz = document->FindElementValueAsNumberConvertTo("ixz", "SLUG*FT2"); if (document->FindElement("iyz")) biyz = document->FindElementValueAsNumberConvertTo("iyz", "SLUG*FT2"); SetAircraftBaseInertias(FGMatrix33( bixx, -bixy, bixz, -bixy, biyy, -biyz, bixz, -biyz, bizz )); if (document->FindElement("emptywt")) { EmptyWeight = document->FindElementValueAsNumberConvertTo("emptywt", "LBS"); } Element *element = document->FindElement("location"); while (element) { element_name = element->GetAttributeValue("name"); if (element_name == "CG") vbaseXYZcg = element->FindElementTripletConvertTo("IN"); element = document->FindNextElement("location"); } // Find all POINTMASS elements that descend from this METRICS branch of the // config file. element = document->FindElement("pointmass"); while (element) { AddPointMass(element); element = document->FindNextElement("pointmass"); } double ChildFDMWeight = 0.0; for (int fdm=0; fdm<FDMExec->GetFDMCount(); fdm++) { if (FDMExec->GetChildFDM(fdm)->mated) ChildFDMWeight += FDMExec->GetChildFDM(fdm)->exec->GetMassBalance()->GetWeight(); } Weight = EmptyWeight + in.TanksWeight + GetTotalPointMassWeight() + in.GasMass*slugtolb + ChildFDMWeight; Mass = lbtoslug*Weight; PostLoad(document, PropertyManager); Debug(2); return true; }
bool FGScript::LoadScript(string script, double deltaT) { string aircraft="", initialize="", comparison = "", prop_name=""; string notifyPropertyName=""; Element *element=0, *run_element=0, *event_element=0; Element *condition_element=0, *set_element=0, *delay_element=0; Element *notify_element = 0L, *notify_property_element = 0L; Element *property_element = 0L; Element *output_element = 0L; Element *input_element = 0L; bool result = false; double dt = 0.0, value = 0.0; struct event *newEvent; FGCondition *newCondition; document = LoadXMLDocument(script); if (!document) { cerr << "File: " << script << " could not be loaded." << endl; return false; } // Set up input and output files if specified output_element = document->FindElement("output"); input_element = document->FindElement("input"); if (document->GetName() != string("runscript")) { cerr << "File: " << script << " is not a script file" << endl; return false; } ScriptName = document->GetAttributeValue("name"); // First, find "run" element and set delta T run_element = document->FindElement("run"); if (!run_element) { cerr << "No \"run\" element found in script." << endl; return false; } // Set sim timing StartTime = run_element->GetAttributeValueAsNumber("start"); FDMExec->Setsim_time(StartTime); EndTime = run_element->GetAttributeValueAsNumber("end"); if (deltaT == 0.0) dt = run_element->GetAttributeValueAsNumber("dt"); else { dt = deltaT; cout << endl << "Overriding simulation step size from the command line. New step size is: " << deltaT << " seconds (" << 1/deltaT << " Hz)" << endl << endl; } FDMExec->Setdt(dt); // read aircraft and initialization files element = document->FindElement("use"); if (element) { aircraft = element->GetAttributeValue("aircraft"); if (!aircraft.empty()) { result = FDMExec->LoadModel(aircraft); if (!result) return false; } else { cerr << "Aircraft must be specified in use element." << endl; return false; } initialize = element->GetAttributeValue("initialize"); if (initialize.empty()) { cerr << "Initialization file must be specified in use element." << endl; return false; } } else { cerr << "No \"use\" directives in the script file." << endl; return false; } // Now, read input spec if given. if (input_element > 0) { FDMExec->GetInput()->Load(input_element); } // Now, read output spec if given. if (output_element > 0) { string output_file = output_element->GetAttributeValue("file"); if (output_file.empty()) { cerr << "No logging directives file was specified." << endl; } else { if (!FDMExec->SetOutputDirectives(output_file)) return false; } } // Read local property/value declarations property_element = run_element->FindElement("property"); while (property_element) { double value=0.0; string title=""; title = property_element->GetDataLine(); if ( ! property_element->GetAttributeValue("value").empty()) value = property_element->GetAttributeValueAsNumber("value"); LocalProps *localProp = new LocalProps(value); localProp->title = title; local_properties.push_back(localProp); if (PropertyManager->HasNode(title)) { PropertyManager->GetNode(title)->setDoubleValue(value); } else { PropertyManager->Tie(localProp->title, localProp->value); } property_element = run_element->FindNextElement("property"); } // Read "events" from script event_element = run_element->FindElement("event"); while (event_element) { // event processing // Create the event structure newEvent = new struct event(); // Retrieve the event name if given newEvent->Name = event_element->GetAttributeValue("name"); // Is this event persistent? That is, does it execute every time the // condition triggers to true, or does it execute as a one-shot event, only? if (event_element->GetAttributeValue("persistent") == string("true")) { newEvent->Persistent = true; } // Does this event execute continuously when triggered to true? if (event_element->GetAttributeValue("continuous") == string("true")) { newEvent->Continuous = true; } // Process the conditions condition_element = event_element->FindElement("condition"); if (condition_element != 0) { try { newCondition = new FGCondition(condition_element, PropertyManager); } catch(string str) { cout << endl << fgred << str << reset << endl << endl; return false; } newEvent->Condition = newCondition; } else { cerr << "No condition specified in script event " << newEvent->Name << endl; return false; } // Is there a delay between the time this event is triggered, and when the event // actions are executed? delay_element = event_element->FindElement("delay"); if (delay_element) newEvent->Delay = event_element->FindElementValueAsNumber("delay"); else newEvent->Delay = 0.0; // Notify about when this event is triggered? if ((notify_element = event_element->FindElement("notify")) != 0) { newEvent->Notify = true; notify_property_element = notify_element->FindElement("property"); while (notify_property_element) { notifyPropertyName = notify_property_element->GetDataLine(); if (PropertyManager->GetNode(notifyPropertyName)) { newEvent->NotifyProperties.push_back( PropertyManager->GetNode(notifyPropertyName) ); } else { cout << endl << fgred << " Could not find the property named " << notifyPropertyName << " in script" << endl << " \"" << ScriptName << "\". This unknown property will not be " << "echoed for notification." << reset << endl; } notify_property_element = notify_element->FindNextElement("property"); } } // Read set definitions (these define the actions to be taken when the event is triggered). set_element = event_element->FindElement("set"); while (set_element) { prop_name = set_element->GetAttributeValue("name"); newEvent->SetParam.push_back( PropertyManager->GetNode(prop_name) ); //Todo - should probably do some safety checking here to make sure one or the other //of value or function is specified. if (!set_element->GetAttributeValue("value").empty()) { value = set_element->GetAttributeValueAsNumber("value"); newEvent->Functions.push_back((FGFunction*)0L); } else if (set_element->FindElement("function")) { value = 0.0; newEvent->Functions.push_back(new FGFunction(PropertyManager, set_element->FindElement("function"))); } newEvent->SetValue.push_back(value); newEvent->OriginalValue.push_back(0.0); newEvent->newValue.push_back(0.0); newEvent->ValueSpan.push_back(0.0); string tempCompare = set_element->GetAttributeValue("type"); if (to_lower(tempCompare).find("delta") != string::npos) newEvent->Type.push_back(FG_DELTA); else if (to_lower(tempCompare).find("bool") != string::npos) newEvent->Type.push_back(FG_BOOL); else if (to_lower(tempCompare).find("value") != string::npos) newEvent->Type.push_back(FG_VALUE); else newEvent->Type.push_back(FG_VALUE); // DEFAULT tempCompare = set_element->GetAttributeValue("action"); if (to_lower(tempCompare).find("ramp") != string::npos) newEvent->Action.push_back(FG_RAMP); else if (to_lower(tempCompare).find("step") != string::npos) newEvent->Action.push_back(FG_STEP); else if (to_lower(tempCompare).find("exp") != string::npos) newEvent->Action.push_back(FG_EXP); else newEvent->Action.push_back(FG_STEP); // DEFAULT if (!set_element->GetAttributeValue("tc").empty()) newEvent->TC.push_back(set_element->GetAttributeValueAsNumber("tc")); else newEvent->TC.push_back(1.0); // DEFAULT newEvent->Transiting.push_back(false); set_element = event_element->FindNextElement("set"); } Events.push_back(*newEvent); delete newEvent; event_element = run_element->FindNextElement("event"); } Debug(4); FGInitialCondition *IC=FDMExec->GetIC(); if ( ! IC->Load( initialize )) { cerr << "Initialization unsuccessful" << endl; exit(-1); } return true; }
bool FGOutput::Load(Element* element) { int subSystems = 0; Element *property_element; std::vector<FGPropertyManager *> outputProperties; if (!DirectivesFile.empty()) { // A directives filename from the command line overrides output_file_name = DirectivesFile; // one found in the config file. document = LoadXMLDocument(output_file_name); } else if (!element->GetAttributeValue("file").empty()) { output_file_name = FDMExec->GetRootDir() + element->GetAttributeValue("file"); document = LoadXMLDocument(output_file_name); } else { document = element; } if (!document) return false; string type = document->GetAttributeValue("type"); string name = document->GetAttributeValue("name"); string port = document->GetAttributeValue("port"); string protocol = document->GetAttributeValue("protocol"); if (!document->GetAttributeValue("rate").empty()) { rate = document->GetAttributeValueAsNumber("rate"); } else { rate = 1; } if (document->FindElementValue("simulation") == string("ON")) subSystems += ssSimulation; if (document->FindElementValue("aerosurfaces") == string("ON")) subSystems += ssAerosurfaces; if (document->FindElementValue("rates") == string("ON")) subSystems += ssRates; if (document->FindElementValue("velocities") == string("ON")) subSystems += ssVelocities; if (document->FindElementValue("forces") == string("ON")) subSystems += ssForces; if (document->FindElementValue("moments") == string("ON")) subSystems += ssMoments; if (document->FindElementValue("atmosphere") == string("ON")) subSystems += ssAtmosphere; if (document->FindElementValue("massprops") == string("ON")) subSystems += ssMassProps; if (document->FindElementValue("position") == string("ON")) subSystems += ssPropagate; if (document->FindElementValue("coefficients") == string("ON") || document->FindElementValue("aerodynamics") == string("ON")) subSystems += ssAeroFunctions; if (document->FindElementValue("ground_reactions") == string("ON")) subSystems += ssGroundReactions; if (document->FindElementValue("fcs") == string("ON")) subSystems += ssFCS; if (document->FindElementValue("propulsion") == string("ON")) subSystems += ssPropulsion; property_element = document->FindElement("property"); while (property_element) { string property_str = property_element->GetDataLine(); FGPropertyManager* node = PropertyManager->GetNode(property_str); if (!node) { cerr << fgred << highint << endl << " No property by the name " << property_str << " has been defined. This property will " << endl << " not be logged. You should check your configuration file." << reset << endl; } else { outputProperties.push_back(node); } property_element = document->FindNextElement("property"); } return Load(subSystems, protocol, type, port, name, rate, outputProperties); }