Commit 904c0cf9 authored by Tobias Meuser's avatar Tobias Meuser
Browse files

Current version for Ad-Hoc Networks

parent d30afc6c
......@@ -30,6 +30,4 @@ public interface EnvironmentProperty {
// Enabler Interface
long getDetectionDate();
EnvironmentProperty getDefaultProperty();
}
......@@ -36,12 +36,25 @@ public class JamProperty implements RoadProperty {
private final RoadNetworkEdge _edge;
private final boolean _jammed;
private long _detectionDate;
private double _averageSpeed = -1;
public JamProperty(Location pLocation, RoadNetworkEdge pEdge, boolean pJammed) {
this(pLocation, pEdge, pJammed, -1);
if (_jammed) {
_averageSpeed = 15;
} else {
_averageSpeed = -1;
}
}
public JamProperty(Location pLocation, RoadNetworkEdge pEdge, boolean pJammed, double pAverageSpeed) {
_location = pLocation;
_edge = pEdge;
_jammed = pJammed;
_detectionDate = Time.getCurrentTime();
_averageSpeed = pAverageSpeed;
}
@Override
......@@ -63,9 +76,17 @@ public class JamProperty implements RoadProperty {
return _jammed;
}
public double getAverageSpeed() {
return _averageSpeed;
}
public void setAverageSpeed(double pAverageSpeed) {
_averageSpeed = pAverageSpeed;
}
@Override
public EnvironmentProperty getDefaultProperty() {
return new JamProperty(_location, _edge, false);
return new JamProperty(_location, _edge, false, -1);
}
}
/*
* Copyright (c) 2005-2010 KOM – Multimedia Communications Lab
*
* This file is part of Simonstrator.KOM.
*
* Simonstrator.KOM is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* PeerfactSim.KOM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PeerfactSim.KOM. If not, see <http://www.gnu.org/licenses/>.
*
*/
package de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.Location;
import de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.RoadNetworkEdge;
/**
* @author Tobias Meuser (tobias.meuser@kom.tu-darmstadt.de)
* @version 1.0 at 13.04.2018
*
*/
public abstract class NumericVectoralProperty extends VectoralProperty {
public NumericVectoralProperty(Location pLocation, RoadNetworkEdge pEdge, double[] values) {
super(pLocation, pEdge, values);
}
public NumericVectoralProperty(Location pLocation, RoadNetworkEdge pEdge, int pValueAmount) {
super(pLocation, pEdge, pValueAmount);
}
@Override
public abstract NumericVectoralProperty clone();
@Override
public abstract Double getValueAtIndex(int pIndex);
@Override
public Double getMostProbableValue() {
return (Double) super.getMostProbableValue();
}
public Double getExpectation() {
double sum = 0;
double[] probs = getValueProbabilities();
for (int i = 0; i < probs.length; i++) {
sum += getValueAtIndex(i) * probs[i];
}
return sum;
}
}
......@@ -30,4 +30,6 @@ import de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.Road
*/
public interface RoadProperty extends LocationBasedEnvironmentProperty {
RoadNetworkEdge getEdge();
EnvironmentProperty getDefaultProperty();
}
/*
* Copyright (c) 2005-2010 KOM – Multimedia Communications Lab
*
* This file is part of Simonstrator.KOM.
*
* Simonstrator.KOM is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* PeerfactSim.KOM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PeerfactSim.KOM. If not, see <http://www.gnu.org/licenses/>.
*
*/
package de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data;
import java.util.Arrays;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.vector.TemporalDependencyMatrix;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.Location;
import de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.RoadNetworkEdge;
/**
* @author Tobias Meuser (tobias.meuser@kom.tu-darmstadt.de)
* @version 1.0 at 12.04.2018
*
*/
public class VectoralJamProperty extends NumericVectoralProperty {
public static final double SCALING = 6;
private static final int DIMENSIONS = 15;
private static final double TEMPORAL_CHANGE = 0.05;
public VectoralJamProperty(Location pLocation, RoadNetworkEdge pEdge) {
super(pLocation, pEdge, DIMENSIONS);
}
public void setSpeed(double pSpeed, double pDeviation) {
setProbabilities(pSpeed / SCALING, pDeviation / SCALING);
}
@Override
public VectoralJamProperty clone() {
VectoralJamProperty vectoralJamProperty = new VectoralJamProperty(getLocation(), getEdge());
vectoralJamProperty.setProbabilities(Arrays.copyOf(getValueProbabilities(), getValueProbabilities().length));
vectoralJamProperty.setDetectionDate(getDetectionDate());
return vectoralJamProperty;
}
@Override
public EnvironmentProperty getDefaultProperty() {
return new VectoralJamProperty(getLocation(), getEdge());
}
@Override
public Double getValueAtIndex(int pIndex) {
return pIndex * SCALING;
}
@Override
public TemporalDependencyMatrix getDependencyMatrix() {
TemporalDependencyMatrix temporalDependencyMatrix = new TemporalDependencyMatrix(DIMENSIONS);
for (int x = 0; x < DIMENSIONS; x++) {
double[] probabilities = new double[DIMENSIONS];
probabilities[Math.max(0, x - 1)] += TEMPORAL_CHANGE;
probabilities[Math.min(DIMENSIONS - 1, x + 1)] += TEMPORAL_CHANGE;
probabilities[x] += (1 - 2 * TEMPORAL_CHANGE);
temporalDependencyMatrix.setTransitionProbability(x, probabilities);
}
return temporalDependencyMatrix;
}
public double getProbabilityForValue(Object pValue) {
if (pValue instanceof Double) {
double value = (double) pValue;
int index = (int) (value / SCALING);
return getValueProbabilities()[index];
}
return 0;
}
/**
* @return
*/
public boolean isJammed() {
if (getEdge() != null) {
double originalMaxSpeed = getEdge().getOriginalMaxSpeed();
double speed = getExpectation();
if (speed < (((int) (originalMaxSpeed / VectoralJamProperty.SCALING)) * VectoralJamProperty.SCALING)
* 0.375) {
return true;
}
}
return false;
}
@Override
public int hashCode() {
return Double.hashCode(getMostProbableValue());
}
@Override
public boolean equals(Object pObj) {
if (pObj instanceof VectoralJamProperty) {
VectoralJamProperty property = (VectoralJamProperty) pObj;
if (property.getMostProbableValue().equals(getMostProbableValue())) {
return true;
}
return false;
}
return super.equals(pObj);
}
}
\ No newline at end of file
/*
* Copyright (c) 2005-2010 KOM – Multimedia Communications Lab
*
* This file is part of Simonstrator.KOM.
*
* Simonstrator.KOM is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* PeerfactSim.KOM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PeerfactSim.KOM. If not, see <http://www.gnu.org/licenses/>.
*
*/
package de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data;
import java.util.Arrays;
import de.tudarmstadt.maki.simonstrator.api.Time;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.vector.TemporalDependencyMatrix;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.Location;
import de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.RoadNetworkEdge;
/**
* @author Tobias Meuser (tobias.meuser@kom.tu-darmstadt.de)
* @version 1.0 at 27.02.2018
*
*/
public abstract class VectoralProperty implements RoadProperty, Cloneable {
private static final boolean TRIM_PROBABILITIES = false;
private static final double MINIMAL_PROBABILITY = 0.0001;
private final Location _location;
private final RoadNetworkEdge _edge;
private long _detectionDate;
private double[] _valueProbabilities;
public VectoralProperty(Location pLocation, RoadNetworkEdge pEdge, int valueAmount) {
this(pLocation, pEdge, createProbabilityArray(valueAmount));
}
public VectoralProperty(Location pLocation, RoadNetworkEdge pEdge, double[] values) {
_location = pLocation;
_edge = pEdge;
_detectionDate = Time.getCurrentTime();
_valueProbabilities = values;
}
public void setProbabilities(double[] pValueProbabilities) {
_valueProbabilities = pValueProbabilities;
}
protected void setProbabilities(double pMean, double pDeviation) {
if (pDeviation > 0) {
double sum = 0;
for (int i = 0; i < _valueProbabilities.length; i++) {
double probability = 1 / (2 * Math.PI * Math.pow(pDeviation, 2))
* Math.exp(-Math.pow(i - pMean, 2) / (2 * Math.pow(pDeviation, 2)));
if (probability < MINIMAL_PROBABILITY && TRIM_PROBABILITIES) {
probability = MINIMAL_PROBABILITY;
}
_valueProbabilities[i] = probability;
sum += probability;
}
for (int i = 0; i < _valueProbabilities.length; i++) {
_valueProbabilities[i] /= sum;
}
} else {
Arrays.fill(_valueProbabilities, 0);
_valueProbabilities[(int) pMean] = 1;
}
}
public static double[] createProbabilityArray(int valueAmount) {
double[] probabilities = new double[valueAmount];
Arrays.fill(probabilities, 1 / (double) probabilities.length);
return probabilities;
}
@Override
public long getDetectionDate() {
return _detectionDate;
}
protected void setDetectionDate(long pDetectionDate) {
_detectionDate = pDetectionDate;
}
@Override
public Location getLocation() {
return _location;
}
@Override
public RoadNetworkEdge getEdge() {
return _edge;
}
public double[] getValueProbabilities() {
return _valueProbabilities;
}
public abstract Object getValueAtIndex(int pIndex);
public Object getMostProbableValue() {
double max = -1;
int index = 0;
double[] probs = getValueProbabilities();
for (int i = 0; i < probs.length; i++) {
if (probs[i] > max) {
max = probs[i];
index = i;
}
}
return getValueAtIndex(index);
}
public abstract TemporalDependencyMatrix getDependencyMatrix();
@Override
public abstract VectoralProperty clone();
public VectoralProperty age(long pAge) {
return age(pAge, getDependencyMatrix());
}
public VectoralProperty age(long pAge, TemporalDependencyMatrix pTemporalDependency) {
VectoralProperty result = clone();
double[] valueProbabilities = result.getValueProbabilities();
double[] currentProbabilities = getValueProbabilities();
for (int t = 0; t < pAge; t++) {
Arrays.fill(valueProbabilities, 0);
for (int i = 0; i < valueProbabilities.length; i++) {
for (int j = 0; j < valueProbabilities.length; j++) {
double added = currentProbabilities[i] * pTemporalDependency.getTransitionProbability(i, j);
valueProbabilities[j] += added;
}
}
double sum = 0;
for (int i = 0; i < valueProbabilities.length; i++) {
if (valueProbabilities[i] < MINIMAL_PROBABILITY && TRIM_PROBABILITIES) {
valueProbabilities[i] = MINIMAL_PROBABILITY;
}
sum += valueProbabilities[i];
}
for (int i = 0; i < valueProbabilities.length; i++) {
valueProbabilities[i] /= sum;
}
currentProbabilities = Arrays.copyOf(valueProbabilities, valueProbabilities.length);
}
return result;
}
public abstract double getProbabilityForValue(Object pValue);
public VectoralProperty combine(VectoralProperty pVectoralProperty) {
VectoralProperty result = clone();
double sum = 0;
double[] valueProbabilities = result.getValueProbabilities();
for (int i = 0; i < valueProbabilities.length; i++) {
valueProbabilities[i] *= pVectoralProperty.getValueProbabilities()[i];
if (valueProbabilities[i] < MINIMAL_PROBABILITY && TRIM_PROBABILITIES) {
valueProbabilities[i] = MINIMAL_PROBABILITY;
}
sum += valueProbabilities[i];
}
for (int i = 0; i < valueProbabilities.length; i++) {
valueProbabilities[i] /= sum;
}
return result;
}
}
/*
* Copyright (c) 2005-2010 KOM – Multimedia Communications Lab
*
* This file is part of Simonstrator.KOM.
*
* Simonstrator.KOM is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* PeerfactSim.KOM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PeerfactSim.KOM. If not, see <http://www.gnu.org/licenses/>.
*
*/
package de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data;
import de.tudarmstadt.maki.simonstrator.api.Time;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.Location;
import de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.RoadNetworkEdge;
/**
* @author Tobias Meuser (tobias.meuser@kom.tu-darmstadt.de)
* @version 1.0 at 27.02.2018
*
*/
public class VehicleProperty implements LocationBasedEnvironmentProperty {
private final long _id;
private final Location _location;
private final RoadNetworkEdge _edge;
private final double _speed;
private long _detectionDate;
public VehicleProperty(long pId, Location pLocation, RoadNetworkEdge pEdge, double pSpeed) {
_id = pId;
_location = pLocation;
_edge = pEdge;
_speed = pSpeed;
_detectionDate = Time.getCurrentTime();
}
public long getId() {
return _id;
}
@Override
public long getDetectionDate() {
return _detectionDate;
}
@Override
public Location getLocation() {
return _location;
}
public RoadNetworkEdge getEdge() {
return _edge;
}
public double getSpeed() {
return _speed;
}
}
/*
* Copyright (c) 2005-2010 KOM – Multimedia Communications Lab
*
* This file is part of Simonstrator.KOM.
*
* Simonstrator.KOM is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* PeerfactSim.KOM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PeerfactSim.KOM. If not, see <http://www.gnu.org/licenses/>.
*
*/
package de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.vector;
import java.util.Arrays;
/**
* @author Tobias Meuser (tobias.meuser@kom.tu-darmstadt.de)
* @version 1.0 at 12.04.2018
*
*/
public class TemporalDependencyMatrix implements Cloneable {
// Value x | y --> Transition probability from state x to state y
private double[][] _dependencies;
public TemporalDependencyMatrix(int dimension) {
_dependencies = new double[dimension][dimension];
}
private TemporalDependencyMatrix(double[][] pDependencies) {
_dependencies = pDependencies;
}
public double[][] getDependencies() {
return _dependencies;
}
public void setTransitionProbability(int pCurrent, double[] pProbabilities) {
for (int y = 0; y < pProbabilities.length; y++) {
_dependencies[pCurrent][y] = pProbabilities[y];
}
}
public TemporalDependencyMatrix age(long pAge) {
double[][] current = cloneArray(_dependencies);
for (long t = 0; t < pAge; t++) {
double[][] next = createEmptyArray(current);
for (int i = 0; i < current.length; i++) {
for (int j = 0; j < current[i].length; j++) {
for (int k = 0; k < current[i].length; k++) {
next[i][j] += current[i][k] * _dependencies[k][j];
}
}
}
current = next;
}
return new TemporalDependencyMatrix(current);
}
public double[][] cloneArray(double[][] pDependencies) {
double[][] current = new double[pDependencies.length][];
for (int i = 0; i < current.length; i++) {
current[i] = Arrays.copyOf(pDependencies[i], pDependencies[i].length);
}
return current;
}
public double[][] createEmptyArray(double[][] pDependencies) {
double[][] current = new double[pDependencies.length][];
for (int i = 0; i < current.length; i++) {
current[i] = new double[pDependencies[i].length];
}
return current;
}
public double getTransitionProbability(int pCurrent, int pNext) {
return _dependencies[pCurrent][pNext];
}
@Override
public TemporalDependencyMatrix clone() {
double[][] dependencies = new double[_dependencies.length][];
for (int i = 0; i < dependencies.length; i++) {
dependencies[i] = Arrays.copyOf(_dependencies[i], _dependencies[i].length);
}
return new TemporalDependencyMatrix(dependencies);
}
}
/*
* Copyright (c) 2005-2010 KOM – Multimedia Communications Lab
*
* This file is part of Simonstrator.KOM.
*
* Simonstrator.KOM is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* PeerfactSim.KOM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PeerfactSim.KOM. If not, see <http://www.gnu.org/licenses/>.
*
*/
package de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.plugin;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
import de.tudarmstadt.maki.simonstrator.api.Host;
import de.tudarmstadt.maki.simonstrator.api.Randoms;
import de.tudarmstadt.maki.simonstrator.api.component.ComponentNotAvailableException;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.EnvironmentProperty;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.JamProperty;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.RoadProperty;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.VectoralJamProperty;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.Location;
import de.tudarmstadt.maki.simonstrator.api.component.sis.SiSComponent;
import de.tudarmstadt.maki.simonstrator.api.component.sis.SiSRequest;
import de.tudarmstadt.maki.simonstrator.api.component.sis.exception.InformationNotAvailableException;
import de.tudarmstadt.maki.simonstrator.api.component.sis.type.SiSTypes;
import de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.RoadNetworkEdge;
import de.tudarmstadt.maki.simonstrator.api.util.XMLConfigurableConstructor;
/**
* @author Tobias Meuser (tobias.meuser@kom.tu-darmstadt.de)
* @version 1.0 at 27.02.2018
*
*/
public class VectoralJamEnvironmentSensorPlugin implements EnvironmentSensorPlugin {
private Host _host;
private SiSComponent _sis;
private double _accuracy;
private Map<Double, Double> _requiredStandardDeviation = new HashMap<>();
private static Random _random = Randoms.getRandom(VectoralJamEnvironmentSensorPlugin.class);
@XMLConfigurableConstructor({ "accuracy" })
public VectoralJamEnvironmentSensorPlugin(double pAccuracy) {
setAccuracy(pAccuracy);
}
@Override
public void setHost(Host pHost) {
_host = pHost;
}
@Override
public List<EnvironmentProperty> getEnvironmentProperties() {
if (_sis == null) {
try {
_sis = _host.getComponent(SiSComponent.class);
} catch (ComponentNotAvailableException e) {
throw new AssertionError("SiS requried!", e);
}
}
try {
RoadNetworkEdge edge = _sis.get().localState(SiSTypes.ROAD_EDGE, SiSRequest.NONE);
Location location = _sis.get().localState(SiSTypes.PHY_LOCATION, SiSRequest.NONE);
double speed = -1;
for (RoadProperty roadProperty : edge.getActiveProperties()) {
if (roadProperty instanceof JamProperty) {
if (((JamProperty) roadProperty).isJammed()) {
speed = ((JamProperty) roadProperty).getAverageSpeed();
}
}
}
if (speed == -1) {
speed = (int) (edge.getOriginalMaxSpeed() / VectoralJamProperty.SCALING) * VectoralJamProperty.SCALING;
}
if (!_requiredStandardDeviation.containsKey(speed)) {
determineCorrectDeviation(speed);
}
double measuredSpeed = measureValue(speed, _requiredStandardDeviation.get(speed));
VectoralJamProperty vectoralJamProperty = new VectoralJamProperty(location, edge);
if (!_requiredStandardDeviation.containsKey(measuredSpeed)) {
determineCorrectDeviation(measuredSpeed);
}
vectoralJamProperty.setSpeed(measuredSpeed, _requiredStandardDeviation.get(measuredSpeed));
List<EnvironmentProperty> properties = new ArrayList<>();
EnvironmentProperty property = vectoralJamProperty;
properties.add(property);
return properties;
} catch (InformationNotAvailableException e) {
throw new AssertionError(SiSTypes.ROAD_EDGE + " and " + SiSTypes.PHY_LOCATION + " are required!");
}
}
public double measureValue(double pRealSpeed, double pDeviation) {
VectoralJamProperty vectoralJamProperty = new VectoralJamProperty(null, null);
vectoralJamProperty.setSpeed(pRealSpeed, pDeviation);
double nextDouble = _random.nextDouble();
double currentAggregate = 0;
for (int i = 0; i < vectoralJamProperty.getValueProbabilities().length; i++) {
currentAggregate += vectoralJamProperty.getValueProbabilities()[i];
if (currentAggregate > nextDouble) {
return vectoralJamProperty.getValueAtIndex(i);
}
}
throw new AssertionError("Unexpected!");
}
public void determineCorrectDeviation(double speed) {
if (_accuracy < 1) {
VectoralJamProperty vectoralJamProperty = new VectoralJamProperty(null, null);
double deviation = 10;
boolean reduceChange = false;
double currentChange = deviation / 2;
do {
vectoralJamProperty.setSpeed(speed, deviation);
if (vectoralJamProperty.getProbabilityForValue(speed) > _accuracy) {
deviation += currentChange;
} else {
deviation -= currentChange;
reduceChange = true;
}
if (reduceChange) {
currentChange /= 2.0;
}
} while (Math.round(vectoralJamProperty.getProbabilityForValue(speed) * 10000) != Math
.round(_accuracy * 10000));
_requiredStandardDeviation.put(speed, deviation);
} else {
_requiredStandardDeviation.put(speed, 0d);
}
}
@Override
public VectoralJamEnvironmentSensorPlugin clone() throws CloneNotSupportedException {
return new VectoralJamEnvironmentSensorPlugin(_accuracy);
}
public void setAccuracy(double pAccuracy) {
_accuracy = pAccuracy;
}
}
......@@ -28,7 +28,7 @@ import de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.Road
public enum AvailableInformationAttributes {
POSITION("position", Location.class), DATE("date", Long.class), VALUE("value"), OWNER("owner", INodeID.class), EDGE(
"edge", RoadNetworkEdge.class), TTL(
"ttl"), EXPECTED_DURATION(
"ttl", Long.class), EXPECTED_DURATION(
"duration"), STANDARD_DEVIATION_DURATION("sd_duration"), TYPE("type", SiSType.class);
private final String attributeID;
......
......@@ -24,6 +24,7 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.JamProperty;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.RoadProperty;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.Location;
import de.tudarmstadt.maki.simonstrator.api.component.vehicular.api.EdgeController;
......@@ -73,10 +74,18 @@ public class RoadNetworkEdge {
public void addRoadProperty(RoadProperty pProperty) {
_activeProperties.add(pProperty);
if (pProperty instanceof JamProperty) {
setMaxSpeed(((JamProperty) pProperty).getAverageSpeed());
}
}
public void removeRoadProperty(RoadProperty pProperty) {
_activeProperties.remove(pProperty);
if (pProperty instanceof JamProperty) {
setMaxSpeed(getOriginalMaxSpeed());
}
}
/**
......
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