Attempts to fix cards not reading at Kiesha Well, POC-104

This commit is contained in:
Patrick McDonagh
2016-08-10 16:58:44 -05:00
parent 43e0c627e9
commit 0aab5dcdcc

View File

@@ -1,7 +1,7 @@
#!/usr/bin/python #!/usr/bin/python
# import types # import types
# import traceback import traceback
# import binascii # import binascii
import threading import threading
import time import time
@@ -30,6 +30,7 @@ plc_ip = '192.168.1.20'
def readTag(addr, tag): def readTag(addr, tag):
time.sleep(0.01)
c = ClxDriver() c = ClxDriver()
if c.open(addr): if c.open(addr):
try: try:
@@ -182,14 +183,22 @@ class Card():
self.num_points = int(readTag(plc_ip, "Card_Past[1].Num_Points")[0]) self.num_points = int(readTag(plc_ip, "Card_Past[1].Num_Points")[0])
print("reading {} from card ID {}".format(self.num_points, self.card_id)) print("reading {} from card ID {}".format(self.num_points, self.card_id))
for i in range(0, self.num_points): for i in range(0, self.num_points):
surf_pos = round(float(readTag(plc_ip, 'Card_Past[1].Surface_Position[{}]'.format(i))[0]), 3) try:
surf_lod = round(float(readTag(plc_ip, 'Card_Past[1].Surface_Load[{}]'.format(i))[0]), 3) surf_pos = round(float(readTag(plc_ip, 'Card_Past[1].Surface_Position[{}]'.format(i))[0]), 3)
down_pos = round(float(readTag(plc_ip, 'Card_Past[1].Downhole_Position[{}]'.format(i))[0]), 3) surf_lod = round(float(readTag(plc_ip, 'Card_Past[1].Surface_Load[{}]'.format(i))[0]), 3)
down_lod = round(float(readTag(plc_ip, 'Card_Past[1].Downhole_Load[{}]'.format(i))[0]), 3) if not (surf_pos == 0.0) and not (surf_lod == 0.0):
if not (surf_pos == 0.0) and not (surf_lod == 0.0): self.sc.append([surf_pos, surf_lod])
self.sc.append([surf_pos, surf_lod]) except:
if not (down_pos == 0.0) and not (down_lod == 0.0): print("Unable to read surface point {}".format(i))
self.dc.append([down_pos, down_lod])
try:
down_pos = round(float(readTag(plc_ip, 'Card_Past[1].Downhole_Position[{}]'.format(i))[0]), 3)
down_lod = round(float(readTag(plc_ip, 'Card_Past[1].Downhole_Load[{}]'.format(i))[0]), 3)
if not (down_pos == 0.0) and not (down_lod == 0.0):
self.dc.append([down_pos, down_lod])
except:
print("Unable to read downhole point {}".format(i))
def stringify(self): def stringify(self):
''' returns a list of two strings [surface card, downhole card]''' ''' returns a list of two strings [surface card, downhole card]'''
@@ -317,6 +326,7 @@ class start(threading.Thread, deviceBase):
except Exception, e: except Exception, e:
sleep_timer = 20 sleep_timer = 20
print "Error during {0} of run loop: {1}\nWill try again in {2} seconds...".format(runLoopStatus, e, sleep_timer) print "Error during {0} of run loop: {1}\nWill try again in {2} seconds...".format(runLoopStatus, e, sleep_timer)
traceback.print_exc()
time.sleep(sleep_timer) time.sleep(sleep_timer)
def checkStatus(self): def checkStatus(self):
@@ -331,7 +341,11 @@ class start(threading.Thread, deviceBase):
1000: 'PLC Error', 1000: 'PLC Error',
9999: 'No Response' 9999: 'No Response'
} }
status = statusMap[int(readTag(plc_ip, "Pump.Run_Status")[0])] s = int(readTag(plc_ip, "Pump.Run_Status")[0])
try:
status = statusMap[s]
except:
print("Could not map status for {}".format(s))
if status: if status:
date = time.time() date = time.time()