histogram set working
All checks were successful
EIVE/-/pipeline/pr-main This commit looks good

This commit is contained in:
Robin Müller 2023-10-27 10:36:51 +02:00
parent d9530271c3
commit 2ca7bc5a70
Signed by: muellerr
GPG Key ID: A649FB78196E3849

View File

@ -108,7 +108,7 @@ class OpCodes:
NORMAL = "nml" NORMAL = "nml"
OFF = "off" OFF = "off"
PING = "ping" PING = "ping"
ONE_SHOOT_HK = "one_shoot_hk" ONE_SHOOT_HK = "one_shot_hk"
ENABLE_HK = "enable_hk" ENABLE_HK = "enable_hk"
DISABLE_HK = "disable_hk" DISABLE_HK = "disable_hk"
ADD_SECONDARY_TM_TO_NORMAL_MODE = "add_secondary_tm" ADD_SECONDARY_TM_TO_NORMAL_MODE = "add_secondary_tm"
@ -674,75 +674,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: for val in SetId:
print("{:<2}: {:<20}".format(val, val.name)) print("{:<2}: {:<20}".format(val, val.name))
setId = int(input("Specify the dataset \n" "")) set_id = int(input("Specify the dataset \n" ""))
match type: if set_id in [SetId.SOLUTION, SetId.TEMPERATURE]:
is_diag = True
else:
is_diag = False
match req_type:
case DataSetRequest.ONESHOT: case DataSetRequest.ONESHOT:
if setId in [ if is_diag:
SetId.SOLUTION,
SetId.TEMPERATURE,
]:
q.add_pus_tc( q.add_pus_tc(
create_request_one_diag_command(make_sid(STAR_TRACKER_ID, setId)) create_request_one_diag_command(make_sid(STAR_TRACKER_ID, set_id))
)
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))
) )
else: else:
print("Not Implemented Yet") q.add_pus_tc(
create_request_one_hk_command(make_sid(STAR_TRACKER_ID, set_id))
)
case DataSetRequest.ENABLE: case DataSetRequest.ENABLE:
interval = float( interval = float(
input("Please specify interval in floating point seconds: ") input("Please specify interval in floating point seconds: ")
) )
if setId in [SetId.SOLUTION]:
if is_diag:
cmd_tuple = enable_periodic_hk_command_with_interval( 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: 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: case DataSetRequest.DISABLE:
if setId in [SetId.SOLUTION]: if is_diag:
q.add_pus_tc( q.add_pus_tc(
disable_periodic_hk_command(True, make_sid(STAR_TRACKER_ID, setId)) disable_periodic_hk_command(True, make_sid(STAR_TRACKER_ID, set_id))
)
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))
) )
else: 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: def pack_read_command(object_id: bytes) -> bytearray:
@ -1098,23 +1073,23 @@ def handle_histogram_set(hk_data: bytes, pw: PrintWrapper):
d_bins = struct.unpack(fmt_str, hk_data[current_idx : current_idx + inc_len]) d_bins = struct.unpack(fmt_str, hk_data[current_idx : current_idx + inc_len])
bins_list.append(d_bins) bins_list.append(d_bins)
pw.dlog( pw.dlog(
"{:<8} {:<8} {:<8} {:<8} {:<8} {:<8} {:<8} {:<8} {:<8} {:<8} {:<8}".format( "Histogram Sections: A Upper Left | B Upper Right | C Lower Left | D Lower Right"
"Section", "Index", "0", "1", "2", "3", "4", "5", "6", "7", "8"
)
) )
for idx in range(4): pw.dlog("{:<12} {:<8} {:<8} {:<8} {:<8}".format("Range", "A", "B", "C", "D"))
name = "?" for idx in range(9):
if idx == 0: if idx == 0:
name = "A" val_range = "0 (0-0)"
if idx == 1: elif idx == 1:
name = "B" val_range = "1 (1-1)"
if idx == 2: else:
name = "C" val_range = f"{idx} ({pow(2, idx - 1)}-{pow(2, idx) - 1})"
if idx == 3:
name = "D"
pw.dlog( pw.dlog(
"{:<8} {:<8} {:<8} {:<8} {:<8} {:<8} {:<8} {:<8} {:<8} {:<8}".format( "{:<12} {:<8} {:<8} {:<8} {:<8}".format(
name, idx, *bins_list[idx] val_range,
bins_list[0][idx],
bins_list[1][idx],
bins_list[2][idx],
bins_list[3][idx],
) )
) )
pass pass