redvypr.data_packets.addr_in_data

redvypr.data_packets.addr_in_data(devicestring, datapacket, get_devicename=False)

Checks if the redvypr addr is in the datapacket.

Examples of devicestrings:
  • Devicename: rand1

  • Devicename with hostname: rand1:randredvypr

  • Devicename with ip and any hostname: rand1:*@192.168.178.33

  • Devicename with uuid: rand1::5c9295ee-6f8e-11ec-9f01-f7ad581789cc

  • Devicename with hostname, IP and uuid: rand1:redvypr1@192.168.178.33::5c9295ee-6f8e-11ec-9f01-f7ad581789cc

Examples of datastreams:
  • ‘data’ key: data/rand1:randredvypr

  • ‘t’ key with with uuid: t/randdata::5c9295ee-6f8e-11ec-9f01-f7ad581789cc

An example data packet with different devicestrings:

from redvypr.data_packets import addr_in_data

data = {'t': 1648623649.1282434, 'data': 1.2414117419163326, '?data': {'unit': 'randomunit', 'type': 'f'}, 'device': 'testranddata', 'host': {'hostname': 'redvyprtest', 'tstart': 1648623606.2900488, 'addr': '192.168.132.74', 'uuid': '07b7a4de-aff7-11ec-9324-135f333bc2f6'}, 'numpacket': 212}
devicestrings = ['testranddata']
devicestrings.append('*')
devicestrings.append('testranddata:redvyprtest')
devicestrings.append('data/testranddata:redvyprtest')
devicestrings.append('testranddata:someotherredvypr')
devicestrings.append('testranddata:*@192.168.132.74')
devicestrings.append('testranddata::07b7a4de-aff7-11ec-9324-135f333bc2f6')
devicestrings.append('*::07b7a4de-aff7-11ec-9324-135f333bc2f6')
devicestrings.append('*::someotheruuid')
devicestrings.append('t/*')
for devicestr in devicestrings:
    print('Devicestring',devicestr)
    result = addr_in_data(devicestr,data)
    print(result)
    result = addr_in_data(devicestr,data,get_devicename=True)
    print(result)
    print('-------')
Parameters:
  • devicestring (str) – String or list of strings consisting the devicename and, optionally, the hostname/respectively IP-Adress

  • data (dict) – a redvypr data dictionary

  • get_devicename (Optional[bool]) – Default False:

Returns:

  • bool: True if devicestring agrees with data dictionary [get_devicename=False]

  • list: [bool,devicename,expanded]: First entry True is devicestring agrees with dictionary, second entry: the devicename string, third entry True if devicestring was expanded

Return type:

bool or list