Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 67bba4bbc1ebac76a6f8afc548861bc4637aa7b2 (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
RoomModel Blinky {

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

	LogicalSystem System_Blinky {
		SubSystemRef subsystem: SubSystem_Blinky
	}

	SubSystemClass SubSystem_Blinky {
		ActorRef application: BlinkyTop
		ActorRef timingService: ATimingService
		LayerConnection ref application satisfied_by timingService.timer
	}

	ActorClass BlinkyTop {
		Structure {
			ActorRef blinky: Blinky
			ActorRef controller: BlinkyController
			Binding blinky.ControlPort and controller.ControlPort
		}
		Behavior { }
	}

	ActorClass Blinky {
		Interface {
			Port ControlPort: BlinkyControlProtocoll
		}
		Structure {
			usercode1 {
				"import org.eclipse.etrice.tutorials.PedLightGUI.*;"
			}
			usercode2 {
				"private PedestrianLightWndNoTcp light = new PedestrianLightWndNoTcp();"
				"private TrafficLight3 carLights;"
				"private TrafficLight2 pedLights;"
			}
			external Port ControlPort
			SAP timer: PTimer
		}
		Behavior {
			Operation ~Blinky() {
				"light.closeWindow();"
			}
			StateMachine {
				Transition init: initial -> off {
					action {
						"carLights = light.getCarLights();"
						"pedLights = light.getPedLights();"
						"carLights.setState(TrafficLight3.OFF);"
						"pedLights.setState(TrafficLight2.OFF);"
					}
				}
				Transition tr0: off -> tp0 of blinking {
					triggers {
						<start: ControlPort>
					}
				}
				Transition tr1: blinking -> off {
					triggers {
						<stop: ControlPort>
					}
					action {
						"timer.kill();"
						"carLights.setState(TrafficLight3.OFF);"
					}
				}
				State off
				State blinking {
					subgraph {
						Transition tr0: my tp0 -> on
						Transition tr1: on -> off {
							triggers {
								<timeout: timer>
							}
						}
						Transition tr2: off -> on {
							triggers {
								<timeout: timer>
							}
						}
						Transition init: initial -> on { }
						EntryPoint tp0
						State on {
							entry {
								"timer.startTimeout(1000);"
								"carLights.setState(TrafficLight3.YELLOW);"
							}
						}
						State off {
							entry {
								"timer.startTimeout(1000);"
								"carLights.setState(TrafficLight3.OFF);"
							}
						}
					}
				}
			}
		}
	}

	ActorClass BlinkyController {
		Interface {
			conjugated Port ControlPort: BlinkyControlProtocoll
		}
		Structure {
			external Port ControlPort
			SAP timer: PTimer
		}
		Behavior {
			StateMachine {
				Transition init: initial -> on {
					action {
						"timer.startTimeout(5000);"
						"ControlPort.start();"
					}
				}
				Transition goOff: on -> off {
					triggers {
						<timeout: timer>
					}
					action {
						"ControlPort.stop();"
						"timer.startTimeout(5000);"
					}
				}
				Transition goOn: off -> on {
					triggers {
						<timeout: timer>
					}
					action {
						"ControlPort.start();"
						"timer.startTimeout(5000);"
					}
				}
				State on
				State off { }
			}
		}
	}

	ProtocolClass BlinkyControlProtocoll {
		incoming {
			Message start()
			Message stop()
		}
		outgoing { }
	}

}

Back to the top