Commit 930bb6e9 authored by Julian Zobel's avatar Julian Zobel
Browse files

Tracefile movement now correctly activates and deactivates the bypass stuff

parent 5a7c6b8c
......@@ -24,8 +24,10 @@ import java.io.File;
import java.io.FileNotFoundException;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;
import de.tud.kom.p2psim.api.churn.ChurnGenerator;
import de.tud.kom.p2psim.api.network.SimNetInterface;
import de.tud.kom.p2psim.api.network.SimNetworkComponent;
import de.tud.kom.p2psim.api.scenario.ConfigurationException;
......@@ -42,6 +44,7 @@ import de.tudarmstadt.maki.simonstrator.api.Event;
import de.tudarmstadt.maki.simonstrator.api.EventHandler;
import de.tudarmstadt.maki.simonstrator.api.Monitor;
import de.tudarmstadt.maki.simonstrator.api.Time;
import de.tudarmstadt.maki.simonstrator.api.component.LifecycleComponent;
public class TracefileMovementModel implements MovementModel, EventHandler {
......@@ -96,7 +99,7 @@ public class TracefileMovementModel implements MovementModel, EventHandler {
}
initialized = true;
Event.scheduleWithDelay(timeBetweenMoveOperations, this, null, EVENT_MOVE);
}
......@@ -143,13 +146,16 @@ public class TracefileMovementModel implements MovementModel, EventHandler {
}
}
}
else {
else {
step = steps.pop();
if(!DefaultTopology.isWithinWorldBoundaries(component.getRealPosition())) {
component.updateCurrentLocation(new PositionVector(step.x, step.y));
startupComponent(component);
}
step = steps.pop();
component.updateCurrentLocation(new PositionVector(step.x, step.y));
else {
component.updateCurrentLocation(new PositionVector(step.x, step.y));
}
}
}
else {
......@@ -176,14 +182,27 @@ public class TracefileMovementModel implements MovementModel, EventHandler {
}
private void shutdownComponent(SimLocationActuator node) {
node.updateCurrentLocation(new PositionVector(DEFAULT_POSITION));
SimNetworkComponent net = (SimNetworkComponent) node.getHost().getNetworkComponent();
SimNetworkComponent net = (SimNetworkComponent) node.getHost().getNetworkComponent();
for (SimNetInterface netI : net.getSimNetworkInterfaces()) {
if (netI.isOnline()) {
netI.goOffline();
}
}
try {
List<LifecycleComponent> comps = node.getHost().getComponents(LifecycleComponent.class);
for (LifecycleComponent lifecycleComponent : comps) {
lifecycleComponent.stopComponent();
}
} catch (Exception e) {
// TODO: handle exception
}
node.updateCurrentLocation(new PositionVector(DEFAULT_POSITION));
}
private void startupComponent(SimLocationActuator node) {
......@@ -195,6 +214,19 @@ public class TracefileMovementModel implements MovementModel, EventHandler {
netI.goOnline();
}
}
try {
List<LifecycleComponent> comps = node.getHost().getComponents(LifecycleComponent.class);
for (LifecycleComponent lifecycleComponent : comps) {
lifecycleComponent.startComponent();
}
} catch (Exception e) {
// TODO: handle exception
}
}
@Override
......@@ -245,7 +277,7 @@ public class TracefileMovementModel implements MovementModel, EventHandler {
e.printStackTrace();
}
System.out.println(actuator.getHost().getId() + " <> " + tracefile.getName());
// System.out.println(actuator.getHost().getId() + " <> " + tracefile.getName());
components.put(actuator, stepQueue);
}
......
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