20 package org.matsim.core.mobsim.qsim.pt;
22 import java.util.List;
23 import java.util.ListIterator;
25 import org.apache.logging.log4j.LogManager;
26 import org.apache.logging.log4j.Logger;
89 accessEgress =
new PassengerAccessEgressImpl(this.internalInterface, agentTracker2, scenario, eventsManager);
95 this.nextStop = (stopIterator.hasNext() ? stopIterator.next() : null);
99 this.nextLinkIndex = 0;
102 final void setDriver(
Person personImpl) {
103 this.dummyPerson = personImpl;
110 if (this.nextLinkIndex < linkIds.size()) {
111 return linkIds.get(this.nextLinkIndex);
113 if (this.nextLinkIndex == linkIds.size()) {
135 int currentLinkIndex = this.nextLinkIndex - 1;
136 if (currentLinkIndex < 0) {
138 }
else if (currentLinkIndex >=
getCarRoute().getLinkIds().size()) {
147 this.nextLinkIndex++;
163 if (this.nextStop == null) {
177 List<TransitRouteStop> stopsToCome = route.
getStops().subList(stopIterator.nextIndex(), route.
getStops().size());
182 double stopTime = this.accessEgress.calculateStopTimeAndTriggerBoarding(
getTransitRoute(),
getTransitLine(), this.vehicle, stop, stopsToCome, now);
187 if (stopTime == 0.0) {
193 final void sendTransitDriverStartsEvent(
final double now) {
197 if (internalInterface != null) {
220 final Person getPerson() {
237 if (this.currentStop == null) {
241 .
or(this.currentStop::getDepartureOffset)
243 log.warn(
"Could not calculate delay!");
259 final double stopTime) {
262 if (now + stopTime < earliestDepTime) {
263 return earliestDepTime - now;
272 .
or(this.currentStop::getArrivalOffset)
274 log.warn(
"Could not calculate delay!");
281 this.nextStop = (stopIterator.hasNext() ? stopIterator.next() : null);
282 if(this.nextStop == null) {
285 this.currentStop = null;
289 if (this.nextStop != null) {
300 log.error(
"Transit vehicle must be empty after last stop! vehicle-id = " + this.vehicle.
getVehicle().
getId(), e);
303 log.error(
"Agent is still in transit vehicle: agent-id = " + ((PersonDriverAgentImpl) agent).getPerson().
getId());
317 return this.dummyPerson.getId() ;
323 abstract Leg getCurrentLeg() ;
339 this.delegate = route;
349 return this.delegate.
getSubRoute(fromLinkId, toLinkId);
364 throw new UnsupportedOperationException(
"read only route.");
369 throw new UnsupportedOperationException(
"read only route.");
374 throw new UnsupportedOperationException(
"read only route.");
379 throw new UnsupportedOperationException(
"read only route.");
384 throw new UnsupportedOperationException(
"read only route.");
389 throw new UnsupportedOperationException(
"read only route.");
426 throw new UnsupportedOperationException(
"read only route.");
431 throw new UnsupportedOperationException(
"read only route.");
436 throw new UnsupportedOperationException(
"read only route.");
443 }
catch (CloneNotSupportedException e) {
444 throw new AssertionError(e);
String getRouteDescription()
void notifyArrivalOnLinkByNonNetworkMode(final Id< Link > linkId)
List< Id< Link > > getLinkIds()
void depart(final double now)
final Id< Link > chooseNextLinkId()
void processEventVehicleArrives(final TransitStopFacility stop, final double now)
Id< Link > getStartLinkId()
NetworkRouteWrapper clone()
ListIterator< TransitRouteStop > stopIterator
void setTravelCost(final double travelCost)
void setVehicleId(final Id< Vehicle > vehicleId)
Id< Link > getEndLinkId()
NetworkRoute getSubRoute(final Id< Link > fromLinkId, final Id< Link > toLinkId)
final MobsimAgent.State getState()
final Id< Link > getCurrentLinkId()
void setEndLinkId(final Id< Link > linkId)
final void setStateToAbort(final double now)
double longerStopTimeIfWeAreAheadOfSchedule(final double now, final double stopTime)
final int getNextLinkIndex()
double getDepartureTime()
TransitRouteStop currentStop
void setDistance(final double distance)
String getRouteDescription()
Collection<? extends PassengerAgent > getPassengers()
abstract void endLegAndComputeNextState(final double now)
final void setVehicle(final MobsimVehicle vehicle)
final TransitVehicle getVehicle()
TransitRouteStop nextStop
NetworkRoute getSubRoute(final Id< Link > fromLinkId, final Id< Link > toLinkId)
static< T > Id< T > create(final long key, final Class< T > type)
void setRouteDescription(String routeDescription)
List< Id< Link > > getLinkIds()
void setTravelTime(final double travelTime)
void processEvent(final Event event)
abstract OptionalTime getArrivalOffset()
List< TransitRouteStop > getStops()
double handleTransitStop(final TransitStopFacility stop, final double now)
OptionalTime getTravelTime()
double orElseGet(DoubleSupplier supplier)
OptionalTime getTravelTime()
abstract Departure getDeparture()
abstract TransitRoute getTransitRoute()
void assertExpectedStop(final TransitStopFacility stop)
final void setNextLinkIndex(int idx)
void setTravelTimeUndefined()
abstract TransitLine getTransitLine()
EventsManager getEventsManager()
Id< Vehicle > getVehicleId()
abstract TransitStopFacility getStopFacility()
abstract double getActivityEndTime()
EventsManager eventsManager
final TransitStopFacility getNextTransitStop()
final void notifyMoveOverNode(Id< Link > nextLinkId)
void setStartLinkId(final Id< Link > linkId)
final PassengerAccessEgressImpl accessEgress
void assertVehicleIsEmpty()
final NetworkRoute delegate
Id< Link > getEndLinkId()
abstract OptionalTime getDepartureOffset()
void assertAllStopsServed()
abstract boolean isAwaitDepartureTime()
final InternalInterface internalInterface
abstract NetworkRoute getCarRoute()
void setLinkIds(final Id< Link > startLinkId, final List< Id< Link >> srcRoute, final Id< Link > endLinkId)
Id< Link > getStartLinkId()
OptionalTime or(OptionalTime optionalTime)