Skip to content

Commit 5aefbdd

Browse files
authored
Merge pull request #344 from sot/scs107_hrc_off
[bugfix] Add commands to turn HRC off to SCS 107
2 parents 6bac076 + 54e6f15 commit 5aefbdd

File tree

5 files changed

+70
-14
lines changed

5 files changed

+70
-14
lines changed

kadi/commands/command_sets.py

+17-6
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from Quaternion import Quat
88
from ska_helpers.utils import convert_to_int_float_str
99

10+
import kadi.commands
1011
from kadi.commands.core import CommandTable
1112

1213
RTS_PATH = Path("FOT/configuration/products/rts")
@@ -90,17 +91,27 @@ def cmd_set_scs107(date=None):
9091
cmds = cmd_set_end_observing()
9192
cmds += (
9293
dict(type="COMMAND_SW", dur=1.025, tlmsid="OORMPDS"),
93-
dict(
94-
type="COMMAND_HW",
95-
# dur=1.025,
96-
tlmsid="AFIDP",
97-
msid="AFLCRSET",
98-
),
94+
dict(type="COMMAND_HW", tlmsid="AFIDP", msid="AFLCRSET"),
9995
dict(type="SIMTRANS", params=dict(POS=-99616), dur=65.66),
10096
dict(type="ACISPKT", tlmsid="AA00000000", dur=1.025),
10197
dict(type="ACISPKT", tlmsid="AA00000000", dur=10.25),
10298
dict(type="ACISPKT", tlmsid=pow_cmd),
10399
)
100+
# Note that the following block to include HRC turn-off commands is wrapped in a
101+
# config variable to make this conditional in support of regression testing. This is
102+
# needed for tests of command generation vs. commands in the archive which did not
103+
# include this HRC SCS-107 commanding (prior to #344).
104+
if not kadi.commands.conf.disable_hrc_scs107_commanding:
105+
cmds += (
106+
dict(type="COMMAND_HW", tlmsid="215PCAOF", dur=1.205),
107+
dict(type="COMMAND_HW", tlmsid="2IMHVOF", dur=1.025),
108+
dict(type="COMMAND_HW", tlmsid="2SPHVOF", dur=1.025),
109+
dict(type="COMMAND_HW", tlmsid="2S2STHV", dur=1.025),
110+
dict(type="COMMAND_HW", tlmsid="2S1STHV", dur=1.025),
111+
dict(type="COMMAND_HW", tlmsid="2S2HVOF", dur=1.025),
112+
dict(type="COMMAND_HW", tlmsid="2S1HVOF", dur=1.025),
113+
)
114+
104115
return cmds
105116

106117

kadi/commands/tests/conftest.py

+7
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
11
import pytest
22
import ska_sun
33

4+
import kadi.commands
5+
46

57
@pytest.fixture()
68
def fast_sun_position_method(monkeypatch: pytest.MonkeyPatch):
79
monkeypatch.setattr(ska_sun.conf, "sun_position_method_default", "fast")
10+
11+
12+
@pytest.fixture()
13+
def disable_hrc_scs107_commanding(monkeypatch: pytest.MonkeyPatch):
14+
monkeypatch.setattr(kadi.commands.conf, "disable_hrc_scs107_commanding", True)

kadi/commands/tests/test_commands.py

+33-7
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,9 @@ def test_get_cmds_from_backstop_and_add_cmds():
236236

237237
@pytest.mark.skipif("not HAS_MPDIR")
238238
@pytest.mark.skipif(not HAS_INTERNET, reason="No internet connection")
239-
def test_commands_create_archive_regress(tmpdir, fast_sun_position_method):
239+
def test_commands_create_archive_regress(
240+
tmpdir, fast_sun_position_method, disable_hrc_scs107_commanding
241+
):
240242
"""Create cmds archive from scratch and test that it matches flight
241243
242244
This tests over an eventful month that includes IU reset/NSM, SCS-107
@@ -462,7 +464,7 @@ def test_get_cmds_v2_recent_only(stop_date_2020_12_03): # noqa: ARG001
462464

463465

464466
@pytest.mark.skipif(not HAS_INTERNET, reason="No internet connection")
465-
def test_get_cmds_nsm_2021(stop_date_2021_10_24): # noqa: ARG001
467+
def test_get_cmds_nsm_2021(stop_date_2021_10_24, disable_hrc_scs107_commanding):
466468
"""NSM at ~2021:296:10:41. This tests non-load commands from cmd_events."""
467469
cmds = commands.get_cmds("2021:296:10:35:00") # , '2021:298:01:58:00')
468470
cmds = cmds[cmds["tlmsid"] != "OBS"]
@@ -538,6 +540,7 @@ def test_get_cmds_nsm_2021(stop_date_2021_10_24): # noqa: ARG001
538540
"2021:297:14:01:00.000 | LOAD_EVENT | None | OCT1821A | "
539541
"event_type=SCHEDULED_STOP_TIME, scs=0",
540542
]
543+
541544
assert cmds.pformat_like_backstop(max_params_width=200) == exp
542545
commands.clear_caches()
543546

@@ -676,7 +679,14 @@ def test_command_set_bsh():
676679
2000:001:00:00:01.025 | SIMTRANS | None | CMD_EVT | event=Bright_star_hold, event_date=2000:001:00:00:00, pos=-99616, scs=0
677680
2000:001:00:01:06.685 | ACISPKT | AA00000000 | CMD_EVT | event=Bright_star_hold, event_date=2000:001:00:00:00, scs=0
678681
2000:001:00:01:07.710 | ACISPKT | AA00000000 | CMD_EVT | event=Bright_star_hold, event_date=2000:001:00:00:00, scs=0
679-
2000:001:00:01:17.960 | ACISPKT | WSPOW00000 | CMD_EVT | event=Bright_star_hold, event_date=2000:001:00:00:00, scs=0"""
682+
2000:001:00:01:17.960 | ACISPKT | WSPOW00000 | CMD_EVT | event=Bright_star_hold, event_date=2000:001:00:00:00, scs=0
683+
2000:001:00:01:17.960 | COMMAND_HW | 215PCAOF | CMD_EVT | event=Bright_star_hold, event_date=2000:001:00:00:00, scs=0
684+
2000:001:00:01:19.165 | COMMAND_HW | 2IMHVOF | CMD_EVT | event=Bright_star_hold, event_date=2000:001:00:00:00, scs=0
685+
2000:001:00:01:20.190 | COMMAND_HW | 2SPHVOF | CMD_EVT | event=Bright_star_hold, event_date=2000:001:00:00:00, scs=0
686+
2000:001:00:01:21.215 | COMMAND_HW | 2S2STHV | CMD_EVT | event=Bright_star_hold, event_date=2000:001:00:00:00, scs=0
687+
2000:001:00:01:22.240 | COMMAND_HW | 2S1STHV | CMD_EVT | event=Bright_star_hold, event_date=2000:001:00:00:00, scs=0
688+
2000:001:00:01:23.265 | COMMAND_HW | 2S2HVOF | CMD_EVT | event=Bright_star_hold, event_date=2000:001:00:00:00, scs=0
689+
2000:001:00:01:24.290 | COMMAND_HW | 2S1HVOF | CMD_EVT | event=Bright_star_hold, event_date=2000:001:00:00:00, scs=0"""
680690

681691
assert cmds.pformat_like_backstop(max_params_width=None) == exp.splitlines()
682692
commands.clear_caches()
@@ -699,13 +709,22 @@ def test_command_set_safe_mode():
699709
2000:001:00:01:06.685 | ACISPKT | AA00000000 | CMD_EVT | event=Safe_mode, event_date=2000:001:00:00:00, scs=0
700710
2000:001:00:01:07.710 | ACISPKT | AA00000000 | CMD_EVT | event=Safe_mode, event_date=2000:001:00:00:00, scs=0
701711
2000:001:00:01:17.960 | ACISPKT | WSPOW00000 | CMD_EVT | event=Safe_mode, event_date=2000:001:00:00:00, scs=0
702-
2000:001:00:01:17.960 | COMMAND_SW | AODSDITH | CMD_EVT | event=Safe_mode, event_date=2000:001:00:00:00, scs=0"""
712+
2000:001:00:01:17.960 | COMMAND_HW | 215PCAOF | CMD_EVT | event=Safe_mode, event_date=2000:001:00:00:00, scs=0
713+
2000:001:00:01:19.165 | COMMAND_HW | 2IMHVOF | CMD_EVT | event=Safe_mode, event_date=2000:001:00:00:00, scs=0
714+
2000:001:00:01:20.190 | COMMAND_HW | 2SPHVOF | CMD_EVT | event=Safe_mode, event_date=2000:001:00:00:00, scs=0
715+
2000:001:00:01:21.215 | COMMAND_HW | 2S2STHV | CMD_EVT | event=Safe_mode, event_date=2000:001:00:00:00, scs=0
716+
2000:001:00:01:22.240 | COMMAND_HW | 2S1STHV | CMD_EVT | event=Safe_mode, event_date=2000:001:00:00:00, scs=0
717+
2000:001:00:01:23.265 | COMMAND_HW | 2S2HVOF | CMD_EVT | event=Safe_mode, event_date=2000:001:00:00:00, scs=0
718+
2000:001:00:01:24.290 | COMMAND_HW | 2S1HVOF | CMD_EVT | event=Safe_mode, event_date=2000:001:00:00:00, scs=0
719+
2000:001:00:01:25.315 | COMMAND_SW | AODSDITH | CMD_EVT | event=Safe_mode, event_date=2000:001:00:00:00, scs=0"""
703720
assert cmds.pformat_like_backstop(max_params_width=None) == exp.splitlines()
704721
commands.clear_caches()
705722

706723

707724
@pytest.mark.skipif(not HAS_INTERNET, reason="No internet connection")
708-
def test_bright_star_hold_event(cmds_dir, stop_date_2020_12_03): # noqa: ARG001
725+
def test_bright_star_hold_event(
726+
cmds_dir, stop_date_2020_12_03, disable_hrc_scs107_commanding
727+
):
709728
"""Make a scenario with a bright star hold event.
710729
711730
Confirm that this inserts expected commands and interrupts all load commands.
@@ -1265,7 +1284,7 @@ def test_get_cmds_from_event_case(par_str):
12651284

12661285

12671286
@pytest.mark.parametrize("idx", range(len(cmd_events_all_exps)))
1268-
def test_get_cmds_from_event_all(idx):
1287+
def test_get_cmds_from_event_all(idx, disable_hrc_scs107_commanding):
12691288
"""Test getting commands from every event type in the Command Events sheet"""
12701289
cevt = cmd_events_all[idx]
12711290
exp = cmd_events_all_exps[idx]
@@ -1337,7 +1356,14 @@ def test_scenario_with_rts(monkeypatch, fast_sun_position_method):
13371356
2021:296:10:43:03.685 | ACISPKT | AA00000000 | CMD_EVT | event=NSM, event_date=2021:296:10:41:57, scs=0
13381357
2021:296:10:43:04.710 | ACISPKT | AA00000000 | CMD_EVT | event=NSM, event_date=2021:296:10:41:57, scs=0
13391358
2021:296:10:43:14.960 | ACISPKT | WSPOW0002A | CMD_EVT | event=NSM, event_date=2021:296:10:41:57, scs=0
1340-
2021:296:10:43:14.960 | COMMAND_SW | AODSDITH | CMD_EVT | event=NSM, event_date=2021:296:10:41:57, scs=0
1359+
2021:296:10:43:14.960 | COMMAND_HW | 215PCAOF | CMD_EVT | event=NSM, event_date=2021:296:10:41:57, scs=0
1360+
2021:296:10:43:16.165 | COMMAND_HW | 2IMHVOF | CMD_EVT | event=NSM, event_date=2021:296:10:41:57, scs=0
1361+
2021:296:10:43:17.190 | COMMAND_HW | 2SPHVOF | CMD_EVT | event=NSM, event_date=2021:296:10:41:57, scs=0
1362+
2021:296:10:43:18.215 | COMMAND_HW | 2S2STHV | CMD_EVT | event=NSM, event_date=2021:296:10:41:57, scs=0
1363+
2021:296:10:43:19.240 | COMMAND_HW | 2S1STHV | CMD_EVT | event=NSM, event_date=2021:296:10:41:57, scs=0
1364+
2021:296:10:43:20.265 | COMMAND_HW | 2S2HVOF | CMD_EVT | event=NSM, event_date=2021:296:10:41:57, scs=0
1365+
2021:296:10:43:21.290 | COMMAND_HW | 2S1HVOF | CMD_EVT | event=NSM, event_date=2021:296:10:41:57, scs=0
1366+
2021:296:10:43:22.315 | COMMAND_SW | AODSDITH | CMD_EVT | event=NSM, event_date=2021:296:10:41:57, scs=0
13411367
2021:296:11:08:12.966 | LOAD_EVENT | OBS | CMD_EVT | manvr_start=2021:296:10:41:57.000, prev_att=(0.594590732, 0.
13421368
2021:297:01:41:01.000 | COMMAND_SW | AONMMODE | CMD_EVT | event=Maneuver, event_date=2021:297:01:41:01, msid=AONMMODE,
13431369
2021:297:01:41:01.256 | COMMAND_SW | AONM2NPE | CMD_EVT | event=Maneuver, event_date=2021:297:01:41:01, msid=AONM2NPE,

kadi/commands/tests/test_validate.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,13 @@ def get_one_validator_data(cls: type[Validate], stop, days, no_exclude):
155155
@pytest.mark.skipif(not HAS_INTERNET, reason="Command sheet not available")
156156
@pytest.mark.parametrize("cls", Validate.subclasses)
157157
@pytest.mark.parametrize("no_exclude", [False, True])
158-
def test_validate_regression(cls, no_exclude, fast_sun_position_method, regress_stop):
158+
def test_validate_regression(
159+
cls,
160+
no_exclude,
161+
fast_sun_position_method,
162+
regress_stop,
163+
disable_hrc_scs107_commanding,
164+
):
159165
"""Test that validator data matches regression data
160166
161167
This is likely to be fragile. In the future we may need helper function to output

kadi/config.py

+6
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,12 @@ class Conf(ConfigNamespace):
7373
"Start date for using AGASC 1.8 catalog.",
7474
)
7575

76+
disable_hrc_scs107_commanding = ConfigItem(
77+
False,
78+
"Disable HRC SCS-107 commanding from #344, strictly for regression testing "
79+
"of command generation prior to that patch.",
80+
)
81+
7682

7783
# Create a configuration instance for the user
7884
conf = Conf()

0 commit comments

Comments
 (0)