I’m having trouble writing string values back to a PLC via SQL tags. The tags were imported from a device by dragging and dropping from the OPC browser. I get no error messages, and the integer values that I write come through correctly. The very first time I wrote a string to the PLC, it set the value, but now it never updates it.
I suspect that the problem may reside with the device, but is there any chance my code is off? It’s actually an array of tags that I’m writing to, setting index 1 to the first set of values I get from my db query, index 2 to the next set, and then clearing out all values for indexes up to and including 50 that don’t have data.
Here’s the code:
[code] # hit every tag, and either populate it from db, or clear it
for x in range (0, 50):
# setup tag names, with an offset of 1
tagNum = x + 1
bolTag = “Malt Handling/BOL_STORAGE/BOL_STORAGE_%d_/BOL” % tagNum
maltTypeTag = “Malt Handling/BOL_STORAGE/BOL_STORAGE_%d_/MALT_TYPE_NUMBER” % tagNum
#maltNameLen = “Malt Handling/BOL_STORAGE/BOL_STORAGE_%d_/MALT_TYPE_NAME/LEN” % tagNum
maltNameTag = “Malt Handling/BOL_STORAGE/BOL_STORAGE_%d_/MALT_TYPE_NAME/STRING” % tagNum
vendorTag = “Malt Handling/BOL_STORAGE/BOL_STORAGE_%d_/VENDOR_NUMBER” % tagNum
vendorNameTag = “Malt Handling/BOL_STORAGE/BOL_STORAGE_%d_/VENDOR_NAME/STRING” % tagNum
# setup list of tag names
tags = [bolTag, maltTypeTag, maltNameTag, vendorTag, vendorNameTag]
# most will be empty, so set up the empty values list
values = [0, 0, "", 0, ""]
if len(data) > x:
# if we found data, set the values found in the query
bol = data[x]["BOL"]
maltType = data[x]["MaltType"]
maltName = data[x]["MaltName"]
# maltNameLen = len(maltName)
vendor = data[x]["Vendor"]
vendorName = data[x]["VendorName"]
values = [bol, maltType, maltName, vendor, vendorName]
print tags
print values
system.tag.writeAll(tags, values)[/code]
Those print statements at the end definitely show the expected values, so I’m at a bit of a loss as to why I can write integers, but not strings.