LogicMachine Forum
More CPU Usage - Printable Version

+- LogicMachine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8)
+--- Thread: More CPU Usage (/showthread.php?tid=4496)



More CPU Usage - Frank68 - 13.01.2023

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



RE: More CPU Usage - Daniel - 13.01.2023

Change grp.write to grp.checkwrite it will help.


RE: More CPU Usage - Frank68 - 13.01.2023

(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


RE: More CPU Usage - Daniel - 13.01.2023

Yes


RE: More CPU Usage - Frank68 - 13.01.2023

(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


RE: More CPU Usage - admin - 13.01.2023

It's all written in the docs: https://openrb.com/docs/lua.htm#grp.checkwrite