Removed error catching for debugging
This commit is contained in:
@@ -35,29 +35,29 @@ def main():
|
||||
for t in tags:
|
||||
tagList.append({"id": int(t[0]), "name": t[1], "val": None, "lastVal": None})
|
||||
|
||||
try:
|
||||
tux = TuxEIP(libpath="/usr/lib/libtuxeip.so")
|
||||
sess = tux.OpenSession(PLC_IP_ADDRESS)
|
||||
reg = tux.RegisterSession(sess)
|
||||
conn = tux.ConnectPLCOverCNET(sess, LGX, 1, 100, 123, randint(0, 9999), 123, 321, 100, 5000, 1, '01')
|
||||
# try:
|
||||
tux = TuxEIP(libpath="/usr/lib/libtuxeip.so")
|
||||
sess = tux.OpenSession(PLC_IP_ADDRESS)
|
||||
reg = tux.RegisterSession(sess)
|
||||
conn = tux.ConnectPLCOverCNET(sess, LGX, 1, 100, 123, randint(0, 9999), 123, 321, 100, 5000, 1, '01')
|
||||
|
||||
while True:
|
||||
for r in tagList:
|
||||
r["val"] = tux.ReadLGXDataAsFloat(sess, conn, r['name'], 1)[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"]
|
||||
while True:
|
||||
for r in tagList:
|
||||
r["val"] = tux.ReadLGXDataAsFloat(sess, conn, r['name'], 1)[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
|
||||
# pass
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
||||
Reference in New Issue
Block a user