Read Entire Ignition Tag Arrays Using Loops & Dynamic Settings

Ignition EDGE stores data with each piece of information being held in one tag. Depending on the application that sets the tags, it may organize arrays of data into subfolders, and will typically have some part of each element’s name be the index. For example, you may have:
strings/myAlarms/Alarm[0] , ../Alarm[1] , ../Alarm[2] , and ../Alarm[3] as an array of Alarm strings.

While in this example they all exist in the one myAlarms folder, each element is an individual tag. So, if you want use Node-RED to read in an entire array of tags with varying indexes, you’ll need to read them one by one. Thankfully Ignition supports dynamic settings and it is straightforward to read them all using a little JavaScript in a function node, so you can automatically move entire arrays into databases and other applications quickly and easily.

The main feature this method makes use of is the “dynamic settings” described in the ignition-tag-read node’s info tab, specifically that you can set msg.payload.tagPath with any valid Ignition tag path and it will overwrite the node settings and get the node to return that specific tag. Then it’s just a matter of using the right code to set that tag path! Here’s a quick example I put together:

tagRoot = "strings/myAlarms/Alarm";
for (i = 0; i<= 3; i++) {
    node.send({ payload : { tagPath : tagRoot + '[' + i + ']' } });
}

The node.send(..) function will send out a message containing the tagPath inside the message payload a total of four times, once for each tag, that can go straight into an ignition node. However, to keep messages from jumping out of order I found that the flow was more consistent with a delay node, with it between the function and ignition-read nodes there was never any messages out of order for my application. From the read node you can easily collect your data into a Node-RED array, feed it straight into MySQL, Azure, or any other application or cloud service that you need!

The flow I used for this example is pictured below, with the clipboard-exported flow.txt attached to this post.

Happy coding!

flow.zip (787 Bytes)

1 Like