Thanks for posting! A couple of comments on the Rules.
ReentrantLocks are dangerous. Thread::sleeps are likewise, dangerous. Even worse is when you put those into a “forever” loop. See Why have my Rules stopped running? Why Thread::sleep is a bad idea for details.
As far as I can tell, the while loop waiting for Remote_Send to change to OFF and the following sleep only serves to delay when the logInfo runs. So instead of using the while loop and sleep, use a Design Pattern: Looping Timers.
val timer = createTimer(now.plusMillis(100), [ |
if(Remote_Send.state != OFF) timer.reschedule(now.plusMillis(100))
else createTimer(now.plusMillis(400), [ | logInfo("Prueba", Remote_Send_Out.state.toString.replaceAll("\r|\n"," Ejecutado ") )])
])
And instead of using the ReentrantLock, use Design Pattern: Gate Keeper. This will queue up your commands and ensure that they never run at the same time or too close together without the risks imposed by the ReentrantLock and without consuming precious Rules threads.