Hi there, I want to get some additional information from Matsim using the Event Listeners provided in the integration bdi-matsim, where events like PersonArrivalEvent are handled in the classes EventsMonitorRegistry and ActionHandlerForPerceive. Especially, I want the total distance of a trip (containing all legs driven on from a start to an end position).
What I did so far:
Working with the ees repository, I found out that ees/matsim/EvacAgent.java contains the method notifyMoveOverNode, which processes the legs in the Matsim network. In that method, I added a total counter as follows:
public final void notifyMoveOverNode(Id<Link> newLinkId) {
driverAgentDelegate.notifyMoveOverNode(newLinkId);
Link link = network.getLinks().get(newLinkId);
double now = simTimer.getTimeOfDay();
//added
if(link != null){
totalLinkLengthTraveled += link.getLength();
}
this.expectedLinkLeaveTime = link.getLength()/link.getFreespeed(now);
}
Now I want to extend the Matsim Event PersonArrivalEvent which occurs, when a trip is finished. I want to add totalLinkLengthTraveled to the Event by extending PersonArrivalEvent. Then I want to add params in ActionHandlerForPerceive in the block PerceptList.ARRIVED to Object[] params = {currentLinkId, totalLinkLengthTraveled}:
case PerceptList.ARRIVED:
(...)
if (model.getAgentManager().getAgentsPerformingBdiDriveTo().containsKey(agentID)
&& model.getAgentManager().getAgentsPerformingBdiDriveTo().get(agentID).equals(currentLinkId)) {
model.getAgentManager().getAgentsPerformingBdiDriveTo().remove(agentID);
Object[] params = {currentLinkId};
ActionContent ac = new ActionContent(params, ActionContent.State.PASSED, ActionList.DRIVETO);
model.getAgentManager().getAgentDataContainerV2().putAction(agent.getAgentID(), ActionList.DRIVETO, ac);
}
return false; // do not unregister
}
}
);
break;
Is this the right solution or are there other possibilities to get the total distance driven of a single trip?
Hi there, I want to get some additional information from Matsim using the Event Listeners provided in the integration
bdi-matsim
, where events likePersonArrivalEvent
are handled in the classesEventsMonitorRegistry
andActionHandlerForPerceive
. Especially, I want the total distance of a trip (containing all legs driven on from a start to an end position).What I did so far:
Working with the
ees
repository, I found out thatees/matsim/EvacAgent.java
contains the methodnotifyMoveOverNode
, which processes the legs in the Matsim network. In that method, I added a total counter as follows:Now I want to extend the Matsim Event
PersonArrivalEvent
which occurs, when a trip is finished. I want to addtotalLinkLengthTraveled
to the Event by extendingPersonArrivalEvent
. Then I want to addparams
inActionHandlerForPerceive
in the blockPerceptList.ARRIVED
toObject[] params = {currentLinkId, totalLinkLengthTraveled}
:Is this the right solution or are there other possibilities to get the total distance driven of a single trip?