redvypr.devices.network.iored¶
Internet of Redvypr (iored) device
Multicast¶
The device provides a multicast based information of the datastreams provided by the redvypr host. It does also listens to multicasts from other redvypr hosts. If a info is received it is sent as a blank datapcket. The distribute_data/do_statistics functionality will add the remote device and host to the available datastreams and will create a datastream_changed signal. That signal is connected by iored and the display widget for an update of datastreams sent over multicast and displayed in the gui.
Zeromq pub/sub¶
The data that is published is a multipart packet:
[b'test_device_0:redvypr@192.168.236.188::93328248922693-217', b't1675787270.261712', b'_redvypr:
device: test_device_0
devicemodulename: test_device
host:
addr: 192.168.236.188
hostname: redvypr
local: true
tstart: 1675787257.351031
uuid: 93328248922693-217
numpacket: 4
t: 1675787257.50375
data: Hello World! t: 1675787257.50375 ‘]
The first part is the address of the device “test_device_0:redvypr@192.168.236.188::93328248922693-217”, the format is “’<device>:<host>@<addr>::<uuid>’” The second part the unix time as a string: “t1675787270.261712” The third part the data packet as a yaml string
How subscriptions work:
iored compares all subscriptions of this host with all online iored/redvyprs. If there is a match, the host will be subscribed.
The device infodata is a dictionary of this structure and is created by create_info_packet():
info_data = {'host': {'hostname': 'redvypr', 'tstart': 1677037052.8936212, 'addr': '192.168.178.26', 'uuid': '93328248922693-056', 'local': True}, 't': 1677037146.6887786, 'zmq_pub': 'tcp://192.168.178.26:18197', 'zmq_rep': 'tcp://192.168.178.26:18196', 'deviceinfo_all': {'iored_0': {'iored_0:redvypr@192.168.178.26::93328248922693-056': {'_redvypr': {'tag': {'93328248922693-056': 1}, 'device': 'iored_0', 'host': {'hostname': 'redvypr', 'tstart': 1677037052.8936212, 'addr': '192.168.178.26', 'uuid': '93328248922693-056', 'local': True}, 't': 1677037053.0344708, 'devicemodulename': 'iored', 'numpacket': 2}, 'datakeys': [], '_deviceinfo': {'subscribe': True, 'publish': True, 'devicemodulename': 'iored'}, '_keyinfo': {}}}, 'test_device_1': {'test_device_1:redvypr@192.168.178.26::93328248922693-056': {'_redvypr': {'tag': {'93328248922693-056': 1}, 'device': 'test_device_1', 'host': {'hostname': 'redvypr', 'tstart': 1677037052.8936212, 'addr': '192.168.178.26', 'uuid': '93328248922693-056', 'local': True}, 't': 1677037145.0688086, 'devicemodulename': 'test_device', 'numpacket': 144}, 'datakeys': ['data', 'count', 't'], '_deviceinfo': {'subscribe': False, 'publish': True, 'devicemodulename': 'test_device'}, '_keyinfo': {'data': {'unit': 'string', 'description': 'Some sentence sent'}, 'count': {'datatype': 'int', 'unit': 'count', 'description': 'Simple packetcount'}}}, 't2:redvypr@192.168.178.26::93328248922693-056': {'_redvypr': {'device': 't2', 'tag': {'93328248922693-056': 1}, 'host': {'hostname': 'redvypr', 'tstart': 1677037052.8936212, 'addr': '192.168.178.26', 'uuid': '93328248922693-056', 'local': True}, 't': 1677037145.0688086, 'devicemodulename': 'test_device', 'numpacket': 144}, 'datakeys': ['t', 'count'], '_deviceinfo': {}, '_keyinfo': {}}}}, 'hostinfo_opt': {'template_name': 'hostinfo_opt'}}
Functions
|
Processes information packet from a redvypr instance. |
|
Connects to a remote iored by starting a thread :param remote_uuid: |
|
|
|
Creates a binary information packet that is used to by iored to send the information about the redvypr instance. |
|
Creates a binary information packet that is used by iored to send the information about the redvypr instance. |
|
Creates a binary information packet to inform that the device is stopped :param device_info: :param url_pub: :param url_rep: |
|
|
|
Filters the deviceinfo_all data structure and removes devices that are not publishing :returns: data_filt dictionary with the devices filtered (at the moment if they publish) |
|
Save the hostinformation in hostinfo dictionary and creates/sends datapackages to the redvypr main task. |
|
Queries a host with url using a zmq req getinfo command :param url: str: address of the host, zmq rep url like tcp://localhost:18196 |
|
A thread wrapper for query-host to be run as thread |
|
|
|
zeromq thread to reply for remote requests for information |
|
zeromq thread for receiving data from a remote redvypr/iored host with a zmq.PUB socket. |
|
Publishes data via sock_zmq_pub :param sock_zmq_pub: zmq publish socket :param data: redvypr data packet :param address_style: The style of the address that is used for subscription |
Classes
|
iored device |
|