Added ability to specify datetime limits
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user