I am using Ignition 8.3.6 with MQTT Engine. I have a UDT with a Parameters folder containing tag1 which holds an MQTT tag path like:
[MQTT Engine]Mimics/iotdata/KCW/N-KCW1-CL1-J-PV-CL_471FN7_KW/value
[MQTT Engine]Mimics/iotdata/GCW/W-GCW1-PH1-X-PV-J1P63_X2/value
[MQTT Engine]Mimics/iotdata/NMGD/W-NMGD1-CM1-F-COP-CM_531WF1_FR1/value
What I Want:
I have an Expression Tag called Tag Name inside the UDT. I want it to dynamically extract the device prefix from the path, which is the segment between the plant folder and the second dash:
| Full Path |
Expected Output |
.../KCW/N-KCW1-CL1-... |
N-KCW1- |
.../GCW/W-GCW1-PH1-... |
W-GCW1- |
.../NMGD/W-NMGD1-CM1-... |
W-NMGD1- |
The plant folder name (KCW, GCW, NMGD etc.) and device suffix (-CL1, -CM1, -PH1) vary across instances, so the solution must be fully dynamic. Can it be done in ignition?
yes. split and indexOf will need to become your friends. Check those expression functions out, and you should be able to get it worked out.
This is honestly not sustainable and will cause a nightmare further down the line when a site is introduced that does not have the exact same tag pathing.
I would instead add more parameters to the UDT and include a TagName or TagDescription parameter that could then be referenced in an expression tag inside the UDT i.e. {TagDescription}
This is ugly without Phil's Integration Toolkit module.. But here goes
split(split({value}, '/')[3,0]), '-')[0,0] + '-' + split(split({value}, '/')[3,0]), '-')[1,0] + '-'
Or
transform(split(split({value}, '/')[3,0], '-'), value()[0,0] + '-' + value()[1,0] + '-')
Hmm. No one should be without it. I would use:
transform(
split(
qvAt(
where(
split(
parsePath(tag('[.]refTag.sourceTagPath'))[0, 'tag'],
'/'
),
it()[0] != 'value'
),
-1,
0
),
'-'
),
stringFormat(
"%s-%s-",
value()[0, 0],
value()[1, 0]
)
)
Presumably the UDT parameter will drive the source path for a reference tag. Place this expression tag adjacent to that reference tag.
Robust against varying tree depth, ignores present or absent /value, and varying length elements of the prefix.