Commit 7f590a14 authored by Julian Zobel's avatar Julian Zobel
Browse files

sim iscram

parent 125d6756
...@@ -23,6 +23,7 @@ package de.tud.kom.p2psim.impl.topology.movement; ...@@ -23,6 +23,7 @@ package de.tud.kom.p2psim.impl.topology.movement;
import java.io.File; import java.io.File;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Scanner; import java.util.Scanner;
...@@ -42,6 +43,7 @@ import de.tud.kom.p2psim.impl.topology.views.VisualizationTopologyView.Visualiza ...@@ -42,6 +43,7 @@ import de.tud.kom.p2psim.impl.topology.views.VisualizationTopologyView.Visualiza
import de.tudarmstadt.maki.simonstrator.api.Event; import de.tudarmstadt.maki.simonstrator.api.Event;
import de.tudarmstadt.maki.simonstrator.api.EventHandler; import de.tudarmstadt.maki.simonstrator.api.EventHandler;
import de.tudarmstadt.maki.simonstrator.api.Monitor; import de.tudarmstadt.maki.simonstrator.api.Monitor;
import de.tudarmstadt.maki.simonstrator.api.Monitor.Level;
import de.tudarmstadt.maki.simonstrator.api.Time; import de.tudarmstadt.maki.simonstrator.api.Time;
import de.tudarmstadt.maki.simonstrator.api.component.LifecycleComponent; import de.tudarmstadt.maki.simonstrator.api.component.LifecycleComponent;
...@@ -75,13 +77,17 @@ public class TracefileMovementModel implements MovementModel, EventHandler { ...@@ -75,13 +77,17 @@ public class TracefileMovementModel implements MovementModel, EventHandler {
private final LinkedHashMap<SimLocationActuator, LinkedList<Step>> components; private final LinkedHashMap<SimLocationActuator, LinkedList<Step>> components;
private final static LinkedHashMap<SimLocationActuator, Integer> componentToStepSize = new LinkedHashMap<SimLocationActuator, Integer>(); private final static LinkedHashMap<SimLocationActuator, Integer> componentToStepSize = new LinkedHashMap<SimLocationActuator, Integer>();
private final LinkedHashSet<SimLocationActuator> unusedComponents;
private LinkedList<File> tracefiles; private LinkedList<File> tracefiles;
private boolean first = true; private boolean first = true;
public TracefileMovementModel() { public TracefileMovementModel() {
components = new LinkedHashMap<SimLocationActuator, LinkedList<Step>>(); components = new LinkedHashMap<SimLocationActuator, LinkedList<Step>>();
tracefiles = new LinkedList<File>();
tracefiles = new LinkedList<File>();
unusedComponents = new LinkedHashSet<SimLocationActuator>();
} }
public void initialize() { public void initialize() {
...@@ -127,7 +133,11 @@ public class TracefileMovementModel implements MovementModel, EventHandler { ...@@ -127,7 +133,11 @@ public class TracefileMovementModel implements MovementModel, EventHandler {
if(first) { if(first) {
components.forEach((component, steps) -> { components.forEach((component, steps) -> {
shutdownComponent(component); shutdownComponent(component);
}); });
unusedComponents.forEach((component) -> {
shutdownComponent(component);
});
} }
// as the files contain the timestamp in seconds, the current time needs to be converted in seconds // as the files contain the timestamp in seconds, the current time needs to be converted in seconds
...@@ -292,7 +302,10 @@ public class TracefileMovementModel implements MovementModel, EventHandler { ...@@ -292,7 +302,10 @@ public class TracefileMovementModel implements MovementModel, EventHandler {
private void associateTracefile(SimLocationActuator actuator) { private void associateTracefile(SimLocationActuator actuator) {
if(tracefiles.isEmpty()) { if(tracefiles.isEmpty()) {
throw new UnsupportedOperationException("List of tracefiles is empty, thus cannot initiate the component!"); Monitor.log(this.getClass(), Level.WARN, "No unassociated trace file available. Skip.", actuator);
//throw new UnsupportedOperationException("List of tracefiles is empty, thus cannot initiate the component!");
unusedComponents.add(actuator);
return;
} }
if(components.containsKey(actuator)) { if(components.containsKey(actuator)) {
...@@ -364,7 +377,7 @@ public class TracefileMovementModel implements MovementModel, EventHandler { ...@@ -364,7 +377,7 @@ public class TracefileMovementModel implements MovementModel, EventHandler {
this.attractionpointVisualization = viz; this.attractionpointVisualization = viz;
} }
public void setIAttractionGenerator(IAttractionProvider attractionGenerator) { public void setIAttractionProvider(IAttractionProvider attractionGenerator) {
if (attractionGenerator == null) { if (attractionGenerator == null) {
throw new ConfigurationException( throw new ConfigurationException(
"AttractionGenerator is missing in ModularMovementModel!"); "AttractionGenerator is missing in ModularMovementModel!");
......
...@@ -101,7 +101,7 @@ public class AttractionPointViz extends JComponent ...@@ -101,7 +101,7 @@ public class AttractionPointViz extends JComponent
drawAttractionPoints(g2); drawAttractionPoints(g2);
} }
if(true) { if(false) {
drawClusters(g2); drawClusters(g2);
} }
} }
...@@ -126,8 +126,13 @@ public class AttractionPointViz extends JComponent ...@@ -126,8 +126,13 @@ public class AttractionPointViz extends JComponent
for (LinkedList<SimHost> group : clusters) { for (LinkedList<SimHost> group : clusters) {
g2.setColor(colors.get(clusters.indexOf(group))); try {
g2.setColor(colors.get(clusters.indexOf(group)));
}
catch (Exception e) {
g2.setColor(Color.black);
}
for (SimHost member : group) { for (SimHost member : group) {
PositionVector p = member.getTopologyComponent().getRealPosition(); PositionVector p = member.getTopologyComponent().getRealPosition();
......
...@@ -24,7 +24,6 @@ import java.io.FileInputStream; ...@@ -24,7 +24,6 @@ import java.io.FileInputStream;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.io.IOException; import java.io.IOException;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
import org.json.JSONArray; import org.json.JSONArray;
import org.json.JSONException; import org.json.JSONException;
......
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