Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 4f7cfb59fe2f3c435ff54239c42cca3756b5302d (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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
RoomModel etrice.example {

	import room.basic.service.tcp.* from "../../../org.eclipse.etrice.modellib.java/model/TcpService.room"

	import room.basic.types.* from "../../../org.eclipse.etrice.modellib.java/model/Types.room"

	import room.basic.service.timing.* from "../../../org.eclipse.etrice.modellib.java/model/TimingService.room"

	LogicalSystem System {
		SubSystemRef SubSysRefName: SubSys
	}

	SubSystemClass SubSys {
		ActorRef application: Application
		ActorRef timingService: ATimingService
		LayerConnection ref application satisfied_by timingService.timer
		LogicalThread defaultThread
	}

	ActorClass Application {
		Structure {
			ActorRef trafficLightIF: TrafficLightIF
			ActorRef trafficLightSocket: ATcpClient
			ActorRef controller: TrafficLightController
			Binding trafficLightIF.control and trafficLightSocket.ControlPort
			Binding trafficLightIF.payload and trafficLightSocket.PayloadPort
			Binding controller.trafficLight and trafficLightIF.fct
		}
		Behavior { }
	}

	ActorClass TrafficLightIF {
		Interface {
			conjugated Port control: PTcpControl
			conjugated Port payload: PTcpPayload
			Port fct: PTrafficLightIF
		}
		Structure {
			external Port control
			external Port payload
			external Port fct
			SAP timeout: PTimer
		}
		Behavior {
			StateMachine {
				Transition init: initial -> NotInitialized { }
				Transition tr0: Init -> tp0 of Initialized_Blinking {
					triggers {
						<established: control>
					}
				}
				Transition tr2: Initialized_Blinking -> AllRed {
					triggers {
						<onForCars: fct>
					}
				}
				Transition tr1: AllRed -> CarGreen {
					triggers {
						<timeout: timeout>
					}
				}
				Transition tr3: Initialized_Blinking -> AllRed2 {
					triggers {
						<onForPeds: fct>
					}
				}
				Transition tr4: AllRed2 -> PedGreen {
					triggers {
						<timeout: timeout>
					}
				}
				Transition tr5: PedGreen -> AllRed {
					triggers {
						<onForCars: fct>
					}
				}
				Transition tr6: CarGreen -> AllRed2 {
					triggers {
						<onForPeds: fct>
					}
				}
				Transition tr7: NotInitialized -> Init {
					triggers {
						<initialize: fct>
					}
				}
				State Init {
					entry {
						"control.open(new DTcpControl(\"localhost\", 4441));\n\n"
					}
				}
				State Initialized_Blinking {
					entry {
						"fct.initialized();"
					}
					subgraph {
						Transition tr0: my tp0 -> ON
						Transition tr1: ON -> OFF {
							triggers {
								<timeout: timeout>
							}
						}
						Transition tr2: OFF -> ON {
							triggers {
								<timeout: timeout>
							}
						}
						EntryPoint tp0
						State ON {
							entry {
								"String text = new String(\"carLights=yellow\\n\");\npayload.send(new DTcpPayload(1, text.length(), text.getBytes()));\ntimeout.startTimeout(500);"
							}
							exit {
								"String text = new String(\"carLights=off\\n\");\npayload.send(new DTcpPayload(1, text.length(), text.getBytes()));\n"
							}
						}
						State OFF {
							entry {
								"timeout.startTimeout(500);"
							}
						}
					}
				}
				State AllRed {
					entry {
						"String text = new String(\"carLights=red\\n\");\npayload.send(new DTcpPayload(1, text.length(), text.getBytes()));\ntext = new String(\"pedLights=red\\n\");\npayload.send(new DTcpPayload(1, text.length(), text.getBytes()));\ntimeout.startTimeout(3000);"
					}
				}
				State CarGreen {
					entry {
						"String text = new String(\"carLights=green\\n\");\npayload.send(new DTcpPayload(1, text.length(), text.getBytes()));\ntext = new String(\"pedLights=red\\n\");\npayload.send(new DTcpPayload(1, text.length(), text.getBytes()));\nfct.onForCarsDone();"
					}
				}
				State AllRed2 {
					entry {
						"String text = new String(\"carLights=red\\n\");\npayload.send(new DTcpPayload(1, text.length(), text.getBytes()));\ntext = new String(\"pedLights=red\\n\");\npayload.send(new DTcpPayload(1, text.length(), text.getBytes()));\ntimeout.startTimeout(3000);\n"
					}
				}
				State PedGreen {
					entry {
						"String text = new String(\"carLights=red\\n\");\npayload.send(new DTcpPayload(1, text.length(), text.getBytes()));\ntext = new String(\"pedLights=green\\n\");\npayload.send(new DTcpPayload(1, text.length(), text.getBytes()));\nfct.onForPedsDone();\n"
					}
				}
				State NotInitialized
			}
		}
	}

	ActorClass TrafficLightController {
		Interface {
			conjugated Port trafficLight: PTrafficLightIF
		}
		Structure {
			external Port trafficLight
			SAP timeout: PTimer
		}
		Behavior {
			StateMachine {
				Transition init: initial -> Init { }
				Transition tr0: Init -> OnForCars {
					triggers {
						<initialized: trafficLight>
					}
				}
				Transition tr1: OnForCars -> WaitABit1 {
					triggers {
						<onForCarsDone: trafficLight>
					}
				}
				Transition tr2: OnForPeds -> WaitABit2 {
					triggers {
						<onForPedsDone: trafficLight>
					}
				}
				Transition tr3: WaitABit1 -> OnForPeds {
					triggers {
						<timeout: timeout>
					}
				}
				Transition tr4: WaitABit2 -> OnForCars {
					triggers {
						<timeout: timeout>
					}
				}
				State Init {
					entry {
						"trafficLight.initialize();"
					}
				}
				State OnForCars {
					entry {
						"trafficLight.onForCars();"
					}
				}
				State OnForPeds {
					entry {
						"trafficLight.onForPeds();"
					}
				}
				State WaitABit1 {
					entry {
						"timeout.startTimeout(2000);"
					}
				}
				State WaitABit2 {
					entry {
						"timeout.startTimeout(2000);\n"
					}
				}
			}
		}
	}

	ProtocolClass PTrafficLightIF {
		incoming {
			Message initialize()
			Message onForCars()
			Message onForPeds()
		}
		outgoing { 
			Message initialized()
			Message onForCarsDone()
			Message onForPedsDone()
		}
	}

}

Back to the top