b = "[default]779/CabTrimAGVs/AGVProgram/AGV%02d/B2"
r = "[default]779/CabTrimAGVs/AGVStatus/AGV%02d/R5"
tagPaths = [b % i for i in xrange(0, 160)] + [r % i for i in xrange(0, 160)]
(assumptions made)
b = "[default]779/CabTrimAGVs/AGVProgram/AGV%02d/B2"
r = "[default]779/CabTrimAGVs/AGVStatus/AGV%02d/R5"
tagPaths = [b % i for i in xrange(0, 160)] + [r % i for i in xrange(0, 160)]
(assumptions made)
only a leading 0 until 2 digits. so 10 is the first one without the leading 0.
Ok. I would install my Integration Toolkit module and then make an expression tag with this:
sum(
transform(
tags(
flatten(
forEach(
159,
stringFormat("[default]779/CabTrimAGVs/AGVProgram/AGV0%02d/B2", idx()+1),
stringFormat("[default]779/CabTrimAGVs/AGVStatus/AGV0%02d/R5", idx()+1)
)
),
100
),
forEach(
value(),
if(
(idx() & 1 = 0) && coalesce(it()[1], false),
coalesce(value()[idx()+1][1], 0.0),
0.0
)
)
)
)
No script. Set the expression tag to event driven execution mode.
(Depending on your Ignition version, you may need to restart your gateway for my toolkit expressions to be available in expression tags.)
The second argument to tags()
is the dwell factor, to make it efficient as batches of tag changes arrive. But it will stay within that dwell factor of real-time.
{ Edit: made an efficiency tweak. And a subscript fix. Further efficiencies could be gained by moving the tagpath generation to another expression tag.}
{ Further comment: I'm not sure I got the tag order right--the expression assumes the boolean is first, then the numeric, in each pair. If I'm backwards, just swap the two stringFormat()
subexpressions. }
Awesome thanks! Ill give it a try.