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.

More CPU Usage
#1
Hi
I can't understand why this script causes excessive CPU load, running every 5 s

Code:
---------------------------------------------------------------------------------------------------------------------------------------
------------------------------------ CONTROLLO REINSERIMENTO PARTIZIONI ALLARME ALLA CHIUSURA DI PORTE SE NEGLI ORARI IMPOSTATI
---------------------------------------------------------------------------------------------------------------------------------------
now = os.date('*t')
TS=' del '..now.day..'/'..now.month..'/'..now.year..' alle '..now.hour..':'..now.min..':'..now.sec..'.'
dc=grp.getvalue('0/2/100') -- 0 = TUTTE PORTE CHIUSE


---------------------------------------------PARTIZIONI ---------------------------------------------------
-- CONTROLLO SE ATTIVATO SCHEDULATORE E SE ENTRO IL RANGE
sched=grp.getvalue('32/5/1') -- SCHEDULATORE ATTIVATO
on_time=grp.getvalue('32/5/5') -- VALORE OGGETTO SCHEDULATO
-- ABILITAZIONE CON SOLO PORTE
porte=grp.getvalue('32/5/7') -- ABILITAZIONE INSERIMENTO CON PORTE CHIUSE

-- CONTROLLO SE INSERITO
n_imm =grp.getvalue('9/6/5')    -- INSERITO IMMEDIATO
n_rit = grp.getvalue('9/6/25') -- INSERITO RITARDATO

e_imm = grp.getvalue('9/6/3') -- INSERITO IMMEDIATO
e_rit = grp.getvalue('9/6/23') -- INSERITO RITARDATO

s_imm = grp.getvalue('9/6/1') -- INSERITO IMMEDIATO
s_rit = grp.getvalue('9/6/21') -- INSERITO RITARDATO

-- or (e_imm==true or e_rit==true)
or_ins = ((n_imm==true or n_rit==true) and (s_imm==true or s_rit==true))
--log( 'VALORE OR INS '..tostring(or_ins))

-- AUTOMATICO PORTE CHIUSE
if (or_ins == false and (on_time==true and sched==true and dc==false))  then
        -- ATTIVO PARTIZIONE RITARDATA PORTE CHIUSE
      grp.write('9/4/1', true)
      grp.write('9/4/5', true)
        --log('ATTIVAZIONE PARTIIONI PERIMETRALI DA SCHEDULATORE' .. TS)
-- ATTIVAZIONE CON SOLO PORTE CHIUSE
elseif (or_ins == false and (sched==false and porte==true and dc==false))  then
        -- ATTIVO PARTIZIONi RITARDATA PORTE CHIUSE
      grp.write('9/4/1', true)
      grp.write('9/4/5', true)
    --log('ATTIVAZIONE ALLARME PARTIIONI PREIMETRALI PORTE CHIUSE' .. TS)
elseif dc==true then
    grp.write('4/7/18', true) -- perimetrale nord
    grp.write('4/7/7', true)  -- perimetrale sud
  grp.write('4/7/16', true) -- abitazione Emanuele
end 

-- disinsermento per gestione manaule o porta aperta
if (sched==false and porte == false) or (dc == true) then
      grp.write('4/7/18', true) -- perimetrale nord
        grp.write('4/7/7', true)  -- perimetrale sud
    grp.write('4/7/16', true) -- abitazione Emanuele
end
Reply
#2
Change grp.write to grp.checkwrite it will help.
------------------------------
Ctrl+F5
Reply
#3
(13.01.2023, 08:45)Daniel Wrote: Change grp.write to grp.checkwrite it will help.

Is possible to use in this way on bool variable, not using Delta

Code:
grp.checkwrite('32/2/2', true)

thank's
Reply
#4
Yes
------------------------------
Ctrl+F5
Reply
#5
(13.01.2023, 09:40)Daniel Wrote: Yes

The same is for
Code:
grp.checkupdate('4/7/21', a)

is value a  not change not write to bus ?

tnak's a lot
Reply
#6
It's all written in the docs: https://openrb.com/docs/lua.htm#grp.checkwrite
Reply


Forum Jump: