public override void Execute(State state, FastPriorityQueue <Event> eventQueue) { // Clear switch (no lane cleared if coming from depot) SwitchLane lane = fromDepot ? SwitchLane.None : Switch.ArrivalLaneFor(platform); eventQueue.Enqueue(new ClearSwitchLane(station, lane), state.time + Config.c.switchClearanceTime); // Log System.Diagnostics.Debug.WriteLine($"ArrivalEndstation: tram {tram.id}, station: {station.name}, {platform}, {lane}, time: {state.time}"); // Check if tram can do another round trip if it is at endstation with depot if (!station.TramToDepot(state.time)) { // Board and unboard (int pOut, int pIn, List <int> e) = station.UnboardAndBoard(tram, tram.passengerCount); entrances = e; // Calculate when to schedule departure // If boarding/unboarding takes shorter than the turnaround, take the turnaround time int passengerTransferTime = state.time + Math.Max(Sampling.passengerExchangeTime(pOut, pIn), Config.c.turnAroundTimeFor(station)); int nextDepartureTime = station.NextDeparture(); int nextEventTime = Math.Max(passengerTransferTime, nextDepartureTime); // Queue event eventQueue.Enqueue(new ExpectedDepartureStartstation(tram, station, platform, nextDepartureTime), nextEventTime); } // Transfer tram to depot else { station.Free(platform); } }
public override void Execute(State state, FastPriorityQueue <Event> eventQueue) { // Free the platform station.Free(platform); // Reset ready for departure tram.ResetReadyForDeparture(); // Claim lane SwitchLane lane = Switch.ExitLaneFor(platform); System.Diagnostics.Debug.WriteLine($"DepartureStartstation: tram {tram.id}, station: {station.name}, {platform}, {lane}, time: {state.time}"); // Clear the lane it's leaving over in 60s eventQueue.Enqueue(new ClearSwitchLane(station, lane), state.time + Config.c.switchClearanceTime); // Queue next arrival int stationIndex = state.stations.IndexOf(station); int newStationIndex = stationIndex + 1; // Make sure trams do not take over each other int drivingTime = Sampling.drivingTime(Config.c.transferTimes[stationIndex].averageTime); int arrivalTime = station.SignalNextArrival(state.time + drivingTime); eventQueue.Enqueue(new ExpectedTramArrival(tram, newStationIndex), arrivalTime); }