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\stub.py as an example of how a Device class should be constructed. The base class is defined in python\peel_devices\__init__.py
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 self.foo = foo @staticmethod def device(): # Return a unique name for this device class return "mydevice" def as_dict(self): # dict keys should match constructor arguments return {'name': self.name, 'foo': self.foo } def teardown(): # disconnect/remove device pass def thread_join(): # block while device is being shutdown pass def __str__(self): # Return the unique name of this device instance return self.name 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 self.update_state() def get_info(self): # return some status info to show in the device dialog return "hello!" @staticmethod def dialog(settings): # return a qt gui widget used to create the device # SimpleDeviceWidget can be used for many devices pass @staticmethod 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. pass def edit(self, settings): # return a qt gui widget to edit the device pass 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 pass
See the code examples in the python/peel_devices directory for more examples.