devices were always CLX
This commit is contained in:
17
tagserver.py
17
tagserver.py
@@ -19,10 +19,11 @@ scan_rate = 30 # seconds
|
||||
save_all = "test" # use True, False, or any string
|
||||
|
||||
tag_store = {}
|
||||
device_types = {}
|
||||
|
||||
|
||||
def main():
|
||||
global web_address, scan_rate, save_all, tag_store
|
||||
global web_address, scan_rate, save_all, tag_store, device_types
|
||||
try:
|
||||
# Get tags stored in database
|
||||
get_tag_request_data = {'where': '{"tag_class": 5}'}
|
||||
@@ -33,6 +34,18 @@ def main():
|
||||
time.sleep(10)
|
||||
main()
|
||||
|
||||
try:
|
||||
# Get tags stored in database
|
||||
|
||||
get_device_type_request = requests.get('{}/device_type'.format(web_address))
|
||||
device_types_json = json.loads(get_device_type_request.text)
|
||||
for t in device_types_json:
|
||||
device_types[t['id']] = t['dType']
|
||||
except Exception, e:
|
||||
print("Error getting tags: {}".format(e))
|
||||
time.sleep(10)
|
||||
main()
|
||||
|
||||
try:
|
||||
sr_req_data = 'where={"parameter": "scan_rate"}'
|
||||
sr_req = requests.get('{}/config?{}'.format(web_address, sr_req_data))
|
||||
@@ -58,7 +71,7 @@ def main():
|
||||
|
||||
for t in tags:
|
||||
# name, tag, db_id, data_type, change_threshold, guarantee_sec, mapFn=None, device_type='CLX', ip_address='192.168.1.10'):
|
||||
tag_store[t['name']] = Tag(t['name'], t['tag'], t['id'], t['data_type'], t['change_threshold'], t['guarantee_sec'], mapFn=t['map_function'], ip_address=t['deviceID']['address'])
|
||||
tag_store[t['name']] = Tag(t['name'], t['tag'], t['id'], t['data_type'], t['change_threshold'], t['guarantee_sec'], mapFn=t['map_function'], ip_address=t['deviceID']['address'], device_type=device_types[t['deviceID']['device_type']])
|
||||
|
||||
while True:
|
||||
for tag in tag_store:
|
||||
|
||||
Reference in New Issue
Block a user