Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'examples/org.eclipse.etrice.tutorials.simulators.trafficlight.example/model/scratch/PedLightsController.room')
-rw-r--r--examples/org.eclipse.etrice.tutorials.simulators.trafficlight.example/model/scratch/PedLightsController.room168
1 files changed, 168 insertions, 0 deletions
diff --git a/examples/org.eclipse.etrice.tutorials.simulators.trafficlight.example/model/scratch/PedLightsController.room b/examples/org.eclipse.etrice.tutorials.simulators.trafficlight.example/model/scratch/PedLightsController.room
new file mode 100644
index 000000000..b47c9ea92
--- /dev/null
+++ b/examples/org.eclipse.etrice.tutorials.simulators.trafficlight.example/model/scratch/PedLightsController.room
@@ -0,0 +1,168 @@
+RoomModel PedLightsController {
+
+ import room.basic.service.timing.* from "../../../org.eclipse.etrice.modellib.java/models/TimingService.room"
+ import room.basic.types.* from "../../../org.eclipse.etrice.modellib.java/models/Types.room"
+
+ LogicalSystem LogSys_PedLights {
+ SubSystemRef application: SubSys_PedLights
+ }
+
+ SubSystemClass SubSys_PedLights {
+ ActorRef PedLightsTopRef: PedLightsTop
+ ActorRef timingService: ATimingService
+ LayerConnection ref PedLightsTopRef satisfied_by timingService.timer
+ }
+
+ ActorClass PedLightsTop {
+ Structure {
+ ActorRef adapter: GuiAdapter
+ ActorRef controller: Controller
+ Binding adapter.ControlPort and controller.ControlPort
+ }
+ Behavior { }
+ }
+
+ ActorClass GuiAdapter {
+ Interface {
+ conjugated Port ControlPort: PedControlProtocol
+ }
+ Structure {
+ usercode1 {
+ "import org.eclipse.etrice.tutorials.PedLightGUI.*;"
+ }
+ usercode2 {
+ "private PedestrianLightWndNoTcp lights = new PedestrianLightWndNoTcp(\"Pedestrian Lights\",\" external port connection \");"
+ "private TrafficLight3 carLights;"
+ "private TrafficLight2 pedLights;"
+ }
+ external Port ControlPort
+ }
+ Behavior {
+ Operation ~GuiAdapter() {
+ "lights.closeWindow();"
+ }
+ StateMachine {
+ Transition init: initial -> running {
+ action {
+ "carLights=lights.getCarLights();"
+ "pedLights=lights.getPedLights();"
+ "carLights.setState(TrafficLight3.OFF);"
+ "pedLights.setState(TrafficLight2.OFF);"
+ "lights.setPort(ControlPort);"
+ }
+ }
+ Transition tr0: running -> running {
+ triggers {
+ <setCarLights: ControlPort>
+ }
+ action {
+ "carLights.setState(state);"
+ }
+ }
+ Transition tr1: running -> running {
+ triggers {
+ <setPedLights: ControlPort>
+ }
+ action {
+ "pedLights.setState(state);"
+ }
+ }
+ State running
+ }
+ }
+ }
+
+ ActorClass Controller {
+ Interface {
+ Port ControlPort: PedControlProtocol
+ }
+ Structure {
+ usercode1 {
+ "import org.eclipse.etrice.tutorials.PedLightGUI.*;"
+ }
+ external Port ControlPort
+ SAP timer: PTimer
+ }
+ Behavior {
+ StateMachine {
+ Transition init: initial -> off { }
+ Transition tr0: off -> carsGreen {
+ triggers {
+ <start: ControlPort>
+ }
+ action {
+ "timer.startTimeout(700);"
+ "ControlPort.setCarLights(TrafficLight3.GREEN);"
+ "ControlPort.setPedLights(TrafficLight2.RED);"
+ }
+ }
+ Transition tr1: carsGreen -> carsYellow {
+ triggers {
+ <timeout: timer>
+ }
+ action {
+ "timer.startTimeout(700);"
+ "ControlPort.setCarLights(TrafficLight3.YELLOW);"
+ "ControlPort.setPedLights(TrafficLight2.RED);"
+ }
+ }
+ Transition tr2: carsYellow -> carsRed {
+ triggers {
+ <timeout: timer>
+ }
+ action {
+ "timer.startTimeout(1500);"
+ "ControlPort.setCarLights(TrafficLight3.RED);"
+ "ControlPort.setPedLights(TrafficLight2.GREEN);"
+ }
+ }
+ Transition tr3: carsRed -> carsYellowRed {
+ triggers {
+ <timeout: timer>
+ }
+ action {
+ "timer.startTimeout(700);"
+ "ControlPort.setCarLights(TrafficLight3.YELLOW_RED);"
+ "ControlPort.setPedLights(TrafficLight2.RED);"
+ }
+ }
+ Transition tr4: carsYellowRed -> carsGreen2 {
+ triggers {
+ <timeout: timer>
+ }
+ action {
+ "timer.startTimeout(700);"
+ "ControlPort.setCarLights(TrafficLight3.GREEN);"
+ "ControlPort.setPedLights(TrafficLight2.RED);"
+ }
+ }
+ Transition tr5: carsGreen2 -> off {
+ triggers {
+ <timeout: timer>
+ }
+ action {
+ "ControlPort.setCarLights(TrafficLight3.OFF);"
+ "ControlPort.setPedLights(TrafficLight2.OFF);"
+ }
+ }
+ State off
+ State carsGreen
+ State carsYellow
+ State carsRed
+ State carsYellowRed
+ State carsGreen2
+ }
+ }
+ }
+
+ ProtocolClass PedControlProtocol {
+ incoming {
+ Message start()
+ }
+ outgoing {
+ Message setCarLights(state: int32)
+ Message setPedLights(state: int32)
+ }
+ }
+
+} \ No newline at end of file

Back to the top