The initRoadPDP(..)
method is called during the initialisation phase of MyDepot
. This happens at the time the Depot
is added to the simulator, which, for depots, is typically before simulation time has started.
The standard way to get notified of time progress is to implement the TickListener interface. Besides keeping track of time, this interface allows you to use the received TimeLapse
object to perform actions that cost time. However, since the first tick received will always be after any call to initRoadPDP
this method may not be suitable for this case.
In any case, the code for using the TickListener
looks like this:
class MyDepot extends Depot implements TickListener {
public MyDepot(Point position) {
super(position);
}
@Override
public void initRoadPDP(RoadModel pRoadModel, PDPModel pPdpModel) {
// how to know the current time?
}
@Override
public void tick(TimeLapse timeLapse) {
timeLapse.getTime(); // current time
}
@Override
public void afterTick(TimeLapse timeLapse) {}
}