30.12.2020, 08:44
Sorry... I change some parts to reduce the code and I put wrong...
No mistakes in syntax and no mistakes in error log
This is the original code in user.varios
And this in resident
No mistakes in syntax and no mistakes in error log
This is the original code in user.varios
Code:
function Revisar_Temporizadores ()
now = os.time()
for i = 1,#TemporizadoresActivos, 1 do
local tf = "_on"
if i == 2 then tf = "_off" end
for _, pir in ipairs(TemporizadoresActivos[i]) do
if next(pir) then
--log(pir)
CrearDG ("ACK_Temp_"..pir.Nombre, pir.DG_Tempo_Activo, dt.bool,"ACK_Tiempo_Activo")
CrearDG ("Delta_"..pir.Nombre, pir.DG_Tempo, dt.uint32)
key = 'pir_timer_' .. pir.Input .. tf
delta = now - storage.get(key, 0)
if grp.getvalue(pir.DG_Tempo_Activo) and pir.T_Activo then
grp.checkupdate(pir.DG_Tempo,delta)
end
t = grp.getvalue(pir.Tiempo)*60
if pir.Condicion == nil then
if delta > t then
if pir.Output ~= nil then
grp.checkwrite(pir.Output, 0)
end
grp.checkupdate(pir.DG_Tempo_Activo,false)
end
else
local cumple = (grp.getvalue(pir.Condicion) - 200) > grp.getvalue(pir.ACKCondicion)
if (delta > t) and (cumple) then
grp.checkwrite(pir.Output, 0)
grp.checkupdate(pir.DG_Tempo_Activo,false)
elseif (delta > t) and (not cumple) and ((grp.getvalue(pir.DG_Tempo_Activo))) then
storage.set(key, now)
end
end
end
end --End for temporizadores on off
end --End for temporizadores
return ("Temporizadores Revisados")
end --End funcion
And this in resident
Code:
require('user.Varios')
local Revisados = Revisar_Temporizadores ()