diff options
Diffstat (limited to 'examples/org.eclipse.etrice.tutorials.c/model/trafficlight/trafficlight.example.room')
-rw-r--r-- | examples/org.eclipse.etrice.tutorials.c/model/trafficlight/trafficlight.example.room | 318 |
1 files changed, 0 insertions, 318 deletions
diff --git a/examples/org.eclipse.etrice.tutorials.c/model/trafficlight/trafficlight.example.room b/examples/org.eclipse.etrice.tutorials.c/model/trafficlight/trafficlight.example.room deleted file mode 100644 index 1b69d6c26..000000000 --- a/examples/org.eclipse.etrice.tutorials.c/model/trafficlight/trafficlight.example.room +++ /dev/null @@ -1,318 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012 protos software gmbh (http://www.protos.de). - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * CONTRIBUTORS: - * Thomas Schuetz (initial contribution) - * - *******************************************************************************/ - - -RoomModel trafficlight.example { - - import room.basic.types.* from "../../../org.eclipse.etrice.modellib.c/model/Types.room" - - import room.basic.service.timing.* from "../../../org.eclipse.etrice.modellib.c/model/TimingService.room" - - import room.basic.service.tcp.* from "../../../org.eclipse.etrice.modellib.c/model/TcpService.room" - - LogicalSystem LSTraffic { - SubSystemRef main: SSTraffic - } - - SubSystemClass SSTraffic ["Subsystem of Trafficlight Example Application. The Subsystem contains all Actors of the application."] { - ActorRef application: TrafficlightExampleApplication ["reference to application"] - ActorRef TimingService: ATimingService ["reference to timing service"] - LayerConnection ref application satisfied_by TimingService.timer - - LogicalThread dflt_thread - } - - ActorClass TrafficlightExampleApplication ["Toplevel Actor of the Trafficlight Example Application."]{ - Structure { - - ActorRef light1: TrafficLight ["first traffic light"] - ActorRef light2: TrafficLight ["second traffic light"] - ActorRef controller: TrafficController ["controller for coordination of the traffic lights"] - Binding controller.light1 and light1.controller - Binding controller.light2 and light2.controller - } - Behavior { } - } - - ActorClass TrafficController ["The TrafficController coordinates two traffic lights (directions)."] { - Interface { - conjugated Port light1: PTrafficLight ["port to control traffic light 1"] - conjugated Port light2: PTrafficLight ["port to control traffic light 2"] - } - Structure { - usercode1 { - "#include \"platform/etTcpSockets.h\"" - } - external Port light1 - external Port light2 - SAP timeout: PTimer - } - Behavior { - Operation TrafficController() { - "etInitSockets();" - } - Operation ~TrafficController() { - "etCleanupSockets();" - } - StateMachine { - Transition init: initial -> Idle { } - Transition tr0: Idle -> SwitchToLight1GreenForCars { - triggers { - <timeout: timeout> - } - } - Transition tr1: SwitchToLight1GreenForCars -> state0 { - triggers { - <greenForCarDone: light1> - } - } - Transition tr2: SwitchToLight1GreenForCars -> state1 { - triggers { - <greenForPedDone: light2> - } - } - Transition tr3: state1 -> Light1GreenForCars { - triggers { - <greenForCarDone: light1> - } - } - Transition tr4: state0 -> Light1GreenForCars { - triggers { - <greenForPedDone: light2> - } - } - Transition tr5: Light1GreenForCars -> SwitchToLight2GreenForCars { - triggers { - <timeout: timeout> - } - } - Transition tr6: SwitchToLight2GreenForCars -> state2 { - triggers { - <greenForPedDone: light1> - } - } - Transition tr7: SwitchToLight2GreenForCars -> state3 { - triggers { - <greenForCarDone: light2> - } - } - Transition tr8: state2 -> Light2GreenForCars { - triggers { - <greenForCarDone: light2> - } - } - Transition tr9: state3 -> Light2GreenForCars { - triggers { - <greenForPedDone: light1> - } - } - Transition tr10: Light2GreenForCars -> SwitchToLight1GreenForCars { - triggers { - <timeout: timeout> - } - } - State Idle { - entry { - "timeout.startTimeout(3000);" - } - } - State Light1GreenForCars { - entry { - "timeout.startTimeout(10000);" - } - } - State SwitchToLight1GreenForCars { - entry { - "light1.greenForCar();" - "light2.greenForPed();" - } - } - State state0 - State state1 - State SwitchToLight2GreenForCars { - entry { - "light1.greenForPed();" - "light2.greenForCar();" - } - } - State state2 - State state3 - State Light2GreenForCars { - entry { - "timeout.startTimeout(10000);" - } - } - } - } - } - - ActorClass TrafficLight ["This Actor is responsible for controlling a single traffic light via socket. It uses a socket client for communication."] { - Interface { - Port controller: PTrafficLight - } - Structure { - external Port controller - conjugated Port tcpCtrl: PTcpControl - conjugated Port tcpPayload: PTcpPayload - SAP timeout: PTimer - SAP blinkerTimeout: PTimer - Attribute ipConfig: DTcpControl ["configuration of the IP-port for the communication with the Traffic Light GUI"] - ActorRef trafficLightSocket: ATcpClient - Binding trafficLightSocket.ControlPort and tcpCtrl - Binding trafficLightSocket.PayloadPort and tcpPayload - } - Behavior { - Operation sendString(text: string)["convenience function for sending a string over the socket"] { - " - static DTcpPayload pl; - strcpy(pl.data, text); - pl.length = strlen(text); - tcpPayload.send(&pl); - " - } - StateMachine { - Transition init: initial -> OpenSocket { } - Transition tr0: OpenSocket -> tp0 of Off_Blinking { - triggers { - <established: tcpCtrl> - } - } - Transition tr2: Off_Blinking -> PedRed { - triggers { - <greenForCar: controller> - } - } - Transition tr3: PedRed -> CarYellow { - triggers { - <timeout: timeout> - } - } - Transition tr1: CarYellow -> CarGreen { - triggers { - <timeout: timeout> - } - } - Transition tr4: Off_Blinking -> CarYellow2 { - triggers { - <greenForPed: controller> - } - } - Transition tr5: CarYellow2 -> CarRed { - triggers { - <timeout: timeout> - } - } - Transition tr6: CarRed -> PedGreen { - triggers { - <timeout: timeout> - } - } - Transition tr7: PedGreen -> PedRed { - triggers { - <greenForCar: controller> - } - } - Transition tr8: CarGreen -> CarYellow2 { - triggers { - <greenForPed: controller> - } - } - State OpenSocket { - entry { - "tcpCtrl.open(&(ipConfig));" - } - } - State CarYellow { - entry { - "sendString(\"carLights=yellow\\n\");" - "timeout.startTimeout(1000);" - } - } - State PedRed { - entry { - "sendString(\"pedLights=red\\n\");" - "sendString(\"carLights=red\\n\");" - "timeout.startTimeout(1000);" - } - } - State CarGreen { - entry { - "sendString(\"carLights=green\\n\");" - "controller.greenForCarDone();" - } - } - State Off_Blinking { - 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(500);" - } - exit { - "sendString(\"carLights=off\\n\");" - "sendString(\"pedLights=off\\n\");" - } - } - State Off { - entry { - "blinkerTimeout.startTimeout(500);" - } - } - } - } - State CarYellow2 { - entry { - "sendString(\"carLights=yellow\\n\");" - "timeout.startTimeout(1000);" - } - } - State CarRed { - entry { - "sendString(\"carLights=red\\n\");" - "timeout.startTimeout(1000);" - } - } - State PedGreen { - entry { - "sendString(\"pedLights=green\\n\");" - "controller.greenForPedDone();" - } - } - } - } - } - - ProtocolClass PTrafficLight { - incoming { - Message greenForCar() ["trigger green for car"] - Message greenForPed() ["trigger green for pedestrians"] - } - outgoing { - Message greenForCarDone() ["positive response for greenForCar - is sent when switch is over"] - Message greenForPedDone() ["positive response for greenForPed - is sent when switch is over"] - } - } - -}
\ No newline at end of file |