Commit 4644867d authored by Stefan Schuhbaeck's avatar Stefan Schuhbaeck
Browse files

Add ScenarioChecker for processors with MeasurementAreas

The ProcessorFlag interface is a marker interface used anywehre a
specifc attribute of some DataProcessors are needed. For instnace
the UsesMeasurementArea Interface is implemented by all Processors
usinge one or more MeasurementAreas. In this example the interface
exposes an array of given MeasurementAreaIds which can be used
within the ScenarioChecker.

These interfaces are therefore aribtraty flags used to filter a
generic list of DataProcesors if needed.
parent 42ce721a
Pipeline #102178 failed with stages
in 96 minutes and 34 seconds
...@@ -25,4 +25,6 @@ public @interface DataProcessorClass { ...@@ -25,4 +25,6 @@ public @interface DataProcessorClass {
String label() default ""; String label() default "";
String description() default ""; String description() default "";
String[] processorFlags() default {};
} }
...@@ -5,6 +5,8 @@ import com.google.auto.service.AutoService; ...@@ -5,6 +5,8 @@ import com.google.auto.service.AutoService;
import org.vadere.annotation.factories.BaseFactoryProcessor; import org.vadere.annotation.factories.BaseFactoryProcessor;
import java.io.PrintWriter; import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Set; import java.util.Set;
import javax.annotation.processing.Processor; import javax.annotation.processing.Processor;
...@@ -12,6 +14,10 @@ import javax.annotation.processing.SupportedAnnotationTypes; ...@@ -12,6 +14,10 @@ import javax.annotation.processing.SupportedAnnotationTypes;
import javax.annotation.processing.SupportedSourceVersion; import javax.annotation.processing.SupportedSourceVersion;
import javax.lang.model.SourceVersion; import javax.lang.model.SourceVersion;
import javax.lang.model.element.Element; import javax.lang.model.element.Element;
import javax.lang.model.element.TypeElement;
import javax.lang.model.type.TypeMirror;
import javax.lang.model.util.Elements;
import javax.lang.model.util.Types;
@SupportedAnnotationTypes("org.vadere.annotation.factories.dataprocessors.DataProcessorClass") @SupportedAnnotationTypes("org.vadere.annotation.factories.dataprocessors.DataProcessorClass")
@SupportedSourceVersion(SourceVersion.RELEASE_11) @SupportedSourceVersion(SourceVersion.RELEASE_11)
...@@ -32,10 +38,23 @@ public class DataProcessorFactoryProcessor extends BaseFactoryProcessor { ...@@ -32,10 +38,23 @@ public class DataProcessorFactoryProcessor extends BaseFactoryProcessor {
protected void addLastConstructor(Set<? extends Element> elements, PrintWriter writer) { protected void addLastConstructor(Set<? extends Element> elements, PrintWriter writer) {
for (Element e : elements) { for (Element e : elements) {
writer.append(" addMember("); writer.append(" addMember(");
writer.append(e.getSimpleName().toString()).append(".class, ");
writer.append("this::").append("get").append(name(e)).append(", "); writer.append("this::").append("get").append(name(e)).append(", ");
writer.append(quote(label(e))).append(", "); writer.append(quote(label(e))).append(", ");
writer.append(quote(descr(e))).println("); "); writer.append(quote(descr(e))).append(", ");
writer.append(e.getSimpleName().toString()).append(".class");
//if flags are provides here...
String[] flags = processorFlags(e);
if (flags.length > 0){
writer.append(", ");
for (int i = 0; i < flags.length -1; i++) {
writer.append(quote(flags[i])).append(", ");
}
writer.append(quote(flags[flags.length-1]));
writer.println("); ");
} else {
writer.println("); ");
}
} }
} }
...@@ -76,4 +95,29 @@ public class DataProcessorFactoryProcessor extends BaseFactoryProcessor { ...@@ -76,4 +95,29 @@ public class DataProcessorFactoryProcessor extends BaseFactoryProcessor {
return dataProcessorClass.description(); return dataProcessorClass.description();
} }
private String[] processorFlags(Element element){
DataProcessorClass dataProcessorClass = element.getAnnotation(DataProcessorClass.class);
Elements elementUtil = processingEnv.getElementUtils();
Types typeUtil = processingEnv.getTypeUtils();
ArrayList<String> flags = new ArrayList<>();
TypeMirror processorFlag = elementUtil
.getTypeElement("org.vadere.simulator.projects.dataprocessing.flags.ProcessorFlag")
.asType();
// cast possible becuse element is a class
TypeElement e = (TypeElement)element;
for (TypeMirror anInterface : e.getInterfaces()) {
if (typeUtil.isAssignable(anInterface, processorFlag)){
flags.add(typeUtil.asElement(anInterface).getSimpleName().toString());
}
}
flags.addAll(Arrays.asList(dataProcessorClass.processorFlags()));
return flags.toArray(String[]::new);
}
} }
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
"name" : "group_OSM_1Source2Places_noGroups", "name" : "group_OSM_1Source2Places_noGroups",
"description" : "", "description" : "",
"release" : "0.8", "release" : "0.8",
`` "processWriters" : { "processWriters" : {
"files" : [ { "files" : [ {
"type" : "org.vadere.simulator.projects.dataprocessing.outputfile.TimestepPedestrianIdOutputFile", "type" : "org.vadere.simulator.projects.dataprocessing.outputfile.TimestepPedestrianIdOutputFile",
"filename" : "postvis.trajectories", "filename" : "postvis.trajectories",
...@@ -240,4 +240,4 @@ ...@@ -240,4 +240,4 @@
}, },
"eventInfos" : [ ] "eventInfos" : [ ]
} }
} }
\ No newline at end of file
...@@ -39,6 +39,8 @@ ScenarioChecker.overlap.obstacle.obstacle=Two obstacles overlap / is enclosed co ...@@ -39,6 +39,8 @@ ScenarioChecker.overlap.obstacle.obstacle=Two obstacles overlap / is enclosed co
ScenarioChecker.simAttr.simTimeStepWrong=simTimeStep parameter outside of allowed range ScenarioChecker.simAttr.simTimeStepWrong=simTimeStep parameter outside of allowed range
ScenarioChecker.processor.measuremetarea.doesNotExist=MeasurementArea referenced in processor does not exist.
ScenarioChecker.msg.ok=Scenario ok. ScenarioChecker.msg.ok=Scenario ok.
ScenarioChecker.msg.warn=Scenario contains warnings. ScenarioChecker.msg.warn=Scenario contains warnings.
ScenarioChecker.msg.err=Scenario contains errors. ScenarioChecker.msg.err=Scenario contains errors.
...@@ -39,6 +39,8 @@ ScenarioChecker.overlap.obstacle.obstacle=Zwei identische bzw. eingeschlossene H ...@@ -39,6 +39,8 @@ ScenarioChecker.overlap.obstacle.obstacle=Zwei identische bzw. eingeschlossene H
ScenarioChecker.simAttr.simTimeStepWrong=simTimeStep Parameter au\u00dferhalb des Definitionsbereichs ScenarioChecker.simAttr.simTimeStepWrong=simTimeStep Parameter au\u00dferhalb des Definitionsbereichs
ScenarioChecker.processor.measuremetarea.doesNotExist=Referenzierte Messfläche im Daten Prozessor existiert nicht.
ScenarioChecker.msg.ok=Szenario ok. ScenarioChecker.msg.ok=Szenario ok.
ScenarioChecker.msg.warn=Szenario hat Warnungen. ScenarioChecker.msg.warn=Szenario hat Warnungen.
ScenarioChecker.msg.err=Szenario ist Fehlerhaft. ScenarioChecker.msg.err=Szenario ist Fehlerhaft.
package org.vadere.simulator.projects.dataprocessing.flags;
/**
* Marker interface to identify a {@link org.vadere.simulator.projects.dataprocessing.processor.DataProcessor}
* based on some arbitrary property. These Interfaces are useful to filter processors of a
* scenario to check if the settings of the processor are correct.
*/
public interface ProcessorFlag {
}
package org.vadere.simulator.projects.dataprocessing.flags;
/**
* Return all id's referencing a {@link org.vadere.state.scenario.MeasurementArea}. These
* are used to check if the specified {@link org.vadere.state.scenario.MeasurementArea}
* exist in the simulation.
*/
public interface UsesMeasurementArea extends ProcessorFlag {
int[] getReferencedMeasurementAreaId();
}
package org.vadere.simulator.projects.dataprocessing.processor; package org.vadere.simulator.projects.dataprocessing.processor;
import org.vadere.simulator.projects.dataprocessing.ProcessorManager; import org.vadere.simulator.projects.dataprocessing.ProcessorManager;
import org.vadere.simulator.projects.dataprocessing.flags.UsesMeasurementArea;
import org.vadere.state.attributes.processor.AttributesAreaDensityVoronoiProcessor; import org.vadere.state.attributes.processor.AttributesAreaDensityVoronoiProcessor;
import org.vadere.state.attributes.processor.AttributesProcessor; import org.vadere.state.attributes.processor.AttributesProcessor;
import org.vadere.annotation.factories.dataprocessors.DataProcessorClass; import org.vadere.annotation.factories.dataprocessors.DataProcessorClass;
import org.vadere.state.scenario.MeasurementArea; import org.vadere.state.scenario.MeasurementArea;
import org.vadere.util.factory.processors.Flag;
import java.util.List;
/** /**
* @author Mario Teixeira Parente * @author Mario Teixeira Parente
* *
*/ */
@DataProcessorClass(label = "AreaDensityVoronoiProcessor") @DataProcessorClass(label = "AreaDensityVoronoiProcessor")
public class AreaDensityVoronoiProcessor extends AreaDensityProcessor { public class AreaDensityVoronoiProcessor extends AreaDensityProcessor implements UsesMeasurementArea {
public AreaDensityVoronoiProcessor(){ public AreaDensityVoronoiProcessor(){
super(); super();
...@@ -41,4 +45,11 @@ public class AreaDensityVoronoiProcessor extends AreaDensityProcessor { ...@@ -41,4 +45,11 @@ public class AreaDensityVoronoiProcessor extends AreaDensityProcessor {
return super.getAttributes(); return super.getAttributes();
} }
@Override
public int[] getReferencedMeasurementAreaId() {
AttributesAreaDensityVoronoiProcessor att = (AttributesAreaDensityVoronoiProcessor) this.getAttributes();
return new int[]{att.getMeasurementAreaId(), att.getMeasurementAreaId()};
}
} }
...@@ -53,6 +53,7 @@ public abstract class DataProcessor<K extends DataKey<K>, V> { ...@@ -53,6 +53,7 @@ public abstract class DataProcessor<K extends DataKey<K>, V> {
this.lastStep = 0; this.lastStep = 0;
} }
protected Map<K, V> getData() { protected Map<K, V> getData() {
return this.data; return this.data;
} }
......
...@@ -6,14 +6,17 @@ import org.vadere.annotation.factories.dataprocessors.DataProcessorClass; ...@@ -6,14 +6,17 @@ import org.vadere.annotation.factories.dataprocessors.DataProcessorClass;
import org.vadere.simulator.control.SimulationState; import org.vadere.simulator.control.SimulationState;
import org.vadere.simulator.projects.dataprocessing.ProcessorManager; import org.vadere.simulator.projects.dataprocessing.ProcessorManager;
import org.vadere.simulator.projects.dataprocessing.datakey.PedestrianIdKey; import org.vadere.simulator.projects.dataprocessing.datakey.PedestrianIdKey;
import org.vadere.simulator.projects.dataprocessing.flags.UsesMeasurementArea;
import org.vadere.state.attributes.processor.AttributesFundamentalDiagramBProcessor; import org.vadere.state.attributes.processor.AttributesFundamentalDiagramBProcessor;
import org.vadere.state.attributes.processor.AttributesProcessor; import org.vadere.state.attributes.processor.AttributesProcessor;
import org.vadere.state.scenario.MeasurementArea; import org.vadere.state.scenario.MeasurementArea;
import org.vadere.state.scenario.Topography; import org.vadere.state.scenario.Topography;
import org.vadere.state.simulation.VTrajectory; import org.vadere.state.simulation.VTrajectory;
import org.vadere.util.factory.processors.Flag;
import org.vadere.util.logging.Logger; import org.vadere.util.logging.Logger;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
/** /**
...@@ -32,7 +35,7 @@ import java.util.Map; ...@@ -32,7 +35,7 @@ import java.util.Map;
* @author Benedikt Zoennchen * @author Benedikt Zoennchen
*/ */
@DataProcessorClass() @DataProcessorClass()
public class FundamentalDiagramBProcessor extends DataProcessor<PedestrianIdKey, Pair<Double, Double>> { public class FundamentalDiagramBProcessor extends DataProcessor<PedestrianIdKey, Pair<Double, Double>> implements UsesMeasurementArea {
private static Logger logger = Logger.getLogger(Topography.class); private static Logger logger = Logger.getLogger(Topography.class);
...@@ -167,4 +170,11 @@ public class FundamentalDiagramBProcessor extends DataProcessor<PedestrianIdKey, ...@@ -167,4 +170,11 @@ public class FundamentalDiagramBProcessor extends DataProcessor<PedestrianIdKey,
public String[] toStrings(@NotNull final PedestrianIdKey key) { public String[] toStrings(@NotNull final PedestrianIdKey key) {
return new String[]{ Double.toString(getValue(key).getLeft()), Double.toString(getValue(key).getRight()) }; return new String[]{ Double.toString(getValue(key).getLeft()), Double.toString(getValue(key).getRight()) };
} }
@Override
public int[] getReferencedMeasurementAreaId() {
AttributesFundamentalDiagramBProcessor att = (AttributesFundamentalDiagramBProcessor) this.getAttributes();
return new int[]{att.getMeasurementAreaId()};
}
} }
...@@ -7,10 +7,13 @@ import org.vadere.simulator.control.SimulationState; ...@@ -7,10 +7,13 @@ import org.vadere.simulator.control.SimulationState;
import org.vadere.simulator.projects.dataprocessing.ProcessorManager; import org.vadere.simulator.projects.dataprocessing.ProcessorManager;
import org.vadere.simulator.projects.dataprocessing.datakey.TimestepKey; import org.vadere.simulator.projects.dataprocessing.datakey.TimestepKey;
import org.vadere.simulator.projects.dataprocessing.datakey.TimestepPedestrianIdKey; import org.vadere.simulator.projects.dataprocessing.datakey.TimestepPedestrianIdKey;
import org.vadere.simulator.projects.dataprocessing.flags.UsesMeasurementArea;
import org.vadere.state.attributes.processor.AttributesFundamentalDiagramCProcessor; import org.vadere.state.attributes.processor.AttributesFundamentalDiagramCProcessor;
import org.vadere.state.attributes.processor.AttributesProcessor; import org.vadere.state.attributes.processor.AttributesProcessor;
import org.vadere.state.scenario.MeasurementArea; import org.vadere.state.scenario.MeasurementArea;
import org.vadere.util.geometry.shapes.VRectangle; import org.vadere.util.factory.processors.Flag;
import java.util.List;
/** /**
* <p>This processor computes the fundamental diagram by computing at a certain time the * <p>This processor computes the fundamental diagram by computing at a certain time the
...@@ -24,7 +27,7 @@ import org.vadere.util.geometry.shapes.VRectangle; ...@@ -24,7 +27,7 @@ import org.vadere.util.geometry.shapes.VRectangle;
* @author Benedikt Zoennchen * @author Benedikt Zoennchen
*/ */
@DataProcessorClass() @DataProcessorClass()
public class FundamentalDiagramCProcessor extends AreaDataProcessor<Pair<Double, Double>> { public class FundamentalDiagramCProcessor extends AreaDataProcessor<Pair<Double, Double>> implements UsesMeasurementArea {
private MeasurementArea measurementArea; private MeasurementArea measurementArea;
...@@ -91,4 +94,10 @@ public class FundamentalDiagramCProcessor extends AreaDataProcessor<Pair<Double, ...@@ -91,4 +94,10 @@ public class FundamentalDiagramCProcessor extends AreaDataProcessor<Pair<Double,
public String[] toStrings(@NotNull final TimestepKey key) { public String[] toStrings(@NotNull final TimestepKey key) {
return new String[]{ Double.toString(getValue(key).getLeft()), Double.toString(getValue(key).getRight()) }; return new String[]{ Double.toString(getValue(key).getLeft()), Double.toString(getValue(key).getRight()) };
} }
@Override
public int[] getReferencedMeasurementAreaId() {
AttributesFundamentalDiagramCProcessor att = (AttributesFundamentalDiagramCProcessor) this.getAttributes();
return new int[]{att.getMeasurementAreaId()};
}
} }
...@@ -6,10 +6,13 @@ import org.vadere.annotation.factories.dataprocessors.DataProcessorClass; ...@@ -6,10 +6,13 @@ import org.vadere.annotation.factories.dataprocessors.DataProcessorClass;
import org.vadere.simulator.control.SimulationState; import org.vadere.simulator.control.SimulationState;
import org.vadere.simulator.projects.dataprocessing.ProcessorManager; import org.vadere.simulator.projects.dataprocessing.ProcessorManager;
import org.vadere.simulator.projects.dataprocessing.datakey.TimestepKey; import org.vadere.simulator.projects.dataprocessing.datakey.TimestepKey;
import org.vadere.simulator.projects.dataprocessing.flags.UsesMeasurementArea;
import org.vadere.state.attributes.processor.AttributesFundamentalDiagramDProcessor; import org.vadere.state.attributes.processor.AttributesFundamentalDiagramDProcessor;
import org.vadere.state.attributes.processor.AttributesProcessor; import org.vadere.state.attributes.processor.AttributesProcessor;
import org.vadere.state.scenario.MeasurementArea; import org.vadere.state.scenario.MeasurementArea;
import org.vadere.util.geometry.shapes.VRectangle; import org.vadere.util.factory.processors.Flag;
import java.util.List;
/** /**
* <p>This processor computes the fundamental diagram by computing at a certain time the * <p>This processor computes the fundamental diagram by computing at a certain time the
...@@ -25,7 +28,7 @@ import org.vadere.util.geometry.shapes.VRectangle; ...@@ -25,7 +28,7 @@ import org.vadere.util.geometry.shapes.VRectangle;
* @author Benedikt Zoennchen * @author Benedikt Zoennchen
*/ */
@DataProcessorClass() @DataProcessorClass()
public class FundamentalDiagramDProcessor extends AreaDataProcessor<Pair<Double, Double>> { public class FundamentalDiagramDProcessor extends AreaDataProcessor<Pair<Double, Double>> implements UsesMeasurementArea {
private IntegralVoronoiAlgorithm integralVoronoiAlgorithm; private IntegralVoronoiAlgorithm integralVoronoiAlgorithm;
private APedestrianVelocityProcessor pedestrianVelocityProcessor; private APedestrianVelocityProcessor pedestrianVelocityProcessor;
...@@ -76,4 +79,11 @@ public class FundamentalDiagramDProcessor extends AreaDataProcessor<Pair<Double, ...@@ -76,4 +79,11 @@ public class FundamentalDiagramDProcessor extends AreaDataProcessor<Pair<Double,
public String[] toStrings(@NotNull final TimestepKey key) { public String[] toStrings(@NotNull final TimestepKey key) {
return new String[]{ Double.toString(getValue(key).getLeft()), Double.toString(getValue(key).getRight()) }; return new String[]{ Double.toString(getValue(key).getLeft()), Double.toString(getValue(key).getRight()) };
} }
@Override
public int[] getReferencedMeasurementAreaId() {
AttributesFundamentalDiagramDProcessor att = (AttributesFundamentalDiagramDProcessor) this.getAttributes();
return new int[]{att.getVoronoiMeasurementAreaId(), att.getMeasurementAreaId()};
}
} }
...@@ -6,16 +6,20 @@ import org.vadere.annotation.factories.dataprocessors.DataProcessorClass; ...@@ -6,16 +6,20 @@ import org.vadere.annotation.factories.dataprocessors.DataProcessorClass;
import org.vadere.simulator.control.SimulationState; import org.vadere.simulator.control.SimulationState;
import org.vadere.simulator.projects.dataprocessing.ProcessorManager; import org.vadere.simulator.projects.dataprocessing.ProcessorManager;
import org.vadere.simulator.projects.dataprocessing.datakey.TimestepKey; import org.vadere.simulator.projects.dataprocessing.datakey.TimestepKey;
import org.vadere.simulator.projects.dataprocessing.flags.UsesMeasurementArea;
import org.vadere.state.attributes.processor.AttributesFundamentalDiagramEProcessor; import org.vadere.state.attributes.processor.AttributesFundamentalDiagramEProcessor;
import org.vadere.state.attributes.processor.AttributesProcessor; import org.vadere.state.attributes.processor.AttributesProcessor;
import org.vadere.state.scenario.MeasurementArea; import org.vadere.state.scenario.MeasurementArea;
import org.vadere.util.factory.processors.Flag;
import java.util.List;
/** /**
* *
* @author Benedikt Zoennchen * @author Benedikt Zoennchen
*/ */
@DataProcessorClass() @DataProcessorClass()
public class FundamentalDiagramEProcessor extends AreaDataProcessor<Pair<Double, Double>> { public class FundamentalDiagramEProcessor extends AreaDataProcessor<Pair<Double, Double>> implements UsesMeasurementArea {
private SumVoronoiAlgorithm sumVoronoiAlgorithm; private SumVoronoiAlgorithm sumVoronoiAlgorithm;
private APedestrianVelocityProcessor pedestrianVelocityProcessor; private APedestrianVelocityProcessor pedestrianVelocityProcessor;
...@@ -66,4 +70,12 @@ public class FundamentalDiagramEProcessor extends AreaDataProcessor<Pair<Double, ...@@ -66,4 +70,12 @@ public class FundamentalDiagramEProcessor extends AreaDataProcessor<Pair<Double,
public String[] toStrings(@NotNull final TimestepKey key) { public String[] toStrings(@NotNull final TimestepKey key) {
return new String[]{ Double.toString(getValue(key).getLeft()), Double.toString(getValue(key).getRight()) }; return new String[]{ Double.toString(getValue(key).getLeft()), Double.toString(getValue(key).getRight()) };
} }
@Override
public int[] getReferencedMeasurementAreaId() {
AttributesFundamentalDiagramEProcessor att = (AttributesFundamentalDiagramEProcessor) this.getAttributes();
return new int[]{att.getVoronoiMeasurementAreaId(), att.getMeasurementAreaId()};
}
} }
...@@ -6,20 +6,21 @@ import org.vadere.annotation.factories.dataprocessors.DataProcessorClass; ...@@ -6,20 +6,21 @@ import org.vadere.annotation.factories.dataprocessors.DataProcessorClass;
import org.vadere.simulator.control.SimulationState; import org.vadere.simulator.control.SimulationState;
import org.vadere.simulator.projects.dataprocessing.ProcessorManager; import org.vadere.simulator.projects.dataprocessing.ProcessorManager;
import org.vadere.simulator.projects.dataprocessing.datakey.PedestrianIdKey; import org.vadere.simulator.projects.dataprocessing.datakey.PedestrianIdKey;
import org.vadere.simulator.projects.dataprocessing.flags.UsesMeasurementArea;
import org.vadere.state.attributes.processor.AttributesCrossingTimeProcessor; import org.vadere.state.attributes.processor.AttributesCrossingTimeProcessor;
import org.vadere.state.attributes.processor.AttributesProcessor; import org.vadere.state.attributes.processor.AttributesProcessor;
import org.vadere.state.scenario.MeasurementArea; import org.vadere.state.scenario.MeasurementArea;
import org.vadere.state.scenario.Pedestrian; import org.vadere.state.scenario.Pedestrian;
import org.vadere.state.simulation.FootStep; import org.vadere.state.simulation.FootStep;
import org.vadere.util.geometry.shapes.VRectangle; import org.vadere.util.factory.processors.Flag;
import org.vadere.util.geometry.shapes.VShape;
import org.vadere.util.logging.Logger; import org.vadere.util.logging.Logger;
import java.util.Collection; import java.util.Collection;
import java.util.List;
//TODO //TODO
@DataProcessorClass() @DataProcessorClass()
public class PedestrianCrossingTimeProcessor extends DataProcessor<PedestrianIdKey, Pair<Double, Double>>{ public class PedestrianCrossingTimeProcessor extends DataProcessor<PedestrianIdKey, Pair<Double, Double>> implements UsesMeasurementArea {
private MeasurementArea measurementArea; private MeasurementArea measurementArea;
private static Logger logger = Logger.getLogger(PedestrianCrossingTimeProcessor.class); private static Logger logger = Logger.getLogger(PedestrianCrossingTimeProcessor.class);
...@@ -99,4 +100,11 @@ public class PedestrianCrossingTimeProcessor extends DataProcessor<PedestrianIdK ...@@ -99,4 +100,11 @@ public class PedestrianCrossingTimeProcessor extends DataProcessor<PedestrianIdK
Pair<Double, Double> times = getValue(key); Pair<Double, Double> times = getValue(key);
return new String[]{Double.toString(times.getLeft()), Double.toString(times.getRight())}; return new String[]{Double.toString(times.getLeft()), Double.toString(times.getRight())};
} }
@Override
public int[] getReferencedMeasurementAreaId() {
AttributesCrossingTimeProcessor att = (AttributesCrossingTimeProcessor) this.getAttributes();
return new int[]{att.getWaitingAreaId(), att.getMeasurementAreaId()};
}
} }
...@@ -4,20 +4,22 @@ import org.vadere.annotation.factories.dataprocessors.DataProcessorClass; ...@@ -4,20 +4,22 @@ import org.vadere.annotation.factories.dataprocessors.DataProcessorClass;
import org.vadere.simulator.control.SimulationState; import org.vadere.simulator.control.SimulationState;
import org.vadere.simulator.projects.dataprocessing.ProcessorManager; import org.vadere.simulator.projects.dataprocessing.ProcessorManager;
import org.vadere.simulator.projects.dataprocessing.datakey.PedestrianIdKey; import org.vadere.simulator.projects.dataprocessing.datakey.PedestrianIdKey;
import org.vadere.simulator.projects.dataprocessing.flags.UsesMeasurementArea;
import org.vadere.state.attributes.processor.AttributesPedestrianWaitingEndTimeProcessor; import org.vadere.state.attributes.processor.AttributesPedestrianWaitingEndTimeProcessor;
import org.vadere.state.attributes.processor.AttributesProcessor; import org.vadere.state.attributes.processor.AttributesProcessor;
import org.vadere.state.scenario.MeasurementArea; import org.vadere.state.scenario.MeasurementArea;
import org.vadere.state.scenario.Pedestrian; import org.vadere.state.scenario.Pedestrian;
import org.vadere.util.factory.processors.Flag;
import org.vadere.util.geometry.shapes.VPoint; import org.vadere.util.geometry.shapes.VPoint;
import org.vadere.util.geometry.shapes.VRectangle;
import java.util.Collection; import java.util.Collection;
import java.util.List;
/** /**
* @author Mario Teixeira Parente * @author Mario Teixeira Parente
*/ */
@DataProcessorClass() @DataProcessorClass()
public class PedestrianWaitingEndTimeProcessor extends DataProcessor<PedestrianIdKey, Double> { public class PedestrianWaitingEndTimeProcessor extends DataProcessor<PedestrianIdKey, Double> implements UsesMeasurementArea {
private MeasurementArea waitingArea; private MeasurementArea waitingArea;
public PedestrianWaitingEndTimeProcessor() { public PedestrianWaitingEndTimeProcessor() {
...@@ -59,4 +61,11 @@ public class PedestrianWaitingEndTimeProcessor extends DataProcessor<PedestrianI ...@@ -59,4 +61,11 @@ public class PedestrianWaitingEndTimeProcessor extends DataProcessor<PedestrianI