common_power module
This commit is contained in:
@ -1,126 +1,141 @@
|
||||
import enum
|
||||
from pus_tc.devs.pdu1 import Pdu1OpCodes
|
||||
from pus_tc.devs.pdu2 import Pdu2OpCodes
|
||||
|
||||
from config.object_ids import PDU_1_HANDLER_ID
|
||||
from gomspace.gomspace_common import pack_set_param_command, Channel
|
||||
from gomspace.gomspace_pdu_definitions import PduConfigTable, PDU_CONFIG_LIST
|
||||
from tmtccmd.tc import DefaultPusQueueHelper
|
||||
from tmtccmd.util import ObjectIdU32
|
||||
from config.definitions import CustomServiceList
|
||||
from tmtccmd.config import TmTcDefWrapper, OpCodeEntry
|
||||
|
||||
from pus_tc.devs.p60dock import P60OpCodes, GomspaceOpCodes, Info
|
||||
from pus_tc.devs.acu import add_acu_cmds
|
||||
from gomspace.gomspace_common import Info as GsInfo
|
||||
|
||||
|
||||
class Pdu1OpCodes(enum.Enum):
|
||||
TCS_BOARD_ON = ["tcs-on", "0"]
|
||||
TCS_BOARD_OFF = ["tcs-off", "1"]
|
||||
STAR_TRACKER_ON = ["str-on", "2"]
|
||||
STAR_TRACKER_OFF = ["str-off", "3"]
|
||||
SUS_NOMINAL_ON = ["sus-nom-on", "4"]
|
||||
SUS_NOMINAL_OFF = ["sum-nom-off", "5"]
|
||||
ACS_A_SIDE_ON = ["acs-a-on", "6"]
|
||||
ACS_A_SIDE_OFF = ["acs-a-off", "7"]
|
||||
SYRLINKS_ON = ["syrlinks-on", "8"]
|
||||
SYRLINKS_OFF = ["syrlinks-off", "9"]
|
||||
MGT_ON = ["mgt-on", "10"]
|
||||
MGT_OFF = ["mgt-off", "11"]
|
||||
# Solar Cell Experiment
|
||||
SCEX_ON = ["scex-on", "12"]
|
||||
SCEX_OFF = ["scex-off", "13"]
|
||||
PLOC_ON = ["ploc-on", "14"]
|
||||
PLOC_OFF = ["ploc-off", "15"]
|
||||
|
||||
TESTS = "32"
|
||||
|
||||
|
||||
class Pdu2OpCodes(enum.Enum):
|
||||
ACS_SIDE_B_ON = "1"
|
||||
ACS_SIDE_B_OFF = "2"
|
||||
SUS_REDUNDANT_ON = "3"
|
||||
SUS_REDUNDANT_OFF = "4"
|
||||
RW_ON = "5"
|
||||
RW_OFF = "6"
|
||||
PL_PCDU_VBAT_NOM_ON = "7"
|
||||
PL_PCDU_VBAT_NOM_OFF = "8"
|
||||
PL_PCDU_VBAT_RED_ON = "9"
|
||||
PL_PCDU_VBAT_RED_OFF = "10"
|
||||
TCS_HEATER_IN_ON = "11"
|
||||
TCS_HEATER_IN_OFF = "12"
|
||||
SOLAR_ARRAY_DEPL_ON = "13"
|
||||
SOLAR_ARRAY_DEPL_OFF = "14"
|
||||
PL_CAMERA_ON = "15"
|
||||
PL_CAMERA_OFF = "16"
|
||||
# There is not really a point of the on command, the SW can not be commanded if the OBC is off
|
||||
Q7S_OFF = "32"
|
||||
|
||||
|
||||
class PowerChannels(enum.IntEnum):
|
||||
TCS = (0,)
|
||||
COM = (1,)
|
||||
STR = (2,)
|
||||
SUS_NOM = 3
|
||||
|
||||
|
||||
Pdu1Dict = {PowerChannels.TCS: (0, "tcs"), PowerChannels.STR: (2, "str")}
|
||||
|
||||
|
||||
class PowerOpCodes:
|
||||
TCS_ON = ["tcs-on"]
|
||||
TCS_OFF = ["tcs-off"]
|
||||
STAR_TRACKER_ON = ["str-on"]
|
||||
STAR_TRACKER_OFF = ["str-off"]
|
||||
|
||||
|
||||
Pdu1OpCodeList = []
|
||||
|
||||
|
||||
def get_power_obj_id(op_code: PowerOpCodes) -> ObjectIdU32:
|
||||
pass
|
||||
|
||||
|
||||
def pack_power_commands(q: DefaultPusQueueHelper, op_code: str):
|
||||
if op_code in PowerOpCodes.TCS_ON:
|
||||
object_id = PDU_1_HANDLER_ID
|
||||
tcs_on_cmd(object_id, q)
|
||||
if op_code in PowerOpCodes.STAR_TRACKER_ON:
|
||||
object_id = PDU_1_HANDLER_ID
|
||||
|
||||
|
||||
def tcs_on_cmd(object_id: ObjectIdU32, q: DefaultPusQueueHelper):
|
||||
generic_on_cmd(object_id, q, "PDU1: Turn TCS board on", 0)
|
||||
|
||||
|
||||
def tcs_off_cmd(object_id: ObjectIdU32, q: DefaultPusQueueHelper):
|
||||
generic_off_cmd(object_id, q, "PDU1: Turn TCS board off", 0)
|
||||
|
||||
|
||||
def str_on_cmd(object_id: ObjectIdU32, q: DefaultPusQueueHelper):
|
||||
generic_on_cmd(object_id, q, "PDU1: Turn Star Tracker on", 2)
|
||||
|
||||
|
||||
def str_off_cmd(object_id: ObjectIdU32, q: DefaultPusQueueHelper):
|
||||
generic_off_cmd(object_id, q, "PDU1: Turn Star Tracker off", 2)
|
||||
|
||||
|
||||
def generic_on_cmd(
|
||||
object_id: ObjectIdU32, q: DefaultPusQueueHelper, info_str: str, out_idx: int
|
||||
):
|
||||
q.add_log_cmd(info_str)
|
||||
q.add_pus_tc(
|
||||
pack_set_param_command(
|
||||
object_id.as_bytes,
|
||||
PDU_CONFIG_LIST[out_idx].parameter_address,
|
||||
PDU_CONFIG_LIST[out_idx].parameter_size,
|
||||
Channel.on,
|
||||
)
|
||||
def add_p60_cmds(defs: TmTcDefWrapper):
|
||||
oce = OpCodeEntry()
|
||||
oce.add(keys=P60OpCodes.STACK_3V3_ON, info=Info.STACK_3V3_ON)
|
||||
oce.add(keys=P60OpCodes.STACK_3V3_OFF, info=Info.STACK_3V3_OFF)
|
||||
oce.add(keys=P60OpCodes.STACK_5V_ON, info=Info.STACK_5V_ON)
|
||||
oce.add(keys=P60OpCodes.STACK_5V_OFF, info=Info.STACK_5V_OFF)
|
||||
oce.add(keys=GomspaceOpCodes.REQUEST_CORE_HK_ONCE, info=GsInfo.REQUEST_CORE_HK_ONCE)
|
||||
oce.add(keys=GomspaceOpCodes.REQUEST_AUX_HK_ONCE, info=GsInfo.REQUEST_AUX_HK_ONCE)
|
||||
oce.add(
|
||||
keys=GomspaceOpCodes.PRINT_SWITCH_V_I,
|
||||
info="P60 Dock: Print Switches, Voltages, Currents",
|
||||
)
|
||||
oce.add(keys=GomspaceOpCodes.PRINT_LATCHUPS, info="P60 Dock: Print Latchups")
|
||||
oce.add(keys=P60OpCodes.TEST, info="P60 Tests")
|
||||
defs.add_service(
|
||||
name=CustomServiceList.P60DOCK.value, info="P60 Device", op_code_entry=oce
|
||||
)
|
||||
|
||||
|
||||
def generic_off_cmd(
|
||||
object_id: ObjectIdU32, q: DefaultPusQueueHelper, info_str: str, out_idx: int
|
||||
):
|
||||
q.add_log_cmd(info_str)
|
||||
q.add_pus_tc(
|
||||
pack_set_param_command(
|
||||
object_id.as_bytes,
|
||||
PDU_CONFIG_LIST[out_idx].parameter_address,
|
||||
PDU_CONFIG_LIST[out_idx].parameter_size,
|
||||
Channel.off,
|
||||
)
|
||||
def add_pdu1_cmds(defs: TmTcDefWrapper):
|
||||
oce = OpCodeEntry()
|
||||
oce.add(keys=Pdu1OpCodes.TCS_BOARD_ON, info="PDU1: Turn TCS board on")
|
||||
oce.add(keys=Pdu1OpCodes.TCS_BOARD_OFF, info="PDU1: Turn TCS board off")
|
||||
oce.add(keys=Pdu1OpCodes.STAR_TRACKER_ON, info="PDU1: Turn star tracker on")
|
||||
oce.add(keys=Pdu1OpCodes.STAR_TRACKER_OFF, info="PDU1: Turn star tracker off")
|
||||
oce.add(keys=Pdu1OpCodes.SUS_NOMINAL_ON, info="PDU1: Turn SUS nominal on")
|
||||
oce.add(keys=Pdu1OpCodes.SUS_NOMINAL_OFF, info="PDU1: Turn SUS nominal off")
|
||||
oce.add(keys=Pdu1OpCodes.ACS_A_SIDE_ON, info="PDU1: Turn ACS A side on")
|
||||
oce.add(keys=Pdu1OpCodes.ACS_A_SIDE_OFF, info="PDU1: Turn ACS A side off")
|
||||
oce.add(keys=Pdu1OpCodes.SYRLINKS_ON, info="PDU1: Turn Syrlinks on")
|
||||
oce.add(keys=Pdu1OpCodes.SYRLINKS_OFF, info="PDU1: Turn Syrlinks off")
|
||||
oce.add(keys=Pdu1OpCodes.MGT_ON, info="PDU1: Turn MGT on")
|
||||
oce.add(keys=Pdu1OpCodes.MGT_OFF, info="PDU1: Turn MGT off")
|
||||
oce.add(keys=Pdu1OpCodes.PLOC_ON, info="PDU1: Turn PLOC on")
|
||||
oce.add(keys=Pdu1OpCodes.PLOC_OFF, info="PDU1: Turn PLOC off")
|
||||
oce.add(keys=Pdu1OpCodes.SCEX_ON, info="PDU1: Turn Solar Cell Experiment on")
|
||||
oce.add(keys=Pdu1OpCodes.SCEX_OFF, info="PDU1: Turn Solar Cell Experiment off")
|
||||
oce.add(keys=GomspaceOpCodes.REQUEST_CORE_HK_ONCE, info=GsInfo.REQUEST_CORE_HK_ONCE)
|
||||
oce.add(keys=GomspaceOpCodes.REQUEST_AUX_HK_ONCE, info=GsInfo.REQUEST_AUX_HK_ONCE)
|
||||
oce.add(
|
||||
keys=GomspaceOpCodes.PRINT_SWITCH_V_I,
|
||||
info="PDU1: Print Switches, Voltages, Currents",
|
||||
)
|
||||
oce.add(keys=GomspaceOpCodes.PRINT_LATCHUPS, info="PDU1: Print Latchups")
|
||||
oce.add(keys=Pdu1OpCodes.TESTS, info="PDU1 Tests")
|
||||
oce.add(keys=GomspaceOpCodes.SET_PARAM, info="Set parameter")
|
||||
defs.add_service(
|
||||
name=CustomServiceList.PDU1.value,
|
||||
info="PDU1 Device",
|
||||
op_code_entry=oce,
|
||||
)
|
||||
|
||||
|
||||
def add_pdu2_cmds(defs: TmTcDefWrapper):
|
||||
oce = OpCodeEntry()
|
||||
oce.add(keys="0", info="PDU2 Tests")
|
||||
oce.add(keys=Pdu2OpCodes.ACS_SIDE_B_ON, info="PDU2: Turn ACS Side B on")
|
||||
oce.add(keys=Pdu2OpCodes.ACS_SIDE_B_OFF, info="PDU2: Turn ACS Side B off")
|
||||
oce.add(keys=Pdu2OpCodes.SUS_REDUNDANT_ON, info="PDU2: Turn SUS redundant on")
|
||||
oce.add(keys=Pdu2OpCodes.SUS_REDUNDANT_OFF, info="PDU2: Turn SUS redundant off")
|
||||
oce.add(keys=Pdu2OpCodes.RW_ON, info="PDU2: Turn reaction wheels on")
|
||||
oce.add(keys=Pdu2OpCodes.RW_OFF, info="PDU2: Turn reaction wheels off")
|
||||
oce.add(
|
||||
keys=Pdu2OpCodes.PL_PCDU_VBAT_NOM_ON,
|
||||
info="PDU2: PL PCDU Switch Channel Nominal (1) on",
|
||||
)
|
||||
oce.add(
|
||||
keys=Pdu2OpCodes.PL_PCDU_VBAT_NOM_OFF,
|
||||
info="PDU2: PL PCDU Switch Channel Nominal (1) off",
|
||||
)
|
||||
oce.add(
|
||||
keys=Pdu2OpCodes.PL_PCDU_VBAT_RED_ON,
|
||||
info="PDU2: PL PCDU Switch Channel Redundant (1) on",
|
||||
)
|
||||
oce.add(
|
||||
keys=Pdu2OpCodes.PL_PCDU_VBAT_RED_OFF,
|
||||
info="PDU2: PL PCDU Switch Channel Redundant (1) off",
|
||||
)
|
||||
oce.add(
|
||||
keys=Pdu2OpCodes.TCS_HEATER_IN_ON,
|
||||
info="PDU2: Switch TCS Heater Input on",
|
||||
)
|
||||
oce.add(
|
||||
keys=Pdu2OpCodes.TCS_HEATER_IN_OFF,
|
||||
info="PDU2: Switch TCS Heater Input off",
|
||||
)
|
||||
oce.add(
|
||||
keys=Pdu2OpCodes.SOLAR_ARRAY_DEPL_ON,
|
||||
info="PDU2: Switch Solar Array Deployment On",
|
||||
)
|
||||
oce.add(
|
||||
keys=Pdu2OpCodes.SOLAR_ARRAY_DEPL_OFF,
|
||||
info="PDU2: Switch Solar Array Deployment Off",
|
||||
)
|
||||
oce.add(
|
||||
keys=Pdu2OpCodes.PL_CAMERA_ON,
|
||||
info="PDU2: Turn payload camera on",
|
||||
)
|
||||
oce.add(
|
||||
keys=Pdu2OpCodes.PL_CAMERA_OFF,
|
||||
info="PDU2: Turn payload camera off",
|
||||
)
|
||||
oce.add(
|
||||
keys=GomspaceOpCodes.REQUEST_CORE_HK_ONCE,
|
||||
info=GsInfo.REQUEST_CORE_HK_ONCE,
|
||||
)
|
||||
oce.add(
|
||||
keys=GomspaceOpCodes.REQUEST_AUX_HK_ONCE,
|
||||
info=GsInfo.REQUEST_AUX_HK_ONCE,
|
||||
)
|
||||
oce.add(
|
||||
keys=GomspaceOpCodes.PRINT_SWITCH_V_I,
|
||||
info="PDU2: Print Switches, Voltages, Currents",
|
||||
)
|
||||
oce.add(
|
||||
keys=GomspaceOpCodes.PRINT_LATCHUPS,
|
||||
info="PDU2: Print Latchups",
|
||||
)
|
||||
defs.add_service(
|
||||
name="pdu2",
|
||||
info="PDU2 Device",
|
||||
op_code_entry=oce,
|
||||
)
|
||||
|
||||
|
||||
def add_pcdu_cmds(defs: TmTcDefWrapper):
|
||||
add_p60_cmds(defs)
|
||||
add_pdu1_cmds(defs)
|
||||
add_pdu2_cmds(defs)
|
||||
add_acu_cmds(defs)
|
||||
|
Reference in New Issue
Block a user