Changes:
- Added new BaseCsc class variables default_initial_state and settings_required. Both have sensible defaults so few users will have to change thse.
- Added new CSC constructor argument settings_to_apply. If present then amain will have argument --settings. Most or all configurable should transition to having this argument.
- amain now adds argument --state to specify the initial state.
- Handle the initial_state constructor argument by transitioning to that state from default_initial_state. This makes it more robust. Note that only the final state is reported.
I also improved Controller startup by only setting the command callbacks after the controller has (mostly) started. That prevents commands from coming in before the transition to the desired state has occurred, or before the CSC, script, or other controller is ready in other ways, e.g. connected to the low-level controller. This was a good idea in any case, but seemed even more important if the CSC startup involves a series of state transition commands, which would be messed up by an external client also trying to transition the state.
Finally, I changed BaseCsc.amain to allow index to be an IntEnum. This allows specifying the allowed indices and help strings describing the choices. This was driven by ts_hexapod, which was using its own too-limited amain.
As mentioned in the previous comment, ts_hexrotcomm, ts_hexapod, and ts_rotator all needed a bit of work, but I not much. I was able to implement the initial_state support in ts_salobj in such a way as to allow transitioning Rotator and Hexapod to the desired initial state, despite their weird architecture. These packages will require ts_salobj 6.1.
ts_ATMCSImulator also needed a small change to fix one unit test. I figured out a way to retain backwards compatibility with ts_salobj 6.0
ts_Watcher is updated so that it is possible to start the CSC in enabled or disabled state. The previous version's command parser would claim to allow that, but would fail, because there was no --settings argument and Watcher requires non-empty settings.
A tiny change, but one that is not backwards compatible.
ts_ATDomeTrajectory had a unit test that was failing. I'm not sure how the change to ts_salobj tickled the problem but in any case I made it more robust (so it will pass with older stalobj and 6.1) and also fixed a cleanup problem in MockDome that produced unpleasant warning messages.
Pull requests:
This is a great suggestion. It should also simplify unit tests a bit, in that all CSCs can be commanded to start in "ENABLED" state even if they need configuration.
I am worried about how to handle the Hexapod and Rotator CSC (the summary state is kept in the low-level controller and the CSC may not have control over it). I'm also not sure I can manage externally commandable CSCs (which may not have control, and which can be running in the OFFLINE state), either, but salobj has no direct support for those.
It may be best to handle standard CSCs and allow disabling the capability for complicated cases. I think we mainly need this for the Watcher and ScriptQueues in any case.