Added ability to specify datetime limits

This commit is contained in:
Patrick McDonagh
2016-02-01 18:13:33 -06:00
parent 4dc4aa0555
commit 90f10611ac
10 changed files with 397 additions and 555 deletions

View File

@@ -53,22 +53,24 @@ def main():
print(tagList)
while True:
for r in tagList:
r["val"] = readTag(PLC_IP_ADDRESS, str(r['name']))[0]
print("{0} - {1}".format(r["name"], r["val"]))
if not r["val"] == r["lastVal"]:
with con:
cur = con.cursor()
aQuery = """INSERT INTO vals (tagID, val) VALUES ('%d', '%f');""" % (r["id"], float(r["val"]))
print(aQuery)
cur.execute(aQuery)
con.commit()
r["lastVal"] = r["val"]
try:
for r in tagList:
r["val"] = readTag(PLC_IP_ADDRESS, str(r['name']))[0]
print("{0} - {1}".format(r["name"], r["val"]))
if not r["val"] == r["lastVal"]:
with con:
cur = con.cursor()
aQuery = """INSERT INTO vals (tagID, val) VALUES ('%d', '%f');""" % (r["id"], float(r["val"]))
print(aQuery)
cur.execute(aQuery)
con.commit()
r["lastVal"] = r["val"]
time.sleep(scan_rate)
# except Exception as err:
# print err
# pass
time.sleep(scan_rate)
except Exception as err:
print err
main()
if __name__ == '__main__':
main()