Zenoh bridging

dataClay includes support for publisher/subscriber communication via Zenoh.

In order to use this functionality, the client class has to inherit the ZenohMixin class. Communications can be established using pub/sub and queries. The subscriber can specify how the messages will be handled and to which topics it will be subscribed. Also, it can ask for the last value stored in an existing subscription using the queries. The publisher can send messages to a specific topic.

class dataclay.contrib.zenoh_module.ZenohMixin(conf: str = '{}')[source]

Zenoh mechanisms

get_last_data(key: str = 'dataclay')[source]

Returns the latest value stored in this Zenoh topic.

Parameters:

key (str) – Topic.

Returns:

Latest value stored on a specific Zenoh topic.

Return type:

list[str{reply.key_expr};{reply.playload}]

handler(sample)[source]

Placeholder for function handler. This function describes how the client will handle a message.

Parameters:

sample (zenoh.Sample) – Information sent by Zenoh to the subscriber.

Raises:

NotImplementedError – If the handler function has not been implemented an error is raised.

produce_zenoh_msg(buf: str = '', key: str = 'dataclay', **more)[source]

Sends the message “buf” to the topic “key”.

Parameters:
  • buf (str, optional) – Message. Defaults to “”.

  • key (str, optional) – Topic. Defaults to “dataclay”.

receive_data(key: str = 'dataclay')[source]

Create a thread which will check if a message from the topic arrives and will handle it.

Parameters:

key (str) – Topic.

send_to_zenoh()[source]

Previous function to produce_zenoh_msg. Gets all the arguments needed from the calling class.

unsubscribe(key: str = 'dataclay')[source]

Unsubscribes the client from a topic.

Parameters:

key (str) – Topic.