Skip to content

Commit

Permalink
Merge pull request #323 from sot/spm-eclipse-reenable-fix
Browse files Browse the repository at this point in the history
Change time threshold for auto-enable of SPM following eclipse
  • Loading branch information
taldcroft authored Feb 17, 2024
2 parents 61a3407 + f37a897 commit 5b70b04
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
16 changes: 12 additions & 4 deletions kadi/commands/states.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 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
Expand Down Expand Up @@ -834,15 +834,20 @@ 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"}
command_params = {"event_type": ["PENTRY", "LSPENTRY"]}
state_keys = SPM_STATE_KEYS
default_value = False

BATTERY_CONNECT_MAX_DT = 135 # seconds

@classmethod
def set_transitions(cls, transitions_dict, cmds, start, stop):
"""
Expand Down Expand Up @@ -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)

Expand Down
8 changes: 7 additions & 1 deletion kadi/commands/tests/test_states.py
Original file line number Diff line number Diff line change
Expand Up @@ -1854,14 +1854,20 @@ 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.
2005:014:15:31:36.410 | COMMAND_SW | EOESTECN | JAN1005B
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
Expand Down

0 comments on commit 5b70b04

Please sign in to comment.