Commit 5f827931 authored by hm-mgoedel's avatar hm-mgoedel

Added new processor: FlowProcessor - calculates the flow as in Seyfried-2009 (delta N / delta T)

parent 749d3cfc
package org.vadere.simulator.projects.dataprocessing.processor;
import org.vadere.annotation.factories.dataprocessors.DataProcessorClass;
import org.vadere.simulator.control.SimulationState;
import org.vadere.simulator.projects.dataprocessing.ProcessorManager;
import org.vadere.simulator.projects.dataprocessing.datakey.NoDataKey;
import org.vadere.state.attributes.processor.AttributesFlowProcessor;
import org.vadere.state.attributes.processor.AttributesProcessor;
import java.util.Collection;
import java.util.OptionalDouble;
/**
* @author Marion Goedel
*
*/
@DataProcessorClass()
public class FlowProcessor extends DataProcessor<NoDataKey, Double> {
private PedestrianLineCrossProcessor pedLineCross;
public FlowProcessor() {
super("flow");
setAttributes(new AttributesFlowProcessor());
}
@Override
protected void doUpdate(final SimulationState state) {
this.pedLineCross.update(state);
}
@Override
public void postLoop(final SimulationState state) {
pedLineCross.postLoop(state);
Collection<Double> lineCrossValues = pedLineCross.getValues();
OptionalDouble lineCrossMax = lineCrossValues.stream().mapToDouble(Double::doubleValue).max();
OptionalDouble lineCrossMin = lineCrossValues.stream().mapToDouble(Double::doubleValue).min();
double flow;
if(lineCrossMax.isPresent() && lineCrossMin.isPresent()){
double deltaT = lineCrossMax.getAsDouble() - lineCrossMin.getAsDouble();
double deltaN = lineCrossValues.size();
// double b = pedLineCross.getLine().length(); // width of corridor -> specific flow
flow = deltaN/deltaT;
} else {
flow = -1.0;
}
putValue(NoDataKey.key(), flow);
}
@Override
public void init(final ProcessorManager manager) {
super.init(manager);
AttributesFlowProcessor att = (AttributesFlowProcessor) this.getAttributes();
this.pedLineCross = (PedestrianLineCrossProcessor) manager.getProcessor(att.getPedestrianLineCrossProcessorId());
}
@Override
public AttributesProcessor getAttributes() {
if(super.getAttributes() == null) {
setAttributes(new AttributesFlowProcessor());
}
return super.getAttributes();
}
}
package org.vadere.state.attributes.processor;
/**
* @author Marion Goedel
*
*/
public class AttributesFlowProcessor extends AttributesProcessor {
private int pedestrianLineCrossProcessorId;
public int getPedestrianLineCrossProcessorId() {
return this.pedestrianLineCrossProcessorId;
}
public void setPedestrianLineCrossProcessorId(int pedestrianLineCrossProcessorId) {
checkSealed();
this.pedestrianLineCrossProcessorId = pedestrianLineCrossProcessorId;
}
}
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