Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Simonstrator
PeerfactSim.KOM
Commits
34cb9024
Commit
34cb9024
authored
Sep 25, 2018
by
Julian Zobel
Browse files
Bugfix for empty battery UAV failure (crash!)
parent
af397019
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/de/tud/kom/p2psim/impl/energy/components/ActuatorEnergyComponent.java
View file @
34cb9024
...
...
@@ -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
;
...
...
src/de/tud/kom/p2psim/impl/energy/models/ComponentBasedEnergyModel.java
View file @
34cb9024
...
...
@@ -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.
*/
...
...
src/de/tud/kom/p2psim/impl/topology/component/UAVTopologyComponent.java
View file @
34cb9024
...
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment