Logic Machine Forum
HEART BIT IMPLEMENTATION - 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: HEART BIT IMPLEMENTATION (/showthread.php?tid=5186)



HEART BIT IMPLEMENTATION - p_xatzi - 04.01.2024

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!


RE: HEART BIT IMPLEMENTATION - Daniel - 04.01.2024

Why don't you use resident script? use grp.update instead of grp.write.


RE: HEART BIT IMPLEMENTATION - p_xatzi - 04.01.2024

(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?


RE: HEART BIT IMPLEMENTATION - Daniel - 04.01.2024

Maybe the trigger group is same as the one you write to and you have a loop.


RE: HEART BIT IMPLEMENTATION - p_xatzi - 04.01.2024

(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!