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
24efeba1
Commit
24efeba1
authored
Jun 18, 2018
by
jimonreal
Committed by
Jose Ignacio Monreal Bailey
Aug 20, 2019
Browse files
Adding logic to extend traffic lights phase
parent
a6b7b583
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/de/tud/kom/p2psim/impl/topology/movement/vehicular/sumo/simulation/controller/traci/TraciSimulationController.java
View file @
24efeba1
...
@@ -213,12 +213,20 @@ public class TraciSimulationController implements VehicleController, SimulationS
...
@@ -213,12 +213,20 @@ public class TraciSimulationController implements VehicleController, SimulationS
public
long
getRemainingPhaseTime
(
String
trafficLightId
)
{
public
long
getRemainingPhaseTime
(
String
trafficLightId
)
{
SumoCommand
nextSwitchCommand
=
Trafficlight
.
getNextSwitch
(
trafficLightId
);
SumoCommand
nextSwitchCommand
=
Trafficlight
.
getNextSwitch
(
trafficLightId
);
Object
nextSwitchObject
=
requestObject
(
nextSwitchCommand
);
Object
nextSwitchObject
=
requestObject
(
nextSwitchCommand
);
long
remaingPhaseTime
=
(
long
)
(((
int
)
nextSwitchObject
)
-
(
Simulator
.
getCurrentTime
()/
1000.0
));
Object
currentTime
=
requestObject
(
Simulation
.
getCurrentTime
());
long
remaingPhaseTime
=
(
long
)((
int
)
nextSwitchObject
-
(
int
)
currentTime
);
return
remaingPhaseTime
;
return
remaingPhaseTime
;
}
}
@Override
@Override
public
void
setPhaseDuration
(
String
trafficLightId
,
int
extraTime
)
{
SumoCommand
phaseDurationCommand
=
Trafficlight
.
setPhaseDuration
(
trafficLightId
,
extraTime
);
execute
(
phaseDurationCommand
);
}
@Override
public
boolean
nextStep
()
{
public
boolean
nextStep
()
{
if
(
Simulator
.
getEndTime
()
==
Simulator
.
getCurrentTime
())
{
if
(
Simulator
.
getEndTime
()
==
Simulator
.
getCurrentTime
())
{
return
false
;
return
false
;
...
...
src/de/tud/kom/p2psim/impl/topology/movement/vehicular/sumo/simulation/controller/xml/XMLSimulationController.java
View file @
24efeba1
...
@@ -225,7 +225,12 @@ public class XMLSimulationController implements VehicleController, SimulationSet
...
@@ -225,7 +225,12 @@ public class XMLSimulationController implements VehicleController, SimulationSet
return
0
;
return
0
;
}
}
@Override
@Override
public
void
setPhaseDuration
(
String
trafficLightId
,
int
extraTime
)
{
}
@Override
public
double
getScenarioWidth
()
{
public
double
getScenarioWidth
()
{
return
-
1
;
return
-
1
;
}
}
...
...
src/de/tud/kom/p2psim/impl/vehicular/trafficlights/DefaultTrafficLightInformationComponent.java
View file @
24efeba1
...
@@ -92,6 +92,11 @@ public class DefaultTrafficLightInformationComponent implements TrafficLightInfo
...
@@ -92,6 +92,11 @@ public class DefaultTrafficLightInformationComponent implements TrafficLightInfo
return
controller
.
getRemainingPhaseTime
(
trafficLightId
);
return
controller
.
getRemainingPhaseTime
(
trafficLightId
);
}
}
@Override
public
void
setPhasaeDuration
(
String
trafficLightId
,
int
extraTime
)
{
controller
.
setPhaseDuration
(
trafficLightId
,
extraTime
);
}
@Override
@Override
public
void
initialize
()
{
public
void
initialize
()
{
...
...
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