39 lines
1.4 KiB
Python
39 lines
1.4 KiB
Python
def bml_display_current_settings(selected_components=None):
|
|
# Displays parameters for selected components.
|
|
# - Uses select_components() to choose components.
|
|
# - Prints each parameter with its value.
|
|
# - If a parameter value is missing or cannot be read, prints NaN.
|
|
|
|
# 1 Get the selected component
|
|
selection = select_components(selected_components)
|
|
if selection is None:
|
|
return # user cancelled or invalid input
|
|
|
|
# 2 Load the machine poarametrers JSON
|
|
try:
|
|
with open(BEAMLINE_PARAMETERS_FILE, "r") as f:
|
|
machine_parameters = json.load(f, object_pairs_hook=OrderedDict)
|
|
except:
|
|
print("Error loading machine_parameters.json")
|
|
return
|
|
|
|
# 3 Loop through the components and display their parameters
|
|
for comp in selection:
|
|
print("\nComponent: " + comp)
|
|
params = machine_parameters.get(comp, {})
|
|
if not params:
|
|
print(" No parameters found.")
|
|
continue
|
|
|
|
for key, param_info in params.items():
|
|
|
|
# param_info enthalt z.B. den read_cmd
|
|
read_cmd = param_info.get("read_cmd") # JSON muss fur jeden Parameter den entsprechenden Befehl enthalten
|
|
|
|
try:
|
|
display_value = caget(read_cmd)
|
|
print(key + " = " + str(display_value))
|
|
except:
|
|
display_value = "NaN"
|
|
# print(" " + key + ": " + display_value)
|