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;
import java.util.Set;
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.network.NetInterface;
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.transport.ConnectivityListener;
import de.tudarmstadt.maki.simonstrator.api.component.vehicular.VehicleInformationComponent;
......@@ -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.RoadNetworkEdge;
import de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.RoadNetworkRoute;
import de.tudresden.sumo.cmd.Simulation;
public class DefaultCachingComponent implements CachingComponent, ConnectivityListener {
......@@ -158,45 +156,52 @@ public class DefaultCachingComponent implements CachingComponent, ConnectivityLi
@Override
public <T extends PointInformation> List<T> getDecidedCacheEntries(
Class<T> pCacheEntryClass, Class<?> pCacheValueClass, RoadNetworkEdge pEdge) {
CacheDecisionStrategy decisionStrategy = getCacheDecisionStrategy(pCacheEntryClass);
Set<RoadNetworkEdge> allEverActiveEdges = RoadNetwork.CURRENT_ROAD_NETWORK.getAllEverActiveEdges();
return getDecidedCacheEntries(pCacheEntryClass, pCacheValueClass, pEdge, null);
}
if (!allEverActiveEdges.contains(pEdge)) {
return null;
}
@Override
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) {
return null;
}
List<T> cacheEntries = getCacheEntries(pCacheEntryClass);
Map<Class<? extends Object>, List<PointInformation>> similarCacheEntries = new HashMap<>();
if (cacheEntries == null) {
return null;
}
for (T t : cacheEntries) {
Object position = getEdgeOrPosition(t);
Map<Class<? extends Object>, List<PointInformation>> similarCacheEntries = new HashMap<>();
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);
}
for (T t : cacheEntries) {
if (pWithoutID == null || !t.getAttribute(AvailableInformationAttributes.OWNER).equals(pWithoutID)) {
Object position = getEdgeOrPosition(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()) {
if (similarInformation.size() >= _minObservations) {
PointInformation correctInformation = decisionStrategy
.decideOnCorrectInformation(similarInformation);
for (List<PointInformation> similarInformation : similarCacheEntries.values()) {
if (similarInformation.size() >= _minObservations) {
PointInformation correctInformation = decisionStrategy
.decideOnCorrectInformation(similarInformation);
decidedInformation.add((T) correctInformation);
}
}
decidedInformation.add((T) correctInformation);
}
}
return decidedInformation;
return decidedInformation;
}
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