terminal

Classes:

Control_Panel(subjects, start_fn, ping_fn, ...)

A QtWidgets.QWidget that contains the controls for all pilots.

Subject_List([subjects, drop_fn])

A trivial modification of QListWidget that updates pilots when an item in the list is dragged to another location.

Pilot_Panel([pilot, subject_list, start_fn, ...])

A little panel with

Pilot_Button([pilot, subject_list, ...])

A subclass of (toggled) QtWidgets.QPushButton that incorporates the style logic of a start/stop button - ie.

class Control_Panel(subjects, start_fn, ping_fn, pilots)[source]

Bases: PySide2.QtWidgets.QWidget

A QtWidgets.QWidget that contains the controls for all pilots.

Parameters
  • subjects (dict) – See Control_Panel.subjects

  • start_fn (toggle_start()) – the Terminal’s toggle_start function, propagated down to each Pilot_Button

  • pilots – Usually the Terminal’s pilots dict. If not passed, will try to load params.PILOT_DB

Variables
  • subjects (dict) – A dictionary with subject ID’s as keys and data.subject.Subject objects as values. Shared with the Terminal object to manage access conflicts.

  • start_fn (toggle_start()) – See Control_Panel.start_fn

  • pilots (dict) – A dictionary with pilot ID’s as keys and nested dictionaries containing subjects, IP, etc. as values

  • subject_lists (dict) – A dict mapping subject ID to subject_List

  • layout (QGridLayout) – Layout grid for widget

  • panels (dict) – A dict mapping pilot name to the relevant Pilot_Panel

Specifically, for each pilot, it contains

  • one subject_List: A list of the subjects that run in each pilot.

  • one Pilot_Panel: A set of button controls for starting/stopping behavior

This class should not be instantiated outside the context of a Terminal object, as they share the subjects dictionary.

Methods:

init_ui()

Called on init, creates the UI components.

add_pilot(pilot_id[, subjects])

Add a Pilot_Panel for a new pilot, and populate a Subject_List for it :Parameters: * pilot_id (str) -- ID of new pilot * subjects (list) -- Optional, list of any subjects that the pilot has.

create_subject(pilot)

Becomes Pilot_Panel.create_fn.

update_db([pilots])

Gathers any changes in Subject_List s and dumps pilots to prefs.get('PILOT_DB')

Attributes:

staticMetaObject

init_ui()[source]

Called on init, creates the UI components.

Specifically, for each pilot in pilots, make a subject_List: and Pilot_Panel:, set size policies and connect Qt signals.

add_pilot(pilot_id: str, subjects: Optional[list] = None)[source]

Add a Pilot_Panel for a new pilot, and populate a Subject_List for it :Parameters: * pilot_id (str) – ID of new pilot

  • subjects (list) – Optional, list of any subjects that the pilot has.

Returns:

create_subject(pilot)[source]

Becomes Pilot_Panel.create_fn. Opens a New_Subject_Wizard to create a new subject file and assign protocol. Finally, adds the new subject to the pilots database and updates it.

Parameters

pilot (str) – Pilot name passed from Pilot_Panel, added to the created Subject object.

update_db(pilots: Optional[dict] = None, **kwargs)[source]

Gathers any changes in Subject_List s and dumps pilots to prefs.get('PILOT_DB')

Parameters

kwargs – Create new pilots by passing a dictionary with the structure

new={‘pilot_name’:’pilot_values’}

where ‘pilot_values’ can be nothing, a list of subjects, or any other information included in the pilot db

staticMetaObject = <PySide2.QtCore.QMetaObject object at 0x7fa11f847300>
class Subject_List(subjects=None, drop_fn=None)[source]

Bases: PySide2.QtWidgets.QListWidget

A trivial modification of QListWidget that updates pilots when an item in the list is dragged to another location.

Should not be initialized except by Control_Panel .

Variables
Parameters
  • subjects – see subjects. Can be None for an empty list

  • drop_fn – see drop_fn(). Passed from Control_Panel

Methods:

populate_list()

Adds each item in Subject_List.subjects to the list.

dropEvent(event)

A trivial redefinition of QtWidgets.QListWidget.dropEvent() that calls the parent dropEvent and then calls drop_fn

Attributes:

staticMetaObject

populate_list()[source]

Adds each item in Subject_List.subjects to the list.

dropEvent(event)[source]

A trivial redefinition of QtWidgets.QListWidget.dropEvent() that calls the parent dropEvent and then calls drop_fn

Parameters

event – A QtCore.QEvent simply forwarded to the superclass.

staticMetaObject = <PySide2.QtCore.QMetaObject object at 0x7fa11f95e380>
class Pilot_Panel(pilot=None, subject_list=None, start_fn=None, ping_fn=None, create_fn=None)[source]

Bases: PySide2.QtWidgets.QWidget

A little panel with

Note

This class should not be instantiated except by Control_Panel

Parameters
Variables
  • layout (QtWidgets.QGridLayout) – Layout for UI elements

  • button (Pilot_Button) – button used to control a pilot

Methods:

init_ui()

Initializes UI elements - creates widgets and adds to Pilot_Panel.layout .

remove_subject()

Remove the currently selected subject in Pilot_Panel.subject_list, and calls the Control_Panel.update_db() method.

create_subject()

Just calls Control_Panel.create_subject() with our pilot as the argument

Attributes:

staticMetaObject

init_ui()[source]

Initializes UI elements - creates widgets and adds to Pilot_Panel.layout . Called on init.

remove_subject()[source]

Remove the currently selected subject in Pilot_Panel.subject_list, and calls the Control_Panel.update_db() method.

create_subject()[source]

Just calls Control_Panel.create_subject() with our pilot as the argument

staticMetaObject = <PySide2.QtCore.QMetaObject object at 0x7fa11f95e0c0>
class Pilot_Button(pilot=None, subject_list=None, start_fn=None, ping_fn=None)[source]

Bases: PySide2.QtWidgets.QPushButton

A subclass of (toggled) QtWidgets.QPushButton that incorporates the style logic of a start/stop button - ie. color, text.

Starts grayed out, turns green if contact with a pilot is made.

Parameters
  • pilot (str) – The ID of the pilot that this button controls

  • subject_list (Subject_List) – The Subject list used to determine which subject is starting/stopping

  • start_fn (toggle_start()) – The final resting place of the toggle_start method

Variables

state (str) – The state of our pilot, reflected in our graphical properties. Mirrors state , with an additional “DISCONNECTED” state for before contact is made with the pilot.

Methods:

toggle_start()

Minor window dressing to call the start_fn() with the appropriate pilot, subject, and whether the task is starting or stopping

set_state(state)

Set the button's appearance and state

Attributes:

staticMetaObject

toggle_start()[source]

Minor window dressing to call the start_fn() with the appropriate pilot, subject, and whether the task is starting or stopping

set_state(state)[source]

Set the button’s appearance and state

Parameters

state (str) – one of ``(‘IDLE’, ‘RUNNING’, ‘STOPPING’, ‘DISCONNECTED’)

Todo

There is some logic duplication in this class, ie. if the button state is changed it also emits a start/stop signal to the pi, which is undesirable. This class needs to be reworked.

Returns:

staticMetaObject = <PySide2.QtCore.QMetaObject object at 0x7fa11f840f80>