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:
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 eachPilot_Button
pilots – Usually the Terminal’s
pilots
dict. If not passed, will try to loadparams.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()
) – SeeControl_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 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
Terminal
object, as they share thesubjects
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 aSubject_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 dumpspilots
toprefs.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: Optional[list] = None)[source]
Add a
Pilot_Panel
for a new pilot, and populate aSubject_List
for 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_Wizard
to create a new subject file and assign protocol. Finally, adds the new subject to thepilots
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 dumpspilots
toprefs.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 updatespilots
when 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_Panel
drop_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.subjects
to the list.dropEvent
(event)A trivial redefinition of
QtWidgets.QListWidget.dropEvent()
that calls the parent dropEvent and then callsdrop_fn
Attributes:
- dropEvent(event)[source]
A trivial redefinition of
QtWidgets.QListWidget.dropEvent()
that calls the parent dropEvent and then callsdrop_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
the name of a pilot,
A
Pilot_Button
to 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_List
we controlstart_fn (
toggle_start()
) – Passed byControl_Panel
create_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 = <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/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 = <PySide2.QtCore.QMetaObject object at 0x7fa11f840f80>