Fix for MAXH2O-41. PLC Write function was not firing

This commit is contained in:
Patrick McDonagh
2017-10-23 11:09:24 -05:00
parent 2918ca5b99
commit d0a7860754
2 changed files with 7 additions and 4 deletions

View File

@@ -3,7 +3,7 @@
"driverFileName":"rigpump.py",
"deviceName":"rigpump",
"driverId":"0150",
"releaseVersion":"5",
"releaseVersion":"7",
"files": {
"file1":"rigpump.py",
"file2":"Channel.py",

View File

@@ -18,6 +18,7 @@ except Exception:
persist = {}
PLC_IP_ADDRESS = "192.168.1.10"
WATCHDOG_SEND_PERIOD = 3600 # seconds
def reverse_map(value, map_):
@@ -49,7 +50,7 @@ class start(threading.Thread, deviceBase):
deviceBase.__init__(self, name=name, number=number, mac=mac, Q=Q, mcu=mcu, companyId=companyId, offset=offset, mqtt=mqtt, Nodes=Nodes)
self.daemon = True
self.version = "5"
self.version = "7"
self.finished = threading.Event()
self.forceSend = False
threading.Thread.start(self)
@@ -73,13 +74,14 @@ class start(threading.Thread, deviceBase):
# after its booted up assuming that M1 is now reading modbus data
# we can replace the reference made to this device name to the M1 driver with this
# driver. The 01 in the 0199 below is the device number you referenced in the modbus wizard
# self.nodes["rigpump_0199"] = self
self.nodes["rigpump_0199"] = self
public_ip_address = get_public_ip_address()
self.sendtodbDev(1, 'public_ip_address', public_ip_address, 0, 'rigpump')
watchdog = self.rigpump_watchdog()
self.sendtodbDev(1, 'watchdog', watchdog, 0, 'rigpump')
watchdog_send_timestamp = time.time()
send_loops = 0
watchdog_loops = 0
@@ -104,8 +106,9 @@ class start(threading.Thread, deviceBase):
watchdog_loops += 1
if (watchdog_loops >= watchdog_check_after):
test_watchdog = self.rigpump_watchdog()
if not test_watchdog == watchdog:
if test_watchdog != watchdog or (time.time() - watchdog_send_timestamp) > WATCHDOG_SEND_PERIOD:
self.sendtodbDev(1, 'watchdog', test_watchdog, 0, 'rigpump')
watchdog_send_timestamp = time.time()
watchdog = test_watchdog
test_public_ip = get_public_ip_address()