Central host to a fleet of
Pilots and user-facing
Called as a module with the -f flag to give the location of a prefs file, eg:
python terminal.py -f prefs_file.json
if the -f flag is not passed, looks in the default location for prefs (ie. /usr/autopilot/prefs.json)
Key Method Description ‘STATE’
A Pi has changed state ‘PING’
Someone wants to know if we’re alive ‘DATA’
Receiving data to store ‘HANDSHAKE’
Pilot first contact, telling us it’s alive and its IP
** Prefs needed by Terminal ** Typically set by
- BASEDIR - Base directory for all local autopilot data, typically /usr/autopilot
- MSGPORT - Port to use for our ROUTER listener, default 5560
- DATADIR - os.path.join(params[‘BASEDIR’], ‘data’)
- SOUNDDIR - os.path.join(params[‘BASEDIR’], ‘sounds’)
- PROTOCOLDIR - os.path.join(params[‘BASEDIR’], ‘protocols’)
- LOGDIR - os.path.join(params[‘BASEDIR’], ‘logs’)
- REPODIR - Path to autopilot git repo
- PILOT_DB - Location of pilot_db.json used to populate
- node (
Net_Node) – Our Net_Node we use to communicate with our main networking object
- networking (
Terminal_Station) – Our networking object to communicate with the outside world
- subjects (dict) – A dictionary mapping subject ID to
- pilots (dict) – A dictionary mapping pilot ID to a list of its subjects, its IP, and any other pilot attributes.
- layout (
QtGui.QGridLayout) – Layout used to organize widgets
- control_panel (
Control_Panel) – Control Panel to manage pilots and subjects
- data_panel (
Plot_Widget) – Plots for each pilot and subject.
- logo (
QtGui.QLabel) – Label holding our beautiful logo ;X
- logger (
logging.Logger) – Used to log messages and network events.
- log_handler (
logging.FileHandler) – Handler for logging
- log_formatter (
Formats log entries as:
"%(asctime)s %(levelname)s : %(message)s"
Start logging to a timestamped file in prefs.LOGDIR
Initializes graphical elements of Terminal.
toggle_start(starting, pilot, subject=None)¶
Start or Stop running the currently selected subject’s task. Sends a message containing the task information to the concerned pilot.
Pilot_Panelis given a lambda function that calls this one with the arguments specified See
Pilot_Button, as it is what calls this function.
- starting (bool) – Does this button press mean we are starting (True) or stopping (False) the task?
- pilot – Which Pilot is starting or stopping?
- subject – Which Subject is currently selected?
A Pilot has sent us data.
value field of message should have subject and pilot added to dictionary for identification.
Any key in value that matches a column in the subject’s trial data table will be saved.
If the subject graduates after receiving this piece of data, stop the current task running on the Pilot and send the new one.
Parameters: value (dict) – A dict of field-value pairs to save
Reminder to implement heartbeating.
Currently unused, as Terminal Net_Node stability hasn’t been a problem and no universal system of heartbeating has been established (global stability has not been an issue).
Parameters: value – (unused)
A Pilot has changed state, keep track of it.
Parameters: value (dict) – dict containing state .
Pilot is sending its IP and state on startup.
If we haven’t heard of this pilot before, make a new entry in
Parameters: value (dict) – dict containing ip and state
Make a new entry in
Terminal.pilotsand make appropriate GUI elements.
gui.Protocol_Wizardto create a new protocol.
Prompts for name of protocol, then saves in prefs.PROTOCOLDIR
Get a list of all subject IDs
Returns: list of all subject IDs present in
Return type: list
Gets recent weights from all
subjectsand open a
gui.Weightswindow to view or set weights.
If we change the protocol file, update the stored version in subject files
Batch reassign protocols and steps.
gui.Reassignwindow after getting protocol data, and applies any changes made in the window.
staticMetaObject= <PySide.QtCore.QMetaObject object>¶
When Closing the Terminal Window, close any running subject objects, ‘KILL’ our networking object.
Since the :class:.Net_Node` keeping us alive is a daemon, no need to explicitly kill it.