/** * This method moves transit vehicles from the stop queue directly to the front of the * "queue" of the QLink. An advantage is that this will observe flow * capacity restrictions. */ void handleTransitVehiclesInStopQueue(final double now) { QVehicle veh; // handle transit traffic in stop queue List<QVehicle> departingTransitVehicles = null; while ((veh = transitVehicleStopQueue.peek()) != null) { // there is a transit vehicle. if (veh.getEarliestLinkExitTime() > now) { break; } if (departingTransitVehicles == null) { departingTransitVehicles = new LinkedList<>(); } departingTransitVehicles.add(transitVehicleStopQueue.poll()); } if (departingTransitVehicles != null) { // add all departing transit vehicles at the front of the vehQueue ListIterator<QVehicle> iter = departingTransitVehicles.listIterator(departingTransitVehicles.size()); while (iter.hasPrevious()) { this.road.addTransitSlightlyUpstreamOfStop(iter.previous()) ; } } }
/** * Move as many waiting cars to the link as it is possible */ private void moveWaitToRoad() { while (!getWaitingList().isEmpty()) { if (!qlane.isAcceptingFromWait(this.getWaitingList().peek())) { return; } QVehicle veh = this.getWaitingList().poll(); double now = context.getSimTimer().getTimeOfDay() ; context.getEventsManager().processEvent( new VehicleEntersTrafficEvent(now, veh.getDriver().getId(), this.getLink().getId(), veh.getId(), veh.getDriver().getMode(), 1.0)); if ( this.getTransitQLink().addTransitToStopQueue(now, veh, this.getLink().getId()) ) { continue ; } if ( veh.getDriver().isWantingToArriveOnCurrentLink() ) { // If the driver wants to stop (again) on this link, give them a special treatment. // addFromWait doesn't work here, because after that, they cannot stop anymore. qlane.addTransitSlightlyUpstreamOfStop(veh) ; continue; } qlane.addFromWait(veh); } }
this.firstLaneQueue.addTransitSlightlyUpstreamOfStop(veh); continue;