public void handleEvent(final VehicleDepartsAtFacilityEvent event) { List<Tuple<Id, Double>> list = this.positions.get(event.getVehicleId()); if (list == null) { list = new ArrayList<Tuple<Id, Double>>(); this.positions.put(event.getVehicleId(), list); } list.add(new Tuple<Id, Double>(event.getFacilityId(), Double.valueOf(event.getTime()))); }
@Override public void handleEvent(VehicleDepartsAtFacilityEvent event) { Integer num = ptVehicles.get(event.getVehicleId()); if(num!=null) { VehicleOccupancyData vehicleOccupancyData = vehicleOccupancy.get(linesRoutesOfVehicle.get(event.getVehicleId())).get(event.getFacilityId()); if(vehicleOccupancyData!=null) vehicleOccupancyData.addVehicleOccupancy((int) (event.getTime()/timeSlot), num/(double)capacities.get(event.getVehicleId())); } } @Override
@Override public void handleEvent(final VehicleDepartsAtFacilityEvent event) { Id<Vehicle> vehId = event.getVehicleId(); Id<TransitStopFacility> facId = event.getFacilityId(); // -----------------------occupancy-------------------------------- this.vehStops.remove(vehId); int[] occupancyAtStop = this.occupancies.get(facId); if (occupancyAtStop == null) { // no previous departure from this stop, therefore no occupancy // record yet. Create this: occupancyAtStop = new int[this.maxSlotIndex + 1]; this.occupancies.put(facId, occupancyAtStop); } Integer noPassengersInVeh = this.vehPassengers.get(vehId); if (noPassengersInVeh != null) { occupancyAtStop[this.getTimeSlotIndex(event.getTime())] += noPassengersInVeh; this.occupancyRecord.append(event.getTime()); this.occupancyRecord.append("\t"); this.occupancyRecord.append(vehId); this.occupancyRecord.append("\t"); this.occupancyRecord.append(facId); this.occupancyRecord.append("\t"); this.occupancyRecord.append(noPassengersInVeh); this.occupancyRecord.append("\n"); } }
@Override public void handleEvent(VehicleDepartsAtFacilityEvent event) { Id<TransitStopFacility> stopId = event.getFacilityId(); Id<Vehicle> vehId = event.getVehicleId(); this.vehStops.remove(vehId); // -----------------------occupancy-------------------------------- int[] occupancyAtStop = this.occupancies.get(stopId); if (occupancyAtStop == null) { // no previous departure from this stop, therefore no occupancy record yet. Create this: occupancyAtStop = new int[this.maxSlotIndex + 1]; this.occupancies.put(stopId, occupancyAtStop); } Integer noPassengersInVeh = this.vehPassengers.get(vehId); if (noPassengersInVeh != null) { occupancyAtStop[this.getTimeSlotIndex(event.getTime())] += noPassengersInVeh; this.occupancyRecord.append(event.getTime()); this.occupancyRecord.append("\t"); this.occupancyRecord.append(vehId); this.occupancyRecord.append("\t"); this.occupancyRecord.append(stopId); this.occupancyRecord.append("\t"); this.occupancyRecord.append(noPassengersInVeh); this.occupancyRecord.append("\n"); } }
@Override public void handleEvent(final VehicleDepartsAtFacilityEvent event) { double time = event.getTime(); Id vehId = event.getVehicleId(); Id facId = event.getFacilityId(); if (this.personsFromVehId.get(vehId) == null) { // (means nobody has entered the vehicle yet) return; } TransitStopFacility fac = this.schedule.getFacilities().get(facId); for (Id personId : this.personsFromVehId.get(vehId)) { // get the "Person" behind the id: Person person = this.sc.getPopulation().getPersons().get(personId); // get the selected plan: Plan selectedPlan = person.getSelectedPlan(); // get the planStepFactory for the plan (or create one): PlanBuilder<TransitStopFacility> tmpPlanStepFactory = getPlanStepFactoryForPlan(selectedPlan); if (tmpPlanStepFactory != null) { // add the "turn" to the planStepfactory tmpPlanStepFactory.addTurn(fac, (int) time); } } }
public void testWriteReadXml() { VehicleDepartsAtFacilityEvent event = new VehicleDepartsAtFacilityEvent(Time.parseTime("10:55:00"), Id.create(5, Vehicle.class), Id.create(11, TransitStopFacility.class), -1.2); VehicleDepartsAtFacilityEvent event2 = XmlEventsTester.testWriteReadXml(getOutputDirectory() + "events.xml", event); assertEquals(Time.parseTime("10:55:00"), event2.getTime(), EPSILON); assertEquals(Id.create(5, Vehicle.class), event2.getVehicleId()); assertEquals(Id.create(11, TransitStopFacility.class), event2.getFacilityId()); assertEquals(Double.valueOf(-1.2), Double.valueOf(event2.getDelay())); } }