This is my latest attempt to get a block for train signals working.
This is a tab for now but will eventually be a sub-flow.
There is a lot of extra stuff on the tab. Input simulation and debug stuff.
The idea is that this is a block of code that receives signals (inputs) and depending on how things are set, may send signals to the outputs.
One of the outputs is then sent to the next block's input and the process is repeated.
I'm also not 100% on the workings of the signals, but I think I am close.
FOREIGN NODE:
Sorry but it is sometimes handy to have
The top part of the tab is the simulated input part.
Whole lot of inject nodes.
Lower part is the code.
There are debug parts which I tried to keep away from the main code.
The input and outputs are link-in and link-out nodes with names explaining their functions.
There is also a group which is used between the output of a node on a side track when it goes into a node which represents points/junction on the track.
Normally the blocks would just connect together - with a slight delay - and work.
But if/when there is/are a set of points (junction) the output of that block would go through the group before going to the next block's input.
(Clear?)
There is an option to HOLD a train at a section.
Then Release it to continue.
Between each section I'd suggest a delay of a few seconds to better show you how the train moves along.
But that is if you get really interested.
The other Signal outputs go to LED nodes and I define the colours to be displayed by their names.
(Keeps it easy)
And there is an output that indicates the position/condition of the points - if there is/are any on that block.
I've used the three main (ONLY?) colours: RED YELLOW and GREEN.
There are other things which can be seen, but for now, I want to make sure I've got the mechanics of the idea working, and those other conditions are rare - at best.
I've named some of the inject nodes with the colour code you should see on the panel (lights) when/if working.
Code:
(Ok, we have a problem. It's too big.)
json format file
I have a working model but the existing subflow fails to allow the train to enter the block if the block is set to hold.
As is, the train is stopped one block before the hold - which is wrong.
So I sat down and put this together. But I now fear/suspect I am blind to any problems with the workings.
Yes, it is a lot to ask. Only if you have a bit of free time.
I've tried to maintain some kind of constant structure. Maybe overkill at this stage, but I want to get the muscle memory so when I do more in the future, the process is there.
Thanks again.
