private void scheduleEndLegMessage(double time) { // move to first link in next leg and schedule an end leg message vehicle.moveToFirstLinkInNextLeg(); Road road = Road.getRoad(vehicle.getCurrentLinkId()); vehicle.scheduleEndLegMessage(time, road); }
@Override public void handleMessage() { // enter the next road Road road = Road.getRoad(vehicle.getCurrentLinkId()); road.enterRoad(vehicle, getMessageArrivalTime()); }
Road road = Road.getRoad(getCurrentLinkId());
@Override public void processEvent() { Event event = null; // the first EnterLink in a leg is a Wait2LinkEvent if (vehicle.getLinkIndex() == -1) { event = new VehicleEntersTrafficEvent(this.getMessageArrivalTime(), vehicle.getOwnerPerson().getId(), vehicle.getCurrentLinkId(), Id.create(vehicle.getOwnerPerson().getId(), org.matsim.vehicles.Vehicle.class), null, 1.0); } else { event = new LinkEnterEvent(this.getMessageArrivalTime(), Id.create(vehicle.getOwnerPerson().getId(), org.matsim.vehicles.Vehicle.class), vehicle.getCurrentLinkId()); } eventsManager.processEvent(event); }
@Override public void handleMessage() { if (vehicle.isCurrentLegFinished()) { /* * the leg is completed, try to enter the last link but do not enter * it (just wait, until you have clearance for enter and then leave * the road) */ vehicle.initiateEndingLegMode(); vehicle.moveToFirstLinkInNextLeg(); Road road = Road.getRoad(vehicle.getCurrentLinkId()); road.enterRequest(vehicle, getMessageArrivalTime()); } else if (!vehicle.isCurrentLegFinished()) { // if leg is not finished yet vehicle.moveToNextLinkInLeg(); Road nextRoad = Road.getRoad(vehicle.getCurrentLinkId()); nextRoad.enterRequest(vehicle, getMessageArrivalTime()); } }
@Override public void processEvent() { Event event; // schedule ActEndEvent event = new ActivityEndEvent(this.getMessageArrivalTime(), vehicle.getOwnerPerson().getId(), vehicle.getCurrentLinkId(), vehicle .getPreviousActivity().getFacilityId(), vehicle.getPreviousActivity().getType()); eventsManager.processEvent(event); // schedule AgentDepartureEvent event = new PersonDepartureEvent(this.getMessageArrivalTime(), vehicle.getOwnerPerson().getId(), vehicle.getCurrentLinkId(), vehicle.getCurrentLeg().getMode()); eventsManager.processEvent(event); }
@Override public void handleMessage() { // if current leg is in car mode, then enter request in first road if (vehicle.getCurrentLeg().getMode().equals(TransportMode.car)) { // if empty leg, then end leg, else simulate leg if (vehicle.getCurrentLinkRoute().length == 0) { // move to first link in next leg and schedule an end leg // message // duration of leg = 0 (departure and arrival time is the same) scheduleEndLegMessage(getMessageArrivalTime()); } else { // start the new leg Road road = Road.getRoad(vehicle.getCurrentLinkId()); road.enterRequest(vehicle, getMessageArrivalTime()); } } else { scheduleEndLegMessage(getMessageArrivalTime() + vehicle.getCurrentLeg().getTravelTime()); } }
@Override public void processEvent() { Event event = null; // schedule enter link event // only, if car leg and is not empty if (vehicle.getCurrentLeg().getMode().equals(TransportMode.car) && (vehicle.getCurrentLinkRoute()!=null && vehicle.getCurrentLinkRoute().length!=0)){ event = new LinkEnterEvent(this.getMessageArrivalTime(), Id.create(vehicle.getOwnerPerson().getId().toString(), org.matsim.vehicles.Vehicle.class), vehicle.getCurrentLinkId()); eventsManager.processEvent(event); } // schedule VehicleLeavesTrafficEvent Id<org.matsim.vehicles.Vehicle> vehicleId = Id.create( this.vehicle.getOwnerPerson().getId() , org.matsim.vehicles.Vehicle.class ) ; event = new VehicleLeavesTrafficEvent(this.getMessageArrivalTime(), this.vehicle.getOwnerPerson().getId(), this.vehicle.getCurrentLinkId(), vehicleId, this.vehicle.getCurrentLeg().getMode(), 1.0 ); eventsManager.processEvent(event); // schedule AgentArrivalEvent event = new PersonArrivalEvent(this.getMessageArrivalTime(), this.vehicle.getOwnerPerson().getId(), this.vehicle.getCurrentLinkId(), this.vehicle.getCurrentLeg().getMode()); eventsManager.processEvent(event); // schedule ActStartEvent Activity nextAct = this.vehicle.getNextActivity(); double actStartEventTime = nextAct.getStartTime(); if (this.getMessageArrivalTime() > actStartEventTime) { actStartEventTime = this.getMessageArrivalTime(); } event = new ActivityStartEvent(actStartEventTime, this.vehicle.getOwnerPerson().getId(), this.vehicle.getCurrentLinkId(), nextAct.getFacilityId(), nextAct.getType()); eventsManager.processEvent(event); }
Road road = Road.getRoad(this.vehicle.getCurrentLinkId());