Logic Machine Forum
Event Script problem - Printable Version

+- Logic Machine 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: Event Script problem (/showthread.php?tid=2763)



Event Script problem - Frank68 - 31.07.2020

Hi I have make some event script "parametric" , in one sysstem with more event alarm

see below

-- GET CURRENT DATA AS TABLE
now = os.date('*t')
TS=' del '..now.day..'/'..now.month..'/'..now.year..' alle '..now.hour..':'..now.min..':'..now.sec..'.'
-- GET MAIL ADDRESS
Dest  = grp.getvalue('32/1/41')
--GET ADDRESS EVENT FIRE
id=event.dst
--GET VALUE
value =grp.find(event.dst).value
-- GET NAME OF OBJECT
name = grp.alias(id)
-------------------------------------------------------------------------------------
if (value == true) then
  subject = 'Allarme Scatto'
  message = 'Inizio ' .. 'ID ' .. id .. ' - ' .. name  ..' '.. TS
  mail(Dest, subject, message)
  alert(message)
  ALM = 1
elseif (value == false) then
  subject = 'Ripristino Allarme'
  message = 'Ripristino ' .. 'ID ' .. id .. ' - ' .. name  ..' ' .. TS
  mail(Dest, subject, message)
  ALM = 0
end
------------------------------------------------------------------------------------
--SET TOTAL NUMBER ALARM
ALM_OLD = grp.getvalue('32/1/40')

if (ALM==1) then
  Alm_N = ALM_OLD+1
elseif (ALM==0) then
  Alm_N = ALM_OLD-1
end 

grp.write('32/1/40', Alm_N)

My proble the script when have event not run , manualy run , where is the problem ?

Best regards


RE: Event Script problem - fleeceable - 31.07.2020

Hi!

Does your trigger variable has been changed?
Does your triger variable has boolean datatype? (01.002 boolean)
Put some logs in your script and try to modify event group address manually. Try this:


Code:
-- GET CURRENT DATA AS TABLE
now = os.date('*t')
TS=' del '..now.day..'/'..now.month..'/'..now.year..' alle '..now.hour..':'..now.min..':'..now.sec..'.'
-- GET MAIL ADDRESS
Dest  = grp.getvalue('32/1/41')
--GET ADDRESS EVENT FIRE
id=event.dst
--GET VALUE
value =grp.find(event.dst).value
-- GET NAME OF OBJECT
name = grp.alias(id)

log(value)
-------------------------------------------------------------------------------------
if (value == true or value == 1) then
  log('value is true')
  subject = 'Allarme Scatto'
  message = 'Inizio ' .. 'ID ' .. id .. ' - ' .. name  ..' '.. TS
  mail(Dest, subject, message)
  alert(message)
  ALM = 1
elseif (value == false or value == 0) then
  log('value is false')
  subject = 'Ripristino Allarme'
  message = 'Ripristino ' .. 'ID ' .. id .. ' - ' .. name  ..' ' .. TS
  mail(Dest, subject, message)
  ALM = 0
end
------------------------------------------------------------------------------------
--SET TOTAL NUMBER ALARM
ALM_OLD = grp.getvalue('32/1/40')

if (ALM==1) then
  Alm_N = ALM_OLD+1
elseif (ALM==0) then
  Alm_N = ALM_OLD-1
end

grp.write('32/1/40', Alm_N)



RE: Event Script problem - Frank68 - 31.07.2020

(31.07.2020, 08:47)fleeceable Wrote: Hi!

Does your trigger variable has been changed?
Does your triger variable has boolean datatype? (01.002 boolean)
Put some logs in your script and try to modify event group address manually. Try this:


Code:
-- GET CURRENT DATA AS TABLE
now = os.date('*t')
TS=' del '..now.day..'/'..now.month..'/'..now.year..' alle '..now.hour..':'..now.min..':'..now.sec..'.'
-- GET MAIL ADDRESS
Dest  = grp.getvalue('32/1/41')
--GET ADDRESS EVENT FIRE
id=event.dst
--GET VALUE
value =grp.find(event.dst).value
-- GET NAME OF OBJECT
name = grp.alias(id)

log(value)
-------------------------------------------------------------------------------------
if (value == true or value == 1) then
  log('value is true')
  subject = 'Allarme Scatto'
  message = 'Inizio ' .. 'ID ' .. id .. ' - ' .. name  ..' '.. TS
  mail(Dest, subject, message)
  alert(message)
  ALM = 1
elseif (value == false or value == 0) then
  log('value is false')
  subject = 'Ripristino Allarme'
  message = 'Ripristino ' .. 'ID ' .. id .. ' - ' .. name  ..' ' .. TS
  mail(Dest, subject, message)
  ALM = 0
end
------------------------------------------------------------------------------------
--SET TOTAL NUMBER ALARM
ALM_OLD = grp.getvalue('32/1/40')

if (ALM==1) then
  Alm_N = ALM_OLD+1
elseif (ALM==0) then
  Alm_N = ALM_OLD-1
end

grp.write('32/1/40', Alm_N)
Hi the variable is boolean , I make script event on object page .
I have more of 100 event script , is possible the problem is this ?

thank's


RE: Event Script problem - fleeceable - 31.07.2020

Tested your script and works for me.
At least when I modified object value from objects tab.

What is your processor values?
Admins can answer that if script count can be the problem...


RE: Event Script problem - Erwin van der Zwart - 31.07.2020

Hi,

Have you tried a restart of the controller?

BR,

Erwin


RE: Event Script problem - Frank68 - 31.07.2020

(31.07.2020, 10:29)Erwin van der Zwart Wrote: Hi,

Have you tried a restart of the controller?

BR,

Erwin

Yes controller restarted , the mail address
Code:
Dest  = grp.getvalue('32/1/41')
is set in init script.

thank for all