03.01.2024, 10:53
(This post was last modified: 03.01.2024, 10:53 by benanderson_475.)
Thanks, this is making sense, i will run a function when the script starts to cache the objects in a table as described how am i best to achieve this?
my first thoughts,
call group.all() then loop through tagcache and validate the tag with prefix 'MQ' is there, then extract all elements as reqired and insert into cached obj table
or maybe i can use myobjects = grp.tag({'tag name 1', 'tag name 2'}, 'any') problem is for this one i dont want to list all the avalible tagsas i may have many different ones the only consistant thing in the tag is the 'MQ' prefix
whats the simplist way to recieve all tags with the 'MQ' prefix or perhaps i should change my naming method to better.
this is wher i am at so far, thoughts? then i can look up the table with th eabove function.
my first thoughts,
call group.all() then loop through tagcache and validate the tag with prefix 'MQ' is there, then extract all elements as reqired and insert into cached obj table
or maybe i can use myobjects = grp.tag({'tag name 1', 'tag name 2'}, 'any') problem is for this one i dont want to list all the avalible tagsas i may have many different ones the only consistant thing in the tag is the 'MQ' prefix
whats the simplist way to recieve all tags with the 'MQ' prefix or perhaps i should change my naming method to better.
this is wher i am at so far, thoughts? then i can look up the table with th eabove function.
Code:
local cached_objects = {}
all_obj = grp.all()
for _, obj in pairs(all_obj) do
local tag_is_MQ
if obj.tagcache then
tag_is_MQ = obj.tagcache:match('(MQ%s+[^,]+)')
end
if tag_is_MQ then
cached_objects[obj.address] = {['address'] =obj.address, ['name'] = obj.name, ['data type'] = obj.datatype, ['tag'] = tag_is_MQ, ['updatetime'] = obj.updatetime}
end
end
log(cached_objects)