Commit f96cb6a8 authored by Tobias Meuser's avatar Tobias Meuser
Browse files

Updated decision making for vehits, used processing server

parent 042766bf
/*
* 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.environment.data.aggregation.AggregationInformation;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.Location;
import de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.RoadNetworkEdge;
public abstract class AbstractRoadProperty implements RoadProperty, AggregatedProperty {
private Location _location;
private RoadNetworkEdge _edge;
private long _detectionDate;
private AggregationInformation _aggregationInformation;
public AbstractRoadProperty(Location pLocation, RoadNetworkEdge pEdge) {
_location = pLocation;
_edge = pEdge;
_detectionDate = Time.getCurrentTime();
}
@Override
public long getDetectionDate() {
return _detectionDate;
}
@Override
public void setDetectionDate(long pDate) {
_detectionDate = pDate;
}
@Override
public Location getLocation() {
return _location;
}
@Override
public void setLocation(Location pLocation) {
_location = pLocation;
}
@Override
public RoadNetworkEdge getEdge() {
return _edge;
}
public void setEdge(RoadNetworkEdge pEdge) {
_edge = pEdge;
}
@Override
public AggregationInformation getAggregationInformation() {
return _aggregationInformation;
}
@Override
public void setAggregationInformation(AggregationInformation pAggregationInformation) {
_aggregationInformation = pAggregationInformation;
}
@Override
public boolean isAggregated() {
return _aggregationInformation != null;
}
@Override
public final int hashCode() {
return getEdge().getEdgeID().hashCode();
}
@Override
public boolean equalLocation(RoadProperty pRoadProperty) {
return pRoadProperty.getEdge().equals(_edge) && pRoadProperty.getLocation().equals(_location);
}
}
/*
* 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.environment.data.aggregation.AggregationInformation;
public interface AggregatedProperty {
AggregationInformation getAggregationInformation();
boolean isAggregated();
void setAggregationInformation(AggregationInformation pAggregationInformation);
}
......@@ -21,7 +21,6 @@
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;
......@@ -30,33 +29,13 @@ import de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.Road
* @version 1.0 at 26.03.2018
*
*/
public class BumpProperty implements RoadProperty {
public class BumpProperty extends AbstractRoadProperty {
private final Location _location;
private final RoadNetworkEdge _edge;
private final boolean _bump;
private long _detectionDate;
public BumpProperty(Location pLocation, RoadNetworkEdge pEdge, boolean pBump) {
_location = pLocation;
_edge = pEdge;
super(pLocation, pEdge);
_bump = pBump;
_detectionDate = Time.getCurrentTime();
}
@Override
public long getDetectionDate() {
return _detectionDate;
}
@Override
public Location getLocation() {
return _location;
}
@Override
public RoadNetworkEdge getEdge() {
return _edge;
}
public boolean hasBump() {
......@@ -65,12 +44,7 @@ public class BumpProperty implements RoadProperty {
@Override
public EnvironmentProperty getDefaultProperty() {
return new BumpProperty(_location, _edge, false);
}
@Override
public int hashCode() {
return getEdge().getEdgeID().hashCode();
return new BumpProperty(getLocation(), getEdge(), false);
}
@Override
......
......@@ -30,4 +30,6 @@ public interface EnvironmentProperty {
// Enabler Interface
long getDetectionDate();
void setDetectionDate(long pDate);
}
......@@ -21,7 +21,6 @@
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;
......@@ -30,33 +29,13 @@ import de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.Road
* @version 1.0 at 27.03.2018
*
*/
public class FogProperty implements RoadProperty {
public class FogProperty extends AbstractRoadProperty {
private final Location _location;
private final RoadNetworkEdge _edge;
private final boolean _fog;
private long _detectionDate;
public FogProperty(Location pLocation, RoadNetworkEdge pEdge, boolean pFog) {
_location = pLocation;
_edge = pEdge;
super(pLocation, pEdge);
_fog = pFog;
_detectionDate = Time.getCurrentTime();
}
@Override
public long getDetectionDate() {
return _detectionDate;
}
@Override
public Location getLocation() {
return _location;
}
@Override
public RoadNetworkEdge getEdge() {
return _edge;
}
public boolean hasFog() {
......@@ -65,12 +44,7 @@ public class FogProperty implements RoadProperty {
@Override
public EnvironmentProperty getDefaultProperty() {
return new FogProperty(_location, _edge, false);
}
@Override
public int hashCode() {
return getEdge().getEdgeID().hashCode();
return new FogProperty(getLocation(), getEdge(), false);
}
@Override
......
......@@ -21,7 +21,6 @@
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;
......@@ -30,33 +29,13 @@ import de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.Road
* @version 1.0 at 26.03.2018
*
*/
public class HazardProperty implements RoadProperty {
public class HazardProperty extends AbstractRoadProperty {
private final Location _location;
private final RoadNetworkEdge _edge;
private final boolean _hazard;
private long _detectionDate;
public HazardProperty(Location pLocation, RoadNetworkEdge pEdge, boolean pHazard) {
_location = pLocation;
_edge = pEdge;
super(pLocation, pEdge);
_hazard = pHazard;
_detectionDate = Time.getCurrentTime();
}
@Override
public long getDetectionDate() {
return _detectionDate;
}
@Override
public Location getLocation() {
return _location;
}
@Override
public RoadNetworkEdge getEdge() {
return _edge;
}
public boolean hasHazard() {
......@@ -65,12 +44,7 @@ public class HazardProperty implements RoadProperty {
@Override
public EnvironmentProperty getDefaultProperty() {
return new HazardProperty(_location, _edge, false);
}
@Override
public int hashCode() {
return getEdge().getEdgeID().hashCode();
return new HazardProperty(getLocation(), getEdge(), false);
}
@Override
......
......@@ -30,4 +30,6 @@ import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.Location;
*/
public interface LocationBasedEnvironmentProperty extends EnvironmentProperty {
Location getLocation();
void setLocation(Location pLocation);
}
......@@ -21,7 +21,6 @@
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;
......@@ -30,33 +29,13 @@ import de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.Road
* @version 1.0 at 27.03.2018
*
*/
public class RainProperty implements RoadProperty {
public class RainProperty extends AbstractRoadProperty {
private final Location _location;
private final RoadNetworkEdge _edge;
private final boolean _rain;
private long _detectionDate;
public RainProperty(Location pLocation, RoadNetworkEdge pEdge, boolean pRain) {
_location = pLocation;
_edge = pEdge;
super(pLocation, pEdge);
_rain = pRain;
_detectionDate = Time.getCurrentTime();
}
@Override
public long getDetectionDate() {
return _detectionDate;
}
@Override
public Location getLocation() {
return _location;
}
@Override
public RoadNetworkEdge getEdge() {
return _edge;
}
public boolean hasRain() {
......@@ -65,12 +44,7 @@ public class RainProperty implements RoadProperty {
@Override
public EnvironmentProperty getDefaultProperty() {
return new RainProperty(_location, _edge, false);
}
@Override
public int hashCode() {
return getEdge().getEdgeID().hashCode();
return new RainProperty(getLocation(), getEdge(), false);
}
@Override
......
......@@ -28,10 +28,14 @@ import de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.Road
* @version 1.0 at 27.02.2018
*
*/
public interface RoadProperty extends LocationBasedEnvironmentProperty {
public interface RoadProperty extends LocationBasedEnvironmentProperty, AggregatedProperty {
RoadNetworkEdge getEdge();
void setEdge(RoadNetworkEdge pEdge);
EnvironmentProperty getDefaultProperty();
long getDetectionDate();
boolean equalLocation(RoadProperty pRoadProperty);
}
......@@ -21,7 +21,6 @@
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;
......@@ -30,33 +29,13 @@ import de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.Road
* @version 1.0 at 26.03.2018
*
*/
public class TrafficSignProperty implements RoadProperty {
public class TrafficSignProperty extends AbstractRoadProperty {
private final Location _location;
private final RoadNetworkEdge _edge;
private final boolean _sign;
private long _detectionDate;
public TrafficSignProperty(Location pLocation, RoadNetworkEdge pEdge, boolean pSign) {
_location = pLocation;
_edge = pEdge;
super(pLocation, pEdge);
_sign = pSign;
_detectionDate = Time.getCurrentTime();
}
@Override
public long getDetectionDate() {
return _detectionDate;
}
@Override
public Location getLocation() {
return _location;
}
@Override
public RoadNetworkEdge getEdge() {
return _edge;
}
public boolean hasSign() {
......@@ -65,12 +44,7 @@ public class TrafficSignProperty implements RoadProperty {
@Override
public EnvironmentProperty getDefaultProperty() {
return new TrafficSignProperty(_location, _edge, false);
}
@Override
public int hashCode() {
return getEdge().getEdgeID().hashCode();
return new TrafficSignProperty(getLocation(), getEdge(), false);
}
@Override
......
......@@ -25,8 +25,6 @@ import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import de.tudarmstadt.maki.simonstrator.api.Time;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.aggregation.AggregationInformation;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.Location;
import de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.RoadNetworkEdge;
......@@ -35,25 +33,17 @@ import de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.Road
* @version 1.0 at 27.02.2018
*
*/
public abstract class VectoralProperty implements RoadProperty, Cloneable {
public abstract class VectoralProperty extends AbstractRoadProperty implements Cloneable {
private static Map<DeviationIdentifier, Double> _requiredStandardDeviation = new HashMap<>();
private final Location _location;
private final RoadNetworkEdge _edge;
private long _detectionDate;
private double[] _valueProbabilities;
private AggregationInformation _aggregationInformation;
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();
super(pLocation, pEdge);
_valueProbabilities = values;
}
......@@ -88,37 +78,10 @@ public abstract class VectoralProperty implements RoadProperty, Cloneable {
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 AggregationInformation getAggregationInformation() {
return _aggregationInformation;
}
public boolean isAggregated() {
return _aggregationInformation != null;
}
public abstract Object getValueAtIndex(int pIndex);
public int getMostProbableIndex() {
......@@ -287,7 +250,20 @@ public abstract class VectoralProperty implements RoadProperty, Cloneable {
public abstract int getDefaultIndex();
@Override
public boolean equals(Object pObj) {
if (pObj instanceof VectoralProperty) {
VectoralProperty vector = (VectoralProperty) pObj;
return vector.getClass().equals(getClass()) && vector.getEdge().equals(getEdge())
&& vector.getMostProbableIndex() == getMostProbableIndex();
}
return super.equals(pObj);
}
private class DeviationIdentifier {
private static final double GRANULARITY = 0.0001;
private Class<? extends VectoralProperty> _propertyClass;
private int _index;
private double _accuracy;
......@@ -295,7 +271,7 @@ public abstract class VectoralProperty implements RoadProperty, Cloneable {
public DeviationIdentifier(Class<? extends VectoralProperty> pPropertyClass, int pIndex, double pAccuracy) {
_propertyClass = pPropertyClass;
_index = pIndex;
_accuracy = pAccuracy;
_accuracy = (int) (pAccuracy / GRANULARITY) * GRANULARITY;
}
public Class<? extends VectoralProperty> getPropertyClass() {
......@@ -312,18 +288,22 @@ public abstract class VectoralProperty implements RoadProperty, Cloneable {
@Override
public int hashCode() {
return _index * Double.hashCode(_accuracy);
int prime = 31;
return Integer.hashCode(_index) * prime + Double.hashCode(_accuracy);
}
@Override
public boolean equals(Object pObj) {
if (pObj instanceof DeviationIdentifier) {
DeviationIdentifier identifier = (DeviationIdentifier) pObj;
return _propertyClass.equals(identifier.getPropertyClass()) && _index == identifier.getIndex()
&& _accuracy == identifier.getAccuracy();
public boolean equals(Object obj) {
if (obj instanceof DeviationIdentifier) {
DeviationIdentifier deviationIdentifier = (DeviationIdentifier) obj;
return deviationIdentifier._accuracy == _accuracy && deviationIdentifier._index == _index
&& deviationIdentifier._propertyClass.equals(_propertyClass);
}
return super.equals(pObj);
return false;
}
private VectoralProperty getOuterType() {
return VectoralProperty.this;
}
}
......
......@@ -21,7 +21,6 @@
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;
......@@ -30,42 +29,28 @@ import de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.Road
* @version 1.0 at 27.02.2018
*
*/
public class VehicleProperty implements LocationBasedEnvironmentProperty {
public class VehicleProperty extends AbstractRoadProperty {
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) {
super(pLocation, pEdge);
_id = pId;
_location = pLocation;
_edge = pEdge;
_speed = pSpeed;
_detectionDate = Time.getCurrentTime();
}
public long getId() {
return _id;
}
@Override
public long getDetectionDate() {
return _detectionDate;
public double getSpeed() {
return _speed;
}
@Override
public Location getLocation() {
return _location;
}
public RoadNetworkEdge getEdge() {
return _edge;
}
public double getSpeed() {
return _speed;
public EnvironmentProperty getDefaultProperty() {
return null;
}
}
/*
* Copyright (c) 2005-2010 KOM – Multimedia Communications Lab
* Copyright (c) 2005-2010 KOM Multimedia Communications Lab
*
* This file is part of Simonstrator.KOM.
*
......@@ -21,5 +21,28 @@
package de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.aggregation;
public class AggregationInformation {
private int numberOfIndiviualMeasurements;
private long _minTimestamp;
public AggregationInformation(int pNumberOfIndiviualMeasurements, long pMinTimestamp) {
numberOfIndiviualMeasurements = pNumberOfIndiviualMeasurements;
_minTimestamp = pMinTimestamp;
}
public int getNumberOfIndiviualMeasurements() {
return numberOfIndiviualMeasurements;
}
public void setNumberOfIndiviualMeasurements(int pNumberOfIndiviualMeasurements) {
numberOfIndiviualMeasurements = pNumberOfIndiviualMeasurements;
}
public long getMinTimestamp() {
return _minTimestamp;
}
public void setMinTimestamp(long pMinTimestamp) {
_minTimestamp = pMinTimestamp;
}
}
......@@ -22,8 +22,8 @@
package de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.jam;
import de.tudarmstadt.maki.simonstrator.api.Time;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.AbstractRoadProperty;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.EnvironmentProperty;
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.roadnetwork.RoadNetworkEdge;
......@@ -32,12 +32,9 @@ import de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.Road
* @version 1.0 at 27.02.2018
*
*/
public class JamProperty implements RoadProperty {
public class JamProperty extends AbstractRoadProperty {
private final Location _location;
private final RoadNetworkEdge _edge;
private final boolean _jammed;
private long _detectionDate;
private double _averageSpeed = -1;
public JamProperty(Location pLocation, RoadNetworkEdge pEdge, boolean pJammed) {
......@@ -51,31 +48,14 @@ public class JamProperty implements RoadProperty {
}
public JamProperty(Location pLocation, RoadNetworkEdge pEdge, boolean pJammed, double pAverageSpeed) {
_location = pLocation;
_edge = pEdge;
_jammed = pJammed;
_detectionDate = Time.getCurrentTime();
super(pLocation, pEdge);
_jammed = pJammed;
_averageSpeed = pAverageSpeed;
}
public void resetDetectionDate() {
_detectionDate = Time.getCurrentTime();
}
@Override
public long getDetectionDate() {
return _detectionDate;
}
@Override
public Location getLocation() {
return _location;
}
@Override
public RoadNetworkEdge getEdge() {
return _edge;
setDetectionDate(Time.getCurrentTime());
}
public boolean isJammed() {
......@@ -92,7 +72,7 @@ public class JamProperty implements RoadProperty {
@Override
public EnvironmentProperty getDefaultProperty() {
return new JamProperty(_location, _edge, false, -1);
return new JamProperty(getLocation(), getEdge(), false, -1);
}
public static boolean isJammed(RoadNetworkEdge pEdge, double pSpeed) {
......@@ -106,4 +86,14 @@ public class JamProperty implements RoadProperty {
return false;
}
@Override
public boolean equals(Object obj) {
if (obj instanceof JamProperty) {
JamProperty jamProperty = (JamProperty) obj;
return jamProperty.getEdge().equals(getEdge()) && (jamProperty.getAverageSpeed() == getAverageSpeed());
}
return super.equals(obj);
}
}
......@@ -179,11 +179,6 @@ public class VectoralJamProperty extends NumericVectoralProperty {
return JamProperty.isJammed(getEdge(), getExpectation());
}
@Override
public int hashCode() {
return Double.hashCode(getMostProbableValue());
}
@Override
public boolean equals(Object pObj) {
if (pObj instanceof VectoralJamProperty) {
......
......@@ -21,9 +21,8 @@
package de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.roadcondition;
import de.tudarmstadt.maki.simonstrator.api.Time;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.AbstractRoadProperty;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.EnvironmentProperty;
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.roadnetwork.RoadNetworkEdge;
......@@ -32,11 +31,8 @@ import de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.Road
* @version 1.0 at 27.02.2018
*
*/
public class RoadConditionProperty implements RoadProperty {
public class RoadConditionProperty extends AbstractRoadProperty {
private final Location _location;
private final RoadNetworkEdge _edge;
private long _detectionDate;
private RoadCondition _roadCondition;
public RoadConditionProperty(Location pLocation, RoadNetworkEdge pEdge) {
......@@ -44,28 +40,10 @@ public class RoadConditionProperty implements RoadProperty {
}
public RoadConditionProperty(Location pLocation, RoadNetworkEdge pEdge, RoadCondition pRoadCondition) {
_location = pLocation;
_edge = pEdge;
_detectionDate = Time.getCurrentTime();
super(pLocation, pEdge);
_roadCondition = pRoadCondition;
}
@Override
public long getDetectionDate() {
return _detectionDate;
}
@Override
public Location getLocation() {
return _location;
}
@Override
public RoadNetworkEdge getEdge() {
return _edge;
}
public RoadCondition getRoadCondition() {
return _roadCondition;
}
......@@ -76,7 +54,7 @@ public class RoadConditionProperty implements RoadProperty {
@Override
public EnvironmentProperty getDefaultProperty() {
return new RoadConditionProperty(_location, _edge, RoadCondition.DRY);
return new RoadConditionProperty(getLocation(), getEdge(), RoadCondition.DRY);
}
}
......@@ -141,11 +141,6 @@ public class VectoralRoadConditionProperty extends VectoralProperty {
return 0;
}
@Override
public int hashCode() {
return getMostProbableValue().hashCode();
}
@Override
public boolean equals(Object pObj) {
if (pObj instanceof VectoralRoadConditionProperty) {
......
......@@ -24,16 +24,41 @@ import java.util.List;
import de.tudarmstadt.maki.simonstrator.api.component.HostComponent;
import de.tudarmstadt.maki.simonstrator.api.component.overlay.NodeInformation;
import de.tudarmstadt.maki.simonstrator.api.component.vehicular.caching.decision.CacheDecisionStrategy;
import de.tudarmstadt.maki.simonstrator.api.component.vehicular.information.PointInformation;
import de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.RoadNetworkEdge;
public interface CachingComponent extends HostComponent, NodeInformation {
static final String DECISION_STRATEGY = "DecisionStrategy";
<T extends PointInformation> List<T> getCacheEntries(Class<T> pCacheEntryClass);
<T extends PointInformation> List<T> getDecidedCacheEntries(Class<T> pCacheEntryClass);
<T extends PointInformation> List<T> getDecidedCacheEntries(Class<T> pCacheEntryClass, RoadNetworkEdge pEdge);
<T extends PointInformation> List<T> getDecidedCacheEntries(Class<T> pCacheEntryClass, Class<?> pCacheValueClass,
RoadNetworkEdge pEdge);
<T extends PointInformation> boolean containsEntry(T pCacheEntry);
<T extends PointInformation> void storeCacheEntry(T pCacheEntry);
void clear();
default <T extends PointInformation> void partialClear(Class<T> pCacheEntryClass, RoadNetworkEdge pEdge) {
partialClear(pCacheEntryClass, null, pEdge);
}
default <T extends PointInformation> void partialClear(Class<T> pCacheEntryClass) {
partialClear(pCacheEntryClass, null);
}
<T extends PointInformation> void partialClear(Class<T> pCacheEntryClass, Class<?> pCacheValueClass,
RoadNetworkEdge pEdge);
void performDecisionTransition(Class<? extends CacheDecisionStrategy> pCacheDecisionStrategy);
void adjustCacheSizePerEntry(int pMaxCacheSizePerEntry);
}
/*
* 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.vehicular.caching.decision;
import java.util.List;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.RoadProperty;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.aggregation.AggregationInformation;
import de.tudarmstadt.maki.simonstrator.api.component.vehicular.information.PointInformation;
import de.tudarmstadt.maki.simonstrator.api.component.vehicular.information.RoadInformation;
public abstract class AbstractCacheDecisionStrategy implements CacheDecisionStrategy {
protected void addAggregationInformation(List<? extends PointInformation> pMeasurements,
PointInformation<?> pAggregate) {
if (pAggregate instanceof RoadInformation) {
RoadProperty roadProperty = ((RoadInformation) pAggregate).getValue();
long minTimestamp = Long.MAX_VALUE;
long maxTimestamp = 0;
for (PointInformation<?> t : pMeasurements) {
long timestamp = t.getDetectionDate();
if (timestamp < minTimestamp) {
minTimestamp = timestamp;
}
if (timestamp > maxTimestamp) {
maxTimestamp = timestamp;
}
}
roadProperty.setAggregationInformation(new AggregationInformation(pMeasurements.size(), minTimestamp));
}
}
}
......@@ -22,8 +22,19 @@ package de.tudarmstadt.maki.simonstrator.api.component.vehicular.caching.decisio
import java.util.List;
import de.tudarmstadt.maki.simonstrator.api.component.transition.TransitionEnabled;
import de.tudarmstadt.maki.simonstrator.api.component.vehicular.information.PointInformation;
public interface CacheDecisionStrategy {
public interface CacheDecisionStrategy extends TransitionEnabled {
<T extends PointInformation> T decideOnCorrectInformation(List<T> pSimilarPointInformation);
@Override
default void startMechanism(Callback pCb) {
pCb.finished(true);
}
@Override
default void stopMechanism(Callback pCb) {
pCb.finished(true);
}
}
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