127 lines
3.4 KiB
Python
127 lines
3.4 KiB
Python
|
import enum
|
||
|
|
||
|
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
|
||
|
|
||
|
|
||
|
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 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,
|
||
|
)
|
||
|
)
|