Commit 97c0ed5e authored by Tobias Meuser's avatar Tobias Meuser
Browse files

Working version for attacker scenario

parent 345fec46
...@@ -28,11 +28,10 @@ import java.util.Map.Entry; ...@@ -28,11 +28,10 @@ import java.util.Map.Entry;
import java.util.Set; import java.util.Set;
import de.tudarmstadt.maki.simonstrator.api.Host; import de.tudarmstadt.maki.simonstrator.api.Host;
import de.tudarmstadt.maki.simonstrator.api.Time; import de.tudarmstadt.maki.simonstrator.api.common.graph.INodeID;
import de.tudarmstadt.maki.simonstrator.api.component.ComponentNotAvailableException; import de.tudarmstadt.maki.simonstrator.api.component.ComponentNotAvailableException;
import de.tudarmstadt.maki.simonstrator.api.component.network.NetInterface; import de.tudarmstadt.maki.simonstrator.api.component.network.NetInterface;
import de.tudarmstadt.maki.simonstrator.api.component.network.NetworkComponent.NetInterfaceName; import de.tudarmstadt.maki.simonstrator.api.component.network.NetworkComponent.NetInterfaceName;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.RoadProperty;
import de.tudarmstadt.maki.simonstrator.api.component.transition.TransitionEngine; import de.tudarmstadt.maki.simonstrator.api.component.transition.TransitionEngine;
import de.tudarmstadt.maki.simonstrator.api.component.transport.ConnectivityListener; import de.tudarmstadt.maki.simonstrator.api.component.transport.ConnectivityListener;
import de.tudarmstadt.maki.simonstrator.api.component.vehicular.VehicleInformationComponent; import de.tudarmstadt.maki.simonstrator.api.component.vehicular.VehicleInformationComponent;
...@@ -50,7 +49,6 @@ import de.tudarmstadt.maki.simonstrator.api.component.vehicular.information.Road ...@@ -50,7 +49,6 @@ import de.tudarmstadt.maki.simonstrator.api.component.vehicular.information.Road
import de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.RoadNetwork; import de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.RoadNetwork;
import de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.RoadNetworkEdge; import de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.RoadNetworkEdge;
import de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.RoadNetworkRoute; import de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.RoadNetworkRoute;
import de.tudresden.sumo.cmd.Simulation;
public class DefaultCachingComponent implements CachingComponent, ConnectivityListener { public class DefaultCachingComponent implements CachingComponent, ConnectivityListener {
...@@ -158,45 +156,52 @@ public class DefaultCachingComponent implements CachingComponent, ConnectivityLi ...@@ -158,45 +156,52 @@ public class DefaultCachingComponent implements CachingComponent, ConnectivityLi
@Override @Override
public <T extends PointInformation> List<T> getDecidedCacheEntries( public <T extends PointInformation> List<T> getDecidedCacheEntries(
Class<T> pCacheEntryClass, Class<?> pCacheValueClass, RoadNetworkEdge pEdge) { Class<T> pCacheEntryClass, Class<?> pCacheValueClass, RoadNetworkEdge pEdge) {
CacheDecisionStrategy decisionStrategy = getCacheDecisionStrategy(pCacheEntryClass); return getDecidedCacheEntries(pCacheEntryClass, pCacheValueClass, pEdge, null);
Set<RoadNetworkEdge> allEverActiveEdges = RoadNetwork.CURRENT_ROAD_NETWORK.getAllEverActiveEdges(); }
if (!allEverActiveEdges.contains(pEdge)) { @Override
return null; public <T extends PointInformation> List<T> getDecidedCacheEntries(Class<T> pCacheEntryClass, Class<?> pCacheValueClass,
} RoadNetworkEdge pEdge, INodeID pWithoutID) {
CacheDecisionStrategy decisionStrategy = getCacheDecisionStrategy(pCacheEntryClass);
Set<RoadNetworkEdge> allEverActiveEdges = RoadNetwork.CURRENT_ROAD_NETWORK.getAllEverActiveEdges();
List<T> cacheEntries = getCacheEntries(pCacheEntryClass); if (!allEverActiveEdges.contains(pEdge)) {
return null;
}
if (cacheEntries == null) { List<T> cacheEntries = getCacheEntries(pCacheEntryClass);
return null;
}
Map<Class<? extends Object>, List<PointInformation>> similarCacheEntries = new HashMap<>(); if (cacheEntries == null) {
return null;
}
for (T t : cacheEntries) { Map<Class<? extends Object>, List<PointInformation>> similarCacheEntries = new HashMap<>();
Object position = getEdgeOrPosition(t);
if (position.equals(pEdge) && (pCacheValueClass == null || t.getValue().getClass().equals(pCacheValueClass))) { for (T t : cacheEntries) {
if (!similarCacheEntries.containsKey(t.getValue().getClass())) { if (pWithoutID == null || !t.getAttribute(AvailableInformationAttributes.OWNER).equals(pWithoutID)) {
similarCacheEntries.put(t.getValue().getClass(), new ArrayList<PointInformation>()); Object position = getEdgeOrPosition(t);
}
similarCacheEntries.get(t.getValue().getClass()).add(t);
}
} if (position.equals(pEdge) && (pCacheValueClass == null || t.getValue().getClass().equals(pCacheValueClass))) {
if (!similarCacheEntries.containsKey(t.getValue().getClass())) {
similarCacheEntries.put(t.getValue().getClass(), new ArrayList<PointInformation>());
}
similarCacheEntries.get(t.getValue().getClass()).add(t);
}
}
}
List<T> decidedInformation = new ArrayList<>(); List<T> decidedInformation = new ArrayList<>();
for (List<PointInformation> similarInformation : similarCacheEntries.values()) { for (List<PointInformation> similarInformation : similarCacheEntries.values()) {
if (similarInformation.size() >= _minObservations) { if (similarInformation.size() >= _minObservations) {
PointInformation correctInformation = decisionStrategy PointInformation correctInformation = decisionStrategy
.decideOnCorrectInformation(similarInformation); .decideOnCorrectInformation(similarInformation);
decidedInformation.add((T) correctInformation); decidedInformation.add((T) correctInformation);
} }
} }
return decidedInformation; return decidedInformation;
} }
private <T extends PointInformation> CacheDecisionStrategy getCacheDecisionStrategy(Class<T> pCacheEntryClass) private <T extends PointInformation> CacheDecisionStrategy getCacheDecisionStrategy(Class<T> pCacheEntryClass)
......
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