from eive_tmtc.config.definitions import CustomServiceList from spacepackets.ecss import PusTelecommand from tmtccmd.config.tmtc import ( tmtc_definitions_provider, TmtcDefinitionWrapper, OpCodeEntry, ) from tmtccmd.tc import service_provider from tmtccmd.pus.s201_fsfw_health import Subservice from tmtccmd.tc.decorator import ServiceProviderParams class OpCode: ANNOUNCE_HEALTH_ALL = "read_health_all" ANNOUNCE_HEALTH = "read_health" class Info: ANNOUNCE_HEALTH_ALL = "Read all health states" ANNOUNCE_HEALTH = "Read health state of one object" @service_provider(CustomServiceList.HEALTH) def pack_test_command(p: ServiceProviderParams): o = p.op_code q = p.queue_helper if o == OpCode.ANNOUNCE_HEALTH: raise NotImplementedError() elif o == 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) ) return raise ValueError(f"unknown op code {o} 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) defs.add_service(CustomServiceList.HEALTH, info="Health Service", op_code_entry=oce)