From 24f5e143dd022f7d1575b3f775649c3de1c63225 Mon Sep 17 00:00:00 2001 From: Javier Quinones Date: Mon, 17 Aug 2026 12:23:51 -0500 Subject: [PATCH] Added a filtering step on __addBindings.jq__ --- addBindings.jq | 41 ++++++++++++++++++++++++----------------- 1 file changed, 24 insertions(+), 17 deletions(-) diff --git a/addBindings.jq b/addBindings.jq index 02e292f..10bb74a 100644 --- a/addBindings.jq +++ b/addBindings.jq @@ -1,23 +1,30 @@ +# Filter first . +| debug("Filtering...") +| .tags[] +|= select(.typeId == "Cooling/PLC_AB/PLC_AB_Auto_v3") # Sort first -| walk( - if type == "object" and has("tags") then - .tags |= sort_by(.name) - end -) +| debug("Sorting...") +| walk( if type == "object" and has("tags") then .tags |= sort_by(.name) end ) # so object positions are predictable -| .tags[3].tags[1].tags as $baseData -| walk( - # Removes .Tags.Controller Tags from the plcName parameter - if type == "object" and has("plcName") then - .plcName.value |= rtrimstr(".Tags.Controller Tags") - elif type == "object" and has("plcname") then - .plcname.value |= rtrimstr(".Tags.Controller Tags") +| 2 as $pos +| .tags[0].tags[$pos].tags as $baseData +| debug("Modifying tags...") +| .tags +|= map( + . + | if .parameters.plcName.value then + .parameters.plcName.value |= rtrimstr(".Tags.Controller Tags") + elif .parameters.plcname.value then + .parameters.plcname.value |= rtrimstr(".Tags.Controller Tags") end -) -# and can be used as the base line to setup the other objects -| walk( - if type == "object" and .name? == "Data" then - .tags = $baseData + | if .tags + and .tags[$pos].name == "Data" + and .tags[$pos].tagType == "Folder" + then + .tags[$pos].tags |= $baseData + else + . + | debug("Data folder not found") end ) \ No newline at end of file