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
af397019
Commit
af397019
authored
Sep 25, 2018
by
Julian Zobel
Browse files
Public battery replacement request function with callback
parent
d3e62a60
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/de/tud/kom/p2psim/api/topology/component/ControllableLocationActuator.java
View file @
af397019
...
...
@@ -28,6 +28,7 @@ import de.tud.kom.p2psim.impl.topology.util.PositionVector;
import
de.tudarmstadt.maki.simonstrator.api.uavsupport.Actuator
;
import
de.tudarmstadt.maki.simonstrator.api.uavsupport.callbacks.BaseConnectedCallback
;
import
de.tudarmstadt.maki.simonstrator.api.uavsupport.callbacks.BaseDisconnectedCallback
;
import
de.tudarmstadt.maki.simonstrator.api.uavsupport.callbacks.BatteryReplacementCallback
;
import
de.tudarmstadt.maki.simonstrator.api.uavsupport.callbacks.ReachedLocationCallback
;
/**
...
...
@@ -60,6 +61,8 @@ public interface ControllableLocationActuator extends Actuator {
public
void
removeAllTargetLocations
();
public
void
batteryReplacement
(
BatteryReplacementCallback
cb
);
public
void
returnToBase
(
ReachedLocationCallback
cb
);
public
void
connectToBase
(
BaseConnectedCallback
cb
);
...
...
src/de/tud/kom/p2psim/impl/topology/component/UAVTopologyComponent.java
View file @
af397019
...
...
@@ -44,6 +44,7 @@ import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.Location;
import
de.tudarmstadt.maki.simonstrator.api.uavsupport.UAVToBaseInterface
;
import
de.tudarmstadt.maki.simonstrator.api.uavsupport.callbacks.BaseConnectedCallback
;
import
de.tudarmstadt.maki.simonstrator.api.uavsupport.callbacks.BaseDisconnectedCallback
;
import
de.tudarmstadt.maki.simonstrator.api.uavsupport.callbacks.BatteryReplacementCallback
;
import
de.tudarmstadt.maki.simonstrator.api.uavsupport.callbacks.ReachedLocationCallback
;
/**
...
...
@@ -54,7 +55,7 @@ import de.tudarmstadt.maki.simonstrator.api.uavsupport.callbacks.ReachedLocation
*/
public
class
UAVTopologyComponent
extends
AbstractTopologyComponent
implements
SimUAVLocationActuator
{
public
enum
UAVstate
{
OFFLINE
,
ACTION
,
RETURN
,
CRASHED
}
public
enum
UAVstate
{
OFFLINE
,
BASE_CONNECTION
,
ACTION
,
RETURN
,
CRASHED
}
private
UAVMovementModel
movement
;
...
...
@@ -268,15 +269,19 @@ public class UAVTopologyComponent extends AbstractTopologyComponent implements S
movement
.
setTargetLocation
(
baseLocation
,
returnCallback
);
}
protected
void
batteryReplacement
()
{
public
void
batteryReplacement
(
BatteryReplacementCallback
cb
)
{
if
(
state
!=
UAVstate
.
BASE_CONNECTION
)
throw
new
UnsupportedOperationException
(
"Cannot recharge if not connected to base!"
);
BaseTopologyComponent
base
=
UAVBasePlacement
.
base
;
base
.
getCharger
().
charge
(
this
,
null
);
base
.
getCharger
().
charge
(
this
,
cb
);
}
public
void
setControllerInterface
(
UAVToBaseInterface
controllerInterface
)
{
this
.
controllerInterface
=
controllerInterface
;
UAVBasePlacement
.
base
.
connect
UAV
ToBase
(
this
.
controllerInterface
);
state
=
UAVstate
.
OFFLINE
;
this
.
connectToBase
(
null
);
}
@Override
...
...
@@ -286,6 +291,8 @@ public class UAVTopologyComponent extends AbstractTopologyComponent implements S
if
(
cb
!=
null
)
cb
.
successfulConnection
();
this
.
state
=
UAVstate
.
BASE_CONNECTION
;
}
@Override
...
...
@@ -295,6 +302,8 @@ public class UAVTopologyComponent extends AbstractTopologyComponent implements S
if
(
cb
!=
null
)
cb
.
successfulDisconnection
();
this
.
state
=
UAVstate
.
OFFLINE
;
}
...
...
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