Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Schuetz2012-10-04 14:35:23 -0400
committerThomas Schuetz2012-10-04 14:36:19 -0400
commitc18e073a3d56e7ddf67ea99b5ec5eee07dc277f2 (patch)
tree9bbc7b8ce08fe8425f982488b9c29594572cc698 /examples/org.eclipse.etrice.tutorials.simulators.trafficlight.example/model
parent9898c539d6ed47ae91a3f53edc4bd44fbaa977e7 (diff)
downloadorg.eclipse.etrice-c18e073a3d56e7ddf67ea99b5ec5eee07dc277f2.tar.gz
org.eclipse.etrice-c18e073a3d56e7ddf67ea99b5ec5eee07dc277f2.tar.xz
org.eclipse.etrice-c18e073a3d56e7ddf67ea99b5ec5eee07dc277f2.zip
[tutorials.simulators.trafficlight.example] added example for traffic light - start for new tutorial
Diffstat (limited to 'examples/org.eclipse.etrice.tutorials.simulators.trafficlight.example/model')
-rw-r--r--examples/org.eclipse.etrice.tutorials.simulators.trafficlight.example/model/trafficlight.example.config15
-rw-r--r--examples/org.eclipse.etrice.tutorials.simulators.trafficlight.example/model/trafficlight.example.room130
2 files changed, 145 insertions, 0 deletions
diff --git a/examples/org.eclipse.etrice.tutorials.simulators.trafficlight.example/model/trafficlight.example.config b/examples/org.eclipse.etrice.tutorials.simulators.trafficlight.example/model/trafficlight.example.config
new file mode 100644
index 000000000..4b6e02dca
--- /dev/null
+++ b/examples/org.eclipse.etrice.tutorials.simulators.trafficlight.example/model/trafficlight.example.config
@@ -0,0 +1,15 @@
+import trafficlight.example.* from "trafficlight.example.room"
+
+ActorInstanceConfig SSTraffic/application/light1{
+ Attr ipConfig{
+ Attr IPAddr="127.0.0.1"
+ Attr TcpPort=4441
+ }
+}
+
+ActorInstanceConfig SSTraffic/application/light2 {
+ Attr ipConfig{
+ Attr IPAddr="127.0.0.1"
+ Attr TcpPort=4442
+ }
+} \ No newline at end of file
diff --git a/examples/org.eclipse.etrice.tutorials.simulators.trafficlight.example/model/trafficlight.example.room b/examples/org.eclipse.etrice.tutorials.simulators.trafficlight.example/model/trafficlight.example.room
new file mode 100644
index 000000000..ee8019e58
--- /dev/null
+++ b/examples/org.eclipse.etrice.tutorials.simulators.trafficlight.example/model/trafficlight.example.room
@@ -0,0 +1,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);"
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+} \ No newline at end of file

Back to the top