Commit 418e119c authored by Benedikt Kleinmeier's avatar Benedikt Kleinmeier

Extended "BangEvent" to hold a "Target" and use this new information in...

Extended "BangEvent" to hold a "Target" and use this new information in "UpdateSchemeEventDriven" and "UpdateSchemeSequential".
parent 3856b1f8
Pipeline #92611 failed with stages
in 3 minutes and 30 seconds
......@@ -163,6 +163,23 @@
"deletionDistance" : 0.1,
"startingWithRedLight" : false,
"nextSpeed" : -1.0
}, {
"id" : 0,
"absorbing" : true,
"shape" : {
"x" : 18.3,
"y" : 6.8,
"width" : 2.9,
"height" : 1.5,
"type" : "RECTANGLE"
},
"waitingTime" : 0.0,
"waitingTimeYellowPhase" : 0.0,
"parallelWaiters" : 0,
"individualWaiting" : true,
"deletionDistance" : 0.1,
"startingWithRedLight" : false,
"nextSpeed" : -1.0
} ],
"absorbingAreas" : [ ],
"sources" : [ {
......@@ -221,14 +238,15 @@
},
"eventInfos" : [ {
"eventTimeframe" : {
"startTime" : 18.0,
"endTime" : 18.4,
"startTime" : 15.0,
"endTime" : 15.4,
"repeat" : false,
"waitTimeBetweenRepetition" : 0.0
},
"events" : [ {
"type" : "BangEvent",
"targets" : [ ]
"targets" : [ ],
"originAsTargetId" : 0
} ]
} ]
}
......
......@@ -6,10 +6,12 @@ import org.vadere.simulator.models.potential.combinedPotentials.CombinedPotentia
import org.vadere.simulator.models.potential.combinedPotentials.TargetDistractionStrategy;
import org.vadere.state.events.types.*;
import org.vadere.state.scenario.Pedestrian;
import org.vadere.state.scenario.Target;
import org.vadere.state.scenario.Topography;
import org.vadere.util.geometry.shapes.VPoint;
import java.util.Comparator;
import java.util.LinkedList;
import java.util.PriorityQueue;
/**
......@@ -65,6 +67,13 @@ public class UpdateSchemeEventDriven implements UpdateSchemeOSM {
// Watch out: For testing purposes, a bang event changes only
// the "CombinedPotentialStrategy". The agent does not move here!
// Therefore, trigger only a single bang event and then use "ElapsedTimeEvent"
BangEvent bangEvent = (BangEvent) mostImportantEvent;
Target bangOrigin = topography.getTarget(bangEvent.getOriginAsTargetId());
LinkedList<Integer> nextTarget = new LinkedList<>();
nextTarget.add(bangOrigin.getId());
pedestrian.setTargets(nextTarget);
pedestrian.setCombinedPotentialStrategy(CombinedPotentialStrategy.TARGET_DISTRACTION_STRATEGY);
}
}
......
......@@ -5,10 +5,13 @@ import org.vadere.simulator.models.osm.PedestrianOSM;
import org.vadere.simulator.models.potential.combinedPotentials.CombinedPotentialStrategy;
import org.vadere.state.events.types.*;
import org.vadere.state.scenario.Pedestrian;
import org.vadere.state.scenario.Target;
import org.vadere.state.scenario.Topography;
import org.vadere.util.geometry.shapes.VPoint;
import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
public class UpdateSchemeSequential implements UpdateSchemeOSM {
......@@ -50,6 +53,13 @@ public class UpdateSchemeSequential implements UpdateSchemeOSM {
// Watch out: For testing purposes, a bang event changes only
// the "CombinedPotentialStrategy". The agent does not move here!
// Therefore, trigger only a single bang event and then use "ElapsedTimeEvent"
BangEvent bangEvent = (BangEvent) mostImportantEvent;
Target bangOrigin = topography.getTarget(bangEvent.getOriginAsTargetId());
LinkedList<Integer> nextTarget = new LinkedList<>();
nextTarget.add(bangOrigin.getId());
pedestrian.setTargets(nextTarget);
pedestrian.setCombinedPotentialStrategy(CombinedPotentialStrategy.TARGET_DISTRACTION_STRATEGY);
}
}
......
......@@ -6,9 +6,14 @@ import java.util.List;
/**
* Class signals agents a bang - for instance something exploded.
*
* This event holds one additional information: a target id
* which represents the origin of the bang.
*/
public class BangEvent extends Event {
private int originAsTargetId = -1;
// Default constructor required for JSON de-/serialization.
public BangEvent() { super(); }
......@@ -20,4 +25,14 @@ public class BangEvent extends Event {
super(time, targets);
}
public BangEvent(double time, List<ScenarioElement> targets, int originAsTargetId) {
super(time, targets);
this.originAsTargetId = originAsTargetId;
}
public int getOriginAsTargetId() { return originAsTargetId; }
public void setOriginAsTargetId(int originAsTargetId) { this.originAsTargetId = originAsTargetId; }
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment