You can subscribe to this list here.
2004 |
Jan
|
Feb
|
Mar
|
Apr
(64) |
May
(260) |
Jun
(65) |
Jul
(28) |
Aug
(13) |
Sep
(46) |
Oct
(55) |
Nov
(25) |
Dec
(57) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2005 |
Jan
(97) |
Feb
(13) |
Mar
(90) |
Apr
(25) |
May
(97) |
Jun
(124) |
Jul
(39) |
Aug
(16) |
Sep
(62) |
Oct
(13) |
Nov
(32) |
Dec
(258) |
2006 |
Jan
(87) |
Feb
(67) |
Mar
(27) |
Apr
(19) |
May
(42) |
Jun
(12) |
Jul
(31) |
Aug
(51) |
Sep
(7) |
Oct
(4) |
Nov
(27) |
Dec
(6) |
2007 |
Jan
(23) |
Feb
(41) |
Mar
(6) |
Apr
(14) |
May
(31) |
Jun
(6) |
Jul
(9) |
Aug
(13) |
Sep
(41) |
Oct
(26) |
Nov
(13) |
Dec
(11) |
2008 |
Jan
(75) |
Feb
(24) |
Mar
(32) |
Apr
(103) |
May
(49) |
Jun
(15) |
Jul
(45) |
Aug
(61) |
Sep
(6) |
Oct
(12) |
Nov
(18) |
Dec
(32) |
2009 |
Jan
(77) |
Feb
(33) |
Mar
(33) |
Apr
(19) |
May
(52) |
Jun
(43) |
Jul
(14) |
Aug
(80) |
Sep
(32) |
Oct
(81) |
Nov
(20) |
Dec
(12) |
2010 |
Jan
(15) |
Feb
(50) |
Mar
(28) |
Apr
(49) |
May
(12) |
Jun
(19) |
Jul
(78) |
Aug
(49) |
Sep
(52) |
Oct
(22) |
Nov
(108) |
Dec
(33) |
2011 |
Jan
(47) |
Feb
(3) |
Mar
(7) |
Apr
(3) |
May
(7) |
Jun
(43) |
Jul
(80) |
Aug
(55) |
Sep
(34) |
Oct
(33) |
Nov
(33) |
Dec
(20) |
2012 |
Jan
(16) |
Feb
(18) |
Mar
(29) |
Apr
(26) |
May
(4) |
Jun
(5) |
Jul
(13) |
Aug
(14) |
Sep
(47) |
Oct
(29) |
Nov
(19) |
Dec
(66) |
2013 |
Jan
(55) |
Feb
(46) |
Mar
|
Apr
(1) |
May
|
Jun
(32) |
Jul
|
Aug
(1) |
Sep
(40) |
Oct
(3) |
Nov
(43) |
Dec
(26) |
2014 |
Jan
(63) |
Feb
(30) |
Mar
(2) |
Apr
(3) |
May
(51) |
Jun
(18) |
Jul
(4) |
Aug
(6) |
Sep
(10) |
Oct
|
Nov
(17) |
Dec
(3) |
2015 |
Jan
(13) |
Feb
(36) |
Mar
(12) |
Apr
(37) |
May
(8) |
Jun
|
Jul
(29) |
Aug
(23) |
Sep
(55) |
Oct
(82) |
Nov
(57) |
Dec
(72) |
2016 |
Jan
(61) |
Feb
(6) |
Mar
(1) |
Apr
(18) |
May
(59) |
Jun
(42) |
Jul
(24) |
Aug
(20) |
Sep
(6) |
Oct
|
Nov
(8) |
Dec
(1) |
2017 |
Jan
(2) |
Feb
(20) |
Mar
(14) |
Apr
(4) |
May
(9) |
Jun
(7) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Bertrand <bco...@us...> - 2017-03-11 19:21:07
|
Update of /cvsroot/jsbsim/JSBSim/tests In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv20112/tests Modified Files: CMakeLists.txt Added Files: TestEngineIndexedProps.py Log Message: Added a new test to check the indexed properties (i.e. which indices are replaced by #) in the engines definition. --- NEW FILE --- # TestEngineIndexedProps.py # # Check that indexed properties (where the engine number is replaced by '#) in # engines XML definition are working. # # Copyright (c) 2016 Bertrand Coconnier # # This program is free software; you can redistribute it and/or modify it under # the terms of the GNU General Public License as published by the Free Software # Foundation; either version 3 of the License, or (at your option) any later # version. # # This program is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more # details. # # You should have received a copy of the GNU General Public License along with # this program; if not, see <http://www.gnu.org/licenses/> # import shutil import xml.etree.ElementTree as et from JSBSim_utils import JSBSimTestCase, CreateFDM, RunTest class TestEngineIndexedProps(JSBSimTestCase): def testEnginePowerVC(self): fdm = CreateFDM(self.sandbox) fdm.load_script(self.sandbox.path_to_jsbsim_file('scripts', 'L4102.xml')) fdm.run_ic() pm = fdm.get_property_manager() self.assertTrue(pm.hasNode('propulsion/engine[0]/EnginePowerVC')) self.assertTrue(pm.hasNode('propulsion/engine[1]/EnginePowerVC')) while fdm.run(): self.assertAlmostEqual(fdm['propulsion/engine[0]/EnginePowerVC'], fdm['propulsion/engine[1]/EnginePowerVC']) def testFunctionWithIndexedProps(self): tree = et.parse(self.sandbox.path_to_jsbsim_file('engine', 'eng_PegasusXc.xml')) # Define the function starter-max-power-W as a 'post' function root = tree.getroot() startPowFunc_tag = root.find("function/[@name='propulsion/engine[#]/starter-max-power-W']") startPowFunc_tag.attrib['type']='post' tree.write('eng_PegasusXc.xml') # Copy the propeller file. shutil.copy(self.sandbox.path_to_jsbsim_file('engine', 'prop_deHavilland5000.xml'), '.') fdm = CreateFDM(self.sandbox) fdm.set_engine_path('.') fdm.load_script(self.sandbox.path_to_jsbsim_file('scripts', 'Short_S23_1.xml')) fdm.run_ic() pm = fdm.get_property_manager() self.assertTrue(pm.hasNode('propulsion/engine[0]/starter-max-power-W')) self.assertTrue(pm.hasNode('propulsion/engine[1]/starter-max-power-W')) self.assertTrue(pm.hasNode('propulsion/engine[2]/starter-max-power-W')) self.assertTrue(pm.hasNode('propulsion/engine[3]/starter-max-power-W')) while fdm.run(): rpm = [fdm['propulsion/engine[0]/engine-rpm'], fdm['propulsion/engine[1]/engine-rpm'], fdm['propulsion/engine[2]/engine-rpm'], fdm['propulsion/engine[3]/engine-rpm']] for i in xrange(4): maxPower = max(0.0, 1.0-rpm[i]/400)*498.941*0.10471976*rpm[i] self.assertAlmostEqual(fdm['propulsion/engine[%d]/starter-max-power-W' % (i,)], maxPower) def testTableWithIndexedVars(self): tree = et.parse(self.sandbox.path_to_jsbsim_file('engine', 'eng_PegasusXc.xml')) # Define the function starter-max-power-W as a 'post' function root = tree.getroot() startPowFunc_tag = root.find("function/[@name='propulsion/engine[#]/starter-max-power-W']") startPowFunc_tag.attrib['type']='post' max_tag = startPowFunc_tag.find('product/max') diff_tag = max_tag.find('difference') max_tag.remove(diff_tag) table_tag = et.SubElement(max_tag,'table') table_tag.attrib['name']='propulsion/engine[#]/starter-tabular-data' indepVar_tag = et.SubElement(table_tag, 'independentVar') indepVar_tag.attrib['lookup']='row' indepVar_tag.text = 'propulsion/engine[#]/engine-rpm' tData_tag = et.SubElement(table_tag, 'tableData') tData_tag.text ='0.0 1.0\n400.0 0.0' tree.write('eng_PegasusXc.xml') # Copy the propeller file. shutil.copy(self.sandbox.path_to_jsbsim_file('engine', 'prop_deHavilland5000.xml'), '.') fdm = CreateFDM(self.sandbox) fdm.set_engine_path('.') fdm.load_script(self.sandbox.path_to_jsbsim_file('scripts', 'Short_S23_1.xml')) fdm.run_ic() pm = fdm.get_property_manager() self.assertTrue(pm.hasNode('propulsion/engine[0]/starter-max-power-W')) self.assertTrue(pm.hasNode('propulsion/engine[1]/starter-max-power-W')) self.assertTrue(pm.hasNode('propulsion/engine[2]/starter-max-power-W')) self.assertTrue(pm.hasNode('propulsion/engine[3]/starter-max-power-W')) while fdm.run(): rpm = [fdm['propulsion/engine[0]/engine-rpm'], fdm['propulsion/engine[1]/engine-rpm'], fdm['propulsion/engine[2]/engine-rpm'], fdm['propulsion/engine[3]/engine-rpm']] for i in xrange(4): tabularData = max(0.0, 1.0-rpm[i]/400) maxPower = tabularData*498.941*0.10471976*rpm[i] self.assertAlmostEqual(fdm['propulsion/engine[%d]/starter-max-power-W' % (i,)], maxPower) self.assertAlmostEqual(fdm['propulsion/engine[%d]/starter-tabular-data' % (i,)], tabularData) RunTest(TestEngineIndexedProps) Index: CMakeLists.txt =================================================================== RCS file: /cvsroot/jsbsim/JSBSim/tests/CMakeLists.txt,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -r1.31 -r1.32 *** CMakeLists.txt 10 Jul 2016 09:10:59 -0000 1.31 --- CMakeLists.txt 11 Mar 2017 19:21:04 -0000 1.32 *************** *** 51,55 **** TestAeroFuncOutput TestKinematic ! TestTurboProp) foreach(test ${PYTHON_TESTS}) --- 51,57 ---- TestAeroFuncOutput TestKinematic ! TestTurboProp ! TestEngineIndexedProps ! ) foreach(test ${PYTHON_TESTS}) |
From: Bertrand <bco...@us...> - 2017-03-11 12:12:15
|
Update of /cvsroot/jsbsim/JSBSim/src/input_output In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv30309/src/input_output Modified Files: FGfdmSocket.cpp Log Message: Fixed a bug reported by Ron H. and Rebecca N. Palmer on the FG mailing list: the 'length' parameter passed to gethostbyaddr was erroneous. Index: FGfdmSocket.cpp =================================================================== RCS file: /cvsroot/jsbsim/JSBSim/src/input_output/FGfdmSocket.cpp,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -r1.31 -r1.32 *** FGfdmSocket.cpp 22 Mar 2015 12:19:31 -0000 1.31 --- FGfdmSocket.cpp 11 Mar 2017 12:12:12 -0000 1.32 *************** *** 94,100 **** } } else { ! unsigned int ip; ip = inet_addr(address.c_str()); ! if ((host = gethostbyaddr((char*)&ip, address.size(), PF_INET)) == NULL) { cout << "Could not get host net address by number..." << endl; } --- 94,100 ---- } } else { ! unsigned long ip; ip = inet_addr(address.c_str()); ! if ((host = gethostbyaddr((char*)&ip, sizeof(ip), PF_INET)) == NULL) { cout << "Could not get host net address by number..." << endl; } |
From: Bertrand <bco...@us...> - 2017-03-11 12:07:25
|
Update of /cvsroot/jsbsim/JSBSim/src/models In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv29975/src/models Modified Files: FGLGear.h Log Message: Fixed a division by zero for gears that are not steerable Index: FGLGear.h =================================================================== RCS file: /cvsroot/jsbsim/JSBSim/src/models/FGLGear.h,v retrieving revision 1.65 retrieving revision 1.66 diff -C2 -r1.65 -r1.66 *** FGLGear.h 16 May 2016 18:19:57 -0000 1.65 --- FGLGear.h 11 Mar 2017 12:07:22 -0000 1.66 *************** *** 274,278 **** @return true if reporting is turned on */ bool GetReport(void) const { return ReportEnable; } ! double GetSteerNorm(void) const { return radtodeg/maxSteerAngle*SteerAngle; } void SetSteerCmd(double cmd) { SetSteerAngleDeg(cmd * maxSteerAngle); } double GetstaticFCoeff(void) const { return staticFCoeff; } --- 274,280 ---- @return true if reporting is turned on */ bool GetReport(void) const { return ReportEnable; } ! double GetSteerNorm(void) const { ! return maxSteerAngle == 0.0 ? 0.0 : radtodeg/maxSteerAngle*SteerAngle; ! } void SetSteerCmd(double cmd) { SetSteerAngleDeg(cmd * maxSteerAngle); } double GetstaticFCoeff(void) const { return staticFCoeff; } |
From: Bertrand <bco...@us...> - 2017-03-11 12:06:37
|
Update of /cvsroot/jsbsim/JSBSim/tests In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv29910/tests Modified Files: jsbsim.pxd jsbsim.pyx TestLGearSteer.py Log Message: Check that FGLGear::GetSteerNorm does not generate a division by zero for non steerable gears. Index: jsbsim.pxd =================================================================== RCS file: /cvsroot/jsbsim/JSBSim/tests/jsbsim.pxd,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** jsbsim.pxd 25 Feb 2017 14:23:20 -0000 1.4 --- jsbsim.pxd 11 Mar 2017 12:06:34 -0000 1.5 *************** *** 66,69 **** --- 66,79 ---- bool HasNode(string path) + cdef extern from "models/FGGroundReactions.h" namespace "JSBSim": + cdef cppclass c_FGGroundReactions "JSBSim::FGGroundReactions": + c_FGGroundReactions(c_FGFDMExec* fdm) + c_FGLGear* GetGearUnit(int gear) + int GetNumGearUnits() + + cdef extern from "models/FGLGear.h" namespace "JSBSim": + cdef cppclass c_FGLGear "JSBSim::FGLGear": + double GetSteerNorm() + cdef extern from "FGFDMExec.h" namespace "JSBSim": cdef cppclass c_FGFDMExec "JSBSim::FGFDMExec": *************** *** 126,127 **** --- 136,138 ---- c_FGPropagate* GetPropagate() c_FGPropertyManager* GetPropertyManager() + c_FGGroundReactions* GetGroundReactions() Index: jsbsim.pyx =================================================================== RCS file: /cvsroot/jsbsim/JSBSim/tests/jsbsim.pyx,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -r1.13 -r1.14 *** jsbsim.pyx 25 Feb 2017 14:23:20 -0000 1.13 --- jsbsim.pyx 11 Mar 2017 12:06:34 -0000 1.14 *************** *** 88,91 **** --- 88,116 ---- return self.thisptr.HasNode(path) + cdef class FGGroundReactions: + + cdef c_FGGroundReactions *thisptr + + def __init__(self): + self.thisptr = NULL + + def get_gear_unit(self, gear): + lgear = FGLGear() + lgear.thisptr = self.thisptr.GetGearUnit(gear) + return lgear + + def get_num_gear_units(self): + return self.thisptr.GetNumGearUnits() + + cdef class FGLGear: + + cdef c_FGLGear *thisptr + + def __init__(self): + self.thisptr = NULL + + def get_steer_norm(self): + return self.thisptr.GetSteerNorm() + # this is the python wrapper class cdef class FGFDMExec: *************** *** 564,565 **** --- 589,595 ---- pm.thisptr = self.thisptr.GetPropertyManager() return pm + + def get_ground_reactions(self): + grndreact = FGGroundReactions() + grndreact.thisptr = self.thisptr.GetGroundReactions() + return grndreact Index: TestLGearSteer.py =================================================================== RCS file: /cvsroot/jsbsim/JSBSim/tests/TestLGearSteer.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** TestLGearSteer.py 16 May 2016 17:29:46 -0000 1.1 --- TestLGearSteer.py 11 Mar 2017 12:06:34 -0000 1.2 *************** *** 20,23 **** --- 20,24 ---- import os + import fpectl import xml.etree.ElementTree as et from JSBSim_utils import JSBSimTestCase, CreateFDM, RunTest, CopyAircraftDef *************** *** 33,36 **** --- 34,48 ---- self.assertAlmostEqual(fdm['fcs/steer-cmd-norm'], 0.0) self.assertAlmostEqual(fdm['fcs/steer-pos-deg'], 0.0) + + # Should be part of a unit test in C++ ? + fpectl.turnon_sigfpe() + + grndreact = fdm.get_ground_reactions() + for i in xrange(grndreact.get_num_gear_units()): + gear = grndreact.get_gear_unit(i) + self.assertEqual(gear.get_steer_norm(), 0.0) + + fpectl.turnoff_sigfpe() + fdm['fcs/steer-pos-deg'] = 5.0 self.assertAlmostEqual(fdm['fcs/steer-pos-deg'], 5.0) |
From: Bertrand <bco...@us...> - 2017-03-08 21:28:04
|
Update of /cvsroot/jsbsim/JSBSim/src/utilities/aeromatic In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv26981/src/utilities/aeromatic Modified Files: aeromatic2.html Log Message: Fixed the links to SF (were broken since SF moved to Allura). Index: aeromatic2.html =================================================================== RCS file: /cvsroot/jsbsim/JSBSim/src/utilities/aeromatic/aeromatic2.html,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -r1.11 -r1.12 *** aeromatic2.html 1 Oct 2015 08:01:49 -0000 1.11 --- aeromatic2.html 8 Mar 2017 21:28:01 -0000 1.12 *************** *** 13,28 **** </DIV> <UL class=solidblockmenu> ! <LI><A href="http://jsbsim.sourceforge.net/index.html">Home</A></LI> ! <LI><A href="http://jsbsim.sourceforge.net/about.html">About Us</A></LI> ! <LI><A href="http://jsbsim.sourceforge.net/news.html">News</A></LI> ! <LI><A href="http://jsbsim.sourceforge.net/download.html">Download</A></LI> ! <LI><A title="JSBSim Reference Manual (PDF)" href="http://jsbsim.sourceforge.net/JSBSimReferenceManual.pdf">Documentation</A></LI> ! <LI><A href="http://sourceforge.net/mail/?group_id=19399">Mailing List</A></LI> ! <LI><A href="http://jsbsim.sourceforge.net/links.html">Links</A></LI> <LI><A href="http://www.sf.net/projects/jsbsim">SF.net/JSBSim</A></LI> ! <LI><A title="View or file a bug report." href="http://sourceforge.net/tracker/?atid=119399&group_id=19399&func=browse">Bugs</A></LI> ! <LI><A title="Make a suggestion to the JSBSim team." href="http://sourceforge.net/tracker/?atid=369399&group_id=19399&func=browse">Suggestions</A></LI> ! <LI><A href="http://jsbsim.wiki.sourceforge.net/">Wiki</A> </LI> ! <LI><A class=current href="http://jsbsim.sf.net/aeromatic2.html">Aeromatic</A></LI> </UL> <DIV id=main align=center> --- 13,29 ---- </DIV> <UL class=solidblockmenu> ! <LI><A href="index.html">Home</A></LI> ! <LI><A href="about.html">About Us</A></LI> ! <LI><A href="https://sourceforge.net/p/jsbsim/news/">News</A></LI> ! <LI><A href="download.html">Download</A></LI> ! <LI><A href="documentation.html" title="JSBSim reference material">Documentation</A></li> ! <LI><A href="https://sourceforge.net/p/jsbsim/mailman/">Mailing List</A></LI> ! <LI><A href="links.html">Links</A></LI> <LI><A href="http://www.sf.net/projects/jsbsim">SF.net/JSBSim</A></LI> ! <LI><A href="https://sourceforge.net/p/jsbsim/bugs/" title="View or file a bug report.">Bugs</A></LI> ! <LI><A href="https://sourceforge.net/p/jsbsim/feature-requests/" title="Make a suggestion to the JSBSim team.">Suggestions</A></LI> ! <LI><A href="https://sourceforge.net/p/jsbsim/wiki/">Wiki</A> </LI> ! <LI><A class="current" href="http://jsbsim.sf.net/aeromatic2.html" title="Generate aircraft configurations files.">Aeromatic</A></LI> ! <LI><A href="http://jsbsim.sf.net/matlab.html" title="Use JSBSim with MATLAB/Simulink">MATLAB</A></LI> </UL> <DIV id=main align=center> |
From: Bertrand <bco...@us...> - 2017-03-03 23:03:23
|
Update of /cvsroot/jsbsim/JSBSim In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv27580 Modified Files: JSBSim.dox Log Message: Updated the Doxygen documentation Index: JSBSim.dox =================================================================== RCS file: /cvsroot/jsbsim/JSBSim/JSBSim.dox,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -r1.26 -r1.27 *** JSBSim.dox 10 Jun 2013 02:10:00 -0000 1.26 --- JSBSim.dox 3 Mar 2017 23:03:20 -0000 1.27 *************** *** 1,13 **** ! # Doxyfile 1.8.2 # This file describes the settings to be used by the documentation system ! # doxygen (www.doxygen.org) for a project # ! # All text after a hash (#) is considered a comment and will be ignored # The format is: ! # TAG = value [value, ...] ! # For lists items can also be appended using: ! # TAG += value [value, ...] [...4085 lines suppressed...] ! # this, this feature is disabled by default. ! # The default value is: NO. ! # This tag requires that the tag HAVE_DOT is set to YES. DOT_MULTI_TARGETS = NO ! # If the GENERATE_LEGEND tag is set to YES doxygen will generate a legend page ! # explaining the meaning of the various boxes and arrows in the dot generated ! # graphs. ! # The default value is: YES. ! # This tag requires that the tag HAVE_DOT is set to YES. GENERATE_LEGEND = YES ! # If the DOT_CLEANUP tag is set to YES, doxygen will remove the intermediate dot ! # files that are used to generate the various graphs. ! # The default value is: YES. ! # This tag requires that the tag HAVE_DOT is set to YES. DOT_CLEANUP = YES |
From: Bertrand <bco...@us...> - 2017-03-03 23:03:23
|
Update of /cvsroot/jsbsim/JSBSim/src/models In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv27580/src/models Modified Files: FGFCS.h Log Message: Updated the Doxygen documentation Index: FGFCS.h =================================================================== RCS file: /cvsroot/jsbsim/JSBSim/src/models/FGFCS.h,v retrieving revision 1.54 retrieving revision 1.55 diff -C2 -r1.54 -r1.55 *** FGFCS.h 25 Feb 2017 14:23:18 -0000 1.54 --- FGFCS.h 3 Mar 2017 23:03:20 -0000 1.55 *************** *** 431,435 **** /** Sets the propeller pitch command for the specified engine @param engine engine ID number ! @param cmd mixture command in percent (0.0 - 1.0)*/ void SetPropAdvanceCmd(int engine, double cmd); --- 431,435 ---- /** Sets the propeller pitch command for the specified engine @param engine engine ID number ! @param cmd pitch command in percent (0.0 - 1.0)*/ void SetPropAdvanceCmd(int engine, double cmd); |
From: Bertrand <bco...@us...> - 2017-03-03 23:00:44
|
Update of /cvsroot/jsbsim/JSBSim/src In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv27414/src Modified Files: FGFDMExec.cpp Log Message: The propeller gyroscopic moment is now using vPQRi because the moment shall be evaluated in the ECI frame. This is for the consistency of the code since FGAccelerations computes the accelerations in the ECI frame and as such is expecting forces and moments to be expressed in that same frame. The documentation has also been updated to mention the 'version' attribute of the <propeller> section that was added to address the [bugs:#110] Index: FGFDMExec.cpp =================================================================== RCS file: /cvsroot/jsbsim/JSBSim/src/FGFDMExec.cpp,v retrieving revision 1.193 retrieving revision 1.194 diff -C2 -r1.193 -r1.194 *** FGFDMExec.cpp 25 Feb 2017 14:23:18 -0000 1.193 --- FGFDMExec.cpp 3 Mar 2017 23:00:39 -0000 1.194 *************** *** 429,433 **** Propulsion->in.PropFeather = FCS->GetPropFeather(); Propulsion->in.H_agl = Propagate->GetDistanceAGL(); ! Propulsion->in.PQR = Propagate->GetPQR(); break; --- 429,433 ---- Propulsion->in.PropFeather = FCS->GetPropFeather(); Propulsion->in.H_agl = Propagate->GetDistanceAGL(); ! Propulsion->in.PQRi = Propagate->GetPQRi(); break; |
From: Bertrand <bco...@us...> - 2017-03-03 23:00:44
|
Update of /cvsroot/jsbsim/JSBSim/src/models/propulsion In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv27414/src/models/propulsion Modified Files: FGEngine.cpp FGEngine.h FGPropeller.cpp FGPropeller.h FGThruster.h Log Message: The propeller gyroscopic moment is now using vPQRi because the moment shall be evaluated in the ECI frame. This is for the consistency of the code since FGAccelerations computes the accelerations in the ECI frame and as such is expecting forces and moments to be expressed in that same frame. The documentation has also been updated to mention the 'version' attribute of the <propeller> section that was added to address the [bugs:#110] Index: FGEngine.cpp =================================================================== RCS file: /cvsroot/jsbsim/JSBSim/src/models/propulsion/FGEngine.cpp,v retrieving revision 1.67 retrieving revision 1.68 diff -C2 -r1.67 -r1.68 *** FGEngine.cpp 27 Sep 2015 09:54:21 -0000 1.67 --- FGEngine.cpp 3 Mar 2017 23:00:39 -0000 1.68 *************** *** 159,163 **** Thruster->in.TotalDeltaT = in.TotalDeltaT; Thruster->in.H_agl = in.H_agl; ! Thruster->in.PQR = in.PQR; Thruster->in.AeroPQR = in.AeroPQR; Thruster->in.AeroUVW = in.AeroUVW; --- 159,163 ---- Thruster->in.TotalDeltaT = in.TotalDeltaT; Thruster->in.H_agl = in.H_agl; ! Thruster->in.PQRi = in.PQRi; Thruster->in.AeroPQR = in.AeroPQR; Thruster->in.AeroUVW = in.AeroUVW; Index: FGEngine.h =================================================================== RCS file: /cvsroot/jsbsim/JSBSim/src/models/propulsion/FGEngine.h,v retrieving revision 1.47 retrieving revision 1.48 diff -C2 -r1.47 -r1.48 *** FGEngine.h 27 Sep 2015 10:16:57 -0000 1.47 --- FGEngine.h 3 Mar 2017 23:00:39 -0000 1.48 *************** *** 139,143 **** FGColumnVector3 AeroUVW; FGColumnVector3 AeroPQR; ! FGColumnVector3 PQR; std::vector <double> ThrottleCmd; std::vector <double> MixtureCmd; --- 139,143 ---- FGColumnVector3 AeroUVW; FGColumnVector3 AeroPQR; ! FGColumnVector3 PQRi; std::vector <double> ThrottleCmd; std::vector <double> MixtureCmd; Index: FGPropeller.cpp =================================================================== RCS file: /cvsroot/jsbsim/JSBSim/src/models/propulsion/FGPropeller.cpp,v retrieving revision 1.59 retrieving revision 1.60 diff -C2 -r1.59 -r1.60 *** FGPropeller.cpp 26 Feb 2017 12:09:46 -0000 1.59 --- FGPropeller.cpp 3 Mar 2017 23:00:39 -0000 1.60 *************** *** 81,86 **** Sense_multiplier = 1.0; ! if (prop_element->HasAttribute("version")) ! if (prop_element->GetAttributeValueAsNumber("version") > 1.0) Sense_multiplier = -1.0; --- 81,86 ---- Sense_multiplier = 1.0; ! if (prop_element->HasAttribute("version") ! && prop_element->GetAttributeValueAsNumber("version") > 1.0) Sense_multiplier = -1.0; *************** *** 147,150 **** --- 147,151 ---- RPM = 0; vTorque.InitMatrix(); + vH.InitMatrix(); D4 = Diameter*Diameter*Diameter*Diameter; D5 = D4*Diameter; *************** *** 274,279 **** vH(eX) = Ixx*omega*Sense*Sense_multiplier; - vH(eY) = 0.0; - vH(eZ) = 0.0; if (omega > 0.0) ExcessTorque = PowerAvailable / omega; --- 275,278 ---- *************** *** 286,290 **** // Transform Torque and momentum first, as PQR is used in this // equation and cannot be transformed itself. ! vMn = in.PQR*(Transform()*vH) + Transform()*vTorque; return Thrust; // return thrust in pounds --- 285,289 ---- // Transform Torque and momentum first, as PQR is used in this // equation and cannot be transformed itself. ! vMn = in.PQRi*(Transform()*vH) + Transform()*vTorque; return Thrust; // return thrust in pounds *************** *** 306,310 **** // do normal calculation when propeller is neither feathered nor reversed // Note: This method of feathering and reversing was added to support the ! // turboprop model. It's left here for backward compatablity, but // now feathering and reversing should be done in Manual Pitch Mode. if (!Feathered) { --- 305,309 ---- // do normal calculation when propeller is neither feathered nor reversed // Note: This method of feathering and reversing was added to support the ! // turboprop model. It's left here for backward compatiblity, but // now feathering and reversing should be done in Manual Pitch Mode. if (!Feathered) { Index: FGPropeller.h =================================================================== RCS file: /cvsroot/jsbsim/JSBSim/src/models/propulsion/FGPropeller.h,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -r1.27 -r1.28 *** FGPropeller.h 26 Feb 2017 12:09:46 -0000 1.27 --- FGPropeller.h 3 Mar 2017 23:00:39 -0000 1.28 *************** *** 58,68 **** %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ ! /** FGPropeller models a propeller given the tabular data for Ct and Cp, ! indexed by the advance ratio "J". ! <h3>Configuration File Format:</h3> ! @code <sense> {1 | -1} </sense> ! <propeller name="{string}"> <ixx> {number} </ixx> <diameter unit="IN"> {number} </diameter> --- 58,69 ---- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ ! /** FGPropeller models a propeller given the tabular data for Ct (thrust) and ! Cp (power), indexed by the advance ratio "J". ! ### Configuration File Format ! ! ~~~{.xml} <sense> {1 | -1} </sense> ! <propeller name="{string}" version="{string}"> <ixx> {number} </ixx> <diameter unit="IN"> {number} </diameter> *************** *** 103,111 **** </table> - </propeller> ! @endcode - <h3>Configuration Parameters:</h3> <pre> \<ixx> - Propeller rotational inertia. --- 104,112 ---- </table> </propeller> ! ~~~ ! ! ### Configuration Parameters <pre> \<ixx> - Propeller rotational inertia. *************** *** 127,149 **** </pre> ! Two tables are needed. One for coefficient of thrust (Ct) and one for ! coefficient of power (Cp). ! Two tables are optional. They apply a factor to Ct and Cp based on the ! helical tip Mach. ! <br> ! ! Several references were helpful, here:<ul> ! <li>Barnes W. McCormick, "Aerodynamics, Aeronautics, and Flight Mechanics", ! Wiley & Sons, 1979 ISBN 0-471-03032-5</li> ! <li>Edwin Hartman, David Biermann, "The Aerodynamic Characteristics of ! Full Scale Propellers Having 2, 3, and 4 Blades of Clark Y and R.A.F. 6 ! Airfoil Sections", NACA Report TN-640, 1938 (?)</li> ! <li>Various NACA Technical Notes and Reports</li> ! </ul> ! @author Jon S. Berndt ! @version $Id$ ! @see FGEngine ! @see FGThruster */ --- 128,165 ---- </pre> ! Two tables are needed. One for coefficient of thrust (Ct) and one for ! coefficient of power (Cp). ! Two tables are optional. They apply a factor to Ct and Cp based on the ! helical tip Mach. ! ! In addition to thrust, the propeller applies two moments to the aircraft: ! - The torque that tends to roll the aircraft in the direction opposite to the ! propeller rotation, ! - and the gyroscopic moment. ! ! It should be noted that historically the gyroscopic moment had an incorrect ! sign. The correct sign can be obtained by specifying a **version** attribute ! higher than 1.0 to the propeller definition ! ~~~.xml ! <propeller name="a_prop" version="1.1"> ! <!-- propeller definition --> ! </propeller> ! ~~~ ! For backward compatibility, the absence of the **version** attribute will result ! in the gyroscopic moment to be computed with the legacy incorrect sign. ! ! Several references were helpful, here: ! + Barnes W. McCormick, "Aerodynamics, Aeronautics, and Flight Mechanics", ! Wiley & Sons, 1979 ISBN 0-471-03032-5 ! + Edwin Hartman, David Biermann, "The Aerodynamic Characteristics of ! Full Scale Propellers Having 2, 3, and 4 Blades of Clark Y and R.A.F. 6 ! Airfoil Sections", NACA Report TN-640, 1938 (?) ! + Various NACA Technical Notes and Reports ! ! @author Jon S. Berndt ! @version $Id$ ! @see FGEngine ! @see FGThruster */ *************** *** 164,167 **** --- 180,184 ---- ~FGPropeller(); + /// Reset the initial conditions. void ResetToIC(void); *************** *** 169,178 **** instance will calculate its own rotational velocity, given the Torque produced by the engine and integrating over time using the standard ! equation for rotational acceleration "a": a = Q/I , where Q is Torque and ! I is moment of inertia for the propeller. @param rpm the rotational velocity of the propeller */ void SetRPM(double rpm) {RPM = rpm;} ! /** Sets the Revolutions Per Minute for the propeller using the engine gear ratio **/ void SetEngineRPM(double rpm) {RPM = rpm/GearRatio;} --- 186,196 ---- instance will calculate its own rotational velocity, given the Torque produced by the engine and integrating over time using the standard ! equation for rotational acceleration \f$a\f$: \f$a = Q/I\f$ , where ! \f$Q\f$ is Torque and \f$I\f$ is moment of inertia for the propeller. @param rpm the rotational velocity of the propeller */ void SetRPM(double rpm) {RPM = rpm;} ! /** Sets the Revolutions Per Minute for the propeller using the engine gear ! ratio */ void SetEngineRPM(double rpm) {RPM = rpm/GearRatio;} *************** *** 189,192 **** --- 207,213 ---- void SetPitch(double pitch) {Pitch = pitch;} + /** Set the propeller pitch. + @param advance the pitch command in percent (0.0 - 1.0) + */ void SetAdvance(double advance) {Advance = advance;} *************** *** 258,275 **** @return the thrust in pounds */ double Calculate(double EnginePower); FGColumnVector3 GetPFactor(void) const; std::string GetThrusterLabels(int id, const std::string& delimeter); std::string GetThrusterValues(int id, const std::string& delimeter); ! void SetReverseCoef (double c) { Reverse_coef = c; } double GetReverseCoef (void) const { return Reverse_coef; } void SetReverse (bool r) { Reversed = r; } bool GetReverse (void) const { return Reversed; } void SetFeather (bool f) { Feathered = f; } bool GetFeather (void) const { return Feathered; } double GetThrustCoefficient(void) const {return ThrustCoeff;} double GetHelicalTipMach(void) const {return HelicalTipMach;} int GetConstantSpeed(void) const {return ConstantSpeed;} void SetInducedVelocity(double Vi) {Vinduced = Vi;} double GetInducedVelocity(void) const {return Vinduced;} --- 279,311 ---- @return the thrust in pounds */ double Calculate(double EnginePower); + /// Retrieves the P-Factor constant FGColumnVector3 GetPFactor(void) const; + /// Generate the labels for the thruster standard CSV output std::string GetThrusterLabels(int id, const std::string& delimeter); + /// Generate the values for the thruster standard CSV output std::string GetThrusterValues(int id, const std::string& delimeter); ! /** Set the propeller reverse pitch. ! @param c the reverse pitch command in percent (0.0 - 1.0) ! */ void SetReverseCoef (double c) { Reverse_coef = c; } + /// Retrieves the reverse pitch command. double GetReverseCoef (void) const { return Reverse_coef; } + /// If true, sets the propeller in reversed position. void SetReverse (bool r) { Reversed = r; } + /// Returns true if the propeller is in reverse position. bool GetReverse (void) const { return Reversed; } + /// If true, sets the propeller in feathered position. void SetFeather (bool f) { Feathered = f; } + /// Returns true if the propeller is in feathered position. bool GetFeather (void) const { return Feathered; } + /// Retrieves the thrust coefficient double GetThrustCoefficient(void) const {return ThrustCoeff;} + /// Retrieves the Mach number at the propeller tips. double GetHelicalTipMach(void) const {return HelicalTipMach;} + /// Returns a non-zero value if the propeller is constant speed. int GetConstantSpeed(void) const {return ConstantSpeed;} + /// Set the propeller induced velocity void SetInducedVelocity(double Vi) {Vinduced = Vi;} + /// Get the propeller induced velocity. double GetInducedVelocity(void) const {return Vinduced;} Index: FGThruster.h =================================================================== RCS file: /cvsroot/jsbsim/JSBSim/src/models/propulsion/FGThruster.h,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -r1.26 -r1.27 *** FGThruster.h 27 Sep 2015 10:03:53 -0000 1.26 --- FGThruster.h 3 Mar 2017 23:00:39 -0000 1.27 *************** *** 117,121 **** double TotalDeltaT; double H_agl; ! FGColumnVector3 PQR; FGColumnVector3 AeroPQR; FGColumnVector3 AeroUVW; --- 117,121 ---- double TotalDeltaT; double H_agl; ! FGColumnVector3 PQRi; FGColumnVector3 AeroPQR; FGColumnVector3 AeroUVW; |
From: Bertrand <bco...@us...> - 2017-02-26 12:18:10
|
Update of /cvsroot/jsbsim/JSBSim/aircraft/Short_S23 In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv14853/aircraft/Short_S23 Modified Files: reset01.xml reset02.xml reset03.xml Log Message: Modified the initial value of the aircraft pitch to help convergence of the trim solver which otherwise fails to find a solution. (The trim solver is really struggling with the Short S23, hence this aircraft is a very good stress test for the algorithm ;-) Index: reset01.xml =================================================================== RCS file: /cvsroot/jsbsim/JSBSim/aircraft/Short_S23/reset01.xml,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** reset01.xml 6 Oct 2012 19:55:37 -0000 1.2 --- reset01.xml 26 Feb 2017 12:18:07 -0000 1.3 *************** *** 10,14 **** <longitude unit="DEG">-122.34 </longitude> <phi unit="DEG"> 0.0 </phi> ! <theta unit="DEG"> 0.0 </theta> <psi unit="DEG"> 180.0 </psi> <altitude unit="FT"> 3000.0 </altitude> --- 10,14 ---- <longitude unit="DEG">-122.34 </longitude> <phi unit="DEG"> 0.0 </phi> ! <theta unit="DEG"> -1.0 </theta> <psi unit="DEG"> 180.0 </psi> <altitude unit="FT"> 3000.0 </altitude> Index: reset02.xml =================================================================== RCS file: /cvsroot/jsbsim/JSBSim/aircraft/Short_S23/reset02.xml,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** reset02.xml 13 Dec 2015 14:29:19 -0000 1.4 --- reset02.xml 26 Feb 2017 12:18:07 -0000 1.5 *************** *** 8,12 **** <longitude unit="DEG">-122.34 </longitude> <phi unit="DEG"> 0.0 </phi> ! <theta unit="DEG"> -2.0 </theta> <psi unit="DEG"> 180.0 </psi> <altitude unit="FT"> 5500.0 </altitude> --- 8,12 ---- <longitude unit="DEG">-122.34 </longitude> <phi unit="DEG"> 0.0 </phi> ! <theta unit="DEG"> -2.5 </theta> <psi unit="DEG"> 180.0 </psi> <altitude unit="FT"> 5500.0 </altitude> Index: reset03.xml =================================================================== RCS file: /cvsroot/jsbsim/JSBSim/aircraft/Short_S23/reset03.xml,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** reset03.xml 2 Jan 2016 17:49:30 -0000 1.3 --- reset03.xml 26 Feb 2017 12:18:07 -0000 1.4 *************** *** 8,12 **** <longitude unit="DEG">-122.34 </longitude> <phi unit="DEG"> 0.0 </phi> ! <theta unit="DEG"> 2.0 </theta> <psi unit="DEG"> 180.0 </psi> <altitude unit="FT"> 400.0 </altitude> --- 8,12 ---- <longitude unit="DEG">-122.34 </longitude> <phi unit="DEG"> 0.0 </phi> ! <theta unit="DEG"> 1.5 </theta> <psi unit="DEG"> 180.0 </psi> <altitude unit="FT"> 400.0 </altitude> |
From: Bertrand <bco...@us...> - 2017-02-26 12:09:49
|
Update of /cvsroot/jsbsim/JSBSim/src/models/propulsion In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv14476/src/models/propulsion Modified Files: FGPropeller.cpp FGPropeller.h Log Message: The propeller required power was computed with an advance ratio which did not account for the engine tilt (using in.AeroUVW instead of localAeroVel). This is not supposed to make much difference but this patch brings consistency and saves a bit of computation since J is now only computed once. Index: FGPropeller.cpp =================================================================== RCS file: /cvsroot/jsbsim/JSBSim/src/models/propulsion/FGPropeller.cpp,v retrieving revision 1.58 retrieving revision 1.59 diff -C2 -r1.58 -r1.59 *** FGPropeller.cpp 4 Jun 2016 11:06:51 -0000 1.58 --- FGPropeller.cpp 26 Feb 2017 12:09:46 -0000 1.59 *************** *** 188,191 **** --- 188,199 ---- //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + void FGPropeller::ResetToIC(void) + { + FGThruster::ResetToIC(); + Vinduced = 0.0; + } + + //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // // We must be getting the aerodynamic velocity here, NOT the inertial velocity. *************** *** 212,220 **** HelicalTipMach = sqrt(Vtip*Vtip + Vel*Vel) / in.Soundspeed; - PowerAvailable = EnginePower - GetPowerRequired(); - if (RPS > 0.0) J = Vel / (Diameter * RPS); // Calculate J normally else J = Vel / Diameter; if (MaxPitch == MinPitch) { // Fixed pitch prop ThrustCoeff = cThrust->GetValue(J); --- 220,228 ---- HelicalTipMach = sqrt(Vtip*Vtip + Vel*Vel) / in.Soundspeed; if (RPS > 0.0) J = Vel / (Diameter * RPS); // Calculate J normally else J = Vel / Diameter; + PowerAvailable = EnginePower - GetPowerRequired(); + if (MaxPitch == MinPitch) { // Fixed pitch prop ThrustCoeff = cThrust->GetValue(J); *************** *** 287,297 **** double FGPropeller::GetPowerRequired(void) { ! double cPReq, J; ! double rho = in.Density; ! double Vel = in.AeroUVW(eU) + Vinduced; ! double RPS = RPM / 60.0; ! ! if (RPS != 0.0) J = Vel / (Diameter * RPS); ! else J = Vel / Diameter; if (MaxPitch == MinPitch) { // Fixed pitch prop --- 295,299 ---- double FGPropeller::GetPowerRequired(void) { ! double cPReq; if (MaxPitch == MinPitch) { // Fixed pitch prop *************** *** 350,356 **** if (CpMach) cPReq *= CpMach->GetValue(HelicalTipMach); double local_RPS = RPS < 0.01 ? 0.01 : RPS; ! PowerRequired = cPReq*local_RPS*local_RPS*local_RPS*D5*rho; vTorque(eX) = -Sense*PowerRequired / (local_RPS*2.0*M_PI); --- 352,359 ---- if (CpMach) cPReq *= CpMach->GetValue(HelicalTipMach); + double RPS = RPM / 60.0; double local_RPS = RPS < 0.01 ? 0.01 : RPS; ! PowerRequired = cPReq*local_RPS*local_RPS*local_RPS*D5*in.Density; vTorque(eX) = -Sense*PowerRequired / (local_RPS*2.0*M_PI); Index: FGPropeller.h =================================================================== RCS file: /cvsroot/jsbsim/JSBSim/src/models/propulsion/FGPropeller.h,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -r1.26 -r1.27 *** FGPropeller.h 2 Jan 2016 17:42:53 -0000 1.26 --- FGPropeller.h 26 Feb 2017 12:09:46 -0000 1.27 *************** *** 164,167 **** --- 164,169 ---- ~FGPropeller(); + void ResetToIC(void); + /** Sets the Revolutions Per Minute for the propeller. Normally the propeller instance will calculate its own rotational velocity, given the Torque |
From: Bertrand <bco...@us...> - 2017-02-26 11:41:31
|
Update of /cvsroot/jsbsim/JSBSim/src/models/propulsion In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv13271/src/models/propulsion Modified Files: FGTurboProp.h FGTurboProp.cpp Log Message: Removed dead code Index: FGTurboProp.h =================================================================== RCS file: /cvsroot/jsbsim/JSBSim/src/models/propulsion/FGTurboProp.h,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -r1.24 -r1.25 *** FGTurboProp.h 10 Jul 2016 12:39:28 -0000 1.24 --- FGTurboProp.h 26 Feb 2017 11:41:28 -0000 1.25 *************** *** 122,126 **** double GetN1(void) const {return N1;} - double GetEPR(void) const {return EPR;} double GetITT(void) const {return Eng_ITT_degC;} double GetEngStarting(void) const { return EngStarting; } --- 122,125 ---- *************** *** 133,137 **** void SetPhase( phaseType p ) { phase = p; } - void SetEPR(double epr) {EPR = epr;} void SetReverse(bool reversed) { Reversed = reversed; } void SetCutoff(bool cutoff) { Cutoff = cutoff; } --- 132,135 ---- *************** *** 146,150 **** phaseType phase; ///< Operating mode, or "phase" - double MilThrust; ///< Maximum Unaugmented Thrust, static @ S.L. (lbf) double IdleN1; ///< Idle N1 double N1; ///< N1 --- 144,147 ---- *************** *** 156,160 **** bool Cutoff; - double EPR; double OilPressure_psi; double OilTemp_degK; --- 153,156 ---- Index: FGTurboProp.cpp =================================================================== RCS file: /cvsroot/jsbsim/JSBSim/src/models/propulsion/FGTurboProp.cpp,v retrieving revision 1.35 retrieving revision 1.36 diff -C2 -r1.35 -r1.36 *** FGTurboProp.cpp 10 Jul 2016 12:39:28 -0000 1.35 --- FGTurboProp.cpp 26 Feb 2017 11:41:28 -0000 1.36 *************** *** 112,117 **** // ToDo: Need to make sure units are properly accounted for below. - if (el->FindElement("milthrust")) - MilThrust = el->FindElementValueAsNumberConvertTo("milthrust","LBS"); if (el->FindElement("idlen1")) IdleN1 = el->FindElementValueAsNumber("idlen1"); --- 112,115 ---- *************** *** 198,202 **** ThrottlePos = in.ThrottlePos[EngineNumber]; ! /* The thruster controls the engine RPM because it encapsulates the gear ratio and other transmission variables */ RPM = Thruster->GetEngineRPM(); if (thrusterType == FGThruster::ttPropeller) { --- 196,201 ---- ThrottlePos = in.ThrottlePos[EngineNumber]; ! /* The thruster controls the engine RPM because it encapsulates the gear ratio ! and other transmission variables */ RPM = Thruster->GetEngineRPM(); if (thrusterType == FGThruster::ttPropeller) { *************** *** 321,325 **** double FGTurboProp::Run(void) { - double thrust = 0.0; double EngPower_HP; --- 320,323 ---- *************** *** 343,347 **** OilPressure_psi = (N1/100.0*0.25+(0.1-(OilTemp_degK-273.15)*0.1/80.0)*N1/100.0) / 7692.0e-6; //from MPa to psi //--- - EPR = 1.0 + thrust/MilThrust; OilTemp_degK = Seek(&OilTemp_degK, 353.15, 0.4-N1*0.001, 0.04); --- 341,344 ---- *************** *** 478,482 **** HP = 0.0; Type = etTurboprop; - MilThrust = 10000.0; IdleN1 = 30.0; MaxN1 = 100.0; --- 475,478 ---- *************** *** 591,595 **** cout << "\n ****MUJ MOTOR TURBOPROP****\n"; cout << "\n Engine Name: " << Name << endl; - cout << " MilThrust: " << MilThrust << endl; cout << " IdleN1: " << IdleN1 << endl; cout << " MaxN1: " << MaxN1 << endl; --- 587,590 ---- |
From: Bertrand <bco...@us...> - 2017-02-26 11:37:34
|
Update of /cvsroot/jsbsim/JSBSim/tests In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv13088/tests Modified Files: CheckAircrafts.py CheckOutputRate.py CheckSimTimeReset.py JSBSim_utils.py Log Message: Code clean up Index: CheckAircrafts.py =================================================================== RCS file: /cvsroot/jsbsim/JSBSim/tests/CheckAircrafts.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** CheckAircrafts.py 11 Jun 2016 16:19:01 -0000 1.4 --- CheckAircrafts.py 26 Feb 2017 11:37:30 -0000 1.5 *************** *** 21,25 **** import os ! from JSBSim_utils import JSBSimTestCase, append_xml, CreateFDM, CheckXMLFile, RunTest --- 21,25 ---- import os ! from JSBSim_utils import JSBSimTestCase, CreateFDM, CheckXMLFile, RunTest *************** *** 34,38 **** continue ! f = os.path.join(aircraft_path, d, append_xml(d)) # Is f an aircraft definition file ? --- 34,38 ---- continue ! f = os.path.join(aircraft_path, d, d+'.xml') # Is f an aircraft definition file ? Index: CheckOutputRate.py =================================================================== RCS file: /cvsroot/jsbsim/JSBSim/tests/CheckOutputRate.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -r1.6 -r1.7 *** CheckOutputRate.py 31 Jan 2016 11:29:41 -0000 1.6 --- CheckOutputRate.py 26 Feb 2017 11:37:30 -0000 1.7 *************** *** 37,50 **** self.tree = et.parse(self.script_path) root = self.tree.getroot() ! use_tag = root.find("./use") aircraft_name = use_tag.attrib['aircraft'] ! self.run_tag = root.find("./run") self.dt = float(self.run_tag.attrib['dt']) # Read the date at which the trim will be run ! event_tags = root.findall('./run/event') ! for event in event_tags: if event.attrib['name'] == 'Trim': ! cond_tag = event.find('./condition') self.trim_date = float(string.split(cond_tag.text)[-1]) break --- 37,49 ---- self.tree = et.parse(self.script_path) root = self.tree.getroot() ! use_tag = root.find('use') aircraft_name = use_tag.attrib['aircraft'] ! self.run_tag = root.find('run') self.dt = float(self.run_tag.attrib['dt']) # Read the date at which the trim will be run ! for event in root.findall('run/event'): if event.attrib['name'] == 'Trim': ! cond_tag = event.find('condition') self.trim_date = float(string.split(cond_tag.text)[-1]) break *************** *** 54,58 **** append_xml(ai |
From: Bertrand <bco...@us...> - 2017-02-26 11:36:44
|
Update of /cvsroot/jsbsim/JSBSim/tests In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv13040/tests Modified Files: TestInputSocket.py Log Message: Now checks that the time step obtained thru the socket is containing the expected value before using it. Index: TestInputSocket.py =================================================================== RCS file: /cvsroot/jsbsim/JSBSim/tests/TestInputSocket.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** TestInputSocket.py 30 Jan 2016 18:50:24 -0000 1.4 --- TestInputSocket.py 26 Feb 2017 11:36:41 -0000 1.5 *************** *** 157,165 **** def test_input_socket(self): # The aircraft c172x does not contain an <input> tag so we need # to add one. tree, aircraft_name, b = CopyAircraftDef(self.script_path, self.sandbox) ! self.root = tree.getroot() ! input_tag = et.SubElement(self.root, 'input') input_tag.attrib['port'] = '1137' tree.write(self.sandbox('aircraft', aircraft_name, --- 157,169 ---- def test_input_socket(self): + # First, extract the time step from the script file + tree = et.parse(self.script_path) + dt = float(tree.getroot().find('run').attrib['dt']) + # The aircraft c172x does not contain an <input> tag so we need # to add one. tree, aircraft_name, b = CopyAircraftDef(self.script_path, self.sandbox) ! root = tree.getroot() ! input_tag = et.SubElement(root, 'input') input_tag.attrib['port'] = '1137' tree.write(self.sandbox('aircraft', aircraft_name, *************** *** 178,184 **** msg = string.split(tn.sendCommand("info"), '\n') self.assertEqual(string.strip(string.split(msg[2], ':')[1]), ! string.strip(self.root.attrib['name'])) self.assertEqual(string.strip(string.split(msg[1], ':')[1]), ! string.strip(self.root.attrib['version'])) # Check that the simulation time is 0.0 --- 182,188 ---- msg = string.split(tn.sendCommand("info"), '\n') self.assertEqual(string.strip(string.split(msg[2], ':')[1]), ! string.strip(root.attrib['name'])) self.assertEqual(string.strip(string.split(msg[1], ':')[1]), ! string.strip(root.attrib['version'])) # Check that the simulation time is 0.0 *************** *** 187,190 **** --- 191,197 ---- self.assertEqual(tn.getPropertyValue("simulation/sim-time-sec"), 0.0) + # Check the time step we get through the socket interface + self.assertEqual(tn.getDeltaT(), dt) + # Check that 'iterate' iterates the correct number of times tn.sendCommand("iterate 19") |
From: Bertrand <bco...@us...> - 2017-02-25 15:50:05
|
Update of /cvsroot/jsbsim/JSBSim/src In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv31261/src Modified Files: JSBSim.cpp Log Message: Mac build fix from James Turner Index: JSBSim.cpp =================================================================== RCS file: /cvsroot/jsbsim/JSBSim/src/JSBSim.cpp,v retrieving revision 1.90 retrieving revision 1.91 diff -C2 -r1.90 -r1.91 *** JSBSim.cpp 25 Feb 2017 14:23:18 -0000 1.90 --- JSBSim.cpp 25 Feb 2017 15:50:02 -0000 1.91 *************** *** 288,292 **** _controlfp(_controlfp(0, 0) & ~(_EM_INVALID | _EM_ZERODIVIDE | _EM_OVERFLOW), _MCW_EM); ! #elif defined(__GNUC__) && !defined(sgi) feenableexcept(FE_DIVBYZERO | FE_INVALID); #endif --- 288,292 ---- _controlfp(_controlfp(0, 0) & ~(_EM_INVALID | _EM_ZERODIVIDE | _EM_OVERFLOW), _MCW_EM); ! #elif defined(__GNUC__) && !defined(sgi) && !defined(__APPLE__) feenableexcept(FE_DIVBYZERO | FE_INVALID); #endif |
From: Bertrand <bco...@us...> - 2017-02-25 15:47:06
|
Update of /cvsroot/jsbsim/JSBSim/src/simgear/misc In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv31144/src/simgear/misc Modified Files: strutils.cxx Log Message: Removed the C++11 statements and C++98 instead since JBSim does not set the C++11 flag for compilation. Index: strutils.cxx =================================================================== RCS file: /cvsroot/jsbsim/JSBSim/src/simgear/misc/strutils.cxx,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** strutils.cxx 25 Feb 2017 14:23:20 -0000 1.1 --- strutils.cxx 25 Feb 2017 15:47:03 -0000 1.2 *************** *** 179,183 **** string_list split_on_any_of(const std::string& str, const char* seperators) { ! if (seperators == nullptr || (strlen(seperators) == 0)) { throw "illegal/missing seperator string"; } --- 179,183 ---- string_list split_on_any_of(const std::string& str, const char* seperators) { ! if (seperators == NULL || (strlen(seperators) == 0)) { throw "illegal/missing seperator string"; } *************** *** 269,287 **** stripTrailingNewlines_inplace(string& s) { ! // The following (harder to read) implementation is much slower on ! // my system (g++ 6.2.1 on Debian): 11.4 vs. 3.9 seconds on ! // 50,000,000 iterations performed on a short CRLF-terminated ! // string---and it is even a bit slower (12.9 seconds) with ! // std::next(it) instead of (it+1). // ! // for (string::reverse_iterator it = s.rbegin(); ! // it != s.rend() && (*it == '\r' || *it == '\n'); /* empty */) { ! // it = string::reverse_iterator(s.erase( (it+1).base() )); ! // } ! ! // Simple and fast ! while (!s.empty() && (s.back() == '\r' || s.back() == '\n')) { ! s.pop_back(); } } --- 269,287 ---- stripTrailingNewlines_inplace(string& s) { ! // Florent Rougon: The following (harder to read) implementation is ! // much slower on my system (g++ 6.2.1 on Debian): 11.4 vs. 3.9 ! // seconds on 50,000,000 iterations performed on a short ! // CRLF-terminated string---and it is even a bit slower (12.9 seconds) ! // with std::next(it) instead of (it+1). // ! for (string::reverse_iterator it = s.rbegin(); ! it != s.rend() && (*it == '\r' || *it == '\n'); /* empty */) { ! it = string::reverse_iterator(s.erase( (it+1).base() )); } + + // Simple and fast but need C++11 + // while (!s.empty() && (s.back() == '\r' || s.back() == '\n')) { + // s.pop_back(); + // } } |
From: Bertrand <bco...@us...> - 2017-02-25 15:45:27
|
Update of /cvsroot/jsbsim/JSBSim/examples In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv31066/examples Modified Files: FlightGear.cxx Log Message: Backport from FlightGear Index: FlightGear.cxx =================================================================== RCS file: /cvsroot/jsbsim/JSBSim/examples/FlightGear.cxx,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -r1.24 -r1.25 *** FlightGear.cxx 18 May 2016 13:26:59 -0000 1.24 --- FlightGear.cxx 25 Feb 2017 15:45:23 -0000 1.25 *************** *** 186,189 **** --- 186,190 ---- case SG_WARN: case SG_ALERT: + case SG_POPUP: FGJSBBase::debug_lvl = 0x00; break; *************** *** 234,240 **** fdmex->Setdt( dt ); ! result = fdmex->LoadModel( aircraft_path.str(), ! engine_path.str(), ! systems_path.str(), fgGetString("/sim/aero"), false ); --- 235,239 ---- fdmex->Setdt( dt ); ! result = fdmex->LoadModel( aircraft_path, engine_path, systems_path, fgGetString("/sim/aero"), false ); *************** *** 503,507 **** // Run an iteration of the EOM (equations of motion) - void FGJSBsim::update( double dt ) { --- 502,505 ---- *************** *** 655,659 **** eng->SetReverse( globals->get_controls()->get_reverser(i) ); eng->SetCutoff( globals->get_controls()->get_cutoff(i) ); ! eng->SetIgnition( globals->get_controls()->get_ignition(i) ); eng->SetGeneratorPower( globals->get_controls()->get_generator_breaker(i) ); --- 653,657 ---- eng->SetReverse( globals->get_controls()->get_reverser(i) ); eng->SetCutoff( globals->get_controls()->get_cutoff(i) ); ! // eng->SetIgnition( globals->get_controls()->get_ignition(i) ); eng->SetGeneratorPower( globals->get_controls()->get_generator_breaker(i) ); *************** *** 883,889 **** //node->setDoubleValue("n2", eng->GetN2()); node->setDoubleValue("itt_degf", 32 + eng->GetITT()*9/5); ! node->setBoolValue("ignition", eng->GetIgnition() != 0); ! node->setDoubleValue("nozzle-pos-norm", eng->GetNozzle()); ! node->setDoubleValue("inlet-pos-norm", eng->GetInlet()); node->setDoubleValue("oil-pressure-psi", eng->getOilPressure_psi()); node->setBoolValue("reversed", eng->GetReversed()); --- 881,887 ---- //node->setDoubleValue("n2", eng->GetN2()); node->setDoubleValue("itt_degf", 32 + eng->GetITT()*9/5); ! // node->setBoolValue("ignition", eng->GetIgnition() != 0); ! // node->setDoubleValue("nozzle-pos-norm", eng->GetNozzle()); ! // node->setDoubleValue("inlet-pos-norm", eng->GetInlet()); node->setDoubleValue("oil-pressure-psi", eng->getOilPressure_psi()); node->setBoolValue("reversed", eng->GetReversed()); *************** *** 1024,1037 **** SG_LOG(SG_FLIGHT,SG_INFO," cur alt (ft) = " << alt ); ! sgGeodToGeoc( lat, alt * SG_FEET_TO_METER, ! &sea_level_radius_meters, &lat_geoc ); ! double sea_level_radius_ft = sea_level_radius_meters * SG_METER_TO_FEET; ! _set_Sea_level_radius( sea_level_radius_ft ); - if (needTrim) - fgic->SetLatitudeRadIC( lat_geoc ); - else Propagate->SetLatitude(lat_geoc); FGInterface::set_Latitude(lat); --- 1022,1036 ---- SG_LOG(SG_FLIGHT,SG_INFO," cur alt (ft) = " << alt ); ! if (needTrim) ! fgic->SetGeodLatitudeRadIC( lat ); ! else { ! sgGeodToGeoc( lat, alt * SG_FEET_TO_METER, ! &sea_level_radius_meters, &lat_geoc ); ! double sea_level_radius_ft = sea_level_radius_meters * SG_METER_TO_FEET; ! _set_Sea_level_radius( sea_level_radius_ft ); Propagate->SetLatitude(lat_geoc); + } FGInterface::set_Latitude(lat); *************** *** 1056,1066 **** SG_LOG(SG_FLIGHT,SG_INFO, "FGJSBsim::set_Altitude: " << alt ); ! if (needTrim) { ! FGLocation position = fgic->GetPosition(); ! ! position.SetPositionGeodetic(0.0, position.GetGeodLatitudeRad(), alt); ! fgic->SetAltitudeASLFtIC(position.GetAltitudeASL()); ! fgic->SetLatitudeRadIC(position.GetLatitude()); ! } else Propagate->SetAltitudeASL(alt); --- 1055,1060 ---- SG_LOG(SG_FLIGHT,SG_INFO, "FGJSBsim::set_Altitude: " << alt ); ! if (needTrim) ! fgic->SetAltitudeASLFtIC(alt); else Propagate->SetAltitudeASL(alt); *************** *** 1312,1315 **** --- 1306,1310 ---- // ground in this area. double groundCacheRadius = acrad + 2*dt*Propagate->GetUVW().Magnitude(); + cart_pos[0] = cart(1); cart_pos[1] = cart(2); |
From: Bertrand <bco...@us...> - 2017-02-25 14:23:23
|
Update of /cvsroot/jsbsim/JSBSim/tests In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv24758/tests Modified Files: jsbsim.pxd jsbsim.pyx Log Message: JSBSim now uses SGPath to manage file names. It allows to use absolute paths, to use Unicode file names and to benefit from SimGear maintenance for the corresponding code. Index: jsbsim.pxd =================================================================== RCS file: /cvsroot/jsbsim/JSBSim/tests/jsbsim.pxd,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** jsbsim.pxd 25 Jun 2016 19:55:15 -0000 1.3 --- jsbsim.pxd 25 Feb 2017 14:23:20 -0000 1.4 *************** *** 29,37 **** int GetNumEngines() cdef extern from "initialization/FGInitialCondition.h" namespace "JSBSim": cdef cppclass c_FGInitialCondition "JSBSim::FGInitialCondition": c_FGInitialCondition(c_FGFDMExec* fdm) c_FGInitialCondition(c_FGInitialCondition* ic) ! bool Load(string rstfile, bool useStoredPath) cdef extern from "math/FGMatrix33.h" namespace "JSBSim": --- 29,44 ---- int GetNumEngines() + cdef extern from "simgear/misc/sg_path.hxx": + cdef cppclass c_SGPath "SGPath": + c_SGPath(const string& path, int* validator) + c_SGPath(const c_SGPath& p) + void set(const string& p) + string utf8Str() + cdef extern from "initialization/FGInitialCondition.h" namespace "JSBSim": cdef cppclass c_FGInitialCondition "JSBSim::FGInitialCondition": c_FGInitialCondition(c_FGFDMExec* fdm) c_FGInitialCondition(c_FGInitialCondition* ic) ! bool Load(const c_SGPath& rstfile, bool useStoredPath) cdef extern from "math/FGMatrix33.h" namespace "JSBSim": *************** *** 61,65 **** cdef extern from "FGFDMExec.h" namespace "JSBSim": cdef cppclass c_FGFDMExec "JSBSim::FGFDMExec": ! c_FGFDMExec(int root, int fdmctr) void Unbind() bool Run() except +convertJSBSimToPyExc --- 68,72 ---- cdef extern from "FGFDMExec.h" namespace "JSBSim": cdef cppclass c_FGFDMExec "JSBSim::FGFDMExec": ! c_FGFDMExec(c_FGPropertyManager* root, unsigned int* fdmctr) void Unbind() bool Run() except +convertJSBSimToPyExc *************** *** 67,89 **** bool LoadModel(string model, bool add_model_to_path) ! bool LoadModel(string aircraft_path, ! string engine_path, ! string systems_path, ! string model, bool add_model_to_path) ! bool LoadScript(string script, double delta_t, string initfile) except +convertJSBSimToPyExc ! bool SetEnginePath(string path) ! bool SetAircraftPath(string path) ! bool SetSystemsPath(string path) ! void SetRootDir(string path) ! string GetEnginePath() ! string GetAircraftPath() ! string GetSystemsPath() ! string GetRootDir() ! string GetFullAircraftPath() double GetPropertyValue(string property) void SetPropertyValue(string property, double value) except +convertJSBSimToPyExc string GetModelName() ! bool SetOutputDirectives(string fname) except + #void ForceOutput(int idx=0) void SetLoggingRate(double rate) --- 74,97 ---- bool LoadModel(string model, bool add_model_to_path) ! bool LoadModel(const c_SGPath aircraft_path, ! const c_SGPath engine_path, ! const c_SGPath systems_path, ! const string model, bool add_model_to_path) ! bool LoadScript(const c_SGPath& script, double delta_t, ! const c_SGPath& initfile) except +convertJSBSimToPyExc ! bool SetEnginePath(const c_SGPath& path) ! bool SetAircraftPath(const c_SGPath& path) ! bool SetSystemsPath(const c_SGPath& path) ! void SetRootDir(const c_SGPath& path) ! const c_SGPath& GetEnginePath() ! const c_SGPath& GetAircraftPath() ! const c_SGPath& GetSystemsPath() ! const c_SGPath& GetRootDir() ! const c_SGPath& GetFullAircraftPath() double GetPropertyValue(string property) void SetPropertyValue(string property, double value) except +convertJSBSimToPyExc string GetModelName() ! bool SetOutputDirectives(const c_SGPath& fname) except + #void ForceOutput(int idx=0) void SetLoggingRate(double rate) Index: jsbsim.pyx =================================================================== RCS file: /cvsroot/jsbsim/JSBSim/tests/jsbsim.pyx,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -r1.12 -r1.13 *** jsbsim.pyx 16 May 2016 17:25:48 -0000 1.12 --- jsbsim.pyx 25 Feb 2017 14:23:20 -0000 1.13 *************** *** 93,104 **** cdef c_FGFDMExec *thisptr # hold a C++ instance which we're wrapping ! def __cinit__(self, **kwargs): # this hides startup message # os.environ["JSBSIM_DEBUG"]=str(0) ! self.thisptr = new c_FGFDMExec(0,0) if self.thisptr is NULL: raise MemoryError() - - def __init__(self, root_dir=None): if root_dir is None: self.find_root_dir() --- 93,102 ---- cdef c_FGFDMExec *thisptr # hold a C++ instance which we're wrapping ! def __cinit__(self, root_dir=None): # this hides startup message # os.environ["JSBSIM_DEBUG"]=str(0) ! self.thisptr = new c_FGFDMExec(NULL, NULL) if self.thisptr is NULL: raise MemoryError() if root_dir is None: self.find_root_dir() *************** *** 222,227 **** @return true if successful """ ! return self.thisptr.LoadModel(model, aircraft_path, ! engine_path, systems_path, add_model_to_path) def load_script(self, script, delta_t=0.0, initfile=""): --- 220,226 ---- @return true if successful """ ! return self.thisptr.LoadModel(c_SGPath(aircraft_path, NULL), ! c_SGPath(engine_path, NULL), c_SGPath(systems_path, NULL), model, ! add_model_to_path) def load_script(self, script, delta_t=0.0, initfile=""): *************** *** 238,242 **** @return true if successfully loads; false otherwise. */ """ ! return self.thisptr.LoadScript(script, delta_t, initfile) def set_engine_path(self, path): --- 237,242 ---- @return true if successfully loads; false otherwise. */ """ ! return self.thisptr.LoadScript(c_SGPath(script, NULL), delta_t, ! c_SGPath(initfile,NULL)) def set_engine_path(self, path): *************** *** 246,250 **** files are kept, for instance "engine" """ ! return self.thisptr.SetEnginePath(path) def set_aircraft_path(self, path): --- 246,250 ---- files are kept, for instance "engine" """ ! return self.thisptr.SetEnginePath(c_SGPath(path, NULL)) def set_aircraft_path(self, path): *************** *** 255,259 **** modeled aircraft such as C172/, x15/, etc. """ ! return self.thisptr.SetAircraftPath(path) def set_systems_path(self, path): --- 255,259 ---- modeled aircraft such as C172/, x15/, etc. """ ! return self.thisptr.SetAircraftPath(c_SGPath(path, NULL)) def set_systems_path(self, path): *************** *** 263,267 **** files are kept, for instance "systems" """ ! return self.thisptr.SetSystemsPath(path) def set_root_dir(self, path): --- 263,267 ---- files are kept, for instance "systems" """ ! return self.thisptr.SetSystemsPath(c_SGPath(path, NULL)) def set_root_dir(self, path): *************** *** 270,274 **** @param path the string containing the root directory. """ ! self.thisptr.SetRootDir(path) # this is a hack to fix a bug in JSBSim --- 270,274 ---- @param path the string containing the root directory. """ ! self.thisptr.SetRootDir(c_SGPath(path, NULL)) # this is a hack to fix a bug in JSBSim *************** *** 281,285 **** Retrieves the engine path """ ! return self.thisptr.GetEnginePath() def get_aircraft_path(self): --- 281,285 ---- Retrieves the engine path """ ! return self.thisptr.GetEnginePath().utf8Str() def get_aircraft_path(self): *************** *** 287,291 **** Retrieves the aircraft path """ ! return self.thisptr.GetAircraftPath() def get_systems_path(self): --- 287,291 ---- Retrieves the aircraft path """ ! return self.thisptr.GetAircraftPath().utf8Str() def get_systems_path(self): *************** *** 293,297 **** Retrieves the systems path """ ! return self.thisptr.GetSystemsPath() def get_full_aircraft_path(self): --- 293,297 ---- Retrieves the systems path """ ! return self.thisptr.GetSystemsPath().utf8Str() def get_full_aircraft_path(self): *************** *** 299,303 **** Retrieves the full aircraft path name """ ! return self.thisptr.GetFullAircraftPath() def get_root_dir(self): --- 299,303 ---- Retrieves the full aircraft path name """ ! return self.thisptr.GetFullAircraftPath().utf8Str() def get_root_dir(self): *************** *** 306,310 **** @return the string representing the root (base) JSBSim directory. """ ! return self.thisptr.GetRootDir() def get_property_value(self, name): --- 306,310 ---- @return the string representing the root (base) JSBSim directory. """ ! return self.thisptr.GetRootDir().utf8Str() def get_property_value(self, name): *************** *** 347,351 **** @param fname the filename of an output directives file. """ ! return self.thisptr.SetOutputDirectives(fname) #def force_output(self, index): --- 347,351 ---- @param fname the filename of an output directives file. """ ! return self.thisptr.SetOutputDirectives(c_SGPath(fname, NULL)) #def force_output(self, index): *************** *** 553,557 **** def load_ic(self, rstfile, useStoredPath): ! return self.thisptr.GetIC().Load(rstfile, useStoredPath) def get_propagate(self): --- 553,557 ---- def load_ic(self, rstfile, useStoredPath): ! return self.thisptr.GetIC().Load(c_SGPath(rstfile, NULL), useStoredPath) def get_propagate(self): |
From: Bertrand <bco...@us...> - 2017-02-25 14:23:23
|
Update of /cvsroot/jsbsim/JSBSim/src/simgear/misc In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv24758/src/simgear/misc Modified Files: CMakeLists.txt Added Files: sg_path.cxx sg_path.hxx strutils.cxx strutils.hxx Log Message: JSBSim now uses SGPath to manage file names. It allows to use absolute paths, to use Unicode file names and to benefit from SimGear maintenance for the corresponding code. --- NEW FILE --- // sg_path.cxx -- routines to abstract out path separator differences // between MacOS and the rest of the world // // Written by Curtis L. Olson, started April 1999. // // Copyright (C) 1999 Curtis L. Olson - http://www.flightgear.org/~curt // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Library General Public // License as published by the Free Software Foundation; either // version 2 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Library General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. // // $Id: sg_path.cxx,v 1.1 2017/02/25 14:23:20 bcoconni Exp $ #include <simgear/compiler.h> #include <simgear/misc/strutils.hxx> #include <stdio.h> #include <sys/stat.h> #include <errno.h> #include <fstream> #include <cstdlib> #include <iostream> #ifdef _WIN32 # include <direct.h> #endif #include "sg_path.hxx" using std::string; /** * define directory path separators */ static const char sgDirPathSep = '/'; static const char sgDirPathSepBad = '\\'; #ifdef _WIN32 const char SGPath::pathListSep = ';'; #else const char SGPath::pathListSep = ':'; #endif // For windows, replace "\" by "/". void SGPath::fix() { string::size_type sz = path.size(); for ( string::size_type i = 0; i < sz; ++i ) { if ( path[i] == sgDirPathSepBad ) { path[i] = sgDirPathSep; } } // drop trailing "/" while ((sz>1)&&(path[sz-1]==sgDirPathSep)) { path.resize(--sz); } } // default constructor SGPath::SGPath(PermissionChecker validator) : path(""), _permission_checker(validator), _cached(false), _rwCached(false), _cacheEnabled(true) { } // create a path based on "path" SGPath::SGPath( const std::string& p, PermissionChecker validator ) : path(p), _permission_checker(validator), _cached(false), _rwCached(false), _cacheEnabled(true) { fix(); } // create a path based on "path" SGPath::SGPath(const std::wstring& p, PermissionChecker validator) : _permission_checker(validator), _cached(false), _rwCached(false), _cacheEnabled(true) { path = simgear::strutils::convertWStringToUtf8(p); fix(); } // create a path based on "path" and a "subpath" SGPath::SGPath( const SGPath& p, const std::string& r, PermissionChecker validator ) : path(p.path), _permission_checker(validator), _cached(false), _rwCached(false), _cacheEnabled(p._cacheEnabled) { append(r); fix(); } SGPath SGPath::fromLocal8Bit(const char *name) { return SGPath(simgear::strutils::convertWindowsLocal8BitToUtf8(name)); } SGPath SGPath::fromUtf8(const std::string& bytes, PermissionChecker p) { return SGPath(bytes, p); } SGPath::SGPath(const SGPath& p) : path(p.path), _permission_checker(p._permission_checker), _cached(p._cached), _rwCached(p._rwCached), _cacheEnabled(p._cacheEnabled), _canRead(p._canRead), _canWrite(p._canWrite), _exists(p._exists), _isDir(p._isDir), _isFile(p._isFile), _modTime(p._modTime), _size(p._size) { } SGPath& SGPath::operator=(const SGPath& p) { path = p.path; _permission_checker = p._permission_checker, _cached = p._cached; _rwCached = p._rwCached; _cacheEnabled = p._cacheEnabled; _canRead = p._canRead; _canWrite = p._canWrite; _exists = p._exists; _isDir = p._isDir; _isFile = p._isFile; _modTime = p._modTime; _size = p._size; return *this; } // destructor SGPath::~SGPath() { } // set path void SGPath::set( const string& p ) { path = p; fix(); _cached = false; _rwCached = false; } //------------------------------------------------------------------------------ void SGPath::setPermissionChecker(PermissionChecker validator) { _permission_checker = validator; _rwCached = false; } //------------------------------------------------------------------------------ SGPath::PermissionChecker SGPath::getPermissionChecker() const { return _permission_checker; } //------------------------------------------------------------------------------ void SGPath::set_cached(bool cached) { _cacheEnabled = cached; _cached = false; } // append another piece to the existing path void SGPath::append( const string& p ) { if ( path.empty() ) { path = p; } else { if ( p[0] != sgDirPathSep ) { path += sgDirPathSep; } path += p; } fix(); _cached = false; _rwCached = false; } //------------------------------------------------------------------------------ SGPath SGPath::operator/( const std::string& p ) const { SGPath ret = *this; ret.append(p); return ret; } #if defined(ENABLE_OLD_PATH_API) //add a new path component to the existing path string void SGPath::add( const string& p ) { append( SGPath::pathListSep+p ); } #endif // concatenate a string to the end of the path without inserting a // path separator void SGPath::concat( const string& p ) { if ( path.empty() ) { path = p; } else { path += p; } fix(); _cached = false; _rwCached = false; } std::string SGPath::local8BitStr() const { return simgear::strutils::convertUtf8ToWindowsLocal8Bit(path); } // Get the file part of the path (everything after the last path sep) string SGPath::file() const { string::size_type index = path.rfind(sgDirPathSep); if (index != string::npos) { return path.substr(index + 1); } else { return path; } } // get the directory part of the path. string SGPath::dir() const { int index = path.rfind(sgDirPathSep); if (index >= 0) { return path.substr(0, index); } else { return ""; } } SGPath SGPath::dirPath() const { return SGPath::fromUtf8(dir()); } // get the base part of the path (everything but the extension.) string SGPath::base() const { string::size_type index = path.rfind("."); string::size_type lastSep = path.rfind(sgDirPathSep); // tolerate dots inside directory names if ((lastSep != string::npos) && (index < lastSep)) { return path; } if (index != string::npos) { return path.substr(0, index); } else { return path; } } string SGPath::file_base() const { string::size_type index = path.rfind(sgDirPathSep); if (index == string::npos) { index = 0; // no separator in the name } else { ++index; // skip past the separator } string::size_type firstDot = path.find(".", index); if (firstDot == string::npos) { return path.substr(index); // no extensions } return path.substr(index, firstDot - index); } // get the extension (everything after the final ".") // but make sure no "/" follows the "." character (otherwise it // is has to be a directory name containing a "."). string SGPath::extension() const { int index = path.rfind("."); if ((index >= 0) && (path.find("/", index) == string::npos)) { return path.substr(index + 1); } else { return ""; } } //------------------------------------------------------------------------------ void SGPath::validate() const { if (_cached && _cacheEnabled) { return; } if (path.empty()) { _exists = false; _canWrite = _canRead = false; return; } #if defined(SG_WINDOWS) struct _stat buf ; bool remove_trailing = false; std::wstring statPath(wstr()); if ((path.length() > 1) && (path.back() == '/')) { statPath.pop_back(); } if (_wstat(statPath.c_str(), &buf ) < 0) { _exists = false; _canRead = false; // check parent directory for write-ability std::wstring parentPath = simgear::strutils::convertUtf8ToWString(dir()); struct _stat parentBuf; if (_wstat(parentPath.c_str(), &parentBuf) >= 0) { _canWrite = parentBuf.st_mode & _S_IWRITE; } else { _canWrite = false; } } else { _exists = true; _isFile = ((S_IFREG & buf.st_mode ) !=0); _isDir = ((S_IFDIR & buf.st_mode ) !=0); _modTime = buf.st_mtime; _size = buf.st_size; _canRead = _S_IREAD & buf.st_mode; _canWrite = _S_IWRITE & buf.st_mode; } #else struct stat buf ; if (stat(path.c_str(), &buf ) < 0) { _exists = false; _canRead = false; // check parent directory for write-ability std::string parentPath = dir(); struct stat parentBuf; if (stat(parentPath.c_str(), &parentBuf) >= 0) { _canWrite = parentBuf.st_mode & S_IWUSR; } else { _canWrite = false; } } else { _exists = true; _isFile = ((S_ISREG(buf.st_mode )) != 0); _isDir = ((S_ISDIR(buf.st_mode )) != 0); _modTime = buf.st_mtime; _size = buf.st_size; _canRead = S_IRUSR & buf.st_mode; _canWrite = S_IWUSR & buf.st_mode; } #endif // ensure permissions are no less restrictive than what the // permissions checker offers if ( _permission_checker ) { Permissions p = _permission_checker(*this); _canRead &= p.read; _canWrite &= p.write; } _cached = true; } //------------------------------------------------------------------------------ void SGPath::checkAccess() const { if( _rwCached && _cacheEnabled ) return; validate(); _rwCached = true; } bool SGPath::exists() const { validate(); return _exists; } //------------------------------------------------------------------------------ bool SGPath::canRead() const { checkAccess(); return _canRead; } //------------------------------------------------------------------------------ bool SGPath::canWrite() const { checkAccess(); return _canWrite; } bool SGPath::isDir() const { validate(); return _exists && _isDir; } bool SGPath::isFile() const { validate(); return _exists && _isFile; } string_list sgPathBranchSplit( const string &dirpath ) { string_list path_elements; string element, path = dirpath; while ( ! path.empty() ) { size_t p = path.find( sgDirPathSep ); if ( p != string::npos ) { element = path.substr( 0, p ); path.erase( 0, p + 1 ); } else { element = path; path = ""; } if ( ! element.empty() ) path_elements.push_back( element ); } return path_elements; } string_list sgPathSplit( const string &search_path ) { string tmp = search_path; string_list result; result.clear(); bool done = false; while ( !done ) { int index = tmp.find(SGPath::pathListSep); if (index >= 0) { result.push_back( tmp.substr(0, index) ); tmp = tmp.substr( index + 1 ); } else { if ( !tmp.empty() ) result.push_back( tmp ); done = true; } } return result; } bool SGPath::isAbsolute() const { if (path.empty()) { return false; } #ifdef _WIN32 // detect '[A-Za-z]:/' if (path.size() > 2) { if (isalpha(path[0]) && (path[1] == ':') && (path[2] == sgDirPathSep)) { return true; } } #endif return (path[0] == sgDirPathSep); } bool SGPath::isNull() const { return path.empty(); } #if defined(ENABLE_OLD_PATH_API) std::string SGPath::str_native() const { #ifdef _WIN32 std::string s = local8BitStr(); std::string::size_type pos; std::string nativeSeparator; nativeSeparator = sgDirPathSepBad; while( (pos=s.find( sgDirPathSep )) != std::string::npos ) { s.replace( pos, 1, nativeSeparator ); } return s; #else return utf8Str(); #endif } #endif time_t SGPath::modTime() const { validate(); return _modTime; } size_t SGPath::sizeInBytes() const { validate(); return _size; } bool SGPath::operator==(const SGPath& other) const { return (path == other.path); } bool SGPath::operator!=(const SGPath& other) const { return (path != other.path); } //------------------------------------------------------------------------------ SGPath SGPath::fromEnv(const char* name, const SGPath& def) { #if defined(SG_WINDOWS) std::wstring wname = simgear::strutils::convertUtf8ToWString(name); const wchar_t* val = _wgetenv(wname.c_str()); if (val && val[0]) return SGPath(val, def._permission_checker); #else const char* val = getenv(name); if( val && val[0] ) return SGPath(val, def._permission_checker); #endif return def; } //------------------------------------------------------------------------------ std::vector<SGPath> SGPath::pathsFromEnv(const char *name) { std::vector<SGPath> r; #if defined(SG_WINDOWS) std::wstring wname = simgear::strutils::convertUtf8ToWString(name); const wchar_t* val = _wgetenv(wname.c_str()); #else const char* val = getenv(name); #endif if (!val) { return r; } #if defined(SG_WINDOWS) return pathsFromUtf8(simgear::strutils::convertWStringToUtf8(val)); #else return pathsFromUtf8(val); #endif } //------------------------------------------------------------------------------ std::vector<SGPath> SGPath::pathsFromUtf8(const std::string& paths) { std::vector<SGPath> r; string_list items = sgPathSplit(paths); string_list_iterator it; for (it = items.begin(); it != items.end(); ++it) { r.push_back(SGPath::fromUtf8(it->c_str())); } return r; } //------------------------------------------------------------------------------ std::vector<SGPath> SGPath::pathsFromLocal8Bit(const std::string& paths) { std::vector<SGPath> r; string_list items = sgPathSplit(paths); string_list_iterator it; for (it = items.begin(); it != items.end(); ++it) { r.push_back(SGPath::fromLocal8Bit(it->c_str())); } return r; } //------------------------------------------------------------------------------ SGPath SGPath::realpath() const { #if defined(SG_WINDOWS) // with absPath NULL, will allocate, and ignore length std::wstring ws = wstr(); wchar_t *buf = _wfullpath( NULL, ws.c_str(), _MAX_PATH ); #else // POSIX char* buf = ::realpath(path.c_str(), NULL); #endif if (!buf) // File does not exist: return the realpath it would have if created now // (needed for fgValidatePath security) { if (path.empty()) { return SGPath(".").realpath(); // current directory } std::string this_dir = dir(); if (isAbsolute() && this_dir.empty()) { // top level this_dir = "/"; } if (file() == "..") { this_dir = SGPath(this_dir).realpath().dir(); if (this_dir.empty()) { // invalid path: .. above root return SGPath(); } return SGPath(this_dir).realpath(); // use native path separator, // and handle 'existing/nonexisting/../symlink' paths } return SGPath(this_dir).realpath() / file(); } #if defined(SG_WINDOWS) SGPath p = SGPath(std::wstring(buf), NULL); #else SGPath p(SGPath::fromLocal8Bit(buf)); #endif free(buf); return p; } //------------------------------------------------------------------------------ std::string SGPath::join(const std::vector<SGPath>& paths, const std::string& joinWith) { std::string r; if (paths.empty()) { return r; } r = paths[0].utf8Str(); for (size_t i=1; i<paths.size(); ++i) { r += joinWith + paths[i].utf8Str(); } return r; } //------------------------------------------------------------------------------ std::wstring SGPath::wstr() const { return simgear::strutils::convertUtf8ToWString(path); } //------------------------------------------------------------------------------ bool SGPath::permissionsAllowsWrite() const { return _permission_checker ? _permission_checker(*this).write : true; } --- NEW FILE --- /** * \file sg_path.hxx * Routines to abstract out path separator differences between MacOS * and the rest of the world. */ // Written by Curtis L. Olson, started April 1999. // // Copyright (C) 1999 Curtis L. Olson - http://www.flightgear.org/~curt // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Library General Public // License as published by the Free Software Foundation; either // version 2 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Library General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. // // $Id: sg_path.hxx,v 1.1 2017/02/25 14:23:20 bcoconni Exp $ #ifndef _SG_PATH_HXX #define _SG_PATH_HXX #include <sys/types.h> #include <simgear/compiler.h> #include <string> #include <ctime> #include <vector> #ifdef _MSC_VER typedef int mode_t; #endif typedef std::vector<std::string> string_list; typedef string_list::iterator string_list_iterator; /** * A class to hide path separator difference across platforms and assist * in managing file system path names. * * Paths can be input in any platform format and will be converted * automatically to the proper format. */ class SGPath { public: // OS-dependent separator used in paths lists static const char pathListSep; struct Permissions { bool read : 1; bool write : 1; }; typedef Permissions (*PermissionChecker)(const SGPath&); /** Default constructor */ explicit SGPath(PermissionChecker validator = NULL); /** Copy contructor */ SGPath(const SGPath& p); SGPath& operator=(const SGPath& p); /** * Construct a path based on the starting path provided. * @param p initial path */ explicit SGPath( const std::string& p, PermissionChecker validator = NULL ); explicit SGPath(const std::wstring& p, PermissionChecker validator = NULL); /** * Construct a path based on the starting path provided and a relative subpath * @param p initial path * @param r relative subpath */ SGPath( const SGPath& p, const std::string& r, PermissionChecker validator = NULL ); /** Destructor */ ~SGPath(); /** * Set path to a new value * @param p new path */ void set( const std::string& p ); SGPath& operator= ( const char* p ) { this->set(p); return *this; } bool operator==(const SGPath& other) const; bool operator!=(const SGPath& other) const; void setPermissionChecker(PermissionChecker validator); PermissionChecker getPermissionChecker() const; /** * Set if file information (exists, type, mod-time) is cached or * retrieved each time it is queried. Caching is enabled by default */ void set_cached(bool cached); /** * Append another piece to the existing path. Inserts a path * separator between the existing component and the new component. * @param p additional path component */ void append( const std::string& p ); /** * Get a copy of this path with another piece appended. * * @param p additional path component */ SGPath operator/( const std::string& p ) const; /** * Append a new piece to the existing path. Inserts a search path * separator to the existing path and the new patch component. * @param p additional path component */ void add( const std::string& p ); /** * Concatenate a string to the end of the path without inserting a * path separator. * @param p additional path suffix */ void concat( const std::string& p ); /** * Returns a path with the absolute pathname that names the same file, whose * resolution does not involve '.', '..', or symbolic links. */ SGPath realpath() const; /** * Get the file part of the path (everything after the last path sep) * @return file string */ std::string file() const; /** * Get the directory part of the path. * @return directory string */ std::string dir() const; /** * Get the base part of the path (everything but the final extension.) * @return the base string */ std::string base() const; /** * Get the base part of the filename (everything before the first '.') * @return the base filename */ std::string file_base() const; /** * Get the extension part of the path (everything after the final ".") * @return the extension string */ std::string extension() const; /** * Get the path string * @return path string */ std::string str() const { return path; } std::string utf8Str() const { return path; } std::string local8BitStr() const; std::wstring wstr() const; /** * Get the path string * @return path in "C" string (ptr to char array) form. */ const char* c_str() const { return path.c_str(); } /** * Get the path string in OS native form */ std::string str_native() const; /** * Determine if file exists by attempting to fopen it. * @return true if file exists, otherwise returns false. */ bool exists() const; /** * Check if reading file is allowed. Readabilty does not imply the existance * of the file. * * @note By default all files will be marked as readable. No check is made * if the operating system allows the given file to be read. Derived * classes may actually implement custom read/write rights. */ bool canRead() const; bool canWrite() const; bool isFile() const; bool isDir() const; /** * Opposite sense to isAbsolute */ bool isRelative() const { return !isAbsolute(); } /** * Is this an absolute path? * I.e starts with a directory seperator, or a single character + colon */ bool isAbsolute() const; /** * check for default constructed path */ bool isNull() const; /** * modification time of the file */ time_t modTime() const; /** * */ size_t sizeInBytes() const; /** * return the path of the parent directory of this path. */ SGPath dirPath() const; /** * Get a path stored in the environment variable with the given \a name. * * @param name Name of the environment variable * @param def Default path to return if the environment variable does not * exist or is empty. */ static SGPath fromEnv(const char* name, const SGPath& def = SGPath()); static SGPath fromUtf8(const std::string& bytes, PermissionChecker p = NULL); static SGPath fromLocal8Bit(const char* name); static std::vector<SGPath> pathsFromEnv(const char* name); static std::vector<SGPath> pathsFromUtf8(const std::string& paths); static std::vector<SGPath> pathsFromLocal8Bit(const std::string& paths); static std::string join(const std::vector<SGPath>& paths, const std::string& joinWith); private: void fix(); void validate() const; void checkAccess() const; bool permissionsAllowsWrite() const; std::string path; PermissionChecker _permission_checker; mutable bool _cached : 1; mutable bool _rwCached : 1; bool _cacheEnabled : 1; ///< cacheing can be disbled if required mutable bool _canRead : 1; mutable bool _canWrite : 1; mutable bool _exists : 1; mutable bool _isDir : 1; mutable bool _isFile : 1; mutable time_t _modTime; mutable size_t _size; }; /// Output to an ostream template<typename char_type, typename traits_type> inline std::basic_ostream<char_type, traits_type>& operator<<(std::basic_ostream<char_type, traits_type>& s, const SGPath& p) { return s << "Path \"" << p.utf8Str() << "\""; } /** * Split a directory string into a list of it's parent directories. */ string_list sgPathBranchSplit( const std::string &path ); /** * Split a directory search path into a vector of individual paths */ string_list sgPathSplit( const std::string &search_path ); #endif // _SG_PATH_HXX --- NEW FILE --- // String utilities. // // Written by Bernie Bright, started 1998 // // Copyright (C) 1998 Bernie Bright - bb...@bi... // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Library General Public // License as published by the Free Software Foundation; either // version 2 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Library General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. // // $Id: strutils.cxx,v 1.1 2017/02/25 14:23:20 bcoconni Exp $ #include <ctype.h> #include <cstring> #include <sstream> #include <algorithm> #include <iostream> #include <string.h> // strerror_r() and strerror_s() #include <errno.h> #if defined(HAVE_CPP11_CODECVT) #include <codecvt> // new in C++11 #endif #include "strutils.hxx" #include <simgear/compiler.h> // SG_WINDOWS #if defined(SG_WINDOWS) #include <windows.h> #endif using std::string; using std::vector; using std::stringstream; using std::cout; using std::endl; namespace simgear { namespace strutils { /* * utf8ToLatin1() convert utf8 to latin, useful for accent character (i.e éâà îè...) */ template <typename Iterator> size_t get_length (Iterator p) { unsigned char c = static_cast<unsigned char> (*p); if (c < 0x80) return 1; else if (!(c & 0x20)) return 2; else if (!(c & 0x10)) return 3; else if (!(c & 0x08)) return 4; else if (!(c & 0x04)) return 5; else return 6; } typedef unsigned int value_type; template <typename Iterator> value_type get_value (Iterator p) { size_t len = get_length (p); if (len == 1) return *p; value_type res = static_cast<unsigned char> ( *p & (0xff >> (len + 1))) << ((len - 1) * 6 ); for (--len; len; --len) { value_type next_byte = static_cast<unsigned char> (*(++p)) - 0x80; if (next_byte & 0xC0) return 0x00ffffff; // invalid UTF-8 res |= next_byte << ((len - 1) * 6); } return res; } string utf8ToLatin1( string& s_utf8 ) { string s_latin1; for (string::iterator p = s_utf8.begin(); p != s_utf8.end(); ++p) { value_type value = get_value<string::iterator&>(p); if (value > 0x10ffff) return s_utf8; // invalid UTF-8: guess that the input was already Latin-1 if (value > 0xff) SG_LOG(SG_IO, SG_WARN, "utf8ToLatin1: wrong char value: " << value); s_latin1 += static_cast<char>(value); } return s_latin1; } /** * */ static vector<string> split_whitespace( const string& str, int maxsplit ) { vector<string> result; string::size_type len = str.length(); string::size_type i = 0; string::size_type j; int countsplit = 0; while (i < len) { while (i < len && isspace((unsigned char)str[i])) { ++i; } j = i; while (i < len && !isspace((unsigned char)str[i])) { ++i; } if (j < i) { result.push_back( str.substr(j, i-j) ); ++countsplit; while (i < len && isspace((unsigned char)str[i])) { ++i; } if (maxsplit && (countsplit >= maxsplit) && i < len) { result.push_back( str.substr( i, len-i ) ); i = len; } } } return result; } /** * */ vector<string> split( const string& str, const char* sep, int maxsplit ) { if (sep == 0) return split_whitespace( str, maxsplit ); vector<string> result; int n = std::strlen( sep ); if (n == 0) { // Error: empty separator string return result; } const char* s = str.c_str(); string::size_type len = str.length(); string::size_type i = 0; string::size_type j = 0; int splitcount = 0; while (i+n <= len) { if (s[i] == sep[0] && (n == 1 || std::memcmp(s+i, sep, n) == 0)) { result.push_back( str.substr(j,i-j) ); i = j = i + n; ++splitcount; if (maxsplit && (splitcount >= maxsplit)) break; } else { ++i; } } result.push_back( str.substr(j,len-j) ); return result; } string_list split_on_any_of(const std::string& str, const char* seperators) { if (seperators == nullptr || (strlen(seperators) == 0)) { throw "illegal/missing seperator string"; } string_list result; size_t pos = 0; size_t startPos = str.find_first_not_of(seperators, 0); for(;;) { pos = str.find_first_of(seperators, startPos); if (pos == string::npos) { result.push_back(str.substr(startPos)); break; } result.push_back(str.substr(startPos, pos - startPos)); startPos = str.find_first_not_of(seperators, pos); if (startPos == string::npos) { break; } } return result; } /** * The lstrip(), rstrip() and strip() functions are implemented * in do_strip() which uses an additional parameter to indicate what * type of strip should occur. */ const int LEFTSTRIP = 0; const int RIGHTSTRIP = 1; const int BOTHSTRIP = 2; static string do_strip( const string& s, int striptype ) { string::size_type len = s.length(); if( len == 0 ) // empty string is trivial return s; string::size_type i = 0; if (striptype != RIGHTSTRIP) { while (i < len && isspace(s[i])) { ++i; } } string::size_type j = len; if (striptype != LEFTSTRIP) { do { --j; } while (j >= 1 && isspace(s[j])); ++j; } if (i == 0 && j == len) { return s; } else { return s.substr( i, j - i ); } } string lstrip( const string& s ) { return do_strip( s, LEFTSTRIP ); } string rstrip( const string& s ) { return do_strip( s, RIGHTSTRIP ); } string strip( const string& s ) { return do_strip( s, BOTHSTRIP ); } void stripTrailingNewlines_inplace(string& s) { // The following (harder to read) implementation is much slower on // my system (g++ 6.2.1 on Debian): 11.4 vs. 3.9 seconds on // 50,000,000 iterations performed on a short CRLF-terminated // string---and it is even a bit slower (12.9 seconds) with // std::next(it) instead of (it+1). // // for (string::reverse_iterator it = s.rbegin(); // it != s.rend() && (*it == '\r' || *it == '\n'); /* empty */) { // it = string::reverse_iterator(s.erase( (it+1).base() )); // } // Simple and fast while (!s.empty() && (s.back() == '\r' || s.back() == '\n')) { s.pop_back(); } } string stripTrailingNewlines(const string& s) { string res = s; stripTrailingNewlines_inplace(res); return res; } string rpad( const string & s, string::size_type length, char c ) { string::size_type l = s.length(); if( l >= length ) return s; string reply = s; return reply.append( length-l, c ); } string lpad( const string & s, size_t length, char c ) { string::size_type l = s.length(); if( l >= length ) return s; string reply = s; return reply.insert( 0, length-l, c ); } bool starts_with( const string & s, const string & substr ) { return s.compare(0, substr.length(), substr) == 0; } bool ends_with( const string & s, const string & substr ) { if( substr.length() > s.length() ) return false; return s.compare( s.length() - substr.length(), substr.length(), substr ) == 0; } string simplify(const string& s) { string result; // reserve size of 's'? string::const_iterator it = s.begin(), end = s.end(); // advance to first non-space char - simplifes logic in main loop, // since we can always prepend a single space when we see a // space -> non-space transition for (; (it != end) && isspace(*it); ++it) { /* nothing */ } bool lastWasSpace = false; for (; it != end; ++it) { char c = *it; if (isspace(c)) { lastWasSpace = true; continue; } if (lastWasSpace) { result.push_back(' '); } lastWasSpace = false; result.push_back(c); } return result; } int to_int(const std::string& s, int base) { stringstream ss(s); switch (base) { case 8: ss >> std::oct; break; case 16: ss >> std::hex; break; default: break; } int result; ss >> result; return result; } int compare_versions(const string& v1, const string& v2, int maxComponents) { vector<string> v1parts(split(v1, ".")); vector<string> v2parts(split(v2, ".")); int lastPart = std::min(v1parts.size(), v2parts.size()); if (maxComponents > 0) { lastPart = std::min(lastPart, maxComponents); } for (int part=0; part < lastPart; ++part) { int part1 = to_int(v1parts[part]); int part2 = to_int(v2parts[part]); if (part1 != part2) { return part1 - part2; } } // of parts iteration // reached end - longer wins return v1parts.size() - v2parts.size(); } string join(const string_list& l, const string& joinWith) { string result; unsigned int count = l.size(); for (unsigned int i=0; i < count; ++i) { result += l[i]; if (i < (count - 1)) { result += joinWith; } } return result; } string uppercase(const string &s) { string rslt(s); for(string::iterator p = rslt.begin(); p != rslt.end(); p++){ *p = toupper(*p); } return rslt; } string lowercase(const string &s) { string rslt(s); for(string::iterator p = rslt.begin(); p != rslt.end(); p++){ *p = tolower(*p); } return rslt; } void lowercase(string &s) { for(string::iterator p = s.begin(); p != s.end(); p++){ *p = tolower(*p); } } #if defined(SG_WINDOWS) static std::wstring convertMultiByteToWString(DWORD encoding, const std::string& a) { std::vector<wchar_t> result; DWORD flags = 0; int requiredWideChars = MultiByteToWideChar(encoding, flags, a.c_str(), a.size(), NULL, 0); result.resize(requiredWideChars); MultiByteToWideChar(encoding, flags, a.c_str(), a.size(), result.data(), result.size()); return std::wstring(result.data(), result.size()); } static std::string convertWStringToMultiByte(DWORD encoding, const std::wstring& w) { std::vector<char> result; DWORD flags = 0; int requiredMBChars = WideCharToMultiByte(encoding, flags, w.data(), w.size(), NULL, 0, NULL, NULL); result.resize(requiredMBChars); WideCharToMultiByte(encoding, flags, w.data(), w.size(), result.data(), result.size(), NULL, NULL); return std::string(result.data(), result.size()); } #endif std::wstring convertUtf8ToWString(const std::string& a) { #ifdef SG_WINDOWS return convertMultiByteToWString(CP_UTF8, a); #elif defined(HAVE_CPP11_CODECVT) std::wstring_convert<std::codecvt_utf8<wchar_t>, wchar_t> ucs2conv; return ucs2conv.from_bytes(a); #else return std::wstring(); #endif } std::string convertWStringToUtf8(const std::wstring& w) { #ifdef SG_WINDOWS return convertWStringToMultiByte(CP_UTF8, w); #elif defined(HAVE_CPP11_CODECVT) std::wstring_convert<std::codecvt_utf8<wchar_t>, wchar_t> ucs2conv; return ucs2conv.to_bytes(w); #else return std::string(); #endif } std::string convertWindowsLocal8BitToUtf8(const std::string& a) { #ifdef SG_WINDOWS return convertWStringToMultiByte(CP_UTF8, convertMultiByteToWString(CP_ACP, a)); #else return a; #endif } std::string convertUtf8ToWindowsLocal8Bit(const std::string& a) { #ifdef SG_WINDOWS return convertWStringToMultiByte(CP_ACP, convertMultiByteToWString(CP_UTF8, a)); #else return a; #endif } //------------------------------------------------------------------------------ static const std::string base64_chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" "abcdefghijklmnopqrstuvwxyz" "0123456789+/"; static const unsigned char base64_decode_map[128] = { 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 62, 127, 127, 127, 63, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 127, 127, 127, 64, 127, 127, 127, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 127, 127, 127, 127, 127, 127, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 127, 127, 127, 127, 127 }; static inline bool is_base64(unsigned char c) { return (isalnum(c) || (c == '+') || (c == '/')); } static bool is_whitespace(unsigned char c) { return ((c == ' ') || (c == '\r') || (c == '\n')); } void decodeBase64(const std::string& encoded_string, std::vector<unsigned char>& ret) { int in_len = encoded_string.size(); int i = 0; int j = 0; int in_ = 0; unsigned char char_array_4[4], char_array_3[3]; while (in_len-- && ( encoded_string[in_] != '=')) { if (is_whitespace( encoded_string[in_])) { in_++; continue; } if (!is_base64(encoded_string[in_])) { break; } char_array_4[i++] = encoded_string[in_]; in_++; if (i ==4) { for (i = 0; i <4; i++) char_array_4[i] = base64_decode_map[char_array_4[i]]; char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4); char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2); char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3]; for (i = 0; (i < 3); i++) ret.push_back(char_array_3[i]); i = 0; } } if (i) { for (j = i; j <4; j++) char_array_4[j] = 0; for (j = 0; j <4; j++) char_array_4[j] = base64_decode_map[char_array_4[j]]; char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4); char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2); char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3]; for (j = 0; (j < i - 1); j++) ret.push_back(char_array_3[j]); } } //------------------------------------------------------------------------------ const char hexChar[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'}; std::string encodeHex(const std::string& bytes) { return encodeHex( reinterpret_cast<const unsigned char*>(bytes.c_str()), bytes.size() ); } std::string encodeHex(const unsigned char* rawBytes, unsigned int length) { std::string hex(length * 2, '\0'); for (unsigned int i=0; i<length;++i) { unsigned char c = *rawBytes++; hex[i * 2] = hexChar[c >> 4]; hex[i * 2 + 1] = hexChar[c & 0x0f]; } return hex; } //------------------------------------------------------------------------------ std::string unescape(const char* s) { std::string r; while( *s ) { if( *s != '\\' ) { r += *s++; continue; } if( !*++s ) break; if (*s == '\\') { r += '\\'; } else if (*s == 'n') { r += '\n'; } else if (*s == 'r') { r += '\r'; } else if (*s == 't') { r += '\t'; } else if (*s == 'v') { r += '\v'; } else if (*s == 'f') { r += '\f'; } else if (*s == 'a') { r += '\a'; } else if (*s == 'b') { r += '\b'; } else if (*s == 'x') { if (!*++s) break; int v = 0; for (int i = 0; i < 2 && isxdigit(*s); i++, s++) v = v * 16 + (isdigit(*s) ? *s - '0' : 10 + tolower(*s) - 'a'); r += v; continue; } else if (*s >= '0' && *s <= '7') { int v = *s++ - '0'; for (int i = 0; i < 3 && *s >= '0' && *s <= '7'; i++, s++) v = v * 8 + *s - '0'; r += v; continue; } else { r += *s; } s++; } return r; } string sanitizePrintfFormat(const string& input) { string::size_type i = input.find("%n"); if (i != string::npos) { SG_LOG(SG_IO, SG_WARN, "sanitizePrintfFormat: bad format string:" << input); return string(); } return input; } std::string error_string(int errnum) { char buf[512]; // somewhat arbitrary... // This could be simplified with C11 (annex K, optional...), which offers: // // errno_t strerror_s( char *buf, rsize_t bufsz, errno_t errnum ); // size_t strerrorlen_s( errno_t errnum ); #if defined(_WIN32) errno_t retcode; // Always makes the string in 'buf' null-terminated retcode = strerror_s(buf, sizeof(buf), errnum); #elif defined(_GNU_SOURCE) return std::string(strerror_r(errnum, buf, sizeof(buf))); #elif (_POSIX_C_SOURCE >= 200112L) || defined(SG_MAC) || defined(__FreeBSD__) int retcode; // POSIX.1-2001 and POSIX.1-2008 retcode = strerror_r(errnum, buf, sizeof(buf)); #else #error "Could not find a thread-safe alternative to strerror()." #endif #if !defined(_GNU_SOURCE) if (retcode) { std::string msg = "unable to get error message for a given error number"; // C++11 would make this shorter with std::to_string() std::ostringstream ostr; ostr << errnum; #if !defined(_WIN32) if (retcode == ERANGE) { // more specific error message in this case msg = std::string("buffer too small to hold the error message for " "the specified error number"); } #endif throw msg + ostr.str(); } return std::string(buf); #endif // !defined(_GNU_SOURCE) } } // end namespace strutils } // end namespace simgear --- NEW FILE --- /** * \file strutils.hxx * String utilities. */ // Written by Bernie Bright, started 1998 // // Copyright (C) 1998 Bernie Bright - bb...@bi... // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Library General Public // License as published by the Free Software Foundation; either // version 2 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Library General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. // // $Id: strutils.hxx,v 1.1 2017/02/25 14:23:20 bcoconni Exp $ #ifndef STRUTILS_H #define STRUTILS_H #include <simgear/compiler.h> #include <string> #include <vector> #include <cstdlib> typedef std::vector < std::string > string_list; namespace simgear { namespace strutils { /** * utf8ToLatin1() convert utf8 to latin, useful for accent character (i.e éâà îè...) */ std::string utf8ToLatin1( std::string & s_utf8 ); // /** // * atof() wrapper for "string" type // */ // inline double // atof( const string& str ) // { // return ::atof( str.c_str() ); // } // /** // * atoi() wrapper for "string" type // */ // inline int // atoi( const string& str ) // { // return ::atoi( str.c_str() ); // } /** * Strip leading and/or trailing whitespace from s. * @param s String to strip. * @return The stripped string. */ std::string lstrip( const std::string& s ); std::string rstrip( const std::string& s ); std::string strip( const std::string& s ); /** * Return a new string with any trailing \r and \n characters removed. * Typically useful to clean a CR-terminated line obtained from * std::getline() which, upon reading CRLF (\r\n), discards the Line * Feed character (\n) but leaves the Carriage Return (\r) in the * string. * @param s Input string * @return The cleaned string */ std::string stripTrailingNewlines(const std::string& s); /** * Strip any trailing \r and \n characters from a string. * Should have slightly less overhead than stripTrailingNewlines(). * @param s Input string (modified in-place) */ void stripTrailingNewlines_inplace(std::string& s); /** * Right-padding of a string to a given length * @param s String to pad * @param length The total length of the resulting string * @param c The character to pad with * @return The padded string */ std::string rpad( const std::string & s, size_t length, char c ); /** * Left-padding of a string to a given length * @param s String to pad * @param length The total length of the resulting string * @param c The character to pad with * @return The padded string */ std::string lpad( const std::string & s, size_t length, char c ); /** * Split a string into a words using 'sep' as the delimiter string. * Produces a result similar to the perl and python functions of the * same name. * * @param s The string to split into words, * @param sep Word delimiters. If not specified then any whitespace is a separator, * @param maxsplit If given, splits at no more than maxsplit places, * resulting in at most maxsplit+1 words. * @return Array of words. */ string_list split( const std::string& s, const char* sep = 0, int maxsplit = 0 ); /** * split a string on any of several characters. Commonly used to deal * with strings containing whitespace, newlines. To parse CSS style * string, use with '\n\t ,' as the seperator list. * * Note consecutive seperators will not produce empty entries in the * the result, i.e splitting 'a,b,,c,d' with a ',' will produce a result * with four entries, not five. */ string_list split_on_any_of(const std::string&, const char* seperators); /** * create a single string by joining the elements of a list with * another string. */ std::string join(const string_list& l, const std::string& joinWith = ""); /** * Test if a string starts with a string * * @param s The string to be tested * @param substr The string to test * @return True, if s starts with substr, False otherwise */ bool starts_with( const std::string & s, const std::string & substr ); /** * Test if a string ends with a string * * @param s The string to be tested * @param substr The string to test * @return True, if s ends with substr, False otherwise */ bool ends_with( const std::string & s, const std::string & substr ); /** * Strip all leading/trailing whitespace, and transform all interal * whitespace into a single ' ' character - i.e newlines/carriage returns/ * tabs/multiple spaces will be condensed. */ std::string simplify(const std::string& s); /** * convert a string representing a decimal number, to an int */ int to_int(const std::string& s, int base = 10); /** * Like strcmp(), but for dotted versions strings NN.NN.NN * any number of terms are supported. * @return 0 if versions match, -ve number if v1 is lower, +ve if v1 * is greater * @param maxComponents is the maximum number of components to look at. * This can be used to ignore (say) the patch level by setting it to 2 */ int compare_versions(const std::string& v1, const std::string& v2, int maxComponents = 0); /** * Convert a string to upper case. * @return upper case string */ std::string uppercase(const std::string &s); /** * Convert a string to lower case. * @return lower case string */ std::string lowercase(const std::string &s); /** * Convert a string to lower case in place */ void lowercase(std::string &s); /** * convert a string in the local Windows 8-bit encoding to UTF-8 * (no-op on other platforms) */ std::string convertWindowsLocal8BitToUtf8(const std::string& a); /** * */ std::string convertUtf8ToWindowsLocal8Bit(const std::string& a); std::wstring convertUtf8ToWString(const std::string& a); std::string convertWStringToUtf8(const std::wstring& w); /** * convert base-64 encoded data to raw bytes (possibly with embedded * NULs). Throws an exception if input data is not base64, or is * malformed */ void decodeBase64(const std::string& a, std::vector<unsigned char>& output); /** * convert bytes to hexadecimal equivalent */ std::string encodeHex(const std::string& bytes); std::string encodeHex(const unsigned char* rawBytes, unsigned int length); /** * Unescape string. * * @param str String possibly containing escaped characters. * @return string with escaped characters replaced by single character * values. */ std::string unescape(const char* str); inline std::string unescape(const std::string& str) { return unescape(str.c_str()); } /** * Check a printf-style format string for dangerous (buffer-overflowing, * memory re-writing) format tokens. If a problematic token is * found, logs an error (SG_WARN) and returns an empty format string. */ std::string sanitizePrintfFormat(const std::string& input); /** * Get the message corresponding to a given value of errno. * * Similar to strerror(), except it should be thread-safe and returns an * std::string. */ std::string error_string(int errnum); } // end namespace strutils } // end namespace simgear #endif // STRUTILS_H Index: CMakeLists.txt =================================================================== RCS file: /cvsroot/jsbsim/JSBSim/src/simgear/misc/CMakeLists.txt,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** CMakeLists.txt 22 Jan 2014 11:54:52 -0000 1.2 --- CMakeLists.txt 25 Feb 2017 14:23:19 -0000 1.3 *************** *** 1,4 **** ! set(JSBSIM_SIMGEAR_MISC_HDR stdint.hxx) ! install(FILES ${JSBSIM_SIMGEAR_MISC_HDR} DESTINATION include/JSBSim/simgear/misc) --- 1,8 ---- ! set(SOURCES sg_path.cxx strutils.cxx) ! set(HEADERS stdint.hxx sg_path.hxx strutils.hxx) + add_full_path_name(MISC_SRC "${SOURCES}") + add_full_path_name(MISC_HDR "${HEADERS}") + + install(FILES ${HEADERS} DESTINATION include/JSBSim/simgear/misc) |
From: Bertrand <bco...@us...> - 2017-02-25 14:23:23
|
Update of /cvsroot/jsbsim/JSBSim/src/models In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv24758/src/models Modified Files: FGFCS.cpp FGFCS.h FGInput.cpp FGInput.h FGModel.cpp FGModel.h FGOutput.cpp FGOutput.h FGPropagate.cpp FGPropulsion.cpp FGPropulsion.h Log Message: JSBSim now uses SGPath to manage file names. It allows to use absolute paths, to use Unicode file names and to benefit from SimGear maintenance for the corresponding code. Index: FGFCS.cpp =================================================================== RCS file: /cvsroot/jsbsim/JSBSim/src/models/FGFCS.cpp,v retrieving revision 1.97 retrieving revision 1.98 diff -C2 -r1.97 -r1.98 *** FGFCS.cpp 18 May 2016 08:06:57 -0000 1.97 --- FGFCS.cpp 25 Feb 2017 14:23:18 -0000 1.98 *************** *** 603,616 **** //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! string FGFCS::FindFullPathName(const string& sysfilename) const { ! string name = FGModel::FindFullPathName(sysfilename); ! if (systype != stSystem || !name.empty()) return name; ! name = CheckFullPathName(FDMExec->GetFullAircraftPath() + "/Systems", sysfilename); ! if (!name.empty()) return name; ! ! return CheckFullPathName(FDMExec->GetSystemsPath(), sysfilename); } --- 603,615 ---- //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! SGPath FGFCS::FindFullPathName(const SGPath& path) const { ! SGPath name = FGModel::FindFullPathName(path); ! if (systype != stSystem || !name.isNull()) return name; ! name = CheckPathName(FDMExec->GetFullAircraftPath()/string("Systems"), path); ! if (!name.isNu |
From: Bertrand <bco...@us...> - 2017-02-25 14:23:23
|
Update of /cvsroot/jsbsim/JSBSim/src/simgear/io/iostreams In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv24758/src/simgear/io/iostreams Added Files: CMakeLists.txt sgstream.cxx sgstream.hxx Log Message: JSBSim now uses SGPath to manage file names. It allows to use absolute paths, to use Unicode file names and to benefit from SimGear maintenance for the corresponding code. --- NEW FILE --- set(SOURCES sgstream.cxx) set(HEADERS sgstream.hxx) add_full_path_name(IOSTREAMS_SRC "${SOURCES}") add_full_path_name(IOSTREAMS_HDR "${HEADERS}") install(FILES ${HEADERS} DESTINATION include/JSBSim/simgear/io/iostreams) --- NEW FILE --- // zlib input file stream wrapper. // // Written by Bernie Bright, 1998 // // Copyright (C) 1998 Bernie Bright - bb...@c0... // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Library General Public // License as published by the Free Software Foundation; either // version 2 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Library General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. // // $Id: sgstream.cxx,v 1.1 2017/02/25 14:23:19 bcoconni Exp $ #include <simgear/compiler.h> #include <string> #include "sgstream.hxx" #include <simgear/misc/sg_path.hxx> using std::istream; using std::ostream; sg_ifstream::sg_ifstream(const SGPath& path, std::ios::openmode io_mode) { #if defined(SG_WINDOWS) std::wstring ps = path.wstr(); #else std::string ps = path.local8BitStr(); #endif std::ifstream::open(ps.c_str(), io_mode); } void sg_ifstream::open( const SGPath& name, std::ios::openmode io_mode ) { #if defined(SG_WINDOWS) std::wstring ps = name.wstr(); #else std::string ps = name.local8BitStr(); #endif std::ifstream::open(ps.c_str(), io_mode); } sg_ofstream::sg_ofstream(const SGPath& path, std::ios::openmode io_mode) { #if defined(SG_WINDOWS) std::wstring ps = path.wstr(); #else std::string ps = path.local8BitStr(); #endif std::ofstream::open(ps.c_str(), io_mode); } void sg_ofstream::open( const SGPath& name, std::ios::openmode io_mode ) { #if defined(SG_WINDOWS) std::wstring ps = name.wstr(); #else std::string ps = name.local8BitStr(); #endif std::ofstream::open(ps.c_str(), io_mode); } --- NEW FILE --- /** * \file sgstream.hxx * input file stream wrapper. */ // Written by Bernie Bright, 1998 // // Copyright (C) 1998 Bernie Bright - bb...@c0... // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Library General Public // License as published by the Free Software Foundation; either // version 2 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Library General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. // // $Id: sgstream.hxx,v 1.1 2017/02/25 14:23:19 bcoconni Exp $ #ifndef _SGSTREAM_HXX #define _SGSTREAM_HXX #ifndef __cplusplus # error This library requires C++ #endif #include <simgear/compiler.h> #include <iostream> #include <fstream> #include <string> class SGPath; class sg_ifstream : public std::ifstream { public: sg_ifstream() {} sg_ifstream(const SGPath& path, std::ios::openmode io_mode = std::ios::in | std::ios::binary); void open( const SGPath& name, std::ios::openmode io_mode = std::ios::in|std::ios::binary ); }; class sg_ofstream : public std::ofstream { public: sg_ofstream() { } sg_ofstream(const SGPath& path, std::ios::openmode io_mode = std::ios::out | std::ios::binary); void open( const SGPath& name, std::ios::openmode io_mode = std::ios::out|std::ios::binary ); }; #endif /* _SGSTREAM_HXX */ |
From: Bertrand <bco...@us...> - 2017-02-25 14:23:23
|
Update of /cvsroot/jsbsim/JSBSim/src/input_output In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv24758/src/input_output Modified Files: FGModelLoader.cpp FGModelLoader.h FGOutputFile.cpp FGOutputFile.h FGOutputTextFile.cpp FGOutputTextFile.h FGScript.cpp FGScript.h FGXMLFileRead.h Log Message: JSBSim now uses SGPath to manage file names. It allows to use absolute paths, to use Unicode file names and to benefit from SimGear maintenance for the corresponding code. Index: FGModelLoader.cpp =================================================================== RCS file: /cvsroot/jsbsim/JSBSim/src/input_output/FGModelLoader.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** FGModelLoader.cpp 12 Jul 2015 12:41:55 -0000 1.3 --- FGModelLoader.cpp 25 Feb 2017 14:23:18 -0000 1.4 *************** *** 61,86 **** if (!fname.empty()) { FGXMLFileRead XMLFileRead; ! string file; ! try { ! file = model->FindFullPathName(fname); ! if (file.empty()) throw string("File does not exist."); ! } ! catch(string& e) { ! cerr << endl << el->ReadFrom() ! << "Could not open file: " << fname << endl << e << endl; ! return NULL; ! } ! if (CachedFiles.find(file) != CachedFiles.end()) ! document = CachedFiles[file]; else { ! document = XMLFileRead.LoadXMLDocument(file); if (document == 0L) { cerr << endl << el->ReadFrom() ! << "Could not open file: " << file << endl; return NULL; } ! CachedFiles[file] = document; } --- 61,79 ---- if (!fname.empty()) { FGXMLFileRead XMLFileRead; ! SGPath path(SGPath::fromLocal8Bit(fname.c_str())); ! if (path.isRelative()) ! path = model->FindFullPathName(path); ! if (CachedFiles.find(path.utf8Str()) != CachedFiles.end()) ! document = CachedFiles[path.utf8Str()]; else { ! document = XMLFileRead.LoadXMLDocument(path); if (document == 0L) { cerr << endl << el->ReadFrom() ! << "Could not open file: " << path << endl; return NULL; } ! CachedFiles[path.utf8Str()] = document; } *************** *** 94,111 **** } ! //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! ! string CheckFullPathName(const string& path, const string& fname) ! { ! string name = path + "/" + fname; ! ! if (name.length() <=4 || name.substr(name.length()-4, 4) != ".xml") ! name.append(".xml"); ! ifstream file(name.c_str()); ! if (!file.is_open()) ! return string(); ! return name; } } --- 87,97 ---- } ! SGPath CheckPathName(const SGPath& path, const SGPath& filename) { ! SGPath fullName = path/filename.utf8Str(); ! if (fullName.extension().empty()) ! fullName.concat(".xml"); ! return fullName.exists() ? fullName : SGPath(); } } Index: FGModelLoader.h =================================================================== RCS file: /cvsroot/jsbsim/JSBSim/src/input_output/FGModelLoader.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** FGModelLoader.h 9 Jun 2014 11:52:06 -0000 1.1 --- FGModelLoader.h 25 Feb 2017 14:23:18 -0000 1.2 *************** *** 42,45 **** --- 42,46 ---- #include "FGXMLElement.h" + #include "simgear/misc/sg_path.hxx" /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% *************** *** 76,80 **** }; ! std::string CheckFullPathName(const std::string& path, const std::string& fname); } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% --- 77,81 ---- }; ! SGPath CheckPathN |
From: Bertrand <bco...@us...> - 2017-02-25 14:23:22
|
Update of /cvsroot/jsbsim/JSBSim/src/initialization In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv24758/src/initialization Modified Files: FGInitialCondition.cpp FGInitialCondition.h Log Message: JSBSim now uses SGPath to manage file names. It allows to use absolute paths, to use Unicode file names and to benefit from SimGear maintenance for the corresponding code. Index: FGInitialCondition.cpp =================================================================== RCS file: /cvsroot/jsbsim/JSBSim/src/initialization/FGInitialCondition.cpp,v retrieving revision 1.113 retrieving revision 1.114 diff -C2 -r1.113 -r1.114 *** FGInitialCondition.cpp 11 Sep 2016 11:31:00 -0000 1.113 --- FGInitialCondition.cpp 25 Feb 2017 14:23:18 -0000 1.114 *************** *** 881,889 **** //******************* |
From: Bertrand <bco...@us...> - 2017-02-25 14:23:22
|
Update of /cvsroot/jsbsim/JSBSim/src In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv24758/src Modified Files: CMakeLists.txt FGFDMExec.cpp FGFDMExec.h JSBSim.cpp Log Message: JSBSim now uses SGPath to manage file names. It allows to use absolute paths, to use Unicode file names and to benefit from SimGear maintenance for the corresponding code. Index: CMakeLists.txt =================================================================== RCS file: /cvsroot/jsbsim/JSBSim/src/CMakeLists.txt,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -r1.11 -r1.12 *** CMakeLists.txt 22 Mar 2015 12:24:48 -0000 1.11 --- CMakeLists.txt 25 Feb 2017 14:23:18 -0000 1.12 *************** *** 6,10 **** if(MSVC) ! add_definitions("/D _USE_MATH_DEFINES") endif() --- 6,10 ---- if(MSVC) ! add_definitions("/D _USE_MATH_DEFINES /D NOMINMAX") endif() *************** *** 82,85 **** --- 82,87 ---- ${JSBSIM_SIMGEAR_XML_HDR} ${JSBSIM_SIMGEAR_XML_SRC} ${JSBSIM_SIMGEAR_MAGVAR_HDR} ${JSBSIM_SIMGEAR_MAGVAR_SRC} + ${JSBSIM_SIMGEAR_MISC_HDR} ${JSBSIM_SIMGEAR_MISC_SRC} + ${JSBSIM_SIMGEAR_IOSTREAMS_HDR} ${JSBSIM_SIMGEAR_IOSTREAMS_SRC} ) Index: FGFDMExec.cpp =================================================================== RCS file: /cvsroot/jsbsim/JSBSim/src/FGFDMExec.cpp,v retrieving revision 1.192 retrieving revision 1.193 diff -C2 -r1.192 -r1.193 *** FGFDMExec.cpp 22 Jan 2017 09:46:48 -0000 1.192 --- FGFDMExec.cpp 25 Feb 2017 14:23:18 -0000 1.193 *************** *** 651,660 **** //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! bool FGFDMExec::LoadScript(const string& script, double deltaT, const string& initfile) { bool result; Script = new FGScript(this); ! result = Script->LoadScript(RootDir + script, deltaT, initfile); return result; --- 651,661 ---- //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! bool FGFDMExec::LoadScript(const SGPath& script, double deltaT, ! const SGPath& initfile) { bool result; Script = new FGScript(this); ! result = Script->LoadScript(GetFullPath(script), deltaT, initfile); return result; *************** *** 663,672 **** //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! bool FGFDMExec::LoadModel(const string& AircraftPath, const string& EnginePath, const string& SystemsPath, ! const string& model, bool addModelToPath) ! { ! FGFDMExec::AircraftPath = RootDir + AircraftPath; ! FGFDMExec::EnginePath = RootDir + EnginePath; ! FGFDMExec::SystemsPath = RootDir + SystemsPath; return LoadModel(model, addModelToPath); --- 664,674 ---- //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! bool FGFDMExec::LoadModel(const SGPath& AircraftPath, const SGPath& EnginePath, ! const SGPath& SystemsPath, const string& model, ! bool addModelToPath) ! { ! FGFDMExec::AircraftPath = GetFullPath(AircraftPath); ! FGFDMExec::EnginePath = GetFullPath(EnginePath); ! FGFDMExec::SystemsPath = GetFullPath(SystemsPath); return LoadModel(model, addModelToPath); *************** *** 677,686 **** bool FGFDMExec::LoadModel(const string& model, bool addModelToPath) { ! string aircraftCfgFileName; 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; --- 679,688 ---- bool FGFDMExec::LoadModel(const string& model, bool addModelToPath) { ! SGPath aircraftCfgFil |
From: Bertrand <bco...@us...> - 2017-02-25 14:23:22
|
Update of /cvsroot/jsbsim/JSBSim/src/simgear In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv24758/src/simgear Modified Files: CMakeLists.txt compiler.h Log Message: JSBSim now uses SGPath to manage file names. It allows to use absolute paths, to use Unicode file names and to benefit from SimGear maintenance for the corresponding code. Index: CMakeLists.txt =================================================================== RCS file: /cvsroot/jsbsim/JSBSim/src/simgear/CMakeLists.txt,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** CMakeLists.txt 16 Feb 2014 14:07:52 -0000 1.3 --- CMakeLists.txt 25 Feb 2017 14:23:19 -0000 1.4 *************** *** 4,13 **** --- 4,16 ---- add_subdirectory(misc) add_subdirectory(xml) + add_subdirectory(io/iostreams) set(JSBSIM_SIMGEAR_HDR compiler.h) propagate_source_files(SIMGEAR MAGVAR) + propagate_source_files(SIMGEAR MISC) propagate_source_files(SIMGEAR PROPS) propagate_source_files(SIMGEAR XML) + propagate_source_files(SIMGEAR IOSTREAMS) install(FILES ${JSBSIM_SIMGEAR_HDR} DESTINATION include/JSBSim/simgear) Index: compiler.h =================================================================== RCS file: /cvsroot/jsbsim/JSBSim/src/simgear/compiler.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** compiler.h 18 May 2007 03:17:41 -0000 1.3 --- compiler.h 25 Feb 2017 14:23:19 -0000 1.4 *************** *** 28,29 **** --- 28,65 ---- #define SG_LOG(type, level, message) (cout <<message << endl) #define SG_USING_STD(X) using std::X + + #ifdef __APPLE__ + # define SG_MAC + # define SG_UNIX + #endif + + #if defined (__FreeBSD__) + # define SG_UNIX + #endif + + #if defined (__CYGWIN__) + # define SG_WINDOWS + # define SG_UNIX + # include <ieeefp.h> // isnan + #endif + + // includes both MSVC and mingw compilers + #if defined(_WIN32) || defined(__WIN32__) + # define SG_WINDOWS + #endif + + #if defined(__linux__) || defined(_AIX) || defined ( sgi ) + # define SG_UNIX + #endif + + #if defined( __GNUC__ ) + # define DEPRECATED __attribute__ ((deprecated)) + #else + # define DEPRECATED + #endif + + #if defined(__clang__) + # define SG_NO_RETURN [[noreturn]] + #else + # define SG_NO_RETURN + #endif |