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
a17bcd3f
Commit
a17bcd3f
authored
Jun 27, 2017
by
Tobias Meuser
Committed by
Jose Ignacio Monreal Bailey
Aug 20, 2019
Browse files
Added functionality to reroute vehicles to VehicleInformationComponent
parent
ccf2a6ee
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/de/tud/kom/p2psim/impl/topology/movement/vehicular/sumo/simulation/controller/VehicleController.java
View file @
a17bcd3f
...
...
@@ -3,7 +3,10 @@ package de.tud.kom.p2psim.impl.topology.movement.vehicular.sumo.simulation.contr
import
java.util.List
;
import
de.tud.kom.p2psim.impl.topology.movement.vehicular.information.Position
;
import
de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.RoadNetworkEdge
;
import
de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.RoadNetworkRoute
;
import
de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.exception.NoAdditionalRouteAvailableException
;
import
de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.exception.NoExitAvailableException
;
public
interface
VehicleController
{
void
setObservedArea
(
double
pStartX
,
double
pStartY
,
double
pEndX
,
double
pEndY
);
...
...
@@ -20,10 +23,16 @@ public interface VehicleController {
double
getMaximumAvailablePrediction
();
void
rerouteVehicle
(
String
pVehicle
,
RoadNetworkRoute
pRoute
);
RoadNetworkRoute
findNewRoute
(
String
pVehicle
)
throws
NoAdditionalRouteAvailableException
;
RoadNetworkRoute
findNewRoute
(
String
pVehicle
,
List
<
RoadNetworkEdge
>
pEdgesToAvoid
,
boolean
pKeepDestination
)
throws
NoAdditionalRouteAvailableException
,
NoExitAvailableException
;
double
getStep
();
double
getStart
();
void
init
();
}
src/de/tud/kom/p2psim/impl/topology/movement/vehicular/sumo/simulation/controller/traci/TraciSimulationController.java
View file @
a17bcd3f
...
...
@@ -414,6 +414,7 @@ public class TraciSimulationController implements VehicleController, SimulationS
return
_roadNetwork
;
}
@Override
public
RoadNetworkRoute
findNewRoute
(
String
pVehicle
)
throws
NoAdditionalRouteAvailableException
{
List
<
RoadNetworkRoute
>
routes
=
new
ArrayList
<>();
RoadNetworkRoute
route
=
getCurrentRoute
(
pVehicle
);
...
...
@@ -425,6 +426,7 @@ public class TraciSimulationController implements VehicleController, SimulationS
return
findRoute
;
}
@Override
public
RoadNetworkRoute
findNewRoute
(
String
pVehicle
,
List
<
RoadNetworkEdge
>
pEdgesToAvoid
,
boolean
pKeepDestination
)
throws
NoAdditionalRouteAvailableException
,
NoExitAvailableException
{
if
(
pKeepDestination
)
{
List
<
RoadNetworkRoute
>
routes
=
new
ArrayList
<>();
...
...
@@ -473,6 +475,7 @@ public class TraciSimulationController implements VehicleController, SimulationS
}
}
@Override
public
void
rerouteVehicle
(
String
pVehicle
,
RoadNetworkRoute
pRoute
)
{
SumoStringList
routeEdges
=
new
SumoStringList
();
for
(
RoadNetworkEdge
edge
:
pRoute
.
getRoute
())
{
...
...
src/de/tud/kom/p2psim/impl/vehicular/DefaultVehicleInformationComponent.java
View file @
a17bcd3f
...
...
@@ -20,11 +20,16 @@
package
de.tud.kom.p2psim.impl.vehicular
;
import
java.util.List
;
import
de.tud.kom.p2psim.impl.topology.movement.vehicular.sumo.simulation.controller.SimulationSetupExtractor
;
import
de.tud.kom.p2psim.impl.topology.movement.vehicular.sumo.simulation.controller.VehicleController
;
import
de.tudarmstadt.maki.simonstrator.api.Host
;
import
de.tudarmstadt.maki.simonstrator.api.component.vehicular.VehicleInformationComponent
;
import
de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.RoadNetworkEdge
;
import
de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.RoadNetworkRoute
;
import
de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.exception.NoAdditionalRouteAvailableException
;
import
de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.exception.NoExitAvailableException
;
public
class
DefaultVehicleInformationComponent
implements
VehicleInformationComponent
{
...
...
@@ -74,4 +79,30 @@ public class DefaultVehicleInformationComponent implements VehicleInformationCom
return
controller
.
getCurrentRoute
(
vehicleID
);
}
@Override
public
boolean
changeCurrentRoute
(
RoadNetworkRoute
pRoute
)
{
controller
.
rerouteVehicle
(
vehicleID
,
pRoute
);
return
true
;
}
@Override
public
RoadNetworkRoute
findNewRoute
()
{
try
{
return
controller
.
findNewRoute
(
vehicleID
);
}
catch
(
NoAdditionalRouteAvailableException
e
)
{
return
null
;
}
}
@Override
public
RoadNetworkRoute
findNewRoute
(
List
<
RoadNetworkEdge
>
pEdgesToAvoid
,
boolean
pKeepDestination
)
{
try
{
return
controller
.
findNewRoute
(
vehicleID
,
pEdgesToAvoid
,
pKeepDestination
);
}
catch
(
NoAdditionalRouteAvailableException
|
NoExitAvailableException
e
)
{
return
null
;
}
}
}
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