A new class of entities in Spur, with its position in the overall architecture similar to that of the Jitter class, i.e., like a property attached to a component. When there is a "critical" / "exclusive" section of components that can collectively only hold a single train at a time, an instance of the "block exclusive zone" (BEZ) class will be associated with each component (specified in the input file as an extra field in each component, similar to how jitter is specified). The BEZ instance will be identified uniquely by name.
If the critical section is occupied, additional trains attempting to enter it (i.e., the direction of travel is into the section) will be held and placed into a queue in the BEZ instance. Once a train leaves the critical section, the section is free. The next train in the queue is allowed through, which could be entering from either end of the section.
Parameters
Name (unique)
Logic
BEZ class object:
Maintain a Boolean state variable of whether the critical section is occupied
Maintain a queue structure of trains waiting to enter the critical section
Component with an associated BEZ instance:
When a train requests use of the component [this is the function that SpurResource will call to determine if it should accept the train into the component]:
Check if the train's previous component has the same BEZ instance as the current one it is trying to enter
If yes: train is staying in the same critical section, decide whether to accept the train based on component-specific factors
If no: train is entering critical section
Check if train is already on the queue in BEZ instance
If no: append train to queue in BEZ instance
Check if section is unoccupied AND if the current train is at the head of the queue:
If yes: dequeue the train, update state to occupied in BEZ instance, accept the train
If no: reject the train
When a train is being released from the component:
Check if the train's next component has the same BEZ instance as the current one it is leaving
If yes: train is staying in the same critical section, proceed with the release of the train
If no: train is leaving critical section
Update state to unoccupied in BEZ instance, proceed with the release of the train
Check the head of the queue in BEZ instance - if the train is requesting to enter the critical section from a component other than the current one, proactively call the method to process the request from the resource of that component
(if the next train in the queue is requesting to enter from the current component, the request will be processed automatically as the previous train leaves, handled by SimPy)
Description
A new class of entities in Spur, with its position in the overall architecture similar to that of the Jitter class, i.e., like a property attached to a component. When there is a "critical" / "exclusive" section of components that can collectively only hold a single train at a time, an instance of the "block exclusive zone" (BEZ) class will be associated with each component (specified in the input file as an extra field in each component, similar to how jitter is specified). The BEZ instance will be identified uniquely by name.
If the critical section is occupied, additional trains attempting to enter it (i.e., the direction of travel is into the section) will be held and placed into a queue in the BEZ instance. Once a train leaves the critical section, the section is free. The next train in the queue is allowed through, which could be entering from either end of the section.
Parameters
Logic