SnoopEvents

The driver has method:

async def snoopevent(self, event):

If this driver is ‘snooping’ on other drivers, this method should be written to handle events created as data is received.

Your code should typically use match and case to determine the type of event, and read the event contents, and then take any appropriate action.

Snooping

Snooping can occur on a network of INDI drivers, typically connected together by IPyServer, or using the program ‘indiserver’ from indilib.org. A driver can transmit a ‘getProperties’ command using driver coroutine method:

send_getProperties(devicename=None, vectorname=None)

which requests the server utility to copy traffic from another driver/device to this driver.

If vectorname is None, then all traffic from the specified device will be copied, if devicename is None as well, then traffic from all devices will be copied (apart from devices on this particular driver).

Note: in this implementation, snooping will not occur between devices on the same driver. Your driver code is handling all its devices, so should be able to control all traffic needed between them.

Snooping is typically used when an instrument should only take actions if another remote instrument has already taken a required prior action. Snooping may also be useful as a method of logging traffic.

To snoop on a remote device, send the getProperties command, and handle the incoming traffic using the snoopevent method. The snoop event objects are described below, you never need to create these objects - they are automatically created by the received data, however you should test the event matches an object, and act accordingly.

The event type passed into the method reflects the command sent by the remote device.

Events

All snoop events have attributes devicename, root and timestamp. The root is an xml.etree.ElementTree object. The timestamp is a datetime object, or None if unable to parse the timestamp given in the protocol. In the attempt to parse, fractional minutes or seconds may be lost, and if no received timestamp is given, datetime.utcnow() is used. If the exact received timestamp is required it can be obtained from event.root.get(“timestamp”) which will return either the string from the received xml, or None if not present.

class Message(root)

This contains attribute ‘message’ with the message string sent by the remote driver. Attribute devicename could be None if the driver is sending a system wide message.

class delProperty(root)

The remote driver is instructing the client to delete either a device or a vector property. This contains attribute vectorname, if it is None, then the whole device is to be deleted. A ‘message’ attribute contains any message sent by the client with this instruction.

def Vector events also all have attributes vectorname, label, group, state and message. They are also a mapping of membername:value, which should contain all the vector member names, so for example event[‘membername’] would give the value of that member.

class defSwitchVector(root)

The remote driver has sent this to define a switch vector property, it has further attributes perm, rule, timeout, and memberlabels which is a dictionary of membername:label.

class defTextVector(root)

The remote driver has sent this to define a text vector property, it has further attributes perm, timeout, and memberlabels which is a dictionary of membername:label.

class defNumberVector(root)

The remote driver has sent this to define a number vector property, it has further attributes perm, timeout, and memberlabels which is a dictionary of membername:(label, format, min, max, step).

class defLightVector(root)

The remote driver has sent this to define a light vector property, it has further attribute memberlabels which is a dictionary of membername:label.

class defBLOBVector(root)

The remote driver has sent this to define a BLOB vector property, it has further attributes perm, timeout, and memberlabels which is a dictionary of membername:label.

However this class does not have an object mapping of member name to value, since values are not given in defBLOBVectors

set Vector events all have attributes vectorname, message and state (which could be None if not given due to no change of state). These events are also a mapping of membername:value, so for example event[‘membername’] would give the value of that member. However this object may not include members if they have not changed.

class setSwitchVector(root)

The remote driver is setting a Switch vector property, this has further attribute timeout.

class setTextVector(root)

The remote driver is setting a Text vector property, this has further attribute timeout.

class setNumberVector(root)

The remote driver is setting a Number vector property, this has further attribute timeout. The number values of the membername:membervalue are string values.

class setLightVector(root)

The remote driver is setting a Light vector property.

class setBLOBVector(root)

The remote driver is setting a BLOB vector property, this has further attributes timeout and sizeformat which is a dictionary of membername:(size, format).