OOF3
All checks were successful
EIVE/-/pipeline/head This commit looks good

This commit is contained in:
2023-11-22 13:51:33 +01:00
parent 02d9d6adfc
commit d640d547bd
15 changed files with 300 additions and 347 deletions

View File

@ -1,14 +1,12 @@
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,
TmtcDefinitionWrapper,
OpCodeEntry,
CmdTreeNode,
)
from tmtccmd.tmtc import service_provider
from tmtccmd.pus.s201_fsfw_health import Subservice, FsfwHealth
from tmtccmd.tmtc.decorator import ServiceProviderParams
from tmtccmd.pus.s201_fsfw_health import FsfwHealth, Subservice
from tmtccmd.tmtc import DefaultPusQueueHelper
from eive_tmtc.config.definitions import CustomServiceList
from eive_tmtc.tmtc.obj_prompt import prompt_object
class OpCode:
@ -30,11 +28,8 @@ def prompt_health() -> FsfwHealth:
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:
def pack_health_cmd(q: DefaultPusQueueHelper, cmd_str: str):
if cmd_str == OpCode.SET_HEALTH:
app_data = bytearray(prompt_object())
health = prompt_health()
app_data.append(health)
@ -44,7 +39,7 @@ def pack_test_command(p: ServiceProviderParams):
service=201, subservice=Subservice.TC_SET_HEALTH, app_data=app_data
)
)
elif o == OpCode.ANNOUNCE_HEALTH:
elif cmd_str == OpCode.ANNOUNCE_HEALTH:
app_data = bytearray(prompt_object())
q.add_log_cmd(Info.ANNOUNCE_HEALTH)
q.add_pus_tc(
@ -52,19 +47,22 @@ def pack_test_command(p: ServiceProviderParams):
service=201, subservice=Subservice.TC_ANNOUNCE_HEALTH, app_data=app_data
)
)
elif o == OpCode.ANNOUNCE_HEALTH_ALL:
elif cmd_str == OpCode.ANNOUNCE_HEALTH_ALL:
q.add_log_cmd(Info.ANNOUNCE_HEALTH_ALL)
q.add_pus_tc(
PusTelecommand(service=201, subservice=Subservice.TC_ANNOUNCE_HEALTH_ALL)
)
else:
raise ValueError(f"unknown op code {o} for service {CustomServiceList.HEALTH}")
raise ValueError(
f"unknown command string {cmd_str} for service {CustomServiceList.HEALTH}"
)
@tmtc_definitions_provider
def add_health_cmd_defs(defs: TmtcDefinitionWrapper):
oce = OpCodeEntry()
oce.add(OpCode.ANNOUNCE_HEALTH_ALL, Info.ANNOUNCE_HEALTH_ALL)
oce.add(OpCode.ANNOUNCE_HEALTH, Info.ANNOUNCE_HEALTH)
oce.add(OpCode.SET_HEALTH, Info.SET_HEALTH)
defs.add_service(CustomServiceList.HEALTH, info="Health Service", op_code_entry=oce)
def create_global_health_node() -> CmdTreeNode:
health_node = CmdTreeNode("health", "Health Commands")
health_node.add_child(
CmdTreeNode(OpCode.ANNOUNCE_HEALTH_ALL, Info.ANNOUNCE_HEALTH_ALL)
)
health_node.add_child(CmdTreeNode(OpCode.ANNOUNCE_HEALTH, Info.ANNOUNCE_HEALTH))
health_node.add_child(CmdTreeNode(OpCode.SET_HEALTH, Info.SET_HEALTH))
return health_node