Working with SampleData.py and SSL. Issues still exist with tag graphs
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
'''
|
||||
MySQL Tag Server
|
||||
Sample Tag generator
|
||||
Created on April 7, 2016
|
||||
@author: Patrick McDonagh
|
||||
@description: Continuously loops through a list of tags to store values from a PLC into a MySQL database
|
||||
@@ -15,7 +15,7 @@ import requests
|
||||
import json
|
||||
|
||||
# DEFAULTS
|
||||
db_address = "10.10.10.10:3000"
|
||||
db_address = "localhost:5000"
|
||||
db_url = "https://{}".format(db_address)
|
||||
scan_rate = 30 # seconds
|
||||
save_all = "test" # use True, False, or any string
|
||||
@@ -61,9 +61,8 @@ def main():
|
||||
global db_address, scan_rate, save_all
|
||||
try:
|
||||
# Get tags stored in database
|
||||
get_tag_request_data = {'where': '{"tag_class": 5}'}
|
||||
get_tag_request = requests.get('{}/tag'.format(db_url), params=get_tag_request_data, verify=False)
|
||||
tags = json.loads(get_tag_request.text)
|
||||
get_tag_request = requests.get('{}/api/tags'.format(db_url), verify=False)
|
||||
tags = json.loads(get_tag_request.text)['objects']
|
||||
except Exception as e:
|
||||
print("Error getting tags: {}".format(e))
|
||||
time.sleep(10)
|
||||
@@ -91,10 +90,9 @@ def main():
|
||||
except Exception as e:
|
||||
print("Error getting save-all: {}".format(e))
|
||||
print("I'll just use {} as the save-all parameter...".format(save_all))
|
||||
|
||||
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']] = Sample(t['name'], t['tag'], t['id'], t['data_type'], t['change_threshold'], t['guarantee_sec'], mapFn=t['map_function'], ip_address=t['deviceID']['address'], db_address=db_address)
|
||||
tag_store[t['name']] = Sample(t['name'], t['tag'], t['id'], t['data_type_id'], t['change_threshold'], t['guarantee_sec'], mapFn=t['map_function'], ip_address=t['device']['address'], db_address=db_address)
|
||||
|
||||
while True:
|
||||
for tag in tag_store:
|
||||
|
||||
Reference in New Issue
Block a user