keep the driver up and running if something fails
This commit is contained in:
@@ -267,6 +267,7 @@ class start(threading.Thread, deviceBase):
|
|||||||
time.sleep(sleep_timer)
|
time.sleep(sleep_timer)
|
||||||
|
|
||||||
def checkBackup(self):
|
def checkBackup(self):
|
||||||
|
try:
|
||||||
backupList = json.loads(requests.get(self.device_address + "/json/backups").text)
|
backupList = json.loads(requests.get(self.device_address + "/json/backups").text)
|
||||||
file = backupList["backups"][0]
|
file = backupList["backups"][0]
|
||||||
data = json.loads(requests.get(self.device_address + "/json/backups/" + file).text)
|
data = json.loads(requests.get(self.device_address + "/json/backups/" + file).text)
|
||||||
@@ -276,8 +277,11 @@ class start(threading.Thread, deviceBase):
|
|||||||
self.wellSetup = data
|
self.wellSetup = data
|
||||||
with open('wellSetup.p', 'wb') as handle:
|
with open('wellSetup.p', 'wb') as handle:
|
||||||
pickle.dump(self.wellSetup, handle)
|
pickle.dump(self.wellSetup, handle)
|
||||||
|
except Exception, e:
|
||||||
|
print("checkBackup Error: {}".format(e))
|
||||||
|
|
||||||
def checkEvents(self):
|
def checkEvents(self):
|
||||||
|
try:
|
||||||
data = json.loads(requests.get(self.device_address + "/json/event_list").text)
|
data = json.loads(requests.get(self.device_address + "/json/event_list").text)
|
||||||
events = data["events"]
|
events = data["events"]
|
||||||
for event in events:
|
for event in events:
|
||||||
@@ -290,8 +294,11 @@ class start(threading.Thread, deviceBase):
|
|||||||
del self.eventIds[0]
|
del self.eventIds[0]
|
||||||
with open('eventIds.p', 'wb') as handle:
|
with open('eventIds.p', 'wb') as handle:
|
||||||
pickle.dump(self.eventIds, handle)
|
pickle.dump(self.eventIds, handle)
|
||||||
|
except Exception, e:
|
||||||
|
print("checkEvents Error: {}".format(e))
|
||||||
|
|
||||||
def checkNotes(self):
|
def checkNotes(self):
|
||||||
|
try:
|
||||||
data = json.loads(requests.get(self.device_address + "/json/notes/get").text)
|
data = json.loads(requests.get(self.device_address + "/json/notes/get").text)
|
||||||
notes = data["notes"]
|
notes = data["notes"]
|
||||||
for note in notes:
|
for note in notes:
|
||||||
@@ -304,8 +311,11 @@ class start(threading.Thread, deviceBase):
|
|||||||
del self.noteIDs[0]
|
del self.noteIDs[0]
|
||||||
with open('noteIDs.p', 'wb') as handle:
|
with open('noteIDs.p', 'wb') as handle:
|
||||||
pickle.dump(self.noteIDs, handle)
|
pickle.dump(self.noteIDs, handle)
|
||||||
|
except Exception, e:
|
||||||
|
print("checkNotes Error: {}".format(e))
|
||||||
|
|
||||||
def checkFluidShots(self):
|
def checkFluidShots(self):
|
||||||
|
try:
|
||||||
data = json.loads(requests.get(self.device_address + "/json/fluid_shot/get").text)
|
data = json.loads(requests.get(self.device_address + "/json/fluid_shot/get").text)
|
||||||
fluid_shots = data["fluid_shots"]
|
fluid_shots = data["fluid_shots"]
|
||||||
for shot in fluid_shots:
|
for shot in fluid_shots:
|
||||||
@@ -318,8 +328,11 @@ class start(threading.Thread, deviceBase):
|
|||||||
del self.fluidshotIDs[0]
|
del self.fluidshotIDs[0]
|
||||||
with open('fluidshotIDs.p', 'wb') as handle:
|
with open('fluidshotIDs.p', 'wb') as handle:
|
||||||
pickle.dump(self.fluidshotIDs, handle)
|
pickle.dump(self.fluidshotIDs, handle)
|
||||||
|
except Exception, e:
|
||||||
|
print("checkFluidShots Error: {}".format(e))
|
||||||
|
|
||||||
def checkWellTests(self):
|
def checkWellTests(self):
|
||||||
|
try:
|
||||||
data = json.loads(requests.get(self.device_address + "/json/well_test/get").text)
|
data = json.loads(requests.get(self.device_address + "/json/well_test/get").text)
|
||||||
well_tests = data["well_tests"]
|
well_tests = data["well_tests"]
|
||||||
for test in well_tests:
|
for test in well_tests:
|
||||||
@@ -332,8 +345,11 @@ class start(threading.Thread, deviceBase):
|
|||||||
del self.welltestIDs[0]
|
del self.welltestIDs[0]
|
||||||
with open('welltestIDs.p', 'wb') as handle:
|
with open('welltestIDs.p', 'wb') as handle:
|
||||||
pickle.dump(self.welltestIDs, handle)
|
pickle.dump(self.welltestIDs, handle)
|
||||||
|
except Exception, e:
|
||||||
|
print("checkWellTests Error: {}".format(e))
|
||||||
|
|
||||||
def checkStatus(self):
|
def checkStatus(self):
|
||||||
|
try:
|
||||||
global status
|
global status
|
||||||
statusMap = {
|
statusMap = {
|
||||||
0: 'Stopped',
|
0: 'Stopped',
|
||||||
@@ -367,8 +383,11 @@ class start(threading.Thread, deviceBase):
|
|||||||
# timestamp = calendar.timegm(dt.timetuple())
|
# timestamp = calendar.timegm(dt.timetuple())
|
||||||
self.sendtodb("status", status_read, 0)
|
self.sendtodb("status", status_read, 0)
|
||||||
status.last_value = status_read
|
status.last_value = status_read
|
||||||
|
except Exception, e:
|
||||||
|
print("checkStatus Error: {}".format(e))
|
||||||
|
|
||||||
def checkDailyTotals(self):
|
def checkDailyTotals(self):
|
||||||
|
try:
|
||||||
data = json.loads(requests.get(self.device_address + "/json/totals").text)
|
data = json.loads(requests.get(self.device_address + "/json/totals").text)
|
||||||
if data['status'] == "OK":
|
if data['status'] == "OK":
|
||||||
totals = data["totals"]
|
totals = data["totals"]
|
||||||
@@ -379,8 +398,11 @@ class start(threading.Thread, deviceBase):
|
|||||||
self.sendtodb(dt_channels[val['name']].mesh_name, dt_channels[val['name']].value, timestamp)
|
self.sendtodb(dt_channels[val['name']].mesh_name, dt_channels[val['name']].value, timestamp)
|
||||||
else:
|
else:
|
||||||
print("checkDailyTotalsError: {0}".format(data.message))
|
print("checkDailyTotalsError: {0}".format(data.message))
|
||||||
|
except Exception, e:
|
||||||
|
print("checkDailyTotals Error: {}".format(e))
|
||||||
|
|
||||||
def checkGaugeOffData(self):
|
def checkGaugeOffData(self):
|
||||||
|
try:
|
||||||
data = json.loads(requests.get(self.device_address + "/json/history").text)
|
data = json.loads(requests.get(self.device_address + "/json/history").text)
|
||||||
day = data["hist"]
|
day = data["hist"]
|
||||||
date = day['gauge_date']
|
date = day['gauge_date']
|
||||||
@@ -394,8 +416,11 @@ class start(threading.Thread, deviceBase):
|
|||||||
if entry in go_channels:
|
if entry in go_channels:
|
||||||
if go_channels[entry].checkSend(day[entry], False):
|
if go_channels[entry].checkSend(day[entry], False):
|
||||||
self.sendtodb(go_channels[entry].mesh_name, day[entry], timestamp)
|
self.sendtodb(go_channels[entry].mesh_name, day[entry], timestamp)
|
||||||
|
except Exception, e:
|
||||||
|
print("checkGaugeOffData Error: {}".format(e))
|
||||||
|
|
||||||
def checkLatestCard(self, numCards = 1):
|
def checkLatestCard(self, numCards = 1):
|
||||||
|
try:
|
||||||
latest = ""
|
latest = ""
|
||||||
if numCards == 1:
|
if numCards == 1:
|
||||||
latest = json.loads(requests.get(self.device_address + "/json/latestcard").text)
|
latest = json.loads(requests.get(self.device_address + "/json/latestcard").text)
|
||||||
@@ -428,6 +453,8 @@ class start(threading.Thread, deviceBase):
|
|||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
self.process_card(card, timestamp, card_timestamp, sendCards=False)
|
self.process_card(card, timestamp, card_timestamp, sendCards=False)
|
||||||
|
except Exception, e:
|
||||||
|
print("checkLatestCard Error: {}".format(e))
|
||||||
|
|
||||||
def process_card(self, data, data_timestamp, card_timestamp, sendCards=False):
|
def process_card(self, data, data_timestamp, card_timestamp, sendCards=False):
|
||||||
|
|
||||||
@@ -474,6 +501,7 @@ class start(threading.Thread, deviceBase):
|
|||||||
self.sendtodb("dc", newDc, card_timestamp)
|
self.sendtodb("dc", newDc, card_timestamp)
|
||||||
|
|
||||||
def checkStoredValues(self, forceSend):
|
def checkStoredValues(self, forceSend):
|
||||||
|
try:
|
||||||
data = json.loads(requests.get(self.device_address + "/json/tagvalues").text)
|
data = json.loads(requests.get(self.device_address + "/json/tagvalues").text)
|
||||||
if data['status'] == "OK":
|
if data['status'] == "OK":
|
||||||
vals = data['vals']
|
vals = data['vals']
|
||||||
@@ -481,8 +509,11 @@ class start(threading.Thread, deviceBase):
|
|||||||
if val['name'] in tag_channels:
|
if val['name'] in tag_channels:
|
||||||
if tag_channels[val['name']].checkSend(val['val'], forceSend):
|
if tag_channels[val['name']].checkSend(val['val'], forceSend):
|
||||||
self.sendtodbJSON(tag_channels[val['name']].mesh_name, tag_channels[val['name']].value, 0)
|
self.sendtodbJSON(tag_channels[val['name']].mesh_name, tag_channels[val['name']].value, 0)
|
||||||
|
except Exception, e:
|
||||||
|
print("checkStoredValues Error: {}".format(e))
|
||||||
|
|
||||||
def getLatestXCards(self, numCards):
|
def getLatestXCards(self, numCards):
|
||||||
|
try:
|
||||||
data = json.loads(requests.get(self.device_address + "/json/latest/" + str(int(numCards))).text)
|
data = json.loads(requests.get(self.device_address + "/json/latest/" + str(int(numCards))).text)
|
||||||
for card in data['cards']:
|
for card in data['cards']:
|
||||||
card_data = json.loads(requests.get(self.device_address + "/json/" + data['folder'] + "/" + card).text)
|
card_data = json.loads(requests.get(self.device_address + "/json/" + data['folder'] + "/" + card).text)
|
||||||
@@ -497,8 +528,11 @@ class start(threading.Thread, deviceBase):
|
|||||||
channels["card_history"]["last_value"] = (data['folder'] + "/" + card)
|
channels["card_history"]["last_value"] = (data['folder'] + "/" + card)
|
||||||
self.sendtodb("card_history", (data['folder'] + "/" + card), card_timestamp)
|
self.sendtodb("card_history", (data['folder'] + "/" + card), card_timestamp)
|
||||||
self.process_card(card_data, timestamp, card_timestamp, sendCards=True)
|
self.process_card(card_data, timestamp, card_timestamp, sendCards=True)
|
||||||
|
except Exception, e:
|
||||||
|
print("getLatestXCards Error: {}".format(e))
|
||||||
|
|
||||||
def getDataLoggerStatus(self):
|
def getDataLoggerStatus(self):
|
||||||
|
try:
|
||||||
data = json.loads(requests.get(self.device_address + "/json/pythonstatus/").text)
|
data = json.loads(requests.get(self.device_address + "/json/pythonstatus/").text)
|
||||||
al_status = "Not OK"
|
al_status = "Not OK"
|
||||||
if data['status']['alarmLogger']:
|
if data['status']['alarmLogger']:
|
||||||
@@ -514,6 +548,8 @@ class start(threading.Thread, deviceBase):
|
|||||||
if al_status != self.dl_status_last:
|
if al_status != self.dl_status_last:
|
||||||
self.sendtodb("datalogger_status", dl_status, 0)
|
self.sendtodb("datalogger_status", dl_status, 0)
|
||||||
self.dl_status_last = dl_status
|
self.dl_status_last = dl_status
|
||||||
|
except Exception, e:
|
||||||
|
print("getDataLoggerStatus Error: {}".format(e))
|
||||||
|
|
||||||
def poc_get_card(self, name, value):
|
def poc_get_card(self, name, value):
|
||||||
self.getcard(value)
|
self.getcard(value)
|
||||||
|
|||||||
Reference in New Issue
Block a user