Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 8bdc716849f4e5ecd1c2c9574dbb3f8928566a54 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
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
		LayerConnection ref PedLightsTopRef satisfied_by timingService.timeout
	}

	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: PTimeout
		}
		Behavior {
			StateMachine {
				Transition init: initial -> off { }
				Transition tr0: off -> carsGreen {
					triggers {
						<start: ControlPort>
					}
					action {
						"timer.Start(700);"
						"ControlPort.setCarLights(TrafficLight3.GREEN);"
						"ControlPort.setPedLights(TrafficLight2.RED);"
					}
				}
				Transition tr1: carsGreen -> carsYellow {
					triggers {
						<timeoutTick: timer>
					}
					action {
						"timer.Start(700);"
						"ControlPort.setCarLights(TrafficLight3.YELLOW);"
						"ControlPort.setPedLights(TrafficLight2.RED);"
					}
				}
				Transition tr2: carsYellow -> carsRed {
					triggers {
						<timeoutTick: timer>
					}
					action {
						"timer.Start(1500);"
						"ControlPort.setCarLights(TrafficLight3.RED);"
						"ControlPort.setPedLights(TrafficLight2.GREEN);"
					}
				}
				Transition tr3: carsRed -> carsYellowRed {
					triggers {
						<timeoutTick: timer>
					}
					action {
						"timer.Start(700);"
						"ControlPort.setCarLights(TrafficLight3.YELLOW_RED);"
						"ControlPort.setPedLights(TrafficLight2.RED);"
					}
				}
				Transition tr4: carsYellowRed -> carsGreen2 {
					triggers {
						<timeoutTick: timer>
					}
					action {
						"timer.Start(700);"
						"ControlPort.setCarLights(TrafficLight3.GREEN);"
						"ControlPort.setPedLights(TrafficLight2.RED);"
					}
				}
				Transition tr5: carsGreen2 -> off {
					triggers {
						<timeoutTick: 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)
		}
	}

}

Back to the top