@Override public void handleEvent(PersonArrivalEvent event) { Id personId = event.getPersonId(); PersonDriverAgentImpl agent = this.agents.get(personId); Plan executedPlan = agent.getCurrentPlan(); int planElementIndex = ParallelSafePlanElementAccessLib.getCurrentExpectedLegIndex(agent); if (agentDoesNotDriveCarDuringWholeDay(personId)) { return; } if (!isPlanElementDuringDay(personId, planElementIndex)) { return; } if (firstParkingWalkTmp.get(personId) == null) { DebugLib.emptyFunctionForSettingBreakPoint(); } double durationFirstWalk = 0; double durationSecondWalk = 0; // same start and end time causes wrong interval calculation (3600*24 seconds, instead of zero). if (firstParkingWalkTmp.get(personId) != null && firstParkingWalkTmp.get(personId) != event.getTime()) { durationFirstWalk = GeneralLib.getIntervalDuration(firstParkingWalkTmp.get(personId), event.getTime()); } if (secondParkingWalkTmp.get(personId) != null && secondParkingWalkTmp.get(personId) != event.getTime()) { durationSecondWalk = GeneralLib.getIntervalDuration(secondParkingWalkTmp.get(personId), event.getTime()); } updateWalkTimeTmpVariables( event.getLegMode(), personId, executedPlan, planElementIndex, durationFirstWalk, durationSecondWalk); }
@Override public void handleEvent(PersonDepartureEvent event) { Id personId = event.getPersonId(); PersonDriverAgentImpl agent = this.agents.get(personId); Plan executedPlan = agent.getCurrentPlan(); int planElementIndex = ParallelSafePlanElementAccessLib.getCurrentExpectedLegIndex(agent); double startTimeWalkLeg = event.getTime(); if (agentDoesNotDriveCarDuringWholeDay(personId)) { return; } updateWalkTimeTmpVariables( event.getLegMode(), personId, executedPlan, planElementIndex, startTimeWalkLeg, startTimeWalkLeg); }
public CaptureParkingWalkTimesDuringDay( Map<Id, PersonDriverAgentImpl> agents, Map<Id, Integer> firstParkingActivityPlanElemIndex, Map<Id, Integer> lastParkingActivityPlanElemIndex) { this.firstParkingActivityPlanElemIndex = firstParkingActivityPlanElemIndex; this.lastParkingActivityPlanElemIndex = lastParkingActivityPlanElemIndex; this.agents = agents; for (PersonDriverAgentImpl agent : agents.values()) { Id personId = agent.getCurrentPlan().getPerson().getId(); for (PlanElement pe : agent.getCurrentPlan().getPlanElements()) { if (pe instanceof Leg) { Leg leg = (Leg) pe; if (leg.getMode().equals(TransportMode.car)) { firstParkingWalkTmp.put(personId, 0.0); secondParkingWalkTmp.put(personId, 0.0); break; } } } } }