Uploaded image for project: 'Data Management'
  1. Data Management
  2. DM-26497

Allow CSCs to transition to ENABLED state on startup

    XMLWordPrintable

    Details

    • Story Points:
      5
    • Sprint:
      TSSW Sprint - Oct 12 - Oct 26, TSSW Sprint - Oct 26 - Nov 9
    • Team:
      Telescope and Site
    • Urgent?:
      No

      Description

      The capability to send a CSC to ENABLED via appropriate command-line flags should be implemented. The CSC needs to do the following:

      1. Accept a flag to indicate ENABLED as the desired top state (may already exist)
      2. Accepts a flag for settingsToApply if necessary
      3. CSC should transition through all states from STANDBY to ENABLED in order to maintain correct summary state transition history.

        Attachments

          Issue Links

            Activity

            Hide
            rowen Russell Owen added a comment - - edited

            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.

            Show
            rowen Russell Owen added a comment - - edited 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.
            Hide
            rowen Russell Owen added a comment - - edited

            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:

            Show
            rowen Russell Owen added a comment - - edited 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: https://github.com/lsst-ts/ts_salobj/pull/160 https://github.com/lsst-ts/ts_hexrotcomm/pull/24 https://github.com/lsst-ts/ts_hexapod/pull/28 https://github.com/lsst-ts/ts_rotator/pull/25 https://github.com/lsst-ts/ts_scriptqueue/pull/58 https://github.com/lsst-ts/ts_ATMCSSimulator/pull/26 https://github.com/lsst-ts/ts_ATDomeTrajectory/pull/30 https://github.com/lsst-ts/ts_watcher/pull/24
            Hide
            rowen Russell Owen added a comment -

            As per request I have updated ts_salobj as follows:

            • Added new class variable enable_cmdline_state which defaults to False. If True BaseCsc.amain adds command-line arguments -state and (if a configurable CSC) -settings.
            • Report the intermediate states, as requested. For example if initial_state is ENABLED the CSC will report states STANDBY, DISABLED, ENABLED during startup (whether run from the command line or a unit test).
            • Update BaseCscTestCase.make_csc to read and check all but the final state. This means that unit tests using BaseCscTestCase should not require any changes. There may be a few packages using some other means to make CSCs; those should be updated to use BaseCscTestCase.
            • Added new salobj function get_expected_summary_states to make checks such as this easier. It is used in 2 places in salobj and one in hexrotcomm, and I don't expect much other use.
            • The CSC delays assigning command callbacks until the CSC is started, to avoid weird errors from trying to command a partially built CSC. However, this assignment is done before reporting summaryState. So the CSC is fully functional once the first summary state is reported.
            Show
            rowen Russell Owen added a comment - As per request I have updated ts_salobj as follows: Added new class variable enable_cmdline_state which defaults to False. If True BaseCsc.amain adds command-line arguments - state and (if a configurable CSC) -settings . Report the intermediate states, as requested. For example if initial_state is ENABLED the CSC will report states STANDBY, DISABLED, ENABLED during startup (whether run from the command line or a unit test). Update BaseCscTestCase.make_csc to read and check all but the final state. This means that unit tests using BaseCscTestCase should not require any changes. There may be a few packages using some other means to make CSCs; those should be updated to use BaseCscTestCase . Added new salobj function get_expected_summary_states to make checks such as this easier. It is used in 2 places in salobj and one in hexrotcomm, and I don't expect much other use. The CSC delays assigning command callbacks until the CSC is started, to avoid weird errors from trying to command a partially built CSC. However, this assignment is done before reporting summaryState. So the CSC is fully functional once the first summary state is reported.
            Hide
            mareuter Michael Reuter added a comment -

            All PRs reviewed and approved.

            Show
            mareuter Michael Reuter added a comment - All PRs reviewed and approved.
            Hide
            rowen Russell Owen added a comment - - edited

            All packages merged to develop.

            Release awaits DM-27296 since I want that to be part of ts_salobj 6.1,
            except for these packages that are compatible with ts_salobj 6:

            • ts_ATDomeTrajectory and released as v1.4.5
            • ts_ATMCSSimulator and released as v1.1.0
            Show
            rowen Russell Owen added a comment - - edited All packages merged to develop. Release awaits DM-27296 since I want that to be part of ts_salobj 6.1, except for these packages that are compatible with ts_salobj 6: ts_ATDomeTrajectory and released as v1.4.5 ts_ATMCSSimulator and released as v1.1.0

              People

              Assignee:
              rowen Russell Owen
              Reporter:
              mareuter Michael Reuter
              Reviewers:
              Michael Reuter
              Watchers:
              Michael Reuter, Russell Owen
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:

                  Jenkins Builds

                  No builds found.