30.04.2018, 17:41
Thank you
FYI FBE_Blocks_Control.luas
is the issue
FYI FBE_Blocks_Control.luas
is the issue
Code:
--- [Function] fbe_hysteresis_3_limits
--- Hysteresis with 3 limits
--- [Comment]
--- The module evaluates an input value in dependence on 3 freely definable limits (3 switch-on and 3 switch-off values).
--- When the limits are exceeded or dropped below, the outputs 1-3 are controlled operated.
--- If a limit has been exceeded (dropped below), first the limit must be dropped below (exceeded) again, before the output can be sent again if the limit is exceeded (dropped below) again.
--- [Input]
--- Input [object]
--- Limit 1 ON [value]
--- Limit 1 OFF [value]
--- Limit 2 ON [value]
--- Limit 2 OFF [value]
--- Limit 3 ON [value]
--- Limit 3 OFF [value]
--- [Output]
--- threshold1 - Threshold 1 [object, storage]
--- threshold2 - Threshold 2 [object, storage]
--- threshold3 - Threshold 3 [object, storage]
function fbe_hysteresis_3_limits(input, on1, off1, on2, off2, on3, off3, blockID)
local on = { on1, on2, on3 }
local off = { off1, off2, off3 }
local prevState = storage.get(blockID .. "_prevState") or {}
local out = {}
log(on)
log(off)
log(prevState)
for i=1,3 do
local state = 0
if on[i] ~= nil and input > on[i] then
state = 1
elseif off[i] ~= nil and input < off[i] then
state = -1
end
if state == 0 or prevState[i] == nil or prevState[i] == state then
out[i] = nil
else
out[i] = state > 0
end
prevState[i] = state
end
storage.set(blockID .. "_prevState", prevState)
return out[1], out[2], out[3]
end
LM5Lp, firmware: 2018.08.22 and 2021.12.15, FlashSYS v2, ARMv7 Processor rev 5 (v7l), kernel 4.4.151 and 4.4.259