Device

The device object is a mapping of vectorname:vectorobject, so to access a vector you could use device[‘vectorname’].

As well as the methods documented below, dict methods are available such as get() and iteration through keys(), values() and items().

Similarly a Vector object is a mapping to a member value, so to access a value you could use device[‘vectorname’][‘membername’], which for example, given a SwitchVector would be either “On” or “Off”.


class Device(devicename, properties, **devicedata)

An instance of this should be created for each device controlled by this driver. The properties argument is a list of vectors controlling this device. devicedata will be an attribute dictionary of any hardware data that may be usefull.

This object will be a mapping of vector name to vector object

async devhardware(*args, **kwargs)

As default, does nothing and is not called.

If required, override this to handle any necessary device actions. This should be called from the driver ‘hardware’ method if it is used.

async devrxevent(event, *args, **kwargs)

As default, does nothing and is not called.

If required, override this to handle any necessary device actions. This should be called from the driver ‘rxevent’ method if it is used.

async devsnoopevent(event, *args, **kwargs)

As default, does nothing and is not called.

If required, override this to handle any necessary device actions. This should be called from the driver ‘snoopevent’ method if it is used.

properties()

Returns a list of vector objects

async send_delProperty(message='', timestamp=None)

Sending delProperty with this device method, (as opposed to the vector send_delProperty method) informs the client this device is not available, it also sets a device.enable attribute to False, which stops any data being transmitted between the client and this device. Setting device.enable to True re-enables communications. The message argument is any appropriate string which the client could display to the user. The timestamp should be either None or a datetime.datetime object. If the timestamp is None a UTC value will be inserted.

async send_device_message(message='', timestamp=None)

Send a message associated with this device, which the client could display. The timestamp should be either None or a datetime.datetime object. If the timestamp is None a UTC value will be inserted.

shutdown()

Shuts down the device, sets the flag self._stop to True and shuts down property vector handlers

property stop

returns self._stop, being the instruction to stop the driver

The device has attributes:

devicename

The given name of the device, this device object can be accessed from the driver as driver[devicename]

enable

Automatically set to False if the device is deleted by calling the device send_delProperty() method. The attribute should be set to True to re-enable the device, also for every property of the device, you will need to call the vector send_defVector() method to inform the client that the device and its properties are now available.

devicedata

Set from the device constructer as optional keyword arguments, can be used to pass in hardware data to the device object.

stop

When a driver is shutdown, it automatically calls the shutdown method of each device, which sets this stop flag to True. So this flag could be tested in the devhardware method if that facility is used, and should gracefully shut down the co-routine.

driver

The driver object, can be used to access driver.send_message() and driver.send_getProperties() methods if required, and also to access any other device using the driver mapping feature.