This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

VAV Optimiser, Max Function
#2
Fault objects should have similar names to the value objects that you are using for calculation. You need to change the "search_for" and "replace_with" parameters in gsub so the value object name is converted to the fault object name.

Code:
function tag_max(tag)
  local objects = grp.tag(tag)
  local result = -math.huge

  for _, object in ipairs(objects) do
    local faultname = obj.name:gsub('search_for', 'replace_with')
    local faultobj = grp.find(faultname)
    local fault = false

    if faultobj then
      fault = faultobj.value
    end

    if not fault then
      result = math.max(result, object.value)
    end
  end

  return result
end
max = tag_max('MaxExtDmpPos')
log(max)

grp.checkwrite('32/1/23', max)
Reply


Messages In This Thread
RE: VAV Optimiser, Max Function - by admin - 12.08.2021, 06:39

Forum Jump: