From 85a45e832d9934483879da2f063273d3ccd10b76 Mon Sep 17 00:00:00 2001 From: Nico Melone Date: Fri, 24 Jan 2020 15:59:43 -0600 Subject: [PATCH] squashed bugs --- flow-monitor/config.txt | 2 +- flow-monitor/flow-monitor.py | 12 ++++++++---- plcfreshwater/config.txt | 2 +- plcfreshwater/plcfreshwater.py | 8 ++++---- 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/flow-monitor/config.txt b/flow-monitor/config.txt index f384a01..75c0338 100644 --- a/flow-monitor/config.txt +++ b/flow-monitor/config.txt @@ -6,6 +6,6 @@ }, "deviceName": "flowmonitor", "driverId": "0140", - "releaseVersion": "15", + "releaseVersion": "17", "driverFileName": "flow-monitor.py" } \ No newline at end of file diff --git a/flow-monitor/flow-monitor.py b/flow-monitor/flow-monitor.py index 81ab563..e2f3e15 100644 --- a/flow-monitor/flow-monitor.py +++ b/flow-monitor/flow-monitor.py @@ -179,7 +179,7 @@ class start(threading.Thread, deviceBase): self.force_send = False self.daemon = True - self.version = "15" + self.version = "17" self.finished = threading.Event() threading.Thread.start(self) @@ -349,8 +349,7 @@ class start(threading.Thread, deviceBase): psi_val = scale(analog1_val, self.pressure_raw_min, self.pressure_raw_max, self.pressure_psi_min, self.pressure_psi_max) if din1_val == 0 and scaled_cloop > 10: din1_val = 1 - if gpm_val < self.GPM_IGNORE_LIMIT: - gpm_val = 0 + if self.gpm_or_bpd == "gpm": gpm_val = scaled_cloop @@ -358,7 +357,10 @@ class start(threading.Thread, deviceBase): else: bpd_val = scaled_cloop gpm_val = (((bpd_val * gal_per_bbl) / 24) / 60) # Computes GPM from BPD - + + if gpm_val < self.GPM_IGNORE_LIMIT: + gpm_val = 0 + bpd_val = 0 now = time.time() time_diff = now - last_measured_timestamp if time_diff > 0 and time_diff < 180: @@ -611,6 +613,8 @@ class start(threading.Thread, deviceBase): try: self.GPM_IGNORE_LIMIT = float(value) self.sendtodb("setgpmignorelimit", self.GPM_IGNORE_LIMIT, 0) + PERSIST['gpm_ignore_limit'] = self.GPM_IGNORE_LIMIT + persistence.store(PERSIST) return True except Exception as e: logger.error("Error during flowmonitor_setgpmignorelimit: {}".format(e)) diff --git a/plcfreshwater/config.txt b/plcfreshwater/config.txt index a83fb88..8839d0d 100644 --- a/plcfreshwater/config.txt +++ b/plcfreshwater/config.txt @@ -8,7 +8,7 @@ "file4": "Tags.py" }, "deviceName": "plcfreshwater", - "releaseVersion": "4", + "releaseVersion": "5", "driverFileName": "plcfreshwater.py", "driverId": "0100" } \ No newline at end of file diff --git a/plcfreshwater/plcfreshwater.py b/plcfreshwater/plcfreshwater.py index 2ed63c9..faf58c3 100644 --- a/plcfreshwater/plcfreshwater.py +++ b/plcfreshwater/plcfreshwater.py @@ -52,7 +52,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 = "" @@ -60,7 +60,7 @@ class start(threading.Thread, deviceBase): self.private_ip_address = "" self.plcip = "" self.ping_counter = 0 - self.plc_ping_status = 'Comms Error to PLC' + self.plc_ping_status = 'Default' threading.Thread.start(self) # this is a required function for all drivers, its goal is to upload some piece of data @@ -112,11 +112,11 @@ class start(threading.Thread, deviceBase): # print("plcfreshwater driver still alive...") plc_ping = os.system("ping -c 1 " + IP_TABLE[self.mac]) if plc_ping == 0: - if self.plc_ping_status == "Comms Error to PLC": + if not self.plc_ping_status == "OK": self.sendtodbDev(1, "plc_ping","OK", 0, 'plcfreshwater') self.plc_ping_status = "OK" else: - if self.plc_ping_status == "OK": + if not self.plc_ping_status == "Comms Error to PLC": self.sendtodbDev(1, 'plc_ping', "Comms Error to PLC",0, 'plcfreshwater') self.plc_ping_status = 'Comms Error to PLC' time.sleep(10)