Page 1 of 1

### Train stations with multiple wares

Posted: Mon Nov 14, 2022 3:35 am
Hello folks! I'm having an issue setting up a specific train station, and I'd need the help of one of the combinator guru out there to tell me if there's an easy fix.
Problem is, my understanding of the combinator is pretty basic. I can get along with the circuit network cookbook... well most of it... but that's prtty much it.

So I have this train station that needs to output 7 different ressources (yes, I know, bad idea, but I want to try. And yes, it's Bob&Angel, which is why I have so much different stuff to shuffle around). I want to make it so that a train will come pick a resource:
-only if there's enough to fill it
-fill it only with one ressource (although that point is minor)
-only if the receiving station has enough room for it
Most of this is covered, but I have one major hiccup.

The setup:
-The "pulling" station sends a -1 signal on the base network for every ware it has enough room to receive a train. (I set that as convertion for other setups, so I'm using this here by default)
-The "pushing" station
1) convert these back to +1 with a (decider, any<0, any, 1)
2) sends a signal for any wares in sufficent quantities (decider, any>8000, any, 1)
3) combines both signals from 1 and 2, send to the station and filter inserters if both entries above have a common hit (decider, any = 2, any, 1)

So as soon as I have a ware that is both needed and has a value of >8000, the station activates and the inserters are ordered to take the ware in question

The problem: The train arrives, the inserters start to load the train, until the warehouse value drops below 8000. Then the inserters deactivate, leaving a train nearly empty. I would need twice the required quantity to fill up the train fully.
I was thinking I would need to use a S/R latch or a memory cell in conjonction with my setup above, so the inserters keep their setup active as long as there's a train in the station, then reset when the train leaves. Sadly, I have absolutely no clue how to proceed.

Here's a snapshot of the current setup. Thanks for suggestions.

### Re: Train stations with multiple wares

Posted: Mon Nov 14, 2022 11:46 am
Not sure about the whole setup but I maybe have an easy solution for your immediate problem:
Set your station to read train content and send that signal into your ">8000" detection logic (on a different wire colour)
That way what is inside your train is still considered to be inside the warehouse and your inserters won't stop.

If you can that logic should only apply to your inserter logic and not towards the logic that activates the station.

### Re: Train stations with multiple wares

Posted: Mon Nov 14, 2022 7:26 pm
Ezarkal wrote:
Mon Nov 14, 2022 3:35 am
Hello folks! I'm having an issue setting up a specific train station, and I'd need the help of one of the combinator guru out there to tell me if there's an easy fix.

I was thinking I would need to use a S/R latch or a memory cell in conjonction with my setup above, so the inserters keep their setup active as long as there's a train in the station, then reset when the train leaves. Sadly, I have absolutely no clue how to proceed.

Here's a snapshot of the current setup. Thanks for suggestions.
I think the solution proposed by Nosferatu is your easy fix.

The not so easy S/R latch i think would also require you to "read train content" or "read train ID" using a red wire from your screenshot.

The first part would be to detect when to start holding the value. This can be done in your setup using that red wire to send the train ID to a combinator that does each * (-1) => each and then to the "memory cell filter" . And another wire skipping this (*-1) step going directly in the "memory cell filter". In practice when a train will arrive at the station, it will send its ID directly to the memory cell filter , and 1 tick later, the negative ID will also be sent to the memory cell filter canceling each other.

This allow you to have 1 special tick during which T signal will be positive when a train arrive.

The memory cell could be made with a decider combinator allowing "all value" to pass , only when T is not 0 ( the filter). with as input the 2 parralel wire used for the ID signal and 1 coming from your warehouse. This means when a train arrive, only during 1 tick, the content of the warehouse is "sent forward" through the filter.

This is not yet a memory cell though, just the requirement to produce the kind of signals that make them work, a signal that last only 1 tick. This allow to use a decider combinator that does ( If T superior than 0 output each ) looping on itself. just after the previously described filter.

This means after the 1 tick signal containing the train ID and the warehouse content, is received, it will stay in the memory combinator unchanged until a train leaves.

When the train leaves, its positive ID will be removed 1 tick earlier than the negative ID which means during 1 tick the T value will not be 0 but be negative, the filter will read T is not 0 and pass the new negative ID in the memory cell, which will stop emiting any value, since T is not superior to 0 when a train leaves, this is the reverse one where for 1 tick the value is negative, it will therefore reset the memory until another train arrive.

I made a blueprint because at this point i realize my explanation maybe are bad
memory warehouse train.png (519.68 KiB) Viewed 315 times

I'm not quite sure how that would play out with your existing design and i think it's a little different than the memory cell you can see in the circuit cookbook but it works with somewhat of the same principle, it's easier to understand when you use the /editor command in game, and then make the time pass only 1 tick at a time and looking at the value on the circuit network because some event occur only during 1/60th of a second and when you are not already familiar with what's going on it's not easy to grasp at real speed.

again i think Nosferatu's proposal is simpler but maybe you want to toy a bit with combinators

### Re: Train stations with multiple wares

Posted: Mon Nov 14, 2022 10:25 pm
Nosferatu wrote:
Mon Nov 14, 2022 11:46 am
Not sure about the whole setup but I maybe have an easy solution for your immediate problem:
Set your station to read train content and send that signal into your ">8000" detection logic (on a different wire colour)
That way what is inside your train is still considered to be inside the warehouse and your inserters won't stop.

If you can that logic should only apply to your inserter logic and not towards the logic that activates the station.
You, good sir, are a genius. I should be able to make this work with the train signal.
I will try to split this from the inserter logic as suggested. It should be doable. It is not necessary in my current setup, but it could become usefull as my base grow, and we all know bases tend to do that.
mmmPI wrote:
Mon Nov 14, 2022 7:26 pm
[…]

Thank you very much for your reply. I'll play around with the idea and try to make something out of it, if only for the educational purposes. Combinators are tricky.

### Re: Train stations with multiple wares

Posted: Tue Nov 15, 2022 1:02 am
Ezarkal wrote:
Mon Nov 14, 2022 10:25 pm
I'll play around with the idea and try to make something out of it, if only for the educational purposes. Combinators are tricky.
i agree it's tricky and i wouldn't recommend using the previous blueprint over the much simpler solution when it's available

The S/R latchs from the cookbook i think are meant to be used with pulse signal, lasting only 1 tick, which you get easily when reading from a belt or inserter but not from a train or warehouse/chest content, those are called continuous signal i think in proper english.

The previous blueprint uses a trick to create a pulse signal from the contiuous signal generated by the train stop reading the train ID.

It uses the way the circuit network value are updated to catch the moment a train enter or leave the train stop.

If you consider the ID of the train every tick as it is read by the train stop it will look like this : ( 0 0 0 15 15 15 15 15) ( with 15 the ID is the value of the signal T , looking at 8 successive value over time ; when a train arrive 3 time 0 when the train is not here yet and then only 15 when the train is here)

If you wire the station to an arithmetic or decider combinator's input and then from that combinator's output to somewhere else, you happen to delay the signal by 1 tick it will be (0 0 0 0 15 15 15 15) ( just 1 more 0 ). That is the very important notion hard to see in game when time is not slowed.

The output of that delayed signal is also the negative of the original signal, because the operation is * -1. ( 0 0 0 0 -15 -15 -15 -15)

So when this delayed negative signal and the original signal are sumed, which happens with a green wire and a red wire connected to the input of the decider combinator ( the filter ) there is 1 tick latency when the result is positive before it is 0 , so (0 0 0 15 0 0 0 0 ) And this is a pulse with 15, different than 0, which means the filter let the warehouse content in the memory and the 15 T signal ( the filter let "everything" pass when T is not 0). And also superior to 0 which means the memory cell will remember.

When the train leaves, the delay is in the other way around, the value are ( 15 15 15 15 0 0 0 0) in the direct signal, and ( - 15 -15 -15 -15 -15 0 0 0) in the delayed signal. the result is ( 0 0 0 0 -15 0 0 0) .And this is a pulse with -15, different than 0, which means the filter let the -15T signal through, into the memory cell and also the content of the warehouse again but that doesn't matter because then the memory cell will have a T value of 0. Since it has the 15 in memory and is now receiving -15. This means the memory cell will reset ( given the condition is : T strictly superior to 0 in the memory cell).

It's now ready for the next train.

I hope those explanations are less sloppy than the previous one and more useful for educational purposes