From 3006bd34539f3899ef024ba344477f3724b22155 Mon Sep 17 00:00:00 2001 From: Bertrand Coconnier Date: Sun, 21 Jun 2026 17:04:46 +0200 Subject: [PATCH 1/3] Add an option `--outputpath` to the scripts. --- python/JSBSim.py | 21 ++++++++++++++------- src/JSBSim.cpp | 18 ++++++++++++++---- 2 files changed, 28 insertions(+), 11 deletions(-) diff --git a/python/JSBSim.py b/python/JSBSim.py index d7a3b101a1..cdabb3095f 100644 --- a/python/JSBSim.py +++ b/python/JSBSim.py @@ -27,23 +27,25 @@ import time import xml.etree.ElementTree as et -import _jsbsim +import jsbsim def main(): parser = argparse.ArgumentParser(formatter_class=argparse.RawTextHelpFormatter) parser.add_argument("input", nargs='?', help="script file name") parser.add_argument("--version", action="version", - version="%(prog)s {}".format(_jsbsim.FGJSBBase().get_version())) - parser.add_argument("--outputlogfile", action="append", metavar="", - help="sets (overrides) the name of a data output file") - parser.add_argument("--logdirectivefile", action="append", metavar="", - help="specifies the name of a data logging directives file") + version="%(prog)s {}".format(jsbsim.FGJSBBase().get_version())) parser.add_argument("--root", default='.', metavar="", help="specifies the JSBSim root directory (where aircraft/, engine/, etc. reside)") parser.add_argument("--aircraft", metavar="", help="specifies the name of the aircraft to be modeled") parser.add_argument("--script", metavar="", help="specifies a script to run") + parser.add_argument("--outputlogfile", action="append", metavar="", + help="sets (overrides) the name of a data output file") + parser.add_argument("--logdirectivefile", action="append", metavar="", + help="specifies the name of a data logging directives file") + parser.add_argument("--outputpath", metavar="", + help="specifies the directory where the output files will be written.") parser.add_argument("--realtime", default=False, action="store_true", help="specifies to run in real world time") parser.add_argument("--nice", default=False, action="store_true", @@ -113,11 +115,16 @@ def CheckXMLFile(f): else: args.aircraft = args.input - fdm = _jsbsim.FGFDMExec(args.root, None) + fdm = jsbsim.FGFDMExec(args.root, None) if args.nohighlight: fdm.disable_highlighting() + if args.outputpath: + fdm.set_output_path(args.outputpath) + else: + fdm.set_output_path(".") + if args.simulation_rate: if args.simulation_rate < 1.0: fdm.set_dt(args.simulation_rate) diff --git a/src/JSBSim.cpp b/src/JSBSim.cpp index bc563feec1..ea2eec9c20 100644 --- a/src/JSBSim.cpp +++ b/src/JSBSim.cpp @@ -86,6 +86,7 @@ GLOBAL DATA %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ SGPath RootDir; +SGPath OutputPath; SGPath ScriptName; string AircraftName; SGPath ResetName; @@ -364,6 +365,7 @@ int real_main(int argc, char* argv[]) AircraftName = ""; ResetName = ""; PlanetName = ""; + OutputPath = SGPath("."); LogOutputName.clear(); LogDirectiveName.clear(); bool result = false, success; @@ -394,7 +396,7 @@ int real_main(int argc, char* argv[]) FDMExec->SetAircraftPath(SGPath("aircraft")); FDMExec->SetEnginePath(SGPath("engine")); FDMExec->SetSystemsPath(SGPath("systems")); - FDMExec->SetOutputPath(SGPath(".")); + FDMExec->SetOutputPath(OutputPath); FDMExec->GetPropertyManager()->Tie("simulation/frame_start_time", &actual_elapsed_time); FDMExec->GetPropertyManager()->Tie("simulation/cycle_duration", &cycle_duration); @@ -712,6 +714,13 @@ bool options(int count, char **arg) gripe; exit(1); } + } else if (keyword == "--outputpath") { + if (n != string::npos) { + OutputPath = SGPath::fromLocal8Bit(value.c_str()); + } else { + gripe; + exit(1); + } } else if (keyword == "--aircraft") { if (n != string::npos) { AircraftName = value; @@ -842,12 +851,13 @@ void PrintHelp(void) cout << " options:" << endl; cout << " --help returns this message" << endl; cout << " --version returns the version number" << endl; - cout << " --outputlogfile= sets (overrides) the name of a data output file" << endl; - cout << " --logdirectivefile= specifies the name of a data logging directives file" << endl; - cout << " (can appear multiple times)" << endl; cout << " --root= specifies the JSBSim root directory (where aircraft/, engine/, etc. reside)" << endl; cout << " --aircraft= specifies the name of the aircraft to be modeled" << endl; cout << " --script= specifies a script to run" << endl; + cout << " --outputlogfile= sets (overrides) the name of a data output file" << endl; + cout << " --logdirectivefile= specifies the name of a data logging directives file" << endl; + cout << " (can appear multiple times)" << endl; + cout << " --outputpath= specifies the directory where the output files will be written." << endl; cout << " --realtime specifies to run in actual real world time" << endl; cout << " --nice specifies to run at lower CPU usage" << endl; cout << " --nohighlight specifies that console output should be pure text only (no color)" << endl; From ee2f1699116bcee6bae2225d543190447a199fab Mon Sep 17 00:00:00 2001 From: Bertrand Coconnier Date: Sun, 21 Jun 2026 17:31:59 +0200 Subject: [PATCH 2/3] Fix the order of the arguments in the help message. --- python/JSBSim.py | 10 +++++----- src/JSBSim.cpp | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/python/JSBSim.py b/python/JSBSim.py index cdabb3095f..25fcc0bdbf 100644 --- a/python/JSBSim.py +++ b/python/JSBSim.py @@ -33,13 +33,17 @@ def main(): parser = argparse.ArgumentParser(formatter_class=argparse.RawTextHelpFormatter) parser.add_argument("input", nargs='?', help="script file name") parser.add_argument("--version", action="version", - version="%(prog)s {}".format(jsbsim.FGJSBBase().get_version())) + version=f"{jsbsim.FGJSBBase().get_version()}") parser.add_argument("--root", default='.', metavar="", help="specifies the JSBSim root directory (where aircraft/, engine/, etc. reside)") parser.add_argument("--aircraft", metavar="", help="specifies the name of the aircraft to be modeled") parser.add_argument("--script", metavar="", help="specifies a script to run") + parser.add_argument("--initfile", metavar="", + help="specifies an initialization file") + parser.add_argument("--planet", metavar="", + help="specifies a planet definition file") parser.add_argument("--outputlogfile", action="append", metavar="", help="sets (overrides) the name of a data output file") parser.add_argument("--logdirectivefile", action="append", metavar="", @@ -54,10 +58,6 @@ def main(): help="specifies that console output should be pure text only (no color)") parser.add_argument("--suspend", default=False, action="store_true", help="specifies to suspend the simulation after initialization") - parser.add_argument("--initfile", metavar="", - help="specifies an initialization file") - parser.add_argument("--planet", metavar="", - help="specifies a planet definition file") parser.add_argument("--catalog", default=False, action="store_true", help="specifies that all properties for this aircraft model should be printed") parser.add_argument("--property", action="append", metavar="", diff --git a/src/JSBSim.cpp b/src/JSBSim.cpp index ea2eec9c20..d8d86aa6cd 100644 --- a/src/JSBSim.cpp +++ b/src/JSBSim.cpp @@ -854,6 +854,8 @@ void PrintHelp(void) cout << " --root= specifies the JSBSim root directory (where aircraft/, engine/, etc. reside)" << endl; cout << " --aircraft= specifies the name of the aircraft to be modeled" << endl; cout << " --script= specifies a script to run" << endl; + cout << " --initfile= specifies an initialization file" << endl; + cout << " --planet= specifies a planet definition file" << endl; cout << " --outputlogfile= sets (overrides) the name of a data output file" << endl; cout << " --logdirectivefile= specifies the name of a data logging directives file" << endl; cout << " (can appear multiple times)" << endl; @@ -862,8 +864,6 @@ void PrintHelp(void) cout << " --nice specifies to run at lower CPU usage" << endl; cout << " --nohighlight specifies that console output should be pure text only (no color)" << endl; cout << " --suspend specifies to suspend the simulation after initialization" << endl; - cout << " --initfile= specifies an initialization file" << endl; - cout << " --planet= specifies a planet definition file" << endl; cout << " --catalog specifies that all properties for this aircraft model should be printed" << endl; cout << " (catalog=aircraftname is an optional format)" << endl; cout << " --property= e.g. --property=simulation/integrator/rate/rotational=1" << endl; From bfdcd3d0478044ec8872c8c3d42c594ca116dfce Mon Sep 17 00:00:00 2001 From: Bertrand Coconnier Date: Sun, 21 Jun 2026 19:36:06 +0200 Subject: [PATCH 3/3] Replace `` with ``. --- python/JSBSim.py | 2 +- src/JSBSim.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/python/JSBSim.py b/python/JSBSim.py index 25fcc0bdbf..76fb18bbfe 100644 --- a/python/JSBSim.py +++ b/python/JSBSim.py @@ -48,7 +48,7 @@ def main(): help="sets (overrides) the name of a data output file") parser.add_argument("--logdirectivefile", action="append", metavar="", help="specifies the name of a data logging directives file") - parser.add_argument("--outputpath", metavar="", + parser.add_argument("--outputpath", metavar="", help="specifies the directory where the output files will be written.") parser.add_argument("--realtime", default=False, action="store_true", help="specifies to run in real world time") diff --git a/src/JSBSim.cpp b/src/JSBSim.cpp index d8d86aa6cd..7b623fe6d4 100644 --- a/src/JSBSim.cpp +++ b/src/JSBSim.cpp @@ -859,7 +859,7 @@ void PrintHelp(void) cout << " --outputlogfile= sets (overrides) the name of a data output file" << endl; cout << " --logdirectivefile= specifies the name of a data logging directives file" << endl; cout << " (can appear multiple times)" << endl; - cout << " --outputpath= specifies the directory where the output files will be written." << endl; + cout << " --outputpath= specifies the directory where the output files will be written." << endl; cout << " --realtime specifies to run in actual real world time" << endl; cout << " --nice specifies to run at lower CPU usage" << endl; cout << " --nohighlight specifies that console output should be pure text only (no color)" << endl;