Commit 34cb9024 authored by Julian Zobel's avatar Julian Zobel
Browse files

Bugfix for empty battery UAV failure (crash!)

parent af397019
......@@ -131,7 +131,7 @@ public class ActuatorEnergyComponent implements EnergyComponent {
@Override
public boolean isOn() {
if(!currentState.equals(OFF))
if(!currentState.equals(OFF) && isAvailable())
{
doStateChange(FLY);
return true;
......
......@@ -25,6 +25,7 @@ import de.tud.kom.p2psim.api.energy.Battery;
import de.tud.kom.p2psim.api.energy.EnergyComponent;
import de.tud.kom.p2psim.api.energy.EnergyEventListener;
import de.tud.kom.p2psim.api.network.SimNetInterface;
import de.tud.kom.p2psim.impl.energy.components.ActuatorEnergyComponent;
/**
* Energy Model based on multiple exchangeable components. Each component states the amount of consumed energy,
......@@ -59,6 +60,10 @@ public class ComponentBasedEnergyModel extends AbstractEnergyModel implements En
monitorEmptyBattery();
if(component instanceof ActuatorEnergyComponent) {
((ActuatorEnergyComponent) component).turnOff();
}
/*
* Battery is now empty. Go offline.
*/
......
......@@ -137,7 +137,14 @@ public class UAVTopologyComponent extends AbstractTopologyComponent implements S
@Override
public boolean isActive() {
return actuator.isOn();
if(actuator.isOn())
return true;
else {
if(state == UAVstate.ACTION || state == UAVstate.RETURN) {
this.deactivate();
}
return false;
}
}
@Override
......@@ -279,9 +286,7 @@ public class UAVTopologyComponent extends AbstractTopologyComponent implements S
}
public void setControllerInterface(UAVToBaseInterface controllerInterface) {
this.controllerInterface = controllerInterface;
this.connectToBase(null);
this.controllerInterface = controllerInterface;
}
@Override
......
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