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
290a11b9
Commit
290a11b9
authored
Jun 18, 2018
by
Jose Ignacio Monreal Bailey
Browse files
Adding trip output file
parent
24efeba1
Changes
8
Hide whitespace changes
Inline
Side-by-side
pom.xml
View file @
290a11b9
...
...
@@ -382,7 +382,7 @@
<dependency>
<groupId>
TraaS
</groupId>
<artifactId>
TraaS
</artifactId>
<version>
2.
0
</version>
<version>
2.
1
</version>
</dependency>
</dependencies>
...
...
src/de/tud/kom/p2psim/impl/topology/movement/RSUMovementModel.java
View file @
290a11b9
...
...
@@ -53,6 +53,7 @@ public class RSUMovementModel implements MovementModel, EventHandler {
private
final
String
sumoExe
;
private
final
String
sumoConfigFile
;
private
final
String
sumoTripOutputFile
;
private
final
String
sumoIntersections
;
...
...
@@ -76,8 +77,8 @@ public class RSUMovementModel implements MovementModel, EventHandler {
private
static
final
Location
DEFAULT_LOCATION
=
new
PositionVector
(
Double
.
NaN
,
Double
.
NaN
);
@XMLConfigurableConstructor
({
"timeBetweenMoveOperations"
,
"sumoExe"
,
"sumoConfigFile"
,
"offsetX"
,
"offsetY"
,
"width"
,
"height"
})
public
RSUMovementModel
(
long
timeBetweenMoveOperations
,
String
sumoExe
,
String
sumoConfigFile
,
String
offsetX
,
String
offsetY
,
String
width
,
String
height
)
{
@XMLConfigurableConstructor
({
"timeBetweenMoveOperations"
,
"sumoExe"
,
"sumoConfigFile"
,
"sumoTripOutputFile"
,
"offsetX"
,
"offsetY"
,
"width"
,
"height"
})
public
RSUMovementModel
(
long
timeBetweenMoveOperations
,
String
sumoExe
,
String
sumoConfigFile
,
String
sumoTripOutputFile
,
String
offsetX
,
String
offsetY
,
String
width
,
String
height
)
{
this
.
components
=
new
LinkedList
<>();
this
.
idComponentMatcher
=
new
HashMap
<>();
this
.
freeComponents
=
new
LinkedList
<>();
...
...
@@ -88,6 +89,7 @@ public class RSUMovementModel implements MovementModel, EventHandler {
this
.
sumoExe
=
sumoExe
;
this
.
sumoConfigFile
=
sumoConfigFile
;
this
.
sumoTripOutputFile
=
sumoTripOutputFile
;
this
.
sumoIntersections
=
null
;
...
...
@@ -110,6 +112,7 @@ public class RSUMovementModel implements MovementModel, EventHandler {
this
.
sumoExe
=
null
;
this
.
sumoConfigFile
=
null
;
this
.
sumoTripOutputFile
=
null
;
this
.
offsetX
=
Integer
.
parseInt
(
offsetX
);
this
.
offsetY
=
Integer
.
parseInt
(
offsetY
);
...
...
@@ -160,7 +163,7 @@ public class RSUMovementModel implements MovementModel, EventHandler {
Event
.
scheduleWithDelay
(
timeBetweenMoveOperations
,
this
,
null
,
0
);
if
(
this
.
sumoExe
!=
null
)
{
_controller
=
TraciSimulationController
.
createSimulationController
(
sumoExe
,
sumoConfigFile
);
_controller
=
TraciSimulationController
.
createSimulationController
(
sumoExe
,
sumoConfigFile
,
null
);
_controller
.
init
();
_controller
.
setObservedArea
(
offsetX
,
offsetY
,
offsetX
+
width
,
offsetY
+
height
);
_intersections
=
_controller
.
getAllIntersections
(
true
);
...
...
src/de/tud/kom/p2psim/impl/topology/movement/VehicleMovementModel.java
View file @
290a11b9
...
...
@@ -80,6 +80,7 @@ public class VehicleMovementModel implements MovementModel, EventHandler {
private
final
String
sumoExe
;
private
final
String
sumoConfigFile
;
private
final
String
sumoTripOutputFile
;
private
final
String
sumoTrace
;
private
String
sumoIntersections
;
...
...
@@ -102,8 +103,8 @@ public class VehicleMovementModel implements MovementModel, EventHandler {
* @param width The width of the scenario.
* @param height The height of the scenario.
*/
@XMLConfigurableConstructor
({
"timeBetweenMoveOperations"
,
"sumoExe"
,
"sumoConfigFile"
,
"offsetX"
,
"offsetY"
,
"width"
,
"height"
})
public
VehicleMovementModel
(
long
timeBetweenMoveOperations
,
String
sumoExe
,
String
sumoConfigFile
,
String
offsetX
,
String
offsetY
,
String
width
,
String
height
)
{
@XMLConfigurableConstructor
({
"timeBetweenMoveOperations"
,
"sumoExe"
,
"sumoConfigFile"
,
"sumoTripOutputFile"
,
"offsetX"
,
"offsetY"
,
"width"
,
"height"
})
public
VehicleMovementModel
(
long
timeBetweenMoveOperations
,
String
sumoExe
,
String
sumoConfigFile
,
String
sumoTripOutputFile
,
String
offsetX
,
String
offsetY
,
String
width
,
String
height
)
{
MOVEMENT
=
this
;
this
.
timeBetweenMoveOperations
=
timeBetweenMoveOperations
;
...
...
@@ -112,6 +113,7 @@ public class VehicleMovementModel implements MovementModel, EventHandler {
this
.
idComponentMatcher
=
new
HashMap
<>();
this
.
sumoExe
=
sumoExe
;
this
.
sumoConfigFile
=
sumoConfigFile
;
this
.
sumoTripOutputFile
=
sumoTripOutputFile
;
this
.
sumoTrace
=
null
;
this
.
offsetX
=
Integer
.
parseInt
(
offsetX
);
this
.
offsetY
=
Integer
.
parseInt
(
offsetY
);
...
...
@@ -139,6 +141,7 @@ public class VehicleMovementModel implements MovementModel, EventHandler {
this
.
idComponentMatcher
=
new
HashMap
<>();
this
.
sumoExe
=
null
;
this
.
sumoConfigFile
=
null
;
this
.
sumoTripOutputFile
=
null
;
this
.
sumoTrace
=
sumoTrace
;
this
.
sumoIntersections
=
sumoIntersections
;
this
.
offsetX
=
offsetX
;
...
...
@@ -218,7 +221,7 @@ public class VehicleMovementModel implements MovementModel, EventHandler {
Event
.
scheduleWithDelay
(
timeBetweenMoveOperations
,
this
,
null
,
0
);
if
(
sumoExe
!=
null
)
{
TraciSimulationController
simulationController
=
TraciSimulationController
.
createSimulationController
(
sumoExe
,
sumoConfigFile
);
TraciSimulationController
simulationController
=
TraciSimulationController
.
createSimulationController
(
sumoExe
,
sumoConfigFile
,
sumoTripOutputFile
);
_controller
=
simulationController
;
_controller
.
setObservedArea
(
offsetX
,
offsetY
,
offsetX
+
width
,
offsetY
+
height
);
_controller
.
init
();
...
...
src/de/tud/kom/p2psim/impl/topology/movement/vehicular/sumo/simulation/controller/traci/TraciSimulationController.java
View file @
290a11b9
...
...
@@ -54,6 +54,7 @@ public class TraciSimulationController implements VehicleController, SimulationS
private
String
_sumoExe
;
private
String
_configFile
;
private
String
_tripOutputFile
;
private
SumoTraciConnection
_connection
;
...
...
@@ -77,18 +78,20 @@ public class TraciSimulationController implements VehicleController, SimulationS
private
RoutingAlgorithm
_algorithm
=
new
DijkstraAlgorithm
();
public
static
synchronized
TraciSimulationController
createSimulationController
(
String
pSumoExe
,
String
pConfigFile
)
{
public
static
synchronized
TraciSimulationController
createSimulationController
(
String
pSumoExe
,
String
pConfigFile
,
String
pTripOutputFile
)
{
if
(!
CONTROLLER
.
containsKey
(
pConfigFile
))
{
CONTROLLER
.
put
(
pConfigFile
,
new
TraciSimulationController
(
pSumoExe
,
pConfigFile
));
CONTROLLER
.
put
(
pConfigFile
,
new
TraciSimulationController
(
pSumoExe
,
pConfigFile
,
pTripOutputFile
));
}
return
CONTROLLER
.
get
(
pConfigFile
);
}
private
TraciSimulationController
(
String
pSumoExe
,
String
pConfigFile
)
{
private
TraciSimulationController
(
String
pSumoExe
,
String
pConfigFile
,
String
pTripOutputFile
)
{
_sumoExe
=
pSumoExe
;
_configFile
=
pConfigFile
;
_tripOutputFile
=
pTripOutputFile
;
}
public
static
VehicleController
getSimulationController
()
{
return
CONTROLLER
.
values
().
iterator
().
next
();
}
...
...
@@ -104,11 +107,12 @@ public class TraciSimulationController implements VehicleController, SimulationS
// This will only work with the updated version of the TraaS API for sumo
// It is available for download at https://dev.kom.e-technik.tu-darmstadt.de/gitlab/tobiasm/TraaS.git
_connection
=
new
SumoTraciConnection
(
_sumoExe
,
_configFile
,
random
.
nextInt
());
_connection
=
new
SumoTraciConnection
(
_sumoExe
,
_configFile
,
random
.
nextInt
()
,
_tripOutputFile
);
/*
* prevent vehicles form teleporting (http://sumo.dlr.de/wiki/Simulation/Why_Vehicles_are_teleporting)
*/
_connection
.
addOption
(
"time-to-teleport"
,
Integer
.
toString
(-
1
));
_connection
.
printSumoError
(
true
);
try
{
_connection
.
runServer
();
...
...
@@ -135,6 +139,16 @@ public class TraciSimulationController implements VehicleController, SimulationS
}
}
private
double
getVehicleWaitingTime
(
String
vehicleId
)
{
double
waitingTime
=
0
;
SumoCommand
waitingTimeCommand
=
Vehicle
.
getWaitingTime
(
vehicleId
);
Object
waitingTimeObject
=
requestObject
(
waitingTimeCommand
);
waitingTime
=
(
double
)
waitingTimeObject
;
return
waitingTime
;
}
@Override
public
Location
getVehiclePosition
(
String
pVehicleID
)
{
return
_positons
.
get
(
pVehicleID
).
getPosition
();
...
...
@@ -278,9 +292,7 @@ public class TraciSimulationController implements VehicleController, SimulationS
public
String
getVehicleType
(
String
pVehicleID
)
{
String
vehicleType
=
"default"
;
SumoCommand
typeCommand
=
Vehicle
.
getTypeID
(
pVehicleID
);
Object
typeObject
=
requestObject
(
typeCommand
);
if
(
typeObject
!=
null
)
{
...
...
@@ -302,6 +314,15 @@ public class TraciSimulationController implements VehicleController, SimulationS
execute
(
typeCommand
);
}
@Override
public
long
getWaitingTime
(
String
vehicleID
)
{
SumoCommand
waitingTimeCommand
=
Vehicle
.
getWaitingTime
(
vehicleID
);
Object
waitingTimeObject
=
requestObject
(
waitingTimeCommand
);
String
waitingTime
=
(
String
)
waitingTimeObject
;
return
Long
.
parseLong
(
waitingTime
);
}
@Override
public
void
setVehicleMaxSpeed
(
String
pVehicleID
,
double
pVehicleSpeed
)
{
SumoCommand
maxSpeedCommand
=
Vehicle
.
setMaxSpeed
(
pVehicleID
,
pVehicleSpeed
);
...
...
src/de/tud/kom/p2psim/impl/topology/movement/vehicular/sumo/simulation/controller/xml/XMLSimulationController.java
View file @
290a11b9
...
...
@@ -289,6 +289,11 @@ public class XMLSimulationController implements VehicleController, SimulationSet
_vehicleDataInformationHandler
.
getVehiclePositions
().
get
(
pVehicleID
).
setGap
(
gap
);
}
@Override
public
long
getWaitingTime
(
String
vehicleID
)
{
return
0
;
}
@Override
public
void
setVehicleMaxSpeed
(
String
pVehicleID
,
double
pVehicleSpeed
)
{
_vehicleDataInformationHandler
.
getVehiclePositions
().
get
(
pVehicleID
).
setSpeed
(
pVehicleSpeed
);
...
...
src/de/tud/kom/p2psim/impl/topology/placement/RSUPlacement.java
View file @
290a11b9
...
...
@@ -37,6 +37,7 @@ public class RSUPlacement implements PlacementModel {
private
final
String
sumoExe
;
private
final
String
sumoConfigFile
;
private
final
String
sumoTripInfoOutputFile
;
private
final
String
sumoIntersections
;
...
...
@@ -50,10 +51,11 @@ public class RSUPlacement implements PlacementModel {
private
List
<
Location
>
_intersections
;
private
int
_currentIndex
=
0
;
@XMLConfigurableConstructor
({
"sumoExe"
,
"sumoConfigFile"
,
"offsetX"
,
"offsetY"
,
"width"
,
"height"
})
public
RSUPlacement
(
String
sumoExe
,
String
sumoConfigFile
,
String
offsetX
,
String
offsetY
,
String
width
,
String
height
)
{
@XMLConfigurableConstructor
({
"sumoExe"
,
"sumoConfigFile"
,
"sumoTripOutputFile"
,
"offsetX"
,
"offsetY"
,
"width"
,
"height"
})
public
RSUPlacement
(
String
sumoExe
,
String
sumoConfigFile
,
String
sumoTripInfoOutputFile
,
String
offsetX
,
String
offsetY
,
String
width
,
String
height
)
{
this
.
sumoExe
=
sumoExe
;
this
.
sumoConfigFile
=
sumoConfigFile
;
this
.
sumoTripInfoOutputFile
=
sumoTripInfoOutputFile
;
this
.
sumoIntersections
=
null
;
...
...
@@ -71,6 +73,7 @@ public class RSUPlacement implements PlacementModel {
this
.
sumoExe
=
null
;
this
.
sumoConfigFile
=
null
;
this
.
sumoTripInfoOutputFile
=
null
;
this
.
offsetX
=
Integer
.
parseInt
(
offsetX
);
this
.
offsetY
=
Integer
.
parseInt
(
offsetY
);
...
...
@@ -86,7 +89,7 @@ public class RSUPlacement implements PlacementModel {
*/
protected
void
initializeModel
()
{
if
(
this
.
sumoExe
!=
null
)
{
_controller
=
TraciSimulationController
.
createSimulationController
(
sumoExe
,
sumoConfigFile
);
_controller
=
TraciSimulationController
.
createSimulationController
(
sumoExe
,
sumoConfigFile
,
sumoTripInfoOutputFile
);
_controller
.
init
();
_controller
.
setObservedArea
(
offsetX
,
offsetY
,
offsetX
+
width
,
offsetY
+
height
);
_intersections
=
_controller
.
getAllIntersections
(
true
);
...
...
src/de/tud/kom/p2psim/impl/topology/placement/TrafficLightPlacementModel.java
View file @
290a11b9
...
...
@@ -44,7 +44,7 @@ public class TrafficLightPlacementModel implements PlacementModel, EventHandler
protected
void
initializeModel
()
{
if
(
this
.
sumoExe
!=
null
)
{
controller
=
TraciSimulationController
.
createSimulationController
(
sumoExe
,
sumoConfigFile
);
controller
=
TraciSimulationController
.
createSimulationController
(
sumoExe
,
sumoConfigFile
,
null
);
controller
.
init
();
controller
.
setObservedArea
(
offsetX
,
offsetY
,
offsetX
+
width
,
offsetY
+
height
);
intersections
=
controller
.
getAllIntersections
(
true
);
...
...
src/de/tud/kom/p2psim/impl/vehicular/DefaultVehicleInformationComponent.java
View file @
290a11b9
...
...
@@ -149,6 +149,11 @@ public class DefaultVehicleInformationComponent implements VehicleInformationCom
controller
.
setVehicleMaxSpeed
(
vehicleID
,
vehicleSpeed
);
}
@Override
public
long
getWaitingTime
()
{
return
controller
.
getWaitingTime
(
vehicleID
);
}
@Override
public
void
resetVehicleID
()
{
vehicleID
=
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