This commit is contained in:
Nico Melone
2022-07-21 13:57:30 -05:00
parent 9b3296a04b
commit b042d41fc1
15 changed files with 209 additions and 54 deletions

View File

@@ -8,7 +8,7 @@
"file4": "Tags.py"
},
"deviceName": "tenflowmeterskid",
"releaseVersion": "4",
"releaseVersion": "5",
"driverFileName": "tenflowmeterskid.py",
"driverId": "0100"
}

View File

@@ -64,7 +64,7 @@ class start(threading.Thread, deviceBase):
mqtt=mqtt, Nodes=Nodes)
self.daemon = True
self.version = "4"
self.version = "5"
self.finished = threading.Event()
self.force_send = False
self.public_ip_address = ""
@@ -100,23 +100,27 @@ class start(threading.Thread, deviceBase):
log.warning("FORCE SEND: TRUE")
for chan in CHANNELS:
val = chan.read()
if chan.mesh_name == "total_in_flowrate":
val = sum(self.flowrates)
if chan.check(val, self.force_send) or self.check_new_day(chan.mesh_name[:-9]):
if chan.mesh_name in PERSIST["ignore_list"]:
if "lifetime" in chan.mesh_name and chan.mesh_name not in ['forward_out_lifetime', 'reverse_out_lifetime', 'net_out_lifetime']:
self.totalizer_null(chan.mesh_name[:-9])
try:
val = chan.read()
if chan.mesh_name == "total_in_flowrate":
val = sum(self.flowrates)
if chan.check(val, self.force_send) or self.check_new_day(chan.mesh_name[:-9]):
if chan.mesh_name in PERSIST["ignore_list"]:
if "lifetime" in chan.mesh_name and chan.mesh_name not in ['forward_out_lifetime', 'reverse_out_lifetime', 'net_out_lifetime']:
self.totalizer_null(chan.mesh_name[:-9])
else:
self.sendtodbDev(1, chan.mesh_name, None, 0, 'tenflowmeterskid')
elif "lifetime" in chan.mesh_name and chan.mesh_name not in ['forward_out_lifetime', 'reverse_out_lifetime', 'net_out_lifetime']:
self.totalize(val, chan.mesh_name[:-9])
else:
self.sendtodbDev(1, chan.mesh_name, None, 0, 'tenflowmeterskid')
elif "lifetime" in chan.mesh_name and chan.mesh_name not in ['forward_out_lifetime', 'reverse_out_lifetime', 'net_out_lifetime']:
self.totalize(val, chan.mesh_name[:-9])
else:
self.sendtodbDev(1, chan.mesh_name, chan.value, 0, 'tenflowmeterskid')
if "flowrate" in chan.mesh_name and chan.mesh_name not in ["total_in_flowrate","total_out_flowrate"]:
self.flowrates[int(chan.mesh_name.split("_")[0][2:]) - 1] = val
#time.sleep(TAG_DATAERROR_SLEEPTIME) # sleep to allow Micro800 to handle ENET requests
self.sendtodbDev(1, chan.mesh_name, chan.value, 0, 'tenflowmeterskid')
if "flowrate" in chan.mesh_name and chan.mesh_name not in ["total_in_flowrate","total_out_flowrate"]:
self.flowrates[int(chan.mesh_name.split("_")[0][2:]) - 1] = val
except Exception as e:
log.error("Error in reading {}".format(chan.mesh_name))
log.error(e)
for pond_index in range(1, 3):
self.read_pond_calibration(pond_index)
@@ -133,6 +137,7 @@ class start(threading.Thread, deviceBase):
if (now - self.public_ip_address_last_checked) > IP_CHECK_PERIOD:
self._check_ip_address()
time.sleep(5) # sleep to allow Micro800 to handle ENET requests
def check_new_day(self, totalizer):
right_now = dt.today()