|
From: Erik H. <eh...@us...> - 2015-10-26 18:05:16
|
Update of /cvsroot/jsbsim/JSBSim/utils/aeromatic++ In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv29023 Modified Files: Aircraft.cpp Aircraft.h Log Message: Fix CD for Speedbrake Add the option to write to separate System files Index: Aircraft.cpp =================================================================== RCS file: /cvsroot/jsbsim/JSBSim/utils/aeromatic++/Aircraft.cpp,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -r1.21 -r1.22 *** Aircraft.cpp 26 Oct 2015 11:50:41 -0000 1.21 --- Aircraft.cpp 26 Oct 2015 18:05:13 -0000 1.22 *************** *** 68,71 **** --- 68,72 ---- Aeromatic::Aeromatic() : Aircraft(), _atype(LIGHT), + _system_files(true), _metric(0), _max_weight(10000.0), *************** *** 87,90 **** --- 88,92 ---- /* general information */ + _general.push_back(new Param("Use dedicates System files?", "Select no to keep all systems in the aircraft configuration file", _system_files)); Param* units = new Param("Chose a system of measurement", "The options affects all units for length, surface area, speed and thrust/power", _metric); _general.push_back(units); *************** *** 285,288 **** --- 287,306 ---- _dir = _subdir ? create_dir(_path, _name) : _path; + if (_dir.empty()) { + std::cout << "Unable to create directory: " << _path << "/" << _name << std::endl; + return false; + } + + std::string systems_dir; + if (_system_files) + { + systems_dir = create_dir(_dir, "Systems"); + if (systems_dir.empty()) + { + std::cout << "Unable to create directory: " << _dir<< "/Systems" << std::endl; + _system_files = false; + } + } + std::string fname = _dir + "/" + std::string(_name) + ".xml"; *************** *** 455,468 **** //***** SYSTEMS *********************************************** file << " <flight_control name=\"FCS: " << _name << "\">" << std::endl; file << std::endl; ! for (unsigned i=0; i<systems.size(); ++i) { ! if (systems[i]->enabled()) { ! std::string system = systems[i]->system(); ! if (!system.empty()) { ! file << system << std::endl; } } --- 473,522 ---- //***** SYSTEMS *********************************************** + if (_system_files == true) + { + for (unsigned i=0; i<systems.size(); ++i) + { + if (systems[i]->enabled()) + { + std::string system = systems[i]->system(); + if (!system.empty()) + { + std::string sname = systems[i]->get_description(); + std::string sfname = sname + ".xml"; + file << " <system file=\"" << sfname << "\"/>" << std::endl; + + std::string sfpath = systems_dir + "/" + sfname; + std::ofstream sfile; + sfile.open(sfpath.c_str()); + if (sfile.fail() || sfile.bad()) { + file << system << std::endl; + } + else + { + sfile << "<?xml version=\"1.0\"?>" << std::endl; + sfile << "<system name=\"" << sname << "\">" << std::endl; + sfile << system << std::endl; + sfile << "</system>" << std::endl; + } + sfile.close(); + } + } + } + file << std::endl; + } + file << " <flight_control name=\"FCS: " << _name << "\">" << std::endl; file << std::endl; ! if (_system_files == false) { ! for (unsigned i=0; i<systems.size(); ++i) { ! if (systems[i]->enabled()) ! { ! std::string system = systems[i]->system(); ! if (!system.empty()) { ! file << system << std::endl; ! } } } Index: Aircraft.h =================================================================== RCS file: /cvsroot/jsbsim/JSBSim/utils/aeromatic++/Aircraft.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -r1.5 -r1.6 *** Aircraft.h 23 Oct 2015 12:33:29 -0000 1.5 --- Aircraft.h 26 Oct 2015 18:05:13 -0000 1.6 *************** *** 545,548 **** --- 545,549 ---- unsigned _atype; + bool _system_files; bool _metric; |