Hello Losant Support!
I have an application that needs to collect data from Allen-Bradley PLC’s with varying tag names. I have setup a workflow that utilizes a function to built an array of the tags, keys, types, and program required for the Allen-Bradley: Read node. This works successfully when run on a small subset of tags, however when I expand it to the full list, it fails on a “tag name must be a valid string” error. I am guessing that the Allen-Bradley: Read node does not like the format of one of the tag strings, but I cannot determine which one it is (I have removed anything obvious).
Are there any guidelines on the string requirements for the Allen-Bradley: Read node? Do you have any recommendations on how to appropriately validate the string before placing it into the array? Or, is there a way to get the Allen-Bradley: Read node to run on the tags that it can validate and omit the ones it cannot?
Here is the function that is building the array in case it may be useful.
var i = 0
let retArray = []
payload.plcDevice.value.attributes.forEach(getElements)
payload.data = retArray
function getElements(element){
if (typeof element.attributeTags.plcTagName != 'undefined'){
retArray[i] =
{
"key": element.name,
"tag":element.attributeTags.plcTagName,
"program":"",
"type": element.attributeTags.plcDataType
}
}
i = i + 1
}