local min_fan_slot = 0xff
local max_fan_slot = 0
local min_fan_level = ProcessingFlow[2].Destination.LevelPercentRange[1]
local max_fan_level = 100
for _, cooling_fan in pairs(Input) do
min_fan_slot = cooling_fan.FanId < min_fan_slot and cooling_fan.FanId or min_fan_slot
max_fan_slot = cooling_fan.FanId > max_fan_slot and cooling_fan.FanId or max_fan_slot
end
local fan_level = ReqBody.value
local fan_id = ReqBody.fanid and ReqBody.fanid or 0xff
if not fan_level or fan_level < 0 then
return { 1, min_fan_slot, max_fan_slot }
end
if fan_id and fan_id < 0 then
return { 1, min_fan_slot, max_fan_slot }
end
if ProcessingFlow[2].Destination.CtrlMode == 'Auto' then
return { 2, fan_id, fan_level, min_fan_slot, max_fan_slot }
end
if not (fan_id == 0xff or (fan_id >= min_fan_slot and fan_id <= max_fan_slot)) then
return { 1, min_fan_slot, max_fan_slot }
end
if fan_level < min_fan_level then
return { 3, min_fan_level }
end
if fan_level > max_fan_level then
return { 4 }
end
return { true, fan_id, fan_level, ProcessingFlow[2].Destination.TimeOut }