I have used Siggboys system quite extensively and after messing around with it I now want to build my own system with slightly different design criteria.
Goals
- The main goal is for this system to be scalable to a really high throughput
- Secondary goals include minimal configuration when setting up and when expanding the system
- Current design assumes a fixed size train
- Only full loads will be transported
- Each station is built to handle one type of material
- The system does not scale indefinetly, there is a limit in throughput for each material due to the matching system. In addition, this is somewhat dependent on the number of stations
- Will probably require a large number of combinators for each station (depending on how smart I am... or how much you guys help me )
- Currently need both green and red wire to function, if possible Id like to optimize this but I am not confident I can without reducing system throughput
- This is currently a paper design, I will need to tinker a lot with the details to get this fully functional
Depot and control panel
- Manages bit/adress list
- Stores system settings, train capacity etc.
- Main system clock
- Store, refuel and dispatch unused trains
- Monitor for system health
- System reset for when things are a mess
- Broadcasts available resource
- Requests empty train for loading (either when material for 1 trainload is available, or using prefetch to improve throughput)
- Match with and request available resource from provider station (including collision detection)
- Dispatch empty trains to Depot
- Possible feature not yet included - dynamic dispatch directly to next station without passing depot (dependant on dynamic refuel solution)
- Station registration and removal from the station bit/adress list
- Registering new station IDs
- Match materials for transport
To enable maximum throughput in the system I have decided on a decentralized peer to peer system. In practice this means the logic for matching and sending trains are part of each station.
To speed up matching and increase system throughput I have decided to assign each station a bit in a bit mask. My hope is that this can greatly reduce the selection and matching process.
The combinator uses a 32 bit signed integer. I reserve 1 bit for interrupt and collision detection. This way a large number of stations can signal if they have a material available each tick.
Ill have to experiment a bit with this part to see how many bits I can actually use, it depends on how fast I can decode/encode this. In a best case scenario I should be able to flag the status for 31 stations each tick. (unless Im getting this wrong...)
If more than 31 stations are to be used Ill simply have to alternate between the two or however many are needed. (this enumeration should be based on the system clock)
Here is an example:
Ill use iron and the station is assigned bit 3 (integer value of 4)
Starting in the default state the provider station signals 4 iron on the red wire once it has a full train ready for transport, all these values add up, but by looking at each bit we know the availability at each station.
A requester station that needs iron reads the positive iron signal on the red wire and initiates the decoding and selection process. I hope to keep this as short as possible by selecting the first or last available bit that is flagged.
Once selected the requester station will send an iron interrupt signal using bit 32 (-2147483648). If multiple bit masks are used this will have to be timed correctly using the system clock.
All iron stations in the system will thus see a negative signal on the system and stop transmitting. If two requester stations signal at the same time this will cause an overflow and the signal will not be negative. This will tell both requester stations that a collision has occured. Either dropping the attempt and inducing a delay based on station ID in each station, or handling the collision. Im not sure whats best yet.
Assuming no collision was detected the next tick the requester station will send the bit value for the selected provider station. In this case 4, this will ensure the provider station listens.
The tick after that the requester station will send its own station ID as an iron integer, at the same time the provider station will send its station ID as an iron integer.
The number on the bus is now a combination of both station IDs and the matching process is completed. All iron stations will now go back to the default state and the bus is now ready for the next matching.
My plan is to keep this matching process to a fixed number of ticks so that the bus can go back to normal without a second interrupt signal to start it up again.
In a maximum throughput scenario it should be possible for the next match to be initiated on the tick after this.
While that is going on both stations now have a combined number that they will need to decode. This is a simple process since they both know their own station ID and simply subtract that from the number they received on the bus.
If the number is higher than 0 they have a confirmed match. The provider can dispatch the train and the requester can store in a register that it is to receive a trainload of iron.
Ill just stop here for now, Im already out of time...