From 3adf6d96b7deda839ecec848ee51a401ca710e51 Mon Sep 17 00:00:00 2001 From: Nico Melone Date: Thu, 26 Aug 2021 09:41:44 -0500 Subject: [PATCH] updated change thresholds and added commands --- tankalarms/Tags.py | 4 ++-- tankalarms/tankalarms.py | 43 +++++++++++++++++++++++++++++++++++++++- 2 files changed, 44 insertions(+), 3 deletions(-) diff --git a/tankalarms/Tags.py b/tankalarms/Tags.py index 48cf129..6499d12 100644 --- a/tankalarms/Tags.py +++ b/tankalarms/Tags.py @@ -2,7 +2,7 @@ from Channel import PLCChannel, ModbusChannel from tankalarms import PLC_IP_ADDRESS tags = [ - PLCChannel(PLC_IP_ADDRESS, "water_level","WaterTxLevel","REAL", 5, 3600, plc_type="Micro800"), + PLCChannel(PLC_IP_ADDRESS, "water_level","WaterTxLevel","REAL", 0.5, 3600, plc_type="Micro800"), PLCChannel(PLC_IP_ADDRESS, "water_batt_volts","WaterTxBatVolts","REAL", 5, 3600, plc_type="Micro800"), PLCChannel(PLC_IP_ADDRESS, "water_rssi","WaterTxRSSI","REAL", 5, 3600, plc_type="Micro800"), PLCChannel(PLC_IP_ADDRESS, "water_hihi_spt","WaterTx_HHSP","REAL", 5, 3600, plc_type="Micro800"), @@ -11,7 +11,7 @@ tags = [ PLCChannel(PLC_IP_ADDRESS, "water_hi_alm","WaterTx_HAlrm","BOOL", 0, 3600, plc_type="Micro800"), PLCChannel(PLC_IP_ADDRESS, "water_batt_lolo_alm","WaterTxBatVolts_LLAlrm","BOOL", 0, 3600, plc_type="Micro800"), PLCChannel(PLC_IP_ADDRESS, "water_comm_fail_alm","WaterTx_RF_CommFail","BOOL", 0, 3600, plc_type="Micro800"), - PLCChannel(PLC_IP_ADDRESS, "oil_level","OilTxLevel","REAL", 5, 3600, plc_type="Micro800"), + PLCChannel(PLC_IP_ADDRESS, "oil_level","OilTxLevel","REAL", 0.5, 3600, plc_type="Micro800"), PLCChannel(PLC_IP_ADDRESS, "oil_batt_volts","OilTxBatVolts","REAL", 5, 3600, plc_type="Micro800"), PLCChannel(PLC_IP_ADDRESS, "oil_rssi","OilTxRSSI","REAL", 5, 3600, plc_type="Micro800"), PLCChannel(PLC_IP_ADDRESS, "oil_hihi_spt","OilTx_HHSP","REAL", 5, 3600, plc_type="Micro800"), diff --git a/tankalarms/tankalarms.py b/tankalarms/tankalarms.py index 64e0b4e..7dc1381 100644 --- a/tankalarms/tankalarms.py +++ b/tankalarms/tankalarms.py @@ -77,7 +77,7 @@ class start(threading.Thread, deviceBase): val = chan.read() if chan.check(val, self.force_send): self.sendtodbDev(1, chan.mesh_name, chan.value, 0, 'tankalarms') - time.sleep(TAG_DATAERROR_SLEEPTIME) # sleep to allow Micro800 to handle ENET requests + time.sleep(TAG_DATAERROR_SLEEPTIME) # sleep to allow Micro800 to handle ENET requests # print("tankalarms driver still alive...") if self.force_send: @@ -151,3 +151,44 @@ class start(threading.Thread, deviceBase): write_res = "Error writing to PLC..." return write_res return False +""" + def tankalarms_water_hihi_spt(self, name, value): + log.info("Value received is {}".format(value)) + + write_res = write_tag(str(PLC_IP_ADDRESS), "WaterTx_HHSP", 1, plc_type="Micro800") + log.info("Result of tankalarms_water_hihi_spt {}, {}, {}".format(name, value, write_res)) + if write_res is None: + write_res = "Error writing to PLC..." + return write_res + + + def tankalarms_water_hi_spt(self, name, value): + log.info("Value received is {}".format(value)) + if value == 1 or value == "1": + write_res = write_tag(str(PLC_IP_ADDRESS), "WaterTx_HSP", 1, plc_type="Micro800") + log.info("Result of tankalarms_water_hi_spt {}, {}, {}".format(name, value, write_res)) + if write_res is None: + write_res = "Error writing to PLC..." + return write_res + return False + + def tankalarms_oil_hihi_spt(self, name, value): + log.info("Value received is {}".format(value)) + if value == 1 or value == "1": + write_res = write_tag(str(PLC_IP_ADDRESS), "OilTx_HHSP", 1, plc_type="Micro800") + log.info("Result of tankalarms_oil_hihi_spt {}, {}, {}".format(name, value, write_res)) + if write_res is None: + write_res = "Error writing to PLC..." + return write_res + return False + + def tankalarms_oil_hi_spt(self, name, value): + log.info("Value received is {}".format(value)) + if value == 1 or value == "1": + write_res = write_tag(str(PLC_IP_ADDRESS), "OilTx_HSP", 1, plc_type="Micro800") + log.info("Result of tankalarms_oil_hi_spt {}, {}, {}".format(name, value, write_res)) + if write_res is None: + write_res = "Error writing to PLC..." + return write_res + return False + """