2022-10-13 18:04:35 +02:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
"""
|
|
|
|
@file solar_array_deployment.py
|
|
|
|
@brief The test function in this file simply returns a command which triggers the solar array deployment.
|
|
|
|
@author J. Meier
|
|
|
|
@date 15.02.2021
|
|
|
|
"""
|
|
|
|
import struct
|
|
|
|
|
2023-01-18 11:32:21 +01:00
|
|
|
from eive_tmtc.config.definitions import CustomServiceList
|
|
|
|
from eive_tmtc.config.object_ids import SOLAR_ARRAY_DEPLOYMENT_ID
|
2022-10-13 18:04:35 +02:00
|
|
|
from tmtccmd.config.tmtc import (
|
|
|
|
tmtc_definitions_provider,
|
|
|
|
TmtcDefinitionWrapper,
|
|
|
|
OpCodeEntry,
|
|
|
|
)
|
|
|
|
from tmtccmd.tc import service_provider
|
2023-01-18 11:32:21 +01:00
|
|
|
from tmtccmd.pus.s8_fsfw_funccmd import create_action_cmd
|
2022-10-13 18:04:35 +02:00
|
|
|
from tmtccmd.tc.decorator import ServiceProviderParams
|
|
|
|
from tmtccmd import get_console_logger
|
|
|
|
|
|
|
|
LOGGER = get_console_logger()
|
|
|
|
|
|
|
|
|
2023-01-16 14:18:15 +01:00
|
|
|
class OpCode:
|
2022-10-13 18:04:35 +02:00
|
|
|
MANUAL_DEPLOYMENT = "man_depl"
|
|
|
|
|
|
|
|
|
|
|
|
class Info:
|
|
|
|
MANUAL_DEPLOYMENT = "Manual Solar Array Deployment"
|
|
|
|
|
|
|
|
|
2023-01-16 14:18:15 +01:00
|
|
|
class ActionId:
|
2022-10-13 18:04:35 +02:00
|
|
|
MANUAL_DEPLOYMENT = 5
|
|
|
|
|
|
|
|
|
|
|
|
@tmtc_definitions_provider
|
2023-01-19 13:11:28 +01:00
|
|
|
def add_sa_depl_cmds(defs: TmtcDefinitionWrapper):
|
2022-10-13 18:04:35 +02:00
|
|
|
oce = OpCodeEntry()
|
2023-01-16 14:18:15 +01:00
|
|
|
oce.add(keys=OpCode.MANUAL_DEPLOYMENT, info=Info.MANUAL_DEPLOYMENT)
|
2022-10-13 18:04:35 +02:00
|
|
|
defs.add_service(
|
|
|
|
name=CustomServiceList.SA_DEPLYOMENT,
|
|
|
|
info="Solar Array Deployment",
|
|
|
|
op_code_entry=oce,
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
@service_provider(CustomServiceList.SA_DEPLYOMENT)
|
|
|
|
def pack_solar_array_deployment_test_into(p: ServiceProviderParams):
|
|
|
|
q = p.queue_helper
|
|
|
|
user_data = bytearray()
|
|
|
|
while True:
|
|
|
|
burn_time = int(input("Please specify burn time in seconds [0-120 secs]: "))
|
|
|
|
if burn_time < 0 or burn_time > 120:
|
|
|
|
LOGGER.warning(f"Invalid burn time {burn_time}")
|
|
|
|
continue
|
|
|
|
user_data.extend(struct.pack("!I", burn_time))
|
|
|
|
break
|
|
|
|
while True:
|
|
|
|
dry_run = input("Dry run? [y/n]: ")
|
|
|
|
if dry_run in ["yes", "y", "1"]:
|
|
|
|
dry_run = 1
|
|
|
|
elif dry_run in ["no", "n", "0"]:
|
|
|
|
dry_run = 0
|
|
|
|
else:
|
|
|
|
LOGGER.warning("Invalid input for dry run parameter")
|
|
|
|
continue
|
|
|
|
user_data.append(dry_run)
|
|
|
|
break
|
|
|
|
if dry_run == 1:
|
|
|
|
dry_run_str = " as dry run"
|
|
|
|
else:
|
|
|
|
dry_run_str = ""
|
|
|
|
q.add_log_cmd(f"Testing S/A Deployment with burn time {burn_time}{dry_run_str}")
|
2023-01-18 11:32:21 +01:00
|
|
|
command = create_action_cmd(
|
2023-01-16 14:18:15 +01:00
|
|
|
SOLAR_ARRAY_DEPLOYMENT_ID, ActionId.MANUAL_DEPLOYMENT, user_data
|
2022-10-13 18:04:35 +02:00
|
|
|
)
|
|
|
|
q.add_pus_tc(command)
|