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.

HEART BIT IMPLEMENTATION
#1
Happy New Year to all,

I am trying to implement a heart bit that I use to send to some modbus servers in order to take appropriate action by their side if communication is lost.

I have setup the following simple event script:


Code:
value = event.getvalue()

log('start value : ' .. tostring(value) )

os.sleep(10.0)

value1 = not value

grp.write('31/7/1', value1)
grp.write('1/1/255', value1)
grp.write('2/1/255', value1)
grp.write('3/1/255', value1)
grp.write('4/1/255', value1)
grp.write('5/1/255', value1)
grp.write('6/1/255', value1)
grp.write('7/1/255', value1)
grp.write('8/1/255', value1)
grp.write('9/1/255', value1)
grp.write('11/1/255', value1)
grp.write('12/1/255', value1)
grp.write('13/1/255', value1)
grp.write('14/1/255', value1)
grp.write('15/1/255', value1)

log('new value : ' .. tostring(value1) )

GA '31/7/1' is the trigger bit which I initiate every minute buy a scheduled script in case something goes wrong.

The monitor of heart bit at modbus slave site is shorter than a minute so I can not use a scheduled script for that purpose.

Initially script works but after some time it runs continuously not taking into account os.sleep function.

What am I doing wrong. 

Thanks in advance!
Reply
#2
Why don't you use resident script? use grp.update instead of grp.write.
------------------------------
Ctrl+F5
Reply
#3
(04.01.2024, 14:04)Daniel Wrote: Why don't you use resident script?  use grp.update instead of grp.write.

Thanks! It works! Long time to use resident scripts and forgot that you can set time interval... But why is this issue with event script. Is there something I am missing?
Reply
#4
Maybe the trigger group is same as the one you write to and you have a loop.
------------------------------
Ctrl+F5
Reply
#5
(04.01.2024, 17:18)Daniel Wrote: Maybe the trigger group is same as the one you write to and you have a loop.

Anyway, thanks a lot!
Reply


Forum Jump: