added retrieval by time range impl

This commit is contained in:
Robin Müller 2023-02-20 15:57:38 +01:00
parent 6a6d9c0a7a
commit 8f5f7064e9
No known key found for this signature in database
GPG Key ID: 11D4952C8CCEF814

View File

@ -45,15 +45,12 @@ def pack_tm_store_commands(p: ServiceProviderParams):
if o == OpCode.DELETE_UP_TO:
obj_id, store_string = store_select_prompt()
app_data = bytearray(obj_id.as_bytes)
delete_up_to_time = time_prompt()
delete_up_to_time = time_prompt("Determining deletion end time")
end_stamp = int(math.floor(delete_up_to_time.timestamp()))
app_data.extend(struct.pack("!I", end_stamp))
q.add_log_cmd(Info.DELETE_UP_TO)
q.add_log_cmd(f"Selected Store: {obj_id}")
q.add_log_cmd(
f"Deletion up to time "
f"{datetime.datetime.fromtimestamp(end_stamp, tz=datetime.timezone.utc)}"
)
q.add_log_cmd(f"Deletion up to time {delete_up_to_time}")
q.add_pus_tc(
PusTelecommand(
service=15, subservice=Subservice.DELETE_UP_TO, app_data=app_data
@ -61,7 +58,26 @@ def pack_tm_store_commands(p: ServiceProviderParams):
)
elif o == OpCode.RETRIEVAL_BY_TIME_RANGE:
q.add_log_cmd(Info.RETRIEVAL_BY_TIME_RANGE)
pass
obj_id, store_string = store_select_prompt()
app_data = bytearray(obj_id.as_bytes)
start_of_dump_time = time_prompt("Determining retrival start time")
start_stamp = int(math.floor(start_of_dump_time.timestamp()))
end_of_dump_time = time_prompt("Determining retrieval end time")
end_stamp = int(math.floor(end_of_dump_time.timestamp()))
app_data.extend(struct.pack("!I", start_stamp))
app_data.extend(struct.pack("!I", end_stamp))
q.add_log_cmd(Info.RETRIEVAL_BY_TIME_RANGE)
q.add_log_cmd(f"Selected Store: {obj_id}")
q.add_log_cmd(
f"Retrieval from time {start_of_dump_time} up to time {end_of_dump_time}"
)
q.add_pus_tc(
PusTelecommand(
service=15,
subservice=Subservice.RETRIEVAL_BY_TIME_RANGE,
app_data=app_data,
)
)
@tmtc_definitions_provider
@ -100,8 +116,8 @@ TIME_INPUT_DICT = {
}
def time_prompt() -> datetime.datetime:
print("Available time input types: ")
def time_prompt(info_str: str) -> datetime.datetime:
print(f"{info_str}. Available time input types: ")
for k, v in TIME_INPUT_DICT.items():
print(f" {k}: {v}")
while True: