12.12.2022, 07:21
Average is already implemented, for min/max add these functions before -- prepare each group
Add mapping like this:
Code:
-- MAX value
calc['max'] = function(group)
local result = -math.huge
for _, address in ipairs(group.objects) do
local value = values[ address ]
if type(value) == 'number' then
result = math.max(result, value)
end
end
grp.checkupdate(group.output, result)
end
-- MIN value
calc['min'] = function(group)
local result = math.huge
for _, address in ipairs(group.objects) do
local value = values[ address ]
if type(value) == 'number' then
result = math.min(result, value)
end
end
grp.checkupdate(group.output, result)
end
Add mapping like this:
Code:
groups = {
{ tag = 'nor1', output = '0/0/8', mode = 'nor' },
{ tag = 'avg1', output = '0/0/1', mode = 'avg' },
{ tag = 'min1', output = '0/0/2', mode = 'min' },
{ tag = 'max1', output = '0/0/3', mode = 'max' },
}