79 lines
2.2 KiB
Python
79 lines
2.2 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""
|
|
@file tmp1075.py
|
|
@brief TMP1075 tests
|
|
@author J. Meier
|
|
@date 06.01.2021
|
|
"""
|
|
import enum
|
|
|
|
from eive_tmtc.config.definitions import CustomServiceList
|
|
from spacepackets.ecss.tc import PusTelecommand
|
|
from tmtccmd.config.tmtc import (
|
|
tmtc_definitions_provider,
|
|
TmtcDefinitionWrapper,
|
|
OpCodeEntry,
|
|
)
|
|
from tmtccmd.tc import DefaultPusQueueHelper
|
|
from tmtccmd.tc.pus_200_fsfw_mode import Mode, pack_mode_data
|
|
from tmtccmd.tc.pus_3_fsfw_hk import create_request_one_hk_command, make_sid
|
|
from tmtccmd.util import ObjectIdU32
|
|
|
|
|
|
class OpCode:
|
|
OFF = "off"
|
|
ON = "on"
|
|
NML = "nml"
|
|
HK = "hk"
|
|
|
|
|
|
class Info:
|
|
OFF = "Off"
|
|
ON = "On"
|
|
NML = "Normal"
|
|
HK = "HK"
|
|
|
|
|
|
class Tmp1075ActionId(enum.IntEnum):
|
|
GET_TEMP = 1
|
|
START_ADC_CONV = 2
|
|
|
|
|
|
class SetId(enum.IntEnum):
|
|
TEMPERATURE = 1
|
|
|
|
|
|
def pack_tmp1075_test_into(
|
|
object_id: ObjectIdU32, op_code: str, q: DefaultPusQueueHelper
|
|
):
|
|
q.add_log_cmd(
|
|
f"Testing Tmp1075 Temperature Sensor Handler with object id: {object_id}"
|
|
)
|
|
obyt = object_id.as_bytes
|
|
if op_code == OpCode.OFF:
|
|
q.add_log_cmd("TMP1075: Set Normal Off")
|
|
mode_data = pack_mode_data(obyt, Mode.OFF, 0)
|
|
q.add_pus_tc(PusTelecommand(service=200, subservice=1, app_data=mode_data))
|
|
if op_code == OpCode.NML:
|
|
q.add_log_cmd("TMP1075: Set Mode Normal")
|
|
mode_data = pack_mode_data(obyt, Mode.NORMAL, 0)
|
|
q.add_pus_tc(PusTelecommand(service=200, subservice=1, app_data=mode_data))
|
|
if op_code == OpCode.ON:
|
|
q.add_log_cmd("TMP1075: Set Mode On")
|
|
mode_data = pack_mode_data(obyt, Mode.ON, 0)
|
|
q.add_pus_tc(PusTelecommand(service=200, subservice=1, app_data=mode_data))
|
|
if op_code == OpCode.HK:
|
|
q.add_log_cmd("TMP1075: Request One-Shot HK")
|
|
q.add_pus_tc(create_request_one_hk_command(make_sid(obyt, SetId.TEMPERATURE)))
|
|
return q
|
|
|
|
|
|
@tmtc_definitions_provider
|
|
def add_tmp_sens_cmds(defs: TmtcDefinitionWrapper):
|
|
oce = OpCodeEntry()
|
|
oce.add(OpCode.OFF, Info.OFF)
|
|
oce.add(OpCode.ON, Info.ON)
|
|
oce.add(OpCode.NML, Info.NML)
|
|
oce.add(OpCode.HK, Info.HK)
|
|
defs.add_service(CustomServiceList.TMP1075.value, "TMP1075 Temperature Sensor", oce)
|