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.

event script e os.sleep
#3
(18.11.2020, 10:20)admin Wrote: Are you using event.getvalue()? You should use grp.getvalue(event.dst) after sleep.
Hi

I use grp.getvalue(event.dst) this is my code
Code:
-- INDICAZIONI COMUNI -- get current data as table now = os.date('*t') TS=' del '..now.day..'/'..now.month..'/'..now.year..' alle '..now.hour..':'..now.min..':'..now.sec..'.' -- recupero indirizzo mail e telefono principali DestGen  = grp.getvalue('32/1/1') NumTel  = grp.getvalue('32/1/2') -- INDIRIZZI MAIL SECONDARI DestMail1  = grp.getvalue('32/1/10') DestMail2  = grp.getvalue('32/1/11') DestMail3  = grp.getvalue('32/1/12') DestMail4  = grp.getvalue('32/1/13') DestMail5  = grp.getvalue('32/1/14') DestMail6  = grp.getvalue('32/1/15') -- NUMERI TELEFONO SECONDARI NumTel1  = grp.getvalue('32/1/20') NumTel2  = grp.getvalue('32/1/21') NumTel3  = grp.getvalue('32/1/22') NumTel4  = grp.getvalue('32/1/23') NumTel5  = grp.getvalue('32/1/24') NumTel6  = grp.getvalue('32/1/25') -- recupero tag per destinazione FLT_TAG1 = grp.getvalue('32/1/30') FLT_TAG2 = grp.getvalue('32/1/31') FLT_TAG3 = grp.getvalue('32/1/32') FLT_TAG4 = grp.getvalue('32/1/33') FLT_TAG5 = grp.getvalue('32/1/34') FLT_TAG6 = grp.getvalue('32/1/35') id=event.dst -- wait forseconds os.sleep(15) --recupero  STATO INTERUTTORE value = grp.getvalue(id) -- recupero descrizione name = grp.alias(id) ------- retry TAGS for mailing dest tbl = grp.gettags(name) strTAGS = table.concat(tbl, ', ') -- last val memory OldVal=grp.getvalue('32/1/55') -- setc current val to OldVal object grp.write('32/1/55', value) -- cambio del valore rispetto giro precedente if(value~=OldVal) then --casistica valori   if (value==1) then     log('valore 1')     subject = 'Commutazione selettore UTI'     message = 'Stato  ID  - '.. id .. ' - ' .. name  ..'  Posizione 1  ' .. TS     mail(DestGen, subject, message)     alert(message)     ALM = false   end        if (value ==2) then     log('valore 2')     subject = 'Commutazione selettore UTI'     message = 'Stato  ID  - '.. id .. ' - ' .. name  ..'  Posizione 2  ' .. TS     mail(Dest1, subject, message)     alert(message)     ALM = false     end        if (value ==0) then     subject = 'Commutazione selettore UTI'     message = 'Stato  ID  - '.. id .. ' - ' .. name  ..'  Posizione Sconosiuta  ' .. TS     mail(Dest1, subject, message)     log( 'valoer 0')     alert(message)     ALM = true     end end ------------------------------------------------------------------------------------

in my code I would like, if possible, that only after a certain period, depending on the value 0,1,2, delel actions were performed, but unfortunately seeing from the log ('value n'), 0 is always also executed without taking into account the time 15 cesondi, in this period the value has changed state and is no longer 0, in practice only if I have 0 after a certain period I have to perform an action.

available for clarification

thanks
Reply


Messages In This Thread
event script e os.sleep - by Frank68 - 18.11.2020, 10:15
RE: event script e os.sleep - by admin - 18.11.2020, 10:20
RE: event script e os.sleep - by Frank68 - 18.11.2020, 12:40
RE: event script e os.sleep - by admin - 18.11.2020, 14:27

Forum Jump: