My solution: The station goes through two phases: 1) if there are any full barrels waiting to be loaded, begin unloading empty barrels (to make space). 2) once there are no full barrels left to load, stop unloading empties and begin loading them from the other side. In the end, the train has picked up all the filled barrels and then filled the rest of its cargo with empties. It can continue running to multiple of these stations, delivering more empties along the way. Eventually, the total amount of empty barrels should become roughly equal across stations.
It all comes down to the circuit network, which works like this: 1 green input line and 2 red output lines, and a third red input/output line.
Green line: reads the amount of empties in the four smart chests being loaded into the assemblers, as well as the amount of full barrels in the four smart chests being loaded onto the train. This runs into the six smart inserters loading empties onto the train, which are set to load if [full barrels] = 0. It also runs into the two combinators on the far right, which connect to...
Red line 1: The first combinator outputs 1 green signal if [full barrels] > 0. The second outputs 1 green signal if [empty barrels] < 1500. 1500 is semi-arbitrarily chosen to be a little less than the capacity of the four leftmost smart chests. Red line 1 carries these signals to the ten rightmost smart inserters, which are set to unload empties from the train if [green signal] > 0, so if either condition is fulfilled. The first condition does most of the work; I added the second condition because I realized there was no way otherwise to deliver empties to a station that has not filled any barrels, so there was no way to get one of these running from scratch.
The green wire also runs into the middle combinator, which connects to...
Red line 2: if the middle combinator reads less than 1500 empties from the green line, it outputs 1 empty (arbitrary signal) along red line 1. This line does not interact with anything else in the pumping station, but runs straight back to my main base, where some assemblers are set to produce more empties if [empty barrels] > 0. So basically make more barrels until every station is full.
Red line 3: this line does not connect to the green line, or any other line; instead it reads directly from the top and bottom pairs of smart chests which load full barrels onto the train, into separate combinators. Each combinator outputs a green signal if [full barrels] < 900 (semi-arbitrarily chosen as less-than-capacity for each pair of smart chests). This runs to the four leftmost smart inserters unloading full barrels from the assemblers, which are set to run only if [green signal] > 0. This is to prevent a backlog of full barrels, since once the loading chests are full, the full barrels will move past them and be stuck next to the loading chests for empties. This is pretty rare, but has happened a few times and its a pet peeve of mine.
That's basically it.
Full disclosure: I may not have realized that you can filter cargo car slots until after I made this...

In before the new update makes this all obsolete probablyyyy. <3