| 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 |
| ActorRef timingService: ATimingService |
| LayerConnection ref application satisfied_by timingService.timer |
| LogicalThread defaultThread |
| } |
| ActorClass Application { |
| Structure { |
| ActorRef commands: TrafficLightCommands |
| ActorRef controller: TrafficLightController |
| Binding controller.tlCommands and commands.fct |
| } |
| Behavior { } |
| } |
| |
| ActorClass TrafficLightController { |
| Interface { |
| conjugated Port tlCommands: PTrafficLightCommands |
| } |
| Structure { |
| external Port tlCommands |
| SAP timeout: PTimer |
| |
| } |
| Behavior { |
| StateMachine { |
| Transition init: initial -> InitCommands { } |
| Transition tr0: InitCommands -> tp0 of Blinking { |
| triggers { |
| <doneInit: tlCommands> |
| } |
| } |
| State InitCommands { |
| entry { |
| "tlCommands.startInit();" |
| } |
| } |
| State Blinking { |
| entry { |
| "tlCommands.carYellow();" |
| } |
| 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 { |
| "tlCommands.carYellow();" |
| "timeout.startTimeout(500);" |
| } |
| exit { |
| "tlCommands.carOff();" |
| } |
| } |
| State Off { |
| entry { |
| "timeout.startTimeout(500);" |
| } |
| } |
| } |
| } |
| } |
| } |
| } |
| |
| 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 -> NotInitialized { |
| action { |
| "socketConfig = new DTcpControl(\"localhost\", 4441);" |
| } |
| } |
| Transition tr0: ConfigSocket -> SocketOpen { |
| triggers { |
| <established: socketControl> |
| } |
| action { |
| "fct.doneInit();" |
| } |
| } |
| Transition tr1: SocketOpen -> SocketOpen { |
| triggers { |
| <carRed: fct> |
| } |
| action { |
| "String payload = new String(\"carLights=red\\n\");" |
| "socketPayload.send(new DTcpPayload(0, payload.length(), payload.getBytes() ));" |
| } |
| } |
| Transition tr2: SocketOpen -> SocketOpen { |
| triggers { |
| <carYellow: fct> |
| } |
| action { |
| "String payload = new String(\"carLights=yellow\\n\");" |
| "socketPayload.send(new DTcpPayload(0, payload.length(), payload.getBytes() ));" |
| } |
| } |
| Transition tr3: SocketOpen -> SocketOpen { |
| triggers { |
| <carGreen: fct> |
| } |
| action { |
| "String payload = new String(\"carLights=green\\n\");" |
| "socketPayload.send(new DTcpPayload(0, payload.length(), payload.getBytes() ));" |
| } |
| } |
| Transition tr4: SocketOpen -> SocketOpen { |
| triggers { |
| <carOff: fct> |
| } |
| action { |
| "String payload = new String(\"carLights=off\\n\");" |
| "socketPayload.send(new DTcpPayload(0, payload.length(), payload.getBytes() ));" |
| } |
| } |
| Transition tr5: SocketOpen -> SocketOpen { |
| triggers { |
| <pedRed: fct> |
| } |
| action { |
| "String payload = new String(\"pedLights=red\\n\");" |
| "socketPayload.send(new DTcpPayload(0, payload.length(), payload.getBytes() ));" |
| } |
| } |
| Transition tr6: SocketOpen -> SocketOpen { |
| triggers { |
| <pedGreen: fct> |
| } |
| action { |
| "String payload = new String(\"pedLights=green\\n\");" |
| "socketPayload.send(new DTcpPayload(0, payload.length(), payload.getBytes() ));" |
| } |
| } |
| Transition tr7: SocketOpen -> SocketOpen { |
| triggers { |
| <pedOff: fct> |
| } |
| action { |
| "String payload = new String(\"pedLights=off\\n\");" |
| "socketPayload.send(new DTcpPayload(0, payload.length(), payload.getBytes() ));" |
| } |
| } |
| Transition tr8: SocketOpen -> SocketOpen { |
| triggers { |
| <receive: socketPayload> |
| } |
| action { |
| "fct.pressedButton();" |
| } |
| } |
| Transition tr9: NotInitialized -> ConfigSocket { |
| triggers { |
| <startInit: fct> |
| } |
| } |
| State ConfigSocket { |
| entry { |
| "socketControl.open(socketConfig);" |
| } |
| } |
| State SocketOpen |
| State NotInitialized |
| } |
| } |
| } |
| |
| ProtocolClass PTrafficLightCommands { |
| incoming { |
| Message startInit() |
| |
| Message carRed() |
| Message carYellow() |
| Message carYellowRed() |
| Message carGreen() |
| Message carOff() |
| |
| Message pedRed() |
| Message pedGreen() |
| Message pedOff() |
| |
| } |
| outgoing { |
| Message doneInit() |
| |
| Message pressedButton() |
| } |
| } |
| } |