Logic Machine Forum
Is it possible to tag/untag an object with a digital value? - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8)
+--- Thread: Is it possible to tag/untag an object with a digital value? (/showthread.php?tid=4075)



Is it possible to tag/untag an object with a digital value? - Odd Egil Aasheim - 01.06.2022

Hi.

I have about 100 1-byte scaling values that I want to calculate maximum of by tagging them all with i.e "Max_value".

But if I for some reason there are object(s) that NOT should be included in the calculation temporarily, is it possible to toggle them off if I have digital value(s) for each in my visu?
Or is the only solution to go into scada-main and remove the tag for the desired value(s) ?


RE: Is it possible to tag/untag an object with a digital value? - admin - 02.06.2022

Which script are you using for maximum calculation? Do you have a separate binary on/off object for each 1-byte value?


RE: Is it possible to tag/untag an object with a digital value? - Odd Egil Aasheim - 03.06.2022

(02.06.2022, 05:42)admin Wrote: Which script are you using for maximum calculation? Do you have a separate binary on/off object for each 1-byte value?

Hi.
I'm using a script like this:

Code:
-- Enter tag here
knxTable = grp.tag('Maxvalue')
-- Outputadress
MAX = '32/1/4'

-- Don't change below --

newTable = {}
for i, v in ipairs(knxTable) do
  table.insert(newTable, v.value)
end

table.sort(newTable)
grp.checkwrite(MAX, newTable[#newTable], 0.5)

Let's say I have the %-values from 1/1/1 to 1/1/50 where everyone is tagged "Maxvalue", (in real project they are not next to eachother)
I think will have to create separate 1-bit enablesignals for the corresponding 1/2/1 to 1/2/50.

Is there any possibility to "untag" 1/1/10 with setting 1/2/10 to off?

Plan B is making a script to push 1/1/1 into another GA if 1/2/1 is true, else set to 0 and tag the new GA instead of the one I have now.


RE: Is it possible to tag/untag an object with a digital value? - admin - 06.06.2022

Instead of changing tags you can simply tag on/off objects with a different tag. The number of tagged objects for both max and status tags must be the same. It also makes sense to map this script to both value and status objects. A different common tag can be be used for this.
Code:
function sortbyid(a, b)
  return a.id < b.id
end

objs = grp.tag('max')
table.sort(objs, sortbyid)

stat = grp.tag('status')
table.sort(stat, sortbyid)

max = -math.huge

for i, obj in ipairs(objs) do
  if stat[ i ].value then
    max = math.max(obj.value, max)
  end
end

log(max)