A Priority System
-
- Manual Inserter
- Posts: 2
- Joined: Sun Nov 29, 2020 1:22 am
- Contact:
A Priority System
I originally designed this to be used in a city block type base where there are multiple train pickups and drop offs for a variety of items spread around the base. To control whether or not a station was active an SR latch was hooked up such that trains would only come if the latch was "set." However problems arose when secondary outputs overflowed. The entire base would lock up once a critical item was produced as a secondary output but not be picked up by trains since all the drop offs were already full. If trains would prioritize picking up these critical items from areas where they were a secondary output, then the base would continue as normal.
Here is a simplified version of the base's rail network using the priority system. (The green lamp below the rail indicates a station is on) The train will go to the bottom station to drop off iron plates, then go to the stations above it to pick them up. Each station has a node hooked up to it with priorities top to bottom: 500, 500, 100, 250. The top two stations have the highest priority and therefore are active. After the train goes to the top two stations their SR latches will reset temporarily removing them from the priority system. After the top two stations disable the bottom station will be active since it has the second highest priority. If a higher priority station activates again, then any lower priority stations will disable regardless of the lower priority stations' contents. This system works by using the average priority of all active stations. If a station's priority is greater than the average priority, then it adds it's priority to the average calculation. If a station's priority is less than the average priority, then it removes it's priority from the calculation. Since stations remove their priority if it's less than the average, the average converges to the highest priority. To prevent stations from flashing on and off while the average converges I have a clock that resets upon a station's activation to delay the actual activation of the train station. To calculate the average I just have the sum of all priorities on green and the count of priorities on red then dividing the sum by the count. Blueprints:
node
station