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
6d17b580
Commit
6d17b580
authored
Aug 10, 2017
by
Björn Richerzhagen
Browse files
Added segment handling
parent
7fc458be
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/de/tud/kom/p2psim/impl/topology/movement/local/RealWorldStreetsMovement.java
View file @
6d17b580
...
...
@@ -185,7 +185,7 @@ public class RealWorldStreetsMovement extends AbstractLocalMovementStrategy {
*/
trajectory
=
new
RouteImpl
(
comp
.
getRealPosition
(),
destination
,
pointList
,
routeSensor
.
getSegmentListeners
(),
routeSensor
.
getSegmentListeners
(),
routeSensor
,
calculateSegments
(
pointList
));
}
else
{
trajectory
=
new
RouteImpl
(
comp
.
getRealPosition
(),
...
...
src/de/tud/kom/p2psim/impl/topology/movement/local/RouteImpl.java
View file @
6d17b580
...
...
@@ -32,6 +32,7 @@ import de.tud.kom.p2psim.api.topology.movement.SimLocationActuator;
import
de.tud.kom.p2psim.impl.topology.PositionVector
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.location.Location
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.route.Route
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.route.RouteSensor
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.route.RouteSensor.RouteSegmentListener
;
/**
...
...
@@ -50,6 +51,8 @@ import de.tudarmstadt.maki.simonstrator.api.component.sensor.route.RouteSensor.R
*/
public
class
RouteImpl
implements
Route
{
private
final
RouteSensor
sensor
;
private
PositionVector
start
;
private
PositionVector
destination
;
...
...
@@ -82,8 +85,9 @@ public class RouteImpl implements Route {
*/
public
RouteImpl
(
PositionVector
start
,
PositionVector
destination
,
PointList
pointList
,
Set
<
RouteSegmentListener
>
segmentListeners
,
Set
<
RouteSegmentListener
>
segmentListeners
,
RouteSensor
sensor
,
List
<
RouteSegmentImpl
>
routeSegments
)
{
this
.
sensor
=
sensor
;
this
.
start
=
start
;
this
.
destination
=
destination
;
this
.
pointList
=
pointList
;
...
...
@@ -108,7 +112,7 @@ public class RouteImpl implements Route {
*/
public
RouteImpl
(
PositionVector
start
,
PositionVector
destination
,
PointList
pointList
)
{
this
(
start
,
destination
,
pointList
,
Collections
.
emptySet
(),
this
(
start
,
destination
,
pointList
,
Collections
.
emptySet
(),
null
,
Collections
.
emptyList
());
}
...
...
@@ -181,8 +185,22 @@ public class RouteImpl implements Route {
}
/*
*
TODO
Segment handling (also inform listeners!)
* Segment handling (also inform listeners!)
*/
if
(
routeSegmentsLength
>
0
&&
routeSegmentsLength
>
currentSegmentIndex
)
{
List
<
RouteSegmentImpl
>
segmentSublist
=
routeSegments
.
subList
(
currentSegmentIndex
+
1
,
routeSegmentsLength
);
for
(
RouteSegmentImpl
candidate
:
segmentSublist
)
{
if
(
candidate
.
getFromRouteIndex
()
>=
currentIndex
)
{
break
;
}
currentSegmentIndex
++;
segmentListeners
.
forEach
(
l
->
l
.
onChangedRouteSegment
(
sensor
,
this
,
routeSegments
.
get
(
currentSegmentIndex
-
1
),
candidate
));
}
}
/*
* Reached target flag
...
...
src/de/tud/kom/p2psim/impl/topology/movement/modularosm/ModularMovementModelViz.java
View file @
6d17b580
...
...
@@ -205,6 +205,9 @@ public class ModularMovementModelViz extends JComponent
public
void
drawTrajectory
(
Graphics2D
g2
)
{
Route
rt
=
routeSensor
.
getRoute
();
if
(!
rt
.
hasSegmentInformation
())
{
return
;
}
for
(
RouteSegment
segment
:
rt
.
getSegmentsAhead
())
{
Location
lastLoc
=
null
;
for
(
Location
loc
:
segment
.
getSegmentLocations
())
{
...
...
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