Files
@ b433eae633b8
Branch filter:
Location: HydroBot/hydrobot-software/protocol.py - annotation
b433eae633b8
2.5 KiB
text/x-python
Added config sensor type and removed old files that are no longer needed.
25926382c27b 25926382c27b 25926382c27b 25926382c27b 25926382c27b 25926382c27b 25926382c27b 25926382c27b 25926382c27b 25926382c27b 25926382c27b 25926382c27b 25926382c27b 25926382c27b 25926382c27b 25926382c27b 25926382c27b 25926382c27b 25926382c27b 25926382c27b 25926382c27b 25926382c27b 25926382c27b 25926382c27b 25926382c27b 25926382c27b 25926382c27b 25926382c27b 25926382c27b 25926382c27b 25926382c27b 25926382c27b 25926382c27b 25926382c27b 25926382c27b 25926382c27b 25926382c27b 25926382c27b 25926382c27b 25926382c27b 25926382c27b 25926382c27b 25926382c27b 25926382c27b 25926382c27b 25926382c27b 25926382c27b 25926382c27b 25926382c27b 25926382c27b 25926382c27b 25926382c27b 25926382c27b 25926382c27b 25926382c27b 25926382c27b 25926382c27b 25926382c27b 25926382c27b 25926382c27b 25926382c27b 25926382c27b 25926382c27b 25926382c27b 25926382c27b 25926382c27b 25926382c27b 25926382c27b 25926382c27b 25926382c27b 25926382c27b 25926382c27b 25926382c27b b433eae633b8 b433eae633b8 b433eae633b8 b433eae633b8 b433eae633b8 b433eae633b8 | import json
_protocol_def = None
with open('hydrobot_def.json') as def_file:
_protocol_def = json.load(def_file)
def lookup_device_name_by_id(id):
devices = _protocol_def['devices']
for device in devices:
if device.get('id') == "{0:#0{1}x}".format(id, 4):
return device.get('name')
def lookup_device_id_by_name(name):
devices = _protocol_def['devices']
for device in devices:
if device.get('name') == name:
return int(device.get('id'), 16)
def lookup_device_display_by_id(id):
devices = _protocol_def['devices']
for device in devices:
if device.get('id') == "{0:#0{1}x}".format(id, 4):
return device.get('display')
def lookup_device_class_by_id(id):
devices = _protocol_def['devices']
for device in devices:
if device.get('id') == "{0:#0{1}x}".format(id, 4):
return device.get('class')
def lookup_device_display_by_name(name):
devices = _protocol_def['devices']
for device in devices:
if device.get('name') == name:
return device.get('display')
def lookup_data_name_by_key(key):
data_keys = _protocol_def['data_keys']
for data_key in data_keys:
if data_key.get('key') == "{0:#0{1}x}".format(key, 6):
return data_key.get('name')
def lookup_data_key_by_name(name):
data_keys = _protocol_def['data_keys']
for data_key in data_keys:
if data_key.get('name') == name:
return int(data_key.get('key'), 16)
def lookup_data_display_by_key(key):
data_keys = _protocol_def['data_keys']
for data_key in data_keys:
if data_key.get('key') == "{0:#0{1}x}".format(key, 6):
return data_key.get('display')
def lookup_command_name_by_key(key):
commands = _protocol_def['command_keys']
for command in commands:
if command.get('key') == "{0:#0{1}x}".format(key, 6):
return command.get('name')
def lookup_command_key_by_name(name):
commands = _protocol_def['command_keys']
for command in commands:
if command.get('name') == name:
return int(command.get('key'), 16)
def lookup_command_display_by_key(key):
commands = _protocol_def['command_keys']
for command in commands:
if command.get('key') == "{0:#0{1}x}".format(key, 6):
return command.get('display')
def lookup_sensors_by_device_name(name):
devices = _protocol_def['devices']
for device in devices:
if device.get('name') == name:
return device.get('sensors')
|