Commit 465f18d1 authored by Julian Zobel's avatar Julian Zobel
Browse files

Static attraction point retrieval from ap generator (hack)

parent 2e075ebb
......@@ -23,6 +23,8 @@ package de.tud.kom.p2psim.impl.topology.component;
import java.util.LinkedList;
import java.util.Set;
import org.apache.batik.bridge.AbstractSVGGradientElementBridge.Stop;
import de.tud.kom.p2psim.api.common.SimHost;
import de.tud.kom.p2psim.api.energy.ComponentType;
import de.tud.kom.p2psim.api.energy.EnergyModel;
......@@ -65,7 +67,7 @@ public class UAVTopologyComponent extends AbstractTopologyComponent implements S
private ActuatorEnergyComponent actuator;
private RechargeableBattery battery;
private UAVstate state;
private UAVstate state = UAVstate.OFFLINE;
private PositionVector baseLocation;
private UAVToBaseInterface controllerInterface;
......@@ -162,22 +164,20 @@ public class UAVTopologyComponent extends AbstractTopologyComponent implements S
@Override
public boolean deactivate() {
actuator.turnOff();
if(this.position.getAltitude() != 0) {
state = UAVstate.CRASHED;
System.err.println("UAV was destroyed due to actuator deactivation during flight");
uavOverlayComponent.shutdown();
for (SimNetInterface net : getHost().getNetworkComponent()
.getSimNetworkInterfaces()) {
net.goOffline();
}
uavOverlayComponent.shutdown();
shutdownCommunication();
}
else {
state = UAVstate.OFFLINE;
}
return true;
}
......@@ -299,10 +299,14 @@ public class UAVTopologyComponent extends AbstractTopologyComponent implements S
cb.successfulConnection();
this.state = UAVstate.BASE_CONNECTION;
shutdownCommunication();
}
@Override
public void disconnectFromBase(BaseDisconnectedCallback cb) {
startCommunication();
BaseTopologyComponent base = UAVBasePlacement.base;
base.disconnectUAVFromBase(controllerInterface);
......@@ -312,7 +316,14 @@ public class UAVTopologyComponent extends AbstractTopologyComponent implements S
this.state = UAVstate.OFFLINE;
}
private void shutdownCommunication() {
for (SimNetInterface net : getHost().getNetworkComponent().getSimNetworkInterfaces())
net.goOffline();
}
private void startCommunication() {
for (SimNetInterface net : getHost().getNetworkComponent().getSimNetworkInterfaces())
net.goOnline();
}
}
......@@ -20,6 +20,7 @@
package de.tud.kom.p2psim.impl.topology.movement.modularosm.attraction;
import java.util.LinkedList;
import java.util.List;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.AttractionPoint;
......@@ -32,6 +33,8 @@ import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.Attraction
*/
public interface IAttractionGenerator {
public static LinkedList<AttractionPoint> attractionPoints = new LinkedList<>();
public List<AttractionPoint> getAttractionPoints();
}
......@@ -51,8 +51,6 @@ public class RandomAttractionGenerator implements IAttractionGenerator {
private boolean numberOfAPsSet = false;
private List<AttractionPoint> attractionPoints;
@XMLConfigurableConstructor({"numberOfAttractionPoints"})
public RandomAttractionGenerator(int numberOfAttractionPoints) {
this.rand = Randoms.getRandom(RandomAttractionGenerator.class);
......@@ -64,7 +62,7 @@ public class RandomAttractionGenerator implements IAttractionGenerator {
}
this.numberOfAPsSet = true;
this.numberOfAttractionPoints = numberOfAttractionPoints;
this.attractionPoints = new LinkedList<AttractionPoint>();
attractionPoints.clear();
createAttractionPoints();
}
......
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