alternate/subset startup modes, e.g. a FGCanvas mode or a headless mode. We can now also display the
Aircraft Center right after starting.
Mainly, these patches will:
- move FGNasalSys out of the global SubsystemMgr into the FGGlobals class, along with getters
- update fgMainLoop() to explicitly call the Nasal::update() method there
- fix up all globals->get_subsystem("nasal") lookups to use globals->get_nasal() instead
- move initialization of subsystem-specific APIs into each subsystem's bind() method
- the interpreter is now instantiated at the beginning of the init routine
- currently, it's right after fgcommands are added, as those are likely to be needed anyway
- reset/re-init handling is augmented to directly access the instance or allocate a new one
For testing purposes, there some CLI flags added, these will probably disappear once $FG_ROOT/Nasal is fixed up:
--enable-scripted-init - passes control to a configurable boot script in $FG_ROOT/Boot
--mode=filename - allows the boot file to be specified, defaults to default.boot
--enable-early-nasal-init - initializes Nasal earlier, to see which scripts still need to be fixed
We're hoping to re-implement bootstrapping in Nasal space using Philosopher's code, which would then
be moved into $FG_ROOT/Boot/default.boot - once that works, we'll still have to fix up $FG_ROOT/Nasal
to make subsystem dependencies more explicit there.
Once that is the case, the two --enable-... options can go, and we can easily implement additional startup
modes by adding other *.boot files
Hopefully, this will also allow us to more easily do regression testing in an automated fashion-for
example by adding a new "unit-test" startup mode that will run certain APIs to do a self-check.
Likewise, we could also use this to do headless benchmarking/profiling and debugging, possibly even
right on the build server (minus all the visuals obviously).
Future changes will be mainly about:
- moving fgCreateSubsystems() into scripting space
- extending the subsystemFactory accordingly
- extending fgIdleFunction() to allow some of it to be scripted (e.g. splash screens)
Additional info at:
http://wiki.flightgear.org/Initializing_Nasal_early- move initialization of event_mgr into fgIdleFunc() because Nasal timers depend on events
- main.cxx/fg_init.cxx extract init logic into standalone helper functions and expose them to Nasal
- fg_init.cxx split up fgCreateSubsystems() and use a separate function for "early" subsystems
- preparations for creating & initializing a subset of subsystems earlier than the others
- add a few new "signals" after intializing subsystems, so that Nasal listeners can pick those up for dependencies
- expose idle-state as a propertyObject so that Nasal listeners can be registered
- re-order idle-state increments to the bottom of each block, because using listeners will otherwise invalidate things
NOTE: This patch will now assume that there's ALWAYS at least a default boot script in $FG_ROOT/Boot/default.boot
The script can be empty though - an empty file will do.
But make things more interesting, add this to the file:
var p = "/sim/startup/current-idle-state";
var update = func(n) {
print(p," changed:", var n =getprop(p));
}
_setlistener(p, update);
When booting/resetting, You should get notifications for each change in idle-state, such as:
Scripted initialization, now passing control to:Path ".../fgroot/Boot/default.boot"
/sim/startup/current-idle-state changed:3
Nasal interpreter initialized
/sim/startup/current-idle-state changed:4
/sim/startup/current-idle-state changed:5
/sim/startup/current-idle-state changed:7
/sim/startup/current-idle-state changed:8
/sim/startup/current-idle-state changed:9
/sim/startup/current-idle-state changed:10
/sim/startup/current-idle-state changed:900
/sim/startup/current-idle-state changed:1000
There's a new _boot namespace exposed that contains a handful of init routines so that initialization can
be easily re-implemented and customized using a few lines of Nasal in each boot script.
For the time being, FGNasalSys::postinit() will default to running the hard-coded bootstrapping
scheme - but boot scripts can override this via:
setprop("/sim/startup/disable-hardcoded-nasal-bootstrapping",1);
This option will disappear once scripted bootstrapping works properly.
The next set of patches is going to make fgCreateSubsystems() better configurable.