¿ªÔÆÌåÓý

Re: LogixNG - Sanity check and guidance


 

¿ªÔÆÌåÓý

Nick,

The problem with your solution is that the action "Execute A after 10 seconds" does not stop the ConditionalNG. The ConditionalNG continues to run and stops as soon as all the actions are completed. And then the rest of the ConditionalNGs run. The "Return" action is executed after 10 seconds, but at that time the other ConditionalNGs have already been run.

I could add a new LogixNG action "Wait" that would stop the ConditionalNG from running for some time, but it would be bad programming practice to use it. And there is a huge risk that non experienced users would use it in a bad way. LogixNG is intended to be used also by users which are not experienced developers but want to do some programming.

The solution I gave you with the internal sensor will keep the other ConditonalNGs from doing their stuff before they are supposed to do so.

Daniel

On 2025-04-21 16:59, nicklocke via groups.io wrote:

Thanks Daniel.
?
Much appreciated that you took the trouble/time to ask on the JMRI developers list.? I can see that Bob has replied, but it looks like I don't have access to answer there. Bob makes a good point about responses not necessarily being received, although the send queue becomes empty. In my specific use case, that is fine though. All I am trying to prevent is more and more messages being added by the NGs, making the send queue longer and longer- the responses coming back later "asynchronously" is fine.?I do agree with Bob's point about possible user confusion though.
?
Thanks for confirming that the single threading is going to work how I expected.
?
I think I might be missing something with your recommendation though. All I am trying to do with the "Execute A after 10 seconds" is make sure that there is time to breathe before the next ConditionalNG kicks into life. I agree that if they were running "all over the place" then it would make sense to use an internal sensor. But here, I am running the ConditionalNGs once when JMRI starts and never again. So, unless I am missing something (which is very likely), I can't see any functional difference between:
?
  • Wait ten seconds ....... Return ....... Next Conditional NG starts (because the thread is now free).
  • Wait ten seconds ....... Set Internal Sensor ...... Next Conditional NG starts (because the thread is now free) ....... NG checks the sensor, which will always be set by now, and carries on.
Maybe though, good practice says I should use the internal flag approach, just in case the ConditionalNGs are not always only run at startup in the future.
?
Thanks, Nick.

Join [email protected] to automatically receive all group messages.