Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 77aa33e50ee3cf7fae3a65b1720512d47579cc13 (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
RoomModel PiModel {
	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"
	import trafficlight.connector.* from "trafficlight.connector.room"
	
	LogicalSystem PiSystem {
		SubSystemRef piSubSys:PiSubSys 
	}
	SubSystemClass PiSubSys {
		ActorRef application:Application
		ActorRef timing: ATimingService
		LayerConnection ref application satisfied_by timing.timer
		LogicalThread defaultThread
	}
	ActorClass Application {
		Structure {
			ActorRef tcpIp: ATcpClient
			ActorRef tfIf: TrafficLightInterface
			ActorRef controller: Comtroller
			ActorRef mqtt: MqttWrapperActor
			Binding tfIf.control and tcpIp.ControlPort
			Binding tfIf.payload and tcpIp.PayloadPort
			Binding controller.traffic and tfIf.fct
			Binding controller.mqtt and mqtt.fct
		}
		Behavior { }
	}

	ActorClass Comtroller {
		Interface {
			conjugated Port traffic: PTrafficLightInterface
			conjugated Port mqtt: PMqtt
		}
		Structure {
			external Port traffic
			external Port mqtt
			SAP timer: PTimer
		}
		Behavior {
			StateMachine {
				Transition init: initial -> MQTTInit { }
				Transition tr0: Initialize -> tp0 of Initialized {
					triggers {
						<initialized: traffic>
					}
				}
				Transition tr1: MQTTInit -> Initialize {
					triggers {
						<connected: mqtt>
					}
				}
				State Initialize {
					entry {
						"traffic.initialize();"
					}
				}
				State Initialized {
					entry {
						"traffic.pedRed();"
						"mqtt.publish(new DMqttMessage(\"eTrice/TraaficLight/Controller\", \"State: Initialized\", true, 1));"
					}
					subgraph {
						Transition tr0: my tp0 -> On
						Transition tr1: On -> Off {
							triggers {
								<timeout: timer>
							}
						}
						Transition tr2: Off -> On {
							triggers {
								<timeout: timer>
							}
						}
						EntryPoint tp0
						State On {
							entry {
								"traffic.pedRed();"
								"traffic.carRed();"
								"timer.startTimeout(1000);"
							}
							exit {
								"traffic.pedOff();"
								"traffic.carOff();"
							}
						}
						State Off {
							entry {
								"timer.startTimeout(1000);"
							}
						}
					}
				}
				State MQTTInit {
					entry {
						"mqtt.connect(new DMqttConfig(\"tcp://m2m.eclipse.org:1883\", \"eTrice-Paho-Tester\"));"
					}
				}
			}
		}
	}

}

Back to the top