Updating Loop
This simulator has 7 states. The current state is shown in the upper left corner of the display.
0. Stopped
1. Idle
2. Starting
3. Transition
4. Run
5. Return
6. Parking
In system states 2, 3, 5 & 6 temporary paths are followed by a train to move from the parking lot, to their assigned path and from their assigned path back to the parking lot. A train is switched from its current path to its next path when the next two sections of track in the current path match two sections of track in the next path.
0. The "Stopped" simulator state is entered when the simulator is started, or after the <ABORT> or <End Run> buttons are clicked. See the Introduction for options available in the "Stopped" state. After configuring a simulator run in the Initialization window, clicking <Run Train(s)> will change the simulator to the "Starting" state (2) below and start the Updating Loop program.
1. The "Idle" state is entered from the "Parking" state (6) when <Repeat Runs> was selected, the random number of run steps were completed in "Run" state (4) and all trains are parked in state 6. The next simulator run is configured similarly to the one selected in "Stopped" state (0). The same number of paths are randomly selected, direction randomly assigned and assigned to a randomly selected colored trains. A random number of steps, between 5 and 20, are selected for the "Run" state. When configured, the state is changed to "Starting" (2). See "Idle" for details of this process.
2. In the "Starting" state each train is moved along a path to exit the parking lot and enter a large CW figure-eight loop. If the train's assigned path is a small oval or small figure-eight, at the appropriate time the train then switches from a large to a small CW figure-eight path. Trains assigned to a large path follow a large CW figure-eight path until the parking lot is empty. This avoids a train running into back of the parking lot or blocking the exit from the parking lot. (Ok so this can't happen in the simulator. But remember this tool is a prologue to a hardware implementation.) When all trains are out of the "parking lot" all tracks are available and the simulator goes to the "Transition" state (3). See "Starting" for details of this state.
3. In the "Transition" state trains are switched from CW figure-eight paths given in state (2) to the path assigned in the "Stopped" or initialization state. This may be a two-step process depending on the final direction assigned. When all trains are following their assigned path, in the desired direction the simulator advances to "Run" state (4). Step wise details are in "Transition".
4. In the "Run" state each train follows its assigned endless loop until one of three events occur:
- The <ABORT> button is clicked. The simulator goes directly to the "Stopped" state (0) and the Initialization program.
- The <End Run> button is clicked. The simulator goes to the "Return" (5), then "Parking" (6) states and finally returns to the "Stopped" state (0) after all trains are parked..
- If the <Repeat Runs> option was selected and the random number of steps have been completed. As with <End Run> trains are returned to the parking lot. When all trains are parked the simulator changes to the "Idle" state (1) to start another simulator run.
For details of which train goes when see "Run".
5. In the "Return" state each train is moved from their assigned path to a large or small CCW figure-eight depending on their assigned level. Depending on the assigned direction this may be a two-step process. When all trains are following a CCW figure-eight, the state is changed to "Parking" (6). Details of this state can be seen at "Return".
6. In the "Parking" state each train is moved, in order, from the temporary CCW figure-eight path into the right-hand end of the parking lot. If all four trains are in use, the RED train is first moved to a large figure-eight path and then into the parking lot. This avoids congestion in the large figure-eight path. When there are three or fewer trains to be parked, all trains are moved to a large figure-eight and in order moved into the parking lot. When all the trains are parked the simulator does one of two things:
- If the <Repeat Runs> was selected in the beginning and no buttons were pressed in the "Run" state to end the run early, the simulator goes to the "Idle" state (1).
- Otherwise, the <End Run> button was clicked in the "Run" state, and all the trains have been parked, the simulator returns to the "Stopped" state (0) and the "Initialization" screen is displayed.
This process is detailed in the "Parking" section.