Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 943f487da2bff4e5e819d4184d195c105a7b1972 (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
RoomModel TrafficlightModel {
	
	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 room.basic.service.tcp.* from "../../../org.eclipse.etrice.modellib.java/model/TcpService.room"
	
	LogicalSystem TrafficlightLogSys {
		SubSystemRef subsystem:SubSys 
	}
	SubSystemClass SubSys {
		ActorRef application:Application 
		LogicalThread defaultThread
	}
	ActorClass Application {
		Structure {
			ActorRef commands: TrafficLightCommands
		}
		Behavior { }
	}
	
	ActorClass TrafficLightCommands {
		Interface {
			Port fct: PTrafficLightCommands
		}
		Structure {
			external Port fct
			conjugated Port socketControl: PTcpControl
			conjugated Port socketPayload: PTcpPayload
			ActorRef socket: ATcpClient
			Binding socketControl and socket.ControlPort
			Binding socketPayload and socket.PayloadPort
			Attribute socketConfig: DTcpControl
			
		}
		Behavior {
			StateMachine {
				Transition init: initial -> ConfigSocket {
					action {
						"socketConfig = new DTcpControl(\"localhost\", 4441);"
					}
				}
				Transition tr0: ConfigSocket -> SocketOpen {
					triggers {
						<established: socketControl>
					}
				}
				State ConfigSocket {
					entry {
						"socketControl.open(socketConfig);"
					}
				}
				State SocketOpen {
					entry {
						"String payload = new String(\"carLights=red\\n\");"
						"socketPayload.send(new DTcpPayload(0, payload.length(), payload.getBytes() ));"
					}
				}
			}
		}
	}
	
	ProtocolClass PTrafficLightCommands {
		incoming {
			Message carRed()
			Message carYellow()
			Message carYellowRed()
			Message carGreen()
			Message carOff()
			
			Message pedRed()
			Message pedGreen()
			Message pedOff()
			
		}
		outgoing {
			Message pressedButton()
		}
	}
}

Back to the top