@Override public Collection<MobsimVehicle> getAllNonParkedVehicles(){ Collection<MobsimVehicle> vehicles = new ArrayList<>(); vehicles.addAll(this.getTransitQLink().getTransitVehicleStopQueue()); vehicles.addAll(this.getWaitingList()); vehicles.addAll( qlane.getAllVehicles() ) ; return vehicles; }
private boolean checkForActivity() { /* * Leave Link active as long as there are vehicles on the link (ignore * buffer because the buffer gets emptied by nodes and not links) and leave * link active until buffercap has accumulated (so a newly arriving vehicle * is not delayed). */ return qlane.isActive() || !this.getWaitingList().isEmpty() || !this.getTransitQLink().getTransitVehicleStopQueue().isEmpty() ; }
@Override public boolean doSimStep() { double now = context.getSimTimer().getTimeOfDay() ; qlane.initBeforeSimStep(); if ( context.qsimConfig.isInsertingWaitingVehiclesBeforeDrivingVehicles() ) { this.moveWaitToRoad(); this.getTransitQLink().handleTransitVehiclesInStopQueue(now); qlane.doSimStep(); } else { this.getTransitQLink().handleTransitVehiclesInStopQueue(now); qlane.doSimStep(); this.moveWaitToRoad(); } this.setActive(this.checkForActivity()); return isActive(); // yy seems to me that for symmetry there should be something like // netElementActivationRegistry.registerLinkAsActive(this); // and may be a qlink.deactivateLink(...) around it (analogous to qlink.activateLink). // That is, do NOT pass the deactivation of the link rather implicitly via returning a false here. // kai, mar'16 }
/** * 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); } }
@Override public Collection<AgentSnapshotInfo> addAgentSnapshotInfo( Collection<AgentSnapshotInfo> positions) { // AbstractAgentSnapshotInfoBuilder snapshotInfoBuilder = qnetwork.simEngine.getAgentSnapshotInfoBuilder(); QLaneI.VisData roadVisData = getAcceptingQLane().getVisData() ; if (visLink != null) { ((QueueWithBuffer.VisDataImpl)roadVisData).setVisInfo(visLink.getLinkStartCoord(), visLink.getLinkEndCoord()) ; // yyyy not so great but an elegant solution needs more thinking about visualizer structure. kai, jun'13 } double now = context.getSimTimer().getTimeOfDay() ; positions = roadVisData.addAgentSnapshotInfo(positions,now) ; int cnt2 = 10 ; // a counter according to which non-moving items can be "spread out" in the visualization // initialize a bit away from the lane // treat vehicles from transit stops cnt2 = context.snapshotInfoBuilder.positionVehiclesFromTransitStop(positions, getLink(), getTransitQLink().getTransitVehicleStopQueue(), cnt2 ); // treat vehicles from waiting list: cnt2 = context.snapshotInfoBuilder.positionVehiclesFromWaitingList(positions, QLinkImpl.this.getLink(), cnt2, QLinkImpl.this.getWaitingList()); cnt2 = context.snapshotInfoBuilder.positionAgentsInActivities(positions, QLinkImpl.this.getLink(), QLinkImpl.this.getAdditionalAgentsOnLink(), cnt2); return positions; }