add health set and announce health impl

This commit is contained in:
Robin Müller 2023-03-06 13:09:28 +01:00
parent 7f872c92c4
commit f18a7f49cf
No known key found for this signature in database
GPG Key ID: 11D4952C8CCEF814
2 changed files with 29 additions and 4 deletions

View File

@ -1,4 +1,7 @@
import struct
from eive_tmtc.config.definitions import CustomServiceList from eive_tmtc.config.definitions import CustomServiceList
from eive_tmtc.tmtc.obj_prompt import prompt_object
from spacepackets.ecss import PusTelecommand from spacepackets.ecss import PusTelecommand
from tmtccmd.config.tmtc import ( from tmtccmd.config.tmtc import (
tmtc_definitions_provider, tmtc_definitions_provider,
@ -6,7 +9,7 @@ from tmtccmd.config.tmtc import (
OpCodeEntry, OpCodeEntry,
) )
from tmtccmd.tc import service_provider from tmtccmd.tc import service_provider
from tmtccmd.pus.s201_fsfw_health import Subservice from tmtccmd.pus.s201_fsfw_health import Subservice, FsfwHealth
from tmtccmd.tc.decorator import ServiceProviderParams from tmtccmd.tc.decorator import ServiceProviderParams
@ -22,14 +25,35 @@ class Info:
ANNOUNCE_HEALTH = "Read health state of one object" ANNOUNCE_HEALTH = "Read health state of one object"
def prompt_health() -> FsfwHealth:
for item in FsfwHealth:
print(f"{item}: {item.name}")
health_idx = input("Please enter health by index: ")
return FsfwHealth(health_idx)
@service_provider(CustomServiceList.HEALTH) @service_provider(CustomServiceList.HEALTH)
def pack_test_command(p: ServiceProviderParams): def pack_test_command(p: ServiceProviderParams):
o = p.op_code o = p.op_code
q = p.queue_helper q = p.queue_helper
if o == OpCode.SET_HEALTH: if o == OpCode.SET_HEALTH:
raise NotImplementedError app_data = bytearray(prompt_object())
health = prompt_health()
app_data.extend(struct.pack("!I", health))
q.add_log_cmd(Info.SET_HEALTH)
q.add_pus_tc(
PusTelecommand(
service=201, subservice=Subservice.TC_SET_HEALTH, app_data=app_data
)
)
if o == OpCode.ANNOUNCE_HEALTH: if o == OpCode.ANNOUNCE_HEALTH:
raise NotImplementedError app_data = bytearray(prompt_object())
q.add_log_cmd(Info.ANNOUNCE_HEALTH)
q.add_pus_tc(
PusTelecommand(
service=201, subservice=Subservice.TC_ANNOUNCE_HEALTH, app_data=app_data
)
)
elif o == OpCode.ANNOUNCE_HEALTH_ALL: elif o == OpCode.ANNOUNCE_HEALTH_ALL:
q.add_log_cmd(Info.ANNOUNCE_HEALTH_ALL) q.add_log_cmd(Info.ANNOUNCE_HEALTH_ALL)
q.add_pus_tc( q.add_pus_tc(

View File

@ -4,7 +4,7 @@ from eive_tmtc.config.object_ids import (
IMTQ_HANDLER_ID, IMTQ_HANDLER_ID,
ACS_BOARD_ASS_ID, ACS_BOARD_ASS_ID,
RW_ASSEMBLY, RW_ASSEMBLY,
SUS_BOARD_ASS_ID SUS_BOARD_ASS_ID,
) )
SUBSYSTEM_DICT = { SUBSYSTEM_DICT = {
@ -21,6 +21,7 @@ ACS_OBJ_DICT = {
4: ("iMTQ MGT", IMTQ_HANDLER_ID), 4: ("iMTQ MGT", IMTQ_HANDLER_ID),
} }
def prompt_object() -> bytes: def prompt_object() -> bytes:
for k, v in SUBSYSTEM_DICT: for k, v in SUBSYSTEM_DICT:
print(f"{k}: {v}") print(f"{k}: {v}")