fbgui package¶
Subpackages¶
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_program module¶
Module for baking program specific logic.
-
class
fbgui.baking_program.BakingProgram(master)[source]¶ Bases:
fbgui.program.ProgramContains 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 inReturn type: boolReturns: True if the drift rate is stable otherwise returns false
-
fbgui.cal_program module¶
Contains the calibration program specific logic.
-
class
fbgui.cal_program.CalProgram(master)[source]¶ Bases:
fbgui.program.ProgramContains 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 cycleReturn type: boolReturns: True if the drift rate is below the configured drift rate, otherwise False
-
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: floatReturns: 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
-
fbgui.calibration_excel_container module¶
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 otherwiseReturn type: List[str]Returns: list of serial numbers
fbgui.constants module¶
Constants used throughout the program.
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.FrameTkinter 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
fbgui.data_container module¶
Data container for database data.
-
class
fbgui.data_container.DataCollection[source]¶ Bases:
objectData 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
- is_cal (
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-
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
-
get_last_cycle_num()[source]¶ Get the number of the last calibration cycle that data is recorded for.
Return type: intReturns: last calibration cycle number, or 0 if there is no data calibration recorded
-
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 cursorReturn type: boolReturns: True if the program exists, otherwise False
-
record_calibration_point(timestamp, temperature, wavelengths, powers, drift_rate, is_real_calibration_point, cycle_num)[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: DataFrameReturns: 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.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.FrameOverrides ttk Frame class used to create a data view.
Variables:
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-
create_series_bake(x_values, y_values, index)[source]¶ Return type: <function SeriesFactory at 0x000001781C6DCA60>
-
show_excel(style_frames, sheet_names, parameters, graph_results, coefficients=None, baking_coefficients=None)[source]¶
-
-
fbgui.excel_file_controller.create_chart(temperatures, extra_point_temperatures=None)[source]¶ Return type: ScatterChart
fbgui.excel_graph_helpers module¶
-
class
fbgui.excel_graph_helpers.BakingGraphParameters(num_rows, trend_line_indexes, sensitivity_indexes)[source]¶
-
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]¶
-
class
fbgui.excel_graph_helpers.CalibrationGraphSubType(graph_type, start_row, reading_type, mean_units=None)[source]¶ Bases:
enum.EnumAn 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.EnumAn enumeration.
-
DEVIATION= ('{} deviation from mean ({})', 'Cycle {}', 'B')¶
-
MEAN= ('{} mean ({})', 'Mean', 'V')¶
-
SENSITIVITY= ('{} sensitivity ({}/K)', 'Sensitivity', 'AP')¶
-
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.NavigationToolbar2TkAggOverrides the default Matplotlib toolbar to add play and pause animation buttons.
Variables: graphing_helper (Graphing) – Graphing helper object that controls 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:
objectClass 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
-
class
fbgui.graphing.Graphing(dims, is_cal, figure, canvas, toolbar, master, snums, main_queue, database_controller)[source]¶ Bases:
objectClass 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¶
-
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
-
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 argumentReturn 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
- axis (
-
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
- axes (
-
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
- axes (
-
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
- val (
-
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
- axis (
-
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
- axes (
-
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
- axis (
-
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
- axis (
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 convertReturn 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 stringsReturn 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 flattenReturn 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 extensionReturn type: strReturns: 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 uniquenessReturn type: boolReturns: 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: Return type: List[~T]Returns: list of values of the cast type
Raises: ValueError – if list cannot be cast to the specified time
fbgui.install module¶
Ensures assets, and helper data is in the correct place.
fbgui.laser_data module¶
fbgui.laser_recorder module¶
Gets the amplitude and wavelength data using the Micron Optics SM125, and the Optical Switch.
fbgui.main_program module¶
Module contains the main entry point for the Kyton UI.
-
class
fbgui.main_program.Application(*args, **kwargs)[source]¶ Bases:
tkinter.TkMain 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
-
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
- dev (
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.FrameWidget 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
-
click_handler(_)[source]¶ Click handler for the Program Log header to allow the user to view developer messages.
-
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 messagesReturn type: OrderedDictReturns: 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
- pattern (
-
class
fbgui.messages.Message(msg_type, title, text)[source]¶ Bases:
objectMessage 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.EnumLength 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.EnumType 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.MutableMappingA 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.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.FrameOptions 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_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:
-
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
-
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: ButtonReturns: the created tkinter Button
-
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
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.NotebookDefinition 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: boolReturns: 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 inReturn type: boolReturns: True if all the devices can be connected to, False otherwise
-
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 inReturn type: Tuple[List[float],List[float]]Returns: wavelength readings, power readings
-
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: boolReturns: True if the file is valid, False otherwise
-
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
- temp (
fbgui.reset_config module¶
Makes sure configuration files are setup.
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: TextReturns: the text widget created
- container (
-
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: Return type: IntVarReturns: 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
- container (
-
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
- text_var (
-
fbgui.ui_helper.get_all_children_tree(tree, item='')[source]¶ Get all of the children of item.
Parameters: 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
- widget (
-
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.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
- container (
-
fbgui.ui_helper.sort_column(tree, col, descending)[source]¶ Sort tree contents when a column header is clicked on.
Parameters:
-
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: DoubleVarReturns: the DoubleVar referencing the entry
- container (
-
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