Refactor ACS modes #163

Merged
muellerr merged 3 commits from refactor_acs_modes into main 2023-03-10 15:00:13 +01:00
4 changed files with 55 additions and 55 deletions

View File

@ -10,6 +10,10 @@ list yields a list of all related PRs for each release.
# [unreleased]
## Changed
- ACS mode changes: The ACS CTRL submodes are now modes. DETUBMLE is now submode of SAFE mode.
# [v2.17.3] 2023-03-09
## Fixed

View File

@ -8,6 +8,7 @@ from typing import Tuple
from eive_tmtc.config.definitions import CustomServiceList
from eive_tmtc.config.object_ids import ACS_CONTROLLER
from eive_tmtc.pus_tm.defs import PrintWrapper
from eive_tmtc.tmtc.acs.defs import AcsMode, SafeSubmode
from tmtccmd.config.tmtc import (
tmtc_definitions_provider,
TmtcDefinitionWrapper,
@ -55,17 +56,6 @@ class SetId(enum.IntEnum):
ACTUATOR_CMD_DATA = 9
class Submode(enum.IntEnum):
OFF = 0
SAFE = 10
DETUMBLE = 11
IDLE = 12
PTG_NADIR = 13
PTG_TARGET = 14
PTG_TARGET_GS = 15
PTG_INERTIAL = 16
class ActionId(enum.IntEnum):
SOLAR_ARRAY_DEPLOYMENT_SUCCESSFUL = 0
RESET_MEKF = 1
@ -73,13 +63,13 @@ class ActionId(enum.IntEnum):
class OpCodes:
OFF = ["off"]
SAFE = ["normal_safe"]
DTBL = ["normal_detumble"]
IDLE = ["normal_idle"]
NADIR = ["normal_nadir"]
TARGET = ["normal_target"]
GS = ["normal_gs"]
INERTIAL = ["normal_inertial"]
SAFE = ["safe"]
DTBL = ["safe_detumble"]
IDLE = ["ptg_idle"]
NADIR = ["ptg_nadir"]
TARGET = ["ptg_target"]
GS = ["ptg_target_gs"]
INERTIAL = ["ptg_inertial"]
SAFE_PTG = ["confirm_deployment"]
RESET_MEKF = ["reset_mekf"]
SET_PARAMETER_SCALAR = ["set_scalar_param"]
@ -119,9 +109,9 @@ class OpCodes:
class Info:
OFF = "Switch ACS CTRL off"
SAFE = "Switch ACS CTRL normal - safe"
DTBL = "Switch ACS CTRL normal - detumble"
IDLE = "Switch ACS CTRL normal - idle"
SAFE = "Switch ACS CTRL - safe"
DTBL = "Switch ACS CTRL - safe with detumble submode"
IDLE = "Switch ACS CTRL - pointing idle"
NADIR = "Switch ACS CTRL normal - pointing nadir"
TARGET = "Switch ACS CTRL normal - pointing target"
GS = "Switch ACS CTRL normal - pointing target groundstation"
@ -235,29 +225,29 @@ def pack_acs_ctrl_command(p: ServiceProviderParams):
q.add_pus_tc(pack_mode_command(ACS_CONTROLLER, Mode.OFF, 0))
elif op_code in OpCodes.SAFE:
q.add_log_cmd(f"{Info.SAFE}")
q.add_pus_tc(pack_mode_command(ACS_CONTROLLER, Mode.NORMAL, Submode.SAFE))
q.add_pus_tc(
pack_mode_command(ACS_CONTROLLER, AcsMode.SAFE, SafeSubmode.DEFAULT)
)
elif op_code in OpCodes.DTBL:
q.add_log_cmd(f"{Info.DTBL}")
q.add_pus_tc(pack_mode_command(ACS_CONTROLLER, Mode.NORMAL, Submode.DETUMBLE))
q.add_pus_tc(
pack_mode_command(ACS_CONTROLLER, AcsMode.SAFE, SafeSubmode.DETUMBLE)
)
elif op_code in OpCodes.IDLE:
q.add_log_cmd(f"{Info.IDLE}")
q.add_pus_tc(pack_mode_command(ACS_CONTROLLER, Mode.NORMAL, Submode.IDLE))
q.add_pus_tc(pack_mode_command(ACS_CONTROLLER, AcsMode.IDLE, 0))
elif op_code in OpCodes.NADIR:
q.add_log_cmd(f"{Info.NADIR}")
q.add_pus_tc(pack_mode_command(ACS_CONTROLLER, Mode.NORMAL, Submode.PTG_NADIR))
q.add_pus_tc(pack_mode_command(ACS_CONTROLLER, AcsMode.PTG_NADIR, 0))
elif op_code in OpCodes.TARGET:
q.add_log_cmd(f"{Info.TARGET}")
q.add_pus_tc(pack_mode_command(ACS_CONTROLLER, Mode.NORMAL, Submode.PTG_TARGET))
q.add_pus_tc(pack_mode_command(ACS_CONTROLLER, AcsMode.PTG_TARGET, 0))
elif op_code in OpCodes.GS:
q.add_log_cmd(f"{Info.GS}")
q.add_pus_tc(
pack_mode_command(ACS_CONTROLLER, Mode.NORMAL, Submode.PTG_TARGET_GS)
)
q.add_pus_tc(pack_mode_command(ACS_CONTROLLER, AcsMode.PTG_TARGET_GS, 0))
elif op_code in OpCodes.INERTIAL:
q.add_log_cmd(f"{Info.INERTIAL}")
q.add_pus_tc(
pack_mode_command(ACS_CONTROLLER, Mode.NORMAL, Submode.PTG_INERTIAL)
)
q.add_pus_tc(pack_mode_command(ACS_CONTROLLER, AcsMode.PTG_INERTIAL, 0))
elif op_code in OpCodes.SAFE_PTG:
q.add_log_cmd(f"{Info.SAFE_PTG}")
q.add_pus_tc(

View File

@ -0,0 +1,16 @@
import enum
class AcsMode(enum.IntEnum):
OFF = 0
SAFE = 10
IDLE = 11
PTG_NADIR = 12
PTG_TARGET = 13
PTG_TARGET_GS = 14
PTG_INERTIAL = 15
class SafeSubmode(enum.IntEnum):
DEFAULT = 0
DETUMBLE = 1

View File

@ -1,6 +1,7 @@
import enum
from typing import Tuple, Dict
from eive_tmtc.tmtc.acs.defs import AcsMode, SafeSubmode
from spacepackets.ecss import PusTelecommand
from eive_tmtc.tmtc.common import pack_mode_cmd_with_info
from eive_tmtc.config.object_ids import ACS_SUBSYSTEM_ID
@ -27,17 +28,6 @@ class OpCode(str, enum.Enum):
REPORT_ALL_MODES = "all_modes"
class AcsMode(enum.IntEnum):
OFF = 0
SAFE = 10
DETUMBLE = 11
IDLE = 12
PTG_TARGET_NADIR = 13
PTG_TARGET = 14
PTG_TARGET_GS = 15
PTG_TARGET_INERTIAL = 16
class Info(str, enum.Enum):
OFF = "Off Command"
SAFE = "Safe Mode Command"
@ -50,15 +40,15 @@ class Info(str, enum.Enum):
REPORT_ALL_MODES = "Report All Modes Recursively"
HANDLER_LIST: Dict[str, Tuple[int, str]] = {
OpCode.OFF: (AcsMode.OFF, Info.OFF),
OpCode.SAFE: (AcsMode.SAFE, Info.SAFE),
OpCode.DETUMBLE: (AcsMode.DETUMBLE, Info.DETUMBLE),
OpCode.IDLE: (AcsMode.IDLE, Info.IDLE),
OpCode.PTG_TARGET: (AcsMode.PTG_TARGET, Info.PTG_TARGET),
OpCode.PTG_TARGET_GS: (AcsMode.PTG_TARGET_GS, Info.PTG_TARGET_GS),
OpCode.PTG_TARGET_NADIR: (AcsMode.PTG_TARGET_NADIR, Info.PTG_TARGET_NADIR),
OpCode.PTG_TARGET_INERTIAL: (AcsMode.PTG_TARGET_INERTIAL, Info.PTG_TARGET_INERTIAL),
HANDLER_LIST: Dict[str, Tuple[int, int, str]] = {
OpCode.OFF: (AcsMode.OFF, 0, Info.OFF),
OpCode.SAFE: (AcsMode.SAFE, SafeSubmode.DEFAULT, Info.SAFE),
OpCode.DETUMBLE: (AcsMode.SAFE, SafeSubmode.DETUMBLE, Info.DETUMBLE),
OpCode.IDLE: (AcsMode.IDLE, 0, Info.IDLE),
OpCode.PTG_TARGET: (AcsMode.PTG_TARGET, 0, Info.PTG_TARGET),
OpCode.PTG_TARGET_GS: (AcsMode.PTG_TARGET_GS, 0, Info.PTG_TARGET_GS),
OpCode.PTG_TARGET_NADIR: (AcsMode.PTG_NADIR, 0, Info.PTG_TARGET_NADIR),
OpCode.PTG_TARGET_INERTIAL: (AcsMode.PTG_INERTIAL, 0, Info.PTG_TARGET_INERTIAL),
}
@ -81,9 +71,9 @@ def build_acs_subsystem_cmd(p: ServiceProviderParams):
return
pack_mode_cmd_with_info(
object_id=ACS_SUBSYSTEM_ID,
info=f"{info_prefix}: {mode_info_tup[1]}",
submode=0,
info=f"{info_prefix}: {mode_info_tup[2]}",
mode=mode_info_tup[0],
submode=mode_info_tup[1],
q=q,
)
@ -91,7 +81,7 @@ def build_acs_subsystem_cmd(p: ServiceProviderParams):
@tmtc_definitions_provider
def add_acs_subsystem_cmds(defs: TmtcDefinitionWrapper):
oce = OpCodeEntry()
for op_code, (_, info) in HANDLER_LIST.items():
for op_code, (_, _, info) in HANDLER_LIST.items():
oce.add(op_code, info)
oce.add(OpCode.REPORT_ALL_MODES, Info.REPORT_ALL_MODES)
defs.add_service(CustomServiceList.ACS_SS, "ACS Subsystem", oce)