Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: ee8019e586e38ab1fea2ae7398fea0f9b01d2f48 (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
RoomModel trafficlight.example {
	import room.basic.types.* from "../../org.eclipse.etrice.modellib.java/models/Types.room"
	import room.basic.service.timing.* from "../../org.eclipse.etrice.modellib.java/models/TimingService.room"
	import room.basic.service.tcp.* from "../../org.eclipse.etrice.modellib.java/models/TcpService.room"
	
	SubSystemClass SSTraffic {
		ActorRef application:Application
		ActorRef TimingService: ATimingService
		LayerConnection ref application satisfied_by TimingService.timer
	}
	
	
	ActorClass Application {
		Structure {
			ActorRef light1: TrafficLight
			ActorRef light2: TrafficLight
		}
		Behavior { }
	}
	
	ActorClass TrafficLight {
		Structure {
			conjugated Port tcpCtrl: PTcpControl
			conjugated Port tcpPayload: PTcpPayload
			SAP timeout: PTimer
			SAP blinkerTimeout: PTimer
			Attribute ipConfig : DTcpControl
			ActorRef trafficLightSocket: ATcpClient
			Binding trafficLightSocket.ControlPort and tcpCtrl
			Binding trafficLightSocket.PayloadPort and tcpPayload
			
			
		}
		Behavior {
			
			Operation sendString (text: string){"
				DTcpPayload pl = new DTcpPayload();
				pl.setData(text.getBytes());
				tcpPayload.send(new DTcpPayload(1, text.length(), text.getBytes()));
			"}
			StateMachine {
				Transition init: initial -> OpenSocket { }
				Transition tr0: OpenSocket -> tp0 of Off_Blinking {
					triggers {
						<established: tcpCtrl>
					}
				}
				Transition tr2: Off_Blinking -> Red {
					triggers {
						<timeout: timeout>
					}
				}
				Transition tr3: Red -> Yellow {
					triggers {
						<timeout: timeout>
					}
				}
				Transition tr1: Yellow -> Green {
					triggers {
						<timeout: timeout>
					}
				}
				Transition tr4: Green -> tp0 of Off_Blinking {
					triggers {
						<timeout: timeout>
					}
				}
				State OpenSocket {
					entry {
						"tcpCtrl.open(ipConfig);"
					}
				}
				State Yellow {
					entry {
						"sendString(\"carLights=yellow\\n\");"
						"timeout.startTimeout(1000);"
					}
				}
				State Red {
					entry {
						"sendString(\"carLights=red\\n\");"
						"timeout.startTimeout(1000);"
					}
				}
				State Green {
					entry {
						"sendString(\"carLights=green\\n\");"
						"timeout.startTimeout(1000);"
					}
				}
				State Off_Blinking {
					entry {
						"timeout.startTimeout(6000);"
					}
					subgraph {
						Transition tr0: my tp0 -> On
						Transition tr1: On -> Off {
							triggers {
								<timeout: blinkerTimeout>
							}
						}
						Transition tr2: Off -> On {
							triggers {
								<timeout: blinkerTimeout>
							}
						}
						EntryPoint tp0
						State On {
							entry {
								"sendString(\"carLights=red\\n\");"
								"sendString(\"pedLights=red\\n\");"
								"blinkerTimeout.startTimeout(1000);"
							}
							exit {
								"sendString(\"carLights=off\\n\");"
								"sendString(\"pedLights=off\\n\");"
							}
						}
						State Off {
							entry {
								"blinkerTimeout.startTimeout(1000);"
							}
						}
					}
				}
			}
		}
	}

}

Back to the top