Adds tag and driver code for writing notes from POCloud to the PLC for display on the HMI

This commit is contained in:
Patrick McDonagh
2016-12-12 07:49:53 -06:00
parent 2116052278
commit f3f36919af
2 changed files with 5102 additions and 4997 deletions

File diff suppressed because one or more lines are too long

View File

@@ -2,6 +2,33 @@
import threading
import time
from device_base import deviceBase
from pycomm.ab_comm.clx import Driver as plcDriver
def write_string(addr, tag, to_send):
"""
Writes a given string to the tag in a CLX PLC
"""
data_name = ".".join((tag, "DATA"))
len_name = ".".join((tag, "LEN"))
# Begin by clearing out the entire array
clear = [0 for _ in range(0, 82)]
clx = plcDriver()
if clx.open(addr):
try:
clx.write_array(data_name, "SINT", clear)
clx.write_tag(len_name, 0, "DINT")
conv_string = [ord(x) for x in to_send[0:82]]
clx.write_array(data_name, "SINT", conv_string)
clx.write_tag(len_name, len(conv_string), "DINT")
except Exception as e:
print("Unable to write string {} to {}".format(to_send, tag))
return False
clx.close()
return True
return False
class start(threading.Thread, deviceBase):
@@ -21,3 +48,8 @@ class start(threading.Thread, deviceBase):
def run(self):
pass
def advvfdipp_writenote(self, name, value):
note_tag_name = "POCloud_note"
plc_ip = "192.168.1.10"
return write_string(plc_ip, note_tag_name, value)