terminal
Classes:
|
A |
|
A trivial modification of |
|
A little panel with |
|
A subclass of (toggled) |
- class Control_Panel(subjects, start_fn, ping_fn, pilots)[source]
Bases:
QWidgetA
QtWidgets.QWidgetthat contains the controls for all pilots.- Parameters:
subjects (dict) – See
Control_Panel.subjectsstart_fn (
toggle_start()) – the Terminal’s toggle_start function, propagated down to eachPilot_Buttonpilots – Usually the Terminal’s
pilotsdict. If not passed, will try to loadparams.PILOT_DB
- Variables:
subjects (dict) – A dictionary with subject ID’s as keys and
data.subject.Subjectobjects as values. Shared with the Terminal object to manage access conflicts.start_fn (
toggle_start()) – SeeControl_Panel.start_fnpilots (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_Listlayout (
QGridLayout) – Layout grid for widgetpanels (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
Terminalobject, as they share thesubjectsdictionary.Methods:
init_ui()Called on init, creates the UI components.
add_pilot(pilot_id[, subjects])Add a
Pilot_Panelfor a new pilot, and populate aSubject_Listfor 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_Lists and dumpspilotstoprefs.get('PILOT_DB')Attributes:
- init_ui()[source]
Called on init, creates the UI components.
Specifically, for each pilot in
pilots, make asubject_List: andPilot_Panel:, set size policies and connect Qt signals.
- add_pilot(pilot_id: str, subjects: list | None = None)[source]
Add a
Pilot_Panelfor a new pilot, and populate aSubject_Listfor it :Parameters: * pilot_id (str) – ID of new pilotsubjects (list) – Optional, list of any subjects that the pilot has.
Returns:
- create_subject(pilot)[source]
Becomes
Pilot_Panel.create_fn. Opens aNew_Subject_Wizardto create a new subject file and assign protocol. Finally, adds the new subject to thepilotsdatabase and updates it.- Parameters:
pilot (str) – Pilot name passed from
Pilot_Panel, added to the created Subject object.
- update_db(pilots: dict | None = None, **kwargs)[source]
Gathers any changes in
Subject_Lists and dumpspilotstoprefs.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 = PySide6.QtCore.QMetaObject("Control_Panel" inherits "QWidget": )
- class Subject_List(subjects=None, drop_fn=None)[source]
Bases:
QListWidgetA trivial modification of
QListWidgetthat updatespilotswhen an item in the list is dragged to another location.Should not be initialized except by
Control_Panel.- Variables:
subjects (list) – A list of subjects ID’s passed by
Control_Paneldrop_fn (
Control_Panel.update_db()) – called on a drop event
- Parameters:
subjects – see
subjects. Can be None for an empty listdrop_fn – see
drop_fn(). Passed fromControl_Panel
Methods:
Adds each item in
Subject_List.subjectsto the list.dropEvent(event)A trivial redefinition of
QtWidgets.QListWidget.dropEvent()that calls the parent dropEvent and then callsdrop_fnAttributes:
- dropEvent(event)[source]
A trivial redefinition of
QtWidgets.QListWidget.dropEvent()that calls the parent dropEvent and then callsdrop_fn- Parameters:
event – A
QtCore.QEventsimply forwarded to the superclass.
- staticMetaObject = PySide6.QtCore.QMetaObject("Subject_List" inherits "QListWidget": )
- class Pilot_Panel(pilot=None, subject_list=None, start_fn=None, ping_fn=None, create_fn=None)[source]
Bases:
QWidgetA little panel with
the name of a pilot,
A
Pilot_Buttonto start and stop the taskAdd and remove buttons to
create_subject()andPilot_Panel.remove_subject()
Note
This class should not be instantiated except by
Control_Panel- Parameters:
pilot (str) – The name of the pilot this panel controls
subject_list (
Subject_List) – TheSubject_Listwe controlstart_fn (
toggle_start()) – Passed byControl_Panelcreate_fn (
Control_Panel.create_subject()) – Passed byControl_Panel
- Variables:
layout (
QtWidgets.QGridLayout) – Layout for UI elementsbutton (
Pilot_Button) – button used to control a pilot
Methods:
init_ui()Initializes UI elements - creates widgets and adds to
Pilot_Panel.layout.Remove the currently selected subject in
Pilot_Panel.subject_list, and calls theControl_Panel.update_db()method.Just calls
Control_Panel.create_subject()with our pilot as the argumentAttributes:
- 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 theControl_Panel.update_db()method.
- create_subject()[source]
Just calls
Control_Panel.create_subject()with our pilot as the argument
- staticMetaObject = PySide6.QtCore.QMetaObject("Pilot_Panel" inherits "QWidget": )
- class Pilot_Button(pilot=None, subject_list=None, start_fn=None, ping_fn=None)[source]
Bases:
QPushButtonA subclass of (toggled)
QtWidgets.QPushButtonthat 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/stoppingstart_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:
Minor window dressing to call the
start_fn()with the appropriate pilot, subject, and whether the task is starting or stoppingset_state(state)Set the button's appearance and state
Attributes:
- 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 = PySide6.QtCore.QMetaObject("Pilot_Button" inherits "QPushButton": )