My problem comes with the unloading portion. The rule for the train is to wait until cargo is empty. Where this occasionally becomes a problem is when the chests aren't unloading fast enough. The previous train would be gone already, the next train comes up that lane and can't unload its cargo since the chests are still (partially) full. Here's the image, my idea on how to solve this is below.

What I am wanting to figure out is if there's a way to keep track of the total amount of items in the unloading chests, per row, so that I can turn a signal on/off at the entrance, hence redirecting a train to an empty unloading area. I am currently using red wiring to figure out the total of each ores through the system, for the south waiting area. That's fairly easy, I tell the signal based on specific ore and amount. Is there a way to use a similar method to find out the total amount of items in 4 chests for the unloading area, keeping in mind that a chest can contain (and often will) more than one type of item?
thanks!