add health set and announce health impl
This commit is contained in:
parent
7f872c92c4
commit
f18a7f49cf
@ -1,4 +1,7 @@
|
||||
import struct
|
||||
|
||||
from eive_tmtc.config.definitions import CustomServiceList
|
||||
from eive_tmtc.tmtc.obj_prompt import prompt_object
|
||||
from spacepackets.ecss import PusTelecommand
|
||||
from tmtccmd.config.tmtc import (
|
||||
tmtc_definitions_provider,
|
||||
@ -6,7 +9,7 @@ from tmtccmd.config.tmtc import (
|
||||
OpCodeEntry,
|
||||
)
|
||||
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
|
||||
|
||||
|
||||
@ -22,14 +25,35 @@ class Info:
|
||||
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)
|
||||
def pack_test_command(p: ServiceProviderParams):
|
||||
o = p.op_code
|
||||
q = p.queue_helper
|
||||
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:
|
||||
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:
|
||||
q.add_log_cmd(Info.ANNOUNCE_HEALTH_ALL)
|
||||
q.add_pus_tc(
|
||||
|
@ -4,7 +4,7 @@ from eive_tmtc.config.object_ids import (
|
||||
IMTQ_HANDLER_ID,
|
||||
ACS_BOARD_ASS_ID,
|
||||
RW_ASSEMBLY,
|
||||
SUS_BOARD_ASS_ID
|
||||
SUS_BOARD_ASS_ID,
|
||||
)
|
||||
|
||||
SUBSYSTEM_DICT = {
|
||||
@ -21,6 +21,7 @@ ACS_OBJ_DICT = {
|
||||
4: ("iMTQ MGT", IMTQ_HANDLER_ID),
|
||||
}
|
||||
|
||||
|
||||
def prompt_object() -> bytes:
|
||||
for k, v in SUBSYSTEM_DICT:
|
||||
print(f"{k}: {v}")
|
||||
|
Loading…
Reference in New Issue
Block a user