API

class rc.MainWindow
closeEvent(event)

Custom function overriding the close event behavior. It will close both log and settings window, and also leave message in the logger.

create_run_directory()

Get all runs in the data directory, get the run numbers using regex to handle 2/3 digits of run number and possible suffix at the end would handle folder names like “20240101_00”, “20240101_0001”, “20240101_03 cf252”, “20240101_04.252”, non_continuous folder numbers it also handles the case that there’s no runs today yet

display_image(path, label, checked=True)

Function that controls image display of last event

event_starting
event_stopping
format_time(t)

Time formatting helper function for event time display. t is in milliseconds If time is under a minute, it will return “12s 345” If time ie between a minute and an hour, it will return “12m 34s 567” If time is more than an hour, it will return “12h 34m 56s 789”

Parameters:

t (int) – Time in milliseconds

Returns:

formatted time string

Return type:

str

open_data_folder()
open_log_window()

Create and show the logs window.

open_settings_window()

Create and show the settings window.

program_starting
program_stopping
run_starting
run_stopping
select_file()

Open a file dialog to select a file. The selected file path will be set in the file_path line edit.

send_trigger
set_up_workers()
start_event()

Main RC function to start an event. First it checks if the max number of events has been reached. If so, it will stop the run. Then, it will start the event timer, set the numbers on main window, and create the event directory. Finally, it will send out the event_starting signal to all modules.

start_program()
start_run()

Start a new run. Copies configuration into run-specific config. Creates run directory. Initializes data submodules.

starting_event_wait(module)

A slot method to append ready module names to the list. It will add the module to a list and change the status light. The update function will check the length of the list. When all modules are ready, it will proceed to the active state.

starting_program_wait(module)
starting_run_wait(module)

A slot method to append ready module names to the list. It will add the module to a list and change the status light. The update function will check the length of the list. When all modules are ready, it will proceed to the start_event state.

stop_event()

Stop the event. Enter into compressing state. If the “Stop Run” button is pressed or the max number of events are reached, then it will enter into “stopping” state. Otherwise, it will start another event.

stop_run()
stop_run_but_pressed()
stopping_event_wait(module)

A slot method to append ready module names to the list. It will add the module to a list and change the status light. The update function will check the length of the list. When all modules are ready, it will proceed to next event or stopping run.

stopping_run_wait(module)

A slot method to append ready module names to the list. It will add the module to a list and change the status light. The update function will check the length of the list. When all modules are ready, it will proceed to the idle state.

sw_trigger()
update()

Event loop function. This function will run every 100ms. In the active state, it will update event and run timer, and check if max event time is reached. If so, it will end the event. In the starting_run, stopping_run, starting_event, and stopping_event states, it will check if all modules are ready to proceed to the next state.

update_state(s)

The update_state function will change the self.run_state variable to the current state, and also change the GUI to reflect it. The “Start Run” and “Stop Run” buttons are enabled and disabled accordingly. The states are: - “Preparing”: The program is starting up. Initializing necessary variables. - Idle: The program is idling. Settings can be changed and a new run can be started - Starting: The run is starting. A configuration file is used for the entire run. - Stopping: The running is stopping. - Expanding: An event is starting. The pump is expanding the chamber and all components are starting up, ready to take data - Compressing: The event is stopping. The pump is compressing back to non-superheated state, and all components are saving data to file. - Active: All components are actively taking data to buffer.

class src.acoustics.Acoustics(mainwindow)
event_started
event_stopped
periodic_task()
range_conversion = {'±1 V': 2000, '±100 mV': 200, '±2 V': 4000, '±200 mV': 400, '±5 V': 10000, '±500 mV': 1000}
run()
sample_rate_conversion = {'1 MS/s': 1000000, '1 kS/s': 1000, '10 MS/s': 10000000, '10 kS/s': 10000, '100 MS/s': 100000000, '100 kS/s': 100000, '12.5 MS/s': 12500000, '2 MS/s': 2000000, '2 kS/s': 2000, '20 kS/s': 20000, '200 kS/s': 200000, '25 MS/s': 25000000, '5 MS/s': 5000000, '5 kS/s': 5000, '50 MS/s': 50000000, '50 kS/s': 50000, '500 kS/s': 500000}
save_config()
start_event()
start_gage()
stop_event()
class src.arduinos.Arduino(mainwindow, arduino)
arduino_port_map = {0: 'E0', 1: 'E1', 2: 'E4', 3: 'E5', 4: 'G5', 5: 'E3', 6: 'H3', 7: 'H4', 8: 'H5', 9: 'H6', 10: 'B4', 11: 'B5', 12: 'B6', 13: 'B7', 14: 'J1', 15: 'J0', 16: 'H1', 17: 'H0', 18: 'D3', 19: 'D2', 20: 'D1', 21: 'D0', 22: 'A0', 23: 'A1', 24: 'A2', 25: 'A3', 26: 'A4', 27: 'A5', 28: 'A6', 29: 'A7', 30: 'C7', 31: 'C6', 32: 'C5', 33: 'C4', 34: 'C3', 35: 'C2', 36: 'C1', 37: 'C0', 38: 'D7', 39: 'G2', 40: 'G1', 41: 'G0', 42: 'L7', 43: 'L6', 44: 'L5', 45: 'L4', 46: 'L3', 47: 'L2', 48: 'L1', 49: 'L0', 50: 'B3', 51: 'B2', 52: 'B1', 53: 'B0'}
check_arduino()
latch_pins = [0, 1, 5, 2, 3, 17, 16, 6, 7, 8, 9, 15, 14]
periodic_task()
reverse_port_map = {}
run()
sketch_uploaded
upload_sketch()
class src.caen.Caen(mainwindow)
data_retrieved
event_started
event_stopped
periodic_task()
run()
run_started
run_stopped
set_config()
start_event()
start_run()
stop_event()
stop_run()
class src.cameras.Camera(mainwindow, cam_name)
camera_closed
camera_connected
camera_started
periodic_task()
run()
start_camera()
stop_camera()
test_rpi()
class src.config.Config(mainwindow, path)

Class object to load and save run config files

apply_config(ui)
load_config()
load_config_from_file(path, ui)

Updates the config dict with new json dict. The new json has to follow the same structure, but doesn’t need to have all the values

load_config_to_mainwindow()
load_config_to_window(ui)
periodic_task()
run_config_saved
save_config(path)
save_config_from_ui(ui, path)
start_event()
start_run()
stop_run()
update_dict(original, new)

recursive helper function to update config dictionary with new settings. Prevents overwriting keys in the same level that is written.

class src.niusb.NIUSB(mainwindow)
check_niusb()
drive_definition = {'': 'input', 'comm_cam1': 'active_drive', 'comm_cam2': 'active_drive', 'comm_cam3': 'active_drive', 'latch': 'open_collector', 'reset': 'open_collector', 'state_cam1': 'open_collector', 'state_cam2': 'open_collector', 'state_cam3': 'open_collector', 'trig': 'open_collector', 'trigen_cam1': 'active_drive', 'trigen_cam2': 'active_drive', 'trigen_cam3': 'active_drive', 'trigff_ar': 'open_collector', 'trigff_but': 'open_collector', 'trigff_cam1': 'open_collector', 'trigff_cam2': 'open_collector', 'trigff_cam3': 'open_collector', 'trigff_cf4': 'open_collector', 'trigff_p': 'open_collector', 'trigff_piezo': 'open_collector', 'trigff_rc': 'open_collector'}
event_started
event_stopped
ff_dict = {'trigff_ar': 'Kulite Ar', 'trigff_but': 'Ext Button', 'trigff_cam1': 'Cam1', 'trigff_cam2': 'Cam2', 'trigff_cam3': 'Cam3', 'trigff_cf4': 'Kulite CF4', 'trigff_p': 'Pressure', 'trigff_piezo': 'Piezo', 'trigff_rc': 'Run Control'}
periodic_task()
pin_definition = {'': 'input', 'comm_cam1': 'output', 'comm_cam2': 'output', 'comm_cam3': 'output', 'latch': 'input', 'reset': 'output', 'state_cam1': 'input', 'state_cam2': 'input', 'state_cam3': 'input', 'trig': 'output', 'trigen_cam1': 'output', 'trigen_cam2': 'output', 'trigen_cam3': 'output', 'trigff_ar': 'input', 'trigff_but': 'input', 'trigff_cam1': 'input', 'trigff_cam2': 'input', 'trigff_cam3': 'input', 'trigff_cf4': 'input', 'trigff_p': 'input', 'trigff_piezo': 'input', 'trigff_rc': 'input'}
run()
run_started
run_stopped
send_trigger(source)
start_event()
start_run()
stop_event()
stop_run()
trigger_detected
trigger_ff
class src.sipm_amp.SiPMAmp(mainwindow, amp)
adc_mapping = {1: '6 0 1', 2: '6 4 5', 3: '6 6 7', 4: '6 2 3', 5: '4 0 1', 6: '4 4 5', 7: '4 6 7', 8: '4 2 3', 9: '3 0 1', 10: '3 4 5', 11: '3 6 7', 12: '3 2 3', 13: '1 0 1', 14: '1 4 5', 15: '1 6 7', 16: '1 2 3'}
bias_sipm()
check_iv_interval()

return the time stamp of last IV curve measurement

daq_mapping = {1: '5 0', 2: '5 1', 3: '5 2', 4: '5 3', 5: '5 4', 6: '5 5', 7: '5 6', 8: '5 7', 9: '2 0', 10: '2 1', 11: '2 2', 12: '2 3', 13: '2 4', 14: '2 5', 15: '2 6', 16: '2 7'}
exec_commands(host, commands)
periodic_task()
run()
run_iv_curve()

tell the SiPM amplifier to do an IV curve measurement

sipm_biased
sipm_unbiased
start_run()
test_sipm_amp()
unbias_sipm()

if not enabled, try pinging the IP address if ping successes, still unbias. if not, quit ping with only 1 packet, with 1s timeout

class src.sql.SQL(mainwindow)
close_connection()
connect_and_execute(query)
deleteLater(self, /) None
event_started
event_stopped
periodic_task()
retrieve_run_id(date='')
run()
run_started
run_stopped
setup_connection()
start_event()
start_run()
stop_event()
stop_run()
class src.ui_loader.CheckBoxPairBinder(checkbox1, checkbox2)
sync_checkboxes(state)
class src.ui_loader.SettingsWindow(mainwindow)
apply_config()
caen_group_changed(state)
caen_individual_changed()
load_config()
load_config_from_file()
save_config()
select_amp1_iv_dir()
select_amp2_iv_dir()
select_amp3_iv_dir()
select_caen_data_path()
select_clock_sketch_dir()
select_config_path()
select_data_dir()
select_log_dir()
select_position_sketch_dir()
select_trigger_sketch_dir()
class src.ui_loader.LogWindow(main_window)
load_log()
periodic_task()
class src.writer.Writer(mainwindow)
event_stopped
periodic_task()
run()
run_stopped
write_event_data()
write_run_data()