eive-tmtc/eive_tmtc/pus_tc/system/time.py

30 lines
1003 B
Python
Raw Normal View History

2022-04-09 18:44:04 +02:00
from datetime import datetime
2022-11-29 16:53:29 +01:00
from eive_tmtc.config.definitions import CustomServiceList
2022-04-09 18:44:04 +02:00
from spacepackets.ecss import PusTelecommand
2022-08-18 14:08:05 +02:00
from tmtccmd import DefaultProcedureInfo, TcHandlerBase
2022-04-09 18:44:04 +02:00
from tmtccmd.logging import get_console_logger
2022-08-12 22:33:16 +02:00
from tmtccmd.tc import DefaultPusQueueHelper, service_provider
2022-08-18 14:08:05 +02:00
from tmtccmd.tc.decorator import ServiceProviderParams
2022-04-09 18:44:04 +02:00
LOGGER = get_console_logger()
2023-01-16 14:13:06 +01:00
class OpCode:
2022-04-09 18:44:04 +02:00
SET_CURRENT_TIME = ["0", "set-curr-time"]
class Info:
SET_CURRENT_TIME = "Setting current time in ASCII format"
2022-08-12 22:33:16 +02:00
@service_provider(CustomServiceList.TIME.value)
2022-08-18 14:08:05 +02:00
def pack_set_current_time_ascii_command(p: ServiceProviderParams):
q = p.queue_helper
2022-04-09 18:44:04 +02:00
time_test_current_time = datetime.utcnow().isoformat() + "Z" + "\0"
current_time_ascii = time_test_current_time.encode("ascii")
LOGGER.info(f"Current time in ASCII format: {current_time_ascii}")
2022-07-04 17:59:09 +02:00
q.add_log_cmd(Info.SET_CURRENT_TIME)
q.add_pus_tc(PusTelecommand(service=9, subservice=128, app_data=current_time_ascii))