Fixes inabilty to write to PLC from driver

This commit is contained in:
Patrick McDonagh
2017-08-29 17:10:48 -05:00
parent 92bd3367a3
commit 02aa1de457
3 changed files with 7226 additions and 6946 deletions

View File

@@ -3,7 +3,7 @@
"driverFileName":"transferstation.py",
"deviceName":"transferstation",
"driverId":"0140",
"releaseVersion":"2",
"releaseVersion":"3",
"files": {
"file1":"transferstation.py",
"file2":"Channel.py",

View File

@@ -74,7 +74,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 = "2"
self.version = "3"
self.finished = threading.Event()
self.forceSend = False
threading.Thread.start(self)
@@ -89,11 +89,15 @@ class start(threading.Thread, deviceBase):
def run(self):
"""Actually run the driver."""
global persist
wait_sec = 10
wait_sec = 60
for i in range(0, wait_sec):
print("transferstation driver will start in {} seconds".format(wait_sec - i))
time.sleep(1)
print("BOOM! Starting transferstation driver...")
# 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["transferstation_0199"] = self
send_loops = 0
while True:
if self.forceSend:
@@ -117,14 +121,14 @@ class start(threading.Thread, deviceBase):
else:
send_loops += 1
def transferstation_sync(self, name, value):
"""Sync all data from the driver."""
self.forceSend = True
# self.sendtodb("log", "synced", 0)
return True
# def transferstation_sync(self, name, value):
# """Sync all data from the driver."""
# self.forceSend = True
# # self.sendtodb("log", "synced", 0)
# return True
def transferstation_writeplctag(self, name, value):
"""Write a value to the PLC."""
# """Write a value to the PLC."""
new_val = json.loads(str(value).replace("'", '"'))
tag_n = str(new_val['tag']) # "cmd_Start"
val_n = new_val['val']

File diff suppressed because one or more lines are too long