From 1ed12413410dbd49cf1adcf29ced7d5377aa44f1 Mon Sep 17 00:00:00 2001 From: Tom Aldcroft Date: Fri, 16 Feb 2024 12:36:50 -0500 Subject: [PATCH 1/2] Change time threshold for auto-enable of SPM following eclipse --- kadi/commands/states.py | 16 ++++++++++++---- kadi/commands/tests/test_states.py | 8 +++++++- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/kadi/commands/states.py b/kadi/commands/states.py index 27de1ad4..bb4a3ed6 100644 --- a/kadi/commands/states.py +++ b/kadi/commands/states.py @@ -782,7 +782,7 @@ class SPMEclipseEnableTransition(BaseTransition): Automatic enable of sun position monitor. This occurs 11 minutes after eclipse exit, but only if the battery-connect - command occurs within 2:05 minutes of eclipse entry. + command occurs within 2.5 minutes of eclipse entry. Connect batteries is an event type COMMAND_SW and TLMSID= EOESTECN Eclipse entry is event type ORBPOINT with TYPE=PENTRY or TYPE=LSPENTRY @@ -834,8 +834,11 @@ class EclipseEnableSPM(BaseTransition): """Flag to indicate whether SPM will be enabled 11 minutes after eclipse exit. This is evaluated at the time of eclipse entry and checks that the most recent - battery connect command (via the ``battery_connect`` state) was within 2:05 minutes + battery connect command (via the ``battery_connect`` state) was within 135 seconds of eclipse entry. + + See email thread "Criteria for SPM auto-enable following eclipse" around 2024-Feb-17 + for more details on the 135 second threshold. """ command_attributes = {"type": "ORBPOINT"} @@ -843,6 +846,8 @@ class EclipseEnableSPM(BaseTransition): state_keys = SPM_STATE_KEYS default_value = False + BATTERY_CONNECT_MAX_DT = 135 # seconds + @classmethod def set_transitions(cls, transitions_dict, cmds, start, stop): """ @@ -873,12 +878,15 @@ def set_transitions(cls, transitions_dict, cmds, start, stop): def callback(cls, date, transitions, state, idx): """Set flag if SPM will be enabled 11 minutes after eclipse exit. - ``battery_connect_time`` is the time of the battery connect EOESTECN command, + ``battery_connect`` is the time of the battery connect EOESTECN command, which must occur prior to this command which is eclipse entry. """ battery_connect_time = date2secs(state["battery_connect"]) eclipse_entry_time = date2secs(date) - enable_spm = eclipse_entry_time - battery_connect_time < 125 + # By definition, the battery connect time is always less than the eclipse entry. + enable_spm = ( + eclipse_entry_time - battery_connect_time < cls.BATTERY_CONNECT_MAX_DT + ) transition = {"date": date, "eclipse_enable_spm": enable_spm} add_transition(transitions, idx, transition) diff --git a/kadi/commands/tests/test_states.py b/kadi/commands/tests/test_states.py index a469c529..19a72281 100644 --- a/kadi/commands/tests/test_states.py +++ b/kadi/commands/tests/test_states.py @@ -1854,7 +1854,7 @@ def test_sun_pos_mon_within_eclipse(): assert sts[names][-2:].pformat_all() == exp -def test_sun_pos_mon_within_eclipse_no_spm_enab(): +def test_sun_pos_mon_within_eclipse_no_spm_enab(monkeypatch): """ Test a case where battery connect is more than 125 sec before pentry. @@ -1862,6 +1862,12 @@ def test_sun_pos_mon_within_eclipse_no_spm_enab(): 2005:014:15:33:49.164 | ORBPOINT | None | JAN1005B | PENTRY 2005:014:16:38:09.164 | ORBPOINT | None | JAN1005B | PEXIT """ + # PR #323 changed the time threshold from 125 to 135 sec. Here we monkeypatch back + # to 125 sec to test the case where battery connect is more than 125 sec + # before pentry. From telemetry this case with a dt of around 133 sec actually did + # end up with the SPM enabled. + monkeypatch.setattr(states.EclipseEnableSPM, "BATTERY_CONNECT_MAX_DT", 125) + sts = states.get_states( "2005:014:16:38:10", # Just after pexit "2005:014:17:00:00", # 22 min later From f37a897bdf0d8906766f5e8308cd9ce00b2fe0e1 Mon Sep 17 00:00:00 2001 From: Tom Aldcroft Date: Sat, 17 Feb 2024 12:31:35 -0500 Subject: [PATCH 2/2] Fix doc string error --- kadi/commands/states.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kadi/commands/states.py b/kadi/commands/states.py index bb4a3ed6..d02b37d4 100644 --- a/kadi/commands/states.py +++ b/kadi/commands/states.py @@ -782,7 +782,7 @@ class SPMEclipseEnableTransition(BaseTransition): Automatic enable of sun position monitor. This occurs 11 minutes after eclipse exit, but only if the battery-connect - command occurs within 2.5 minutes of eclipse entry. + command occurs within 135 seconds of eclipse entry. Connect batteries is an event type COMMAND_SW and TLMSID= EOESTECN Eclipse entry is event type ORBPOINT with TYPE=PENTRY or TYPE=LSPENTRY