Module peel_devices
Table of Contents
PeelDeviceBase
All Devices must inherit from peel_devices.PeelDeviceBase. See the Stub device for a fully implemented working example.
Custom devices can be placed in userPython/peel_user_devices directory
- class peel_devices.PeelDeviceBase(name, parent=None)
- as_dict()
Returns the fields and values for this instance. Used by reconfigure recreate the instance between application sessions
- command(command, argument)
Command, Argument may be:
record takename
play takename or “” for last recorded
stop
transport stop | next | prev
notes note - sent when the notes are changed, relevant for the last take
timecode timecode - called when recording starts
selectedTake take - sent when a user selects a take, passes the take name
The following are called when take information needs to be updated, ie the take name has changed or when recording starts:
takeName n
shotName name
shotTag tag
takeNumber n
description description
takeId id
- connect_device()
Initiates the connection to the device. Called by the application. If the device is already connected this function should disconnect it then reconnect again. :return: None
- data_directory()
returns the current data directory for this device
- static device()
returns the string name for this device type
- device_added(widget)
Called after a device has been successfully added or edited
- device_ref(reason, state=None, info=None)
Create a PeelApp.Device() object that contains the information needed to update the main ui. The Device() object is implemented in c++ to make it easier to pass around inside the main app.
This function does not need to be overridden for subclasses, the default should be okay for most uses.
See the note in update_state() about populating state and info values when calling this from get_state() or get_info()
- static dialog_class()
Return the widget class (the class, not an instance)
- get_info(reason=None)
- Parameters
reason – why this is being requested. used to determine if the request to the device should be made
- Returns
The text to put in the main ui next to the device name
- get_state(reason=None)
- Parameters
reason – why this is being requested. used to determine if the request to the device should be made
- Returns
one of: “OFFLINE”, “ONLINE”, “RECORDING”, “PLAYING” or “ERROR”
- harvest(directory, all_files)
Download the takes to the local storage directory
- has_harvest()
Return True if the device supports the ability to download files from the device to local storage
- list_takes()
list the take files currently on the device
- reconfigure(name, **kwargs)
Called to set the device settings. Does not need to be overridden if a different dialog is being used. The kwargs need to match the parameters specified in SimpleDeviceWidget constructor, ie if has_host is True, kwargs will have a “host” parameter. :return: True if values are valid, False will keep the add dialog open to fix issues
- set_enabled(value)
Main app calls this to enable / disable the device. Default behavior is to set self.enabled The implementation of this is somewhat device specific. The minimum expected behavior will be the devices not longer responds to commands and reports status - it will appear greyed out in the ui.
- staticMetaObject = PySide6.QtCore.QMetaObject("PeelDeviceBase" inherits "QObject": )
- teardown()
Called when the app is shutting down - tell all threads to stop and return
- thread_join()
Called when the app is shutting down - block till threads are stopped
- update_state(state=None, info=None, reason='UPDATE')
This function is usually called in response to a device thread or socket changing state or having new info to update in the ui to avoid the need for polling devices.
If state is None, the device’s get_state() will be called for the value.
If info is None, the device’s get_info() will be called to get the value.
A device can call: self.update_state() to push a new state to the app whenever the state has changed.
When calling this function, if the state and info are known they should be provided as arguments. If the state is not known and needs to be obtained by a request to the device, the state and/or info values should not be provided and get_state should actively get the state from the device.
Device implementations of get_state or get_info cannot cause a call to device_ref() as that would trigger a state request and cause a loop.
- Valid values for reason:
DEVICE - the device has initiated the update
BaseDeviceWidget
- class peel_devices.BaseDeviceWidget(settings)
- do_add()
Called when adding a new device to validate the parameters before adding. Should return true if the parameters are valid and false if they are not to stop the device being added and the dialog closing. Default action has a double click check as this appears to happen often, even with a single click.
- populate_from_device(device)
Populate the values in this ui from information in the device class.
- reset_timer()
- set_info(msg)
- staticMetaObject = PySide6.QtCore.QMetaObject("BaseDeviceWidget" inherits "QWidget": )
- update_device(device)
Update the device with values in this dialog. Should not modify the state of device, reconfigure() and connect_device() will be called after
SimpleDeviceWidget
- class peel_devices.SimpleDeviceWidget(settings, title, has_host, has_port, has_broadcast, has_listen_ip, has_listen_port, has_set_capture_folder=False)
- do_add()
The ui is asking for the device to be added - validate and save the settings returns true if the data is valid. If returning false it’s a good idea to pop up a message to the user to say what was wrong
- populate_from_device(device)
populate the gui using data from the provided device object values of None will be left unchanged (set by constructor / qsettings)
- staticMetaObject = PySide6.QtCore.QMetaObject("SimpleDeviceWidget" inherits "BaseDeviceWidget": )
- update_device(device, data=None)
Set the device properties from values in the ui device is the object to modify, by calling reconfigure data has any kwargs for reconfigure to be passed on Return true to close the window when adding
DeviceCollection
- class peel_devices.DeviceCollection(parent=None)
- add_device(device)
Add a new device to the list, called by the Add Device UI
- static all_classes()
Search the peel_devices and peel_user_devices module for any devices that subclass PeelDeviceBase
- from_id(device_id)
- get_data()
get the key value data for all devices, used to save the json data
- has_device(device_name, name)
- load_json(data, mode)
- reconnect(device_id)
- refresh(device_id)
push a status update for a single device
- remove(device_id)
cleanly remove a device from the current list
- remove_all()
Cleanly remove all devices
- staticMetaObject = PySide6.QtCore.QMetaObject("DeviceCollection" inherits "QObject": )
- teardown()
We are shutting down - stop all devices
- unique_name(device_name)
Generate a unique name for the device
- update_all(reason)
push a status update for all devices
XmlUdpListenThread
TcpDevice
XmlUdpDevice
DownloadThread
- class peel_devices.DownloadThread(all_files)
- COPY_FAIL = 0
- COPY_OK = 1
- COPY_SKIP = 2
- STATUS_FINISHED = 3
- STATUS_NONE = 0
- STATUS_RUNNING = 1
- STATUS_STOP = 2
- add_bytes(value)
- all_done
- calc_bandwidth(new_bytes)
- current_file()
- file_done
- file_fail(name, err)
- file_ok(name)
- file_skip(name)
- is_running()
- log(message)
- message
- process()
- progress()
- set_current(index)
- set_finished()
- set_started()
- staticMetaObject = PySide6.QtCore.QMetaObject("DownloadThread" inherits "QObject": Methods: #5 type=Signal, signature=file_done(QString,int,QString), parameters=QString, int, QString #6 type=Signal, signature=all_done() #7 type=Signal, signature=message(QString), parameters=QString )
- teardown()