Skip to content

Create Experiment

SuprajaKumbargeri edited this page May 8, 2023 · 1 revision

This page contains implementation details of the 'Create Experiment' window

class GUI.experimentWindowGui.ExperimentWindowGui(parent_gui, ics, logger)

Bases: [PyQt6.QtWidgets.QMainWindow]

Displays the 'Create Experiment' window. It creates different tables in the window (as seen in the layout) using their respective classes and connects them. It creates the DTO that the Experiment Runner uses.

Parameters for init constructor:

  • parent_gui - Reference to the parent gui, InstrumentServerWindow
  • ics - InstrumentConnectionService object
  • logger - Logging.logger

Relevant attributes:

  • _working_instruments: dictionary of instruments added for the experiment in the Channels table

    Dictionary format: key -> Instrument Name, value -> InstrumentManager object

  • experiment_DTO: the Data Transfer Object with experiment details that the Experiment Runner uses

Relevant Methods:

Channels table related implementation

  • construct_channels_section(): Constructs the QTreeWidget for Channels table using ChannelsTreeWidget class
  • add_channel(): Implements the add instrument functionality to the Channel table
  • remove_channel(): Removes an added instrument from the Channels table
  • edit_channel_quantity(): Modifies an existing instrument's quantity

Step sequence table related implementation

  • construct_step_sequence_section(): Constructs the QTreeWidget for Step Sequence table using StepSequenceTreeWidget class
  • edit_quantity_sequence(): Modifies an existing sequence for a quantity
  • remove_quantity_sequence(): Removes an added quantity from sequence table

Log Channels table related implementation

  • construct_logging_section(): Constructs the QTreeWidget for Log Channels table using StepSequenceTreeWidget class
  • remove_log_quantity(): Removes an added quantity from log table

Experiment Runner related implementation

  • experiment_runner_clicked(): Validates the step sequence, creates an experiment DTO and calls to shiw the Experiment Runner window for the created DTO
  • show_experiment_runner_window(): Creates and shows the Experiment Runner GUI
  • construct_DTO() -> DTO: Constructs the DTO for an experiment

Implementation related to data validation across tables

  • item_valid(ins_name: str, qty_name: str) -> bool: Validates if a quantity (represented as (ins, qty)) already exists in either of Step Sequence and Log Channels table. Returns True if the item doesn't already exist in these tables and hence can be added. Returns False if the item already exists
  • validate_experiment_data(): Checks if the step sequence data is valid to construct an experiment with

class GUI.experimentWindowGui.ChannelsTreeWidget(parent_gui, channels_added, logger)

Bases: [PyQt6.QtWidgets.QTreeWidget]

Constructs the Channels Table Tree Widget and implements all its functionality

Parameters for init constructor:

  • parent_gui - Reference to the parent gui, ExperimentWindowGui
  • channels_added - dictionary for added channels in the table
  • logger - Logging.logger

Relevant attributes:

  • channels_added: dictionary for added channels in the table Dictionary format: key -> Instrument Name, value -> InstrumentManager object
  • quantities_added: dictionary for quantities of each added channel Dictionary format: key -> instrument name value -> dictionary of quantity and QuantityManager objects example: self.quantities_added[ins_name][qty_name] = QuantityManager object

Relevant methods:

  • add_channel_item(instrument_manager): Adds a connected instrument and all its quantities to the Channels table
  • get_value(quantity): Gets the value for the quantity, similar implementation as quantity frames in the instrument manager GUI
  • remove_channel(): Removes a instrument and all its quantities from the Channels table
  • show_quantity_frame_gui(selected_item: QTreeWidgetItem): Resuses quantity frames to modify the value of a quantity
  • _handle_quant_value_change(quantity_changed, new_value): Called by QuantityFrame when the quantity's value is changed. Sets visibility of other quantities depending on new value.

class GUI.experimentWindowGui.StepSequenceTreeWidget(channels_added, item_valid, logger)

Bases: [PyQt6.QtWidgets.QTreeWidget]

Constructs the Step Sequence Table Tree Widget and implements all its functionality

Parameters for init constructor:

  • channels_added - dictionary for added channels in the table
  • item_valid - Callable to the item_valid method in the parent gui (ExperimentWindowGUI)
  • logger - Logging.logger

Relevant attributes:

  • channels_added: dictionary for added channels in the table Dictionary format: key -> Instrument Name, value -> InstrumentManager object
  • quantities_added: dictionary for quantities of each added channel Dictionary format: key -> tuple (instrument_name, quantity_name) value -> SequenceConstructor object

Relevant methods:

  • check_item_valid(instrument_name: str, quantity_name: str): Returns False if the quantity already exists in this table so that it cannot be added again or elsewhere
  • add_tree_item(sequence_constructor: SequenceConstructor): Adds a QTreeWidgetItem for a quantity with its step sequence data
  • show_sequence_constructor_gui(selected_item: QTreeWidgetItem): Displays a quantity's SequenceConstructor dialog and updates the QTreeWidgetItem with the modified step sequence data
  • remove_quantity(): Removes a selected quantity sequence from the Step Sequence Table
  • remove_channel(cute_name: str): Removes all quantity sequences related to an instrument from the Step Sequence Table
  • update_tree(): Sort the tree items based on level value
  • validate_sequence(): Check if the step sequences in the table are valid for an experiment. Check if quantities at the same level have the same number of points.
  • get_step_sequence_quantities(): Provides input quantities and quantity sequences details for the Experiment DTO

class GUI.experimentWindowGui.SequenceConstructor(quantity, logger)

Bases: [PyQt6.QtWidgets.QDialog]

Base class for constructing dialog box for a quantity to define the sequence to be added to the Step Sequence Table. Child classes for should implement quantity data type related implementation. Created by sequence_constructor_factory method.

Parameters for init constructor:

  • quantity - QuantityManager object for the quantity being added to the Step Sequence table
  • logger - Logging.logger

Relevant attributes/properties:

  • instrument_name: Name of the instrument the quantity belongs to (str)
  • quantity_name: Name of the quantity (str)
  • data_type: Data_type as mentioned in the QuantityManager
  • unit: Unit if exists (str)
  • level: Level in the step sequence table this quantity will be added to
  • value_flag: True if single point is selected. False if start and stop values are given.
  • single_point_value: Value to be set at when value_flag is True
  • start_value: Start value when value_flag is False
  • stop_value: Stop value when value_flag is False
  • number_of_points: Number of points in [start, stop] (inclusive range) the sequence should be constructed for
Quantities can be set to two different types of values
        Single point value - quantity is set at a constant value through out the experiment
        Start stop values - quantity is varied from start to stop values through a list of points determined by one of two attributes
                        step value -> divide [start, stop] into a list of points with 'step value' difference between each point
                        number of points -> divide [start, stop] into a list of 'number of points' points

Relevant methods:

* handle_value_checkboxes_toggle(): Handles toggling between single point and start - stop options. Should be implemented by child class

  • handle_step_checkboxes_toggle(): Handles toggling between step size and number of steps options -- enabled by start - stop option. Should be implemented by child class
  • save_data(): Saves the sequence data

class GUI.experimentWindowGui.LogChannelsTreeWidget(channels_added, item_valid, logger)

Bases: [PyQt6.QtWidgets.QTreeWidget]

Constructs the Log Channels Table Tree Widget and implements all its functionality

Parameters for init constructor:

  • channels_added - dictionary for added channels in the table
  • item_valid - Callable to the item_valid method in the parent gui (ExperimentWindowGUI)
  • logger - Logging.logger

Relevant attributes:

  • channels_added: dictionary for added channels in the table Dictionary format: key -> Instrument Name, value -> InstrumentManager object
  • quantities_added: dictionary for quantities of each added channel Dictionary format: key -> tuple (instrument_name, quantity_name) value -> QTreeWidgetItem

Relevant methods:

  • check_item_valid(instrument_name: str, quantity_name: str): Returns False if the quantity already exists in this table so that it cannot be added again or elsewhere
  • remove_quantity(): Removes a selected quantity sequence from the Log Channels Table
  • remove_channel(cute_name: str): Removes all quantity sequences related to an instrument from the Log Channels Table
  • get_log_table_quantities(): Provides output quantities for the Experiment DTO

Table of Contents

Clone this wiki locally