Compare commits
2 Commits
d9530271c3
...
5821c60eb4
Author | SHA1 | Date | |
---|---|---|---|
5821c60eb4
|
|||
2ca7bc5a70
|
@@ -108,7 +108,7 @@ class OpCodes:
|
||||
NORMAL = "nml"
|
||||
OFF = "off"
|
||||
PING = "ping"
|
||||
ONE_SHOOT_HK = "one_shoot_hk"
|
||||
ONE_SHOOT_HK = "one_shot_hk"
|
||||
ENABLE_HK = "enable_hk"
|
||||
DISABLE_HK = "disable_hk"
|
||||
ADD_SECONDARY_TM_TO_NORMAL_MODE = "add_secondary_tm"
|
||||
@@ -142,6 +142,7 @@ class SetId(enum.IntEnum):
|
||||
TEMPERATURE = 25
|
||||
SOLUTION = 24
|
||||
HISTOGRAM = 28
|
||||
CONTRAST = 29
|
||||
CHECKSUM = 50
|
||||
CAMERA = 67
|
||||
LIMITS = 68
|
||||
@@ -674,75 +675,50 @@ def pack_star_tracker_commands( # noqa C901
|
||||
)
|
||||
|
||||
|
||||
def request_dataset(q: DefaultPusQueueHelper, type: DataSetRequest):
|
||||
def request_dataset(q: DefaultPusQueueHelper, req_type: DataSetRequest):
|
||||
for val in SetId:
|
||||
print("{:<2}: {:<20}".format(val, val.name))
|
||||
setId = int(input("Specify the dataset \n" ""))
|
||||
match type:
|
||||
set_id = int(input("Specify the dataset \n" ""))
|
||||
if set_id in [SetId.SOLUTION, SetId.TEMPERATURE]:
|
||||
is_diag = True
|
||||
else:
|
||||
is_diag = False
|
||||
match req_type:
|
||||
case DataSetRequest.ONESHOT:
|
||||
if setId in [
|
||||
SetId.SOLUTION,
|
||||
SetId.TEMPERATURE,
|
||||
]:
|
||||
if is_diag:
|
||||
q.add_pus_tc(
|
||||
create_request_one_diag_command(make_sid(STAR_TRACKER_ID, setId))
|
||||
)
|
||||
elif setId in [
|
||||
SetId.AUTO_BLOB,
|
||||
SetId.MATCHED_CENTROIDS,
|
||||
SetId.BLOB,
|
||||
SetId.BLOBS,
|
||||
SetId.CENTROID,
|
||||
SetId.CENTROIDS,
|
||||
]:
|
||||
q.add_pus_tc(
|
||||
create_request_one_hk_command(make_sid(STAR_TRACKER_ID, setId))
|
||||
create_request_one_diag_command(make_sid(STAR_TRACKER_ID, set_id))
|
||||
)
|
||||
else:
|
||||
print("Not Implemented Yet")
|
||||
q.add_pus_tc(
|
||||
create_request_one_hk_command(make_sid(STAR_TRACKER_ID, set_id))
|
||||
)
|
||||
case DataSetRequest.ENABLE:
|
||||
interval = float(
|
||||
input("Please specify interval in floating point seconds: ")
|
||||
)
|
||||
if setId in [SetId.SOLUTION]:
|
||||
|
||||
if is_diag:
|
||||
cmd_tuple = enable_periodic_hk_command_with_interval(
|
||||
True, make_sid(STAR_TRACKER_ID, setId), interval
|
||||
True, make_sid(STAR_TRACKER_ID, set_id), interval
|
||||
)
|
||||
q.add_pus_tc(cmd_tuple[0])
|
||||
q.add_pus_tc(cmd_tuple[1])
|
||||
elif setId in [
|
||||
SetId.AUTO_BLOB,
|
||||
SetId.MATCHED_CENTROIDS,
|
||||
SetId.BLOB,
|
||||
SetId.BLOBS,
|
||||
SetId.CENTROID,
|
||||
SetId.CENTROIDS,
|
||||
]:
|
||||
cmd_tuple = enable_periodic_hk_command_with_interval(
|
||||
False, make_sid(STAR_TRACKER_ID, setId), interval
|
||||
)
|
||||
q.add_pus_tc(cmd_tuple[0])
|
||||
q.add_pus_tc(cmd_tuple[1])
|
||||
else:
|
||||
print("Not Implemented Yet")
|
||||
cmd_tuple = enable_periodic_hk_command_with_interval(
|
||||
False, make_sid(STAR_TRACKER_ID, set_id), interval
|
||||
)
|
||||
q.add_pus_tc(cmd_tuple[0])
|
||||
q.add_pus_tc(cmd_tuple[1])
|
||||
case DataSetRequest.DISABLE:
|
||||
if setId in [SetId.SOLUTION]:
|
||||
if is_diag:
|
||||
q.add_pus_tc(
|
||||
disable_periodic_hk_command(True, make_sid(STAR_TRACKER_ID, setId))
|
||||
)
|
||||
elif setId in [
|
||||
SetId.AUTO_BLOB,
|
||||
SetId.MATCHED_CENTROIDS,
|
||||
SetId.BLOB,
|
||||
SetId.BLOBS,
|
||||
SetId.CENTROID,
|
||||
SetId.CENTROIDS,
|
||||
]:
|
||||
q.add_pus_tc(
|
||||
disable_periodic_hk_command(False, make_sid(STAR_TRACKER_ID, setId))
|
||||
disable_periodic_hk_command(True, make_sid(STAR_TRACKER_ID, set_id))
|
||||
)
|
||||
else:
|
||||
print("Not Implemented Yet")
|
||||
q.add_pus_tc(
|
||||
disable_periodic_hk_command(
|
||||
False, make_sid(STAR_TRACKER_ID, set_id)
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
def pack_read_command(object_id: bytes) -> bytearray:
|
||||
@@ -826,6 +802,8 @@ def handle_str_hk_data(set_id: int, hk_data: bytes, pw: PrintWrapper):
|
||||
handle_centroid_set(hk_data, pw)
|
||||
elif set_id == SetId.CENTROIDS:
|
||||
handle_centroids_set(hk_data, pw)
|
||||
elif set_id == SetId.CONTRAST:
|
||||
handle_contrast_set(hk_data, pw)
|
||||
else:
|
||||
_LOGGER.warning(f"HK parsing for Star Tracker set ID {set_id} unimplemented")
|
||||
|
||||
@@ -1075,13 +1053,14 @@ def handle_auto_blob_set(hk_data: bytes, pw: PrintWrapper):
|
||||
threshold = struct.unpack(
|
||||
fmt_threshold, hk_data[current_idx : current_idx + inc_len]
|
||||
)[0]
|
||||
pw.dlog(f"Threshold {threshold}")
|
||||
current_idx += inc_len
|
||||
assert current_idx == len(hk_data) - 1
|
||||
pw.dlog(f"Threshold {threshold}")
|
||||
FsfwTmTcPrinter.get_validity_buffer(hk_data[current_idx:], num_vars=3)
|
||||
|
||||
|
||||
def handle_histogram_set(hk_data: bytes, pw: PrintWrapper):
|
||||
pw.dlog("Received Histogram Set")
|
||||
def handle_histo_or_contrast_set(name: str, hk_data: bytes, pw: PrintWrapper):
|
||||
pw.dlog(f"Received {name} Set")
|
||||
current_idx = unpack_time_hk(hk_data, 0, pw)
|
||||
fmt_str = "!IIIIIIIII"
|
||||
bins_list = []
|
||||
@@ -1098,26 +1077,33 @@ def handle_histogram_set(hk_data: bytes, pw: PrintWrapper):
|
||||
d_bins = struct.unpack(fmt_str, hk_data[current_idx : current_idx + inc_len])
|
||||
bins_list.append(d_bins)
|
||||
pw.dlog(
|
||||
"{:<8} {:<8} {:<8} {:<8} {:<8} {:<8} {:<8} {:<8} {:<8} {:<8} {:<8}".format(
|
||||
"Section", "Index", "0", "1", "2", "3", "4", "5", "6", "7", "8"
|
||||
)
|
||||
f"{name} Sections: A Upper Left | B Upper Right | C Lower Left | D Lower Right"
|
||||
)
|
||||
for idx in range(4):
|
||||
name = "?"
|
||||
pw.dlog("{:<12} {:<10} {:<10} {:<10} {:<10}".format("Range", "A", "B", "C", "D"))
|
||||
for idx in range(9):
|
||||
if idx == 0:
|
||||
name = "A"
|
||||
if idx == 1:
|
||||
name = "B"
|
||||
if idx == 2:
|
||||
name = "C"
|
||||
if idx == 3:
|
||||
name = "D"
|
||||
val_range = "0 (0-0)"
|
||||
elif idx == 1:
|
||||
val_range = "1 (1-1)"
|
||||
else:
|
||||
val_range = f"{idx} ({pow(2, idx - 1)}-{pow(2, idx) - 1})"
|
||||
pw.dlog(
|
||||
"{:<8} {:<8} {:<8} {:<8} {:<8} {:<8} {:<8} {:<8} {:<8} {:<8}".format(
|
||||
name, idx, *bins_list[idx]
|
||||
"{:<12} {:<10} {:<10} {:<10} {:<10}".format(
|
||||
val_range,
|
||||
bins_list[0][idx],
|
||||
bins_list[1][idx],
|
||||
bins_list[2][idx],
|
||||
bins_list[3][idx],
|
||||
)
|
||||
)
|
||||
pass
|
||||
|
||||
|
||||
def handle_histogram_set(hk_data: bytes, pw: PrintWrapper):
|
||||
handle_histo_or_contrast_set("Histogram", hk_data, pw)
|
||||
|
||||
|
||||
def handle_contrast_set(hk_data: bytes, pw: PrintWrapper):
|
||||
handle_histo_or_contrast_set("Contrast", hk_data, pw)
|
||||
|
||||
|
||||
def handle_star_tracker_action_replies(
|
||||
|
Reference in New Issue
Block a user