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
a6b7b583
Commit
a6b7b583
authored
Jun 15, 2018
by
Jose Ignacio Monreal Bailey
Browse files
Starting to change dinamically the lights time
parent
019d1168
Changes
3
Show whitespace changes
Inline
Side-by-side
src/de/tud/kom/p2psim/impl/topology/movement/vehicular/sumo/simulation/controller/traci/TraciSimulationController.java
View file @
a6b7b583
...
...
@@ -194,6 +194,30 @@ public class TraciSimulationController implements VehicleController, SimulationS
return
result
;
}
@Override
public
int
getPhase
(
String
trafficLightId
)
{
SumoCommand
phaseCommand
=
Trafficlight
.
getPhase
(
trafficLightId
);
Object
phaseObject
=
requestObject
(
phaseCommand
);
int
phase
=
(
int
)
phaseObject
;
return
phase
;
}
@Override
public
void
setPhase
(
String
trafficLightId
,
int
phase
)
{
SumoCommand
phaseCommand
=
Trafficlight
.
setPhase
(
trafficLightId
,
phase
);
execute
(
phaseCommand
);
}
@Override
public
long
getRemainingPhaseTime
(
String
trafficLightId
)
{
SumoCommand
nextSwitchCommand
=
Trafficlight
.
getNextSwitch
(
trafficLightId
);
Object
nextSwitchObject
=
requestObject
(
nextSwitchCommand
);
long
remaingPhaseTime
=
(
long
)
(((
int
)
nextSwitchObject
)
-
(
Simulator
.
getCurrentTime
()/
1000.0
));
return
remaingPhaseTime
;
}
@Override
public
boolean
nextStep
()
{
if
(
Simulator
.
getEndTime
()
==
Simulator
.
getCurrentTime
())
{
...
...
src/de/tud/kom/p2psim/impl/topology/movement/vehicular/sumo/simulation/controller/xml/XMLSimulationController.java
View file @
a6b7b583
...
...
@@ -210,6 +210,21 @@ public class XMLSimulationController implements VehicleController, SimulationSet
return
_roadSideUnitInformationHandler
.
getIntersections
();
}
@Override
public
int
getPhase
(
String
trafficLightId
)
{
return
-
1
;
}
@Override
public
void
setPhase
(
String
trafficLightId
,
int
phase
)
{
}
@Override
public
long
getRemainingPhaseTime
(
String
trafficLightId
)
{
return
0
;
}
@Override
public
double
getScenarioWidth
()
{
return
-
1
;
...
...
src/de/tud/kom/p2psim/impl/vehicular/trafficlights/DefaultTrafficLightInformationComponent.java
View file @
a6b7b583
...
...
@@ -4,10 +4,13 @@ import de.tudarmstadt.maki.simonstrator.api.Host;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.location.Location
;
import
de.tudarmstadt.maki.simonstrator.api.component.vehicular.api.SimulationSetupExtractor
;
import
de.tudarmstadt.maki.simonstrator.api.component.vehicular.api.TrafficLightController
;
import
de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.RoadNetworkLink
;
import
de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.trafficlights.TrafficLight
;
import
de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.trafficlights.TrafficLightInformationComponent
;
import
de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.trafficlights.TrafficLightState
;
import
java.util.List
;
import
java.util.Map
;
public
class
DefaultTrafficLightInformationComponent
implements
TrafficLightInformationComponent
{
private
Host
host
;
...
...
@@ -69,6 +72,26 @@ public class DefaultTrafficLightInformationComponent implements TrafficLightInfo
return
controller
.
getControlledEdges
(
pTrafficLightId
);
}
@Override
public
Map
<
RoadNetworkLink
,
TrafficLightState
>
getTrafficLightStateForEachLane
()
{
return
controller
.
getTrafficLightStateForEachLane
(
trafficLightId
);
}
@Override
public
int
getPhase
()
{
return
controller
.
getPhase
(
trafficLightId
);
}
@Override
public
void
setPhase
(
int
phase
)
{
controller
.
setPhase
(
trafficLightId
,
phase
);
}
@Override
public
long
getRemainingPhaseTime
()
{
return
controller
.
getRemainingPhaseTime
(
trafficLightId
);
}
@Override
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