I just finished my first working version of a smart unloading station using two new features: station disabling (0.15) and reading stopped train (0.15.11).
Stations not ready for trains are disabledWhen there are multiple stations with the same name the trains will drive to the nearest (free) station. By disabling stations that wouldn't allow trains to enter all trains targeting that station are redirected instantly. Normally that only happens when they get blocked at some signal.
Has a waiting bayThe waiting bay allows one train to unload and one train to wait behind it. Once the first train leaves the second can quickly reach the station and start unloading. This minimized the interval between trains considerably, more so the farther away they have to travel.
Normally a waiting bay will conflict with disabling stations because the second train will skip to the next station on its list if all unloading stations are busy. Trains wait at the "pre" station until they get a signal to move on and that is timed with the following unloading station to be empty and enabled. A waiting bay train will always go on to the following unloading station.
Unloading never blocksThe station keeps track of the amount of items in the buffer chests, in the hands of the inserters doing the unloading, in the wagon being unloaded, the wagon in the waiting bay and even said wagon while it drives from the waiting bay to the unloading stop.
The unloading station has therefore always an exact count of items that will be unloaded. The waiting bay is only enabled if a full train car can be unloaded into the buffer chests. A train will therefore never be stuck in the station waiting for items to be consumed so it can be unloaded.
This allows for fewer trains to service more stations and adjusts to demands. A slow consumer will only get one train every so often while a fast consumer will get trains in its waiting bay.
Trains won't stop on the main trackWith a single waiting bay the signals will normally prevent a third train from entering the station. The train will then sit in front of the branch to the stations and block traffic until it gets re-path-ed. Worse, if there are more trains than unloading stations or it doesn't feel like it then it might not switch to another station.
Not so when using disabled stations. As soon as a station is disabled all trains targeting that station will switch to another station with the same name or skip that station. Due to the chain signals used at the entry this happens while any train is still on the main track and it will keep on driving. Due to the way the stations are disabled it will also always skip the unloading station when it skips a waiting bay station.
Tips about the design- The stations have a green light that shows if they are enabled. The waiting bay also as a red light that shows if a train is allowed to leave the station.
- The combinators are placed so that signals run from bottom to top. Each combinator is one higher than its highest input. This is just so I can keep track of signals delays.
- Each station has a edge trigger for the T signal. In the waiting bay it stores the train contents in a memory cell while at the unloading stop it clears the memory cell. This keeps track of the train contents while it moves between the two stops.
- There is also a SR flip-flop to generate the go signal for the waiting bay.
- A bunch of combinators are just there to add a delay to a signal.
Figuring out which is which is left as an exercise to the reader.