Fixes to make the script work correctly

This commit is contained in:
Patrick McDonagh
2016-03-29 09:47:41 -05:00
parent d73d349c2b
commit 3e105f9361

View File

@@ -105,11 +105,12 @@ class Tag():
v = readTag(PLC_IP_ADDRESS, self.tag)
if v:
if self.data_type == 'BOOL' or self.data_type == 'STRING':
if (self.last_send_time == 0) or (self.value is None) or not (self.value == v[0]) or ((time.time() - self.last_send_time) > self.guarantee_sec) or (forceSend):
val = v[0]
if self.mapFn:
val = self.mapFn[val]
if (self.last_send_time == 0) or (self.value is None) or not (self.value == val) or ((time.time() - self.last_send_time) > self.guarantee_sec) or (forceSend):
self.last_value = self.value
self.value = v[0]
if self.mapFn:
self.value = self.mapFn[v[0]]
self.value = val
return True
else:
return False
@@ -136,7 +137,7 @@ class Tag():
class Status(Tag):
def sendToDB(self):
query = "INSERT INTO status (dtime, status) VALUES ({}, '{}')".format(time.time(), self.value)
query = "INSERT INTO run_status (dtime, status) VALUES ({}, '{}')".format(time.time(), self.value)
print query
with con:
cur = con.cursor()
@@ -276,10 +277,14 @@ welltest_tags = {
def readPoints():
global PLC_IP_ADDRESS
num_points = readTag(PLC_IP_ADDRESS, "Card_Past[1].Num_Points")[0]
surf_pos = readArray(PLC_IP_ADDRESS, "Card_Past[1].Surface_Position", num_points + 1)
surf_lod = readArray(PLC_IP_ADDRESS, "Card_Past[1].Surface_Load", num_points + 1)
down_pos = readArray(PLC_IP_ADDRESS, "Card_Past[1].Downhole_Position", num_points + 1)
down_lod = readArray(PLC_IP_ADDRESS, "Card_Past[1].Downhole_Load", num_points + 1)
surf_pos = readArray(PLC_IP_ADDRESS, "Card_Past[1].Surface_Position", num_points + 1)[1:]
surf_pos.append(surf_pos[0])
surf_lod = readArray(PLC_IP_ADDRESS, "Card_Past[1].Surface_Load", num_points + 1)[1:]
surf_lod.append(surf_lod[0])
down_pos = readArray(PLC_IP_ADDRESS, "Card_Past[1].Downhole_Position", num_points + 1)[1:]
down_pos.append(down_pos[0])
down_lod = readArray(PLC_IP_ADDRESS, "Card_Past[1].Downhole_Load", num_points + 1)[1:]
down_lod.append(down_lod[0])
return([surf_pos, surf_lod, down_pos, down_lod])