PeelCapture – Custom Devices

  1. Adding a new device
  2. Device module
  3. Methods

Adding a new device

New devices can be added using pythons scripts.

To add a new device, create a new device class that is a subclass of PeelDeviceBase and put the .py module for your class in python\peel_devices. See python\peel_devices\ as an example of how a Device class should be constructed. The base class is defined in python\peel_devices\

The source code for all devices is available on github here.

If you find any bugs or have any suggestions for new devices, please create issues on github or create merge requests.

Top Home

Device Module

Your device module should implement the something similar to this template:

from peel_devices import PeelDevice

class MyDevice(PeelDevice):

    def __init__(self, name):
        super(MyDevice, self).__init__(name, foo)
        self.state = None = foo

    def device():
        # Return a unique name for this device class
        return "mydevice"

    def as_dict(self):
        # dict keys should match constructor arguments
        return {'name':, 'foo': }

    def teardown():
        # disconnect/remove device

    def thread_join():
        # block while device is being shutdown

    def __str__(self):
        # Return the unique name of this device instance

    def get_state(self):
        # Called by the app or calls to update_state() update the device state
        if self.state is None:      return "OFFLINE"
        if self.state == "stopped": return "ONLINE"
        if self.state == "running": return "RECORDING"
        if self.state == "fail":    return "ERROR"
        return "ERROR"

    def command(self, command, argument):
        # record and stop actions
        if command == "record":
            self.state = "running"
            print("Take is: " + str(argument))

        if command == "stop":
            self.state = "stopped"

        # Push a state update to the main app
        # Uses get_state() and get_info() for state/info values

    def get_info(self):
        # return some status info to show in the device dialog
        return "hello!"

    def dialog(settings):
        # return a qt gui widget used to create the device
        # SimpleDeviceWidget can be used for many devices

    def dialog_callback(widget):
        # callback when the create widget is confirmed.  Create a new instance
        # of your device using the values in the widget.  Return the new device.

    def edit(self, settings):
        # return a qt gui widget to edit the device
    def edit_callback(self, widget):
        # callback when the edit wiget is confirmed. Update the device
        # using the values from the widget   

    def has_harvest(self):
        # Return true if the device is able to copy files locally
        return True
    def harvest(self, directory):
        # copy the data from the device to the directory

See the code examples in the python/peel_devices directory for more examples.

Top Home