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
38885049
Commit
38885049
authored
Oct 20, 2016
by
Björn Richerzhagen
Browse files
Exposed TComp movement model and attraction points for REST-demo
parent
99f01b63
Changes
5
Hide whitespace changes
Inline
Side-by-side
src/de/tud/kom/p2psim/impl/topology/DefaultTopologyComponent.java
View file @
38885049
...
...
@@ -202,6 +202,14 @@ public class DefaultTopologyComponent implements TopologyComponent {
public
Topology
getTopology
()
{
return
topology
;
}
/**
* Access to the movement model
* @return
*/
public
MovementModel
getMovementModel
()
{
return
movementModel
;
}
@Override
public
double
getMinMovementSpeed
()
{
...
...
src/de/tud/kom/p2psim/impl/topology/movement/modularosm/ModularMovementModel.java
View file @
38885049
...
...
@@ -31,6 +31,8 @@ import java.util.Vector;
import
javax.swing.JComponent
;
import
org.w3c.dom.Attr
;
import
de.tud.kom.p2psim.api.scenario.ConfigurationException
;
import
de.tud.kom.p2psim.api.topology.Topology
;
import
de.tud.kom.p2psim.api.topology.TopologyComponent
;
...
...
@@ -53,6 +55,7 @@ import de.tudarmstadt.maki.simonstrator.api.Event;
import
de.tudarmstadt.maki.simonstrator.api.EventHandler
;
import
de.tudarmstadt.maki.simonstrator.api.Randoms
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.location.Location
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.location.LocationActuator
;
/**
* Modular Movement Model uses different models/strategies to create a movement
...
...
@@ -178,9 +181,19 @@ public class ModularMovementModel implements MovementModel, EventHandler {
public
void
changeTargetLocation
(
SimLocationActuator
actuator
,
double
longitude
,
double
latitude
)
{
/*
* Set a new target AP for the current actuator
* Set a new target AP for the current actuator
(or assign to an AP close by)
*/
transition
.
updateTargetAttractionPoint
(
actuator
,
new
AttractionPoint
((
int
)
longitude
,
(
int
)
latitude
,
""
));
AttractionPoint
apFound
=
null
;
for
(
AttractionPoint
ap
:
transition
.
getAllAttractionPoints
())
{
if
(
ap
.
getRealPosition
().
distanceTo
(
new
PositionVector
(
longitude
,
latitude
))
<
1
)
{
apFound
=
ap
;
break
;
}
}
if
(
apFound
==
null
)
{
apFound
=
new
AttractionPoint
((
int
)
longitude
,
(
int
)
latitude
,
""
);
}
transition
.
updateTargetAttractionPoint
(
actuator
,
apFound
);
}
private
void
checkConfiguration
()
{
...
...
@@ -305,8 +318,16 @@ public class ModularMovementModel implements MovementModel, EventHandler {
*
* @return
*/
protected
List
<
AttractionPoint
>
getAttractionPoints
()
{
return
new
Vector
<
AttractionPoint
>(
attractionGenerator
.
getAttractionPoints
());
public
List
<
AttractionPoint
>
getAttractionPoints
()
{
return
new
Vector
<
AttractionPoint
>(
transition
.
getAllAttractionPoints
());
}
/**
* Only for visualization
* @param actuator
* @return
*/
public
AttractionPoint
getCurrentAttractionPoint
(
LocationActuator
actuator
)
{
return
transition
.
getAssignments
().
get
(
actuator
);
}
}
src/de/tud/kom/p2psim/impl/topology/movement/modularosm/transition/FixedAssignmentStrategy.java
View file @
38885049
...
...
@@ -65,6 +65,11 @@ public class FixedAssignmentStrategy implements ITransitionStrategy {
public
void
setAttractionPoints
(
List
<
AttractionPoint
>
attractionPoints
)
{
aPoints
.
addAll
(
attractionPoints
);
}
@Override
public
List
<
AttractionPoint
>
getAllAttractionPoints
()
{
return
aPoints
;
}
@Override
public
void
addComponent
(
SimLocationActuator
ms
)
{
...
...
src/de/tud/kom/p2psim/impl/topology/movement/modularosm/transition/ITransitionStrategy.java
View file @
38885049
...
...
@@ -47,6 +47,12 @@ public interface ITransitionStrategy {
* @param attractionPoints
*/
public
void
setAttractionPoints
(
List
<
AttractionPoint
>
attractionPoints
);
/**
* Return a list of all attraction points
* @return
*/
public
List
<
AttractionPoint
>
getAllAttractionPoints
();
/**
* Add the object and assign the MS to an {@link AttractionPoint}.
...
...
src/de/tud/kom/p2psim/impl/topology/movement/modularosm/transition/SocialTransitionStrategy.java
View file @
38885049
...
...
@@ -160,6 +160,11 @@ public class SocialTransitionStrategy implements ITransitionStrategy,
init
();
aPoints
.
addAll
(
attractionPoints
);
}
@Override
public
List
<
AttractionPoint
>
getAllAttractionPoints
()
{
return
aPoints
;
}
@Override
public
void
addComponent
(
SimLocationActuator
ms
)
{
...
...
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