Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cascade disabling of Guidance Controller to PVG Autopilot
This fixes the problem where PVG would finish but the staging controller would still run once and jettison a stage. The largest bug here was that PVG would disable itself but then the autopilot+glueball wouldn't run until later and see that it should terminate. This change makes the disabling of the guidance controller fire an action to disable the "calling" module as well. It does this via the introduction of an events API into ComputerModule with one supported event ModuleDisabledEvent and the addition of an API CascadeDisable() which lets a computer module call that on another computer module to setup an event to have itself disabled when the target module disables itself. This places the calling module in control, which seems right (rather than making the GuidanceController know to poke the PVG autopilot which seems very, very wrong). There's other jankiness going on in here with the weird coupling between the PVG Autopilot, the Guidance Controller and the PVG Glueball where they're all touching all kinds of different modules without being 'subscribed' to those modules. But this gets the right behavior since when the GuidanceController disables itself that executes the callback which disables the PVG autopilot and since the PVG autopilot is the "process group leader" and it has an OnModuleDisabled that disables the whole tree, that makes sure that this works more or less like killing the process group leader in Unix. By the time that "Enabled = false" returns to the GuidanceController method the whole set of modules is disabled. I took a little bit of care to have the callbacks execute in the reverse order that CascadeDelete() was called and to have them be non-duplicated. The event is called ModuleDisabledEvent instead of onModuleDisabled or OnModuleDisabled because that already exists as the abstract API for the ComputerModule itself, naming things is hard. Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
- Loading branch information