fbgui package

Submodules

fbgui.baking_curve_fit module

fbgui.baking_curve_fit.add_baking_trend_line(data_frame, coefficients, fbg_name, x_index=1)[source]
Return type:int
fbgui.baking_curve_fit.create_sensitivity_line(data_frame, sensitivity, trend_index, fbg_name, fbg_index)[source]
Return type:Optional[int]
fbgui.baking_curve_fit.curve_fit_baking(data_frame, y_index, x_index=1)[source]
Return type:List[float]

fbgui.baking_program module

Module for baking program specific logic.

class fbgui.baking_program.BakingProgram(master)[source]

Bases: fbgui.program.Program

Contains the Baking Program specific logic, extends the Program abstract class.

check_stable(thread_id)[source]

Check if the program is ready to move to primary interval.

Parameters:thread_id (UUID) – UUID of the thread this code is running in
Return type:bool
Returns:True if the drift rate is stable otherwise returns false
get_temperature(thread_id)[source]
Return type:float
program_loop(thread_id)[source]

Runs the baking process.

Parameters:thread_id (UUID) – UUID of the thread this code is running in
set_oven(count)[source]
Return type:int

fbgui.cal_program module

Contains the calibration program specific logic.

class fbgui.cal_program.CalProgram(master)[source]

Bases: fbgui.program.Program

Contains the logic specific for running a calibration program.

cal_loop(temps)[source]

Runs the main calibration loop.

Parameters:temps (List[float]) – the list of temperatures to set the oven to
check_drift_rate(cycle_num)[source]

Checks if the drift rate is below the configured drift, and the temperature is within 1 degree of the set temperature.

Parameters:cycle_num (int) – The number of the current calibration cycle
Return type:bool
Returns:True if the drift rate is below the configured drift rate, otherwise False
check_program_stopped()[source]
get_drift_rate(get_wave_amp=False)[source]

Get the drift rate of the system.

Param:the UUID of the thread the code is currently running on
Return type:Tuple[float, float, float, List[float], List[float]]
Returns:the current drift rate in mK/min
get_temp()[source]

Takes the configured number of temperature readings and averages them.

Return type:float
Returns:the averaged temperature
program_loop(thread_id)[source]

Runs the calibration main loop.

Parameters:thread_id (UUID) – UUID of the thread this code is running in
record_beginning_extra_points(cycle_num, first_temperature)[source]
record_end_extra_points(cycle_num, last_temperature)[source]
record_extra_point(cycle_num, temperature, wavelength_text, power_text)[source]
reset_temp(start_temp)[source]

Checks to see if the temperature is 4.5K below the starting temperature.

Parameters:
  • start_temp (float) – The first temperature the oven is set to
  • cycle_num – Number of the current cycle
Return type:

bool

sleep()[source]

Sleeps for the configured temp_interval on the home screen.

fbgui.calibration_excel_container module

class fbgui.calibration_excel_container.CalibrationExcelContainer(real_point_data_frame, cycles)[source]

Bases: object

add_deviation_column(deviation_column_name, header, cycle, means)[source]
add_power_deviation()[source]
add_powers(temperatures)[source]
add_wavelength_deviation()[source]
add_wavelengths(temperatures, cycle_num)[source]
get_data_frame()[source]
Return type:DataFrame
get_means_and_fbg_name(header)[source]
Return type:Tuple[List[float], str]
get_power_sensitivity_coefficients(temperatures)[source]
get_readings(cycle_num, header)[source]
Return type:List[float]
get_temperatures(cycle_num)[source]
Return type:List[float]
get_wavelength_sensitivity_coefficients(temperatures)[source]
plot_master_temperatures(all_temperatures)[source]
populate()[source]
fbgui.calibration_excel_container.fbg_name_from_header(header)[source]
Return type:str
fbgui.calibration_excel_container.get_means_at_temperatures(values, num_temps)[source]
Return type:List[float]

fbgui.config_controller module

fbgui.config_controller.get_configured_fbg_names(is_calibration)[source]

Get the serial numbers recorded in the prog_config configuration file, under the header based on the is_cal parameter

Parameters:is_calibration (bool) – True if program is calibration, False otherwise
Return type:List[str]
Returns:list of serial numbers

fbgui.constants module

Constants used throughout the program.

class fbgui.constants.Colors(hex_color)[source]

Bases: enum.Enum

Colors used in the GUI styling.

AZ_WHITE = '#dcedff'
BLACK = '#1D2731'
GOLD = '#D9B310'
GRAY = '#2b2a29'
MED_BLUE = '#0B3C5D'
SKY_BLUE = '#328CC1'
WHITE = '#f0eff4'

fbgui.create_excel_table module

Home page table used for creating excel spreadsheets of program runs.

class fbgui.create_excel_table.ExcelTable(master, main_queue, **kwargs)[source]

Bases: tkinter.ttk.Frame

Tkinter frame containing widgets for creating excel spreadsheets.

Variables:
  • headers (List[str]) – the treeview table headers
  • main_queue (Queue) – main_queue parameter
  • tree (ttk.Treeview) – ttk tree displaying information about the program runs
  • item_ids (List[int]) – ids of the items currently stored in the tree
  • Dict[int – str] file_paths: mapping of map table ids to file paths
  • s_nums (List[str]) – map of program database ids to comma separated strings of serial numbers for that program
add_data(item)[source]

Adds data to the tree view for a program stored in the map database table.

Parameters:item (List[str]) – list of strings for the program id, program name, and program type respectively
create_spreadsheet()[source]

Create the spreadsheet(s) for the selected elements of the tree view.

delete_run()[source]
refresh()[source]

Refreshes the table and loads all of the programs from the map database table.

show_spreadsheet(file_path, fbg_names, program_type, sensitivity, extra_points)[source]

fbgui.data_container module

Data container for database data.

class fbgui.data_container.DataCollection[source]

Bases: object

Data container class for data stored in the database for the program

Create must be called in order to instantiate the object properly based on a dataframe object.

Variables:
  • times (List[float]) – list of delta times in hours, from the start
  • temps (List[float]) – list of temperatures in Kelvin
  • List[delta_temps – list of delta temperatures in Kelvin, from the start
  • powers (List[List[float]]) – 2D list of powers by serial number in dBm.
  • delta_powers (List[List[float]]) – 2D list of delta powers, from the start, by serial number, in dBm.
  • mean_delta_powers (List[float]) – list of average delta power in dBm, from the start
  • wavelengths (List[List[float]]) – 2D list of wavelengths by serial number in nm.
  • delta_wavelengths (List[List[float]]) – 2D list of delta wavelengths, from the start, by serial number, in pm.
  • mean_delta_wavelengths (List[float]) – list of average delta wavelengths in pm.
  • drift_rates (List[float]) – list of calibration drift rates mK/min
create(is_cal, df, fbg_names=None, main_queue=None)[source]

Creates a data collection from the given dataframe, updates the instance variables to match how they are specified in the class docstring, numpy arrays are used instead of lists however.

Adds date time column to the data frame

Parameters:
  • is_cal (bool) – boolean for whether or not the program is a calibration program
  • df (DataFrame) – dataframe representing the sql table for the program
  • fbg_names (Optional[List[str]]) – list of serial numbers that are in use for the program, if None the serial numbers will be found using file_helper get_snums function
  • main_queue (Optional[Queue]) – if present used for writing messages to the program log
Raises:

RuntimeError – If the table has not been created or populated yet

fbgui.database_controller module

class fbgui.database_controller.DatabaseController(file_path, fbg_names, main_queue, function_type, table=None, excel_table=None, bake_sensitivity=None, extra_point_temperatures=None)[source]

Bases: object

add_entry_to_map(cursor)[source]
create_database_column_commands()[source]

Returns a list of strings used for creating the database attribute values, includes names and SQL types.

Return type:List[str]
Returns:list of comma separated strings, names and types of table attributes
create_program_table(cursor, columns)[source]
delete_partial_cycles(partial_cycle_nums)[source]
get_cycle_nums()[source]
Return type:List[int]
get_fbg_list()[source]
Return type:List[str]
get_last_cycle_num()[source]

Get the number of the last calibration cycle that data is recorded for.

Return type:int
Returns:last calibration cycle number, or 0 if there is no data calibration recorded
get_table_id(cursor)[source]
handle_sql_error(sql_error)[source]
new_instance(file_path, fbg_names, bake_sensitivity=None, extra_point_temperatures=None)[source]
program_exists(cursor=None)[source]

Checks whether or not there is data in the database for the program of type func, named name.

Parameters:cursor (Optional[Cursor]) – the database cursor
Return type:bool
Returns:True if the program exists, otherwise False
record_baking_point(timestamp, temperature, wavelengths, powers)[source]
record_calibration_point(timestamp, temperature, wavelengths, powers, drift_rate, is_real_calibration_point, cycle_num)[source]
record_point(column_command_string, values, timestamp)[source]
reset_controller(file_path, fbg_names, bake_sensitivity=None, extra_point_temperatures=None)[source]
to_data_frame()[source]

Creates a pandas dataframe object from the database table corresponding to the program run of type func, and named name.

Return type:

DataFrame

Returns:

dataframe for the specified table, or an empty dataframe if one cannot be created for the table

Raises:
  • IndexError – If program is not in the map, thus data has not been recorded for this program yet
  • RuntimeError – If program database has been corrupted, or the table is empty
fbgui.database_controller.add_calibration_column_names(columns)[source]
fbgui.database_controller.add_calibration_commands(columns)[source]
fbgui.database_controller.create_column_names(fbg_names)[source]

Create the data column headers.

Parameters:fbg_names (List[str]) – serial numbers for the current program run
Return type:List[str]
Returns:list of header strings
fbgui.database_controller.create_wavelength_power_list(wavelengths, powers)[source]
fbgui.database_controller.delete_tables(table_ids, program_types)[source]

fbgui.datatable module

Tkinter frame for the data view in the program.

class fbgui.datatable.DataTable(master, create_excel_func, main_queue=None)[source]

Bases: tkinter.ttk.Frame

Overrides ttk Frame class used to create a data view.

Variables:
  • headers (List[str]) – headers for the tree view widget
  • tree (ttk.Treeview) – tree used for displaying the data
  • func (Callable) – param func
  • item_ids (List[int]) – ids of the items currently stored in the tree view
  • main_queue (Queue) – param main_queue
add_data(item)[source]

Adds the values in item as a row in the tree view.

Parameters:item (List[str]) – list of strings corresponding to the columns in the tree view
reset()[source]

Clears the tree view.

setup_headers(headers, reset=False)[source]

Sets up the headers for the tree view.

Parameters:
  • headers (List[str]) – list of header strings to add to the tree view
  • reset (bool) – If true clear the table

fbgui.excel_file_controller module

class fbgui.excel_file_controller.ExcelFileController(excel_file_path, fbg_names, main_queue, function_type, bake_sensitivity=None, extra_point_temperatures=None)[source]

Bases: object

add_delta_powers(data_frame, data_collection, column_ordering)[source]
add_delta_wavelengths(data_frame, data_collection, column_ordering)[source]
create_baking_excel()[source]
create_calibration_excel()[source]
create_excel()[source]
create_series_bake(x_values, y_values, index)[source]
Return type:<function SeriesFactory at 0x000001781C6DCA60>
create_style_frame(data_frame)[source]
graph_bake(parameters)[source]
graph_power_deviation(parameters)[source]
graph_power_means(parameters)[source]
graph_power_sensitivity(parameters)[source]
graph_wavelength_deviation(parameters)[source]
graph_wavelength_means(parameters)[source]
graph_wavelength_sensitivity(parameters)[source]
show_excel(style_frames, sheet_names, parameters, graph_results, coefficients=None, baking_coefficients=None)[source]
write_coefficients(worksheet, row, coefficients, derivative_coefficients=None, write_sensitivity=False)[source]
Return type:int
write_curve_fit_coefficients(coefficients_list, worksheet)[source]
fbgui.excel_file_controller.add_baking_duplicate_columns(data_frame, data_collection)[source]
fbgui.excel_file_controller.add_times(data_frame, data_collection)[source]
fbgui.excel_file_controller.add_wavelength_power_columns(column_ordering, data_frame)[source]
fbgui.excel_file_controller.create_chart(temperatures, extra_point_temperatures=None)[source]
Return type:ScatterChart
fbgui.excel_file_controller.format_chart(chart, x_axis_title, y_axis_title, title)[source]
fbgui.excel_file_controller.get_wavelength_power_headers(data_frame)[source]
Return type:Tuple[List[str], List[str]]
fbgui.excel_file_controller.hex_to_rgb(hex_index)[source]
Return type:List[float]

fbgui.excel_graph_helpers module

class fbgui.excel_graph_helpers.BakingGraphParameters(num_rows, trend_line_indexes, sensitivity_indexes)[source]

Bases: fbgui.excel_graph_helpers.GraphParameters

class fbgui.excel_graph_helpers.CalibrationGraphParameters(num_rows, temperatures, cycles, mean_wavelength_indexes, deviation_wavelength_indexes, mean_power_indexes, deviation_power_indexes, sensitivity_wavelength_indexes, sensitivity_power_indexes, master_temperature_column=0, mean_temperature_column=0)[source]

Bases: fbgui.excel_graph_helpers.GraphParameters

class fbgui.excel_graph_helpers.CalibrationGraphSubType(graph_type, start_row, reading_type, mean_units=None)[source]

Bases: enum.Enum

An enumeration.

POWER_DEVIATION = (<CalibrationGraphType.DEVIATION: ('{} deviation from mean ({})', 'Cycle {}', 'B')>, None, <CalibrationReadingType.POWER: ('Power', 'db')>)
POWER_MEAN = (<CalibrationGraphType.MEAN: ('{} mean ({})', 'Mean', 'V')>, None, <CalibrationReadingType.POWER: ('Power', 'db')>)
POWER_SENSITIVITY = (<CalibrationGraphType.SENSITIVITY: ('{} sensitivity ({}/K)', 'Sensitivity', 'AP')>, None, <CalibrationReadingType.POWER: ('Power', 'db')>)
WAVELENGTH_DEVIATION = (<CalibrationGraphType.DEVIATION: ('{} deviation from mean ({})', 'Cycle {}', 'B')>, 2, <CalibrationReadingType.WAVELENGTH: ('Wavelength', 'pm')>)
WAVELENGTH_MEAN = (<CalibrationGraphType.MEAN: ('{} mean ({})', 'Mean', 'V')>, 2, <CalibrationReadingType.WAVELENGTH: ('Wavelength', 'pm')>, 'nm')
WAVELENGTH_SENSITIVITY = (<CalibrationGraphType.SENSITIVITY: ('{} sensitivity ({}/K)', 'Sensitivity', 'AP')>, 2, <CalibrationReadingType.WAVELENGTH: ('Wavelength', 'pm')>)
class fbgui.excel_graph_helpers.CalibrationGraphType(y_axis_specifier, series_title, column_letter)[source]

Bases: enum.Enum

An enumeration.

DEVIATION = ('{} deviation from mean ({})', 'Cycle {}', 'B')
MEAN = ('{} mean ({})', 'Mean', 'V')
SENSITIVITY = ('{} sensitivity ({}/K)', 'Sensitivity', 'AP')
class fbgui.excel_graph_helpers.CalibrationReadingType(title, units)[source]

Bases: enum.Enum

An enumeration.

POWER = ('Power', 'db')
WAVELENGTH = ('Wavelength', 'pm')
class fbgui.excel_graph_helpers.GraphParameters(num_rows)[source]

Bases: object

class fbgui.excel_graph_helpers.SeriesParameters(parameters, indexes, sub_type, extra_point_temperatures)[source]

Bases: object

fbgui.exceptions module

exception fbgui.exceptions.ProgramStopped[source]

Bases: Exception

fbgui.graph_toolbar module

Overrides the default matplotlib tkinter toolbar to add play and pause to the graph animation.

class fbgui.graph_toolbar.Toolbar(figure_canvas, parent)[source]

Bases: matplotlib.backends.backend_tkagg.NavigationToolbar2TkAgg

Overrides the default Matplotlib toolbar to add play and pause animation buttons.

Variables:graphing_helper (Graphing) – Graphing helper object that controls the graphing screen
pause()[source]

Pauses graph animation linked to button on toolbar.

play()[source]

Plays graph animation linked to play button on toolbar.

set_gh(graphing_helper)[source]

Sets the graphing helper.

Parameters:graphing_helper – The graphing helper class controlling the graphing screen

fbgui.graphing module

Module used for handling the graphing using matplotlib.

class fbgui.graphing.Graph(title, xlabel, ylabels, animate_func, fig, dims, is_cal, snums, main_queue, database_controller)[source]

Bases: object

Class describes a specific graph that can be represented as a subplot or a main plot.

Variables:
  • sub_dims – dimensions for the sub graph, first index of the dims parameter
  • zoom_dims – dimensions for the zoom graph, all dimensions after the first in the dims list parameter
  • sub_axis – Axes object for the sub graph that is plotted in the graph page grid
  • anim – FuncAnimation object when using the animate_func function parameter to animate the graph
  • zoom_axes – list of the axes objects for the zoomed graph
check_val_file(axes_tuple)[source]

Checks whether the currently configured file name is a program stored in the map sql table, and starts the animation if it is.

Parameters:axes_tuple (Tuple[Axes, …]) – tuple of matplotlib Axes objects, that will be graphed using the animate function if the program exists
main_graph(_)[source]

Graph the main plot.

pause()[source]

Pauses the graph animation.

play()[source]

Plays the graph animation.

show_main()[source]

Show the graph as the main plot.

show_sub()[source]

Show the graph as a subplot in the grid.

sub_graph(_)[source]

Graph the subplot.

class fbgui.graphing.Graphing(dims, is_cal, figure, canvas, toolbar, master, snums, main_queue, database_controller)[source]

Bases: object

Class used for graphing the individual Graph objects.

Variables:
  • data_coll – data collection object for baking graph
  • data_coll_cal – data collection object for the calibration graph
  • graphs – list of Graph objects that are contained in the graphing page
  • sub_axes – List of Axes objects that are plotted on the main graph figure, when showing the graph grid
data_coll = None
data_coll_cal = None
pause()[source]

Pause animation for all the graphs.

play()[source]

Play animation for all the graphs.

setup_click_listener()[source]
show_main_plot(event)[source]

Show the main plot, the specified zoomed graph, on the graphing page when double clicked or show the graph at the index of event, if event is an integer.

Parameters:event (Union[MouseEvent, int]) – MouseEvent corresponding to a click event on the graph, or an integer used to index the graphs list to show that graph
show_subplots(event=None)[source]

Show all the subplots in the graphing page, when the main plot is double clicked.

Parameters:event (Optional[MouseEvent]) – MouseEvent object passed in on click
update_axes()[source]

Update the axes to include the sub plots on the graphing page.

update_data_coll()[source]

Updates the data collections used for graphing the data from the sql table, every 8 seconds.

fbgui.graphing.animate_graph(use_snums)[source]

Animate graph function decorator.

Parameters:use_snums (bool) – If True the function being decorated accepts serial nums as an argument
Return type:Callable
fbgui.graphing.average_power_graph(axis, dc)[source]

Animate function for the mean power vs. time graph.

Parameters:
  • axis (List[Axes]) – average power Axes as only element
  • dc (DataCollection) – data collection object to use for populating the graph
fbgui.graphing.average_wave_graph(axes, dc)[source]

Animate function for the mean wavelength vs. time graph.

Parameters:
  • axes (List[Axes]) – average wavelength Axes as only element
  • dc (DataCollection) – data collection object to use for populating the graph
fbgui.graphing.create_legend(axis, fbg_names, axes)[source]
fbgui.graphing.drift_rate_graph(axes, dc)[source]

Animate function for the drift rates graph.

Parameters:
  • axes (List[Axes]) – drift rate vs. time Axes, delta drift rate vs. time Axes [Only for Calibration]
  • dc (DataCollection) – data collection object to use for populating the graph
fbgui.graphing.formatter(val, _)[source]

Axes label formatter.

Format 1 as 1, 0 as 0, and all values whose absolute values is between 0 and 1 without the leading “0.” (e.g., 0.7 is formatted as .7 and -0.4 is formatted as -.4).

Parameters:
  • val (float) – axis label value
  • _ – not needed
fbgui.graphing.power_graph(axis, snums, dc)[source]

Animate function for the individual powers graph.

Parameters:
  • axis (List[Axes]) – delta power vs. time Axes, raw power vs. time Axes [Only used for Baking]
  • snums (List[str]) – the serial numbers in use for the corresponding program run being graphed
  • dc (DataCollection) – data collection object to use for populating the graph
fbgui.graphing.temp_graph(axes, dc)[source]

Animate function for the temperature vs. time graph.

Parameters:
  • axes (List[Axes]) – delta temperature vs. time Axes, raw temperature vs time Axes
  • dc (DataCollection) – data collection object to use for populating the graph
fbgui.graphing.wave_graph(axis, snums, dc)[source]

Animate function for the individual wavelengths graph.

Parameters:
  • axis (List[Axes]) – delat wavelength vs. time Axes, wavelength vs. time Axes
  • snums (List[str]) – the serial numbers in use for the corresponding program run being graphed
  • dc (DataCollection) – data collection object to use for populating the graph
fbgui.graphing.wave_power_graph(axis, snums, dc)[source]

Animate function for the wavelength vs. power graph.

Parameters:
  • axis (List[Axes]) – wavelength vs power Axes as only element
  • snums (List[str]) – the serial numbers in use for the corresponding program run being graphed
  • dc (DataCollection) – data collection object to use for populating the graph

fbgui.helpers module

General helper functions used throughout the package.

fbgui.helpers.average(elements)[source]

Converts a 3 dimensional array of floats into a 2 dimensional array by averaging the inner arrays.

Parameters:elements (List[List[List[float]]]) – Elements to convert
Return type:List[List[float]]
Returns:Elements with the inner lists averaged
fbgui.helpers.clean_str_list(str_list)[source]

Removes invisible characters from a list of strings.

Parameters:str_list (List[str]) – list of strings
Return type:List[str]
Returns:list of strings without whitespace characters
fbgui.helpers.flatten(list2d)[source]

Accepts a 2D list and flattens it into a 1D list.

Parameters:list2d (List[List[~T]]) – Matrix to flatten
Return type:List[~T]
Returns:list is ordered how the list is visually seen in 1D
fbgui.helpers.get_file_name(file_str)[source]

Returns the name of a file removing the file path and file extension.

Parameters:file_str (str) – file path file named.file extension
Return type:str
Returns:file name
fbgui.helpers.is_unique(test_list)[source]

Checks if test_list is all unique values.

Parameters:test_list (List[~T]) – list of objects to test for uniqueness
Return type:bool
Returns:whether or not the elements of the test_list are unique.
fbgui.helpers.list_cast(str_list, cast_type)[source]

Converts a list of strings to the given type.

Parameters:
  • str_list (List[str]) – list of strings
  • cast_type (type) – type to cast the strings to
Return type:

List[~T]

Returns:

list of values of the cast type

Raises:

ValueError – if list cannot be cast to the specified time

fbgui.helpers.make_length(values, length)[source]

Force the values list to be of length, length.

Parameters:
  • values (List[~T]) – list to resize
  • length (int) – required length of the list
Return type:

List[~T]

Returns:

list of length, length

fbgui.install module

Ensures assets, and helper data is in the correct place.

fbgui.install.install()[source]

Move matplotlib assets to correct folder, ensure db and config folders are on the disc.

fbgui.laser_data module

class fbgui.laser_data.LaserData(switch_positions, switch_channel_index)[source]

Bases: object

add_powers(channel, powers, position)[source]
add_wavelengths(channel, wavelengths, position)[source]
get_powers()[source]
Return type:List[List[float]]
get_wavelengths()[source]
Return type:List[List[float]]

fbgui.laser_recorder module

Gets the amplitude and wavelength data using the Micron Optics SM125, and the Optical Switch.

class fbgui.laser_recorder.LaserRecorder(laser, switch, switches, num_pts, thread_id, thread_map, main_queue)[source]

Bases: object

get_wavelength_amplitude_data()[source]
Return type:Tuple[List[float], List[float]]
record_wavelengths_and_amplitudes(laser_data, switch_position)[source]

fbgui.main_program module

Module contains the main entry point for the Kyton UI.

class fbgui.main_program.Application(*args, **kwargs)[source]

Bases: tkinter.Tk

Main Application class, Tk implementation used as the master throughout the package.

Variables:
  • conf_parser (configparser.ConfigParser) – ConfigParser to read, and set device settings
  • manager (visa.ResourceManager) – PyVisa ResourceManager used for communicating with GPIB instruments
  • main_queue (Queue) – Queue used for listening for logging messages to write to the log_view
  • Dict[UUID – bool] thread_map: Map of thread UUIDs to booleans for whether or not to stop the thread
  • open_threads (List[UUID]) – List of UUIDs of the currently open data collection threads
  • graph_threads (List[UUID]) – List of UUIDs of the currently open graph threads
  • running (bool) – True if either program is running, False otherwise
  • running_prog (str) – Program identifier for currently running program, None if the program is not running
  • temp_controller (devices.TemperatureController) – temperature controller wrapper used for communicating with the temperature controller, None if not connected to the temperature controller
  • oven (devices.Oven) – Oven wrapper used for communicating with the Oven, None if not connected to the oven
  • laser (devices.SM125) – Laser wrapper used for communicating with the Laser, None if not connected to the laser
  • switch (devices.OpticalSwitch) – Switch wrapper used for communicating with the Optical Switch, None if not connected to the optical switch
  • is_full_screen (bool) – True if the program is in full screen, False otherwise
  • controller_location (tkinter.IntVar) – tkinter variable for the temperature controller location input field
  • oven_location (tkinter.IntVar) – tkinter variable for the oven location input field
  • op_switch_address (tkinter.StringVar) – tkinter variable for the optical switch address input field
  • op_switch_port (tkinter.IntVar) – tkinter variable for the optical switch port input field
  • sm125_address (tkinter.StringVar) – tkinter variable for the sm125 address input field
  • sm125_port (tkinter.IntVar) – tkinter variable for the sm125 port input field
  • main_notebook (tkinter.Notebook) – ttk notebook widget which is the highest level widget
  • home_frame (tkinter.Frame) – the home page ttk frame widget
  • device_frame (tkinter.Frame) – the widget containing the device input widgets on the home screen
  • log_view (messages.LogView) – Logview widget containing the logging scrolled text widget
  • bake_program (baking_program.BakingProgram) – the program object for the baking program
  • calibration_program (cal_program.CalProgram) – the program object for the calibration program
check_queue()[source]

Check the queue every second for a Message object to write to the log view.

conn_dev(dev, connect=True, try_once=False, thread_id=None)[source]

Connects or Disconnects the program to a required device based on the input location params.

Parameters:
  • dev (str) – device identifier string, to identify which device to connect
  • connect (bool) – True if connect, False if disconnect
  • try_once (bool) – True if try to connect only once, False if continuously try to connect to device
  • thread_id (Optional[UUID]) – UUID of the thread running the code, if None then code is running on main thread
end_full(_=None)[source]

Exit full screen.

on_closing()[source]

Close the program if no data collection is in process, otherwise make the user confirm closing the program.

setup_home_frame()[source]

Sets up the home frame, ttk frame, that is displayed on launch.

setup_window()[source]

Sets up the tkinter window.

toggle_full(_=None)[source]

Toggles full screen on and off.

fbgui.messages module

fbgui.messages.FILTER_TIME = 300.0

Amount of time in between messages to enable the filtering

class fbgui.messages.LogView(container, **kwargs)[source]

Bases: tkinter.ttk.Frame

Widget for the program log messages, ttk Frame implementation.

Variables:
  • message_types (List[MessageType]) – the MessageTypes to include in the filter combobox
  • all_types (List[MessageType]) – a list of all the message types
  • message_delays (List[MessageDelay]) – a list of all of the message delays
  • Dict[str – collections.deque] messages: mapping of message type title string to dequeues of fixed size containing messages’ body
  • Dict[str – float] message_time: message body without timestamp mapped to time in s
  • Dict[str – MessageDelay] message_time_filer: message body without timestamp mapped to MessageDelay
  • first_click_time (float) – the time the header text was first clicked (Used for developer messages)
  • num_clicks (int) – the number of times the header text was clicked within the specified time (Used for dev msgs)
  • showing (bool) – True if developer messages are in the filter, False otherwise
  • current_filter (MessageType) – the current message type to filter messages
  • filter_box (ttk.Combobox) – the combobox tkinter widget used for selecting a filter level
  • log_view (ttk.ScrolledText) – the scrolled text tkinter widget used for displaying log messages
add_msg(msg)[source]

Add the msg to the log view, and the message store data structures.

Parameters:msg (Message) – message to add to the log view
clear()[source]

Clear the log view scrolled text.

click_handler(_)[source]

Click handler for the Program Log header to allow the user to view developer messages.

export()[source]

Export the messages to a log text file in the log folder.

filter_msg(_)[source]

Filters messages when the filter combobox value is changed.

get_msgs(filter_num)[source]

Get all of the messages that have a filter number less than or equal the filter number.

Parameters:filter_num (int) – the number used for filtering messages
Return type:OrderedDict
Returns:time mapped to (text, tag) for all filtered messages
highlight_pattern(pattern, tag, start='1.0', end='end', regexp=False)[source]

Apply the given tag to all text that matches the given pattern.

Parameters:
  • pattern (str) – pattern to match when looking to format the text using the tag.
  • tag (str) – tkinter scrolled text tag corresponding to a tk font
  • start (str) – where to start looking for the pattern from
  • end (str) – where to end looking for the pattern
  • regexp (bool) – If True, pattern will be treated as a Tcl regular expression
write_msg(text, tag, start='1.0')[source]

Write the text to the Scrolled Text tkinter widget, color it based on the tag, add it to the beginning if start is ‘1.0’, if start tk.END add it to the end.

Parameters:
  • text (str) – text to write to the scrolled text view
  • tag (str) – name of the tag that defines the style for the text, based on MessageType
  • start (str) – the position to start writing the text
class fbgui.messages.Message(msg_type, title, text)[source]

Bases: object

Message object contains info about a log message.

Variables:
  • time – unix timestamp in seconds of when the message was created
  • msg – Test of the message without the timestamp included
class fbgui.messages.MessageDelay[source]

Bases: enum.Enum

Length of delay before repeating a message if filtering is enabled.

FIRST = 60.0
LONG = 600.0
MAX = 3600.0
SHORT = 300.0
class fbgui.messages.MessageType(filter_num, color)[source]

Bases: enum.Enum

Type of Message to log, used for coloring and filtering of messages.

CRITICAL = (1, '#FF8800')
DEVELOPER = (5, '#3399FF')
ERROR = (2, '#FF0000')
INFO = (4, '#FFFFFF')
WARNING = (3, '#FFCC00')
class fbgui.messages.SizeDict(maxsize=50000)[source]

Bases: collections.abc.MutableMapping

A dictionary of max length that removes FIFO when the max size is reached.

Variables:
  • store (dict) – dictionary for storing key value pairs
  • added_order (collections.deque) – FIFO queue of the keys used to keep a fixed length
fbgui.messages.sort_messages(msgs)[source]

fbgui.options_frame module

Class sets up the tkinter UI code for the options screen.

class fbgui.options_frame.OptionsPanel(parent, program)[source]

Bases: tkinter.ttk.Frame

Options panel widget in both the baking and calibration program screens, used for configuring program settings.

Variables:
  • sn_ents (List[List[tkinter.Entry]]) – 2D list with one list for each SM125 channel, of tkinter Entrys corresponding to the serial number input fields
  • chan_nums (List[List[int]]) – 2D list with one list for each SM125 channel, of ints where the len of the lists is used for determining the number of FBGs on a channel
  • switch_positions (List[List[tkinter.IntVar]]) – 2D list with one list for each SM125 channel, of tkinter IntVars each representing a ttk spinbox used for specifying the FBGs switch position
  • selected_fbgs (List[List[tk.IntVar]]) – 2D list with one list for each SM125 channel, of IntVars, which are used to watch the value of the CheckButtons in each fbg frame
  • snum_frames (List[List[tkinter.Frame]]) – 2D list with one list for each SM125 channel, of tkinter Frames, each Frame contains a serial number, and switch input for a FBG
  • file_name (tkinter.StringVar) – tkinter StringVar corresponding to the file input
  • prim_time (tkinter.DoubleVar) – tkinter DoubleVar corresponding to the primary bake time
  • num_pts (tkinter.IntVar) – tkinter IntVar corresponding to the number of points to average for each reading
  • num_temp_readings (tkinter.IntVar) – the number of temperature readings to use to average for the calibration program
  • temp_interval (tkinter.IntVar) – IntVar corresponding to the time between taking cal drift rate readings
  • drift_rate (tkinter.DoubleVar) – IntVar corresponding to the maximum calibration point drift rate
  • num_cal_cycles (tkinter.IntVar) – IntVar corresponding to the number of calibration cycles to run
  • cooling (tkinter.IntVar) – IntVar - 1 if cal program is configured to use cooling, 0 if not configured to use cooling
  • target_temps_entry (tkinter.Text) – Text entry corresponding to the calibration target temperatures text input
  • options_grid (tkinter.Frame) – Upper portion of the options screen containing configuration options
  • fbg_grid (tkinter.Frame) – Lower portion of the options screen containing fbg configuration options
  • conf_parser (configparser.ConfigParser) – ConfigParser used for reading in prog_config settings
add_extra_point(row_num, point_num)[source]
add_fbg(chan, fbg_name=None, switch_pos=None)[source]

Add an fbg input to the view, at the column corresponding to the chan index. If fbg_name, and switch_pos are not None then set the serial number entry, and switch position entry to their values respectively.

Parameters:
  • chan (int) – index of where the new fbg sub frame should be added
  • fbg_name (Optional[str]) – If not None, the name of the FBG to add
  • switch_pos (Optional[int]) – If not None, the switch position of the FBG to add
check_config(db_controller)[source]

Checks to make sure all of the input fields are filled in properly, and of the right types.

** This does not ensure the configuration settings make sense, just that the fields have values of the proper type. **

:param db_controller fbgui.DatabaseController :return True if properly configured, False otherwise

Return type:bool
check_extra_point(text, point_num, input_type)[source]
Return type:bool
create_options_grid()[source]

Creates the grid for the user to configure options, in the upper portion of the options screen.

create_start_btn(start)[source]

Creates the start button in the app, and adds the start parameter as the button callback.

Return type:Button
Returns:the created tkinter Button
get_bake_sensitivity()[source]
Return type:Optional[List[float]]
get_extra_point_temperatures()[source]
Return type:Optional[List[float]]
get_target_temps()[source]

Returns the target temps as an array, doesn’t catch the ValueError exception possibility.

Return type:List[float]
Returns:list of target calibration temps
Raises:ValueError – If target temps are not of the right type
init_fbgs()[source]

Initialize the fbg input section of the options page, using settings stored in prog_config.

minus_fbg(chan)[source]

Removes the last FBG sub frame at the specified chan index.

Parameters:chan (int) – index of which column to remove a FBG sub frame from

fbgui.program module

Abstract class defines common functionality between calibration program and baking program.

class fbgui.program.Program(master, program_type)[source]

Bases: tkinter.ttk.Notebook

Definition of the abstract program page, contains shared logic between the two program types, and implements the ttk Notebook widget.

Variables:
  • conf_parser (configparser.ConfigParser) – ConfigParser used for reading the prog_config file
  • channels (List[List[str]]) – 2D list one list for each SM125 channel, each element is a serial number, and is the same shape as the FBG inputs on the options screen
  • switches (List[List[int]]) – 2D list one list for each SM125 channel, each element is a switch position, same shape as the channels matrix
  • snums (List[str]) – serial numbers in order as a flatten list of the channels matrix
  • start_btn (ttk.Button) – start button on the options screen
  • need_oven (bool) – True if the program needs to use the oven, False otherwise
  • options (options_frame.OptionsPanel) – options screen wrapper
  • table (DataTable) – data table screen wrapper
  • graph_helper (graphing.Graphing) – graphing screen wrapper
check_device_config()[source]

Checks if the device configuration is valid on the home screen. The IP addresses are correctly formatted, and the ports are integer values.

Return type:bool
Returns:True if the home screen device inputs are properly configured, False otherwise
connect_devices(thread_id)[source]

Connect to all the required devices, as configured on the main screen.

Parameters:thread_id (UUID) – the thread the code is currently running in
Return type:bool
Returns:True if all the devices can be connected to, False otherwise
create_excel()[source]

Creates excel file, in a new thread.

disconnect_devices()[source]

Disconnect all the devices, and set them to None.

get_wave_amp_data(thread_id)[source]

Use the dev_helper module to get the wavelength and power data from the SM125.

Parameters:thread_id (UUID) – UUID of the thread the code is currently running in
Return type:Tuple[List[float], List[float]]
Returns:wavelength readings, power readings
handle_partial_cycles()[source]
is_valid_file()[source]

Checks if the file is valid, either there is an entry for the program name in the map table of the same type, or the file can be created at the specified location.

Return type:bool
Returns:True if the file is valid, False otherwise
pause_program()[source]

Pauses the program, and stops the running thread.

program_loop(thread_id)[source]

Main loop that the program uses to run.

Parameters:thread_id (UUID) – UUID of the thread running the program loop
run_program()[source]

Setups the thread and the thread map, and then starts the data collection process.

save_config_info()[source]

Write the options, and devices configuration to the prog_config and devices config respectively.

set_oven_temp(temp=None, heat=True, force_connect=False, thread_id=None, cooling=False)[source]

Sets the oven temperature to temp, or to the bake temperature configured on the options screen.

Parameters:
  • temp (Optional[float]) – temp to set the oven to, if None use the baking temperature on the options screen
  • heat (bool) – If True turn on the heater
  • force_connect (bool) – If True make sure the device is connected to, otherwise only try to connect to the device once
  • thread_id – UUID of the thread the code is currently running in
  • cooling – If True turn on the oven cooling
setup_tabs()[source]

Setup the configuration, graphing, and table tabs.

start()[source]

Checks to make sure all the settings are properly configured, and then runs the program if they are. Pause the program if the program is already running.

temp_controller_error()[source]

Writes a temperature controller warning message to the queue log.

class fbgui.program.ProgramType(prog_id)[source]

Bases: object

Defines constants for calibration and baking programs.

Variables:
  • start_title (str) – Title of the start button when the program is paused on the options screen
  • title (str) – Title of the program options screen

fbgui.reset_config module

Makes sure configuration files are setup.

fbgui.reset_config.add_column_to_map(cursor, column_name, data_type)[source]
fbgui.reset_config.reset_config(rewrite_dev=False, rewrite_program=False)[source]

Ensures the configuration files, and database exist. Writes default config files if they do not exist

fbgui.ui_helper module

Helper functions that help setup the ui.

fbgui.ui_helper.array_entry(container, label_text, row, width, height, default_arr=None)[source]

Creates an entry to input multi line text, used for storing array values.

Parameters:
  • container (Frame) – frame to add the widgets to
  • label_text (str) – text to write to the label
  • row (int) – row of the container to add the widgets to
  • width (int) – the width of the text widget
  • height (int) – the height of the text widget
  • default_arr (Optional[List[~T]]) – If not None, the default array to write to the text widget
Return type:

Text

Returns:

the text widget created

fbgui.ui_helper.baking_sensitivity_entry(container, label_text, row, default_value)[source]
Return type:Text
fbgui.ui_helper.browse_file(file_label_var)[source]

Updates the excel text entry for the selected file, using the filedialog.

Parameters:file_label_var (StringVar) – the file label variable referencing the file input entry on the options screen
fbgui.ui_helper.checkbox_entry(container, label_text, row, checked=True)[source]

Creates a checkbox entry, and returns a reference to the entry var.

Parameters:
  • container (Frame) – the container to add the widgets to
  • label_text (str) – the text to set the label to
  • row (int) – the row of the container to add the widgets to
  • checked (bool) – If True the widget defaults to being checked
Return type:

IntVar

Returns:

IntVar referencing the checkbutton

fbgui.ui_helper.conn_warning(dev)[source]

Warn the user that there was an error connecting to a device.

Parameters:dev (str) – the device identifier string
fbgui.ui_helper.device_entry(container, dev_text, loc_str, row, port_str, loc_var, port_var)[source]

Creates an entry in the device grid for a device.

Parameters:
  • container (Frame) – the frame to add the widgets to
  • dev_text (str) – the device name used as the label text
  • loc_str (str) – the string to set the location entry to
  • row (int) – the row to add the widgets to in the container
  • port_str (Optional[str]) – the string to set the port entry to if not None
  • loc_var (StringVar) – the variable referencing the device location
  • port_var (Optional[StringVar]) – If the port_str is not None, the variable referencing the device port
fbgui.ui_helper.double_entry()[source]

Creates a labeled entry that looks for a double value as the input.

Return type:DoubleVar
fbgui.ui_helper.extra_point_entry(container, label_text, row, temperature_value)[source]
Return type:Tuple[DoubleVar, Text, Text]
fbgui.ui_helper.file_entry(text_var, container, row, label)[source]

Creates a labeled entry with a browse button for the excel file.

Parameters:
  • text_var (StringVar) – the variable that will store the entry value
  • container (Frame) – the container to add the widgets to
  • row (int) – the row of the container grid to add the widget to
  • label (Label) – the row label, used for binding an onClick handler
fbgui.ui_helper.get_all_children_tree(tree, item='')[source]

Get all of the children of item.

Parameters:
  • tree (Treeview) – treeview to look through
  • item (str) – parent element to recursively look for children from
Return type:

List[~T]

Returns:

List of all of the children of item

fbgui.ui_helper.int_entry()[source]

Creates a labeled entry that looks for an integer value as the input.

Return type:IntVar
fbgui.ui_helper.loc_warning(loc_type)[source]

Warn the user of an invalid location input.

Parameters:loc_type (str) – string identifying what type of connection is attempting to be made
fbgui.ui_helper.lock(widget, state)[source]

Either lock or unlock a widget based on the state string.

Parameters:
  • widget (Widget) – recursively lock/unlock if its a frame otherwise change the config to the specified state
  • state (str) – state to set the widgets to
fbgui.ui_helper.lock_main_widgets(main)[source]

Lock all of the widgets on the main device frame.

Parameters:main (Frame) – the main device frame
fbgui.ui_helper.lock_widgets(options_frame)[source]

Locks the widgets to prevent the user from editing while the program is running. Lock all the widgets in the options_grid and the fbg_grid of the options_panel.

Parameters:options_frame (OptionsPanel) – options screen wrapper
fbgui.ui_helper.remove_snum_entry(snum_frame)[source]

Remove a serial number frame.

fbgui.ui_helper.serial_num_entry(container, row, col, def_snum, switch_pos)[source]

Creates a serial number entry with channel number and switch position.

Parameters:
  • container (Frame) – the frame to add the widgets to
  • row (int) – the row of the container grid to add the widgets to
  • col (int) – the column of the container grid to add the widgets to
  • def_snum (str) – the default name of the serial number being added
  • switch_pos (Optional[int]) – the default switch position, if None then use 0 as the switch position
Return type:

Tuple[Entry, IntVar, Frame, IntVar]

Returns:

serial number entry widget, IntVar referencing the switch position spinbox, the frame containing the serial number entry and switch position switchbox for a FBG, and an IntVar referencing the CheckButton

fbgui.ui_helper.setup_style()[source]

Sets up the main style of the program.

fbgui.ui_helper.show_entries(_, title, temperature, values_entry)[source]
fbgui.ui_helper.sort_column(tree, col, descending)[source]

Sort tree contents when a column header is clicked on.

Parameters:
  • tree (Treeview) – the root tree to sort
  • col (int) – the column of the tree to sort
  • descending (bool) – If True sort in descending order, otherwise sort in ascending order
fbgui.ui_helper.string_entry()[source]

Creates a labeled entry that looks for a string value as the input.

Return type:StringVar
fbgui.ui_helper.ui_entry(var_type, use_func=False)[source]

Decorator for a standard ui entry input field.

Parameters:
  • var_type – tkinter variable class to use for the ttk Entry
  • use_func (bool) – If True call the wrapped function
fbgui.ui_helper.units_entry(container, label_text, row, width, unit, default_double=0.0)[source]

Creates a time entry, and returns a reference to the entry var.

Parameters:
  • container (Frame) – the frame to add the widgets to
  • label_text (str) – the text to write to the label
  • row (int) – the row of the container grid to add the widgets to
  • width (int) – the width of the entry widget
  • unit (str) – the string representing the unit the values of the entry are in
  • default_double (float) – the default value to use for the widget
Return type:

DoubleVar

Returns:

the DoubleVar referencing the entry

fbgui.ui_helper.unlock_main_widgets(main)[source]

Unlock all the widgets in the main device frame.

Parameters:main (Frame) – main device frame on the home screen
fbgui.ui_helper.unlock_widgets(options_frame)[source]

Unlocks the widgets.

Parameters:options_frame (OptionsPanel) – options screen wrapper, unlock all widgets in the options_frame

Module contents