Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Schuetz2012-01-31 16:25:45 -0500
committerThomas Schuetz2012-01-31 16:25:45 -0500
commit01de373df4a524f266ad4250ea54d9aa30299920 (patch)
treeea2f77be21334d9daaf0156986d25e1a3e5b0a6f
parent010759ae39852112ad533827402087c0e3daef59 (diff)
downloadorg.eclipse.etrice-01de373df4a524f266ad4250ea54d9aa30299920.tar.gz
org.eclipse.etrice-01de373df4a524f266ad4250ea54d9aa30299920.tar.xz
org.eclipse.etrice-01de373df4a524f266ad4250ea54d9aa30299920.zip
[generator.c] added const instances for ROM
-rw-r--r--examples/org.eclipse.etrice.generator.c.reference/model/cGenRef.room33
-rw-r--r--examples/org.eclipse.etrice.generator.c.reference/model/diagrams/cGenRef.ReceiverManual.structure36
-rw-r--r--examples/org.eclipse.etrice.generator.c.reference/model/diagrams/cGenRef.SenderManual.structure36
-rw-r--r--examples/org.eclipse.etrice.generator.c.reference/model/diagrams/cGenRef.SubSys.structure30
-rw-r--r--examples/org.eclipse.etrice.generator.c.reference/src-gen/cGenRef/CommunicationProtocol.c (renamed from tests/org.eclipse.etrice.generator.c.tests/src-gen/cGenRef/CommunicationProtocol.c)7
-rw-r--r--examples/org.eclipse.etrice.generator.c.reference/src-gen/cGenRef/CommunicationProtocol.h49
-rw-r--r--examples/org.eclipse.etrice.generator.c.reference/src-gen/cGenRef/ReceiverManual.c14
-rw-r--r--examples/org.eclipse.etrice.generator.c.reference/src-gen/cGenRef/ReceiverManual.h38
-rw-r--r--examples/org.eclipse.etrice.generator.c.reference/src-gen/cGenRef/SenderManual.c14
-rw-r--r--examples/org.eclipse.etrice.generator.c.reference/src-gen/cGenRef/SenderManual.h39
-rw-r--r--examples/org.eclipse.etrice.generator.c.reference/src-gen/cGenRef/SubSys.c7
-rw-r--r--examples/org.eclipse.etrice.generator.c.reference/src-gen/cGenRef/SubSys.h10
-rw-r--r--examples/org.eclipse.etrice.generator.c.reference/src-gen/cGenRef/SubSys_Inst.h54
-rw-r--r--examples/org.eclipse.etrice.generator.c.reference/src/test/experiments/test.h8
-rw-r--r--plugins/org.eclipse.etrice.generator.c/issues.txt3
-rw-r--r--plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/ActorClassGen.xtend240
-rw-r--r--plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/CExtensions.xtend4
-rw-r--r--plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/MainGen.xtend4
-rw-r--r--plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/ProtocolClassGen.xtend29
-rw-r--r--plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/SubSystemClassGen.xtend92
-rw-r--r--plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/ActorClassGen.java863
-rw-r--r--plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/CExtensions.java6
-rw-r--r--plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/DataClassGen.java498
-rw-r--r--plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/MainGen.java120
-rw-r--r--plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/ProtocolClassGen.java95
-rw-r--r--plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/SubSystemClassGen.java209
-rw-r--r--plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/SubSystemRunnerGen.java290
-rw-r--r--plugins/org.eclipse.etrice.generator.doc/xtend-gen/org/eclipse/etrice/generator/doc/gen/InstanceDiagramGen.java268
-rw-r--r--plugins/org.eclipse.etrice.generator.doc/xtend-gen/org/eclipse/etrice/generator/doc/gen/MainGen.java72
-rw-r--r--plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/ActorClassGen.java1106
-rw-r--r--plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/JavaExtensions.java136
-rw-r--r--plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/MainGen.java122
-rw-r--r--plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/StateMachineGen.java1744
-rw-r--r--plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/SubSystemClassGen.java1266
-rw-r--r--plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/SubSystemRunnerGen.java304
-rw-r--r--plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/extensions/PrepareFileSystem.java170
-rw-r--r--plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/extensions/RoomExtensions.java1560
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/Debug/liborg.eclipse.etrice.runtime.c.abin104764 -> 104764 bytes
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/etPort.h3
-rw-r--r--tests/org.eclipse.etrice.generator.c.tests/src-gen/cGenRef/CommunicationProtocol.h50
40 files changed, 4963 insertions, 4666 deletions
diff --git a/examples/org.eclipse.etrice.generator.c.reference/model/cGenRef.room b/examples/org.eclipse.etrice.generator.c.reference/model/cGenRef.room
index 57726f6f6..8054390a4 100644
--- a/examples/org.eclipse.etrice.generator.c.reference/model/cGenRef.room
+++ b/examples/org.eclipse.etrice.generator.c.reference/model/cGenRef.room
@@ -2,8 +2,8 @@ RoomModel cGenRef {
import room.basic.types.c.* from "CTypes.room"
SubSystemClass SubSys {
- ActorRef Receiver: Receiver
- ActorRef Sender: Sender
+ ActorRef Receiver: ReceiverManual
+ ActorRef Sender: SenderManual
Binding Sender.dataOut and Receiver.dataIn
}
@@ -122,22 +122,29 @@ RoomModel cGenRef {
}
}
- ActorClass SenderManual {
- Interface {
-
- }
- Structure {
+ ActorClass SenderManual {
+ Interface {
+ conjugated Port dataOut: CommunicationProtocol
+ }
+ Structure {
+ external Port dataOut
+ Attribute attribute1: int32
+ Attribute attribute2: DataClass1
}
- Behavior {
+ Behavior {
+ @BehaviorManual
+ Operation operation1(argument1:int32, argument2: DataClass1 ref){""}
}
}
- ActorClass ReceiverManual {
- Interface {
-
- }
- Structure {
+ ActorClass ReceiverManual {
+ Interface {
+ Port dataIn: CommunicationProtocol
+ }
+ Structure {
+ external Port dataIn
}
Behavior {
+ @BehaviorManual
}
}
diff --git a/examples/org.eclipse.etrice.generator.c.reference/model/diagrams/cGenRef.ReceiverManual.structure b/examples/org.eclipse.etrice.generator.c.reference/model/diagrams/cGenRef.ReceiverManual.structure
new file mode 100644
index 000000000..31fb3ac21
--- /dev/null
+++ b/examples/org.eclipse.etrice.generator.c.reference/model/diagrams/cGenRef.ReceiverManual.structure
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="ASCII"?>
+<pi:Diagram xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:al="http://eclipse.org/graphiti/mm/algorithms" xmlns:pi="http://eclipse.org/graphiti/mm/pictograms" visible="true" diagramTypeId="room.structure" name="Structure of ReceiverManual" showGuides="true" pictogramLinks="//@children.0/@link //@link //@children.0/@children.0/@link" verticalGridUnit="0">
+ <graphicsAlgorithm xsi:type="al:Rectangle" background="//@colors.1" foreground="//@colors.0" lineWidth="1" transparency="0.0" width="1000" height="1000"/>
+ <link>
+ <businessObjects href="../cGenRef.room#ActorClass:ReceiverManual"/>
+ </link>
+ <children xsi:type="pi:ContainerShape" visible="true" active="true">
+ <properties key="obj-type" value="cls"/>
+ <graphicsAlgorithm xsi:type="al:Rectangle" lineWidth="1" filled="false" lineVisible="false" transparency="0.0" width="880" height="580" x="40" y="40">
+ <graphicsAlgorithmChildren xsi:type="al:Rectangle" background="//@colors.1" foreground="//@colors.2" lineWidth="4" transparency="0.5" width="800" height="500" x="40" y="40"/>
+ <graphicsAlgorithmChildren xsi:type="al:Rectangle" foreground="//@colors.2" lineWidth="4" filled="false" transparency="0.0" width="800" height="500" x="40" y="40"/>
+ </graphicsAlgorithm>
+ <link>
+ <businessObjects href="../cGenRef.room#ActorClass:ReceiverManual"/>
+ </link>
+ <children xsi:type="pi:ContainerShape" visible="true" active="true">
+ <properties key="obj-type" value="port"/>
+ <properties key="item-kind" value=""/>
+ <graphicsAlgorithm xsi:type="al:Rectangle" lineWidth="1" filled="false" lineVisible="false" transparency="0.0" width="80" height="80" x="339">
+ <graphicsAlgorithmChildren xsi:type="al:Rectangle" background="//@colors.2" foreground="//@colors.2" lineWidth="2" transparency="0.0" width="40" height="40" x="20" y="20"/>
+ <graphicsAlgorithmChildren xsi:type="al:Ellipse" background="//@colors.1" foreground="//@colors.1" lineWidth="2" transparency="0.0" width="20" height="20" x="30" y="30"/>
+ </graphicsAlgorithm>
+ <link>
+ <businessObjects href="../cGenRef.room#Port:ReceiverManual$dataIn"/>
+ </link>
+ <anchors xsi:type="pi:ChopboxAnchor" referencedGraphicsAlgorithm="//@children.0/@children.0/@graphicsAlgorithm/@graphicsAlgorithmChildren.0"/>
+ <children visible="true">
+ <graphicsAlgorithm xsi:type="al:Text" foreground="//@colors.2" lineWidth="1" transparency="0.0" width="80" height="20" font="//@fonts.0" horizontalAlignment="ALIGNMENT_CENTER" value="dataIn"/>
+ </children>
+ </children>
+ </children>
+ <colors red="227" green="238" blue="249"/>
+ <colors red="255" green="255" blue="255"/>
+ <colors/>
+ <fonts name="Arial" size="8"/>
+</pi:Diagram>
diff --git a/examples/org.eclipse.etrice.generator.c.reference/model/diagrams/cGenRef.SenderManual.structure b/examples/org.eclipse.etrice.generator.c.reference/model/diagrams/cGenRef.SenderManual.structure
new file mode 100644
index 000000000..033bd2d82
--- /dev/null
+++ b/examples/org.eclipse.etrice.generator.c.reference/model/diagrams/cGenRef.SenderManual.structure
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="ASCII"?>
+<pi:Diagram xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:al="http://eclipse.org/graphiti/mm/algorithms" xmlns:pi="http://eclipse.org/graphiti/mm/pictograms" visible="true" diagramTypeId="room.structure" name="Structure of SenderManual" showGuides="true" pictogramLinks="//@children.0/@link //@link //@children.0/@children.0/@link" verticalGridUnit="0">
+ <graphicsAlgorithm xsi:type="al:Rectangle" background="//@colors.1" foreground="//@colors.0" lineWidth="1" transparency="0.0" width="1000" height="1000"/>
+ <link>
+ <businessObjects href="../cGenRef.room#ActorClass:SenderManual"/>
+ </link>
+ <children xsi:type="pi:ContainerShape" visible="true" active="true">
+ <properties key="obj-type" value="cls"/>
+ <graphicsAlgorithm xsi:type="al:Rectangle" lineWidth="1" filled="false" lineVisible="false" transparency="0.0" width="880" height="580" x="40" y="40">
+ <graphicsAlgorithmChildren xsi:type="al:Rectangle" background="//@colors.1" foreground="//@colors.2" lineWidth="4" transparency="0.5" width="800" height="500" x="40" y="40"/>
+ <graphicsAlgorithmChildren xsi:type="al:Rectangle" foreground="//@colors.2" lineWidth="4" filled="false" transparency="0.0" width="800" height="500" x="40" y="40"/>
+ </graphicsAlgorithm>
+ <link>
+ <businessObjects href="../cGenRef.room#ActorClass:SenderManual"/>
+ </link>
+ <children xsi:type="pi:ContainerShape" visible="true" active="true">
+ <properties key="obj-type" value="port"/>
+ <properties key="item-kind" value="C"/>
+ <graphicsAlgorithm xsi:type="al:Rectangle" lineWidth="1" filled="false" lineVisible="false" transparency="0.0" width="80" height="80" x="392" y="500">
+ <graphicsAlgorithmChildren xsi:type="al:Rectangle" background="//@colors.1" foreground="//@colors.2" lineWidth="2" transparency="0.0" width="40" height="40" x="20" y="20"/>
+ <graphicsAlgorithmChildren xsi:type="al:Ellipse" background="//@colors.2" foreground="//@colors.2" lineWidth="2" transparency="0.0" width="20" height="20" x="30" y="30"/>
+ </graphicsAlgorithm>
+ <link>
+ <businessObjects href="../cGenRef.room#Port:SenderManual$dataOut"/>
+ </link>
+ <anchors xsi:type="pi:ChopboxAnchor" referencedGraphicsAlgorithm="//@children.0/@children.0/@graphicsAlgorithm/@graphicsAlgorithmChildren.0"/>
+ <children visible="true">
+ <graphicsAlgorithm xsi:type="al:Text" foreground="//@colors.2" lineWidth="1" transparency="0.0" width="80" height="20" y="60" font="//@fonts.0" horizontalAlignment="ALIGNMENT_CENTER" value="dataOut"/>
+ </children>
+ </children>
+ </children>
+ <colors red="227" green="238" blue="249"/>
+ <colors red="255" green="255" blue="255"/>
+ <colors/>
+ <fonts name="Arial" size="8"/>
+</pi:Diagram>
diff --git a/examples/org.eclipse.etrice.generator.c.reference/model/diagrams/cGenRef.SubSys.structure b/examples/org.eclipse.etrice.generator.c.reference/model/diagrams/cGenRef.SubSys.structure
index d315e15c5..9091e8ac8 100644
--- a/examples/org.eclipse.etrice.generator.c.reference/model/diagrams/cGenRef.SubSys.structure
+++ b/examples/org.eclipse.etrice.generator.c.reference/model/diagrams/cGenRef.SubSys.structure
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="ASCII"?>
-<pi:Diagram xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:al="http://eclipse.org/graphiti/mm/algorithms" xmlns:pi="http://eclipse.org/graphiti/mm/pictograms" visible="true" diagramTypeId="room.structure" name="Structure of SubSys" showGuides="true" pictogramLinks="//@children.0/@link //@link //@children.0/@children.0/@link //@children.0/@children.0/@children.1/@link //@children.0/@children.1/@link //@children.0/@children.1/@children.1/@link //@connections.0/@link" verticalGridUnit="0">
+<pi:Diagram xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:al="http://eclipse.org/graphiti/mm/algorithms" xmlns:pi="http://eclipse.org/graphiti/mm/pictograms" visible="true" diagramTypeId="room.structure" name="Structure of SubSys" showGuides="true" pictogramLinks="//@children.0/@link //@link //@children.0/@children.0/@link //@children.0/@children.1/@link //@children.0/@children.1/@children.1/@link //@children.0/@children.0/@children.1/@link //@connections.0/@link" verticalGridUnit="0">
<graphicsAlgorithm xsi:type="al:Rectangle" background="//@colors.1" foreground="//@colors.0" lineWidth="1" transparency="0.0" width="1000" height="1000"/>
<link>
<businessObjects href="../cGenRef.room#SubSystemClass:SubSys"/>
@@ -15,10 +15,10 @@
</link>
<children xsi:type="pi:ContainerShape" visible="true" active="true">
<properties key="obj-type" value="ref"/>
- <graphicsAlgorithm xsi:type="al:Rectangle" lineWidth="1" filled="false" lineVisible="false" transparency="0.0" width="177" height="127" x="297" y="358">
- <graphicsAlgorithmChildren xsi:type="al:Rectangle" background="//@colors.3" foreground="//@colors.2" lineWidth="1" transparency="0.0" width="117" height="67" x="30" y="30">
- <graphicsAlgorithmChildren xsi:type="al:Rectangle" foreground="//@colors.2" lineWidth="1" filled="false" lineVisible="false" transparency="0.0" width="20" height="10" x="87" y="37"/>
- <graphicsAlgorithmChildren xsi:type="al:Rectangle" foreground="//@colors.2" lineWidth="1" filled="false" lineVisible="false" transparency="0.0" width="20" height="10" x="82" y="52"/>
+ <graphicsAlgorithm xsi:type="al:Rectangle" lineWidth="1" filled="false" lineVisible="false" transparency="0.0" width="240" height="140" x="223" y="272">
+ <graphicsAlgorithmChildren xsi:type="al:Rectangle" background="//@colors.3" foreground="//@colors.2" lineWidth="1" transparency="0.0" width="180" height="80" x="30" y="30">
+ <graphicsAlgorithmChildren xsi:type="al:Rectangle" foreground="//@colors.2" lineWidth="1" filled="false" lineVisible="false" transparency="0.0" width="20" height="10" x="150" y="50"/>
+ <graphicsAlgorithmChildren xsi:type="al:Rectangle" foreground="//@colors.2" lineWidth="1" filled="false" lineVisible="false" transparency="0.0" width="20" height="10" x="145" y="65"/>
</graphicsAlgorithmChildren>
</graphicsAlgorithm>
<link>
@@ -26,16 +26,16 @@
</link>
<anchors xsi:type="pi:ChopboxAnchor" referencedGraphicsAlgorithm="//@children.0/@children.0/@graphicsAlgorithm/@graphicsAlgorithmChildren.0"/>
<children visible="true">
- <graphicsAlgorithm xsi:type="al:Text" background="//@colors.2" foreground="//@colors.2" lineWidth="1" transparency="0.0" width="117" height="67" x="30" y="30" font="//@fonts.0" horizontalAlignment="ALIGNMENT_CENTER" value="Receiver&#xA;(Receiver)"/>
+ <graphicsAlgorithm xsi:type="al:Text" background="//@colors.2" foreground="//@colors.2" lineWidth="1" transparency="0.0" width="180" height="80" x="30" y="30" font="//@fonts.0" horizontalAlignment="ALIGNMENT_CENTER" value="Receiver&#xA;(ReceiverManual)"/>
</children>
<children xsi:type="pi:ContainerShape" visible="true" active="true">
<properties key="obj-type" value="port"/>
<properties key="item-kind" value=""/>
- <graphicsAlgorithm xsi:type="al:Rectangle" lineWidth="1" filled="false" lineVisible="false" transparency="0.0" width="60" height="60" x="51">
+ <graphicsAlgorithm xsi:type="al:Rectangle" lineWidth="1" filled="false" lineVisible="false" transparency="0.0" width="60" height="60" x="63">
<graphicsAlgorithmChildren xsi:type="al:Rectangle" background="//@colors.2" foreground="//@colors.2" lineWidth="1" transparency="0.0" width="18" height="18" x="21" y="21"/>
</graphicsAlgorithm>
<link>
- <businessObjects href="../cGenRef.room#Port:Receiver$dataIn"/>
+ <businessObjects href="../cGenRef.room#Port:ReceiverManual$dataIn"/>
</link>
<anchors xsi:type="pi:ChopboxAnchor" incomingConnections="//@connections.0" referencedGraphicsAlgorithm="//@children.0/@children.0/@children.1/@graphicsAlgorithm/@graphicsAlgorithmChildren.0"/>
<children visible="true">
@@ -45,10 +45,10 @@
</children>
<children xsi:type="pi:ContainerShape" visible="true" active="true">
<properties key="obj-type" value="ref"/>
- <graphicsAlgorithm xsi:type="al:Rectangle" lineWidth="1" filled="false" lineVisible="false" transparency="0.0" width="177" height="127" x="304" y="68">
- <graphicsAlgorithmChildren xsi:type="al:Rectangle" background="//@colors.3" foreground="//@colors.2" lineWidth="1" transparency="0.0" width="117" height="67" x="30" y="30">
- <graphicsAlgorithmChildren xsi:type="al:Rectangle" foreground="//@colors.2" lineWidth="1" filled="false" lineVisible="false" transparency="0.0" width="20" height="10" x="87" y="37"/>
- <graphicsAlgorithmChildren xsi:type="al:Rectangle" foreground="//@colors.2" lineWidth="1" filled="false" lineVisible="false" transparency="0.0" width="20" height="10" x="82" y="52"/>
+ <graphicsAlgorithm xsi:type="al:Rectangle" lineWidth="1" filled="false" lineVisible="false" transparency="0.0" width="240" height="140" x="223" y="85">
+ <graphicsAlgorithmChildren xsi:type="al:Rectangle" background="//@colors.3" foreground="//@colors.2" lineWidth="1" transparency="0.0" width="180" height="80" x="30" y="30">
+ <graphicsAlgorithmChildren xsi:type="al:Rectangle" foreground="//@colors.2" lineWidth="1" filled="false" lineVisible="false" transparency="0.0" width="20" height="10" x="150" y="50"/>
+ <graphicsAlgorithmChildren xsi:type="al:Rectangle" foreground="//@colors.2" lineWidth="1" filled="false" lineVisible="false" transparency="0.0" width="20" height="10" x="145" y="65"/>
</graphicsAlgorithmChildren>
</graphicsAlgorithm>
<link>
@@ -56,16 +56,16 @@
</link>
<anchors xsi:type="pi:ChopboxAnchor" referencedGraphicsAlgorithm="//@children.0/@children.1/@graphicsAlgorithm/@graphicsAlgorithmChildren.0"/>
<children visible="true">
- <graphicsAlgorithm xsi:type="al:Text" background="//@colors.2" foreground="//@colors.2" lineWidth="1" transparency="0.0" width="117" height="67" x="30" y="30" font="//@fonts.0" horizontalAlignment="ALIGNMENT_CENTER" value="Sender&#xA;(Sender)"/>
+ <graphicsAlgorithm xsi:type="al:Text" background="//@colors.2" foreground="//@colors.2" lineWidth="1" transparency="0.0" width="180" height="80" x="30" y="30" font="//@fonts.0" horizontalAlignment="ALIGNMENT_CENTER" value="Sender&#xA;(SenderManual)"/>
</children>
<children xsi:type="pi:ContainerShape" visible="true" active="true">
<properties key="obj-type" value="port"/>
<properties key="item-kind" value="C"/>
- <graphicsAlgorithm xsi:type="al:Rectangle" lineWidth="1" filled="false" lineVisible="false" transparency="0.0" width="60" height="60" x="60" y="67">
+ <graphicsAlgorithm xsi:type="al:Rectangle" lineWidth="1" filled="false" lineVisible="false" transparency="0.0" width="60" height="60" x="77" y="80">
<graphicsAlgorithmChildren xsi:type="al:Rectangle" background="//@colors.1" foreground="//@colors.2" lineWidth="1" transparency="0.0" width="18" height="18" x="21" y="21"/>
</graphicsAlgorithm>
<link>
- <businessObjects href="../cGenRef.room#Port:Sender$dataOut"/>
+ <businessObjects href="../cGenRef.room#Port:SenderManual$dataOut"/>
</link>
<anchors xsi:type="pi:ChopboxAnchor" outgoingConnections="//@connections.0" referencedGraphicsAlgorithm="//@children.0/@children.1/@children.1/@graphicsAlgorithm/@graphicsAlgorithmChildren.0"/>
<children visible="true">
diff --git a/tests/org.eclipse.etrice.generator.c.tests/src-gen/cGenRef/CommunicationProtocol.c b/examples/org.eclipse.etrice.generator.c.reference/src-gen/cGenRef/CommunicationProtocol.c
index 22bc04cec..4ff412e02 100644
--- a/tests/org.eclipse.etrice.generator.c.tests/src-gen/cGenRef/CommunicationProtocol.c
+++ b/examples/org.eclipse.etrice.generator.c.reference/src-gen/cGenRef/CommunicationProtocol.c
@@ -1,3 +1,10 @@
+/**
+ * @author generated by eTrice
+ *
+ * Source File of ProtocolClass CommunicationProtocol
+ *
+ */
+
#include "CommunicationProtocol.h"
/*--------------------- port classes */
diff --git a/examples/org.eclipse.etrice.generator.c.reference/src-gen/cGenRef/CommunicationProtocol.h b/examples/org.eclipse.etrice.generator.c.reference/src-gen/cGenRef/CommunicationProtocol.h
new file mode 100644
index 000000000..a600e07e8
--- /dev/null
+++ b/examples/org.eclipse.etrice.generator.c.reference/src-gen/cGenRef/CommunicationProtocol.h
@@ -0,0 +1,49 @@
+/**
+ * @author generated by eTrice
+ *
+ * Header File of ProtocolClass CommunicationProtocol
+ *
+ */
+
+#ifndef _COMMUNICATIONPROTOCOL_H_
+#define _COMMUNICATIONPROTOCOL_H_
+
+#include "etDatatypes.h"
+#include "etPort.h"
+
+
+#include "DataClass1.h"
+
+/* message IDs */
+enum {
+ CommunicationProtocol_MSG_MIN = 0,
+ /* IDs for outgoing messages */
+ CommunicationProtocol_OUT_receivedData = 1,
+ /* IDs for incoming messages */
+ CommunicationProtocol_IN_sendData = 2,
+ CommunicationProtocol_IN_sendData2 = 3,
+ /* error if msgID >= MSG_MAX */
+ CommunicationProtocol_MSG_MAX = 4
+};
+
+/*--------------------- port classes */
+
+typedef etPort CommunicationProtocolPort;
+
+
+
+
+typedef etPort CommunicationProtocolConjPort;
+
+
+
+
+/*--------------------- debug helpers */
+
+/* get message string for message id */
+const char* CommunicationProtocol_getMessageString(int msg_id);
+
+
+
+#endif /* _COMMUNICATIONPROTOCOL_H_ */
+
diff --git a/examples/org.eclipse.etrice.generator.c.reference/src-gen/cGenRef/ReceiverManual.c b/examples/org.eclipse.etrice.generator.c.reference/src-gen/cGenRef/ReceiverManual.c
new file mode 100644
index 000000000..aa5113e40
--- /dev/null
+++ b/examples/org.eclipse.etrice.generator.c.reference/src-gen/cGenRef/ReceiverManual.c
@@ -0,0 +1,14 @@
+/**
+ * @author generated by eTrice
+ *
+ * Source File of ActorClass ReceiverManual
+ *
+ */
+
+#include "ReceiverManual.h"
+
+
+void ReceiverManual_ReceiveMessage(void* self, etInt16 localId, const etMessage*){
+ etLogger_logInfoF("ReceiverManual_ReceiveMessage");
+}
+
diff --git a/examples/org.eclipse.etrice.generator.c.reference/src-gen/cGenRef/ReceiverManual.h b/examples/org.eclipse.etrice.generator.c.reference/src-gen/cGenRef/ReceiverManual.h
new file mode 100644
index 000000000..a1d21b256
--- /dev/null
+++ b/examples/org.eclipse.etrice.generator.c.reference/src-gen/cGenRef/ReceiverManual.h
@@ -0,0 +1,38 @@
+/**
+ * @author generated by eTrice
+ *
+ * Header File of ActorClass ReceiverManual
+ *
+ */
+
+#ifndef _RECEIVERMANUAL_H_
+#define _RECEIVERMANUAL_H_
+
+#include "etDatatypes.h"
+
+
+#include "CommunicationProtocol.h"
+
+
+typedef struct ReceiverManual ReceiverManual;
+
+/* const part of ActorClass (ROM) */
+typedef struct ReceiverManual_const {
+ const ReceiverManual* actor;
+ /* Ports */
+ const CommunicationProtocolPort dataIn;
+
+} ReceiverManual_const;
+
+/* variable part of ActorClass (RAM) */
+struct ReceiverManual {
+ const ReceiverManual_const* constData;
+};
+
+void ReceiverManual_ReceiveMessage(void* self, etInt16 localId, const etMessage*);
+
+
+
+
+#endif /* _RECEIVERMANUAL_H_ */
+
diff --git a/examples/org.eclipse.etrice.generator.c.reference/src-gen/cGenRef/SenderManual.c b/examples/org.eclipse.etrice.generator.c.reference/src-gen/cGenRef/SenderManual.c
new file mode 100644
index 000000000..0ba6959ee
--- /dev/null
+++ b/examples/org.eclipse.etrice.generator.c.reference/src-gen/cGenRef/SenderManual.c
@@ -0,0 +1,14 @@
+/**
+ * @author generated by eTrice
+ *
+ * Source File of ActorClass SenderManual
+ *
+ */
+
+#include "SenderManual.h"
+
+
+void SenderManual_ReceiveMessage(void* self, etInt16 localId, const etMessage*){
+ etLogger_logInfoF("SenderManual_ReceiveMessage");
+}
+
diff --git a/examples/org.eclipse.etrice.generator.c.reference/src-gen/cGenRef/SenderManual.h b/examples/org.eclipse.etrice.generator.c.reference/src-gen/cGenRef/SenderManual.h
new file mode 100644
index 000000000..b131993a7
--- /dev/null
+++ b/examples/org.eclipse.etrice.generator.c.reference/src-gen/cGenRef/SenderManual.h
@@ -0,0 +1,39 @@
+/**
+ * @author generated by eTrice
+ *
+ * Header File of ActorClass SenderManual
+ *
+ */
+
+#ifndef _SENDERMANUAL_H_
+#define _SENDERMANUAL_H_
+
+#include "etDatatypes.h"
+
+#include "DataClass1.h"
+
+#include "CommunicationProtocol.h"
+
+
+typedef struct SenderManual SenderManual;
+
+/* const part of ActorClass (ROM) */
+typedef struct SenderManual_const {
+ const SenderManual* actor;
+ /* Ports */
+ const CommunicationProtocolConjPort dataOut;
+
+} SenderManual_const;
+
+/* variable part of ActorClass (RAM) */
+struct SenderManual {
+ const SenderManual_const* constData;
+};
+
+void SenderManual_ReceiveMessage(void* self, etInt16 localId, const etMessage*);
+
+
+
+
+#endif /* _SENDERMANUAL_H_ */
+
diff --git a/examples/org.eclipse.etrice.generator.c.reference/src-gen/cGenRef/SubSys.c b/examples/org.eclipse.etrice.generator.c.reference/src-gen/cGenRef/SubSys.c
index 2f406e75c..eca7b5290 100644
--- a/examples/org.eclipse.etrice.generator.c.reference/src-gen/cGenRef/SubSys.c
+++ b/examples/org.eclipse.etrice.generator.c.reference/src-gen/cGenRef/SubSys.c
@@ -7,6 +7,9 @@
#include "SubSys.h"
+/* include instances for all classes */
+#include "SubSys_Inst.h"
+
#include "etLogger.h"
/* data for SubSysten SubSys */
@@ -18,6 +21,10 @@ static SubSys SubSysInst = {"SubSys"};
void SubSys_init(void){
etLogger_logInfoF("%s_init", SubSysInst.name);
+
+ /* initialization of all message services */
+ etMessageService_init(&msgService_Thread1, msgBuffer_Thread1, MESSAGE_POOL_MAX, MESSAGE_BLOCK_SIZE);
+
}
void SubSys_start(void){
diff --git a/examples/org.eclipse.etrice.generator.c.reference/src-gen/cGenRef/SubSys.h b/examples/org.eclipse.etrice.generator.c.reference/src-gen/cGenRef/SubSys.h
index 1a7674395..eee116929 100644
--- a/examples/org.eclipse.etrice.generator.c.reference/src-gen/cGenRef/SubSys.h
+++ b/examples/org.eclipse.etrice.generator.c.reference/src-gen/cGenRef/SubSys.h
@@ -13,13 +13,13 @@
* init -> start -> run (loop) -> stop -> destroy
*/
-void SubSys_init(void); // lifecycle init
-void SubSys_start(void); // lifecycle start
+void SubSys_init(void); /* lifecycle init */
+void SubSys_start(void); /* lifecycle start */
-void SubSys_run(void);
+void SubSys_run(void); /* lifecycle run */
-void SubSys_stop(void); // lifecycle stop
-void SubSys_destroy(void); // lifecycle destroy
+void SubSys_stop(void); /* lifecycle stop */
+void SubSys_destroy(void); /* lifecycle destroy */
#endif /* _SUBSYS_H_ */
diff --git a/examples/org.eclipse.etrice.generator.c.reference/src-gen/cGenRef/SubSys_Inst.h b/examples/org.eclipse.etrice.generator.c.reference/src-gen/cGenRef/SubSys_Inst.h
new file mode 100644
index 000000000..2feae0971
--- /dev/null
+++ b/examples/org.eclipse.etrice.generator.c.reference/src-gen/cGenRef/SubSys_Inst.h
@@ -0,0 +1,54 @@
+/**
+ * @author generated by eTrice
+ *
+ * Instance File of SubSystemClass SubSys
+ * - instantiation of all actor instances and port instances
+ * - configuration of data and connection of ports
+ */
+
+#include "etMessageService.h"
+
+/* instantiation of message services */
+#define MESSAGE_POOL_MAX 10
+#define MESSAGE_BLOCK_SIZE 32
+/* MessageService for Thread1 */
+uint8 msgBuffer_Thread1[MESSAGE_POOL_MAX*MESSAGE_BLOCK_SIZE];
+etMessageService msgService_Thread1;
+
+
+/* include all used ActorClasses */
+/* TODO: only include used Actor Classes for current SubSystem */
+#include "SenderManual.h"
+#include "ReceiverManual.h"
+
+/* include all used ProtcolClasses */
+#include "CommunicationProtocol.h"
+
+
+/* declarations of all ActorClass instances (const and variable structs) */
+
+/* forward declaration of varible actor structs */
+static ReceiverManual _SubSys_Receiver;
+static SenderManual _SubSys_Sender;
+
+
+/* instance _SubSys_Receiver */
+static const ReceiverManual_const _SubSys_Receiver_const = {
+ &_SubSys_Receiver,
+ /* Ports: {myActor, etReceiveMessage, msgService, peerAddress, localId} */
+ {&_SubSys_Receiver, NULL, &msgService_Thread1, 1, 123} /* Port dataIn */
+
+};
+static ReceiverManual _SubSys_Receiver = {&_SubSys_Receiver_const};
+
+/* instance _SubSys_Sender */
+static const SenderManual_const _SubSys_Sender_const = {
+ &_SubSys_Sender,
+ /* Ports: {myActor, etReceiveMessage, msgService, peerAddress, localId} */
+ {&_SubSys_Sender, NULL, &msgService_Thread1, 1, 123} /* Port dataOut */
+
+};
+static SenderManual _SubSys_Sender = {&_SubSys_Sender_const};
+
+
+
diff --git a/examples/org.eclipse.etrice.generator.c.reference/src/test/experiments/test.h b/examples/org.eclipse.etrice.generator.c.reference/src/test/experiments/test.h
index cb4ddabe1..a7df3481b 100644
--- a/examples/org.eclipse.etrice.generator.c.reference/src/test/experiments/test.h
+++ b/examples/org.eclipse.etrice.generator.c.reference/src/test/experiments/test.h
@@ -11,14 +11,14 @@ struct MyActor {
const MyActor_const* constData;
};
-static const MyActor Actor1;
-static const MyActor Actor2;
+static MyActor Actor1;
+static MyActor Actor2;
static const MyActor_const Actor1_const = {&Actor1};
static const MyActor_const Actor2_const = {&Actor2};
-static const MyActor Actor1 = {&Actor1_const};
-static const MyActor Actor2 = {&Actor2_const};;
+static MyActor Actor1 = {&Actor1_const};
+static MyActor Actor2 = {&Actor2_const};;
//*****************************
diff --git a/plugins/org.eclipse.etrice.generator.c/issues.txt b/plugins/org.eclipse.etrice.generator.c/issues.txt
index a0929f578..b8125a97e 100644
--- a/plugins/org.eclipse.etrice.generator.c/issues.txt
+++ b/plugins/org.eclipse.etrice.generator.c/issues.txt
@@ -2,5 +2,6 @@ Issues for codegenerators:
- unify all include guards
- unify all generated sourcefile documentation
+- unify function signatures, argument lists
-
+SubSystemClassGen.xtend : /* TODO: only include used Actor Classes for current SubSystem */
diff --git a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/ActorClassGen.xtend b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/ActorClassGen.xtend
index 44fe509a8..f9583c2fa 100644
--- a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/ActorClassGen.xtend
+++ b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/ActorClassGen.xtend
@@ -56,22 +56,17 @@ class ActorClassGen {
}
def generateHeaderFile(Root root, ExpandedActorClass xpac, ActorClass ac) {'''
- #ifndef _«xpac.name»_H_
- #define _«xpac.name»_H_
+ /**
+ * @author generated by eTrice
+ *
+ * Header File of ActorClass «xpac.name»
+ *
+ */
+
+ «generateIncludeGuardBegin(xpac.name)»
#include "etDatatypes.h"
- package «ac.getPackage»;
-
-««« import org.eclipse.etrice.runtime.java.messaging.Address;
-««« import org.eclipse.etrice.runtime.java.messaging.IRTObject;
-««« import org.eclipse.etrice.runtime.java.messaging.IMessageReceiver;
-««« import org.eclipse.etrice.runtime.java.modelbase.ActorClassBase;
-««« import org.eclipse.etrice.runtime.java.modelbase.SubSystemClassBase;
-««« import org.eclipse.etrice.runtime.java.modelbase.InterfaceItemBase;
-««« import org.eclipse.etrice.runtime.java.debugging.DebuggingService;
-
-
«FOR dataClass : root.getReferencedDataClasses(ac)»#include "«dataClass.name».h"
«ENDFOR»
@@ -80,110 +75,145 @@ class ActorClassGen {
«helpers.UserCode(ac.userCode1)»
+ typedef struct «xpac.name» «xpac.name»;
- public «IF ac.abstract»abstract «ENDIF»class «ac.name» extends «IF ac.base!=null»«ac.base.name»«ELSE»ActorClassBase«ENDIF» {
-
- «helpers.UserCode(ac.userCode2)»
-
- //--------------------- ports
- «FOR ep : ac.getEndPorts()»
- protected «ep.getPortClassName()» «ep.name» = null;
- «ENDFOR»
- //--------------------- saps
- «FOR sap : ac.strSAPs»
- protected «sap.getPortClassName()» «sap.name» = null;
- «ENDFOR»
- //--------------------- services
- «FOR svc : ac.serviceImplementations»
- protected «svc.getPortClassName()» «svc.spp.name» = null;
- «ENDFOR»
-
- //--------------------- interface item IDs
+ /* const part of ActorClass (ROM) */
+ typedef struct «xpac.name»_const {
+ const «xpac.name»* actor;
+ /* Ports */
«FOR ep : ac.getEndPorts()»
- protected static final int IFITEM_«ep.name» = «xpac.getInterfaceItemLocalId(ep)+1»;
- «ENDFOR»
- «FOR sap : ac.strSAPs»
- protected static final int IFITEM_«sap.name» = «xpac.getInterfaceItemLocalId(sap)+1»;
+ const «ep.getPortClassName()» «ep.name»;
«ENDFOR»
- «FOR svc : ac.serviceImplementations»
- protected static final int IFITEM_«svc.spp.name» = «xpac.getInterfaceItemLocalId(svc.spp)+1»;
- «ENDFOR»
-
- «helpers.Attributes(ac.attributes)»
- «helpers.OperationsDeclaration(ac.operations, ac.name)»
-
- //--------------------- construction
- public «ac.name»(IRTObject parent, String name, Address[][] port_addr, Address[][] peer_addr){
- «IF ac.base==null»
- super(parent, name, port_addr[0][0], peer_addr[0][0]);
- «ELSE»
- super(parent, name, port_addr, peer_addr);
- «ENDIF»
- setClassName("«ac.name»");
-
- «ac.attributes.attributeInitialization»
-
- // own ports
- «FOR ep : ac.getEndPorts()»
- «ep.name» = new «ep.getPortClassName()»(this, "«ep.name»", IFITEM_«ep.name», «IF ep.multiplicity==1»0, «ENDIF»port_addr[IFITEM_«ep.name»]«IF ep.multiplicity==1»[0]«ENDIF», peer_addr[IFITEM_«ep.name»]«IF ep.multiplicity==1»[0]«ENDIF»);
- «ENDFOR»
- // own saps
- «FOR sap : ac.strSAPs»
- «sap.name» = new «sap.getPortClassName()»(this, "«sap.name»", IFITEM_«sap.name», 0, port_addr[IFITEM_«sap.name»][0], peer_addr[IFITEM_«sap.name»][0]);
- «ENDFOR»
- // own service implementations
- «FOR svc : ac.serviceImplementations»
- «svc.spp.name» = new «svc.getPortClassName()»(this, "«svc.spp.name»", IFITEM_«svc.spp.name», port_addr[IFITEM_«svc.spp.name»], peer_addr[IFITEM_«svc.spp.name»]);
- «ENDFOR»
- }
+ } «xpac.name»_const;
- //--------------------- lifecycle functions
- public void init(){
- initUser();
- }
-
- public void start(){
- startUser();
- }
-
- «IF !ac.overridesStop()»
- public void stop(){
- stopUser();
- }
- «ENDIF»
-
- public void destroy(){
- destroyUser();
- }
-
- «IF ac.stateMachine != null»
- «stateMachineGen.genStateMachine(xpac, ac)»
- «ELSEIF !xpac.hasStateMachine()»
- //--------------------- no state machine
- @Override
- public void receiveEvent(InterfaceItemBase ifitem, int evt, Object data) {
- handleSystemEvent(ifitem, evt, data);
- }
-
- @Override
- public void executeInitTransition(){
- }
- «ENDIF»
+ /* variable part of ActorClass (RAM) */
+ struct «xpac.name» {
+ const «xpac.name»_const* constData;
};
+
+ void «xpac.name»_ReceiveMessage(void* self, etInt16 localId, const etMessage*);
+
+
+««« public «IF ac.abstract»abstract «ENDIF»class «ac.name» extends «IF ac.base!=null»«ac.base.name»«ELSE»ActorClassBase«ENDIF» {
+«««
+«««
+««« //--------------------- ports
+««« «FOR ep : ac.getEndPorts()»
+««« protected «ep.getPortClassName()» «ep.name» = null;
+««« «ENDFOR»
+««« //--------------------- saps
+««« «FOR sap : ac.strSAPs»
+««« protected «sap.getPortClassName()» «sap.name» = null;
+««« «ENDFOR»
+««« //--------------------- services
+««« «FOR svc : ac.serviceImplementations»
+««« protected «svc.getPortClassName()» «svc.spp.name» = null;
+««« «ENDFOR»
+«««
+««« //--------------------- interface item IDs
+««« «FOR ep : ac.getEndPorts()»
+««« protected static final int IFITEM_«ep.name» = «xpac.getInterfaceItemLocalId(ep)+1»;
+««« «ENDFOR»
+««« «FOR sap : ac.strSAPs»
+««« protected static final int IFITEM_«sap.name» = «xpac.getInterfaceItemLocalId(sap)+1»;
+««« «ENDFOR»
+««« «FOR svc : ac.serviceImplementations»
+««« protected static final int IFITEM_«svc.spp.name» = «xpac.getInterfaceItemLocalId(svc.spp)+1»;
+««« «ENDFOR»
+«««
+««« «helpers.Attributes(ac.attributes)»
+««« «helpers.OperationsDeclaration(ac.operations, ac.name)»
+«««
+««« //--------------------- construction
+««« public «ac.name»(IRTObject parent, String name, Address[][] port_addr, Address[][] peer_addr){
+««« «IF ac.base==null»
+««« super(parent, name, port_addr[0][0], peer_addr[0][0]);
+««« «ELSE»
+««« super(parent, name, port_addr, peer_addr);
+««« «ENDIF»
+««« setClassName("«ac.name»");
+«««
+««« «ac.attributes.attributeInitialization»
+«««
+««« // own ports
+««« «FOR ep : ac.getEndPorts()»
+««« «ep.name» = new «ep.getPortClassName()»(this, "«ep.name»", IFITEM_«ep.name», «IF ep.multiplicity==1»0, «ENDIF»port_addr[IFITEM_«ep.name»]«IF ep.multiplicity==1»[0]«ENDIF», peer_addr[IFITEM_«ep.name»]«IF ep.multiplicity==1»[0]«ENDIF»);
+««« «ENDFOR»
+««« // own saps
+««« «FOR sap : ac.strSAPs»
+««« «sap.name» = new «sap.getPortClassName()»(this, "«sap.name»", IFITEM_«sap.name», 0, port_addr[IFITEM_«sap.name»][0], peer_addr[IFITEM_«sap.name»][0]);
+««« «ENDFOR»
+««« // own service implementations
+««« «FOR svc : ac.serviceImplementations»
+««« «svc.spp.name» = new «svc.getPortClassName()»(this, "«svc.spp.name»", IFITEM_«svc.spp.name», port_addr[IFITEM_«svc.spp.name»], peer_addr[IFITEM_«svc.spp.name»]);
+««« «ENDFOR»
+««« }
+«««
+«««
+««« //--------------------- lifecycle functions
+««« public void init(){
+««« initUser();
+««« }
+«««
+««« public void start(){
+««« startUser();
+««« }
+«««
+««« «IF !ac.overridesStop()»
+««« public void stop(){
+««« stopUser();
+««« }
+««« «ENDIF»
+«««
+««« public void destroy(){
+««« destroyUser();
+««« }
+«««
+«««
+«««
+««« «IF ac.stateMachine != null»
+««« «stateMachineGen.genStateMachine(xpac, ac)»
+««« «ELSEIF !xpac.hasStateMachine()»
+««« //--------------------- no state machine
+««« @Override
+««« public void receiveEvent(InterfaceItemBase ifitem, int evt, Object data) {
+««« handleSystemEvent(ifitem, evt, data);
+««« }
+«««
+««« @Override
+««« public void executeInitTransition(){
+««« }
+««« «ENDIF»
+««« };
+
+ «helpers.UserCode(ac.userCode2)»
- #endif /* _«xpac.name»_H_ */
+ «generateIncludeGuardEnd(xpac.name)»
'''
}
def generateSourceFile(Root root, ExpandedActorClass xpac, ActorClass ac) {'''
- #include "«xpac.getCHeaderFileName»"
-
- '''
+ /**
+ * @author generated by eTrice
+ *
+ * Source File of ActorClass «xpac.name»
+ *
+ */
+
+ #include "«xpac.getCHeaderFileName»"
+
+ «helpers.UserCode(xpac.userCode3)»
+
+ void «xpac.name»_ReceiveMessage(void* self, etInt16 localId, const etMessage*){
+ etLogger_logInfoF("«xpac.name»_ReceiveMessage");
+ }
+
+ '''
}
- def msgArgs(Message msg) {
- '''«IF msg.data!=null»«msg.data.defaultValue()»«ENDIF»'''
- }
+// def msgArgs(Message msg) {
+// '''«IF msg.data!=null»«msg.data.defaultValue()»«ENDIF»'''
+// }
} \ No newline at end of file
diff --git a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/CExtensions.xtend b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/CExtensions.xtend
index ecb13f00e..25bb074b7 100644
--- a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/CExtensions.xtend
+++ b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/CExtensions.xtend
@@ -80,6 +80,10 @@ class CExtensions implements ILanguageExtension {
return rc.name+".c";
}
+ def String getInstSourceFileName(RoomClass rc) {
+ return rc.name+"_Inst.h";
+ }
+
def getIncludeGuardString(String filename){
'''_«filename.toUpperCase»_H_'''
}
diff --git a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/MainGen.xtend b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/MainGen.xtend
index ec4181d09..c4398b24a 100644
--- a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/MainGen.xtend
+++ b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/MainGen.xtend
@@ -42,8 +42,8 @@ class MainGen implements IGenerator {
def void doGenerate(Root e) {
dataClassGen.doGenerate(e);
- //protocolClassGen.doGenerate(e);
- //actorClassGen.doGenerate(e);
+ protocolClassGen.doGenerate(e);
+ actorClassGen.doGenerate(e);
subsystemClassGen.doGenerate(e);
if (!e.library) {
diff --git a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/ProtocolClassGen.xtend b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/ProtocolClassGen.xtend
index 4210fe897..21165613e 100644
--- a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/ProtocolClassGen.xtend
+++ b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/ProtocolClassGen.xtend
@@ -51,21 +51,23 @@ class ProtocolClassGen {
def generateHeaderFile(Root root, ProtocolClass pc) {'''
- #ifndef _«pc.name»_H_
- #define _«pc.name»_H_
+ /**
+ * @author generated by eTrice
+ *
+ * Header File of ProtocolClass «pc.name»
+ *
+ */
+
+ «generateIncludeGuardBegin(pc.name)»
#include "etDatatypes.h"
+ #include "etPort.h"
«helpers.UserCode(pc.userCode1)»
«FOR dataClass : root.getReferencedDataClasses(pc)»#include "«dataClass.name».h"
«ENDFOR»
- typedef struct {
-
-
- } «pc.name»;
-
/* message IDs */
enum {
«pc.name»_MSG_MIN = 0,
@@ -95,12 +97,19 @@ class ProtocolClassGen {
«helpers.UserCode(pc.userCode2)»
- #endif /* _«pc.name»_H_ */
+ «generateIncludeGuardEnd(pc.name)»
'''
}
def generateSourceFile(Root root, ProtocolClass pc) {'''
+ /**
+ * @author generated by eTrice
+ *
+ * Source File of ProtocolClass «pc.name»
+ *
+ */
+
#include "«pc.getCHeaderFileName»"
/*--------------------- port classes */
@@ -237,8 +246,8 @@ class ProtocolClassGen {
typedef etPort «portClassName»;
- «ClassOperationSignature(portClassName, "MyOperation1", "int a, int b", "void", true)»
- «ClassOperationSignature(portClassName, "MyOperation2", "", "int", false)»
+««« «ClassOperationSignature(portClassName, "MyOperation1", "int a, int b", "void", true)»
+««« «ClassOperationSignature(portClassName, "MyOperation2", "", "int", false)»
'''
diff --git a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/SubSystemClassGen.xtend b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/SubSystemClassGen.xtend
index 85e6a6dd0..e3e89029e 100644
--- a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/SubSystemClassGen.xtend
+++ b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/SubSystemClassGen.xtend
@@ -49,6 +49,10 @@ class SubSystemClassGen {
fileAccess.setOutputPath(path)
fileAccess.generateFile(file, root.generateSourceFile(ssi, ssi.subSystemClass))
+ file = ssi.subSystemClass.getInstSourceFileName
+ logger.logInfo("generating SubSystemClass instance file: '"+file+"' in '"+path+"'")
+ fileAccess.setOutputPath(path)
+ fileAccess.generateFile(file, root.generateInstanceFile(ssi, ssi.subSystemClass))
}
}
@@ -67,13 +71,13 @@ class SubSystemClassGen {
* init -> start -> run (loop) -> stop -> destroy
*/
- void «ssc.name»_init(void); // lifecycle init
- void «ssc.name»_start(void); // lifecycle start
+ void «ssc.name»_init(void); /* lifecycle init */
+ void «ssc.name»_start(void); /* lifecycle start */
- void «ssc.name»_run(void);
+ void «ssc.name»_run(void); /* lifecycle run */
- void «ssc.name»_stop(void); // lifecycle stop
- void «ssc.name»_destroy(void); // lifecycle destroy
+ void «ssc.name»_stop(void); /* lifecycle stop */
+ void «ssc.name»_destroy(void); /* lifecycle destroy */
«generateIncludeGuardEnd(ssc.name)»
@@ -92,6 +96,9 @@ class SubSystemClassGen {
#include "«ssc.getCHeaderFileName»"
+ /* include instances for all classes */
+ #include "«ssc.getInstSourceFileName»"
+
#include "etLogger.h"
/* data for SubSysten «ssc.name» */
@@ -103,6 +110,10 @@ class SubSystemClassGen {
void «ssc.name»_init(void){
etLogger_logInfoF("%s_init", «ssc.name»Inst.name);
+
+ /* initialization of all message services */
+ etMessageService_init(&msgService_Thread1, msgBuffer_Thread1, MESSAGE_POOL_MAX, MESSAGE_BLOCK_SIZE);
+
}
void «ssc.name»_start(void){
@@ -128,6 +139,77 @@ class SubSystemClassGen {
'''
}
+ def generateInstanceFile(Root root, SubSystemInstance ssi, SubSystemClass ssc) {'''
+ /**
+ * @author generated by eTrice
+ *
+ * Instance File of SubSystemClass «ssc.name»
+ * - instantiation of all actor instances and port instances
+ * - configuration of data and connection of ports
+ */
+
+ #include "etMessageService.h"
+
+ /* instantiation of message services */
+ #define MESSAGE_POOL_MAX 10
+ #define MESSAGE_BLOCK_SIZE 32
+ /* MessageService for Thread1 */
+ uint8 msgBuffer_Thread1[MESSAGE_POOL_MAX*MESSAGE_BLOCK_SIZE];
+ etMessageService msgService_Thread1;
+
+
+ /* include all used ActorClasses */
+ /* TODO: only include used Actor Classes for current SubSystem */
+ «FOR actorClass : root.getUsedActorClasses()»#include "«actorClass.name».h"
+ «ENDFOR»
+
+ /* include all used ProtcolClasses */
+ «FOR protocolClass : root.getUsedProtocolClasses()»#include "«protocolClass.name».h"
+ «ENDFOR»
+
+
+ /* declarations of all ActorClass instances (const and variable structs) */
+
+ /* forward declaration of varible actor structs */
+ «FOR ai : ssi.allContainedInstances»
+ static «ai.actorClass.name» «ai.path.getPathName()»;
+ «ENDFOR»
+
+ «FOR ai : ssi.allContainedInstances»
+
+ /* instance «ai.path.getPathName()» */
+ static const «ai.actorClass.name»_const «ai.path.getPathName()»_const = {
+ &«ai.path.getPathName()»,
+ /* Ports: {myActor, etReceiveMessage, msgService, peerAddress, localId} */
+ «FOR port : ai.actorClass.endPorts»
+ {&«ai.path.getPathName()», NULL, &msgService_Thread1, 1, 123} /* Port «port.name» */
+ «ENDFOR»
+
+ };
+ static «ai.actorClass.name» «ai.path.getPathName()» = {&«ai.path.getPathName()»_const};
+ «ENDFOR»
+
+
+««« «FOR ai : ssi.allContainedInstances»
+««« // actor instance «ai.path» itself => Systemport Address
+««« // TODOTJ: For each Actor, multiple addresses should be generated (actor?, systemport, debugport)
+««« Address addr_item_«ai.path.getPathName()» = new Address(0,«ai.threadId»,«ai.objId»);
+««« // interface items of «ai.path»
+««« «FOR pi : ai.orderedIfItemInstances»
+««« «IF pi instanceof ServiceImplInstance || pi.peers.size>1»
+««« «FOR peer : pi.peers»
+««« «var i = pi.peers.indexOf(peer)»
+««« Address addr_item_«pi.path.getPathName()»_«i» = new Address(0,«pi.threadId»,«pi.objId+i»);
+««« «ENDFOR»
+««« «ELSE»
+««« Address addr_item_«pi.path.getPathName()» = new Address(0,«ai.threadId»,«pi.objId»);
+««« «ENDIF»
+««« «ENDFOR»
+««« «ENDFOR»
+
+ '''
+ }
+
// «var models = root.getReferencedModels(ssc)»
// «FOR model : models»import «model.name».*;«ENDFOR»
diff --git a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/ActorClassGen.java b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/ActorClassGen.java
index 92339fc08..b668d859c 100644
--- a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/ActorClassGen.java
+++ b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/ActorClassGen.java
@@ -1,584 +1,279 @@
-package org.eclipse.etrice.generator.c.gen;
-
-import com.google.inject.Inject;
-import com.google.inject.Singleton;
-import java.util.HashSet;
-import java.util.List;
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.etrice.core.room.ActorClass;
-import org.eclipse.etrice.core.room.Attribute;
-import org.eclipse.etrice.core.room.DataClass;
-import org.eclipse.etrice.core.room.DetailCode;
-import org.eclipse.etrice.core.room.Message;
-import org.eclipse.etrice.core.room.Port;
-import org.eclipse.etrice.core.room.ProtocolClass;
-import org.eclipse.etrice.core.room.SAPRef;
-import org.eclipse.etrice.core.room.SPPRef;
-import org.eclipse.etrice.core.room.ServiceImplementation;
-import org.eclipse.etrice.core.room.StandardOperation;
-import org.eclipse.etrice.core.room.StateMachine;
-import org.eclipse.etrice.core.room.VarDecl;
-import org.eclipse.etrice.generator.base.ILogger;
-import org.eclipse.etrice.generator.c.gen.CExtensions;
-import org.eclipse.etrice.generator.c.gen.StateMachineGen;
-import org.eclipse.etrice.generator.etricegen.ExpandedActorClass;
-import org.eclipse.etrice.generator.etricegen.Root;
-import org.eclipse.etrice.generator.extensions.RoomExtensions;
-import org.eclipse.etrice.generator.generic.ProcedureHelpers;
-import org.eclipse.etrice.generator.generic.TypeHelpers;
-import org.eclipse.xtext.generator.JavaIoFileSystemAccess;
-import org.eclipse.xtext.xbase.lib.BooleanExtensions;
-import org.eclipse.xtext.xbase.lib.IntegerExtensions;
-import org.eclipse.xtext.xbase.lib.ObjectExtensions;
-import org.eclipse.xtext.xbase.lib.StringExtensions;
-import org.eclipse.xtext.xtend2.lib.StringConcatenation;
-
-@SuppressWarnings("all")
-@Singleton
-public class ActorClassGen {
- @Inject
- private JavaIoFileSystemAccess fileAccess;
-
- @Inject
- private CExtensions stdExt;
-
- @Inject
- private RoomExtensions roomExt;
-
- @Inject
- private ProcedureHelpers helpers;
-
- @Inject
- private TypeHelpers _typeHelpers;
-
- @Inject
- private StateMachineGen stateMachineGen;
-
- @Inject
- private ILogger logger;
-
- public void doGenerate(final Root root) {
- EList<ExpandedActorClass> _xpActorClasses = root.getXpActorClasses();
- for (final ExpandedActorClass xpac : _xpActorClasses) {
- {
- ActorClass _actorClass = xpac.getActorClass();
- String _generationTargetPath = this.roomExt.getGenerationTargetPath(_actorClass);
- ActorClass _actorClass_1 = xpac.getActorClass();
- String _path = this.roomExt.getPath(_actorClass_1);
- String _operator_plus = StringExtensions.operator_plus(_generationTargetPath, _path);
- String path = _operator_plus;
- ActorClass _actorClass_2 = xpac.getActorClass();
- String _cHeaderFileName = this.stdExt.getCHeaderFileName(_actorClass_2);
- String _operator_plus_1 = StringExtensions.operator_plus("generating ActorClass header \'", _cHeaderFileName);
- String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, "\' in \'");
- String _operator_plus_3 = StringExtensions.operator_plus(_operator_plus_2, path);
- String _operator_plus_4 = StringExtensions.operator_plus(_operator_plus_3, "\'");
- this.logger.logInfo(_operator_plus_4);
- this.fileAccess.setOutputPath(path);
- ActorClass _actorClass_3 = xpac.getActorClass();
- String _cHeaderFileName_1 = this.stdExt.getCHeaderFileName(_actorClass_3);
- ActorClass _actorClass_4 = xpac.getActorClass();
- StringConcatenation _generateHeaderFile = this.generateHeaderFile(root, xpac, _actorClass_4);
- this.fileAccess.generateFile(_cHeaderFileName_1, _generateHeaderFile);
- ActorClass _actorClass_5 = xpac.getActorClass();
- String _cSourceFileName = this.stdExt.getCSourceFileName(_actorClass_5);
- String _operator_plus_5 = StringExtensions.operator_plus("generating ActorClass header \'", _cSourceFileName);
- String _operator_plus_6 = StringExtensions.operator_plus(_operator_plus_5, "\' in \'");
- String _operator_plus_7 = StringExtensions.operator_plus(_operator_plus_6, path);
- String _operator_plus_8 = StringExtensions.operator_plus(_operator_plus_7, "\'");
- this.logger.logInfo(_operator_plus_8);
- this.fileAccess.setOutputPath(path);
- ActorClass _actorClass_6 = xpac.getActorClass();
- String _cSourceFileName_1 = this.stdExt.getCSourceFileName(_actorClass_6);
- ActorClass _actorClass_7 = xpac.getActorClass();
- StringConcatenation _generateSourceFile = this.generateSourceFile(root, xpac, _actorClass_7);
- this.fileAccess.generateFile(_cSourceFileName_1, _generateSourceFile);
- }
- }
- }
-
- public StringConcatenation generateHeaderFile(final Root root, final ExpandedActorClass xpac, final ActorClass ac) {
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("#ifndef _");
- String _name = xpac.getName();
- _builder.append(_name, "");
- _builder.append("_H_");
- _builder.newLineIfNotEmpty();
- _builder.append("#define _");
- String _name_1 = xpac.getName();
- _builder.append(_name_1, "");
- _builder.append("_H_");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("#include \"etDatatypes.h\"");
- _builder.newLine();
- _builder.newLine();
- _builder.append("package ");
- String _package = this.roomExt.getPackage(ac);
- _builder.append(_package, "");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.newLine();
- _builder.newLine();
- {
- HashSet<DataClass> _referencedDataClasses = root.getReferencedDataClasses(ac);
- for(final DataClass dataClass : _referencedDataClasses) {
- _builder.append("#include \"");
- String _name_2 = dataClass.getName();
- _builder.append(_name_2, "");
- _builder.append(".h\"");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.newLine();
- {
- EList<ProtocolClass> _referencedProtocolClasses = root.getReferencedProtocolClasses(ac);
- for(final ProtocolClass pc : _referencedProtocolClasses) {
- _builder.append("#include \"");
- String _name_3 = pc.getName();
- _builder.append(_name_3, "");
- _builder.append(".h\"");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.newLine();
- DetailCode _userCode1 = ac.getUserCode1();
- StringConcatenation _UserCode = this.helpers.UserCode(_userCode1);
- _builder.append(_UserCode, "");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.newLine();
- _builder.append("public ");
- {
- boolean _isAbstract = ac.isAbstract();
- if (_isAbstract) {
- _builder.append("abstract ");
- }
- }
- _builder.append("class ");
- String _name_4 = ac.getName();
- _builder.append(_name_4, "");
- _builder.append(" extends ");
- {
- ActorClass _base = ac.getBase();
- boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_base, null);
- if (_operator_notEquals) {
- ActorClass _base_1 = ac.getBase();
- String _name_5 = _base_1.getName();
- _builder.append(_name_5, "");
- } else {
- _builder.append("ActorClassBase");
- }
- }
- _builder.append(" {");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("\t");
- DetailCode _userCode2 = ac.getUserCode2();
- StringConcatenation _UserCode_1 = this.helpers.UserCode(_userCode2);
- _builder.append(_UserCode_1, " ");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("//--------------------- ports");
- _builder.newLine();
- {
- List<Port> _endPorts = this.roomExt.getEndPorts(ac);
- for(final Port ep : _endPorts) {
- _builder.append("\t");
- _builder.append("protected ");
- String _portClassName = this.roomExt.getPortClassName(ep);
- _builder.append(_portClassName, " ");
- _builder.append(" ");
- String _name_6 = ep.getName();
- _builder.append(_name_6, " ");
- _builder.append(" = null;");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("\t");
- _builder.append("//--------------------- saps");
- _builder.newLine();
- {
- EList<SAPRef> _strSAPs = ac.getStrSAPs();
- for(final SAPRef sap : _strSAPs) {
- _builder.append("\t");
- _builder.append("protected ");
- String _portClassName_1 = this.roomExt.getPortClassName(sap);
- _builder.append(_portClassName_1, " ");
- _builder.append(" ");
- String _name_7 = sap.getName();
- _builder.append(_name_7, " ");
- _builder.append(" = null;");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("\t");
- _builder.append("//--------------------- services");
- _builder.newLine();
- {
- EList<ServiceImplementation> _serviceImplementations = ac.getServiceImplementations();
- for(final ServiceImplementation svc : _serviceImplementations) {
- _builder.append("\t");
- _builder.append("protected ");
- String _portClassName_2 = this.roomExt.getPortClassName(svc);
- _builder.append(_portClassName_2, " ");
- _builder.append(" ");
- SPPRef _spp = svc.getSpp();
- String _name_8 = _spp.getName();
- _builder.append(_name_8, " ");
- _builder.append(" = null;");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.newLine();
- _builder.append("\t");
- _builder.append("//--------------------- interface item IDs");
- _builder.newLine();
- {
- List<Port> _endPorts_1 = this.roomExt.getEndPorts(ac);
- for(final Port ep_1 : _endPorts_1) {
- _builder.append("\t");
- _builder.append("protected static final int IFITEM_");
- String _name_9 = ep_1.getName();
- _builder.append(_name_9, " ");
- _builder.append(" = ");
- int _interfaceItemLocalId = xpac.getInterfaceItemLocalId(ep_1);
- int _operator_plus = IntegerExtensions.operator_plus(((Integer)_interfaceItemLocalId), ((Integer)1));
- _builder.append(_operator_plus, " ");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- }
- }
- {
- EList<SAPRef> _strSAPs_1 = ac.getStrSAPs();
- for(final SAPRef sap_1 : _strSAPs_1) {
- _builder.append("\t");
- _builder.append("protected static final int IFITEM_");
- String _name_10 = sap_1.getName();
- _builder.append(_name_10, " ");
- _builder.append(" = ");
- int _interfaceItemLocalId_1 = xpac.getInterfaceItemLocalId(sap_1);
- int _operator_plus_1 = IntegerExtensions.operator_plus(((Integer)_interfaceItemLocalId_1), ((Integer)1));
- _builder.append(_operator_plus_1, " ");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- }
- }
- {
- EList<ServiceImplementation> _serviceImplementations_1 = ac.getServiceImplementations();
- for(final ServiceImplementation svc_1 : _serviceImplementations_1) {
- _builder.append("\t");
- _builder.append("protected static final int IFITEM_");
- SPPRef _spp_1 = svc_1.getSpp();
- String _name_11 = _spp_1.getName();
- _builder.append(_name_11, " ");
- _builder.append(" = ");
- SPPRef _spp_2 = svc_1.getSpp();
- int _interfaceItemLocalId_2 = xpac.getInterfaceItemLocalId(_spp_2);
- int _operator_plus_2 = IntegerExtensions.operator_plus(((Integer)_interfaceItemLocalId_2), ((Integer)1));
- _builder.append(_operator_plus_2, " ");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t");
- EList<Attribute> _attributes = ac.getAttributes();
- StringConcatenation _Attributes = this.helpers.Attributes(_attributes);
- _builder.append(_Attributes, " ");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- EList<StandardOperation> _operations = ac.getOperations();
- String _name_12 = ac.getName();
- StringConcatenation _OperationsDeclaration = this.helpers.OperationsDeclaration(_operations, _name_12);
- _builder.append(_OperationsDeclaration, " ");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("\t");
- _builder.append("//--------------------- construction");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("public ");
- String _name_13 = ac.getName();
- _builder.append(_name_13, " ");
- _builder.append("(IRTObject parent, String name, Address[][] port_addr, Address[][] peer_addr){");
- _builder.newLineIfNotEmpty();
- {
- ActorClass _base_2 = ac.getBase();
- boolean _operator_equals = ObjectExtensions.operator_equals(_base_2, null);
- if (_operator_equals) {
- _builder.append("\t\t");
- _builder.append("super(parent, name, port_addr[0][0], peer_addr[0][0]);");
- _builder.newLine();
- } else {
- _builder.append("\t\t");
- _builder.append("super(parent, name, port_addr, peer_addr);");
- _builder.newLine();
- }
- }
- _builder.append("\t\t");
- _builder.append("setClassName(\"");
- String _name_14 = ac.getName();
- _builder.append(_name_14, " ");
- _builder.append("\");");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.newLine();
- _builder.append("\t\t");
- EList<Attribute> _attributes_1 = ac.getAttributes();
- StringConcatenation _attributeInitialization = this.helpers.attributeInitialization(_attributes_1);
- _builder.append(_attributeInitialization, " ");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("// own ports");
- _builder.newLine();
- {
- List<Port> _endPorts_2 = this.roomExt.getEndPorts(ac);
- for(final Port ep_2 : _endPorts_2) {
- _builder.append("\t\t");
- String _name_15 = ep_2.getName();
- _builder.append(_name_15, " ");
- _builder.append(" = new ");
- String _portClassName_3 = this.roomExt.getPortClassName(ep_2);
- _builder.append(_portClassName_3, " ");
- _builder.append("(this, \"");
- String _name_16 = ep_2.getName();
- _builder.append(_name_16, " ");
- _builder.append("\", IFITEM_");
- String _name_17 = ep_2.getName();
- _builder.append(_name_17, " ");
- _builder.append(", ");
- {
- int _multiplicity = ep_2.getMultiplicity();
- boolean _operator_equals_1 = ObjectExtensions.operator_equals(((Integer)_multiplicity), ((Integer)1));
- if (_operator_equals_1) {
- _builder.append("0, ");
- }
- }
- _builder.append("port_addr[IFITEM_");
- String _name_18 = ep_2.getName();
- _builder.append(_name_18, " ");
- _builder.append("]");
- {
- int _multiplicity_1 = ep_2.getMultiplicity();
- boolean _operator_equals_2 = ObjectExtensions.operator_equals(((Integer)_multiplicity_1), ((Integer)1));
- if (_operator_equals_2) {
- _builder.append("[0]");
- }
- }
- _builder.append(", peer_addr[IFITEM_");
- String _name_19 = ep_2.getName();
- _builder.append(_name_19, " ");
- _builder.append("]");
- {
- int _multiplicity_2 = ep_2.getMultiplicity();
- boolean _operator_equals_3 = ObjectExtensions.operator_equals(((Integer)_multiplicity_2), ((Integer)1));
- if (_operator_equals_3) {
- _builder.append("[0]");
- }
- }
- _builder.append("); ");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("\t\t");
- _builder.append("// own saps");
- _builder.newLine();
- {
- EList<SAPRef> _strSAPs_2 = ac.getStrSAPs();
- for(final SAPRef sap_2 : _strSAPs_2) {
- _builder.append("\t\t");
- String _name_20 = sap_2.getName();
- _builder.append(_name_20, " ");
- _builder.append(" = new ");
- String _portClassName_4 = this.roomExt.getPortClassName(sap_2);
- _builder.append(_portClassName_4, " ");
- _builder.append("(this, \"");
- String _name_21 = sap_2.getName();
- _builder.append(_name_21, " ");
- _builder.append("\", IFITEM_");
- String _name_22 = sap_2.getName();
- _builder.append(_name_22, " ");
- _builder.append(", 0, port_addr[IFITEM_");
- String _name_23 = sap_2.getName();
- _builder.append(_name_23, " ");
- _builder.append("][0], peer_addr[IFITEM_");
- String _name_24 = sap_2.getName();
- _builder.append(_name_24, " ");
- _builder.append("][0]); ");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("\t\t");
- _builder.append("// own service implementations");
- _builder.newLine();
- {
- EList<ServiceImplementation> _serviceImplementations_2 = ac.getServiceImplementations();
- for(final ServiceImplementation svc_2 : _serviceImplementations_2) {
- _builder.append("\t\t");
- SPPRef _spp_3 = svc_2.getSpp();
- String _name_25 = _spp_3.getName();
- _builder.append(_name_25, " ");
- _builder.append(" = new ");
- String _portClassName_5 = this.roomExt.getPortClassName(svc_2);
- _builder.append(_portClassName_5, " ");
- _builder.append("(this, \"");
- SPPRef _spp_4 = svc_2.getSpp();
- String _name_26 = _spp_4.getName();
- _builder.append(_name_26, " ");
- _builder.append("\", IFITEM_");
- SPPRef _spp_5 = svc_2.getSpp();
- String _name_27 = _spp_5.getName();
- _builder.append(_name_27, " ");
- _builder.append(", port_addr[IFITEM_");
- SPPRef _spp_6 = svc_2.getSpp();
- String _name_28 = _spp_6.getName();
- _builder.append(_name_28, " ");
- _builder.append("], peer_addr[IFITEM_");
- SPPRef _spp_7 = svc_2.getSpp();
- String _name_29 = _spp_7.getName();
- _builder.append(_name_29, " ");
- _builder.append("]); ");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("\t");
- _builder.newLine();
- _builder.newLine();
- _builder.append("\t");
- _builder.append("//--------------------- lifecycle functions");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("public void init(){");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("initUser();");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.newLine();
- _builder.append("\t");
- _builder.append("public void start(){");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("startUser();");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.newLine();
- {
- boolean _overridesStop = this.roomExt.overridesStop(ac);
- boolean _operator_not = BooleanExtensions.operator_not(_overridesStop);
- if (_operator_not) {
- _builder.append("\t");
- _builder.append("public void stop(){");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("\t");
- _builder.append("stopUser();");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- }
- }
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("public void destroy(){");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("destroyUser();");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("}\t");
- _builder.newLine();
- _builder.newLine();
- {
- StateMachine _stateMachine = ac.getStateMachine();
- boolean _operator_notEquals_1 = ObjectExtensions.operator_notEquals(_stateMachine, null);
- if (_operator_notEquals_1) {
- _builder.append("\t");
- StringConcatenation _genStateMachine = this.stateMachineGen.genStateMachine(xpac, ac);
- _builder.append(_genStateMachine, " ");
- _builder.newLineIfNotEmpty();
- } else {
- boolean _hasStateMachine = xpac.hasStateMachine();
- boolean _operator_not_1 = BooleanExtensions.operator_not(_hasStateMachine);
- if (_operator_not_1) {
- _builder.append("\t");
- _builder.append("//--------------------- no state machine");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("@Override");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("public void receiveEvent(InterfaceItemBase ifitem, int evt, Object data) {");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("handleSystemEvent(ifitem, evt, data);");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("@Override");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("public void executeInitTransition(){");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- }
- }
- }
- _builder.append("};");
- _builder.newLine();
- _builder.newLine();
- _builder.append("#endif /* _");
- String _name_30 = xpac.getName();
- _builder.append(_name_30, "");
- _builder.append("_H_ */");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- return _builder;
- }
-
- public StringConcatenation generateSourceFile(final Root root, final ExpandedActorClass xpac, final ActorClass ac) {
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("#include \"");
- String _cHeaderFileName = this.stdExt.getCHeaderFileName(xpac);
- _builder.append(_cHeaderFileName, "");
- _builder.append("\"");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- return _builder;
- }
-
- public StringConcatenation msgArgs(final Message msg) {
- StringConcatenation _builder = new StringConcatenation();
- {
- VarDecl _data = msg.getData();
- boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_data, null);
- if (_operator_notEquals) {
- VarDecl _data_1 = msg.getData();
- String _defaultValue = this._typeHelpers.defaultValue(_data_1);
- _builder.append(_defaultValue, "");
- }
- }
- return _builder;
- }
-}
+package org.eclipse.etrice.generator.c.gen;
+
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+import java.util.HashSet;
+import java.util.List;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.etrice.core.room.ActorClass;
+import org.eclipse.etrice.core.room.DataClass;
+import org.eclipse.etrice.core.room.DetailCode;
+import org.eclipse.etrice.core.room.Port;
+import org.eclipse.etrice.core.room.ProtocolClass;
+import org.eclipse.etrice.generator.base.ILogger;
+import org.eclipse.etrice.generator.c.gen.CExtensions;
+import org.eclipse.etrice.generator.c.gen.StateMachineGen;
+import org.eclipse.etrice.generator.etricegen.ExpandedActorClass;
+import org.eclipse.etrice.generator.etricegen.Root;
+import org.eclipse.etrice.generator.extensions.RoomExtensions;
+import org.eclipse.etrice.generator.generic.ProcedureHelpers;
+import org.eclipse.etrice.generator.generic.TypeHelpers;
+import org.eclipse.xtext.generator.JavaIoFileSystemAccess;
+import org.eclipse.xtext.xbase.lib.StringExtensions;
+import org.eclipse.xtext.xtend2.lib.StringConcatenation;
+
+@SuppressWarnings("all")
+@Singleton
+public class ActorClassGen {
+ @Inject
+ private JavaIoFileSystemAccess fileAccess;
+
+ @Inject
+ private CExtensions stdExt;
+
+ @Inject
+ private RoomExtensions roomExt;
+
+ @Inject
+ private ProcedureHelpers helpers;
+
+ @Inject
+ private TypeHelpers _typeHelpers;
+
+ @Inject
+ private StateMachineGen stateMachineGen;
+
+ @Inject
+ private ILogger logger;
+
+ public void doGenerate(final Root root) {
+ EList<ExpandedActorClass> _xpActorClasses = root.getXpActorClasses();
+ for (final ExpandedActorClass xpac : _xpActorClasses) {
+ {
+ ActorClass _actorClass = xpac.getActorClass();
+ String _generationTargetPath = this.roomExt.getGenerationTargetPath(_actorClass);
+ ActorClass _actorClass_1 = xpac.getActorClass();
+ String _path = this.roomExt.getPath(_actorClass_1);
+ String _operator_plus = StringExtensions.operator_plus(_generationTargetPath, _path);
+ String path = _operator_plus;
+ ActorClass _actorClass_2 = xpac.getActorClass();
+ String _cHeaderFileName = this.stdExt.getCHeaderFileName(_actorClass_2);
+ String _operator_plus_1 = StringExtensions.operator_plus("generating ActorClass header \'", _cHeaderFileName);
+ String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, "\' in \'");
+ String _operator_plus_3 = StringExtensions.operator_plus(_operator_plus_2, path);
+ String _operator_plus_4 = StringExtensions.operator_plus(_operator_plus_3, "\'");
+ this.logger.logInfo(_operator_plus_4);
+ this.fileAccess.setOutputPath(path);
+ ActorClass _actorClass_3 = xpac.getActorClass();
+ String _cHeaderFileName_1 = this.stdExt.getCHeaderFileName(_actorClass_3);
+ ActorClass _actorClass_4 = xpac.getActorClass();
+ StringConcatenation _generateHeaderFile = this.generateHeaderFile(root, xpac, _actorClass_4);
+ this.fileAccess.generateFile(_cHeaderFileName_1, _generateHeaderFile);
+ ActorClass _actorClass_5 = xpac.getActorClass();
+ String _cSourceFileName = this.stdExt.getCSourceFileName(_actorClass_5);
+ String _operator_plus_5 = StringExtensions.operator_plus("generating ActorClass header \'", _cSourceFileName);
+ String _operator_plus_6 = StringExtensions.operator_plus(_operator_plus_5, "\' in \'");
+ String _operator_plus_7 = StringExtensions.operator_plus(_operator_plus_6, path);
+ String _operator_plus_8 = StringExtensions.operator_plus(_operator_plus_7, "\'");
+ this.logger.logInfo(_operator_plus_8);
+ this.fileAccess.setOutputPath(path);
+ ActorClass _actorClass_6 = xpac.getActorClass();
+ String _cSourceFileName_1 = this.stdExt.getCSourceFileName(_actorClass_6);
+ ActorClass _actorClass_7 = xpac.getActorClass();
+ StringConcatenation _generateSourceFile = this.generateSourceFile(root, xpac, _actorClass_7);
+ this.fileAccess.generateFile(_cSourceFileName_1, _generateSourceFile);
+ }
+ }
+ }
+
+ public StringConcatenation generateHeaderFile(final Root root, final ExpandedActorClass xpac, final ActorClass ac) {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("/**");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* @author generated by eTrice");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("*");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* Header File of ActorClass ");
+ String _name = xpac.getName();
+ _builder.append(_name, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append(" ");
+ _builder.append("* ");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("*/");
+ _builder.newLine();
+ _builder.newLine();
+ String _name_1 = xpac.getName();
+ StringConcatenation _generateIncludeGuardBegin = this.stdExt.generateIncludeGuardBegin(_name_1);
+ _builder.append(_generateIncludeGuardBegin, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("#include \"etDatatypes.h\"");
+ _builder.newLine();
+ _builder.newLine();
+ {
+ HashSet<DataClass> _referencedDataClasses = root.getReferencedDataClasses(ac);
+ for(final DataClass dataClass : _referencedDataClasses) {
+ _builder.append("#include \"");
+ String _name_2 = dataClass.getName();
+ _builder.append(_name_2, "");
+ _builder.append(".h\"");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.newLine();
+ {
+ EList<ProtocolClass> _referencedProtocolClasses = root.getReferencedProtocolClasses(ac);
+ for(final ProtocolClass pc : _referencedProtocolClasses) {
+ _builder.append("#include \"");
+ String _name_3 = pc.getName();
+ _builder.append(_name_3, "");
+ _builder.append(".h\"");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.newLine();
+ DetailCode _userCode1 = ac.getUserCode1();
+ StringConcatenation _UserCode = this.helpers.UserCode(_userCode1);
+ _builder.append(_UserCode, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("typedef struct ");
+ String _name_4 = xpac.getName();
+ _builder.append(_name_4, "");
+ _builder.append(" ");
+ String _name_5 = xpac.getName();
+ _builder.append(_name_5, "");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("/* const part of ActorClass (ROM) */");
+ _builder.newLine();
+ _builder.append("typedef struct ");
+ String _name_6 = xpac.getName();
+ _builder.append(_name_6, "");
+ _builder.append("_const {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("const ");
+ String _name_7 = xpac.getName();
+ _builder.append(_name_7, " ");
+ _builder.append("* actor;");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("/* Ports */");
+ _builder.newLine();
+ {
+ List<Port> _endPorts = this.roomExt.getEndPorts(ac);
+ for(final Port ep : _endPorts) {
+ _builder.append("\t");
+ _builder.append("const ");
+ String _portClassName = this.roomExt.getPortClassName(ep);
+ _builder.append(_portClassName, " ");
+ _builder.append(" ");
+ String _name_8 = ep.getName();
+ _builder.append(_name_8, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("} ");
+ String _name_9 = xpac.getName();
+ _builder.append(_name_9, "");
+ _builder.append("_const;");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("/* variable part of ActorClass (RAM) */");
+ _builder.newLine();
+ _builder.append("struct ");
+ String _name_10 = xpac.getName();
+ _builder.append(_name_10, "");
+ _builder.append(" {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("const ");
+ String _name_11 = xpac.getName();
+ _builder.append(_name_11, " ");
+ _builder.append("_const* constData;");
+ _builder.newLineIfNotEmpty();
+ _builder.append("};");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("void ");
+ String _name_12 = xpac.getName();
+ _builder.append(_name_12, "");
+ _builder.append("_ReceiveMessage(void* self, etInt16 localId, const etMessage*);");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.newLine();
+ _builder.newLine();
+ DetailCode _userCode2 = ac.getUserCode2();
+ StringConcatenation _UserCode_1 = this.helpers.UserCode(_userCode2);
+ _builder.append(_UserCode_1, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ String _name_13 = xpac.getName();
+ StringConcatenation _generateIncludeGuardEnd = this.stdExt.generateIncludeGuardEnd(_name_13);
+ _builder.append(_generateIncludeGuardEnd, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ return _builder;
+ }
+
+ public StringConcatenation generateSourceFile(final Root root, final ExpandedActorClass xpac, final ActorClass ac) {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("/**");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* @author generated by eTrice");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("*");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* Source File of ActorClass ");
+ String _name = xpac.getName();
+ _builder.append(_name, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append(" ");
+ _builder.append("* ");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("*/");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("#include \"");
+ String _cHeaderFileName = this.stdExt.getCHeaderFileName(xpac);
+ _builder.append(_cHeaderFileName, "");
+ _builder.append("\"");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ DetailCode _userCode3 = xpac.getUserCode3();
+ StringConcatenation _UserCode = this.helpers.UserCode(_userCode3);
+ _builder.append(_UserCode, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("void ");
+ String _name_1 = xpac.getName();
+ _builder.append(_name_1, "");
+ _builder.append("_ReceiveMessage(void* self, etInt16 localId, const etMessage*){");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("etLogger_logInfoF(\"");
+ String _name_2 = xpac.getName();
+ _builder.append(_name_2, " ");
+ _builder.append("_ReceiveMessage\");");
+ _builder.newLineIfNotEmpty();
+ _builder.append("}");
+ _builder.newLine();
+ _builder.newLine();
+ return _builder;
+ }
+}
diff --git a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/CExtensions.java b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/CExtensions.java
index bf2103adc..dd59ed946 100644
--- a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/CExtensions.java
+++ b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/CExtensions.java
@@ -87,6 +87,12 @@ public class CExtensions implements ILanguageExtension {
return _operator_plus;
}
+ public String getInstSourceFileName(final RoomClass rc) {
+ String _name = rc.getName();
+ String _operator_plus = StringExtensions.operator_plus(_name, "_Inst.h");
+ return _operator_plus;
+ }
+
public StringConcatenation getIncludeGuardString(final String filename) {
StringConcatenation _builder = new StringConcatenation();
_builder.append("_");
diff --git a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/DataClassGen.java b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/DataClassGen.java
index 0dced56c4..fa7f4ee49 100644
--- a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/DataClassGen.java
+++ b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/DataClassGen.java
@@ -1,249 +1,249 @@
-package org.eclipse.etrice.generator.c.gen;
-
-import com.google.inject.Inject;
-import com.google.inject.Singleton;
-import java.util.HashSet;
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.etrice.core.room.Attribute;
-import org.eclipse.etrice.core.room.DataClass;
-import org.eclipse.etrice.core.room.DetailCode;
-import org.eclipse.etrice.core.room.StandardOperation;
-import org.eclipse.etrice.generator.base.ILogger;
-import org.eclipse.etrice.generator.c.gen.CExtensions;
-import org.eclipse.etrice.generator.etricegen.Root;
-import org.eclipse.etrice.generator.extensions.RoomExtensions;
-import org.eclipse.etrice.generator.generic.ProcedureHelpers;
-import org.eclipse.xtext.generator.JavaIoFileSystemAccess;
-import org.eclipse.xtext.xbase.lib.ObjectExtensions;
-import org.eclipse.xtext.xbase.lib.StringExtensions;
-import org.eclipse.xtext.xtend2.lib.StringConcatenation;
-
-@SuppressWarnings("all")
-@Singleton
-public class DataClassGen {
- @Inject
- private JavaIoFileSystemAccess fileAccess;
-
- @Inject
- private CExtensions stdExt;
-
- @Inject
- private RoomExtensions roomExt;
-
- @Inject
- private ProcedureHelpers helpers;
-
- @Inject
- private ILogger logger;
-
- public void doGenerate(final Root root) {
- EList<DataClass> _usedDataClasses = root.getUsedDataClasses();
- for (final DataClass dc : _usedDataClasses) {
- {
- String _generationTargetPath = this.roomExt.getGenerationTargetPath(dc);
- String _path = this.roomExt.getPath(dc);
- String _operator_plus = StringExtensions.operator_plus(_generationTargetPath, _path);
- String path = _operator_plus;
- String _cHeaderFileName = this.stdExt.getCHeaderFileName(dc);
- String _operator_plus_1 = StringExtensions.operator_plus("generating DataClass header \'", _cHeaderFileName);
- String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, "\' in \'");
- String _operator_plus_3 = StringExtensions.operator_plus(_operator_plus_2, path);
- String _operator_plus_4 = StringExtensions.operator_plus(_operator_plus_3, "\'");
- this.logger.logInfo(_operator_plus_4);
- this.fileAccess.setOutputPath(path);
- String _cHeaderFileName_1 = this.stdExt.getCHeaderFileName(dc);
- StringConcatenation _generateHeaderFile = this.generateHeaderFile(root, dc);
- this.fileAccess.generateFile(_cHeaderFileName_1, _generateHeaderFile);
- String _cSourceFileName = this.stdExt.getCSourceFileName(dc);
- String _operator_plus_5 = StringExtensions.operator_plus("generating DataClass source \'", _cSourceFileName);
- String _operator_plus_6 = StringExtensions.operator_plus(_operator_plus_5, "\' in \'");
- String _operator_plus_7 = StringExtensions.operator_plus(_operator_plus_6, path);
- String _operator_plus_8 = StringExtensions.operator_plus(_operator_plus_7, "\'");
- this.logger.logInfo(_operator_plus_8);
- this.fileAccess.setOutputPath(path);
- String _cSourceFileName_1 = this.stdExt.getCSourceFileName(dc);
- StringConcatenation _generateSourceFile = this.generateSourceFile(root, dc);
- this.fileAccess.generateFile(_cSourceFileName_1, _generateSourceFile);
- }
- }
- }
-
- public StringConcatenation generateHeaderFile(final Root root, final DataClass dc) {
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("/**");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("* @author generated by eTrice");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("*");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("* Header File of DataClass ");
- String _name = dc.getName();
- _builder.append(_name, " ");
- _builder.newLineIfNotEmpty();
- _builder.append(" ");
- _builder.append("* ");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("*/");
- _builder.newLine();
- _builder.newLine();
- String _name_1 = dc.getName();
- StringConcatenation _generateIncludeGuardBegin = this.stdExt.generateIncludeGuardBegin(_name_1);
- _builder.append(_generateIncludeGuardBegin, "");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("#include \"etDatatypes.h\"");
- _builder.newLine();
- _builder.newLine();
- _builder.append("/* TODO: includes only for used DataClasses, also for other models */");
- _builder.newLine();
- {
- HashSet<DataClass> _referencedDataClasses = root.getReferencedDataClasses(dc);
- for(final DataClass dataClass : _referencedDataClasses) {
- _builder.append("#include \"");
- String _name_2 = dataClass.getName();
- _builder.append(_name_2, "");
- _builder.append(".h\"");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.newLine();
- DetailCode _userCode1 = dc.getUserCode1();
- StringConcatenation _UserCode = this.helpers.UserCode(_userCode1);
- _builder.append(_UserCode, "");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.newLine();
- _builder.append("typedef struct {");
- _builder.newLine();
- _builder.append("\t");
- DetailCode _userCode2 = dc.getUserCode2();
- StringConcatenation _UserCode_1 = this.helpers.UserCode(_userCode2);
- _builder.append(_UserCode_1, " ");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- EList<Attribute> _attributes = dc.getAttributes();
- StringConcatenation _Attributes = this.helpers.Attributes(_attributes);
- _builder.append(_Attributes, " ");
- _builder.newLineIfNotEmpty();
- _builder.append("} ");
- String _name_3 = dc.getName();
- _builder.append(_name_3, "");
- {
- DataClass _base = dc.getBase();
- boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_base, null);
- if (_operator_notEquals) {
- _builder.append(" /* extends -> inheritance not implemented yet */ ");
- DataClass _base_1 = dc.getBase();
- String _name_4 = _base_1.getName();
- _builder.append(_name_4, "");
- }
- }
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("// TODO: do we need setters and getters for C and C++ ?");
- _builder.newLine();
- _builder.newLine();
- EList<StandardOperation> _operations = dc.getOperations();
- String _name_5 = dc.getName();
- StringConcatenation _OperationsDeclaration = this.helpers.OperationsDeclaration(_operations, _name_5);
- _builder.append(_OperationsDeclaration, "");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("// deep copy");
- _builder.newLine();
- _builder.append("void ");
- String _name_6 = dc.getName();
- _builder.append(_name_6, "");
- _builder.append("_deepCopy(");
- String _name_7 = dc.getName();
- _builder.append(_name_7, "");
- _builder.append("* source, ");
- String _name_8 = dc.getName();
- _builder.append(_name_8, "");
- _builder.append("* target);");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- String _name_9 = dc.getName();
- StringConcatenation _generateIncludeGuardEnd = this.stdExt.generateIncludeGuardEnd(_name_9);
- _builder.append(_generateIncludeGuardEnd, "");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- return _builder;
- }
-
- public StringConcatenation generateSourceFile(final Root root, final DataClass dc) {
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("/**");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("* @author generated by eTrice");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("*");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("* Source File of DataClass ");
- String _name = dc.getName();
- _builder.append(_name, " ");
- _builder.newLineIfNotEmpty();
- _builder.append(" ");
- _builder.append("* ");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("*/");
- _builder.newLine();
- _builder.newLine();
- _builder.append("#include \"");
- String _cHeaderFileName = this.stdExt.getCHeaderFileName(dc);
- _builder.append(_cHeaderFileName, "");
- _builder.append("\"");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("#include <string.h>");
- _builder.newLine();
- _builder.newLine();
- DetailCode _userCode3 = dc.getUserCode3();
- StringConcatenation _UserCode = this.helpers.UserCode(_userCode3);
- _builder.append(_UserCode, "");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("// TODO: do we need setters and getters for C and C++ ?");
- _builder.newLine();
- _builder.newLine();
- EList<StandardOperation> _operations = dc.getOperations();
- String _name_1 = dc.getName();
- StringConcatenation _OperationsImplementation = this.helpers.OperationsImplementation(_operations, _name_1);
- _builder.append(_OperationsImplementation, "");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("// deep copy");
- _builder.newLine();
- _builder.append("void ");
- String _name_2 = dc.getName();
- _builder.append(_name_2, "");
- _builder.append("_deepCopy(");
- String _name_3 = dc.getName();
- _builder.append(_name_3, "");
- _builder.append("* source, ");
- String _name_4 = dc.getName();
- _builder.append(_name_4, "");
- _builder.append("* target) {");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("memcpy(target, source, sizeof(");
- String _name_5 = dc.getName();
- _builder.append(_name_5, " ");
- _builder.append("));");
- _builder.newLineIfNotEmpty();
- _builder.append("}");
- _builder.newLine();
- _builder.newLine();
- _builder.newLine();
- return _builder;
- }
-}
+package org.eclipse.etrice.generator.c.gen;
+
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+import java.util.HashSet;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.etrice.core.room.Attribute;
+import org.eclipse.etrice.core.room.DataClass;
+import org.eclipse.etrice.core.room.DetailCode;
+import org.eclipse.etrice.core.room.StandardOperation;
+import org.eclipse.etrice.generator.base.ILogger;
+import org.eclipse.etrice.generator.c.gen.CExtensions;
+import org.eclipse.etrice.generator.etricegen.Root;
+import org.eclipse.etrice.generator.extensions.RoomExtensions;
+import org.eclipse.etrice.generator.generic.ProcedureHelpers;
+import org.eclipse.xtext.generator.JavaIoFileSystemAccess;
+import org.eclipse.xtext.xbase.lib.ObjectExtensions;
+import org.eclipse.xtext.xbase.lib.StringExtensions;
+import org.eclipse.xtext.xtend2.lib.StringConcatenation;
+
+@SuppressWarnings("all")
+@Singleton
+public class DataClassGen {
+ @Inject
+ private JavaIoFileSystemAccess fileAccess;
+
+ @Inject
+ private CExtensions stdExt;
+
+ @Inject
+ private RoomExtensions roomExt;
+
+ @Inject
+ private ProcedureHelpers helpers;
+
+ @Inject
+ private ILogger logger;
+
+ public void doGenerate(final Root root) {
+ EList<DataClass> _usedDataClasses = root.getUsedDataClasses();
+ for (final DataClass dc : _usedDataClasses) {
+ {
+ String _generationTargetPath = this.roomExt.getGenerationTargetPath(dc);
+ String _path = this.roomExt.getPath(dc);
+ String _operator_plus = StringExtensions.operator_plus(_generationTargetPath, _path);
+ String path = _operator_plus;
+ String _cHeaderFileName = this.stdExt.getCHeaderFileName(dc);
+ String _operator_plus_1 = StringExtensions.operator_plus("generating DataClass header \'", _cHeaderFileName);
+ String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, "\' in \'");
+ String _operator_plus_3 = StringExtensions.operator_plus(_operator_plus_2, path);
+ String _operator_plus_4 = StringExtensions.operator_plus(_operator_plus_3, "\'");
+ this.logger.logInfo(_operator_plus_4);
+ this.fileAccess.setOutputPath(path);
+ String _cHeaderFileName_1 = this.stdExt.getCHeaderFileName(dc);
+ StringConcatenation _generateHeaderFile = this.generateHeaderFile(root, dc);
+ this.fileAccess.generateFile(_cHeaderFileName_1, _generateHeaderFile);
+ String _cSourceFileName = this.stdExt.getCSourceFileName(dc);
+ String _operator_plus_5 = StringExtensions.operator_plus("generating DataClass source \'", _cSourceFileName);
+ String _operator_plus_6 = StringExtensions.operator_plus(_operator_plus_5, "\' in \'");
+ String _operator_plus_7 = StringExtensions.operator_plus(_operator_plus_6, path);
+ String _operator_plus_8 = StringExtensions.operator_plus(_operator_plus_7, "\'");
+ this.logger.logInfo(_operator_plus_8);
+ this.fileAccess.setOutputPath(path);
+ String _cSourceFileName_1 = this.stdExt.getCSourceFileName(dc);
+ StringConcatenation _generateSourceFile = this.generateSourceFile(root, dc);
+ this.fileAccess.generateFile(_cSourceFileName_1, _generateSourceFile);
+ }
+ }
+ }
+
+ public StringConcatenation generateHeaderFile(final Root root, final DataClass dc) {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("/**");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* @author generated by eTrice");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("*");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* Header File of DataClass ");
+ String _name = dc.getName();
+ _builder.append(_name, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append(" ");
+ _builder.append("* ");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("*/");
+ _builder.newLine();
+ _builder.newLine();
+ String _name_1 = dc.getName();
+ StringConcatenation _generateIncludeGuardBegin = this.stdExt.generateIncludeGuardBegin(_name_1);
+ _builder.append(_generateIncludeGuardBegin, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("#include \"etDatatypes.h\"");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("/* TODO: includes only for used DataClasses, also for other models */");
+ _builder.newLine();
+ {
+ HashSet<DataClass> _referencedDataClasses = root.getReferencedDataClasses(dc);
+ for(final DataClass dataClass : _referencedDataClasses) {
+ _builder.append("#include \"");
+ String _name_2 = dataClass.getName();
+ _builder.append(_name_2, "");
+ _builder.append(".h\"");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.newLine();
+ DetailCode _userCode1 = dc.getUserCode1();
+ StringConcatenation _UserCode = this.helpers.UserCode(_userCode1);
+ _builder.append(_UserCode, "");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.newLine();
+ _builder.append("typedef struct {");
+ _builder.newLine();
+ _builder.append("\t");
+ DetailCode _userCode2 = dc.getUserCode2();
+ StringConcatenation _UserCode_1 = this.helpers.UserCode(_userCode2);
+ _builder.append(_UserCode_1, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ EList<Attribute> _attributes = dc.getAttributes();
+ StringConcatenation _Attributes = this.helpers.Attributes(_attributes);
+ _builder.append(_Attributes, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("} ");
+ String _name_3 = dc.getName();
+ _builder.append(_name_3, "");
+ {
+ DataClass _base = dc.getBase();
+ boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_base, null);
+ if (_operator_notEquals) {
+ _builder.append(" /* extends -> inheritance not implemented yet */ ");
+ DataClass _base_1 = dc.getBase();
+ String _name_4 = _base_1.getName();
+ _builder.append(_name_4, "");
+ }
+ }
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("// TODO: do we need setters and getters for C and C++ ?");
+ _builder.newLine();
+ _builder.newLine();
+ EList<StandardOperation> _operations = dc.getOperations();
+ String _name_5 = dc.getName();
+ StringConcatenation _OperationsDeclaration = this.helpers.OperationsDeclaration(_operations, _name_5);
+ _builder.append(_OperationsDeclaration, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("// deep copy");
+ _builder.newLine();
+ _builder.append("void ");
+ String _name_6 = dc.getName();
+ _builder.append(_name_6, "");
+ _builder.append("_deepCopy(");
+ String _name_7 = dc.getName();
+ _builder.append(_name_7, "");
+ _builder.append("* source, ");
+ String _name_8 = dc.getName();
+ _builder.append(_name_8, "");
+ _builder.append("* target);");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ String _name_9 = dc.getName();
+ StringConcatenation _generateIncludeGuardEnd = this.stdExt.generateIncludeGuardEnd(_name_9);
+ _builder.append(_generateIncludeGuardEnd, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ return _builder;
+ }
+
+ public StringConcatenation generateSourceFile(final Root root, final DataClass dc) {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("/**");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* @author generated by eTrice");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("*");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* Source File of DataClass ");
+ String _name = dc.getName();
+ _builder.append(_name, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append(" ");
+ _builder.append("* ");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("*/");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("#include \"");
+ String _cHeaderFileName = this.stdExt.getCHeaderFileName(dc);
+ _builder.append(_cHeaderFileName, "");
+ _builder.append("\"");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("#include <string.h>");
+ _builder.newLine();
+ _builder.newLine();
+ DetailCode _userCode3 = dc.getUserCode3();
+ StringConcatenation _UserCode = this.helpers.UserCode(_userCode3);
+ _builder.append(_UserCode, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("// TODO: do we need setters and getters for C and C++ ?");
+ _builder.newLine();
+ _builder.newLine();
+ EList<StandardOperation> _operations = dc.getOperations();
+ String _name_1 = dc.getName();
+ StringConcatenation _OperationsImplementation = this.helpers.OperationsImplementation(_operations, _name_1);
+ _builder.append(_OperationsImplementation, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("// deep copy");
+ _builder.newLine();
+ _builder.append("void ");
+ String _name_2 = dc.getName();
+ _builder.append(_name_2, "");
+ _builder.append("_deepCopy(");
+ String _name_3 = dc.getName();
+ _builder.append(_name_3, "");
+ _builder.append("* source, ");
+ String _name_4 = dc.getName();
+ _builder.append(_name_4, "");
+ _builder.append("* target) {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("memcpy(target, source, sizeof(");
+ String _name_5 = dc.getName();
+ _builder.append(_name_5, " ");
+ _builder.append("));");
+ _builder.newLineIfNotEmpty();
+ _builder.append("}");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.newLine();
+ return _builder;
+ }
+}
diff --git a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/MainGen.java b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/MainGen.java
index 51f94d57a..ddbb7e3d4 100644
--- a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/MainGen.java
+++ b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/MainGen.java
@@ -1,59 +1,61 @@
-package org.eclipse.etrice.generator.c.gen;
-
-import com.google.inject.Inject;
-import com.google.inject.Singleton;
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.etrice.generator.c.gen.ActorClassGen;
-import org.eclipse.etrice.generator.c.gen.DataClassGen;
-import org.eclipse.etrice.generator.c.gen.ProtocolClassGen;
-import org.eclipse.etrice.generator.c.gen.SubSystemClassGen;
-import org.eclipse.etrice.generator.c.gen.SubSystemRunnerGen;
-import org.eclipse.etrice.generator.etricegen.Root;
-import org.eclipse.etrice.generator.extensions.PrepareFileSystem;
-import org.eclipse.xtext.generator.IFileSystemAccess;
-import org.eclipse.xtext.generator.IGenerator;
-import org.eclipse.xtext.xbase.lib.BooleanExtensions;
-
-@SuppressWarnings("all")
-@Singleton
-public class MainGen implements IGenerator {
- @Inject
- private DataClassGen dataClassGen;
-
- @Inject
- private ProtocolClassGen protocolClassGen;
-
- @Inject
- private ActorClassGen actorClassGen;
-
- @Inject
- private SubSystemClassGen subsystemClassGen;
-
- @Inject
- private SubSystemRunnerGen subsystemRunnerGen;
-
- @Inject
- private PrepareFileSystem prepFS;
-
- public void doGenerate(final Resource resource, final IFileSystemAccess fsa) {
- this.prepFS.prepare(resource);
- EList<EObject> _contents = resource.getContents();
- for (final EObject e : _contents) {
- if ((e instanceof Root)) {
- this.doGenerate(((Root) e));
- }
- }
- }
-
- public void doGenerate(final Root e) {
- this.dataClassGen.doGenerate(e);
- this.subsystemClassGen.doGenerate(e);
- boolean _isLibrary = e.isLibrary();
- boolean _operator_not = BooleanExtensions.operator_not(_isLibrary);
- if (_operator_not) {
- this.subsystemRunnerGen.doGenerate(e);
- }
- }
-}
+package org.eclipse.etrice.generator.c.gen;
+
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.etrice.generator.c.gen.ActorClassGen;
+import org.eclipse.etrice.generator.c.gen.DataClassGen;
+import org.eclipse.etrice.generator.c.gen.ProtocolClassGen;
+import org.eclipse.etrice.generator.c.gen.SubSystemClassGen;
+import org.eclipse.etrice.generator.c.gen.SubSystemRunnerGen;
+import org.eclipse.etrice.generator.etricegen.Root;
+import org.eclipse.etrice.generator.extensions.PrepareFileSystem;
+import org.eclipse.xtext.generator.IFileSystemAccess;
+import org.eclipse.xtext.generator.IGenerator;
+import org.eclipse.xtext.xbase.lib.BooleanExtensions;
+
+@SuppressWarnings("all")
+@Singleton
+public class MainGen implements IGenerator {
+ @Inject
+ private DataClassGen dataClassGen;
+
+ @Inject
+ private ProtocolClassGen protocolClassGen;
+
+ @Inject
+ private ActorClassGen actorClassGen;
+
+ @Inject
+ private SubSystemClassGen subsystemClassGen;
+
+ @Inject
+ private SubSystemRunnerGen subsystemRunnerGen;
+
+ @Inject
+ private PrepareFileSystem prepFS;
+
+ public void doGenerate(final Resource resource, final IFileSystemAccess fsa) {
+ this.prepFS.prepare(resource);
+ EList<EObject> _contents = resource.getContents();
+ for (final EObject e : _contents) {
+ if ((e instanceof Root)) {
+ this.doGenerate(((Root) e));
+ }
+ }
+ }
+
+ public void doGenerate(final Root e) {
+ this.dataClassGen.doGenerate(e);
+ this.protocolClassGen.doGenerate(e);
+ this.actorClassGen.doGenerate(e);
+ this.subsystemClassGen.doGenerate(e);
+ boolean _isLibrary = e.isLibrary();
+ boolean _operator_not = BooleanExtensions.operator_not(_isLibrary);
+ if (_operator_not) {
+ this.subsystemRunnerGen.doGenerate(e);
+ }
+ }
+}
diff --git a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/ProtocolClassGen.java b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/ProtocolClassGen.java
index 1694c51f0..2a08b5c46 100644
--- a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/ProtocolClassGen.java
+++ b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/ProtocolClassGen.java
@@ -76,19 +76,35 @@ public class ProtocolClassGen {
public StringConcatenation generateHeaderFile(final Root root, final ProtocolClass pc) {
StringConcatenation _builder = new StringConcatenation();
- _builder.append("#ifndef _");
+ _builder.append("/**");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* @author generated by eTrice");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("*");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* Header File of ProtocolClass ");
String _name = pc.getName();
- _builder.append(_name, "");
- _builder.append("_H_");
+ _builder.append(_name, " ");
_builder.newLineIfNotEmpty();
- _builder.append("#define _");
+ _builder.append(" ");
+ _builder.append("* ");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("*/");
+ _builder.newLine();
+ _builder.newLine();
String _name_1 = pc.getName();
- _builder.append(_name_1, "");
- _builder.append("_H_");
+ StringConcatenation _generateIncludeGuardBegin = this.stdExt.generateIncludeGuardBegin(_name_1);
+ _builder.append(_generateIncludeGuardBegin, "");
_builder.newLineIfNotEmpty();
_builder.newLine();
_builder.append("#include \"etDatatypes.h\"");
_builder.newLine();
+ _builder.append("#include \"etPort.h\"");
+ _builder.newLine();
_builder.newLine();
DetailCode _userCode1 = pc.getUserCode1();
StringConcatenation _UserCode = this.helpers.UserCode(_userCode1);
@@ -106,23 +122,13 @@ public class ProtocolClassGen {
}
}
_builder.newLine();
- _builder.append("typedef struct {");
- _builder.newLine();
- _builder.newLine();
- _builder.newLine();
- _builder.append("} ");
- String _name_3 = pc.getName();
- _builder.append(_name_3, "");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
_builder.append("/* message IDs */");
_builder.newLine();
_builder.append("enum {");
_builder.newLine();
_builder.append("\t");
- String _name_4 = pc.getName();
- _builder.append(_name_4, " ");
+ String _name_3 = pc.getName();
+ _builder.append(_name_3, " ");
_builder.append("_MSG_MIN = 0, ");
_builder.newLineIfNotEmpty();
_builder.append("\t");
@@ -132,9 +138,9 @@ public class ProtocolClassGen {
List<Message> _allOutgoingMessages = this.roomExt.getAllOutgoingMessages(pc);
for(final Message message : _allOutgoingMessages) {
_builder.append("\t");
- String _name_5 = pc.getName();
- String _name_6 = message.getName();
- String _outMessageId = this.stdExt.outMessageId(_name_5, _name_6);
+ String _name_4 = pc.getName();
+ String _name_5 = message.getName();
+ String _outMessageId = this.stdExt.outMessageId(_name_4, _name_5);
_builder.append(_outMessageId, " ");
_builder.append(" = ");
List<Message> _allOutgoingMessages_1 = this.roomExt.getAllOutgoingMessages(pc);
@@ -152,9 +158,9 @@ public class ProtocolClassGen {
List<Message> _allIncomingMessages = this.roomExt.getAllIncomingMessages(pc);
for(final Message message_1 : _allIncomingMessages) {
_builder.append("\t");
- String _name_7 = pc.getName();
- String _name_8 = message_1.getName();
- String _inMessageId = this.stdExt.inMessageId(_name_7, _name_8);
+ String _name_6 = pc.getName();
+ String _name_7 = message_1.getName();
+ String _inMessageId = this.stdExt.inMessageId(_name_6, _name_7);
_builder.append(_inMessageId, " ");
_builder.append(" = ");
List<Message> _allIncomingMessages_1 = this.roomExt.getAllIncomingMessages(pc);
@@ -172,8 +178,8 @@ public class ProtocolClassGen {
_builder.append("/* error if msgID >= MSG_MAX */");
_builder.newLine();
_builder.append("\t");
- String _name_9 = pc.getName();
- _builder.append(_name_9, " ");
+ String _name_8 = pc.getName();
+ _builder.append(_name_8, " ");
_builder.append("_MSG_MAX = ");
List<Message> _allOutgoingMessages_3 = this.roomExt.getAllOutgoingMessages(pc);
int _size_1 = _allOutgoingMessages_3.size();
@@ -201,8 +207,8 @@ public class ProtocolClassGen {
_builder.append("/* get message string for message id */");
_builder.newLine();
_builder.append("const char* ");
- String _name_10 = pc.getName();
- _builder.append(_name_10, "");
+ String _name_9 = pc.getName();
+ _builder.append(_name_9, "");
_builder.append("_getMessageString(int msg_id);");
_builder.newLineIfNotEmpty();
_builder.newLine();
@@ -212,10 +218,9 @@ public class ProtocolClassGen {
_builder.newLineIfNotEmpty();
_builder.newLine();
_builder.newLine();
- _builder.append("#endif /* _");
- String _name_11 = pc.getName();
- _builder.append(_name_11, "");
- _builder.append("_H_ */");
+ String _name_10 = pc.getName();
+ StringConcatenation _generateIncludeGuardEnd = this.stdExt.generateIncludeGuardEnd(_name_10);
+ _builder.append(_generateIncludeGuardEnd, "");
_builder.newLineIfNotEmpty();
_builder.newLine();
return _builder;
@@ -223,6 +228,26 @@ public class ProtocolClassGen {
public StringConcatenation generateSourceFile(final Root root, final ProtocolClass pc) {
StringConcatenation _builder = new StringConcatenation();
+ _builder.append("/**");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* @author generated by eTrice");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("*");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* Source File of ProtocolClass ");
+ String _name = pc.getName();
+ _builder.append(_name, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append(" ");
+ _builder.append("* ");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("*/");
+ _builder.newLine();
+ _builder.newLine();
_builder.append("#include \"");
String _cHeaderFileName = this.stdExt.getCHeaderFileName(pc);
_builder.append(_cHeaderFileName, "");
@@ -271,12 +296,6 @@ public class ProtocolClassGen {
_builder.append(";");
_builder.newLineIfNotEmpty();
_builder.newLine();
- StringConcatenation _ClassOperationSignature = this.helpers.ClassOperationSignature(portClassName, "MyOperation1", "int a, int b", "void", true);
- _builder.append(_ClassOperationSignature, "");
- _builder.newLineIfNotEmpty();
- StringConcatenation _ClassOperationSignature_1 = this.helpers.ClassOperationSignature(portClassName, "MyOperation2", "", "int", false);
- _builder.append(_ClassOperationSignature_1, "");
- _builder.newLineIfNotEmpty();
_builder.newLine();
_builder.newLine();
return _builder;
diff --git a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/SubSystemClassGen.java b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/SubSystemClassGen.java
index fb1ff4f13..01d667957 100644
--- a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/SubSystemClassGen.java
+++ b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/SubSystemClassGen.java
@@ -2,10 +2,15 @@ package org.eclipse.etrice.generator.c.gen;
import com.google.inject.Inject;
import com.google.inject.Singleton;
+import java.util.List;
import org.eclipse.emf.common.util.EList;
+import org.eclipse.etrice.core.room.ActorClass;
+import org.eclipse.etrice.core.room.Port;
+import org.eclipse.etrice.core.room.ProtocolClass;
import org.eclipse.etrice.core.room.SubSystemClass;
import org.eclipse.etrice.generator.base.ILogger;
import org.eclipse.etrice.generator.c.gen.CExtensions;
+import org.eclipse.etrice.generator.etricegen.ActorInstance;
import org.eclipse.etrice.generator.etricegen.Root;
import org.eclipse.etrice.generator.etricegen.SubSystemInstance;
import org.eclipse.etrice.generator.extensions.RoomExtensions;
@@ -66,6 +71,18 @@ public class SubSystemClassGen {
SubSystemClass _subSystemClass_5 = ssi.getSubSystemClass();
StringConcatenation _generateSourceFile = this.generateSourceFile(root, ssi, _subSystemClass_5);
this.fileAccess.generateFile(file, _generateSourceFile);
+ SubSystemClass _subSystemClass_6 = ssi.getSubSystemClass();
+ String _instSourceFileName = this.stdExt.getInstSourceFileName(_subSystemClass_6);
+ file = _instSourceFileName;
+ String _operator_plus_9 = StringExtensions.operator_plus("generating SubSystemClass instance file: \'", file);
+ String _operator_plus_10 = StringExtensions.operator_plus(_operator_plus_9, "\' in \'");
+ String _operator_plus_11 = StringExtensions.operator_plus(_operator_plus_10, path);
+ String _operator_plus_12 = StringExtensions.operator_plus(_operator_plus_11, "\'");
+ this.logger.logInfo(_operator_plus_12);
+ this.fileAccess.setOutputPath(path);
+ SubSystemClass _subSystemClass_7 = ssi.getSubSystemClass();
+ StringConcatenation _generateInstanceFile = this.generateInstanceFile(root, ssi, _subSystemClass_7);
+ this.fileAccess.generateFile(file, _generateInstanceFile);
}
}
}
@@ -110,29 +127,29 @@ public class SubSystemClassGen {
_builder.append("void ");
String _name_2 = ssc.getName();
_builder.append(_name_2, "");
- _builder.append("_init(void); // lifecycle init");
+ _builder.append("_init(void);\t\t/* lifecycle init \t */");
_builder.newLineIfNotEmpty();
_builder.append("void ");
String _name_3 = ssc.getName();
_builder.append(_name_3, "");
- _builder.append("_start(void); // lifecycle start");
+ _builder.append("_start(void);\t/* lifecycle start \t */");
_builder.newLineIfNotEmpty();
_builder.newLine();
_builder.append("void ");
String _name_4 = ssc.getName();
_builder.append(_name_4, "");
- _builder.append("_run(void);");
+ _builder.append("_run(void);\t\t/* lifecycle run \t */");
_builder.newLineIfNotEmpty();
_builder.newLine();
_builder.append("void ");
String _name_5 = ssc.getName();
_builder.append(_name_5, "");
- _builder.append("_stop(void); // lifecycle stop");
+ _builder.append("_stop(void); \t/* lifecycle stop\t */");
_builder.newLineIfNotEmpty();
_builder.append("void ");
String _name_6 = ssc.getName();
_builder.append(_name_6, "");
- _builder.append("_destroy(void); // lifecycle destroy");
+ _builder.append("_destroy(void); \t/* lifecycle destroy */");
_builder.newLineIfNotEmpty();
_builder.newLine();
_builder.newLine();
@@ -173,6 +190,14 @@ public class SubSystemClassGen {
_builder.append("\"");
_builder.newLineIfNotEmpty();
_builder.newLine();
+ _builder.append("/* include instances for all classes */");
+ _builder.newLine();
+ _builder.append("#include \"");
+ String _instSourceFileName = this.stdExt.getInstSourceFileName(ssc);
+ _builder.append(_instSourceFileName, "");
+ _builder.append("\"");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
_builder.append("#include \"etLogger.h\"");
_builder.newLine();
_builder.newLine();
@@ -218,6 +243,16 @@ public class SubSystemClassGen {
_builder.append(_name_8, " ");
_builder.append("Inst.name);");
_builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("/* initialization of all message services */");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("etMessageService_init(&msgService_Thread1, msgBuffer_Thread1, MESSAGE_POOL_MAX, MESSAGE_BLOCK_SIZE);");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.newLine();
_builder.append("}");
_builder.newLine();
_builder.newLine();
@@ -289,4 +324,168 @@ public class SubSystemClassGen {
_builder.newLine();
return _builder;
}
+
+ public StringConcatenation generateInstanceFile(final Root root, final SubSystemInstance ssi, final SubSystemClass ssc) {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("/**");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* @author generated by eTrice");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("*");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* Instance File of SubSystemClass ");
+ String _name = ssc.getName();
+ _builder.append(_name, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append(" ");
+ _builder.append("* - instantiation of all actor instances and port instances");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* - configuration of data and connection of ports");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("*/");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("#include \"etMessageService.h\"");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("/* instantiation of message services */");
+ _builder.newLine();
+ _builder.append("#define MESSAGE_POOL_MAX 10");
+ _builder.newLine();
+ _builder.append("#define MESSAGE_BLOCK_SIZE 32");
+ _builder.newLine();
+ _builder.append("/* MessageService for Thread1 */");
+ _builder.newLine();
+ _builder.append("uint8 msgBuffer_Thread1[MESSAGE_POOL_MAX*MESSAGE_BLOCK_SIZE];");
+ _builder.newLine();
+ _builder.append("etMessageService msgService_Thread1;");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("/* include all used ActorClasses */");
+ _builder.newLine();
+ _builder.append("/* TODO: only include used Actor Classes for current SubSystem */");
+ _builder.newLine();
+ {
+ EList<ActorClass> _usedActorClasses = root.getUsedActorClasses();
+ for(final ActorClass actorClass : _usedActorClasses) {
+ _builder.append("#include \"");
+ String _name_1 = actorClass.getName();
+ _builder.append(_name_1, "");
+ _builder.append(".h\"");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.newLine();
+ _builder.append("/* include all used ProtcolClasses */");
+ _builder.newLine();
+ {
+ EList<ProtocolClass> _usedProtocolClasses = root.getUsedProtocolClasses();
+ for(final ProtocolClass protocolClass : _usedProtocolClasses) {
+ _builder.append("#include \"");
+ String _name_2 = protocolClass.getName();
+ _builder.append(_name_2, "");
+ _builder.append(".h\"");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("/* declarations of all ActorClass instances (const and variable structs) */");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("/* forward declaration of varible actor structs */");
+ _builder.newLine();
+ {
+ EList<ActorInstance> _allContainedInstances = ssi.getAllContainedInstances();
+ for(final ActorInstance ai : _allContainedInstances) {
+ _builder.append("static ");
+ ActorClass _actorClass = ai.getActorClass();
+ String _name_3 = _actorClass.getName();
+ _builder.append(_name_3, "");
+ _builder.append(" ");
+ String _path = ai.getPath();
+ String _pathName = this.roomExt.getPathName(_path);
+ _builder.append(_pathName, "");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.newLine();
+ {
+ EList<ActorInstance> _allContainedInstances_1 = ssi.getAllContainedInstances();
+ for(final ActorInstance ai_1 : _allContainedInstances_1) {
+ _builder.newLine();
+ _builder.append("/* instance ");
+ String _path_1 = ai_1.getPath();
+ String _pathName_1 = this.roomExt.getPathName(_path_1);
+ _builder.append(_pathName_1, "");
+ _builder.append(" */");
+ _builder.newLineIfNotEmpty();
+ _builder.append("static const ");
+ ActorClass _actorClass_1 = ai_1.getActorClass();
+ String _name_4 = _actorClass_1.getName();
+ _builder.append(_name_4, "");
+ _builder.append("_const ");
+ String _path_2 = ai_1.getPath();
+ String _pathName_2 = this.roomExt.getPathName(_path_2);
+ _builder.append(_pathName_2, "");
+ _builder.append("_const = {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("&");
+ String _path_3 = ai_1.getPath();
+ String _pathName_3 = this.roomExt.getPathName(_path_3);
+ _builder.append(_pathName_3, " ");
+ _builder.append(",");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("/* Ports: {myActor, etReceiveMessage, msgService, peerAddress, localId} */");
+ _builder.newLine();
+ {
+ ActorClass _actorClass_2 = ai_1.getActorClass();
+ List<Port> _endPorts = this.roomExt.getEndPorts(_actorClass_2);
+ for(final Port port : _endPorts) {
+ _builder.append("\t");
+ _builder.append("{&");
+ String _path_4 = ai_1.getPath();
+ String _pathName_4 = this.roomExt.getPathName(_path_4);
+ _builder.append(_pathName_4, " ");
+ _builder.append(", NULL, &msgService_Thread1, 1, 123} /* Port ");
+ String _name_5 = port.getName();
+ _builder.append(_name_5, " ");
+ _builder.append(" */");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("};");
+ _builder.newLine();
+ _builder.append("static ");
+ ActorClass _actorClass_3 = ai_1.getActorClass();
+ String _name_6 = _actorClass_3.getName();
+ _builder.append(_name_6, "");
+ _builder.append(" ");
+ String _path_5 = ai_1.getPath();
+ String _pathName_5 = this.roomExt.getPathName(_path_5);
+ _builder.append(_pathName_5, "");
+ _builder.append(" = {&");
+ String _path_6 = ai_1.getPath();
+ String _pathName_6 = this.roomExt.getPathName(_path_6);
+ _builder.append(_pathName_6, "");
+ _builder.append("_const};");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.newLine();
+ _builder.newLine();
+ _builder.newLine();
+ return _builder;
+ }
}
diff --git a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/SubSystemRunnerGen.java b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/SubSystemRunnerGen.java
index 18f834214..fc08d3bd3 100644
--- a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/SubSystemRunnerGen.java
+++ b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/SubSystemRunnerGen.java
@@ -1,145 +1,145 @@
-package org.eclipse.etrice.generator.c.gen;
-
-import com.google.inject.Inject;
-import com.google.inject.Singleton;
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.etrice.core.room.SubSystemClass;
-import org.eclipse.etrice.generator.etricegen.Root;
-import org.eclipse.etrice.generator.etricegen.SubSystemInstance;
-import org.eclipse.etrice.generator.extensions.RoomExtensions;
-import org.eclipse.xtext.generator.JavaIoFileSystemAccess;
-import org.eclipse.xtext.xbase.lib.StringExtensions;
-import org.eclipse.xtext.xtend2.lib.StringConcatenation;
-
-@SuppressWarnings("all")
-@Singleton
-public class SubSystemRunnerGen {
- @Inject
- private JavaIoFileSystemAccess fileAccess;
-
- @Inject
- private RoomExtensions roomExt;
-
- public void doGenerate(final Root root) {
- EList<SubSystemInstance> _subSystemInstances = root.getSubSystemInstances();
- for (final SubSystemInstance sc : _subSystemInstances) {
- {
- SubSystemClass _subSystemClass = sc.getSubSystemClass();
- String _generationTargetPath = this.roomExt.getGenerationTargetPath(_subSystemClass);
- SubSystemClass _subSystemClass_1 = sc.getSubSystemClass();
- String _path = this.roomExt.getPath(_subSystemClass_1);
- String _operator_plus = StringExtensions.operator_plus(_generationTargetPath, _path);
- this.fileAccess.setOutputPath(_operator_plus);
- String _name = sc.getName();
- String _operator_plus_1 = StringExtensions.operator_plus(_name, "_Runner.c");
- SubSystemClass _subSystemClass_2 = sc.getSubSystemClass();
- StringConcatenation _generateSourceFile = this.generateSourceFile(root, sc, _subSystemClass_2);
- this.fileAccess.generateFile(_operator_plus_1, _generateSourceFile);
- }
- }
- }
-
- public StringConcatenation generateSourceFile(final Root root, final SubSystemInstance ssi, final SubSystemClass ssc) {
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("/**");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("* @author generated by eTrice");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("*");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("* this class contains the main function running component ");
- String _name = ssi.getName();
- _builder.append(_name, " ");
- _builder.newLineIfNotEmpty();
- _builder.append(" ");
- _builder.append("* it instantiates ");
- String _name_1 = ssi.getName();
- _builder.append(_name_1, " ");
- _builder.append(" and starts and ends the lifecycle");
- _builder.newLineIfNotEmpty();
- _builder.append(" ");
- _builder.append("*/");
- _builder.newLine();
- _builder.newLine();
- _builder.newLine();
- _builder.append("#include \"");
- String _name_2 = ssi.getName();
- _builder.append(_name_2, "");
- _builder.append(".h\"");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("#include \"etLogger.h\"");
- _builder.newLine();
- _builder.newLine();
- _builder.append("/**");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("* main function");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("* creates component and starts and stops the lifecycle");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("*/");
- _builder.newLine();
- _builder.newLine();
- _builder.append("int main(void) {");
- _builder.newLine();
- _builder.newLine();
- _builder.append("\t");
- _builder.append("etLogger_logInfo(\"*** T H E B E G I N ***\");");
- _builder.newLine();
- _builder.newLine();
- _builder.append("\t");
- _builder.append("/* startup sequence of lifecycle */");
- _builder.newLine();
- _builder.append("\t");
- String _name_3 = ssi.getName();
- _builder.append(_name_3, " ");
- _builder.append("_init(); \t\t/* lifecycle init */");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- String _name_4 = ssi.getName();
- _builder.append(_name_4, " ");
- _builder.append("_start(); \t/* lifecycle start */");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("\t");
- _builder.append("/* run Scheduler */");
- _builder.newLine();
- _builder.append("\t");
- String _name_5 = ssi.getName();
- _builder.append(_name_5, " ");
- _builder.append("_run();");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("\t");
- _builder.append("/* shutdown sequence of lifecycle */");
- _builder.newLine();
- _builder.append("\t");
- String _name_6 = ssi.getName();
- _builder.append(_name_6, " ");
- _builder.append("_stop(); \t\t/* lifecycle stop */");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- String _name_7 = ssi.getName();
- _builder.append(_name_7, " ");
- _builder.append("_destroy(); \t/* lifecycle destroy */");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("\t");
- _builder.append("etLogger_logInfo(\"*** T H E E N D ***\");");
- _builder.newLine();
- _builder.newLine();
- _builder.append("\t");
- _builder.append("return 0;");
- _builder.newLine();
- _builder.append("}");
- _builder.newLine();
- _builder.newLine();
- return _builder;
- }
-}
+package org.eclipse.etrice.generator.c.gen;
+
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.etrice.core.room.SubSystemClass;
+import org.eclipse.etrice.generator.etricegen.Root;
+import org.eclipse.etrice.generator.etricegen.SubSystemInstance;
+import org.eclipse.etrice.generator.extensions.RoomExtensions;
+import org.eclipse.xtext.generator.JavaIoFileSystemAccess;
+import org.eclipse.xtext.xbase.lib.StringExtensions;
+import org.eclipse.xtext.xtend2.lib.StringConcatenation;
+
+@SuppressWarnings("all")
+@Singleton
+public class SubSystemRunnerGen {
+ @Inject
+ private JavaIoFileSystemAccess fileAccess;
+
+ @Inject
+ private RoomExtensions roomExt;
+
+ public void doGenerate(final Root root) {
+ EList<SubSystemInstance> _subSystemInstances = root.getSubSystemInstances();
+ for (final SubSystemInstance sc : _subSystemInstances) {
+ {
+ SubSystemClass _subSystemClass = sc.getSubSystemClass();
+ String _generationTargetPath = this.roomExt.getGenerationTargetPath(_subSystemClass);
+ SubSystemClass _subSystemClass_1 = sc.getSubSystemClass();
+ String _path = this.roomExt.getPath(_subSystemClass_1);
+ String _operator_plus = StringExtensions.operator_plus(_generationTargetPath, _path);
+ this.fileAccess.setOutputPath(_operator_plus);
+ String _name = sc.getName();
+ String _operator_plus_1 = StringExtensions.operator_plus(_name, "_Runner.c");
+ SubSystemClass _subSystemClass_2 = sc.getSubSystemClass();
+ StringConcatenation _generateSourceFile = this.generateSourceFile(root, sc, _subSystemClass_2);
+ this.fileAccess.generateFile(_operator_plus_1, _generateSourceFile);
+ }
+ }
+ }
+
+ public StringConcatenation generateSourceFile(final Root root, final SubSystemInstance ssi, final SubSystemClass ssc) {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("/**");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* @author generated by eTrice");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("*");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* this class contains the main function running component ");
+ String _name = ssi.getName();
+ _builder.append(_name, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append(" ");
+ _builder.append("* it instantiates ");
+ String _name_1 = ssi.getName();
+ _builder.append(_name_1, " ");
+ _builder.append(" and starts and ends the lifecycle");
+ _builder.newLineIfNotEmpty();
+ _builder.append(" ");
+ _builder.append("*/");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("#include \"");
+ String _name_2 = ssi.getName();
+ _builder.append(_name_2, "");
+ _builder.append(".h\"");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("#include \"etLogger.h\"");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("/**");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* main function");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* creates component and starts and stops the lifecycle");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("*/");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("int main(void) {");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("etLogger_logInfo(\"*** T H E B E G I N ***\");");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("/* startup sequence of lifecycle */");
+ _builder.newLine();
+ _builder.append("\t");
+ String _name_3 = ssi.getName();
+ _builder.append(_name_3, " ");
+ _builder.append("_init(); \t\t/* lifecycle init */");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ String _name_4 = ssi.getName();
+ _builder.append(_name_4, " ");
+ _builder.append("_start(); \t/* lifecycle start */");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("/* run Scheduler */");
+ _builder.newLine();
+ _builder.append("\t");
+ String _name_5 = ssi.getName();
+ _builder.append(_name_5, " ");
+ _builder.append("_run();");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("/* shutdown sequence of lifecycle */");
+ _builder.newLine();
+ _builder.append("\t");
+ String _name_6 = ssi.getName();
+ _builder.append(_name_6, " ");
+ _builder.append("_stop(); \t\t/* lifecycle stop */");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ String _name_7 = ssi.getName();
+ _builder.append(_name_7, " ");
+ _builder.append("_destroy(); \t/* lifecycle destroy */");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("etLogger_logInfo(\"*** T H E E N D ***\");");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("return 0;");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ _builder.newLine();
+ return _builder;
+ }
+}
diff --git a/plugins/org.eclipse.etrice.generator.doc/xtend-gen/org/eclipse/etrice/generator/doc/gen/InstanceDiagramGen.java b/plugins/org.eclipse.etrice.generator.doc/xtend-gen/org/eclipse/etrice/generator/doc/gen/InstanceDiagramGen.java
index 73877379c..daa9a39f1 100644
--- a/plugins/org.eclipse.etrice.generator.doc/xtend-gen/org/eclipse/etrice/generator/doc/gen/InstanceDiagramGen.java
+++ b/plugins/org.eclipse.etrice.generator.doc/xtend-gen/org/eclipse/etrice/generator/doc/gen/InstanceDiagramGen.java
@@ -1,134 +1,134 @@
-package org.eclipse.etrice.generator.doc.gen;
-
-import com.google.inject.Inject;
-import com.google.inject.Singleton;
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.etrice.core.room.ActorClass;
-import org.eclipse.etrice.core.room.SubSystemClass;
-import org.eclipse.etrice.generator.base.ILogger;
-import org.eclipse.etrice.generator.base.IRoomGenerator;
-import org.eclipse.etrice.generator.etricegen.ActorInstance;
-import org.eclipse.etrice.generator.etricegen.Root;
-import org.eclipse.etrice.generator.etricegen.StructureInstance;
-import org.eclipse.etrice.generator.etricegen.SubSystemInstance;
-import org.eclipse.etrice.generator.extensions.RoomExtensions;
-import org.eclipse.xtext.generator.JavaIoFileSystemAccess;
-import org.eclipse.xtext.xbase.lib.StringExtensions;
-import org.eclipse.xtext.xtend2.lib.StringConcatenation;
-
-@SuppressWarnings("all")
-@Singleton
-public class InstanceDiagramGen implements IRoomGenerator {
- @Inject
- private JavaIoFileSystemAccess fileAccess;
-
- @Inject
- private RoomExtensions roomExt;
-
- @Inject
- private ILogger logger;
-
- public void doGenerate(final Root root) {
- EList<SubSystemInstance> _subSystemInstances = root.getSubSystemInstances();
- for (final SubSystemInstance sc : _subSystemInstances) {
- {
- SubSystemClass _subSystemClass = sc.getSubSystemClass();
- String _generationTargetPath = this.roomExt.getGenerationTargetPath(_subSystemClass);
- SubSystemClass _subSystemClass_1 = sc.getSubSystemClass();
- String _path = this.roomExt.getPath(_subSystemClass_1);
- String _operator_plus = StringExtensions.operator_plus(_generationTargetPath, _path);
- String path = _operator_plus;
- SubSystemClass _subSystemClass_2 = sc.getSubSystemClass();
- String _name = _subSystemClass_2.getName();
- String _operator_plus_1 = StringExtensions.operator_plus(_name, ".dot");
- String file = _operator_plus_1;
- String _operator_plus_2 = StringExtensions.operator_plus("generating instance diagram: \'", file);
- String _operator_plus_3 = StringExtensions.operator_plus(_operator_plus_2, "\' in \'");
- String _operator_plus_4 = StringExtensions.operator_plus(_operator_plus_3, path);
- String _operator_plus_5 = StringExtensions.operator_plus(_operator_plus_4, "\'");
- this.logger.logInfo(_operator_plus_5);
- this.fileAccess.setOutputPath(path);
- SubSystemClass _subSystemClass_3 = sc.getSubSystemClass();
- StringConcatenation _generate = this.generate(root, sc, _subSystemClass_3);
- this.fileAccess.generateFile(file, _generate);
- }
- }
- }
-
- public StringConcatenation generate(final Root root, final SubSystemInstance ssi, final SubSystemClass ssc) {
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("digraph ");
- String _name = ssi.getName();
- _builder.append(_name, "");
- _builder.append(" {");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("rankdir=LR;");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("node [shape=box];");
- _builder.newLine();
- _builder.append("\t");
- String _path = ssi.getPath();
- String _pathName = this.roomExt.getPathName(_path);
- _builder.append(_pathName, " ");
- _builder.append(" [label=\"");
- String _name_1 = ssc.getName();
- _builder.append(_name_1, " ");
- _builder.append("\\n(");
- String _name_2 = ssi.getName();
- _builder.append(_name_2, " ");
- _builder.append(")\" style=filled color=yellow];");
- _builder.newLineIfNotEmpty();
- {
- EList<ActorInstance> _instances = ssi.getInstances();
- for(final ActorInstance ai : _instances) {
- _builder.append("\t");
- StringConcatenation _instance = this.instance(ai);
- _builder.append(_instance, " ");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("}");
- _builder.newLine();
- return _builder;
- }
-
- public StringConcatenation instance(final ActorInstance ai) {
- StringConcatenation _builder = new StringConcatenation();
- EObject _eContainer = ai.eContainer();
- StructureInstance parent = ((StructureInstance) _eContainer);
- _builder.newLineIfNotEmpty();
- String _path = ai.getPath();
- String _pathName = this.roomExt.getPathName(_path);
- _builder.append(_pathName, "");
- _builder.append(" [label=\"");
- String _name = ai.getName();
- _builder.append(_name, "");
- _builder.append("\\n(");
- ActorClass _actorClass = ai.getActorClass();
- String _name_1 = _actorClass.getName();
- _builder.append(_name_1, "");
- _builder.append(")\"];");
- _builder.newLineIfNotEmpty();
- String _path_1 = parent.getPath();
- String _pathName_1 = this.roomExt.getPathName(_path_1);
- _builder.append(_pathName_1, "");
- _builder.append(" -> ");
- String _path_2 = ai.getPath();
- String _pathName_2 = this.roomExt.getPathName(_path_2);
- _builder.append(_pathName_2, "");
- _builder.append("; ");
- _builder.newLineIfNotEmpty();
- {
- EList<ActorInstance> _instances = ai.getInstances();
- for(final ActorInstance sub_ai : _instances) {
- StringConcatenation _instance = this.instance(sub_ai);
- _builder.append(_instance, "");
- _builder.newLineIfNotEmpty();
- }
- }
- return _builder;
- }
-}
+package org.eclipse.etrice.generator.doc.gen;
+
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.etrice.core.room.ActorClass;
+import org.eclipse.etrice.core.room.SubSystemClass;
+import org.eclipse.etrice.generator.base.ILogger;
+import org.eclipse.etrice.generator.base.IRoomGenerator;
+import org.eclipse.etrice.generator.etricegen.ActorInstance;
+import org.eclipse.etrice.generator.etricegen.Root;
+import org.eclipse.etrice.generator.etricegen.StructureInstance;
+import org.eclipse.etrice.generator.etricegen.SubSystemInstance;
+import org.eclipse.etrice.generator.extensions.RoomExtensions;
+import org.eclipse.xtext.generator.JavaIoFileSystemAccess;
+import org.eclipse.xtext.xbase.lib.StringExtensions;
+import org.eclipse.xtext.xtend2.lib.StringConcatenation;
+
+@SuppressWarnings("all")
+@Singleton
+public class InstanceDiagramGen implements IRoomGenerator {
+ @Inject
+ private JavaIoFileSystemAccess fileAccess;
+
+ @Inject
+ private RoomExtensions roomExt;
+
+ @Inject
+ private ILogger logger;
+
+ public void doGenerate(final Root root) {
+ EList<SubSystemInstance> _subSystemInstances = root.getSubSystemInstances();
+ for (final SubSystemInstance sc : _subSystemInstances) {
+ {
+ SubSystemClass _subSystemClass = sc.getSubSystemClass();
+ String _generationTargetPath = this.roomExt.getGenerationTargetPath(_subSystemClass);
+ SubSystemClass _subSystemClass_1 = sc.getSubSystemClass();
+ String _path = this.roomExt.getPath(_subSystemClass_1);
+ String _operator_plus = StringExtensions.operator_plus(_generationTargetPath, _path);
+ String path = _operator_plus;
+ SubSystemClass _subSystemClass_2 = sc.getSubSystemClass();
+ String _name = _subSystemClass_2.getName();
+ String _operator_plus_1 = StringExtensions.operator_plus(_name, ".dot");
+ String file = _operator_plus_1;
+ String _operator_plus_2 = StringExtensions.operator_plus("generating instance diagram: \'", file);
+ String _operator_plus_3 = StringExtensions.operator_plus(_operator_plus_2, "\' in \'");
+ String _operator_plus_4 = StringExtensions.operator_plus(_operator_plus_3, path);
+ String _operator_plus_5 = StringExtensions.operator_plus(_operator_plus_4, "\'");
+ this.logger.logInfo(_operator_plus_5);
+ this.fileAccess.setOutputPath(path);
+ SubSystemClass _subSystemClass_3 = sc.getSubSystemClass();
+ StringConcatenation _generate = this.generate(root, sc, _subSystemClass_3);
+ this.fileAccess.generateFile(file, _generate);
+ }
+ }
+ }
+
+ public StringConcatenation generate(final Root root, final SubSystemInstance ssi, final SubSystemClass ssc) {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("digraph ");
+ String _name = ssi.getName();
+ _builder.append(_name, "");
+ _builder.append(" {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("rankdir=LR;");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("node [shape=box];");
+ _builder.newLine();
+ _builder.append("\t");
+ String _path = ssi.getPath();
+ String _pathName = this.roomExt.getPathName(_path);
+ _builder.append(_pathName, " ");
+ _builder.append(" [label=\"");
+ String _name_1 = ssc.getName();
+ _builder.append(_name_1, " ");
+ _builder.append("\\n(");
+ String _name_2 = ssi.getName();
+ _builder.append(_name_2, " ");
+ _builder.append(")\" style=filled color=yellow];");
+ _builder.newLineIfNotEmpty();
+ {
+ EList<ActorInstance> _instances = ssi.getInstances();
+ for(final ActorInstance ai : _instances) {
+ _builder.append("\t");
+ StringConcatenation _instance = this.instance(ai);
+ _builder.append(_instance, " ");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("}");
+ _builder.newLine();
+ return _builder;
+ }
+
+ public StringConcatenation instance(final ActorInstance ai) {
+ StringConcatenation _builder = new StringConcatenation();
+ EObject _eContainer = ai.eContainer();
+ StructureInstance parent = ((StructureInstance) _eContainer);
+ _builder.newLineIfNotEmpty();
+ String _path = ai.getPath();
+ String _pathName = this.roomExt.getPathName(_path);
+ _builder.append(_pathName, "");
+ _builder.append(" [label=\"");
+ String _name = ai.getName();
+ _builder.append(_name, "");
+ _builder.append("\\n(");
+ ActorClass _actorClass = ai.getActorClass();
+ String _name_1 = _actorClass.getName();
+ _builder.append(_name_1, "");
+ _builder.append(")\"];");
+ _builder.newLineIfNotEmpty();
+ String _path_1 = parent.getPath();
+ String _pathName_1 = this.roomExt.getPathName(_path_1);
+ _builder.append(_pathName_1, "");
+ _builder.append(" -> ");
+ String _path_2 = ai.getPath();
+ String _pathName_2 = this.roomExt.getPathName(_path_2);
+ _builder.append(_pathName_2, "");
+ _builder.append("; ");
+ _builder.newLineIfNotEmpty();
+ {
+ EList<ActorInstance> _instances = ai.getInstances();
+ for(final ActorInstance sub_ai : _instances) {
+ StringConcatenation _instance = this.instance(sub_ai);
+ _builder.append(_instance, "");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ return _builder;
+ }
+}
diff --git a/plugins/org.eclipse.etrice.generator.doc/xtend-gen/org/eclipse/etrice/generator/doc/gen/MainGen.java b/plugins/org.eclipse.etrice.generator.doc/xtend-gen/org/eclipse/etrice/generator/doc/gen/MainGen.java
index c5974af19..013714a80 100644
--- a/plugins/org.eclipse.etrice.generator.doc/xtend-gen/org/eclipse/etrice/generator/doc/gen/MainGen.java
+++ b/plugins/org.eclipse.etrice.generator.doc/xtend-gen/org/eclipse/etrice/generator/doc/gen/MainGen.java
@@ -1,36 +1,36 @@
-package org.eclipse.etrice.generator.doc.gen;
-
-import com.google.inject.Inject;
-import com.google.inject.Singleton;
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.etrice.generator.doc.gen.InstanceDiagramGen;
-import org.eclipse.etrice.generator.etricegen.Root;
-import org.eclipse.etrice.generator.extensions.PrepareFileSystem;
-import org.eclipse.xtext.generator.IFileSystemAccess;
-import org.eclipse.xtext.generator.IGenerator;
-
-@SuppressWarnings("all")
-@Singleton
-public class MainGen implements IGenerator {
- @Inject
- private InstanceDiagramGen instanceDiagramGen;
-
- @Inject
- private PrepareFileSystem prepFS;
-
- public void doGenerate(final Resource resource, final IFileSystemAccess fsa) {
- this.prepFS.prepare(resource);
- EList<EObject> _contents = resource.getContents();
- for (final EObject e : _contents) {
- if ((e instanceof Root)) {
- this.doGenerate(((Root) e));
- }
- }
- }
-
- public void doGenerate(final Root e) {
- this.instanceDiagramGen.doGenerate(e);
- }
-}
+package org.eclipse.etrice.generator.doc.gen;
+
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.etrice.generator.doc.gen.InstanceDiagramGen;
+import org.eclipse.etrice.generator.etricegen.Root;
+import org.eclipse.etrice.generator.extensions.PrepareFileSystem;
+import org.eclipse.xtext.generator.IFileSystemAccess;
+import org.eclipse.xtext.generator.IGenerator;
+
+@SuppressWarnings("all")
+@Singleton
+public class MainGen implements IGenerator {
+ @Inject
+ private InstanceDiagramGen instanceDiagramGen;
+
+ @Inject
+ private PrepareFileSystem prepFS;
+
+ public void doGenerate(final Resource resource, final IFileSystemAccess fsa) {
+ this.prepFS.prepare(resource);
+ EList<EObject> _contents = resource.getContents();
+ for (final EObject e : _contents) {
+ if ((e instanceof Root)) {
+ this.doGenerate(((Root) e));
+ }
+ }
+ }
+
+ public void doGenerate(final Root e) {
+ this.instanceDiagramGen.doGenerate(e);
+ }
+}
diff --git a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/ActorClassGen.java b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/ActorClassGen.java
index 27f6f5dda..93f5cefa2 100644
--- a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/ActorClassGen.java
+++ b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/ActorClassGen.java
@@ -1,553 +1,553 @@
-package org.eclipse.etrice.generator.java.gen;
-
-import com.google.inject.Inject;
-import com.google.inject.Singleton;
-import java.util.List;
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.etrice.core.room.ActorClass;
-import org.eclipse.etrice.core.room.Attribute;
-import org.eclipse.etrice.core.room.DetailCode;
-import org.eclipse.etrice.core.room.Message;
-import org.eclipse.etrice.core.room.Port;
-import org.eclipse.etrice.core.room.ProtocolClass;
-import org.eclipse.etrice.core.room.RoomModel;
-import org.eclipse.etrice.core.room.SAPRef;
-import org.eclipse.etrice.core.room.SPPRef;
-import org.eclipse.etrice.core.room.ServiceImplementation;
-import org.eclipse.etrice.core.room.StandardOperation;
-import org.eclipse.etrice.core.room.StateMachine;
-import org.eclipse.etrice.core.room.VarDecl;
-import org.eclipse.etrice.generator.base.ILogger;
-import org.eclipse.etrice.generator.etricegen.ExpandedActorClass;
-import org.eclipse.etrice.generator.etricegen.Root;
-import org.eclipse.etrice.generator.extensions.RoomExtensions;
-import org.eclipse.etrice.generator.generic.ProcedureHelpers;
-import org.eclipse.etrice.generator.generic.TypeHelpers;
-import org.eclipse.etrice.generator.java.gen.JavaExtensions;
-import org.eclipse.etrice.generator.java.gen.StateMachineGen;
-import org.eclipse.xtext.generator.JavaIoFileSystemAccess;
-import org.eclipse.xtext.xbase.lib.BooleanExtensions;
-import org.eclipse.xtext.xbase.lib.IntegerExtensions;
-import org.eclipse.xtext.xbase.lib.ObjectExtensions;
-import org.eclipse.xtext.xbase.lib.StringExtensions;
-import org.eclipse.xtext.xtend2.lib.StringConcatenation;
-
-@SuppressWarnings("all")
-@Singleton
-public class ActorClassGen {
- @Inject
- private JavaIoFileSystemAccess fileAccess;
-
- @Inject
- private JavaExtensions stdExt;
-
- @Inject
- private RoomExtensions roomExt;
-
- @Inject
- private TypeHelpers _typeHelpers;
-
- @Inject
- private ProcedureHelpers helpers;
-
- @Inject
- private StateMachineGen stateMachineGen;
-
- @Inject
- private ILogger logger;
-
- public void doGenerate(final Root root) {
- EList<ExpandedActorClass> _xpActorClasses = root.getXpActorClasses();
- for (final ExpandedActorClass xpac : _xpActorClasses) {
- {
- ActorClass _actorClass = xpac.getActorClass();
- String _generationTargetPath = this.roomExt.getGenerationTargetPath(_actorClass);
- ActorClass _actorClass_1 = xpac.getActorClass();
- String _path = this.roomExt.getPath(_actorClass_1);
- String _operator_plus = StringExtensions.operator_plus(_generationTargetPath, _path);
- String path = _operator_plus;
- ActorClass _actorClass_2 = xpac.getActorClass();
- String _javaFileName = this.stdExt.getJavaFileName(_actorClass_2);
- String file = _javaFileName;
- String _operator_plus_1 = StringExtensions.operator_plus("generating ActorClass implementation \'", file);
- String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, "\' in \'");
- String _operator_plus_3 = StringExtensions.operator_plus(_operator_plus_2, path);
- String _operator_plus_4 = StringExtensions.operator_plus(_operator_plus_3, "\'");
- this.logger.logInfo(_operator_plus_4);
- this.fileAccess.setOutputPath(path);
- ActorClass _actorClass_3 = xpac.getActorClass();
- StringConcatenation _generate = this.generate(root, xpac, _actorClass_3);
- this.fileAccess.generateFile(file, _generate);
- }
- }
- }
-
- public StringConcatenation generate(final Root root, final ExpandedActorClass xpac, final ActorClass ac) {
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("package ");
- String _package = this.roomExt.getPackage(ac);
- _builder.append(_package, "");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("import org.eclipse.etrice.runtime.java.messaging.Address;");
- _builder.newLine();
- _builder.append("import org.eclipse.etrice.runtime.java.messaging.IRTObject;");
- _builder.newLine();
- _builder.append("import org.eclipse.etrice.runtime.java.messaging.IMessageReceiver;");
- _builder.newLine();
- _builder.append("import org.eclipse.etrice.runtime.java.modelbase.ActorClassBase;");
- _builder.newLine();
- _builder.append("import org.eclipse.etrice.runtime.java.modelbase.SubSystemClassBase;");
- _builder.newLine();
- _builder.append("import org.eclipse.etrice.runtime.java.modelbase.InterfaceItemBase;");
- _builder.newLine();
- _builder.append("import org.eclipse.etrice.runtime.java.debugging.DebuggingService;");
- _builder.newLine();
- _builder.newLine();
- {
- EList<RoomModel> _referencedModels = root.getReferencedModels(ac);
- for(final RoomModel model : _referencedModels) {
- _builder.append("import ");
- String _name = model.getName();
- _builder.append(_name, "");
- _builder.append(".*;");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.newLine();
- {
- EList<ProtocolClass> _referencedProtocolClasses = root.getReferencedProtocolClasses(ac);
- for(final ProtocolClass pc : _referencedProtocolClasses) {
- _builder.append("import ");
- String _package_1 = this.roomExt.getPackage(pc);
- _builder.append(_package_1, "");
- _builder.append(".");
- String _name_1 = pc.getName();
- _builder.append(_name_1, "");
- _builder.append(".*;");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.newLine();
- DetailCode _userCode1 = ac.getUserCode1();
- StringConcatenation _UserCode = this.helpers.UserCode(_userCode1);
- _builder.append(_UserCode, "");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.newLine();
- _builder.append("public ");
- {
- boolean _isAbstract = ac.isAbstract();
- if (_isAbstract) {
- _builder.append("abstract ");
- }
- }
- _builder.append("class ");
- String _name_2 = ac.getName();
- _builder.append(_name_2, "");
- _builder.append(" extends ");
- {
- ActorClass _base = ac.getBase();
- boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_base, null);
- if (_operator_notEquals) {
- ActorClass _base_1 = ac.getBase();
- String _name_3 = _base_1.getName();
- _builder.append(_name_3, "");
- } else {
- _builder.append("ActorClassBase");
- }
- }
- _builder.append(" {");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("\t");
- DetailCode _userCode2 = ac.getUserCode2();
- StringConcatenation _UserCode_1 = this.helpers.UserCode(_userCode2);
- _builder.append(_UserCode_1, " ");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("//--------------------- ports");
- _builder.newLine();
- {
- List<Port> _endPorts = this.roomExt.getEndPorts(ac);
- for(final Port ep : _endPorts) {
- _builder.append("\t");
- _builder.append("protected ");
- String _portClassName = this.roomExt.getPortClassName(ep);
- _builder.append(_portClassName, " ");
- _builder.append(" ");
- String _name_4 = ep.getName();
- _builder.append(_name_4, " ");
- _builder.append(" = null;");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("\t");
- _builder.append("//--------------------- saps");
- _builder.newLine();
- {
- EList<SAPRef> _strSAPs = ac.getStrSAPs();
- for(final SAPRef sap : _strSAPs) {
- _builder.append("\t");
- _builder.append("protected ");
- String _portClassName_1 = this.roomExt.getPortClassName(sap);
- _builder.append(_portClassName_1, " ");
- _builder.append(" ");
- String _name_5 = sap.getName();
- _builder.append(_name_5, " ");
- _builder.append(" = null;");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("\t");
- _builder.append("//--------------------- services");
- _builder.newLine();
- {
- EList<ServiceImplementation> _serviceImplementations = ac.getServiceImplementations();
- for(final ServiceImplementation svc : _serviceImplementations) {
- _builder.append("\t");
- _builder.append("protected ");
- String _portClassName_2 = this.roomExt.getPortClassName(svc);
- _builder.append(_portClassName_2, " ");
- _builder.append(" ");
- SPPRef _spp = svc.getSpp();
- String _name_6 = _spp.getName();
- _builder.append(_name_6, " ");
- _builder.append(" = null;");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.newLine();
- _builder.append("\t");
- _builder.append("//--------------------- interface item IDs");
- _builder.newLine();
- {
- List<Port> _endPorts_1 = this.roomExt.getEndPorts(ac);
- for(final Port ep_1 : _endPorts_1) {
- _builder.append("\t");
- _builder.append("protected static final int IFITEM_");
- String _name_7 = ep_1.getName();
- _builder.append(_name_7, " ");
- _builder.append(" = ");
- int _interfaceItemLocalId = xpac.getInterfaceItemLocalId(ep_1);
- int _operator_plus = IntegerExtensions.operator_plus(((Integer)_interfaceItemLocalId), ((Integer)1));
- _builder.append(_operator_plus, " ");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- }
- }
- {
- EList<SAPRef> _strSAPs_1 = ac.getStrSAPs();
- for(final SAPRef sap_1 : _strSAPs_1) {
- _builder.append("\t");
- _builder.append("protected static final int IFITEM_");
- String _name_8 = sap_1.getName();
- _builder.append(_name_8, " ");
- _builder.append(" = ");
- int _interfaceItemLocalId_1 = xpac.getInterfaceItemLocalId(sap_1);
- int _operator_plus_1 = IntegerExtensions.operator_plus(((Integer)_interfaceItemLocalId_1), ((Integer)1));
- _builder.append(_operator_plus_1, " ");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- }
- }
- {
- EList<ServiceImplementation> _serviceImplementations_1 = ac.getServiceImplementations();
- for(final ServiceImplementation svc_1 : _serviceImplementations_1) {
- _builder.append("\t");
- _builder.append("protected static final int IFITEM_");
- SPPRef _spp_1 = svc_1.getSpp();
- String _name_9 = _spp_1.getName();
- _builder.append(_name_9, " ");
- _builder.append(" = ");
- SPPRef _spp_2 = svc_1.getSpp();
- int _interfaceItemLocalId_2 = xpac.getInterfaceItemLocalId(_spp_2);
- int _operator_plus_2 = IntegerExtensions.operator_plus(((Integer)_interfaceItemLocalId_2), ((Integer)1));
- _builder.append(_operator_plus_2, " ");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t");
- EList<Attribute> _attributes = ac.getAttributes();
- StringConcatenation _Attributes = this.helpers.Attributes(_attributes);
- _builder.append(_Attributes, " ");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- EList<StandardOperation> _operations = ac.getOperations();
- String _name_10 = ac.getName();
- StringConcatenation _OperationsImplementation = this.helpers.OperationsImplementation(_operations, _name_10);
- _builder.append(_OperationsImplementation, " ");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("\t");
- _builder.append("//--------------------- construction");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("public ");
- String _name_11 = ac.getName();
- _builder.append(_name_11, " ");
- _builder.append("(IRTObject parent, String name, Address[][] port_addr, Address[][] peer_addr){");
- _builder.newLineIfNotEmpty();
- {
- ActorClass _base_2 = ac.getBase();
- boolean _operator_equals = ObjectExtensions.operator_equals(_base_2, null);
- if (_operator_equals) {
- _builder.append("\t\t");
- _builder.append("super(parent, name, port_addr[0][0], peer_addr[0][0]);");
- _builder.newLine();
- } else {
- _builder.append("\t\t");
- _builder.append("super(parent, name, port_addr, peer_addr);");
- _builder.newLine();
- }
- }
- _builder.append("\t\t");
- _builder.append("setClassName(\"");
- String _name_12 = ac.getName();
- _builder.append(_name_12, " ");
- _builder.append("\");");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.newLine();
- _builder.append("\t\t");
- EList<Attribute> _attributes_1 = ac.getAttributes();
- StringConcatenation _attributeInitialization = this.helpers.attributeInitialization(_attributes_1);
- _builder.append(_attributeInitialization, " ");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("// own ports");
- _builder.newLine();
- {
- List<Port> _endPorts_2 = this.roomExt.getEndPorts(ac);
- for(final Port ep_2 : _endPorts_2) {
- _builder.append("\t\t");
- String _name_13 = ep_2.getName();
- _builder.append(_name_13, " ");
- _builder.append(" = new ");
- String _portClassName_3 = this.roomExt.getPortClassName(ep_2);
- _builder.append(_portClassName_3, " ");
- _builder.append("(this, \"");
- String _name_14 = ep_2.getName();
- _builder.append(_name_14, " ");
- _builder.append("\", IFITEM_");
- String _name_15 = ep_2.getName();
- _builder.append(_name_15, " ");
- _builder.append(", ");
- {
- int _multiplicity = ep_2.getMultiplicity();
- boolean _operator_equals_1 = ObjectExtensions.operator_equals(((Integer)_multiplicity), ((Integer)1));
- if (_operator_equals_1) {
- _builder.append("0, ");
- }
- }
- _builder.append("port_addr[IFITEM_");
- String _name_16 = ep_2.getName();
- _builder.append(_name_16, " ");
- _builder.append("]");
- {
- int _multiplicity_1 = ep_2.getMultiplicity();
- boolean _operator_equals_2 = ObjectExtensions.operator_equals(((Integer)_multiplicity_1), ((Integer)1));
- if (_operator_equals_2) {
- _builder.append("[0]");
- }
- }
- _builder.append(", peer_addr[IFITEM_");
- String _name_17 = ep_2.getName();
- _builder.append(_name_17, " ");
- _builder.append("]");
- {
- int _multiplicity_2 = ep_2.getMultiplicity();
- boolean _operator_equals_3 = ObjectExtensions.operator_equals(((Integer)_multiplicity_2), ((Integer)1));
- if (_operator_equals_3) {
- _builder.append("[0]");
- }
- }
- _builder.append("); ");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("\t\t");
- _builder.append("// own saps");
- _builder.newLine();
- {
- EList<SAPRef> _strSAPs_2 = ac.getStrSAPs();
- for(final SAPRef sap_2 : _strSAPs_2) {
- _builder.append("\t\t");
- String _name_18 = sap_2.getName();
- _builder.append(_name_18, " ");
- _builder.append(" = new ");
- String _portClassName_4 = this.roomExt.getPortClassName(sap_2);
- _builder.append(_portClassName_4, " ");
- _builder.append("(this, \"");
- String _name_19 = sap_2.getName();
- _builder.append(_name_19, " ");
- _builder.append("\", IFITEM_");
- String _name_20 = sap_2.getName();
- _builder.append(_name_20, " ");
- _builder.append(", 0, port_addr[IFITEM_");
- String _name_21 = sap_2.getName();
- _builder.append(_name_21, " ");
- _builder.append("][0], peer_addr[IFITEM_");
- String _name_22 = sap_2.getName();
- _builder.append(_name_22, " ");
- _builder.append("][0]); ");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("\t\t");
- _builder.append("// own service implementations");
- _builder.newLine();
- {
- EList<ServiceImplementation> _serviceImplementations_2 = ac.getServiceImplementations();
- for(final ServiceImplementation svc_2 : _serviceImplementations_2) {
- _builder.append("\t\t");
- SPPRef _spp_3 = svc_2.getSpp();
- String _name_23 = _spp_3.getName();
- _builder.append(_name_23, " ");
- _builder.append(" = new ");
- String _portClassName_5 = this.roomExt.getPortClassName(svc_2);
- _builder.append(_portClassName_5, " ");
- _builder.append("(this, \"");
- SPPRef _spp_4 = svc_2.getSpp();
- String _name_24 = _spp_4.getName();
- _builder.append(_name_24, " ");
- _builder.append("\", IFITEM_");
- SPPRef _spp_5 = svc_2.getSpp();
- String _name_25 = _spp_5.getName();
- _builder.append(_name_25, " ");
- _builder.append(", port_addr[IFITEM_");
- SPPRef _spp_6 = svc_2.getSpp();
- String _name_26 = _spp_6.getName();
- _builder.append(_name_26, " ");
- _builder.append("], peer_addr[IFITEM_");
- SPPRef _spp_7 = svc_2.getSpp();
- String _name_27 = _spp_7.getName();
- _builder.append(_name_27, " ");
- _builder.append("]); ");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("\t");
- _builder.newLine();
- _builder.newLine();
- _builder.append("\t");
- _builder.append("//--------------------- lifecycle functions");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("public void init(){");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("initUser();");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.newLine();
- _builder.append("\t");
- _builder.append("public void start(){");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("startUser();");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.newLine();
- {
- boolean _overridesStop = this.roomExt.overridesStop(ac);
- boolean _operator_not = BooleanExtensions.operator_not(_overridesStop);
- if (_operator_not) {
- _builder.append("\t");
- _builder.append("public void stop(){");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("\t");
- _builder.append("stopUser();");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- }
- }
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("public void destroy(){");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("destroyUser();");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("}\t");
- _builder.newLine();
- _builder.newLine();
- {
- StateMachine _stateMachine = ac.getStateMachine();
- boolean _operator_notEquals_1 = ObjectExtensions.operator_notEquals(_stateMachine, null);
- if (_operator_notEquals_1) {
- _builder.append("\t");
- StringConcatenation _genStateMachine = this.stateMachineGen.genStateMachine(xpac, ac);
- _builder.append(_genStateMachine, " ");
- _builder.newLineIfNotEmpty();
- } else {
- boolean _hasStateMachine = xpac.hasStateMachine();
- boolean _operator_not_1 = BooleanExtensions.operator_not(_hasStateMachine);
- if (_operator_not_1) {
- _builder.append("\t");
- _builder.append("//--------------------- no state machine");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("@Override");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("public void receiveEvent(InterfaceItemBase ifitem, int evt, Object data) {");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("handleSystemEvent(ifitem, evt, data);");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("@Override");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("public void executeInitTransition(){");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- }
- }
- }
- _builder.append("};");
- _builder.newLine();
- return _builder;
- }
-
- public StringConcatenation msgArgs(final Message msg) {
- StringConcatenation _builder = new StringConcatenation();
- {
- VarDecl _data = msg.getData();
- boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_data, null);
- if (_operator_notEquals) {
- VarDecl _data_1 = msg.getData();
- String _defaultValue = this._typeHelpers.defaultValue(_data_1);
- _builder.append(_defaultValue, "");
- }
- }
- return _builder;
- }
-}
+package org.eclipse.etrice.generator.java.gen;
+
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+import java.util.List;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.etrice.core.room.ActorClass;
+import org.eclipse.etrice.core.room.Attribute;
+import org.eclipse.etrice.core.room.DetailCode;
+import org.eclipse.etrice.core.room.Message;
+import org.eclipse.etrice.core.room.Port;
+import org.eclipse.etrice.core.room.ProtocolClass;
+import org.eclipse.etrice.core.room.RoomModel;
+import org.eclipse.etrice.core.room.SAPRef;
+import org.eclipse.etrice.core.room.SPPRef;
+import org.eclipse.etrice.core.room.ServiceImplementation;
+import org.eclipse.etrice.core.room.StandardOperation;
+import org.eclipse.etrice.core.room.StateMachine;
+import org.eclipse.etrice.core.room.VarDecl;
+import org.eclipse.etrice.generator.base.ILogger;
+import org.eclipse.etrice.generator.etricegen.ExpandedActorClass;
+import org.eclipse.etrice.generator.etricegen.Root;
+import org.eclipse.etrice.generator.extensions.RoomExtensions;
+import org.eclipse.etrice.generator.generic.ProcedureHelpers;
+import org.eclipse.etrice.generator.generic.TypeHelpers;
+import org.eclipse.etrice.generator.java.gen.JavaExtensions;
+import org.eclipse.etrice.generator.java.gen.StateMachineGen;
+import org.eclipse.xtext.generator.JavaIoFileSystemAccess;
+import org.eclipse.xtext.xbase.lib.BooleanExtensions;
+import org.eclipse.xtext.xbase.lib.IntegerExtensions;
+import org.eclipse.xtext.xbase.lib.ObjectExtensions;
+import org.eclipse.xtext.xbase.lib.StringExtensions;
+import org.eclipse.xtext.xtend2.lib.StringConcatenation;
+
+@SuppressWarnings("all")
+@Singleton
+public class ActorClassGen {
+ @Inject
+ private JavaIoFileSystemAccess fileAccess;
+
+ @Inject
+ private JavaExtensions stdExt;
+
+ @Inject
+ private RoomExtensions roomExt;
+
+ @Inject
+ private TypeHelpers _typeHelpers;
+
+ @Inject
+ private ProcedureHelpers helpers;
+
+ @Inject
+ private StateMachineGen stateMachineGen;
+
+ @Inject
+ private ILogger logger;
+
+ public void doGenerate(final Root root) {
+ EList<ExpandedActorClass> _xpActorClasses = root.getXpActorClasses();
+ for (final ExpandedActorClass xpac : _xpActorClasses) {
+ {
+ ActorClass _actorClass = xpac.getActorClass();
+ String _generationTargetPath = this.roomExt.getGenerationTargetPath(_actorClass);
+ ActorClass _actorClass_1 = xpac.getActorClass();
+ String _path = this.roomExt.getPath(_actorClass_1);
+ String _operator_plus = StringExtensions.operator_plus(_generationTargetPath, _path);
+ String path = _operator_plus;
+ ActorClass _actorClass_2 = xpac.getActorClass();
+ String _javaFileName = this.stdExt.getJavaFileName(_actorClass_2);
+ String file = _javaFileName;
+ String _operator_plus_1 = StringExtensions.operator_plus("generating ActorClass implementation \'", file);
+ String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, "\' in \'");
+ String _operator_plus_3 = StringExtensions.operator_plus(_operator_plus_2, path);
+ String _operator_plus_4 = StringExtensions.operator_plus(_operator_plus_3, "\'");
+ this.logger.logInfo(_operator_plus_4);
+ this.fileAccess.setOutputPath(path);
+ ActorClass _actorClass_3 = xpac.getActorClass();
+ StringConcatenation _generate = this.generate(root, xpac, _actorClass_3);
+ this.fileAccess.generateFile(file, _generate);
+ }
+ }
+ }
+
+ public StringConcatenation generate(final Root root, final ExpandedActorClass xpac, final ActorClass ac) {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("package ");
+ String _package = this.roomExt.getPackage(ac);
+ _builder.append(_package, "");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("import org.eclipse.etrice.runtime.java.messaging.Address;");
+ _builder.newLine();
+ _builder.append("import org.eclipse.etrice.runtime.java.messaging.IRTObject;");
+ _builder.newLine();
+ _builder.append("import org.eclipse.etrice.runtime.java.messaging.IMessageReceiver;");
+ _builder.newLine();
+ _builder.append("import org.eclipse.etrice.runtime.java.modelbase.ActorClassBase;");
+ _builder.newLine();
+ _builder.append("import org.eclipse.etrice.runtime.java.modelbase.SubSystemClassBase;");
+ _builder.newLine();
+ _builder.append("import org.eclipse.etrice.runtime.java.modelbase.InterfaceItemBase;");
+ _builder.newLine();
+ _builder.append("import org.eclipse.etrice.runtime.java.debugging.DebuggingService;");
+ _builder.newLine();
+ _builder.newLine();
+ {
+ EList<RoomModel> _referencedModels = root.getReferencedModels(ac);
+ for(final RoomModel model : _referencedModels) {
+ _builder.append("import ");
+ String _name = model.getName();
+ _builder.append(_name, "");
+ _builder.append(".*;");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.newLine();
+ {
+ EList<ProtocolClass> _referencedProtocolClasses = root.getReferencedProtocolClasses(ac);
+ for(final ProtocolClass pc : _referencedProtocolClasses) {
+ _builder.append("import ");
+ String _package_1 = this.roomExt.getPackage(pc);
+ _builder.append(_package_1, "");
+ _builder.append(".");
+ String _name_1 = pc.getName();
+ _builder.append(_name_1, "");
+ _builder.append(".*;");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.newLine();
+ DetailCode _userCode1 = ac.getUserCode1();
+ StringConcatenation _UserCode = this.helpers.UserCode(_userCode1);
+ _builder.append(_UserCode, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("public ");
+ {
+ boolean _isAbstract = ac.isAbstract();
+ if (_isAbstract) {
+ _builder.append("abstract ");
+ }
+ }
+ _builder.append("class ");
+ String _name_2 = ac.getName();
+ _builder.append(_name_2, "");
+ _builder.append(" extends ");
+ {
+ ActorClass _base = ac.getBase();
+ boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_base, null);
+ if (_operator_notEquals) {
+ ActorClass _base_1 = ac.getBase();
+ String _name_3 = _base_1.getName();
+ _builder.append(_name_3, "");
+ } else {
+ _builder.append("ActorClassBase");
+ }
+ }
+ _builder.append(" {");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("\t");
+ DetailCode _userCode2 = ac.getUserCode2();
+ StringConcatenation _UserCode_1 = this.helpers.UserCode(_userCode2);
+ _builder.append(_UserCode_1, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("//--------------------- ports");
+ _builder.newLine();
+ {
+ List<Port> _endPorts = this.roomExt.getEndPorts(ac);
+ for(final Port ep : _endPorts) {
+ _builder.append("\t");
+ _builder.append("protected ");
+ String _portClassName = this.roomExt.getPortClassName(ep);
+ _builder.append(_portClassName, " ");
+ _builder.append(" ");
+ String _name_4 = ep.getName();
+ _builder.append(_name_4, " ");
+ _builder.append(" = null;");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("\t");
+ _builder.append("//--------------------- saps");
+ _builder.newLine();
+ {
+ EList<SAPRef> _strSAPs = ac.getStrSAPs();
+ for(final SAPRef sap : _strSAPs) {
+ _builder.append("\t");
+ _builder.append("protected ");
+ String _portClassName_1 = this.roomExt.getPortClassName(sap);
+ _builder.append(_portClassName_1, " ");
+ _builder.append(" ");
+ String _name_5 = sap.getName();
+ _builder.append(_name_5, " ");
+ _builder.append(" = null;");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("\t");
+ _builder.append("//--------------------- services");
+ _builder.newLine();
+ {
+ EList<ServiceImplementation> _serviceImplementations = ac.getServiceImplementations();
+ for(final ServiceImplementation svc : _serviceImplementations) {
+ _builder.append("\t");
+ _builder.append("protected ");
+ String _portClassName_2 = this.roomExt.getPortClassName(svc);
+ _builder.append(_portClassName_2, " ");
+ _builder.append(" ");
+ SPPRef _spp = svc.getSpp();
+ String _name_6 = _spp.getName();
+ _builder.append(_name_6, " ");
+ _builder.append(" = null;");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("//--------------------- interface item IDs");
+ _builder.newLine();
+ {
+ List<Port> _endPorts_1 = this.roomExt.getEndPorts(ac);
+ for(final Port ep_1 : _endPorts_1) {
+ _builder.append("\t");
+ _builder.append("protected static final int IFITEM_");
+ String _name_7 = ep_1.getName();
+ _builder.append(_name_7, " ");
+ _builder.append(" = ");
+ int _interfaceItemLocalId = xpac.getInterfaceItemLocalId(ep_1);
+ int _operator_plus = IntegerExtensions.operator_plus(((Integer)_interfaceItemLocalId), ((Integer)1));
+ _builder.append(_operator_plus, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ {
+ EList<SAPRef> _strSAPs_1 = ac.getStrSAPs();
+ for(final SAPRef sap_1 : _strSAPs_1) {
+ _builder.append("\t");
+ _builder.append("protected static final int IFITEM_");
+ String _name_8 = sap_1.getName();
+ _builder.append(_name_8, " ");
+ _builder.append(" = ");
+ int _interfaceItemLocalId_1 = xpac.getInterfaceItemLocalId(sap_1);
+ int _operator_plus_1 = IntegerExtensions.operator_plus(((Integer)_interfaceItemLocalId_1), ((Integer)1));
+ _builder.append(_operator_plus_1, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ {
+ EList<ServiceImplementation> _serviceImplementations_1 = ac.getServiceImplementations();
+ for(final ServiceImplementation svc_1 : _serviceImplementations_1) {
+ _builder.append("\t");
+ _builder.append("protected static final int IFITEM_");
+ SPPRef _spp_1 = svc_1.getSpp();
+ String _name_9 = _spp_1.getName();
+ _builder.append(_name_9, " ");
+ _builder.append(" = ");
+ SPPRef _spp_2 = svc_1.getSpp();
+ int _interfaceItemLocalId_2 = xpac.getInterfaceItemLocalId(_spp_2);
+ int _operator_plus_2 = IntegerExtensions.operator_plus(((Integer)_interfaceItemLocalId_2), ((Integer)1));
+ _builder.append(_operator_plus_2, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ EList<Attribute> _attributes = ac.getAttributes();
+ StringConcatenation _Attributes = this.helpers.Attributes(_attributes);
+ _builder.append(_Attributes, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ EList<StandardOperation> _operations = ac.getOperations();
+ String _name_10 = ac.getName();
+ StringConcatenation _OperationsImplementation = this.helpers.OperationsImplementation(_operations, _name_10);
+ _builder.append(_OperationsImplementation, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("//--------------------- construction");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("public ");
+ String _name_11 = ac.getName();
+ _builder.append(_name_11, " ");
+ _builder.append("(IRTObject parent, String name, Address[][] port_addr, Address[][] peer_addr){");
+ _builder.newLineIfNotEmpty();
+ {
+ ActorClass _base_2 = ac.getBase();
+ boolean _operator_equals = ObjectExtensions.operator_equals(_base_2, null);
+ if (_operator_equals) {
+ _builder.append("\t\t");
+ _builder.append("super(parent, name, port_addr[0][0], peer_addr[0][0]);");
+ _builder.newLine();
+ } else {
+ _builder.append("\t\t");
+ _builder.append("super(parent, name, port_addr, peer_addr);");
+ _builder.newLine();
+ }
+ }
+ _builder.append("\t\t");
+ _builder.append("setClassName(\"");
+ String _name_12 = ac.getName();
+ _builder.append(_name_12, " ");
+ _builder.append("\");");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.newLine();
+ _builder.append("\t\t");
+ EList<Attribute> _attributes_1 = ac.getAttributes();
+ StringConcatenation _attributeInitialization = this.helpers.attributeInitialization(_attributes_1);
+ _builder.append(_attributeInitialization, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("// own ports");
+ _builder.newLine();
+ {
+ List<Port> _endPorts_2 = this.roomExt.getEndPorts(ac);
+ for(final Port ep_2 : _endPorts_2) {
+ _builder.append("\t\t");
+ String _name_13 = ep_2.getName();
+ _builder.append(_name_13, " ");
+ _builder.append(" = new ");
+ String _portClassName_3 = this.roomExt.getPortClassName(ep_2);
+ _builder.append(_portClassName_3, " ");
+ _builder.append("(this, \"");
+ String _name_14 = ep_2.getName();
+ _builder.append(_name_14, " ");
+ _builder.append("\", IFITEM_");
+ String _name_15 = ep_2.getName();
+ _builder.append(_name_15, " ");
+ _builder.append(", ");
+ {
+ int _multiplicity = ep_2.getMultiplicity();
+ boolean _operator_equals_1 = ObjectExtensions.operator_equals(((Integer)_multiplicity), ((Integer)1));
+ if (_operator_equals_1) {
+ _builder.append("0, ");
+ }
+ }
+ _builder.append("port_addr[IFITEM_");
+ String _name_16 = ep_2.getName();
+ _builder.append(_name_16, " ");
+ _builder.append("]");
+ {
+ int _multiplicity_1 = ep_2.getMultiplicity();
+ boolean _operator_equals_2 = ObjectExtensions.operator_equals(((Integer)_multiplicity_1), ((Integer)1));
+ if (_operator_equals_2) {
+ _builder.append("[0]");
+ }
+ }
+ _builder.append(", peer_addr[IFITEM_");
+ String _name_17 = ep_2.getName();
+ _builder.append(_name_17, " ");
+ _builder.append("]");
+ {
+ int _multiplicity_2 = ep_2.getMultiplicity();
+ boolean _operator_equals_3 = ObjectExtensions.operator_equals(((Integer)_multiplicity_2), ((Integer)1));
+ if (_operator_equals_3) {
+ _builder.append("[0]");
+ }
+ }
+ _builder.append("); ");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("\t\t");
+ _builder.append("// own saps");
+ _builder.newLine();
+ {
+ EList<SAPRef> _strSAPs_2 = ac.getStrSAPs();
+ for(final SAPRef sap_2 : _strSAPs_2) {
+ _builder.append("\t\t");
+ String _name_18 = sap_2.getName();
+ _builder.append(_name_18, " ");
+ _builder.append(" = new ");
+ String _portClassName_4 = this.roomExt.getPortClassName(sap_2);
+ _builder.append(_portClassName_4, " ");
+ _builder.append("(this, \"");
+ String _name_19 = sap_2.getName();
+ _builder.append(_name_19, " ");
+ _builder.append("\", IFITEM_");
+ String _name_20 = sap_2.getName();
+ _builder.append(_name_20, " ");
+ _builder.append(", 0, port_addr[IFITEM_");
+ String _name_21 = sap_2.getName();
+ _builder.append(_name_21, " ");
+ _builder.append("][0], peer_addr[IFITEM_");
+ String _name_22 = sap_2.getName();
+ _builder.append(_name_22, " ");
+ _builder.append("][0]); ");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("\t\t");
+ _builder.append("// own service implementations");
+ _builder.newLine();
+ {
+ EList<ServiceImplementation> _serviceImplementations_2 = ac.getServiceImplementations();
+ for(final ServiceImplementation svc_2 : _serviceImplementations_2) {
+ _builder.append("\t\t");
+ SPPRef _spp_3 = svc_2.getSpp();
+ String _name_23 = _spp_3.getName();
+ _builder.append(_name_23, " ");
+ _builder.append(" = new ");
+ String _portClassName_5 = this.roomExt.getPortClassName(svc_2);
+ _builder.append(_portClassName_5, " ");
+ _builder.append("(this, \"");
+ SPPRef _spp_4 = svc_2.getSpp();
+ String _name_24 = _spp_4.getName();
+ _builder.append(_name_24, " ");
+ _builder.append("\", IFITEM_");
+ SPPRef _spp_5 = svc_2.getSpp();
+ String _name_25 = _spp_5.getName();
+ _builder.append(_name_25, " ");
+ _builder.append(", port_addr[IFITEM_");
+ SPPRef _spp_6 = svc_2.getSpp();
+ String _name_26 = _spp_6.getName();
+ _builder.append(_name_26, " ");
+ _builder.append("], peer_addr[IFITEM_");
+ SPPRef _spp_7 = svc_2.getSpp();
+ String _name_27 = _spp_7.getName();
+ _builder.append(_name_27, " ");
+ _builder.append("]); ");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("//--------------------- lifecycle functions");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("public void init(){");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("initUser();");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("public void start(){");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("startUser();");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.newLine();
+ {
+ boolean _overridesStop = this.roomExt.overridesStop(ac);
+ boolean _operator_not = BooleanExtensions.operator_not(_overridesStop);
+ if (_operator_not) {
+ _builder.append("\t");
+ _builder.append("public void stop(){");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("stopUser();");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ }
+ }
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("public void destroy(){");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("destroyUser();");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("}\t");
+ _builder.newLine();
+ _builder.newLine();
+ {
+ StateMachine _stateMachine = ac.getStateMachine();
+ boolean _operator_notEquals_1 = ObjectExtensions.operator_notEquals(_stateMachine, null);
+ if (_operator_notEquals_1) {
+ _builder.append("\t");
+ StringConcatenation _genStateMachine = this.stateMachineGen.genStateMachine(xpac, ac);
+ _builder.append(_genStateMachine, " ");
+ _builder.newLineIfNotEmpty();
+ } else {
+ boolean _hasStateMachine = xpac.hasStateMachine();
+ boolean _operator_not_1 = BooleanExtensions.operator_not(_hasStateMachine);
+ if (_operator_not_1) {
+ _builder.append("\t");
+ _builder.append("//--------------------- no state machine");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("@Override");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("public void receiveEvent(InterfaceItemBase ifitem, int evt, Object data) {");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("handleSystemEvent(ifitem, evt, data);");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("@Override");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("public void executeInitTransition(){");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ }
+ }
+ }
+ _builder.append("};");
+ _builder.newLine();
+ return _builder;
+ }
+
+ public StringConcatenation msgArgs(final Message msg) {
+ StringConcatenation _builder = new StringConcatenation();
+ {
+ VarDecl _data = msg.getData();
+ boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_data, null);
+ if (_operator_notEquals) {
+ VarDecl _data_1 = msg.getData();
+ String _defaultValue = this._typeHelpers.defaultValue(_data_1);
+ _builder.append(_defaultValue, "");
+ }
+ }
+ return _builder;
+ }
+}
diff --git a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/JavaExtensions.java b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/JavaExtensions.java
index 91db89536..fafe79b1a 100644
--- a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/JavaExtensions.java
+++ b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/JavaExtensions.java
@@ -1,68 +1,68 @@
-package org.eclipse.etrice.generator.java.gen;
-
-import com.google.inject.Inject;
-import com.google.inject.Singleton;
-import org.eclipse.etrice.core.room.Message;
-import org.eclipse.etrice.core.room.RoomClass;
-import org.eclipse.etrice.generator.etricegen.ExpandedActorClass;
-import org.eclipse.etrice.generator.etricegen.TransitionChain;
-import org.eclipse.etrice.generator.generic.ILanguageExtension;
-import org.eclipse.etrice.generator.generic.LanguageGenerator;
-import org.eclipse.xtext.xbase.lib.StringExtensions;
-
-@SuppressWarnings("all")
-@Singleton
-public class JavaExtensions implements ILanguageExtension {
- @Inject
- private LanguageGenerator languageGen;
-
- public String getTypedDataDefinition(final Message m) {
- String _typedData = this.languageGen.getTypedData(m);
- return _typedData;
- }
-
- public String getJavaFileName(final RoomClass rc) {
- String _name = rc.getName();
- String _operator_plus = StringExtensions.operator_plus(_name, ".java");
- return _operator_plus;
- }
-
- public String accessLevelPrivate() {
- return "private ";
- }
-
- public String accessLevelProtected() {
- return "protected ";
- }
-
- public String accessLevelPublic() {
- return "public ";
- }
-
- public String memberAccess() {
- return "this.";
- }
-
- public String selfPointer(final String classname, final int argumentCount) {
- return "";
- }
-
- public String operationScope(final String classname, final boolean isDeclaration) {
- return "";
- }
-
- public String outMessageId(final String classname, final String messagename) {
- String _operator_plus = StringExtensions.operator_plus("OUT_", messagename);
- return _operator_plus;
- }
-
- public String inMessageId(final String classname, final String messagename) {
- String _operator_plus = StringExtensions.operator_plus("IN_", messagename);
- return _operator_plus;
- }
-
- public String getExecuteChainCode(final ExpandedActorClass ac, final TransitionChain tc) {
- String _executeChain = this.languageGen.getExecuteChain(ac, tc);
- return _executeChain;
- }
-}
+package org.eclipse.etrice.generator.java.gen;
+
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+import org.eclipse.etrice.core.room.Message;
+import org.eclipse.etrice.core.room.RoomClass;
+import org.eclipse.etrice.generator.etricegen.ExpandedActorClass;
+import org.eclipse.etrice.generator.etricegen.TransitionChain;
+import org.eclipse.etrice.generator.generic.ILanguageExtension;
+import org.eclipse.etrice.generator.generic.LanguageGenerator;
+import org.eclipse.xtext.xbase.lib.StringExtensions;
+
+@SuppressWarnings("all")
+@Singleton
+public class JavaExtensions implements ILanguageExtension {
+ @Inject
+ private LanguageGenerator languageGen;
+
+ public String getTypedDataDefinition(final Message m) {
+ String _typedData = this.languageGen.getTypedData(m);
+ return _typedData;
+ }
+
+ public String getJavaFileName(final RoomClass rc) {
+ String _name = rc.getName();
+ String _operator_plus = StringExtensions.operator_plus(_name, ".java");
+ return _operator_plus;
+ }
+
+ public String accessLevelPrivate() {
+ return "private ";
+ }
+
+ public String accessLevelProtected() {
+ return "protected ";
+ }
+
+ public String accessLevelPublic() {
+ return "public ";
+ }
+
+ public String memberAccess() {
+ return "this.";
+ }
+
+ public String selfPointer(final String classname, final int argumentCount) {
+ return "";
+ }
+
+ public String operationScope(final String classname, final boolean isDeclaration) {
+ return "";
+ }
+
+ public String outMessageId(final String classname, final String messagename) {
+ String _operator_plus = StringExtensions.operator_plus("OUT_", messagename);
+ return _operator_plus;
+ }
+
+ public String inMessageId(final String classname, final String messagename) {
+ String _operator_plus = StringExtensions.operator_plus("IN_", messagename);
+ return _operator_plus;
+ }
+
+ public String getExecuteChainCode(final ExpandedActorClass ac, final TransitionChain tc) {
+ String _executeChain = this.languageGen.getExecuteChain(ac, tc);
+ return _executeChain;
+ }
+}
diff --git a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/MainGen.java b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/MainGen.java
index c2e9efeed..b52095047 100644
--- a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/MainGen.java
+++ b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/MainGen.java
@@ -1,61 +1,61 @@
-package org.eclipse.etrice.generator.java.gen;
-
-import com.google.inject.Inject;
-import com.google.inject.Singleton;
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.etrice.generator.etricegen.Root;
-import org.eclipse.etrice.generator.extensions.PrepareFileSystem;
-import org.eclipse.etrice.generator.java.gen.ActorClassGen;
-import org.eclipse.etrice.generator.java.gen.DataClassGen;
-import org.eclipse.etrice.generator.java.gen.ProtocolClassGen;
-import org.eclipse.etrice.generator.java.gen.SubSystemClassGen;
-import org.eclipse.etrice.generator.java.gen.SubSystemRunnerGen;
-import org.eclipse.xtext.generator.IFileSystemAccess;
-import org.eclipse.xtext.generator.IGenerator;
-import org.eclipse.xtext.xbase.lib.BooleanExtensions;
-
-@SuppressWarnings("all")
-@Singleton
-public class MainGen implements IGenerator {
- @Inject
- private DataClassGen dataClassGen;
-
- @Inject
- private ProtocolClassGen protocolClassGen;
-
- @Inject
- private ActorClassGen actorClassGen;
-
- @Inject
- private SubSystemClassGen subsystemClassGen;
-
- @Inject
- private SubSystemRunnerGen subsystemRunnerGen;
-
- @Inject
- private PrepareFileSystem prepFS;
-
- public void doGenerate(final Resource resource, final IFileSystemAccess fsa) {
- this.prepFS.prepare(resource);
- EList<EObject> _contents = resource.getContents();
- for (final EObject e : _contents) {
- if ((e instanceof Root)) {
- this.doGenerate(((Root) e));
- }
- }
- }
-
- public void doGenerate(final Root e) {
- this.dataClassGen.doGenerate(e);
- this.protocolClassGen.doGenerate(e);
- this.actorClassGen.doGenerate(e);
- this.subsystemClassGen.doGenerate(e);
- boolean _isLibrary = e.isLibrary();
- boolean _operator_not = BooleanExtensions.operator_not(_isLibrary);
- if (_operator_not) {
- this.subsystemRunnerGen.doGenerate(e);
- }
- }
-}
+package org.eclipse.etrice.generator.java.gen;
+
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.etrice.generator.etricegen.Root;
+import org.eclipse.etrice.generator.extensions.PrepareFileSystem;
+import org.eclipse.etrice.generator.java.gen.ActorClassGen;
+import org.eclipse.etrice.generator.java.gen.DataClassGen;
+import org.eclipse.etrice.generator.java.gen.ProtocolClassGen;
+import org.eclipse.etrice.generator.java.gen.SubSystemClassGen;
+import org.eclipse.etrice.generator.java.gen.SubSystemRunnerGen;
+import org.eclipse.xtext.generator.IFileSystemAccess;
+import org.eclipse.xtext.generator.IGenerator;
+import org.eclipse.xtext.xbase.lib.BooleanExtensions;
+
+@SuppressWarnings("all")
+@Singleton
+public class MainGen implements IGenerator {
+ @Inject
+ private DataClassGen dataClassGen;
+
+ @Inject
+ private ProtocolClassGen protocolClassGen;
+
+ @Inject
+ private ActorClassGen actorClassGen;
+
+ @Inject
+ private SubSystemClassGen subsystemClassGen;
+
+ @Inject
+ private SubSystemRunnerGen subsystemRunnerGen;
+
+ @Inject
+ private PrepareFileSystem prepFS;
+
+ public void doGenerate(final Resource resource, final IFileSystemAccess fsa) {
+ this.prepFS.prepare(resource);
+ EList<EObject> _contents = resource.getContents();
+ for (final EObject e : _contents) {
+ if ((e instanceof Root)) {
+ this.doGenerate(((Root) e));
+ }
+ }
+ }
+
+ public void doGenerate(final Root e) {
+ this.dataClassGen.doGenerate(e);
+ this.protocolClassGen.doGenerate(e);
+ this.actorClassGen.doGenerate(e);
+ this.subsystemClassGen.doGenerate(e);
+ boolean _isLibrary = e.isLibrary();
+ boolean _operator_not = BooleanExtensions.operator_not(_isLibrary);
+ if (_operator_not) {
+ this.subsystemRunnerGen.doGenerate(e);
+ }
+ }
+}
diff --git a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/StateMachineGen.java b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/StateMachineGen.java
index 08d6fd50e..1304fe233 100644
--- a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/StateMachineGen.java
+++ b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/StateMachineGen.java
@@ -1,872 +1,872 @@
-package org.eclipse.etrice.generator.java.gen;
-
-import com.google.inject.Inject;
-import com.google.inject.Singleton;
-import java.util.List;
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.etrice.core.room.ActorClass;
-import org.eclipse.etrice.core.room.DetailCode;
-import org.eclipse.etrice.core.room.Guard;
-import org.eclipse.etrice.core.room.InterfaceItem;
-import org.eclipse.etrice.core.room.Message;
-import org.eclipse.etrice.core.room.MessageFromIf;
-import org.eclipse.etrice.core.room.NonInitialTransition;
-import org.eclipse.etrice.core.room.State;
-import org.eclipse.etrice.core.room.StateGraph;
-import org.eclipse.etrice.core.room.StateMachine;
-import org.eclipse.etrice.core.room.Transition;
-import org.eclipse.etrice.core.room.Trigger;
-import org.eclipse.etrice.core.room.TriggeredTransition;
-import org.eclipse.etrice.generator.etricegen.ActiveTrigger;
-import org.eclipse.etrice.generator.etricegen.ExpandedActorClass;
-import org.eclipse.etrice.generator.etricegen.TransitionChain;
-import org.eclipse.etrice.generator.extensions.RoomExtensions;
-import org.eclipse.etrice.generator.extensions.RoomNameProv;
-import org.eclipse.etrice.generator.generic.LanguageGenerator;
-import org.eclipse.etrice.generator.generic.TypeHelpers;
-import org.eclipse.etrice.generator.java.gen.JavaExtensions;
-import org.eclipse.xtext.xbase.lib.BooleanExtensions;
-import org.eclipse.xtext.xbase.lib.Functions.Function1;
-import org.eclipse.xtext.xbase.lib.IntegerExtensions;
-import org.eclipse.xtext.xbase.lib.IterableExtensions;
-import org.eclipse.xtext.xtend2.lib.StringConcatenation;
-
-@SuppressWarnings("all")
-@Singleton
-public class StateMachineGen {
- @Inject
- private JavaExtensions stdExt;
-
- @Inject
- private RoomExtensions roomExt;
-
- @Inject
- private TypeHelpers _typeHelpers;
-
- @Inject
- private LanguageGenerator languageGen;
-
- public StringConcatenation genStateMachine(final ExpandedActorClass xpac, final ActorClass ac) {
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("//******************************************");
- _builder.newLine();
- _builder.append("// START of generated code for FSM");
- _builder.newLine();
- _builder.append("//******************************************");
- _builder.newLine();
- _builder.newLine();
- _builder.append("// State IDs for FSM");
- _builder.newLine();
- int _numberOfInheritedBaseStates = this.roomExt.getNumberOfInheritedBaseStates(ac);
- int offset = _numberOfInheritedBaseStates;
- _builder.newLineIfNotEmpty();
- StateMachine _stateMachine = ac.getStateMachine();
- List<State> _baseStateList = this.roomExt.getBaseStateList(_stateMachine);
- List<State> baseStates = _baseStateList;
- _builder.newLineIfNotEmpty();
- {
- for(final State state : baseStates) {
- _builder.append("protected static final int ");
- String _stateId = this.roomExt.getStateId(state);
- _builder.append(_stateId, "");
- _builder.append(" = ");
- int _indexOf = baseStates.indexOf(state);
- int _operator_plus = IntegerExtensions.operator_plus(((Integer)_indexOf), ((Integer)2));
- int _operator_plus_1 = IntegerExtensions.operator_plus(((Integer)_operator_plus), ((Integer)offset));
- _builder.append(_operator_plus_1, "");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("\t");
- _builder.append("protected static final String stateStrings[] = {\"<no state>\",\"<top>\",");
- {
- List<State> _allBaseStates = this.roomExt.getAllBaseStates(ac);
- boolean hasAnyElements = false;
- for(final State state_1 : _allBaseStates) {
- if (!hasAnyElements) {
- hasAnyElements = true;
- } else {
- _builder.appendImmediate(",", " ");
- }
- _builder.append("\"");
- String _statePathName = this.roomExt.getStatePathName(state_1);
- _builder.append(_statePathName, " ");
- _builder.append("\"");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- }
- }
- _builder.append("};");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("// history");
- _builder.newLine();
- _builder.append("// TODOHRR: history defined in ActorClassBase, init in constructor");
- _builder.newLine();
- _builder.append("//\t\thistory = new int[5];");
- _builder.newLine();
- _builder.append("//\t\tfor (int i = 0; i < history.length; i++) {");
- _builder.newLine();
- _builder.append("//\t\t\thistory[i] = NO_STATE;");
- _builder.newLine();
- _builder.append("//\t\t}");
- _builder.newLine();
- _builder.append("protected int history[] = {NO_STATE,NO_STATE");
- {
- List<State> _allBaseStates_1 = this.roomExt.getAllBaseStates(ac);
- for(final State state_2 : _allBaseStates_1) {
- _builder.append(",NO_STATE");
- }
- }
- _builder.append("};");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- EList<TransitionChain> _ownTransitionChains = xpac.getOwnTransitionChains();
- List<TransitionChain> chains = _ownTransitionChains;
- _builder.newLineIfNotEmpty();
- EList<TransitionChain> _transitionChains = xpac.getTransitionChains();
- int _size = _transitionChains.size();
- int _size_1 = chains.size();
- int _operator_minus = IntegerExtensions.operator_minus(((Integer)_size), ((Integer)_size_1));
- int offset_tc = _operator_minus;
- _builder.newLineIfNotEmpty();
- _builder.append("// transition chains");
- _builder.newLine();
- {
- for(final TransitionChain tc : chains) {
- _builder.append("protected static final int ");
- String _chainId = this.roomExt.getChainId(tc);
- _builder.append(_chainId, "");
- _builder.append(" = ");
- int _indexOf_1 = chains.indexOf(tc);
- int _operator_plus_2 = IntegerExtensions.operator_plus(((Integer)_indexOf_1), ((Integer)1));
- int _operator_plus_3 = IntegerExtensions.operator_plus(((Integer)_operator_plus_2), ((Integer)offset_tc));
- _builder.append(_operator_plus_3, "");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.newLine();
- EList<MessageFromIf> _ownTriggers = xpac.getOwnTriggers();
- EList<MessageFromIf> triggers = _ownTriggers;
- _builder.newLineIfNotEmpty();
- _builder.append("// triggers for FSM");
- _builder.newLine();
- {
- for(final MessageFromIf mif : triggers) {
- _builder.append("protected static final int ");
- String _triggerCodeName = xpac.getTriggerCodeName(mif);
- _builder.append(_triggerCodeName, "");
- _builder.append(" = IFITEM_");
- InterfaceItem _from = mif.getFrom();
- String _name = _from.getName();
- _builder.append(_name, "");
- _builder.append(" + EVT_SHIFT*");
- String _messageID = xpac.getMessageID(mif);
- _builder.append(_messageID, "");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.newLine();
- _builder.append("// receiveEvent contains the main implementation of the FSM");
- _builder.newLine();
- _builder.append("@Override");
- _builder.newLine();
- _builder.append("public void receiveEvent(InterfaceItemBase ifitem, int evt, Object generic_data) {");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("int trigger = ifitem.getLocalId() + EVT_SHIFT*evt;");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("int chain = NOT_CAUGHT;");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("int catching_state = NO_STATE;");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("boolean is_handler = false;");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("boolean skip_entry = false;");
- _builder.newLine();
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("if (!handleSystemEvent(ifitem, evt, generic_data)) {");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("switch (state) {");
- _builder.newLine();
- {
- StateMachine _stateMachine_1 = xpac.getStateMachine();
- List<State> _leafStateList = this.roomExt.getLeafStateList(_stateMachine_1);
- for(final State state_3 : _leafStateList) {
- _builder.append("\t\t\t");
- _builder.append("case ");
- String _stateId_1 = this.roomExt.getStateId(state_3);
- _builder.append(_stateId_1, " ");
- _builder.append(":");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t\t");
- _builder.append("\t");
- EList<ActiveTrigger> _activeTriggers = xpac.getActiveTriggers(state_3);
- EList<ActiveTrigger> atlist = _activeTriggers;
- _builder.newLineIfNotEmpty();
- {
- boolean _isEmpty = atlist.isEmpty();
- boolean _operator_not = BooleanExtensions.operator_not(_isEmpty);
- if (_operator_not) {
- _builder.append("\t\t\t");
- _builder.append("\t");
- _builder.append("switch(trigger) {");
- _builder.newLine();
- {
- for(final ActiveTrigger at : atlist) {
- _builder.append("\t\t\t");
- _builder.append("\t");
- _builder.append("case ");
- String _trigger = at.getTrigger();
- String _triggerCodeName_1 = xpac.getTriggerCodeName(_trigger);
- _builder.append(_triggerCodeName_1, " ");
- _builder.append(":");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t\t");
- _builder.append("\t");
- _builder.append("\t");
- boolean _hasGuard = this.roomExt.hasGuard(xpac, at);
- boolean needData = _hasGuard;
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t\t");
- _builder.append("\t");
- _builder.append("\t");
- {
- if (needData) {
- _builder.append("{ ");
- Message _msg = at.getMsg();
- String _typedDataDefinition = this._typeHelpers.getTypedDataDefinition(_msg);
- _builder.append(_typedDataDefinition, " ");
- }
- }
- _builder.newLineIfNotEmpty();
- {
- EList<TriggeredTransition> _transitions = at.getTransitions();
- boolean hasAnyElements_1 = false;
- for(final TriggeredTransition tt : _transitions) {
- if (!hasAnyElements_1) {
- hasAnyElements_1 = true;
- } else {
- _builder.appendImmediate(" else ", " ");
- }
- _builder.append("\t\t\t");
- _builder.append("\t");
- _builder.append("\t");
- TransitionChain _chain = xpac.getChain(tt);
- TransitionChain chain = _chain;
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t\t");
- _builder.append("\t");
- _builder.append("\t");
- Transition _transition = chain.getTransition();
- String _trigger_1 = at.getTrigger();
- StringConcatenation _guard = this.guard(_transition, _trigger_1, xpac);
- _builder.append(_guard, " ");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t\t");
- _builder.append("\t");
- _builder.append("\t");
- _builder.append("{");
- _builder.newLine();
- _builder.append("\t\t\t");
- _builder.append("\t");
- _builder.append("\t");
- _builder.append("\t");
- _builder.append("chain = ");
- String _chainId_1 = this.roomExt.getChainId(chain);
- _builder.append(_chainId_1, " ");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t\t");
- _builder.append("\t");
- _builder.append("\t");
- _builder.append("\t");
- _builder.append("catching_state = ");
- String _contextId = this.roomExt.getContextId(chain);
- _builder.append(_contextId, " ");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t\t");
- _builder.append("\t");
- _builder.append("\t");
- _builder.append("\t");
- {
- boolean _isHandler = chain.isHandler();
- if (_isHandler) {
- _builder.append("is_handler = true;");
- }
- }
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t\t");
- _builder.append("\t");
- _builder.append("\t");
- _builder.append("\t");
- {
- boolean _isSkipEntry = chain.isSkipEntry();
- if (_isSkipEntry) {
- _builder.append("skip_entry = true;");
- }
- }
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t\t");
- _builder.append("\t");
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- }
- }
- _builder.append("\t\t\t");
- _builder.append("\t");
- _builder.append("\t");
- {
- if (needData) {
- _builder.append("}");
- }
- }
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t\t");
- _builder.append("\t");
- _builder.append("break;");
- _builder.newLine();
- }
- }
- _builder.append("\t\t\t");
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- }
- }
- _builder.append("\t\t\t");
- _builder.append("\t");
- _builder.append("break;");
- _builder.newLine();
- }
- }
- _builder.append("\t\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("if (chain != NOT_CAUGHT) {");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("exitTo(state, catching_state, is_handler);");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("int next = executeTransitionChain(chain, ifitem, generic_data);");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("next = enterHistory(next, is_handler, skip_entry);");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("setState(next);");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("}");
- _builder.newLine();
- _builder.newLine();
- _builder.append("private void setState(int new_state) {");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("DebuggingService.getInstance().addActorState(this,stateStrings[new_state]);");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("if (stateStrings[new_state]!=\"Idle\") {");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("// TODOTS: model switch for activation");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("System.out.println(getInstancePath() + \" -> \" + stateStrings[new_state]);");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("}\t");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("this.state = new_state;");
- _builder.newLine();
- _builder.append("}");
- _builder.newLine();
- _builder.newLine();
- _builder.append("@Override");
- _builder.newLine();
- _builder.append("public void executeInitTransition() {");
- _builder.newLine();
- _builder.append("\t");
- StateMachine _stateMachine_2 = xpac.getStateMachine();
- Transition _initTransition = this.roomExt.getInitTransition(_stateMachine_2);
- Transition initt = _initTransition;
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("int chain = ");
- TransitionChain _chain_1 = xpac.getChain(initt);
- String _chainId_2 = this.roomExt.getChainId(_chain_1);
- _builder.append(_chainId_2, " ");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("int next = executeTransitionChain(chain, null, null);");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("next = enterHistory(next, false, false);");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("setState(next);");
- _builder.newLine();
- _builder.append("}");
- _builder.newLine();
- _builder.newLine();
- _builder.append("/**");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("* calls exit codes while exiting from the current state to one of its");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("* parent states while remembering the history");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("* @param current - the current state");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("* @param to - the final parent state");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("* @param handler - entry and exit codes are called only if not handler (for handler TransitionPoints)");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("*/");
- _builder.newLine();
- _builder.append("private void exitTo(int current, int to, boolean handler) {");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("while (current!=to) {");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("switch (current) {");
- _builder.newLine();
- {
- StateMachine _stateMachine_3 = xpac.getStateMachine();
- List<State> _baseStateList_1 = this.roomExt.getBaseStateList(_stateMachine_3);
- for(final State state_4 : _baseStateList_1) {
- _builder.append("\t\t\t");
- _builder.append("case ");
- String _stateId_2 = this.roomExt.getStateId(state_4);
- _builder.append(_stateId_2, " ");
- _builder.append(":");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t\t");
- _builder.append("\t");
- {
- boolean _hasExitCode = this.roomExt.hasExitCode(state_4);
- if (_hasExitCode) {
- _builder.append("if (!handler) ");
- String _exitCodeOperationName = RoomNameProv.getExitCodeOperationName(state_4);
- _builder.append(_exitCodeOperationName, " ");
- _builder.append("();");
- }
- }
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t\t");
- _builder.append("\t");
- _builder.append("history[");
- String _parentStateId = RoomNameProv.getParentStateId(state_4);
- _builder.append(_parentStateId, " ");
- _builder.append("] = ");
- String _stateId_3 = this.roomExt.getStateId(state_4);
- _builder.append(_stateId_3, " ");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t\t");
- _builder.append("\t");
- _builder.append("current = ");
- String _parentStateId_1 = RoomNameProv.getParentStateId(state_4);
- _builder.append(_parentStateId_1, " ");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t\t");
- _builder.append("\t");
- _builder.append("break;");
- _builder.newLine();
- }
- }
- _builder.append("\t\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("}");
- _builder.newLine();
- _builder.append("/**");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("* calls action, entry and exit codes along a transition chain. The generic data are cast to typed data");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("* matching the trigger of this chain. The ID of the final state is returned");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("* @param chain - the chain ID");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("* @param generic_data - the generic data pointer");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("* @return the ID of the final state");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("*/");
- _builder.newLine();
- _builder.append("private int executeTransitionChain(int chain, InterfaceItemBase ifitem, Object generic_data) {");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("switch (chain) {");
- _builder.newLine();
- _builder.append("\t\t");
- EList<TransitionChain> _transitionChains_1 = xpac.getTransitionChains();
- EList<TransitionChain> allchains = _transitionChains_1;
- _builder.newLineIfNotEmpty();
- {
- for(final TransitionChain tc_1 : allchains) {
- _builder.append("\t\t");
- _builder.append("case ");
- String _chainId_3 = this.roomExt.getChainId(tc_1);
- _builder.append(_chainId_3, " ");
- _builder.append(":");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.append("{");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("\t");
- String _executeChainCode = this.stdExt.getExecuteChainCode(xpac, tc_1);
- _builder.append(_executeChainCode, " ");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.append("}");
- _builder.newLine();
- }
- }
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("return NO_STATE;");
- _builder.newLine();
- _builder.append("}");
- _builder.newLine();
- _builder.append("/**");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("* calls entry codes while entering a state\'s history. The ID of the final leaf state is returned");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("* @param state - the state which is entered");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("* @param handler - entry code is executed if not handler");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("* @return - the ID of the final leaf state");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("*/");
- _builder.newLine();
- _builder.append("private int enterHistory(int state, boolean handler, boolean skip_entry) {");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("while (true) {");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("switch (state) {");
- _builder.newLine();
- {
- StateMachine _stateMachine_4 = xpac.getStateMachine();
- List<State> _baseStateList_2 = this.roomExt.getBaseStateList(_stateMachine_4);
- for(final State state_5 : _baseStateList_2) {
- _builder.append("\t\t\t");
- _builder.append("case ");
- String _stateId_4 = this.roomExt.getStateId(state_5);
- _builder.append(_stateId_4, " ");
- _builder.append(":");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t\t");
- _builder.append("\t");
- {
- boolean _hasEntryCode = this.roomExt.hasEntryCode(state_5);
- if (_hasEntryCode) {
- _builder.append("if (!(skip_entry || handler)) ");
- String _entryCodeOperationName = RoomNameProv.getEntryCodeOperationName(state_5);
- _builder.append(_entryCodeOperationName, " ");
- _builder.append("();");
- }
- }
- _builder.newLineIfNotEmpty();
- {
- boolean _isLeaf = this.roomExt.isLeaf(state_5);
- if (_isLeaf) {
- _builder.append("\t\t\t");
- _builder.append("\t");
- _builder.append("// in leaf state: return state id");
- _builder.newLine();
- _builder.append("\t\t\t");
- _builder.append("\t");
- _builder.append("return ");
- String _stateId_5 = this.roomExt.getStateId(state_5);
- _builder.append(_stateId_5, " ");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- } else {
- _builder.append("\t\t\t");
- _builder.append("\t");
- _builder.append("// state has a sub graph");
- _builder.newLine();
- {
- StateGraph _subgraph = state_5.getSubgraph();
- boolean _hasInitTransition = this.roomExt.hasInitTransition(_subgraph);
- if (_hasInitTransition) {
- _builder.append("\t\t\t");
- _builder.append("\t");
- _builder.append("// with init transition");
- _builder.newLine();
- _builder.append("\t\t\t");
- _builder.append("\t");
- _builder.append("if (history[");
- String _stateId_6 = this.roomExt.getStateId(state_5);
- _builder.append(_stateId_6, " ");
- _builder.append("]==NO_STATE) {");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t\t");
- _builder.append("\t");
- _builder.append("\t");
- StateGraph _subgraph_1 = state_5.getSubgraph();
- Transition _initTransition_1 = this.roomExt.getInitTransition(_subgraph_1);
- Transition sub_initt = _initTransition_1;
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t\t");
- _builder.append("\t");
- _builder.append("\t");
- _builder.append("state = executeTransitionChain(");
- TransitionChain _chain_2 = xpac.getChain(sub_initt);
- String _chainId_4 = this.roomExt.getChainId(_chain_2);
- _builder.append(_chainId_4, " ");
- _builder.append(", null, null);");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t\t");
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("\t\t\t");
- _builder.append("\t");
- _builder.append("else {");
- _builder.newLine();
- _builder.append("\t\t\t");
- _builder.append("\t");
- _builder.append("\t");
- _builder.append("state = history[");
- String _stateId_7 = this.roomExt.getStateId(state_5);
- _builder.append(_stateId_7, " ");
- _builder.append("];");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t\t");
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- } else {
- _builder.append("\t\t\t");
- _builder.append("\t");
- _builder.append("// without init transition");
- _builder.newLine();
- _builder.append("\t\t\t");
- _builder.append("\t");
- _builder.append("state = history[");
- String _stateId_8 = this.roomExt.getStateId(state_5);
- _builder.append(_stateId_8, " ");
- _builder.append("];");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("\t\t\t");
- _builder.append("\t");
- _builder.append("break;");
- _builder.newLine();
- }
- }
- }
- }
- _builder.append("\t\t\t");
- _builder.append("case STATE_TOP:");
- _builder.newLine();
- _builder.append("\t\t\t\t");
- _builder.append("state = history[STATE_TOP];");
- _builder.newLine();
- _builder.append("\t\t\t\t");
- _builder.append("break;");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("skip_entry = false;");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("//return NO_STATE; // required by CDT but detected as unreachable by JDT because of while (true)");
- _builder.newLine();
- _builder.append("}");
- _builder.newLine();
- _builder.newLine();
- _builder.append("//*** Entry and Exit Codes");
- _builder.newLine();
- {
- StateMachine _stateMachine_5 = xpac.getStateMachine();
- List<State> _stateList = this.roomExt.getStateList(_stateMachine_5);
- for(final State state_6 : _stateList) {
- {
- boolean _isOwnObject = xpac.isOwnObject(state_6);
- if (_isOwnObject) {
- {
- boolean _hasEntryCode_1 = this.roomExt.hasEntryCode(state_6);
- if (_hasEntryCode_1) {
- _builder.append("protected void ");
- String _entryCodeOperationName_1 = RoomNameProv.getEntryCodeOperationName(state_6);
- _builder.append(_entryCodeOperationName_1, "");
- _builder.append("() {");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- String _entryCode = this.roomExt.getEntryCode(xpac, state_6);
- _builder.append(_entryCode, " ");
- _builder.newLineIfNotEmpty();
- _builder.append("}");
- _builder.newLine();
- }
- }
- {
- boolean _hasExitCode_1 = this.roomExt.hasExitCode(state_6);
- if (_hasExitCode_1) {
- _builder.append("protected void ");
- String _exitCodeOperationName_1 = RoomNameProv.getExitCodeOperationName(state_6);
- _builder.append(_exitCodeOperationName_1, "");
- _builder.append("() {");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- String _exitCode = this.roomExt.getExitCode(xpac, state_6);
- _builder.append(_exitCode, " ");
- _builder.newLineIfNotEmpty();
- _builder.append("}");
- _builder.newLine();
- }
- }
- }
- }
- }
- }
- _builder.newLine();
- _builder.append("//*** Action Codes");
- _builder.newLine();
- {
- StateMachine _stateMachine_6 = xpac.getStateMachine();
- List<Transition> _transitionList = this.roomExt.getTransitionList(_stateMachine_6);
- for(final Transition tr : _transitionList) {
- {
- boolean _operator_and = false;
- boolean _isOwnObject_1 = xpac.isOwnObject(tr);
- if (!_isOwnObject_1) {
- _operator_and = false;
- } else {
- boolean _hasActionCode = this.roomExt.hasActionCode(tr);
- _operator_and = BooleanExtensions.operator_and(_isOwnObject_1, _hasActionCode);
- }
- if (_operator_and) {
- _builder.append("protected void ");
- String _actionCodeOperationName = RoomNameProv.getActionCodeOperationName(tr);
- _builder.append(_actionCodeOperationName, "");
- _builder.append("(");
- {
- if ((tr instanceof NonInitialTransition)) {
- _builder.append("InterfaceItemBase ifitem");
- String _argumentList = this.languageGen.getArgumentList(xpac, tr);
- _builder.append(_argumentList, "");
- }
- }
- _builder.append(") {");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- String _actionCode = this.roomExt.getActionCode(xpac, tr);
- _builder.append(_actionCode, " ");
- _builder.newLineIfNotEmpty();
- _builder.append("}");
- _builder.newLine();
- }
- }
- }
- }
- _builder.append("\t ");
- _builder.newLine();
- _builder.append("//******************************************");
- _builder.newLine();
- _builder.append("// END of generated code for FSM");
- _builder.newLine();
- _builder.append("//******************************************");
- _builder.newLine();
- return _builder;
- }
-
- protected StringConcatenation _guard(final TriggeredTransition tt, final String trigger, final ExpandedActorClass ac) {
- StringConcatenation _builder = new StringConcatenation();
- EList<Trigger> _triggers = tt.getTriggers();
- final Function1<Trigger,Boolean> _function = new Function1<Trigger,Boolean>() {
- public Boolean apply(final Trigger e) {
- boolean _isMatching = ac.isMatching(e, trigger);
- return ((Boolean)_isMatching);
- }
- };
- Trigger _findFirst = IterableExtensions.<Trigger>findFirst(_triggers, _function);
- Trigger tr = _findFirst;
- _builder.newLineIfNotEmpty();
- {
- boolean _hasGuard = this.roomExt.hasGuard(tr);
- if (_hasGuard) {
- _builder.append("if (");
- Guard _guard = tr.getGuard();
- DetailCode _guard_1 = _guard.getGuard();
- String _code = ac.getCode(_guard_1);
- _builder.append(_code, "");
- _builder.append(")");
- _builder.newLineIfNotEmpty();
- }
- }
- return _builder;
- }
-
- protected StringConcatenation _guard(final Transition t, final String trigger, final ExpandedActorClass ac) {
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("/* error */");
- _builder.newLine();
- return _builder;
- }
-
- public StringConcatenation guard(final Transition tt, final String trigger, final ExpandedActorClass ac) {
- if (tt instanceof TriggeredTransition) {
- return _guard((TriggeredTransition)tt, trigger, ac);
- } else {
- return _guard(tt, trigger, ac);
- }
- }
-}
+package org.eclipse.etrice.generator.java.gen;
+
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+import java.util.List;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.etrice.core.room.ActorClass;
+import org.eclipse.etrice.core.room.DetailCode;
+import org.eclipse.etrice.core.room.Guard;
+import org.eclipse.etrice.core.room.InterfaceItem;
+import org.eclipse.etrice.core.room.Message;
+import org.eclipse.etrice.core.room.MessageFromIf;
+import org.eclipse.etrice.core.room.NonInitialTransition;
+import org.eclipse.etrice.core.room.State;
+import org.eclipse.etrice.core.room.StateGraph;
+import org.eclipse.etrice.core.room.StateMachine;
+import org.eclipse.etrice.core.room.Transition;
+import org.eclipse.etrice.core.room.Trigger;
+import org.eclipse.etrice.core.room.TriggeredTransition;
+import org.eclipse.etrice.generator.etricegen.ActiveTrigger;
+import org.eclipse.etrice.generator.etricegen.ExpandedActorClass;
+import org.eclipse.etrice.generator.etricegen.TransitionChain;
+import org.eclipse.etrice.generator.extensions.RoomExtensions;
+import org.eclipse.etrice.generator.extensions.RoomNameProv;
+import org.eclipse.etrice.generator.generic.LanguageGenerator;
+import org.eclipse.etrice.generator.generic.TypeHelpers;
+import org.eclipse.etrice.generator.java.gen.JavaExtensions;
+import org.eclipse.xtext.xbase.lib.BooleanExtensions;
+import org.eclipse.xtext.xbase.lib.Functions.Function1;
+import org.eclipse.xtext.xbase.lib.IntegerExtensions;
+import org.eclipse.xtext.xbase.lib.IterableExtensions;
+import org.eclipse.xtext.xtend2.lib.StringConcatenation;
+
+@SuppressWarnings("all")
+@Singleton
+public class StateMachineGen {
+ @Inject
+ private JavaExtensions stdExt;
+
+ @Inject
+ private RoomExtensions roomExt;
+
+ @Inject
+ private TypeHelpers _typeHelpers;
+
+ @Inject
+ private LanguageGenerator languageGen;
+
+ public StringConcatenation genStateMachine(final ExpandedActorClass xpac, final ActorClass ac) {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("//******************************************");
+ _builder.newLine();
+ _builder.append("// START of generated code for FSM");
+ _builder.newLine();
+ _builder.append("//******************************************");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("// State IDs for FSM");
+ _builder.newLine();
+ int _numberOfInheritedBaseStates = this.roomExt.getNumberOfInheritedBaseStates(ac);
+ int offset = _numberOfInheritedBaseStates;
+ _builder.newLineIfNotEmpty();
+ StateMachine _stateMachine = ac.getStateMachine();
+ List<State> _baseStateList = this.roomExt.getBaseStateList(_stateMachine);
+ List<State> baseStates = _baseStateList;
+ _builder.newLineIfNotEmpty();
+ {
+ for(final State state : baseStates) {
+ _builder.append("protected static final int ");
+ String _stateId = this.roomExt.getStateId(state);
+ _builder.append(_stateId, "");
+ _builder.append(" = ");
+ int _indexOf = baseStates.indexOf(state);
+ int _operator_plus = IntegerExtensions.operator_plus(((Integer)_indexOf), ((Integer)2));
+ int _operator_plus_1 = IntegerExtensions.operator_plus(((Integer)_operator_plus), ((Integer)offset));
+ _builder.append(_operator_plus_1, "");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("\t");
+ _builder.append("protected static final String stateStrings[] = {\"<no state>\",\"<top>\",");
+ {
+ List<State> _allBaseStates = this.roomExt.getAllBaseStates(ac);
+ boolean hasAnyElements = false;
+ for(final State state_1 : _allBaseStates) {
+ if (!hasAnyElements) {
+ hasAnyElements = true;
+ } else {
+ _builder.appendImmediate(",", " ");
+ }
+ _builder.append("\"");
+ String _statePathName = this.roomExt.getStatePathName(state_1);
+ _builder.append(_statePathName, " ");
+ _builder.append("\"");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ }
+ }
+ _builder.append("};");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("// history");
+ _builder.newLine();
+ _builder.append("// TODOHRR: history defined in ActorClassBase, init in constructor");
+ _builder.newLine();
+ _builder.append("//\t\thistory = new int[5];");
+ _builder.newLine();
+ _builder.append("//\t\tfor (int i = 0; i < history.length; i++) {");
+ _builder.newLine();
+ _builder.append("//\t\t\thistory[i] = NO_STATE;");
+ _builder.newLine();
+ _builder.append("//\t\t}");
+ _builder.newLine();
+ _builder.append("protected int history[] = {NO_STATE,NO_STATE");
+ {
+ List<State> _allBaseStates_1 = this.roomExt.getAllBaseStates(ac);
+ for(final State state_2 : _allBaseStates_1) {
+ _builder.append(",NO_STATE");
+ }
+ }
+ _builder.append("};");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ EList<TransitionChain> _ownTransitionChains = xpac.getOwnTransitionChains();
+ List<TransitionChain> chains = _ownTransitionChains;
+ _builder.newLineIfNotEmpty();
+ EList<TransitionChain> _transitionChains = xpac.getTransitionChains();
+ int _size = _transitionChains.size();
+ int _size_1 = chains.size();
+ int _operator_minus = IntegerExtensions.operator_minus(((Integer)_size), ((Integer)_size_1));
+ int offset_tc = _operator_minus;
+ _builder.newLineIfNotEmpty();
+ _builder.append("// transition chains");
+ _builder.newLine();
+ {
+ for(final TransitionChain tc : chains) {
+ _builder.append("protected static final int ");
+ String _chainId = this.roomExt.getChainId(tc);
+ _builder.append(_chainId, "");
+ _builder.append(" = ");
+ int _indexOf_1 = chains.indexOf(tc);
+ int _operator_plus_2 = IntegerExtensions.operator_plus(((Integer)_indexOf_1), ((Integer)1));
+ int _operator_plus_3 = IntegerExtensions.operator_plus(((Integer)_operator_plus_2), ((Integer)offset_tc));
+ _builder.append(_operator_plus_3, "");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.newLine();
+ EList<MessageFromIf> _ownTriggers = xpac.getOwnTriggers();
+ EList<MessageFromIf> triggers = _ownTriggers;
+ _builder.newLineIfNotEmpty();
+ _builder.append("// triggers for FSM");
+ _builder.newLine();
+ {
+ for(final MessageFromIf mif : triggers) {
+ _builder.append("protected static final int ");
+ String _triggerCodeName = xpac.getTriggerCodeName(mif);
+ _builder.append(_triggerCodeName, "");
+ _builder.append(" = IFITEM_");
+ InterfaceItem _from = mif.getFrom();
+ String _name = _from.getName();
+ _builder.append(_name, "");
+ _builder.append(" + EVT_SHIFT*");
+ String _messageID = xpac.getMessageID(mif);
+ _builder.append(_messageID, "");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.newLine();
+ _builder.append("// receiveEvent contains the main implementation of the FSM");
+ _builder.newLine();
+ _builder.append("@Override");
+ _builder.newLine();
+ _builder.append("public void receiveEvent(InterfaceItemBase ifitem, int evt, Object generic_data) {");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("int trigger = ifitem.getLocalId() + EVT_SHIFT*evt;");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("int chain = NOT_CAUGHT;");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("int catching_state = NO_STATE;");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("boolean is_handler = false;");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("boolean skip_entry = false;");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("if (!handleSystemEvent(ifitem, evt, generic_data)) {");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("switch (state) {");
+ _builder.newLine();
+ {
+ StateMachine _stateMachine_1 = xpac.getStateMachine();
+ List<State> _leafStateList = this.roomExt.getLeafStateList(_stateMachine_1);
+ for(final State state_3 : _leafStateList) {
+ _builder.append("\t\t\t");
+ _builder.append("case ");
+ String _stateId_1 = this.roomExt.getStateId(state_3);
+ _builder.append(_stateId_1, " ");
+ _builder.append(":");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t\t");
+ _builder.append("\t");
+ EList<ActiveTrigger> _activeTriggers = xpac.getActiveTriggers(state_3);
+ EList<ActiveTrigger> atlist = _activeTriggers;
+ _builder.newLineIfNotEmpty();
+ {
+ boolean _isEmpty = atlist.isEmpty();
+ boolean _operator_not = BooleanExtensions.operator_not(_isEmpty);
+ if (_operator_not) {
+ _builder.append("\t\t\t");
+ _builder.append("\t");
+ _builder.append("switch(trigger) {");
+ _builder.newLine();
+ {
+ for(final ActiveTrigger at : atlist) {
+ _builder.append("\t\t\t");
+ _builder.append("\t");
+ _builder.append("case ");
+ String _trigger = at.getTrigger();
+ String _triggerCodeName_1 = xpac.getTriggerCodeName(_trigger);
+ _builder.append(_triggerCodeName_1, " ");
+ _builder.append(":");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t\t");
+ _builder.append("\t");
+ _builder.append("\t");
+ boolean _hasGuard = this.roomExt.hasGuard(xpac, at);
+ boolean needData = _hasGuard;
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t\t");
+ _builder.append("\t");
+ _builder.append("\t");
+ {
+ if (needData) {
+ _builder.append("{ ");
+ Message _msg = at.getMsg();
+ String _typedDataDefinition = this._typeHelpers.getTypedDataDefinition(_msg);
+ _builder.append(_typedDataDefinition, " ");
+ }
+ }
+ _builder.newLineIfNotEmpty();
+ {
+ EList<TriggeredTransition> _transitions = at.getTransitions();
+ boolean hasAnyElements_1 = false;
+ for(final TriggeredTransition tt : _transitions) {
+ if (!hasAnyElements_1) {
+ hasAnyElements_1 = true;
+ } else {
+ _builder.appendImmediate(" else ", " ");
+ }
+ _builder.append("\t\t\t");
+ _builder.append("\t");
+ _builder.append("\t");
+ TransitionChain _chain = xpac.getChain(tt);
+ TransitionChain chain = _chain;
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t\t");
+ _builder.append("\t");
+ _builder.append("\t");
+ Transition _transition = chain.getTransition();
+ String _trigger_1 = at.getTrigger();
+ StringConcatenation _guard = this.guard(_transition, _trigger_1, xpac);
+ _builder.append(_guard, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t\t");
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("{");
+ _builder.newLine();
+ _builder.append("\t\t\t");
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("chain = ");
+ String _chainId_1 = this.roomExt.getChainId(chain);
+ _builder.append(_chainId_1, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t\t");
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("catching_state = ");
+ String _contextId = this.roomExt.getContextId(chain);
+ _builder.append(_contextId, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t\t");
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("\t");
+ {
+ boolean _isHandler = chain.isHandler();
+ if (_isHandler) {
+ _builder.append("is_handler = true;");
+ }
+ }
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t\t");
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("\t");
+ {
+ boolean _isSkipEntry = chain.isSkipEntry();
+ if (_isSkipEntry) {
+ _builder.append("skip_entry = true;");
+ }
+ }
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t\t");
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ }
+ }
+ _builder.append("\t\t\t");
+ _builder.append("\t");
+ _builder.append("\t");
+ {
+ if (needData) {
+ _builder.append("}");
+ }
+ }
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t\t");
+ _builder.append("\t");
+ _builder.append("break;");
+ _builder.newLine();
+ }
+ }
+ _builder.append("\t\t\t");
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ }
+ }
+ _builder.append("\t\t\t");
+ _builder.append("\t");
+ _builder.append("break;");
+ _builder.newLine();
+ }
+ }
+ _builder.append("\t\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("if (chain != NOT_CAUGHT) {");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("exitTo(state, catching_state, is_handler);");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("int next = executeTransitionChain(chain, ifitem, generic_data);");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("next = enterHistory(next, is_handler, skip_entry);");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("setState(next);");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("private void setState(int new_state) {");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("DebuggingService.getInstance().addActorState(this,stateStrings[new_state]);");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("if (stateStrings[new_state]!=\"Idle\") {");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("// TODOTS: model switch for activation");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("System.out.println(getInstancePath() + \" -> \" + stateStrings[new_state]);");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("}\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("this.state = new_state;");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("@Override");
+ _builder.newLine();
+ _builder.append("public void executeInitTransition() {");
+ _builder.newLine();
+ _builder.append("\t");
+ StateMachine _stateMachine_2 = xpac.getStateMachine();
+ Transition _initTransition = this.roomExt.getInitTransition(_stateMachine_2);
+ Transition initt = _initTransition;
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("int chain = ");
+ TransitionChain _chain_1 = xpac.getChain(initt);
+ String _chainId_2 = this.roomExt.getChainId(_chain_1);
+ _builder.append(_chainId_2, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("int next = executeTransitionChain(chain, null, null);");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("next = enterHistory(next, false, false);");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("setState(next);");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("/**");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* calls exit codes while exiting from the current state to one of its");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* parent states while remembering the history");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* @param current - the current state");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* @param to - the final parent state");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* @param handler - entry and exit codes are called only if not handler (for handler TransitionPoints)");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("*/");
+ _builder.newLine();
+ _builder.append("private void exitTo(int current, int to, boolean handler) {");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("while (current!=to) {");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("switch (current) {");
+ _builder.newLine();
+ {
+ StateMachine _stateMachine_3 = xpac.getStateMachine();
+ List<State> _baseStateList_1 = this.roomExt.getBaseStateList(_stateMachine_3);
+ for(final State state_4 : _baseStateList_1) {
+ _builder.append("\t\t\t");
+ _builder.append("case ");
+ String _stateId_2 = this.roomExt.getStateId(state_4);
+ _builder.append(_stateId_2, " ");
+ _builder.append(":");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t\t");
+ _builder.append("\t");
+ {
+ boolean _hasExitCode = this.roomExt.hasExitCode(state_4);
+ if (_hasExitCode) {
+ _builder.append("if (!handler) ");
+ String _exitCodeOperationName = RoomNameProv.getExitCodeOperationName(state_4);
+ _builder.append(_exitCodeOperationName, " ");
+ _builder.append("();");
+ }
+ }
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t\t");
+ _builder.append("\t");
+ _builder.append("history[");
+ String _parentStateId = RoomNameProv.getParentStateId(state_4);
+ _builder.append(_parentStateId, " ");
+ _builder.append("] = ");
+ String _stateId_3 = this.roomExt.getStateId(state_4);
+ _builder.append(_stateId_3, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t\t");
+ _builder.append("\t");
+ _builder.append("current = ");
+ String _parentStateId_1 = RoomNameProv.getParentStateId(state_4);
+ _builder.append(_parentStateId_1, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t\t");
+ _builder.append("\t");
+ _builder.append("break;");
+ _builder.newLine();
+ }
+ }
+ _builder.append("\t\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("/**");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* calls action, entry and exit codes along a transition chain. The generic data are cast to typed data");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* matching the trigger of this chain. The ID of the final state is returned");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* @param chain - the chain ID");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* @param generic_data - the generic data pointer");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* @return the ID of the final state");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("*/");
+ _builder.newLine();
+ _builder.append("private int executeTransitionChain(int chain, InterfaceItemBase ifitem, Object generic_data) {");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("switch (chain) {");
+ _builder.newLine();
+ _builder.append("\t\t");
+ EList<TransitionChain> _transitionChains_1 = xpac.getTransitionChains();
+ EList<TransitionChain> allchains = _transitionChains_1;
+ _builder.newLineIfNotEmpty();
+ {
+ for(final TransitionChain tc_1 : allchains) {
+ _builder.append("\t\t");
+ _builder.append("case ");
+ String _chainId_3 = this.roomExt.getChainId(tc_1);
+ _builder.append(_chainId_3, " ");
+ _builder.append(":");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("{");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("\t");
+ String _executeChainCode = this.stdExt.getExecuteChainCode(xpac, tc_1);
+ _builder.append(_executeChainCode, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("}");
+ _builder.newLine();
+ }
+ }
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("return NO_STATE;");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("/**");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* calls entry codes while entering a state\'s history. The ID of the final leaf state is returned");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* @param state - the state which is entered");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* @param handler - entry code is executed if not handler");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* @return - the ID of the final leaf state");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("*/");
+ _builder.newLine();
+ _builder.append("private int enterHistory(int state, boolean handler, boolean skip_entry) {");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("while (true) {");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("switch (state) {");
+ _builder.newLine();
+ {
+ StateMachine _stateMachine_4 = xpac.getStateMachine();
+ List<State> _baseStateList_2 = this.roomExt.getBaseStateList(_stateMachine_4);
+ for(final State state_5 : _baseStateList_2) {
+ _builder.append("\t\t\t");
+ _builder.append("case ");
+ String _stateId_4 = this.roomExt.getStateId(state_5);
+ _builder.append(_stateId_4, " ");
+ _builder.append(":");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t\t");
+ _builder.append("\t");
+ {
+ boolean _hasEntryCode = this.roomExt.hasEntryCode(state_5);
+ if (_hasEntryCode) {
+ _builder.append("if (!(skip_entry || handler)) ");
+ String _entryCodeOperationName = RoomNameProv.getEntryCodeOperationName(state_5);
+ _builder.append(_entryCodeOperationName, " ");
+ _builder.append("();");
+ }
+ }
+ _builder.newLineIfNotEmpty();
+ {
+ boolean _isLeaf = this.roomExt.isLeaf(state_5);
+ if (_isLeaf) {
+ _builder.append("\t\t\t");
+ _builder.append("\t");
+ _builder.append("// in leaf state: return state id");
+ _builder.newLine();
+ _builder.append("\t\t\t");
+ _builder.append("\t");
+ _builder.append("return ");
+ String _stateId_5 = this.roomExt.getStateId(state_5);
+ _builder.append(_stateId_5, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ } else {
+ _builder.append("\t\t\t");
+ _builder.append("\t");
+ _builder.append("// state has a sub graph");
+ _builder.newLine();
+ {
+ StateGraph _subgraph = state_5.getSubgraph();
+ boolean _hasInitTransition = this.roomExt.hasInitTransition(_subgraph);
+ if (_hasInitTransition) {
+ _builder.append("\t\t\t");
+ _builder.append("\t");
+ _builder.append("// with init transition");
+ _builder.newLine();
+ _builder.append("\t\t\t");
+ _builder.append("\t");
+ _builder.append("if (history[");
+ String _stateId_6 = this.roomExt.getStateId(state_5);
+ _builder.append(_stateId_6, " ");
+ _builder.append("]==NO_STATE) {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t\t");
+ _builder.append("\t");
+ _builder.append("\t");
+ StateGraph _subgraph_1 = state_5.getSubgraph();
+ Transition _initTransition_1 = this.roomExt.getInitTransition(_subgraph_1);
+ Transition sub_initt = _initTransition_1;
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t\t");
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("state = executeTransitionChain(");
+ TransitionChain _chain_2 = xpac.getChain(sub_initt);
+ String _chainId_4 = this.roomExt.getChainId(_chain_2);
+ _builder.append(_chainId_4, " ");
+ _builder.append(", null, null);");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t\t");
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t\t\t");
+ _builder.append("\t");
+ _builder.append("else {");
+ _builder.newLine();
+ _builder.append("\t\t\t");
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("state = history[");
+ String _stateId_7 = this.roomExt.getStateId(state_5);
+ _builder.append(_stateId_7, " ");
+ _builder.append("];");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t\t");
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ } else {
+ _builder.append("\t\t\t");
+ _builder.append("\t");
+ _builder.append("// without init transition");
+ _builder.newLine();
+ _builder.append("\t\t\t");
+ _builder.append("\t");
+ _builder.append("state = history[");
+ String _stateId_8 = this.roomExt.getStateId(state_5);
+ _builder.append(_stateId_8, " ");
+ _builder.append("];");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("\t\t\t");
+ _builder.append("\t");
+ _builder.append("break;");
+ _builder.newLine();
+ }
+ }
+ }
+ }
+ _builder.append("\t\t\t");
+ _builder.append("case STATE_TOP:");
+ _builder.newLine();
+ _builder.append("\t\t\t\t");
+ _builder.append("state = history[STATE_TOP];");
+ _builder.newLine();
+ _builder.append("\t\t\t\t");
+ _builder.append("break;");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("skip_entry = false;");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("//return NO_STATE; // required by CDT but detected as unreachable by JDT because of while (true)");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("//*** Entry and Exit Codes");
+ _builder.newLine();
+ {
+ StateMachine _stateMachine_5 = xpac.getStateMachine();
+ List<State> _stateList = this.roomExt.getStateList(_stateMachine_5);
+ for(final State state_6 : _stateList) {
+ {
+ boolean _isOwnObject = xpac.isOwnObject(state_6);
+ if (_isOwnObject) {
+ {
+ boolean _hasEntryCode_1 = this.roomExt.hasEntryCode(state_6);
+ if (_hasEntryCode_1) {
+ _builder.append("protected void ");
+ String _entryCodeOperationName_1 = RoomNameProv.getEntryCodeOperationName(state_6);
+ _builder.append(_entryCodeOperationName_1, "");
+ _builder.append("() {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ String _entryCode = this.roomExt.getEntryCode(xpac, state_6);
+ _builder.append(_entryCode, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("}");
+ _builder.newLine();
+ }
+ }
+ {
+ boolean _hasExitCode_1 = this.roomExt.hasExitCode(state_6);
+ if (_hasExitCode_1) {
+ _builder.append("protected void ");
+ String _exitCodeOperationName_1 = RoomNameProv.getExitCodeOperationName(state_6);
+ _builder.append(_exitCodeOperationName_1, "");
+ _builder.append("() {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ String _exitCode = this.roomExt.getExitCode(xpac, state_6);
+ _builder.append(_exitCode, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("}");
+ _builder.newLine();
+ }
+ }
+ }
+ }
+ }
+ }
+ _builder.newLine();
+ _builder.append("//*** Action Codes");
+ _builder.newLine();
+ {
+ StateMachine _stateMachine_6 = xpac.getStateMachine();
+ List<Transition> _transitionList = this.roomExt.getTransitionList(_stateMachine_6);
+ for(final Transition tr : _transitionList) {
+ {
+ boolean _operator_and = false;
+ boolean _isOwnObject_1 = xpac.isOwnObject(tr);
+ if (!_isOwnObject_1) {
+ _operator_and = false;
+ } else {
+ boolean _hasActionCode = this.roomExt.hasActionCode(tr);
+ _operator_and = BooleanExtensions.operator_and(_isOwnObject_1, _hasActionCode);
+ }
+ if (_operator_and) {
+ _builder.append("protected void ");
+ String _actionCodeOperationName = RoomNameProv.getActionCodeOperationName(tr);
+ _builder.append(_actionCodeOperationName, "");
+ _builder.append("(");
+ {
+ if ((tr instanceof NonInitialTransition)) {
+ _builder.append("InterfaceItemBase ifitem");
+ String _argumentList = this.languageGen.getArgumentList(xpac, tr);
+ _builder.append(_argumentList, "");
+ }
+ }
+ _builder.append(") {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ String _actionCode = this.roomExt.getActionCode(xpac, tr);
+ _builder.append(_actionCode, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("}");
+ _builder.newLine();
+ }
+ }
+ }
+ }
+ _builder.append("\t ");
+ _builder.newLine();
+ _builder.append("//******************************************");
+ _builder.newLine();
+ _builder.append("// END of generated code for FSM");
+ _builder.newLine();
+ _builder.append("//******************************************");
+ _builder.newLine();
+ return _builder;
+ }
+
+ protected StringConcatenation _guard(final TriggeredTransition tt, final String trigger, final ExpandedActorClass ac) {
+ StringConcatenation _builder = new StringConcatenation();
+ EList<Trigger> _triggers = tt.getTriggers();
+ final Function1<Trigger,Boolean> _function = new Function1<Trigger,Boolean>() {
+ public Boolean apply(final Trigger e) {
+ boolean _isMatching = ac.isMatching(e, trigger);
+ return ((Boolean)_isMatching);
+ }
+ };
+ Trigger _findFirst = IterableExtensions.<Trigger>findFirst(_triggers, _function);
+ Trigger tr = _findFirst;
+ _builder.newLineIfNotEmpty();
+ {
+ boolean _hasGuard = this.roomExt.hasGuard(tr);
+ if (_hasGuard) {
+ _builder.append("if (");
+ Guard _guard = tr.getGuard();
+ DetailCode _guard_1 = _guard.getGuard();
+ String _code = ac.getCode(_guard_1);
+ _builder.append(_code, "");
+ _builder.append(")");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ return _builder;
+ }
+
+ protected StringConcatenation _guard(final Transition t, final String trigger, final ExpandedActorClass ac) {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("/* error */");
+ _builder.newLine();
+ return _builder;
+ }
+
+ public StringConcatenation guard(final Transition tt, final String trigger, final ExpandedActorClass ac) {
+ if (tt instanceof TriggeredTransition) {
+ return _guard((TriggeredTransition)tt, trigger, ac);
+ } else {
+ return _guard(tt, trigger, ac);
+ }
+ }
+}
diff --git a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/SubSystemClassGen.java b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/SubSystemClassGen.java
index 852a87265..ed97d4a4c 100644
--- a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/SubSystemClassGen.java
+++ b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/SubSystemClassGen.java
@@ -1,633 +1,633 @@
-package org.eclipse.etrice.generator.java.gen;
-
-import com.google.inject.Inject;
-import com.google.inject.Singleton;
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.etrice.core.room.ActorClass;
-import org.eclipse.etrice.core.room.DetailCode;
-import org.eclipse.etrice.core.room.LogicalThread;
-import org.eclipse.etrice.core.room.RoomModel;
-import org.eclipse.etrice.core.room.SubSystemClass;
-import org.eclipse.etrice.generator.base.ILogger;
-import org.eclipse.etrice.generator.base.Indexed;
-import org.eclipse.etrice.generator.etricegen.ActorInstance;
-import org.eclipse.etrice.generator.etricegen.InterfaceItemInstance;
-import org.eclipse.etrice.generator.etricegen.Root;
-import org.eclipse.etrice.generator.etricegen.ServiceImplInstance;
-import org.eclipse.etrice.generator.etricegen.SubSystemInstance;
-import org.eclipse.etrice.generator.extensions.RoomExtensions;
-import org.eclipse.etrice.generator.generic.ProcedureHelpers;
-import org.eclipse.etrice.generator.java.gen.JavaExtensions;
-import org.eclipse.xtext.generator.JavaIoFileSystemAccess;
-import org.eclipse.xtext.xbase.lib.BooleanExtensions;
-import org.eclipse.xtext.xbase.lib.ComparableExtensions;
-import org.eclipse.xtext.xbase.lib.IntegerExtensions;
-import org.eclipse.xtext.xbase.lib.StringExtensions;
-import org.eclipse.xtext.xtend2.lib.StringConcatenation;
-
-@SuppressWarnings("all")
-@Singleton
-public class SubSystemClassGen {
- @Inject
- private JavaIoFileSystemAccess fileAccess;
-
- @Inject
- private JavaExtensions stdExt;
-
- @Inject
- private RoomExtensions roomExt;
-
- @Inject
- private ProcedureHelpers helpers;
-
- @Inject
- private ILogger logger;
-
- public void doGenerate(final Root root) {
- EList<SubSystemInstance> _subSystemInstances = root.getSubSystemInstances();
- for (final SubSystemInstance ssi : _subSystemInstances) {
- {
- SubSystemClass _subSystemClass = ssi.getSubSystemClass();
- String _generationTargetPath = this.roomExt.getGenerationTargetPath(_subSystemClass);
- SubSystemClass _subSystemClass_1 = ssi.getSubSystemClass();
- String _path = this.roomExt.getPath(_subSystemClass_1);
- String _operator_plus = StringExtensions.operator_plus(_generationTargetPath, _path);
- String path = _operator_plus;
- SubSystemClass _subSystemClass_2 = ssi.getSubSystemClass();
- String _javaFileName = this.stdExt.getJavaFileName(_subSystemClass_2);
- String file = _javaFileName;
- String _operator_plus_1 = StringExtensions.operator_plus("generating SubSystemClass implementation: \'", file);
- String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, "\' in \'");
- String _operator_plus_3 = StringExtensions.operator_plus(_operator_plus_2, path);
- String _operator_plus_4 = StringExtensions.operator_plus(_operator_plus_3, "\'");
- this.logger.logInfo(_operator_plus_4);
- this.fileAccess.setOutputPath(path);
- SubSystemClass _subSystemClass_3 = ssi.getSubSystemClass();
- StringConcatenation _generate = this.generate(root, ssi, _subSystemClass_3);
- this.fileAccess.generateFile(file, _generate);
- }
- }
- }
-
- public StringConcatenation generate(final Root root, final SubSystemInstance comp, final SubSystemClass cc) {
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("package ");
- String _package = this.roomExt.getPackage(cc);
- _builder.append(_package, "");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("import org.eclipse.etrice.runtime.java.messaging.MessageService;");
- _builder.newLine();
- _builder.append("import org.eclipse.etrice.runtime.java.messaging.RTServices;");
- _builder.newLine();
- _builder.append("import org.eclipse.etrice.runtime.java.messaging.Address;");
- _builder.newLine();
- _builder.append("import org.eclipse.etrice.runtime.java.messaging.IRTObject;");
- _builder.newLine();
- _builder.append("import org.eclipse.etrice.runtime.java.messaging.RTSystemServicesProtocol.*;");
- _builder.newLine();
- _builder.append("import org.eclipse.etrice.runtime.java.modelbase.ActorClassBase;");
- _builder.newLine();
- _builder.append("import org.eclipse.etrice.runtime.java.modelbase.SubSystemClassBase;");
- _builder.newLine();
- _builder.append("import org.eclipse.etrice.runtime.java.modelbase.InterfaceItemBase;");
- _builder.newLine();
- _builder.newLine();
- EList<RoomModel> _referencedModels = root.getReferencedModels(cc);
- EList<RoomModel> models = _referencedModels;
- _builder.newLineIfNotEmpty();
- {
- for(final RoomModel model : models) {
- _builder.append("import ");
- String _name = model.getName();
- _builder.append(_name, "");
- _builder.append(".*;");
- }
- }
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.newLine();
- DetailCode _userCode1 = cc.getUserCode1();
- StringConcatenation _UserCode = this.helpers.UserCode(_userCode1);
- _builder.append(_UserCode, "");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("public class ");
- String _name_1 = comp.getName();
- _builder.append(_name_1, "");
- _builder.append(" extends SubSystemClassBase{");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("\t");
- DetailCode _userCode2 = cc.getUserCode2();
- StringConcatenation _UserCode_1 = this.helpers.UserCode(_userCode2);
- _builder.append(_UserCode_1, " ");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("public ");
- String _name_2 = comp.getName();
- _builder.append(_name_2, " ");
- _builder.append("(IRTObject parent, String name) {");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.append("super(parent, name);");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("@Override");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("public void receiveEvent(InterfaceItemBase ifitem, int evt, Object data){");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("@Override\t");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("public void instantiateMessageServices(){");
- _builder.newLine();
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("RTServices.getInstance().getMsgSvcCtrl().addMsgSvc(new MessageService(this, new Address(0, 0, 0),\"MessageService_Main\"));");
- _builder.newLine();
- {
- EList<LogicalThread> _threads = cc.getThreads();
- for(final LogicalThread thread : _threads) {
- _builder.append("\t\t");
- _builder.append("RTServices.getInstance().getMsgSvcCtrl().addMsgSvc(new MessageService(this, new Address(0, ");
- EList<LogicalThread> _threads_1 = cc.getThreads();
- int _indexOf = _threads_1.indexOf(thread);
- int _operator_plus = IntegerExtensions.operator_plus(((Integer)_indexOf), ((Integer)1));
- _builder.append(_operator_plus, " ");
- _builder.append(", 0),\"MessageService_");
- String _name_3 = thread.getName();
- _builder.append(_name_3, " ");
- _builder.append("\", ");
- int _prio = thread.getPrio();
- _builder.append(_prio, " ");
- _builder.append("));");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("\t\t");
- _builder.append("}");
- _builder.newLine();
- _builder.newLine();
- _builder.append("\t");
- _builder.append("@Override");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("public void instantiateActors(){");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("// all addresses");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("// Addresses for the Subsystem Systemport");
- _builder.newLine();
- {
- EList<ActorInstance> _allContainedInstances = comp.getAllContainedInstances();
- int _maxObjId = comp.getMaxObjId();
- Iterable<Indexed<ActorInstance>> _indexed = Indexed.<ActorInstance>indexed(_allContainedInstances, _maxObjId);
- for(final Indexed<ActorInstance> ai : _indexed) {
- _builder.append("\t\t");
- _builder.append("Address addr_item_SystemPort_");
- EList<ActorInstance> _allContainedInstances_1 = comp.getAllContainedInstances();
- ActorInstance _value = ai.getValue();
- int _indexOf_1 = _allContainedInstances_1.indexOf(_value);
- _builder.append(_indexOf_1, " ");
- _builder.append(" = new Address(0,0,");
- int _index1 = ai.getIndex1();
- _builder.append(_index1, " ");
- _builder.append(");");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("\t\t");
- _builder.newLine();
- {
- EList<ActorInstance> _allContainedInstances_2 = comp.getAllContainedInstances();
- for(final ActorInstance ai_1 : _allContainedInstances_2) {
- _builder.append("\t\t");
- _builder.append("// actor instance ");
- String _path = ai_1.getPath();
- _builder.append(_path, " ");
- _builder.append(" itself => Systemport Address");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.append("// TODOTJ: For each Actor, multiple addresses should be generated (actor?, systemport, debugport)");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("Address addr_item_");
- String _path_1 = ai_1.getPath();
- String _pathName = this.roomExt.getPathName(_path_1);
- _builder.append(_pathName, " ");
- _builder.append(" = new Address(0,");
- int _threadId = ai_1.getThreadId();
- _builder.append(_threadId, " ");
- _builder.append(",");
- int _objId = ai_1.getObjId();
- _builder.append(_objId, " ");
- _builder.append(");");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.append("// interface items of ");
- String _path_2 = ai_1.getPath();
- _builder.append(_path_2, " ");
- _builder.newLineIfNotEmpty();
- {
- EList<InterfaceItemInstance> _orderedIfItemInstances = ai_1.getOrderedIfItemInstances();
- for(final InterfaceItemInstance pi : _orderedIfItemInstances) {
- {
- boolean _operator_or = false;
- if ((pi instanceof ServiceImplInstance)) {
- _operator_or = true;
- } else {
- EList<InterfaceItemInstance> _peers = pi.getPeers();
- int _size = _peers.size();
- boolean _operator_greaterThan = ComparableExtensions.<Integer>operator_greaterThan(((Integer)_size), ((Integer)1));
- _operator_or = BooleanExtensions.operator_or((pi instanceof ServiceImplInstance), _operator_greaterThan);
- }
- if (_operator_or) {
- {
- EList<InterfaceItemInstance> _peers_1 = pi.getPeers();
- for(final InterfaceItemInstance peer : _peers_1) {
- _builder.append("\t\t");
- EList<InterfaceItemInstance> _peers_2 = pi.getPeers();
- int _indexOf_2 = _peers_2.indexOf(peer);
- int i = _indexOf_2;
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.append("Address addr_item_");
- String _path_3 = pi.getPath();
- String _pathName_1 = this.roomExt.getPathName(_path_3);
- _builder.append(_pathName_1, " ");
- _builder.append("_");
- _builder.append(i, " ");
- _builder.append(" = new Address(0,");
- int _threadId_1 = pi.getThreadId();
- _builder.append(_threadId_1, " ");
- _builder.append(",");
- int _objId_1 = pi.getObjId();
- int _operator_plus_1 = IntegerExtensions.operator_plus(((Integer)_objId_1), ((Integer)i));
- _builder.append(_operator_plus_1, " ");
- _builder.append(");");
- _builder.newLineIfNotEmpty();
- }
- }
- } else {
- _builder.append("\t\t");
- _builder.append("Address addr_item_");
- String _path_4 = pi.getPath();
- String _pathName_2 = this.roomExt.getPathName(_path_4);
- _builder.append(_pathName_2, " ");
- _builder.append(" = new Address(0,");
- int _threadId_2 = ai_1.getThreadId();
- _builder.append(_threadId_2, " ");
- _builder.append(",");
- int _objId_2 = pi.getObjId();
- _builder.append(_objId_2, " ");
- _builder.append(");");
- _builder.newLineIfNotEmpty();
- }
- }
- }
- }
- }
- }
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("// instantiate all actor instances");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("instances = new ActorClassBase[");
- EList<ActorInstance> _allContainedInstances_3 = comp.getAllContainedInstances();
- int _size_1 = _allContainedInstances_3.size();
- _builder.append(_size_1, " ");
- _builder.append("];");
- _builder.newLineIfNotEmpty();
- {
- EList<ActorInstance> _allContainedInstances_4 = comp.getAllContainedInstances();
- for(final ActorInstance ai_2 : _allContainedInstances_4) {
- _builder.append("\t\t");
- _builder.append("instances[");
- EList<ActorInstance> _allContainedInstances_5 = comp.getAllContainedInstances();
- int _indexOf_3 = _allContainedInstances_5.indexOf(ai_2);
- _builder.append(_indexOf_3, " ");
- _builder.append("] = new ");
- ActorClass _actorClass = ai_2.getActorClass();
- String _name_4 = _actorClass.getName();
- _builder.append(_name_4, " ");
- _builder.append("(");
- _builder.newLineIfNotEmpty();
- {
- EObject _eContainer = ai_2.eContainer();
- if ((_eContainer instanceof SubSystemInstance)) {
- _builder.append("\t\t");
- _builder.append("\t");
- _builder.append("this,");
- _builder.newLine();
- } else {
- _builder.append("\t\t");
- _builder.append("\t");
- _builder.append("instances[");
- EList<ActorInstance> _allContainedInstances_6 = comp.getAllContainedInstances();
- EObject _eContainer_1 = ai_2.eContainer();
- int _indexOf_4 = _allContainedInstances_6.indexOf(_eContainer_1);
- _builder.append(_indexOf_4, " ");
- _builder.append("],");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("\t\t");
- _builder.append("\t");
- _builder.append("\"");
- String _name_5 = ai_2.getName();
- _builder.append(_name_5, " ");
- _builder.append("\",");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.append("\t");
- _builder.append("// own interface item addresses");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("\t");
- _builder.append("new Address[][] {{addr_item_");
- String _path_5 = ai_2.getPath();
- String _pathName_3 = this.roomExt.getPathName(_path_5);
- _builder.append(_pathName_3, " ");
- _builder.append("}");
- {
- EList<InterfaceItemInstance> _orderedIfItemInstances_1 = ai_2.getOrderedIfItemInstances();
- boolean _isEmpty = _orderedIfItemInstances_1.isEmpty();
- boolean _operator_not = BooleanExtensions.operator_not(_isEmpty);
- if (_operator_not) {
- _builder.append(",");
- }
- }
- _builder.newLineIfNotEmpty();
- {
- EList<InterfaceItemInstance> _orderedIfItemInstances_2 = ai_2.getOrderedIfItemInstances();
- boolean hasAnyElements = false;
- for(final InterfaceItemInstance pi_1 : _orderedIfItemInstances_2) {
- if (!hasAnyElements) {
- hasAnyElements = true;
- } else {
- _builder.appendImmediate(",", " ");
- }
- _builder.append("\t\t");
- _builder.append("\t");
- _builder.append("{");
- _builder.newLine();
- {
- boolean _operator_or_1 = false;
- if ((pi_1 instanceof ServiceImplInstance)) {
- _operator_or_1 = true;
- } else {
- EList<InterfaceItemInstance> _peers_3 = pi_1.getPeers();
- int _size_2 = _peers_3.size();
- boolean _operator_greaterThan_1 = ComparableExtensions.<Integer>operator_greaterThan(((Integer)_size_2), ((Integer)1));
- _operator_or_1 = BooleanExtensions.operator_or((pi_1 instanceof ServiceImplInstance), _operator_greaterThan_1);
- }
- if (_operator_or_1) {
- {
- EList<InterfaceItemInstance> _peers_4 = pi_1.getPeers();
- boolean hasAnyElements_1 = false;
- for(final InterfaceItemInstance peer_1 : _peers_4) {
- if (!hasAnyElements_1) {
- hasAnyElements_1 = true;
- } else {
- _builder.appendImmediate(",", " ");
- }
- _builder.append("\t\t");
- _builder.append("\t");
- _builder.append("\t");
- _builder.append("addr_item_");
- String _path_6 = pi_1.getPath();
- String _pathName_4 = this.roomExt.getPathName(_path_6);
- _builder.append(_pathName_4, " ");
- _builder.append("_");
- EList<InterfaceItemInstance> _peers_5 = pi_1.getPeers();
- int _indexOf_5 = _peers_5.indexOf(peer_1);
- _builder.append(_indexOf_5, " ");
- _builder.newLineIfNotEmpty();
- }
- }
- } else {
- _builder.append("\t\t");
- _builder.append("\t");
- _builder.append("\t");
- _builder.append("addr_item_");
- String _path_7 = pi_1.getPath();
- String _pathName_5 = this.roomExt.getPathName(_path_7);
- _builder.append(_pathName_5, " ");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("\t\t");
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- }
- }
- _builder.append("\t\t");
- _builder.append("\t");
- _builder.append("},");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("\t");
- _builder.append("// peer interface item addresses");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("\t");
- _builder.append("new Address[][] {{addr_item_SystemPort_");
- EList<ActorInstance> _allContainedInstances_7 = comp.getAllContainedInstances();
- int _indexOf_6 = _allContainedInstances_7.indexOf(ai_2);
- _builder.append(_indexOf_6, " ");
- _builder.append("}");
- {
- EList<InterfaceItemInstance> _orderedIfItemInstances_3 = ai_2.getOrderedIfItemInstances();
- boolean _isEmpty_1 = _orderedIfItemInstances_3.isEmpty();
- boolean _operator_not_1 = BooleanExtensions.operator_not(_isEmpty_1);
- if (_operator_not_1) {
- _builder.append(",");
- }
- }
- _builder.newLineIfNotEmpty();
- {
- EList<InterfaceItemInstance> _orderedIfItemInstances_4 = ai_2.getOrderedIfItemInstances();
- boolean hasAnyElements_2 = false;
- for(final InterfaceItemInstance pi_2 : _orderedIfItemInstances_4) {
- if (!hasAnyElements_2) {
- hasAnyElements_2 = true;
- } else {
- _builder.appendImmediate(",", " ");
- }
- _builder.append("\t\t");
- _builder.append("\t\t");
- _builder.append("{");
- _builder.newLine();
- {
- boolean _operator_and = false;
- boolean _operator_not_2 = BooleanExtensions.operator_not((pi_2 instanceof ServiceImplInstance));
- if (!_operator_not_2) {
- _operator_and = false;
- } else {
- EList<InterfaceItemInstance> _peers_6 = pi_2.getPeers();
- boolean _isEmpty_2 = _peers_6.isEmpty();
- _operator_and = BooleanExtensions.operator_and(_operator_not_2, _isEmpty_2);
- }
- if (_operator_and) {
- _builder.append("\t\t");
- _builder.append("\t\t");
- _builder.append("\t");
- _builder.append("null");
- _builder.newLine();
- } else {
- {
- EList<InterfaceItemInstance> _peers_7 = pi_2.getPeers();
- boolean hasAnyElements_3 = false;
- for(final InterfaceItemInstance pp : _peers_7) {
- if (!hasAnyElements_3) {
- hasAnyElements_3 = true;
- } else {
- _builder.appendImmediate(",", " ");
- }
- {
- boolean _operator_or_2 = false;
- if ((pp instanceof ServiceImplInstance)) {
- _operator_or_2 = true;
- } else {
- EList<InterfaceItemInstance> _peers_8 = pp.getPeers();
- int _size_3 = _peers_8.size();
- boolean _operator_greaterThan_2 = ComparableExtensions.<Integer>operator_greaterThan(((Integer)_size_3), ((Integer)1));
- _operator_or_2 = BooleanExtensions.operator_or((pp instanceof ServiceImplInstance), _operator_greaterThan_2);
- }
- if (_operator_or_2) {
- _builder.append("\t\t");
- _builder.append("\t\t");
- _builder.append("\t");
- _builder.append("addr_item_");
- String _path_8 = pp.getPath();
- String _pathName_6 = this.roomExt.getPathName(_path_8);
- _builder.append(_pathName_6, " ");
- _builder.append("_");
- EList<InterfaceItemInstance> _peers_9 = pp.getPeers();
- int _indexOf_7 = _peers_9.indexOf(pi_2);
- _builder.append(_indexOf_7, " ");
- _builder.newLineIfNotEmpty();
- } else {
- _builder.append("\t\t");
- _builder.append("\t\t");
- _builder.append("\t");
- _builder.append("addr_item_");
- String _path_9 = pp.getPath();
- String _pathName_7 = this.roomExt.getPathName(_path_9);
- _builder.append(_pathName_7, " ");
- _builder.newLineIfNotEmpty();
- }
- }
- }
- }
- }
- }
- _builder.append("\t\t");
- _builder.append("\t\t");
- _builder.append("}");
- _builder.newLine();
- }
- }
- _builder.append("\t\t");
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("); ");
- _builder.newLine();
- }
- }
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("// create the subsystem system port\t");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("RTSystemPort = new RTSystemServicesProtocolConjPortRepl(this, \"RTSystemPort\",");
- _builder.newLine();
- _builder.append("\t\t\t\t");
- _builder.append("0, //local ID");
- _builder.newLine();
- _builder.append("\t\t\t\t");
- _builder.append("// own addresses");
- _builder.newLine();
- _builder.append("\t\t\t\t");
- _builder.append("new Address[]{");
- _builder.newLine();
- {
- EList<ActorInstance> _allContainedInstances_8 = comp.getAllContainedInstances();
- boolean hasAnyElements_4 = false;
- for(final ActorInstance ai_3 : _allContainedInstances_8) {
- if (!hasAnyElements_4) {
- hasAnyElements_4 = true;
- } else {
- _builder.appendImmediate(",", " ");
- }
- _builder.append("\t\t\t\t\t");
- _builder.append("addr_item_SystemPort_");
- EList<ActorInstance> _allContainedInstances_9 = comp.getAllContainedInstances();
- int _indexOf_8 = _allContainedInstances_9.indexOf(ai_3);
- _builder.append(_indexOf_8, " ");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("\t\t\t\t");
- _builder.append("},");
- _builder.newLine();
- _builder.append("\t\t\t\t");
- _builder.append("// peer addresses");
- _builder.newLine();
- _builder.append("\t\t\t\t");
- _builder.append("new Address[]{");
- _builder.newLine();
- {
- EList<ActorInstance> _allContainedInstances_10 = comp.getAllContainedInstances();
- boolean hasAnyElements_5 = false;
- for(final ActorInstance ai_4 : _allContainedInstances_10) {
- if (!hasAnyElements_5) {
- hasAnyElements_5 = true;
- } else {
- _builder.appendImmediate(",", " ");
- }
- _builder.append("\t\t\t\t\t");
- _builder.append("addr_item_");
- String _path_10 = ai_4.getPath();
- String _pathName_8 = this.roomExt.getPathName(_path_10);
- _builder.append(_pathName_8, " ");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("\t\t\t\t");
- _builder.append("});");
- _builder.newLine();
- _builder.append("\t\t\t\t");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("};");
- _builder.newLine();
- return _builder;
- }
-}
+package org.eclipse.etrice.generator.java.gen;
+
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.etrice.core.room.ActorClass;
+import org.eclipse.etrice.core.room.DetailCode;
+import org.eclipse.etrice.core.room.LogicalThread;
+import org.eclipse.etrice.core.room.RoomModel;
+import org.eclipse.etrice.core.room.SubSystemClass;
+import org.eclipse.etrice.generator.base.ILogger;
+import org.eclipse.etrice.generator.base.Indexed;
+import org.eclipse.etrice.generator.etricegen.ActorInstance;
+import org.eclipse.etrice.generator.etricegen.InterfaceItemInstance;
+import org.eclipse.etrice.generator.etricegen.Root;
+import org.eclipse.etrice.generator.etricegen.ServiceImplInstance;
+import org.eclipse.etrice.generator.etricegen.SubSystemInstance;
+import org.eclipse.etrice.generator.extensions.RoomExtensions;
+import org.eclipse.etrice.generator.generic.ProcedureHelpers;
+import org.eclipse.etrice.generator.java.gen.JavaExtensions;
+import org.eclipse.xtext.generator.JavaIoFileSystemAccess;
+import org.eclipse.xtext.xbase.lib.BooleanExtensions;
+import org.eclipse.xtext.xbase.lib.ComparableExtensions;
+import org.eclipse.xtext.xbase.lib.IntegerExtensions;
+import org.eclipse.xtext.xbase.lib.StringExtensions;
+import org.eclipse.xtext.xtend2.lib.StringConcatenation;
+
+@SuppressWarnings("all")
+@Singleton
+public class SubSystemClassGen {
+ @Inject
+ private JavaIoFileSystemAccess fileAccess;
+
+ @Inject
+ private JavaExtensions stdExt;
+
+ @Inject
+ private RoomExtensions roomExt;
+
+ @Inject
+ private ProcedureHelpers helpers;
+
+ @Inject
+ private ILogger logger;
+
+ public void doGenerate(final Root root) {
+ EList<SubSystemInstance> _subSystemInstances = root.getSubSystemInstances();
+ for (final SubSystemInstance ssi : _subSystemInstances) {
+ {
+ SubSystemClass _subSystemClass = ssi.getSubSystemClass();
+ String _generationTargetPath = this.roomExt.getGenerationTargetPath(_subSystemClass);
+ SubSystemClass _subSystemClass_1 = ssi.getSubSystemClass();
+ String _path = this.roomExt.getPath(_subSystemClass_1);
+ String _operator_plus = StringExtensions.operator_plus(_generationTargetPath, _path);
+ String path = _operator_plus;
+ SubSystemClass _subSystemClass_2 = ssi.getSubSystemClass();
+ String _javaFileName = this.stdExt.getJavaFileName(_subSystemClass_2);
+ String file = _javaFileName;
+ String _operator_plus_1 = StringExtensions.operator_plus("generating SubSystemClass implementation: \'", file);
+ String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, "\' in \'");
+ String _operator_plus_3 = StringExtensions.operator_plus(_operator_plus_2, path);
+ String _operator_plus_4 = StringExtensions.operator_plus(_operator_plus_3, "\'");
+ this.logger.logInfo(_operator_plus_4);
+ this.fileAccess.setOutputPath(path);
+ SubSystemClass _subSystemClass_3 = ssi.getSubSystemClass();
+ StringConcatenation _generate = this.generate(root, ssi, _subSystemClass_3);
+ this.fileAccess.generateFile(file, _generate);
+ }
+ }
+ }
+
+ public StringConcatenation generate(final Root root, final SubSystemInstance comp, final SubSystemClass cc) {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("package ");
+ String _package = this.roomExt.getPackage(cc);
+ _builder.append(_package, "");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("import org.eclipse.etrice.runtime.java.messaging.MessageService;");
+ _builder.newLine();
+ _builder.append("import org.eclipse.etrice.runtime.java.messaging.RTServices;");
+ _builder.newLine();
+ _builder.append("import org.eclipse.etrice.runtime.java.messaging.Address;");
+ _builder.newLine();
+ _builder.append("import org.eclipse.etrice.runtime.java.messaging.IRTObject;");
+ _builder.newLine();
+ _builder.append("import org.eclipse.etrice.runtime.java.messaging.RTSystemServicesProtocol.*;");
+ _builder.newLine();
+ _builder.append("import org.eclipse.etrice.runtime.java.modelbase.ActorClassBase;");
+ _builder.newLine();
+ _builder.append("import org.eclipse.etrice.runtime.java.modelbase.SubSystemClassBase;");
+ _builder.newLine();
+ _builder.append("import org.eclipse.etrice.runtime.java.modelbase.InterfaceItemBase;");
+ _builder.newLine();
+ _builder.newLine();
+ EList<RoomModel> _referencedModels = root.getReferencedModels(cc);
+ EList<RoomModel> models = _referencedModels;
+ _builder.newLineIfNotEmpty();
+ {
+ for(final RoomModel model : models) {
+ _builder.append("import ");
+ String _name = model.getName();
+ _builder.append(_name, "");
+ _builder.append(".*;");
+ }
+ }
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.newLine();
+ DetailCode _userCode1 = cc.getUserCode1();
+ StringConcatenation _UserCode = this.helpers.UserCode(_userCode1);
+ _builder.append(_UserCode, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("public class ");
+ String _name_1 = comp.getName();
+ _builder.append(_name_1, "");
+ _builder.append(" extends SubSystemClassBase{");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("\t");
+ DetailCode _userCode2 = cc.getUserCode2();
+ StringConcatenation _UserCode_1 = this.helpers.UserCode(_userCode2);
+ _builder.append(_UserCode_1, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("public ");
+ String _name_2 = comp.getName();
+ _builder.append(_name_2, " ");
+ _builder.append("(IRTObject parent, String name) {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("super(parent, name);");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("@Override");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("public void receiveEvent(InterfaceItemBase ifitem, int evt, Object data){");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("@Override\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("public void instantiateMessageServices(){");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("RTServices.getInstance().getMsgSvcCtrl().addMsgSvc(new MessageService(this, new Address(0, 0, 0),\"MessageService_Main\"));");
+ _builder.newLine();
+ {
+ EList<LogicalThread> _threads = cc.getThreads();
+ for(final LogicalThread thread : _threads) {
+ _builder.append("\t\t");
+ _builder.append("RTServices.getInstance().getMsgSvcCtrl().addMsgSvc(new MessageService(this, new Address(0, ");
+ EList<LogicalThread> _threads_1 = cc.getThreads();
+ int _indexOf = _threads_1.indexOf(thread);
+ int _operator_plus = IntegerExtensions.operator_plus(((Integer)_indexOf), ((Integer)1));
+ _builder.append(_operator_plus, " ");
+ _builder.append(", 0),\"MessageService_");
+ String _name_3 = thread.getName();
+ _builder.append(_name_3, " ");
+ _builder.append("\", ");
+ int _prio = thread.getPrio();
+ _builder.append(_prio, " ");
+ _builder.append("));");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("\t\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("@Override");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("public void instantiateActors(){");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("// all addresses");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("// Addresses for the Subsystem Systemport");
+ _builder.newLine();
+ {
+ EList<ActorInstance> _allContainedInstances = comp.getAllContainedInstances();
+ int _maxObjId = comp.getMaxObjId();
+ Iterable<Indexed<ActorInstance>> _indexed = Indexed.<ActorInstance>indexed(_allContainedInstances, _maxObjId);
+ for(final Indexed<ActorInstance> ai : _indexed) {
+ _builder.append("\t\t");
+ _builder.append("Address addr_item_SystemPort_");
+ EList<ActorInstance> _allContainedInstances_1 = comp.getAllContainedInstances();
+ ActorInstance _value = ai.getValue();
+ int _indexOf_1 = _allContainedInstances_1.indexOf(_value);
+ _builder.append(_indexOf_1, " ");
+ _builder.append(" = new Address(0,0,");
+ int _index1 = ai.getIndex1();
+ _builder.append(_index1, " ");
+ _builder.append(");");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("\t\t");
+ _builder.newLine();
+ {
+ EList<ActorInstance> _allContainedInstances_2 = comp.getAllContainedInstances();
+ for(final ActorInstance ai_1 : _allContainedInstances_2) {
+ _builder.append("\t\t");
+ _builder.append("// actor instance ");
+ String _path = ai_1.getPath();
+ _builder.append(_path, " ");
+ _builder.append(" itself => Systemport Address");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("// TODOTJ: For each Actor, multiple addresses should be generated (actor?, systemport, debugport)");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("Address addr_item_");
+ String _path_1 = ai_1.getPath();
+ String _pathName = this.roomExt.getPathName(_path_1);
+ _builder.append(_pathName, " ");
+ _builder.append(" = new Address(0,");
+ int _threadId = ai_1.getThreadId();
+ _builder.append(_threadId, " ");
+ _builder.append(",");
+ int _objId = ai_1.getObjId();
+ _builder.append(_objId, " ");
+ _builder.append(");");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("// interface items of ");
+ String _path_2 = ai_1.getPath();
+ _builder.append(_path_2, " ");
+ _builder.newLineIfNotEmpty();
+ {
+ EList<InterfaceItemInstance> _orderedIfItemInstances = ai_1.getOrderedIfItemInstances();
+ for(final InterfaceItemInstance pi : _orderedIfItemInstances) {
+ {
+ boolean _operator_or = false;
+ if ((pi instanceof ServiceImplInstance)) {
+ _operator_or = true;
+ } else {
+ EList<InterfaceItemInstance> _peers = pi.getPeers();
+ int _size = _peers.size();
+ boolean _operator_greaterThan = ComparableExtensions.<Integer>operator_greaterThan(((Integer)_size), ((Integer)1));
+ _operator_or = BooleanExtensions.operator_or((pi instanceof ServiceImplInstance), _operator_greaterThan);
+ }
+ if (_operator_or) {
+ {
+ EList<InterfaceItemInstance> _peers_1 = pi.getPeers();
+ for(final InterfaceItemInstance peer : _peers_1) {
+ _builder.append("\t\t");
+ EList<InterfaceItemInstance> _peers_2 = pi.getPeers();
+ int _indexOf_2 = _peers_2.indexOf(peer);
+ int i = _indexOf_2;
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("Address addr_item_");
+ String _path_3 = pi.getPath();
+ String _pathName_1 = this.roomExt.getPathName(_path_3);
+ _builder.append(_pathName_1, " ");
+ _builder.append("_");
+ _builder.append(i, " ");
+ _builder.append(" = new Address(0,");
+ int _threadId_1 = pi.getThreadId();
+ _builder.append(_threadId_1, " ");
+ _builder.append(",");
+ int _objId_1 = pi.getObjId();
+ int _operator_plus_1 = IntegerExtensions.operator_plus(((Integer)_objId_1), ((Integer)i));
+ _builder.append(_operator_plus_1, " ");
+ _builder.append(");");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ } else {
+ _builder.append("\t\t");
+ _builder.append("Address addr_item_");
+ String _path_4 = pi.getPath();
+ String _pathName_2 = this.roomExt.getPathName(_path_4);
+ _builder.append(_pathName_2, " ");
+ _builder.append(" = new Address(0,");
+ int _threadId_2 = ai_1.getThreadId();
+ _builder.append(_threadId_2, " ");
+ _builder.append(",");
+ int _objId_2 = pi.getObjId();
+ _builder.append(_objId_2, " ");
+ _builder.append(");");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ }
+ }
+ }
+ }
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("// instantiate all actor instances");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("instances = new ActorClassBase[");
+ EList<ActorInstance> _allContainedInstances_3 = comp.getAllContainedInstances();
+ int _size_1 = _allContainedInstances_3.size();
+ _builder.append(_size_1, " ");
+ _builder.append("];");
+ _builder.newLineIfNotEmpty();
+ {
+ EList<ActorInstance> _allContainedInstances_4 = comp.getAllContainedInstances();
+ for(final ActorInstance ai_2 : _allContainedInstances_4) {
+ _builder.append("\t\t");
+ _builder.append("instances[");
+ EList<ActorInstance> _allContainedInstances_5 = comp.getAllContainedInstances();
+ int _indexOf_3 = _allContainedInstances_5.indexOf(ai_2);
+ _builder.append(_indexOf_3, " ");
+ _builder.append("] = new ");
+ ActorClass _actorClass = ai_2.getActorClass();
+ String _name_4 = _actorClass.getName();
+ _builder.append(_name_4, " ");
+ _builder.append("(");
+ _builder.newLineIfNotEmpty();
+ {
+ EObject _eContainer = ai_2.eContainer();
+ if ((_eContainer instanceof SubSystemInstance)) {
+ _builder.append("\t\t");
+ _builder.append("\t");
+ _builder.append("this,");
+ _builder.newLine();
+ } else {
+ _builder.append("\t\t");
+ _builder.append("\t");
+ _builder.append("instances[");
+ EList<ActorInstance> _allContainedInstances_6 = comp.getAllContainedInstances();
+ EObject _eContainer_1 = ai_2.eContainer();
+ int _indexOf_4 = _allContainedInstances_6.indexOf(_eContainer_1);
+ _builder.append(_indexOf_4, " ");
+ _builder.append("],");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("\t\t");
+ _builder.append("\t");
+ _builder.append("\"");
+ String _name_5 = ai_2.getName();
+ _builder.append(_name_5, " ");
+ _builder.append("\",");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("\t");
+ _builder.append("// own interface item addresses");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("\t");
+ _builder.append("new Address[][] {{addr_item_");
+ String _path_5 = ai_2.getPath();
+ String _pathName_3 = this.roomExt.getPathName(_path_5);
+ _builder.append(_pathName_3, " ");
+ _builder.append("}");
+ {
+ EList<InterfaceItemInstance> _orderedIfItemInstances_1 = ai_2.getOrderedIfItemInstances();
+ boolean _isEmpty = _orderedIfItemInstances_1.isEmpty();
+ boolean _operator_not = BooleanExtensions.operator_not(_isEmpty);
+ if (_operator_not) {
+ _builder.append(",");
+ }
+ }
+ _builder.newLineIfNotEmpty();
+ {
+ EList<InterfaceItemInstance> _orderedIfItemInstances_2 = ai_2.getOrderedIfItemInstances();
+ boolean hasAnyElements = false;
+ for(final InterfaceItemInstance pi_1 : _orderedIfItemInstances_2) {
+ if (!hasAnyElements) {
+ hasAnyElements = true;
+ } else {
+ _builder.appendImmediate(",", " ");
+ }
+ _builder.append("\t\t");
+ _builder.append("\t");
+ _builder.append("{");
+ _builder.newLine();
+ {
+ boolean _operator_or_1 = false;
+ if ((pi_1 instanceof ServiceImplInstance)) {
+ _operator_or_1 = true;
+ } else {
+ EList<InterfaceItemInstance> _peers_3 = pi_1.getPeers();
+ int _size_2 = _peers_3.size();
+ boolean _operator_greaterThan_1 = ComparableExtensions.<Integer>operator_greaterThan(((Integer)_size_2), ((Integer)1));
+ _operator_or_1 = BooleanExtensions.operator_or((pi_1 instanceof ServiceImplInstance), _operator_greaterThan_1);
+ }
+ if (_operator_or_1) {
+ {
+ EList<InterfaceItemInstance> _peers_4 = pi_1.getPeers();
+ boolean hasAnyElements_1 = false;
+ for(final InterfaceItemInstance peer_1 : _peers_4) {
+ if (!hasAnyElements_1) {
+ hasAnyElements_1 = true;
+ } else {
+ _builder.appendImmediate(",", " ");
+ }
+ _builder.append("\t\t");
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("addr_item_");
+ String _path_6 = pi_1.getPath();
+ String _pathName_4 = this.roomExt.getPathName(_path_6);
+ _builder.append(_pathName_4, " ");
+ _builder.append("_");
+ EList<InterfaceItemInstance> _peers_5 = pi_1.getPeers();
+ int _indexOf_5 = _peers_5.indexOf(peer_1);
+ _builder.append(_indexOf_5, " ");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ } else {
+ _builder.append("\t\t");
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("addr_item_");
+ String _path_7 = pi_1.getPath();
+ String _pathName_5 = this.roomExt.getPathName(_path_7);
+ _builder.append(_pathName_5, " ");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("\t\t");
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ }
+ }
+ _builder.append("\t\t");
+ _builder.append("\t");
+ _builder.append("},");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("\t");
+ _builder.append("// peer interface item addresses");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("\t");
+ _builder.append("new Address[][] {{addr_item_SystemPort_");
+ EList<ActorInstance> _allContainedInstances_7 = comp.getAllContainedInstances();
+ int _indexOf_6 = _allContainedInstances_7.indexOf(ai_2);
+ _builder.append(_indexOf_6, " ");
+ _builder.append("}");
+ {
+ EList<InterfaceItemInstance> _orderedIfItemInstances_3 = ai_2.getOrderedIfItemInstances();
+ boolean _isEmpty_1 = _orderedIfItemInstances_3.isEmpty();
+ boolean _operator_not_1 = BooleanExtensions.operator_not(_isEmpty_1);
+ if (_operator_not_1) {
+ _builder.append(",");
+ }
+ }
+ _builder.newLineIfNotEmpty();
+ {
+ EList<InterfaceItemInstance> _orderedIfItemInstances_4 = ai_2.getOrderedIfItemInstances();
+ boolean hasAnyElements_2 = false;
+ for(final InterfaceItemInstance pi_2 : _orderedIfItemInstances_4) {
+ if (!hasAnyElements_2) {
+ hasAnyElements_2 = true;
+ } else {
+ _builder.appendImmediate(",", " ");
+ }
+ _builder.append("\t\t");
+ _builder.append("\t\t");
+ _builder.append("{");
+ _builder.newLine();
+ {
+ boolean _operator_and = false;
+ boolean _operator_not_2 = BooleanExtensions.operator_not((pi_2 instanceof ServiceImplInstance));
+ if (!_operator_not_2) {
+ _operator_and = false;
+ } else {
+ EList<InterfaceItemInstance> _peers_6 = pi_2.getPeers();
+ boolean _isEmpty_2 = _peers_6.isEmpty();
+ _operator_and = BooleanExtensions.operator_and(_operator_not_2, _isEmpty_2);
+ }
+ if (_operator_and) {
+ _builder.append("\t\t");
+ _builder.append("\t\t");
+ _builder.append("\t");
+ _builder.append("null");
+ _builder.newLine();
+ } else {
+ {
+ EList<InterfaceItemInstance> _peers_7 = pi_2.getPeers();
+ boolean hasAnyElements_3 = false;
+ for(final InterfaceItemInstance pp : _peers_7) {
+ if (!hasAnyElements_3) {
+ hasAnyElements_3 = true;
+ } else {
+ _builder.appendImmediate(",", " ");
+ }
+ {
+ boolean _operator_or_2 = false;
+ if ((pp instanceof ServiceImplInstance)) {
+ _operator_or_2 = true;
+ } else {
+ EList<InterfaceItemInstance> _peers_8 = pp.getPeers();
+ int _size_3 = _peers_8.size();
+ boolean _operator_greaterThan_2 = ComparableExtensions.<Integer>operator_greaterThan(((Integer)_size_3), ((Integer)1));
+ _operator_or_2 = BooleanExtensions.operator_or((pp instanceof ServiceImplInstance), _operator_greaterThan_2);
+ }
+ if (_operator_or_2) {
+ _builder.append("\t\t");
+ _builder.append("\t\t");
+ _builder.append("\t");
+ _builder.append("addr_item_");
+ String _path_8 = pp.getPath();
+ String _pathName_6 = this.roomExt.getPathName(_path_8);
+ _builder.append(_pathName_6, " ");
+ _builder.append("_");
+ EList<InterfaceItemInstance> _peers_9 = pp.getPeers();
+ int _indexOf_7 = _peers_9.indexOf(pi_2);
+ _builder.append(_indexOf_7, " ");
+ _builder.newLineIfNotEmpty();
+ } else {
+ _builder.append("\t\t");
+ _builder.append("\t\t");
+ _builder.append("\t");
+ _builder.append("addr_item_");
+ String _path_9 = pp.getPath();
+ String _pathName_7 = this.roomExt.getPathName(_path_9);
+ _builder.append(_pathName_7, " ");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ }
+ }
+ }
+ }
+ _builder.append("\t\t");
+ _builder.append("\t\t");
+ _builder.append("}");
+ _builder.newLine();
+ }
+ }
+ _builder.append("\t\t");
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("); ");
+ _builder.newLine();
+ }
+ }
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("// create the subsystem system port\t");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("RTSystemPort = new RTSystemServicesProtocolConjPortRepl(this, \"RTSystemPort\",");
+ _builder.newLine();
+ _builder.append("\t\t\t\t");
+ _builder.append("0, //local ID");
+ _builder.newLine();
+ _builder.append("\t\t\t\t");
+ _builder.append("// own addresses");
+ _builder.newLine();
+ _builder.append("\t\t\t\t");
+ _builder.append("new Address[]{");
+ _builder.newLine();
+ {
+ EList<ActorInstance> _allContainedInstances_8 = comp.getAllContainedInstances();
+ boolean hasAnyElements_4 = false;
+ for(final ActorInstance ai_3 : _allContainedInstances_8) {
+ if (!hasAnyElements_4) {
+ hasAnyElements_4 = true;
+ } else {
+ _builder.appendImmediate(",", " ");
+ }
+ _builder.append("\t\t\t\t\t");
+ _builder.append("addr_item_SystemPort_");
+ EList<ActorInstance> _allContainedInstances_9 = comp.getAllContainedInstances();
+ int _indexOf_8 = _allContainedInstances_9.indexOf(ai_3);
+ _builder.append(_indexOf_8, " ");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("\t\t\t\t");
+ _builder.append("},");
+ _builder.newLine();
+ _builder.append("\t\t\t\t");
+ _builder.append("// peer addresses");
+ _builder.newLine();
+ _builder.append("\t\t\t\t");
+ _builder.append("new Address[]{");
+ _builder.newLine();
+ {
+ EList<ActorInstance> _allContainedInstances_10 = comp.getAllContainedInstances();
+ boolean hasAnyElements_5 = false;
+ for(final ActorInstance ai_4 : _allContainedInstances_10) {
+ if (!hasAnyElements_5) {
+ hasAnyElements_5 = true;
+ } else {
+ _builder.appendImmediate(",", " ");
+ }
+ _builder.append("\t\t\t\t\t");
+ _builder.append("addr_item_");
+ String _path_10 = ai_4.getPath();
+ String _pathName_8 = this.roomExt.getPathName(_path_10);
+ _builder.append(_pathName_8, " ");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("\t\t\t\t");
+ _builder.append("});");
+ _builder.newLine();
+ _builder.append("\t\t\t\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("};");
+ _builder.newLine();
+ return _builder;
+ }
+}
diff --git a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/SubSystemRunnerGen.java b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/SubSystemRunnerGen.java
index 023e9118c..d7cecf26f 100644
--- a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/SubSystemRunnerGen.java
+++ b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/SubSystemRunnerGen.java
@@ -1,152 +1,152 @@
-package org.eclipse.etrice.generator.java.gen;
-
-import com.google.inject.Inject;
-import com.google.inject.Singleton;
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.etrice.core.room.SubSystemClass;
-import org.eclipse.etrice.generator.etricegen.Root;
-import org.eclipse.etrice.generator.etricegen.SubSystemInstance;
-import org.eclipse.etrice.generator.extensions.RoomExtensions;
-import org.eclipse.xtext.generator.JavaIoFileSystemAccess;
-import org.eclipse.xtext.xbase.lib.StringExtensions;
-import org.eclipse.xtext.xtend2.lib.StringConcatenation;
-
-@SuppressWarnings("all")
-@Singleton
-public class SubSystemRunnerGen {
- @Inject
- private JavaIoFileSystemAccess fileAccess;
-
- @Inject
- private RoomExtensions roomExt;
-
- public void doGenerate(final Root root) {
- EList<SubSystemInstance> _subSystemInstances = root.getSubSystemInstances();
- for (final SubSystemInstance sc : _subSystemInstances) {
- {
- SubSystemClass _subSystemClass = sc.getSubSystemClass();
- String _generationTargetPath = this.roomExt.getGenerationTargetPath(_subSystemClass);
- SubSystemClass _subSystemClass_1 = sc.getSubSystemClass();
- String _path = this.roomExt.getPath(_subSystemClass_1);
- String _operator_plus = StringExtensions.operator_plus(_generationTargetPath, _path);
- this.fileAccess.setOutputPath(_operator_plus);
- String _name = sc.getName();
- String _operator_plus_1 = StringExtensions.operator_plus(_name, "Runner.java");
- SubSystemClass _subSystemClass_2 = sc.getSubSystemClass();
- StringConcatenation _generate = this.generate(root, sc, _subSystemClass_2);
- this.fileAccess.generateFile(_operator_plus_1, _generate);
- }
- }
- }
-
- public StringConcatenation generate(final Root root, final SubSystemInstance ssc, final SubSystemClass cc) {
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("/**");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("* @author generated by eTrice");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("*");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("* this class contains the main function running component ");
- String _name = ssc.getName();
- _builder.append(_name, " ");
- _builder.newLineIfNotEmpty();
- _builder.append(" ");
- _builder.append("* it instantiates ");
- String _name_1 = ssc.getName();
- _builder.append(_name_1, " ");
- _builder.append(" and starts and ends the lifecycle");
- _builder.newLineIfNotEmpty();
- _builder.append(" ");
- _builder.append("*/");
- _builder.newLine();
- _builder.newLine();
- _builder.append("package ");
- String _package = this.roomExt.getPackage(cc);
- _builder.append(_package, "");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("import org.eclipse.etrice.runtime.java.modelbase.SubSystemRunnerBase;");
- _builder.newLine();
- _builder.newLine();
- _builder.append("class ");
- String _name_2 = ssc.getName();
- String _operator_plus = StringExtensions.operator_plus(_name_2, "Runner");
- _builder.append(_operator_plus, "");
- _builder.append(" extends SubSystemRunnerBase {");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("\t");
- _builder.append("static ");
- String _name_3 = ssc.getName();
- _builder.append(_name_3, " ");
- _builder.append(" main_component = new ");
- String _name_4 = ssc.getName();
- _builder.append(_name_4, " ");
- _builder.append("(null, \"");
- String _name_5 = ssc.getName();
- _builder.append(_name_5, " ");
- _builder.append("\");");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("\t");
- _builder.append("/**");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("* main function");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("* creates component and starts and stops the lifecycle");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("*/");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("public static void main(String[] args) {");
- _builder.newLine();
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("System.out.println(\"*** T H E B E G I N ***\");");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("main_component.init(); // lifecycle init");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("main_component.start(); // lifecycle start");
- _builder.newLine();
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("// application runs until quit ");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("waitForQuit();");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("// end the lifecycle");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("main_component.stop(); // lifecycle stop");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("main_component.destroy(); // lifecycle destroy");
- _builder.newLine();
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("System.out.println(\"*** T H E E N D ***\");");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("};");
- _builder.newLine();
- return _builder;
- }
-}
+package org.eclipse.etrice.generator.java.gen;
+
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.etrice.core.room.SubSystemClass;
+import org.eclipse.etrice.generator.etricegen.Root;
+import org.eclipse.etrice.generator.etricegen.SubSystemInstance;
+import org.eclipse.etrice.generator.extensions.RoomExtensions;
+import org.eclipse.xtext.generator.JavaIoFileSystemAccess;
+import org.eclipse.xtext.xbase.lib.StringExtensions;
+import org.eclipse.xtext.xtend2.lib.StringConcatenation;
+
+@SuppressWarnings("all")
+@Singleton
+public class SubSystemRunnerGen {
+ @Inject
+ private JavaIoFileSystemAccess fileAccess;
+
+ @Inject
+ private RoomExtensions roomExt;
+
+ public void doGenerate(final Root root) {
+ EList<SubSystemInstance> _subSystemInstances = root.getSubSystemInstances();
+ for (final SubSystemInstance sc : _subSystemInstances) {
+ {
+ SubSystemClass _subSystemClass = sc.getSubSystemClass();
+ String _generationTargetPath = this.roomExt.getGenerationTargetPath(_subSystemClass);
+ SubSystemClass _subSystemClass_1 = sc.getSubSystemClass();
+ String _path = this.roomExt.getPath(_subSystemClass_1);
+ String _operator_plus = StringExtensions.operator_plus(_generationTargetPath, _path);
+ this.fileAccess.setOutputPath(_operator_plus);
+ String _name = sc.getName();
+ String _operator_plus_1 = StringExtensions.operator_plus(_name, "Runner.java");
+ SubSystemClass _subSystemClass_2 = sc.getSubSystemClass();
+ StringConcatenation _generate = this.generate(root, sc, _subSystemClass_2);
+ this.fileAccess.generateFile(_operator_plus_1, _generate);
+ }
+ }
+ }
+
+ public StringConcatenation generate(final Root root, final SubSystemInstance ssc, final SubSystemClass cc) {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("/**");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* @author generated by eTrice");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("*");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* this class contains the main function running component ");
+ String _name = ssc.getName();
+ _builder.append(_name, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append(" ");
+ _builder.append("* it instantiates ");
+ String _name_1 = ssc.getName();
+ _builder.append(_name_1, " ");
+ _builder.append(" and starts and ends the lifecycle");
+ _builder.newLineIfNotEmpty();
+ _builder.append(" ");
+ _builder.append("*/");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("package ");
+ String _package = this.roomExt.getPackage(cc);
+ _builder.append(_package, "");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("import org.eclipse.etrice.runtime.java.modelbase.SubSystemRunnerBase;");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("class ");
+ String _name_2 = ssc.getName();
+ String _operator_plus = StringExtensions.operator_plus(_name_2, "Runner");
+ _builder.append(_operator_plus, "");
+ _builder.append(" extends SubSystemRunnerBase {");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("static ");
+ String _name_3 = ssc.getName();
+ _builder.append(_name_3, " ");
+ _builder.append(" main_component = new ");
+ String _name_4 = ssc.getName();
+ _builder.append(_name_4, " ");
+ _builder.append("(null, \"");
+ String _name_5 = ssc.getName();
+ _builder.append(_name_5, " ");
+ _builder.append("\");");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("/**");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* main function");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* creates component and starts and stops the lifecycle");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("*/");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("public static void main(String[] args) {");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("System.out.println(\"*** T H E B E G I N ***\");");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("main_component.init(); // lifecycle init");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("main_component.start(); // lifecycle start");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("// application runs until quit ");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("waitForQuit();");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("// end the lifecycle");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("main_component.stop(); // lifecycle stop");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("main_component.destroy(); // lifecycle destroy");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("System.out.println(\"*** T H E E N D ***\");");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("};");
+ _builder.newLine();
+ return _builder;
+ }
+}
diff --git a/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/extensions/PrepareFileSystem.java b/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/extensions/PrepareFileSystem.java
index 93397251d..9f39b42d2 100644
--- a/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/extensions/PrepareFileSystem.java
+++ b/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/extensions/PrepareFileSystem.java
@@ -1,85 +1,85 @@
-package org.eclipse.etrice.generator.extensions;
-
-import com.google.inject.Inject;
-import com.google.inject.Singleton;
-import java.io.File;
-import java.util.HashSet;
-import java.util.Set;
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.etrice.core.room.RoomModel;
-import org.eclipse.etrice.generator.base.ILogger;
-import org.eclipse.etrice.generator.etricegen.Root;
-import org.eclipse.etrice.generator.extensions.RoomExtensions;
-import org.eclipse.xtext.generator.JavaIoFileSystemAccess;
-import org.eclipse.xtext.xbase.lib.StringExtensions;
-import org.eclipse.xtext.xtend2.lib.StringConcatenation;
-
-@SuppressWarnings("all")
-@Singleton
-public class PrepareFileSystem {
- @Inject
- private RoomExtensions roomExt;
-
- @Inject
- private JavaIoFileSystemAccess fileAccess;
-
- @Inject
- private ILogger logger;
-
- public void prepare(final Resource resource) {
- HashSet<String> _hashSet = new HashSet<String>();
- Set<String> pathes = _hashSet;
- EList<EObject> _contents = resource.getContents();
- for (final EObject e : _contents) {
- if ((e instanceof Root)) {
- EList<RoomModel> _usedRoomModels = ((Root) e).getUsedRoomModels();
- for (final RoomModel mdl : _usedRoomModels) {
- String _generationTargetPath = this.roomExt.getGenerationTargetPath(mdl);
- pathes.add(_generationTargetPath);
- }
- }
- }
- for (final String path : pathes) {
- {
- String _operator_plus = StringExtensions.operator_plus("clearing ", path);
- this.logger.logInfo(_operator_plus);
- File _file = new File(path);
- File f = _file;
- this.eraseContents(f);
- this.fileAccess.setOutputPath(path);
- StringConcatenation _readmeText = this.readmeText();
- this.fileAccess.generateFile("readme.txt", _readmeText);
- }
- }
- }
-
- public void eraseContents(final File f) {
- boolean _isDirectory = f.isDirectory();
- if (_isDirectory) {
- {
- File[] _listFiles = f.listFiles();
- File[] children = _listFiles;
- for (final File child : children) {
- {
- this.eraseContents(child);
- child.delete();
- }
- }
- }
- }
- }
-
- public StringConcatenation readmeText() {
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("This directory is an eTrice code generation target.");
- _builder.newLine();
- _builder.append("It will be erased every time the generator is executed.");
- _builder.newLine();
- _builder.newLine();
- _builder.append("DO NOT PLACE OTHER FILES HERE!");
- _builder.newLine();
- return _builder;
- }
-}
+package org.eclipse.etrice.generator.extensions;
+
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+import java.io.File;
+import java.util.HashSet;
+import java.util.Set;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.etrice.core.room.RoomModel;
+import org.eclipse.etrice.generator.base.ILogger;
+import org.eclipse.etrice.generator.etricegen.Root;
+import org.eclipse.etrice.generator.extensions.RoomExtensions;
+import org.eclipse.xtext.generator.JavaIoFileSystemAccess;
+import org.eclipse.xtext.xbase.lib.StringExtensions;
+import org.eclipse.xtext.xtend2.lib.StringConcatenation;
+
+@SuppressWarnings("all")
+@Singleton
+public class PrepareFileSystem {
+ @Inject
+ private RoomExtensions roomExt;
+
+ @Inject
+ private JavaIoFileSystemAccess fileAccess;
+
+ @Inject
+ private ILogger logger;
+
+ public void prepare(final Resource resource) {
+ HashSet<String> _hashSet = new HashSet<String>();
+ Set<String> pathes = _hashSet;
+ EList<EObject> _contents = resource.getContents();
+ for (final EObject e : _contents) {
+ if ((e instanceof Root)) {
+ EList<RoomModel> _usedRoomModels = ((Root) e).getUsedRoomModels();
+ for (final RoomModel mdl : _usedRoomModels) {
+ String _generationTargetPath = this.roomExt.getGenerationTargetPath(mdl);
+ pathes.add(_generationTargetPath);
+ }
+ }
+ }
+ for (final String path : pathes) {
+ {
+ String _operator_plus = StringExtensions.operator_plus("clearing ", path);
+ this.logger.logInfo(_operator_plus);
+ File _file = new File(path);
+ File f = _file;
+ this.eraseContents(f);
+ this.fileAccess.setOutputPath(path);
+ StringConcatenation _readmeText = this.readmeText();
+ this.fileAccess.generateFile("readme.txt", _readmeText);
+ }
+ }
+ }
+
+ public void eraseContents(final File f) {
+ boolean _isDirectory = f.isDirectory();
+ if (_isDirectory) {
+ {
+ File[] _listFiles = f.listFiles();
+ File[] children = _listFiles;
+ for (final File child : children) {
+ {
+ this.eraseContents(child);
+ child.delete();
+ }
+ }
+ }
+ }
+ }
+
+ public StringConcatenation readmeText() {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("This directory is an eTrice code generation target.");
+ _builder.newLine();
+ _builder.append("It will be erased every time the generator is executed.");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("DO NOT PLACE OTHER FILES HERE!");
+ _builder.newLine();
+ return _builder;
+ }
+}
diff --git a/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/extensions/RoomExtensions.java b/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/extensions/RoomExtensions.java
index d75313241..d9fba0a08 100644
--- a/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/extensions/RoomExtensions.java
+++ b/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/extensions/RoomExtensions.java
@@ -1,780 +1,780 @@
-package org.eclipse.etrice.generator.extensions;
-
-import com.google.inject.Inject;
-import com.google.inject.Singleton;
-import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.etrice.core.room.ActorClass;
-import org.eclipse.etrice.core.room.BaseState;
-import org.eclipse.etrice.core.room.DetailCode;
-import org.eclipse.etrice.core.room.ExternalPort;
-import org.eclipse.etrice.core.room.Guard;
-import org.eclipse.etrice.core.room.InitialTransition;
-import org.eclipse.etrice.core.room.Message;
-import org.eclipse.etrice.core.room.MessageHandler;
-import org.eclipse.etrice.core.room.Port;
-import org.eclipse.etrice.core.room.PortClass;
-import org.eclipse.etrice.core.room.ProtocolClass;
-import org.eclipse.etrice.core.room.RefableType;
-import org.eclipse.etrice.core.room.RefinedState;
-import org.eclipse.etrice.core.room.RoomClass;
-import org.eclipse.etrice.core.room.RoomModel;
-import org.eclipse.etrice.core.room.SAPRef;
-import org.eclipse.etrice.core.room.SPPRef;
-import org.eclipse.etrice.core.room.ServiceImplementation;
-import org.eclipse.etrice.core.room.StandardOperation;
-import org.eclipse.etrice.core.room.State;
-import org.eclipse.etrice.core.room.StateGraph;
-import org.eclipse.etrice.core.room.StateMachine;
-import org.eclipse.etrice.core.room.Transition;
-import org.eclipse.etrice.core.room.Trigger;
-import org.eclipse.etrice.core.room.TriggeredTransition;
-import org.eclipse.etrice.core.room.VarDecl;
-import org.eclipse.etrice.generator.etricegen.ActiveTrigger;
-import org.eclipse.etrice.generator.etricegen.ExpandedActorClass;
-import org.eclipse.etrice.generator.etricegen.TransitionChain;
-import org.eclipse.etrice.generator.extensions.RoomNameProv;
-import org.eclipse.xtext.xbase.lib.BooleanExtensions;
-import org.eclipse.xtext.xbase.lib.ComparableExtensions;
-import org.eclipse.xtext.xbase.lib.Functions.Function1;
-import org.eclipse.xtext.xbase.lib.IntegerExtensions;
-import org.eclipse.xtext.xbase.lib.IterableExtensions;
-import org.eclipse.xtext.xbase.lib.ObjectExtensions;
-import org.eclipse.xtext.xbase.lib.StringExtensions;
-
-@SuppressWarnings("all")
-@Singleton
-public class RoomExtensions {
- @Inject
- private RoomNameProv nameProvider;
-
- public <T extends Object> List<T> union(final List<T> l1, final List<T> l2) {
- ArrayList<T> _arrayList = new ArrayList<T>();
- ArrayList<T> ret = _arrayList;
- ret.addAll(l1);
- ret.addAll(l2);
- return ret;
- }
-
- public List<Port> punion(final List<Port> in1, final List<ExternalPort> in2) {
- ArrayList<Port> _arrayList = new ArrayList<Port>();
- ArrayList<Port> ret = _arrayList;
- for (final ExternalPort ele : in2) {
- Port _ifport = ele.getIfport();
- ret.add(_ifport);
- }
- ret.addAll(in1);
- return ret;
- }
-
- public String getGenerationPathSegment() {
- return "/src-gen/";
- }
-
- public String getModelPath(final EObject e) {
- Resource _eResource = e.eResource();
- Resource res = _eResource;
- boolean _operator_equals = ObjectExtensions.operator_equals(res, null);
- if (_operator_equals) {
- return "";
- } else {
- URI _uRI = res.getURI();
- String _fileString = _uRI.toFileString();
- return _fileString;
- }
- }
-
- public String getPackage(final RoomClass rc) {
- EObject _eContainer = rc.eContainer();
- String _name = ((RoomModel) _eContainer).getName();
- return _name;
- }
-
- public String getPathFromPackage(final String packageName) {
- String _replaceAll = packageName.replaceAll("\\.", "/");
- String _operator_plus = StringExtensions.operator_plus(_replaceAll, "/");
- return _operator_plus;
- }
-
- public String getPath(final RoomClass rc) {
- String _package = this.getPackage(rc);
- String _pathFromPackage = this.getPathFromPackage(_package);
- return _pathFromPackage;
- }
-
- public String getProjectPath(final EObject e) {
- Resource _eResource = e.eResource();
- Resource res = _eResource;
- boolean _operator_equals = ObjectExtensions.operator_equals(res, null);
- if (_operator_equals) {
- return "";
- } else {
- {
- File _file = new File("");
- File tmpf = _file;
- URI _uRI = res.getURI();
- String _fileString = _uRI.toFileString();
- File _file_1 = new File(_fileString);
- tmpf = _file_1;
- boolean _isFile = tmpf.isFile();
- boolean _operator_not = BooleanExtensions.operator_not(_isFile);
- if (_operator_not) {
- return "";
- }
- boolean isProject = false;
- Boolean _xdowhileexpression;
- do {
- {
- File _parentFile = tmpf.getParentFile();
- tmpf = _parentFile;
- String[] _list = tmpf.list();
- String[] contents = _list;
- for (final String f : contents) {
- boolean _equals = f.equals(".project");
- if (_equals) {
- isProject = true;
- }
- }
- }
- boolean _operator_and = false;
- boolean _operator_not_1 = BooleanExtensions.operator_not(isProject);
- if (!_operator_not_1) {
- _operator_and = false;
- } else {
- File _parentFile_1 = tmpf.getParentFile();
- boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_parentFile_1, null);
- _operator_and = BooleanExtensions.operator_and(_operator_not_1, _operator_notEquals);
- }
- _xdowhileexpression = _operator_and;
- } while(_xdowhileexpression);
- String _absolutePath = tmpf.getAbsolutePath();
- return _absolutePath;
- }
- }
- }
-
- public String getGenerationTargetPath(final EObject e) {
- String _projectPath = this.getProjectPath(e);
- String _generationPathSegment = this.getGenerationPathSegment();
- String _operator_plus = StringExtensions.operator_plus(_projectPath, _generationPathSegment);
- return _operator_plus;
- }
-
- public List<Port> getEndPorts(final ActorClass ac) {
- EList<Port> _intPorts = ac.getIntPorts();
- EList<ExternalPort> _extPorts = ac.getExtPorts();
- List<Port> _punion = this.punion(_intPorts, _extPorts);
- return _punion;
- }
-
- public String getPathName(final String path) {
- String _replaceAll = path.replaceAll("/", "_");
- return _replaceAll;
- }
-
- public String getPortClassName(final ProtocolClass p, final boolean conj) {
- String _name = p.getName();
- String ret = _name;
- if (conj) {
- String _operator_plus = StringExtensions.operator_plus(ret, "ConjPort");
- ret = _operator_plus;
- } else {
- String _operator_plus_1 = StringExtensions.operator_plus(ret, "Port");
- ret = _operator_plus_1;
- }
- return ret;
- }
-
- public String getPortClassName(final Port p) {
- ProtocolClass _protocol = p.getProtocol();
- boolean _isConjugated = p.isConjugated();
- String _portClassName = this.getPortClassName(_protocol, _isConjugated);
- String ret = _portClassName;
- boolean _isReplicated = p.isReplicated();
- if (_isReplicated) {
- String _operator_plus = StringExtensions.operator_plus(ret, "Repl");
- ret = _operator_plus;
- }
- return ret;
- }
-
- public String getPortClassName(final ExternalPort p) {
- Port _ifport = p.getIfport();
- String _portClassName = this.getPortClassName(_ifport);
- return _portClassName;
- }
-
- public String getPortClassName(final SAPRef sap) {
- ProtocolClass _protocol = sap.getProtocol();
- String _portClassName = this.getPortClassName(_protocol, true);
- return _portClassName;
- }
-
- public String getPortClassName(final ServiceImplementation svc) {
- SPPRef _spp = svc.getSpp();
- ProtocolClass _protocol = _spp.getProtocol();
- String _portClassName = this.getPortClassName(_protocol, false);
- String _operator_plus = StringExtensions.operator_plus(_portClassName, "Repl");
- return _operator_plus;
- }
-
- public List<Message> getAllIncomingMessages(final ProtocolClass pc) {
- ProtocolClass _base = pc.getBase();
- boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_base, null);
- if (_operator_notEquals) {
- ProtocolClass _base_1 = pc.getBase();
- List<Message> _allIncomingMessages = this.getAllIncomingMessages(_base_1);
- EList<Message> _incomingMessages = pc.getIncomingMessages();
- List<Message> _union = this.<Message>union(_allIncomingMessages, _incomingMessages);
- return _union;
- } else {
- EList<Message> _incomingMessages_1 = pc.getIncomingMessages();
- return _incomingMessages_1;
- }
- }
-
- public List<Message> getAllOutgoingMessages(final ProtocolClass pc) {
- EList<Message> _xifexpression = null;
- ProtocolClass _base = pc.getBase();
- boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_base, null);
- if (_operator_notEquals) {
- ProtocolClass _base_1 = pc.getBase();
- List<Message> _allOutgoingMessages = this.getAllOutgoingMessages(_base_1);
- EList<Message> _outgoingMessages = pc.getOutgoingMessages();
- List<Message> _union = this.<Message>union(_allOutgoingMessages, _outgoingMessages);
- return _union;
- } else {
- EList<Message> _outgoingMessages_1 = pc.getOutgoingMessages();
- _xifexpression = _outgoingMessages_1;
- }
- return _xifexpression;
- }
-
- public List<Message> getIncoming(final ProtocolClass pc, final boolean conj) {
- if (conj) {
- List<Message> _allOutgoingMessages = this.getAllOutgoingMessages(pc);
- return _allOutgoingMessages;
- } else {
- List<Message> _allIncomingMessages = this.getAllIncomingMessages(pc);
- return _allIncomingMessages;
- }
- }
-
- public List<Message> getOutgoing(final ProtocolClass pc, final boolean conj) {
- if (conj) {
- List<Message> _allIncomingMessages = this.getAllIncomingMessages(pc);
- return _allIncomingMessages;
- } else {
- List<Message> _allOutgoingMessages = this.getAllOutgoingMessages(pc);
- return _allOutgoingMessages;
- }
- }
-
- public PortClass getPortClass(final ProtocolClass pc, final boolean conj) {
- if (conj) {
- PortClass _conjugate = pc.getConjugate();
- return _conjugate;
- } else {
- PortClass _regular = pc.getRegular();
- return _regular;
- }
- }
-
- public boolean handlesSend(final ProtocolClass pc, final boolean conj) {
- PortClass _portClass = this.getPortClass(pc, conj);
- boolean _operator_equals = ObjectExtensions.operator_equals(_portClass, null);
- if (_operator_equals) {
- return false;
- } else {
- PortClass _portClass_1 = this.getPortClass(pc, conj);
- EList<MessageHandler> _msgHandlers = _portClass_1.getMsgHandlers();
- for (final MessageHandler hdlr : _msgHandlers) {
- List<Message> _outgoing = this.getOutgoing(pc, conj);
- Message _msg = hdlr.getMsg();
- boolean _contains = _outgoing.contains(_msg);
- if (_contains) {
- return true;
- }
- }
- }
- return false;
- }
-
- public boolean handlesReceive(final ProtocolClass pc, final boolean conj) {
- PortClass _portClass = this.getPortClass(pc, conj);
- boolean _operator_equals = ObjectExtensions.operator_equals(_portClass, null);
- if (_operator_equals) {
- return false;
- } else {
- PortClass _portClass_1 = this.getPortClass(pc, conj);
- EList<MessageHandler> _msgHandlers = _portClass_1.getMsgHandlers();
- for (final MessageHandler hdlr : _msgHandlers) {
- List<Message> _incoming = this.getIncoming(pc, conj);
- Message _msg = hdlr.getMsg();
- boolean _contains = _incoming.contains(_msg);
- if (_contains) {
- return true;
- }
- }
- }
- return false;
- }
-
- public List<MessageHandler> getReceiveHandlers(final ProtocolClass pc, final boolean conj) {
- PortClass _portClass = this.getPortClass(pc, conj);
- boolean _operator_equals = ObjectExtensions.operator_equals(_portClass, null);
- if (_operator_equals) {
- ArrayList<MessageHandler> _arrayList = new ArrayList<MessageHandler>();
- return _arrayList;
- } else {
- {
- ArrayList<MessageHandler> _arrayList_1 = new ArrayList<MessageHandler>();
- ArrayList<MessageHandler> res = _arrayList_1;
- PortClass _portClass_1 = this.getPortClass(pc, conj);
- EList<MessageHandler> _msgHandlers = _portClass_1.getMsgHandlers();
- for (final MessageHandler hdlr : _msgHandlers) {
- List<Message> _incoming = this.getIncoming(pc, conj);
- Message _msg = hdlr.getMsg();
- boolean _contains = _incoming.contains(_msg);
- if (_contains) {
- res.add(hdlr);
- }
- }
- return res;
- }
- }
- }
-
- public List<MessageHandler> getSendHandlers(final ProtocolClass pc, final boolean conj) {
- PortClass _portClass = this.getPortClass(pc, conj);
- boolean _operator_equals = ObjectExtensions.operator_equals(_portClass, null);
- if (_operator_equals) {
- ArrayList<MessageHandler> _arrayList = new ArrayList<MessageHandler>();
- return _arrayList;
- } else {
- {
- ArrayList<MessageHandler> _arrayList_1 = new ArrayList<MessageHandler>();
- ArrayList<MessageHandler> res = _arrayList_1;
- PortClass _portClass_1 = this.getPortClass(pc, conj);
- EList<MessageHandler> _msgHandlers = _portClass_1.getMsgHandlers();
- for (final MessageHandler hdlr : _msgHandlers) {
- List<Message> _outgoing = this.getOutgoing(pc, conj);
- Message _msg = hdlr.getMsg();
- boolean _contains = _outgoing.contains(_msg);
- if (_contains) {
- res.add(hdlr);
- }
- }
- return res;
- }
- }
- }
-
- public MessageHandler getSendHandler(final Message m, final boolean conj) {
- EObject _eContainer = m.eContainer();
- List<MessageHandler> _sendHandlers = this.getSendHandlers(((ProtocolClass) _eContainer), conj);
- final Function1<MessageHandler,Boolean> _function = new Function1<MessageHandler,Boolean>() {
- public Boolean apply(final MessageHandler e) {
- Message _msg = e.getMsg();
- boolean _operator_equals = ObjectExtensions.operator_equals(_msg, m);
- return ((Boolean)_operator_equals);
- }
- };
- MessageHandler _findFirst = IterableExtensions.<MessageHandler>findFirst(_sendHandlers, _function);
- return _findFirst;
- }
-
- public boolean isIncoming(final Message m) {
- EObject _eContainer = m.eContainer();
- List<Message> _allIncomingMessages = this.getAllIncomingMessages(((ProtocolClass) _eContainer));
- boolean _contains = _allIncomingMessages.contains(m);
- return _contains;
- }
-
- public String getCodeName(final Message m) {
- boolean _isIncoming = this.isIncoming(m);
- if (_isIncoming) {
- String _name = m.getName();
- String _operator_plus = StringExtensions.operator_plus("IN_", _name);
- return _operator_plus;
- } else {
- String _name_1 = m.getName();
- String _operator_plus_1 = StringExtensions.operator_plus("OUT_", _name_1);
- return _operator_plus_1;
- }
- }
-
- public boolean isLeaf(final State s) {
- StateGraph _subgraph = s.getSubgraph();
- boolean _operator_equals = ObjectExtensions.operator_equals(_subgraph, null);
- return _operator_equals;
- }
-
- public List<State> getLeafStateList(final StateGraph sg) {
- ArrayList<State> _arrayList = new ArrayList<State>();
- ArrayList<State> res = _arrayList;
- EList<State> _states = sg.getStates();
- for (final State s : _states) {
- List<State> _leafStateList = this.getLeafStateList(s);
- res.addAll(_leafStateList);
- }
- return res;
- }
-
- public List<State> getLeafStateList(final State s) {
- boolean _isLeaf = this.isLeaf(s);
- if (_isLeaf) {
- {
- ArrayList<State> _arrayList = new ArrayList<State>();
- ArrayList<State> res = _arrayList;
- res.add(s);
- return res;
- }
- } else {
- StateGraph _subgraph = s.getSubgraph();
- List<State> _leafStateList = this.getLeafStateList(_subgraph);
- return _leafStateList;
- }
- }
-
- public List<State> getStateList(final StateGraph sg) {
- ArrayList<State> _arrayList = new ArrayList<State>();
- ArrayList<State> ret = _arrayList;
- EList<State> _states = sg.getStates();
- for (final State e : _states) {
- {
- ret.add(e);
- StateGraph _subgraph = e.getSubgraph();
- StateGraph tmp = _subgraph;
- boolean _operator_notEquals = ObjectExtensions.operator_notEquals(tmp, null);
- if (_operator_notEquals) {
- StateGraph _subgraph_1 = e.getSubgraph();
- List<State> _stateList = this.getStateList(_subgraph_1);
- ret.addAll(_stateList);
- }
- }
- }
- return ret;
- }
-
- public List<State> getBaseStateList(final StateGraph sg) {
- ArrayList<State> _arrayList = new ArrayList<State>();
- ArrayList<State> ret = _arrayList;
- List<State> _stateList = this.getStateList(sg);
- for (final State e : _stateList) {
- if ((e instanceof BaseState)) {
- ret.add(e);
- }
- }
- return ret;
- }
-
- public List<State> getAllBaseStates(final ActorClass ac) {
- List<State> _xifexpression = null;
- ActorClass _base = ac.getBase();
- boolean _operator_equals = ObjectExtensions.operator_equals(_base, null);
- if (_operator_equals) {
- StateMachine _stateMachine = ac.getStateMachine();
- List<State> _baseStateList = this.getBaseStateList(_stateMachine);
- return _baseStateList;
- } else {
- ActorClass _base_1 = ac.getBase();
- List<State> _allBaseStates = this.getAllBaseStates(_base_1);
- StateMachine _stateMachine_1 = ac.getStateMachine();
- List<State> _baseStateList_1 = this.getBaseStateList(_stateMachine_1);
- List<State> _union = this.<State>union(_allBaseStates, _baseStateList_1);
- _xifexpression = _union;
- }
- return _xifexpression;
- }
-
- public boolean overridesStop(final ActorClass ac) {
- boolean _operator_or = false;
- EList<StandardOperation> _operations = ac.getOperations();
- final Function1<StandardOperation,Boolean> _function = new Function1<StandardOperation,Boolean>() {
- public Boolean apply(final StandardOperation e) {
- boolean _operator_and = false;
- boolean _operator_and_1 = false;
- String _name = e.getName();
- boolean _operator_equals = ObjectExtensions.operator_equals(_name, "stop");
- if (!_operator_equals) {
- _operator_and_1 = false;
- } else {
- EList<VarDecl> _arguments = e.getArguments();
- boolean _isEmpty = _arguments.isEmpty();
- _operator_and_1 = BooleanExtensions.operator_and(_operator_equals, _isEmpty);
- }
- if (!_operator_and_1) {
- _operator_and = false;
- } else {
- RefableType _returntype = e.getReturntype();
- boolean _operator_equals_1 = ObjectExtensions.operator_equals(_returntype, null);
- _operator_and = BooleanExtensions.operator_and(_operator_and_1, _operator_equals_1);
- }
- return ((Boolean)_operator_and);
- }
- };
- boolean _exists = IterableExtensions.<StandardOperation>exists(_operations, _function);
- if (_exists) {
- _operator_or = true;
- } else {
- boolean _operator_and = false;
- ActorClass _base = ac.getBase();
- boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_base, null);
- if (!_operator_notEquals) {
- _operator_and = false;
- } else {
- ActorClass _base_1 = ac.getBase();
- boolean _overridesStop = this.overridesStop(_base_1);
- _operator_and = BooleanExtensions.operator_and(_operator_notEquals, _overridesStop);
- }
- _operator_or = BooleanExtensions.operator_or(_exists, _operator_and);
- }
- return _operator_or;
- }
-
- public int getNumberOfInheritedStates(final ActorClass ac) {
- ActorClass _base = ac.getBase();
- boolean _operator_equals = ObjectExtensions.operator_equals(_base, null);
- if (_operator_equals) {
- return 0;
- } else {
- ActorClass _base_1 = ac.getBase();
- StateMachine _stateMachine = _base_1.getStateMachine();
- List<State> _stateList = this.getStateList(_stateMachine);
- int _size = _stateList.size();
- ActorClass _base_2 = ac.getBase();
- int _numberOfInheritedStates = this.getNumberOfInheritedStates(_base_2);
- int _operator_plus = IntegerExtensions.operator_plus(((Integer)_size), ((Integer)_numberOfInheritedStates));
- return _operator_plus;
- }
- }
-
- public int getNumberOfInheritedBaseStates(final ActorClass ac) {
- ActorClass _base = ac.getBase();
- boolean _operator_equals = ObjectExtensions.operator_equals(_base, null);
- if (_operator_equals) {
- return 0;
- } else {
- ActorClass _base_1 = ac.getBase();
- StateMachine _stateMachine = _base_1.getStateMachine();
- List<State> _baseStateList = this.getBaseStateList(_stateMachine);
- int _size = _baseStateList.size();
- ActorClass _base_2 = ac.getBase();
- int _numberOfInheritedBaseStates = this.getNumberOfInheritedBaseStates(_base_2);
- int _operator_plus = IntegerExtensions.operator_plus(((Integer)_size), ((Integer)_numberOfInheritedBaseStates));
- return _operator_plus;
- }
- }
-
- public String getStateId(final State s) {
- String _genStateId = RoomNameProv.getGenStateId(s);
- return _genStateId;
- }
-
- public String getStatePathName(final State s) {
- String _genStatePathName = RoomNameProv.getGenStatePathName(s);
- return _genStatePathName;
- }
-
- public String getChainId(final TransitionChain t) {
- String _genChainId = RoomNameProv.getGenChainId(t);
- return _genChainId;
- }
-
- public boolean hasGuard(final Trigger tr) {
- boolean _operator_and = false;
- boolean _operator_and_1 = false;
- Guard _guard = tr.getGuard();
- boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_guard, null);
- if (!_operator_notEquals) {
- _operator_and_1 = false;
- } else {
- Guard _guard_1 = tr.getGuard();
- DetailCode _guard_2 = _guard_1.getGuard();
- boolean _operator_notEquals_1 = ObjectExtensions.operator_notEquals(_guard_2, null);
- _operator_and_1 = BooleanExtensions.operator_and(_operator_notEquals, _operator_notEquals_1);
- }
- if (!_operator_and_1) {
- _operator_and = false;
- } else {
- Guard _guard_3 = tr.getGuard();
- DetailCode _guard_4 = _guard_3.getGuard();
- EList<String> _commands = _guard_4.getCommands();
- int _size = _commands.size();
- boolean _operator_greaterThan = ComparableExtensions.<Integer>operator_greaterThan(((Integer)_size), ((Integer)0));
- _operator_and = BooleanExtensions.operator_and(_operator_and_1, _operator_greaterThan);
- }
- return _operator_and;
- }
-
- public boolean hasGuard(final ExpandedActorClass ac, final ActiveTrigger at) {
- boolean hasGuard = false;
- EList<TriggeredTransition> _transitions = at.getTransitions();
- for (final TriggeredTransition t : _transitions) {
- EList<Trigger> _triggers = t.getTriggers();
- final Function1<Trigger,Boolean> _function = new Function1<Trigger,Boolean>() {
- public Boolean apply(final Trigger e) {
- boolean _operator_and = false;
- String _trigger = at.getTrigger();
- boolean _isMatching = ac.isMatching(e, _trigger);
- if (!_isMatching) {
- _operator_and = false;
- } else {
- boolean _hasGuard = RoomExtensions.this.hasGuard(e);
- _operator_and = BooleanExtensions.operator_and(_isMatching, _hasGuard);
- }
- return ((Boolean)_operator_and);
- }
- };
- boolean _exists = IterableExtensions.<Trigger>exists(_triggers, _function);
- if (_exists) {
- hasGuard = true;
- }
- }
- return hasGuard;
- }
-
- public boolean hasEntryCode(final State s) {
- boolean _operator_and = false;
- DetailCode _entryCode = s.getEntryCode();
- boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_entryCode, null);
- if (!_operator_notEquals) {
- _operator_and = false;
- } else {
- DetailCode _entryCode_1 = s.getEntryCode();
- EList<String> _commands = _entryCode_1.getCommands();
- int _size = _commands.size();
- boolean _operator_greaterThan = ComparableExtensions.<Integer>operator_greaterThan(((Integer)_size), ((Integer)0));
- _operator_and = BooleanExtensions.operator_and(_operator_notEquals, _operator_greaterThan);
- }
- return _operator_and;
- }
-
- public boolean hasExitCode(final State s) {
- boolean _operator_and = false;
- DetailCode _exitCode = s.getExitCode();
- boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_exitCode, null);
- if (!_operator_notEquals) {
- _operator_and = false;
- } else {
- DetailCode _exitCode_1 = s.getExitCode();
- EList<String> _commands = _exitCode_1.getCommands();
- int _size = _commands.size();
- boolean _operator_greaterThan = ComparableExtensions.<Integer>operator_greaterThan(((Integer)_size), ((Integer)0));
- _operator_and = BooleanExtensions.operator_and(_operator_notEquals, _operator_greaterThan);
- }
- return _operator_and;
- }
-
- public String getEntryCode(final ExpandedActorClass ac, final State s) {
- if ((s instanceof RefinedState)) {
- String _entryCodeOperationName = RoomNameProv.getEntryCodeOperationName(s);
- String _operator_plus = StringExtensions.operator_plus("super.", _entryCodeOperationName);
- String _operator_plus_1 = StringExtensions.operator_plus(_operator_plus, "();\n");
- DetailCode _entryCode = s.getEntryCode();
- String _code = ac.getCode(_entryCode);
- String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, _code);
- return _operator_plus_2;
- } else {
- DetailCode _entryCode_1 = s.getEntryCode();
- String _code_1 = ac.getCode(_entryCode_1);
- return _code_1;
- }
- }
-
- public String getExitCode(final ExpandedActorClass ac, final State s) {
- String _xifexpression = null;
- if ((s instanceof RefinedState)) {
- DetailCode _exitCode = s.getExitCode();
- String _code = ac.getCode(_exitCode);
- String _operator_plus = StringExtensions.operator_plus(_code, "super.");
- String _entryCodeOperationName = RoomNameProv.getEntryCodeOperationName(s);
- String _operator_plus_1 = StringExtensions.operator_plus(_operator_plus, _entryCodeOperationName);
- String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, "();\n");
- return _operator_plus_2;
- } else {
- DetailCode _exitCode_1 = s.getExitCode();
- String _code_1 = ac.getCode(_exitCode_1);
- _xifexpression = _code_1;
- }
- return _xifexpression;
- }
-
- public boolean hasActionCode(final Transition t) {
- boolean _operator_and = false;
- DetailCode _action = t.getAction();
- boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_action, null);
- if (!_operator_notEquals) {
- _operator_and = false;
- } else {
- DetailCode _action_1 = t.getAction();
- EList<String> _commands = _action_1.getCommands();
- int _size = _commands.size();
- boolean _operator_greaterThan = ComparableExtensions.<Integer>operator_greaterThan(((Integer)_size), ((Integer)0));
- _operator_and = BooleanExtensions.operator_and(_operator_notEquals, _operator_greaterThan);
- }
- return _operator_and;
- }
-
- public String getActionCode(final ExpandedActorClass ac, final Transition t) {
- DetailCode _action = t.getAction();
- String _code = ac.getCode(_action);
- return _code;
- }
-
- public String getContextId(final TransitionChain tc) {
- State _stateContext = tc.getStateContext();
- String _stateId = this.getStateId(_stateContext);
- return _stateId;
- }
-
- public Transition getInitTransition(final StateGraph sg) {
- EList<Transition> _transitions = sg.getTransitions();
- for (final Transition tr : _transitions) {
- if ((tr instanceof InitialTransition)) {
- return tr;
- }
- }
- return null;
- }
-
- public boolean hasInitTransition(final StateGraph sg) {
- EList<Transition> _transitions = sg.getTransitions();
- for (final Transition tr : _transitions) {
- if ((tr instanceof InitialTransition)) {
- return true;
- }
- }
- return false;
- }
-
- public List<Transition> getTransitionList(final State s) {
- boolean _isLeaf = this.isLeaf(s);
- if (_isLeaf) {
- ArrayList<Transition> _arrayList = new ArrayList<Transition>();
- return _arrayList;
- } else {
- StateGraph _subgraph = s.getSubgraph();
- List<Transition> _transitionList = this.getTransitionList(_subgraph);
- return _transitionList;
- }
- }
-
- public List<Transition> getTransitionList(final StateGraph sg) {
- EList<Transition> _transitions = sg.getTransitions();
- ArrayList<Transition> _arrayList = new ArrayList<Transition>(_transitions);
- ArrayList<Transition> res = _arrayList;
- EList<State> _states = sg.getStates();
- for (final State s : _states) {
- List<Transition> _transitionList = this.getTransitionList(s);
- res.addAll(_transitionList);
- }
- return res;
- }
-}
+package org.eclipse.etrice.generator.extensions;
+
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.etrice.core.room.ActorClass;
+import org.eclipse.etrice.core.room.BaseState;
+import org.eclipse.etrice.core.room.DetailCode;
+import org.eclipse.etrice.core.room.ExternalPort;
+import org.eclipse.etrice.core.room.Guard;
+import org.eclipse.etrice.core.room.InitialTransition;
+import org.eclipse.etrice.core.room.Message;
+import org.eclipse.etrice.core.room.MessageHandler;
+import org.eclipse.etrice.core.room.Port;
+import org.eclipse.etrice.core.room.PortClass;
+import org.eclipse.etrice.core.room.ProtocolClass;
+import org.eclipse.etrice.core.room.RefableType;
+import org.eclipse.etrice.core.room.RefinedState;
+import org.eclipse.etrice.core.room.RoomClass;
+import org.eclipse.etrice.core.room.RoomModel;
+import org.eclipse.etrice.core.room.SAPRef;
+import org.eclipse.etrice.core.room.SPPRef;
+import org.eclipse.etrice.core.room.ServiceImplementation;
+import org.eclipse.etrice.core.room.StandardOperation;
+import org.eclipse.etrice.core.room.State;
+import org.eclipse.etrice.core.room.StateGraph;
+import org.eclipse.etrice.core.room.StateMachine;
+import org.eclipse.etrice.core.room.Transition;
+import org.eclipse.etrice.core.room.Trigger;
+import org.eclipse.etrice.core.room.TriggeredTransition;
+import org.eclipse.etrice.core.room.VarDecl;
+import org.eclipse.etrice.generator.etricegen.ActiveTrigger;
+import org.eclipse.etrice.generator.etricegen.ExpandedActorClass;
+import org.eclipse.etrice.generator.etricegen.TransitionChain;
+import org.eclipse.etrice.generator.extensions.RoomNameProv;
+import org.eclipse.xtext.xbase.lib.BooleanExtensions;
+import org.eclipse.xtext.xbase.lib.ComparableExtensions;
+import org.eclipse.xtext.xbase.lib.Functions.Function1;
+import org.eclipse.xtext.xbase.lib.IntegerExtensions;
+import org.eclipse.xtext.xbase.lib.IterableExtensions;
+import org.eclipse.xtext.xbase.lib.ObjectExtensions;
+import org.eclipse.xtext.xbase.lib.StringExtensions;
+
+@SuppressWarnings("all")
+@Singleton
+public class RoomExtensions {
+ @Inject
+ private RoomNameProv nameProvider;
+
+ public <T extends Object> List<T> union(final List<T> l1, final List<T> l2) {
+ ArrayList<T> _arrayList = new ArrayList<T>();
+ ArrayList<T> ret = _arrayList;
+ ret.addAll(l1);
+ ret.addAll(l2);
+ return ret;
+ }
+
+ public List<Port> punion(final List<Port> in1, final List<ExternalPort> in2) {
+ ArrayList<Port> _arrayList = new ArrayList<Port>();
+ ArrayList<Port> ret = _arrayList;
+ for (final ExternalPort ele : in2) {
+ Port _ifport = ele.getIfport();
+ ret.add(_ifport);
+ }
+ ret.addAll(in1);
+ return ret;
+ }
+
+ public String getGenerationPathSegment() {
+ return "/src-gen/";
+ }
+
+ public String getModelPath(final EObject e) {
+ Resource _eResource = e.eResource();
+ Resource res = _eResource;
+ boolean _operator_equals = ObjectExtensions.operator_equals(res, null);
+ if (_operator_equals) {
+ return "";
+ } else {
+ URI _uRI = res.getURI();
+ String _fileString = _uRI.toFileString();
+ return _fileString;
+ }
+ }
+
+ public String getPackage(final RoomClass rc) {
+ EObject _eContainer = rc.eContainer();
+ String _name = ((RoomModel) _eContainer).getName();
+ return _name;
+ }
+
+ public String getPathFromPackage(final String packageName) {
+ String _replaceAll = packageName.replaceAll("\\.", "/");
+ String _operator_plus = StringExtensions.operator_plus(_replaceAll, "/");
+ return _operator_plus;
+ }
+
+ public String getPath(final RoomClass rc) {
+ String _package = this.getPackage(rc);
+ String _pathFromPackage = this.getPathFromPackage(_package);
+ return _pathFromPackage;
+ }
+
+ public String getProjectPath(final EObject e) {
+ Resource _eResource = e.eResource();
+ Resource res = _eResource;
+ boolean _operator_equals = ObjectExtensions.operator_equals(res, null);
+ if (_operator_equals) {
+ return "";
+ } else {
+ {
+ File _file = new File("");
+ File tmpf = _file;
+ URI _uRI = res.getURI();
+ String _fileString = _uRI.toFileString();
+ File _file_1 = new File(_fileString);
+ tmpf = _file_1;
+ boolean _isFile = tmpf.isFile();
+ boolean _operator_not = BooleanExtensions.operator_not(_isFile);
+ if (_operator_not) {
+ return "";
+ }
+ boolean isProject = false;
+ Boolean _xdowhileexpression;
+ do {
+ {
+ File _parentFile = tmpf.getParentFile();
+ tmpf = _parentFile;
+ String[] _list = tmpf.list();
+ String[] contents = _list;
+ for (final String f : contents) {
+ boolean _equals = f.equals(".project");
+ if (_equals) {
+ isProject = true;
+ }
+ }
+ }
+ boolean _operator_and = false;
+ boolean _operator_not_1 = BooleanExtensions.operator_not(isProject);
+ if (!_operator_not_1) {
+ _operator_and = false;
+ } else {
+ File _parentFile_1 = tmpf.getParentFile();
+ boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_parentFile_1, null);
+ _operator_and = BooleanExtensions.operator_and(_operator_not_1, _operator_notEquals);
+ }
+ _xdowhileexpression = _operator_and;
+ } while(_xdowhileexpression);
+ String _absolutePath = tmpf.getAbsolutePath();
+ return _absolutePath;
+ }
+ }
+ }
+
+ public String getGenerationTargetPath(final EObject e) {
+ String _projectPath = this.getProjectPath(e);
+ String _generationPathSegment = this.getGenerationPathSegment();
+ String _operator_plus = StringExtensions.operator_plus(_projectPath, _generationPathSegment);
+ return _operator_plus;
+ }
+
+ public List<Port> getEndPorts(final ActorClass ac) {
+ EList<Port> _intPorts = ac.getIntPorts();
+ EList<ExternalPort> _extPorts = ac.getExtPorts();
+ List<Port> _punion = this.punion(_intPorts, _extPorts);
+ return _punion;
+ }
+
+ public String getPathName(final String path) {
+ String _replaceAll = path.replaceAll("/", "_");
+ return _replaceAll;
+ }
+
+ public String getPortClassName(final ProtocolClass p, final boolean conj) {
+ String _name = p.getName();
+ String ret = _name;
+ if (conj) {
+ String _operator_plus = StringExtensions.operator_plus(ret, "ConjPort");
+ ret = _operator_plus;
+ } else {
+ String _operator_plus_1 = StringExtensions.operator_plus(ret, "Port");
+ ret = _operator_plus_1;
+ }
+ return ret;
+ }
+
+ public String getPortClassName(final Port p) {
+ ProtocolClass _protocol = p.getProtocol();
+ boolean _isConjugated = p.isConjugated();
+ String _portClassName = this.getPortClassName(_protocol, _isConjugated);
+ String ret = _portClassName;
+ boolean _isReplicated = p.isReplicated();
+ if (_isReplicated) {
+ String _operator_plus = StringExtensions.operator_plus(ret, "Repl");
+ ret = _operator_plus;
+ }
+ return ret;
+ }
+
+ public String getPortClassName(final ExternalPort p) {
+ Port _ifport = p.getIfport();
+ String _portClassName = this.getPortClassName(_ifport);
+ return _portClassName;
+ }
+
+ public String getPortClassName(final SAPRef sap) {
+ ProtocolClass _protocol = sap.getProtocol();
+ String _portClassName = this.getPortClassName(_protocol, true);
+ return _portClassName;
+ }
+
+ public String getPortClassName(final ServiceImplementation svc) {
+ SPPRef _spp = svc.getSpp();
+ ProtocolClass _protocol = _spp.getProtocol();
+ String _portClassName = this.getPortClassName(_protocol, false);
+ String _operator_plus = StringExtensions.operator_plus(_portClassName, "Repl");
+ return _operator_plus;
+ }
+
+ public List<Message> getAllIncomingMessages(final ProtocolClass pc) {
+ ProtocolClass _base = pc.getBase();
+ boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_base, null);
+ if (_operator_notEquals) {
+ ProtocolClass _base_1 = pc.getBase();
+ List<Message> _allIncomingMessages = this.getAllIncomingMessages(_base_1);
+ EList<Message> _incomingMessages = pc.getIncomingMessages();
+ List<Message> _union = this.<Message>union(_allIncomingMessages, _incomingMessages);
+ return _union;
+ } else {
+ EList<Message> _incomingMessages_1 = pc.getIncomingMessages();
+ return _incomingMessages_1;
+ }
+ }
+
+ public List<Message> getAllOutgoingMessages(final ProtocolClass pc) {
+ EList<Message> _xifexpression = null;
+ ProtocolClass _base = pc.getBase();
+ boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_base, null);
+ if (_operator_notEquals) {
+ ProtocolClass _base_1 = pc.getBase();
+ List<Message> _allOutgoingMessages = this.getAllOutgoingMessages(_base_1);
+ EList<Message> _outgoingMessages = pc.getOutgoingMessages();
+ List<Message> _union = this.<Message>union(_allOutgoingMessages, _outgoingMessages);
+ return _union;
+ } else {
+ EList<Message> _outgoingMessages_1 = pc.getOutgoingMessages();
+ _xifexpression = _outgoingMessages_1;
+ }
+ return _xifexpression;
+ }
+
+ public List<Message> getIncoming(final ProtocolClass pc, final boolean conj) {
+ if (conj) {
+ List<Message> _allOutgoingMessages = this.getAllOutgoingMessages(pc);
+ return _allOutgoingMessages;
+ } else {
+ List<Message> _allIncomingMessages = this.getAllIncomingMessages(pc);
+ return _allIncomingMessages;
+ }
+ }
+
+ public List<Message> getOutgoing(final ProtocolClass pc, final boolean conj) {
+ if (conj) {
+ List<Message> _allIncomingMessages = this.getAllIncomingMessages(pc);
+ return _allIncomingMessages;
+ } else {
+ List<Message> _allOutgoingMessages = this.getAllOutgoingMessages(pc);
+ return _allOutgoingMessages;
+ }
+ }
+
+ public PortClass getPortClass(final ProtocolClass pc, final boolean conj) {
+ if (conj) {
+ PortClass _conjugate = pc.getConjugate();
+ return _conjugate;
+ } else {
+ PortClass _regular = pc.getRegular();
+ return _regular;
+ }
+ }
+
+ public boolean handlesSend(final ProtocolClass pc, final boolean conj) {
+ PortClass _portClass = this.getPortClass(pc, conj);
+ boolean _operator_equals = ObjectExtensions.operator_equals(_portClass, null);
+ if (_operator_equals) {
+ return false;
+ } else {
+ PortClass _portClass_1 = this.getPortClass(pc, conj);
+ EList<MessageHandler> _msgHandlers = _portClass_1.getMsgHandlers();
+ for (final MessageHandler hdlr : _msgHandlers) {
+ List<Message> _outgoing = this.getOutgoing(pc, conj);
+ Message _msg = hdlr.getMsg();
+ boolean _contains = _outgoing.contains(_msg);
+ if (_contains) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ public boolean handlesReceive(final ProtocolClass pc, final boolean conj) {
+ PortClass _portClass = this.getPortClass(pc, conj);
+ boolean _operator_equals = ObjectExtensions.operator_equals(_portClass, null);
+ if (_operator_equals) {
+ return false;
+ } else {
+ PortClass _portClass_1 = this.getPortClass(pc, conj);
+ EList<MessageHandler> _msgHandlers = _portClass_1.getMsgHandlers();
+ for (final MessageHandler hdlr : _msgHandlers) {
+ List<Message> _incoming = this.getIncoming(pc, conj);
+ Message _msg = hdlr.getMsg();
+ boolean _contains = _incoming.contains(_msg);
+ if (_contains) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ public List<MessageHandler> getReceiveHandlers(final ProtocolClass pc, final boolean conj) {
+ PortClass _portClass = this.getPortClass(pc, conj);
+ boolean _operator_equals = ObjectExtensions.operator_equals(_portClass, null);
+ if (_operator_equals) {
+ ArrayList<MessageHandler> _arrayList = new ArrayList<MessageHandler>();
+ return _arrayList;
+ } else {
+ {
+ ArrayList<MessageHandler> _arrayList_1 = new ArrayList<MessageHandler>();
+ ArrayList<MessageHandler> res = _arrayList_1;
+ PortClass _portClass_1 = this.getPortClass(pc, conj);
+ EList<MessageHandler> _msgHandlers = _portClass_1.getMsgHandlers();
+ for (final MessageHandler hdlr : _msgHandlers) {
+ List<Message> _incoming = this.getIncoming(pc, conj);
+ Message _msg = hdlr.getMsg();
+ boolean _contains = _incoming.contains(_msg);
+ if (_contains) {
+ res.add(hdlr);
+ }
+ }
+ return res;
+ }
+ }
+ }
+
+ public List<MessageHandler> getSendHandlers(final ProtocolClass pc, final boolean conj) {
+ PortClass _portClass = this.getPortClass(pc, conj);
+ boolean _operator_equals = ObjectExtensions.operator_equals(_portClass, null);
+ if (_operator_equals) {
+ ArrayList<MessageHandler> _arrayList = new ArrayList<MessageHandler>();
+ return _arrayList;
+ } else {
+ {
+ ArrayList<MessageHandler> _arrayList_1 = new ArrayList<MessageHandler>();
+ ArrayList<MessageHandler> res = _arrayList_1;
+ PortClass _portClass_1 = this.getPortClass(pc, conj);
+ EList<MessageHandler> _msgHandlers = _portClass_1.getMsgHandlers();
+ for (final MessageHandler hdlr : _msgHandlers) {
+ List<Message> _outgoing = this.getOutgoing(pc, conj);
+ Message _msg = hdlr.getMsg();
+ boolean _contains = _outgoing.contains(_msg);
+ if (_contains) {
+ res.add(hdlr);
+ }
+ }
+ return res;
+ }
+ }
+ }
+
+ public MessageHandler getSendHandler(final Message m, final boolean conj) {
+ EObject _eContainer = m.eContainer();
+ List<MessageHandler> _sendHandlers = this.getSendHandlers(((ProtocolClass) _eContainer), conj);
+ final Function1<MessageHandler,Boolean> _function = new Function1<MessageHandler,Boolean>() {
+ public Boolean apply(final MessageHandler e) {
+ Message _msg = e.getMsg();
+ boolean _operator_equals = ObjectExtensions.operator_equals(_msg, m);
+ return ((Boolean)_operator_equals);
+ }
+ };
+ MessageHandler _findFirst = IterableExtensions.<MessageHandler>findFirst(_sendHandlers, _function);
+ return _findFirst;
+ }
+
+ public boolean isIncoming(final Message m) {
+ EObject _eContainer = m.eContainer();
+ List<Message> _allIncomingMessages = this.getAllIncomingMessages(((ProtocolClass) _eContainer));
+ boolean _contains = _allIncomingMessages.contains(m);
+ return _contains;
+ }
+
+ public String getCodeName(final Message m) {
+ boolean _isIncoming = this.isIncoming(m);
+ if (_isIncoming) {
+ String _name = m.getName();
+ String _operator_plus = StringExtensions.operator_plus("IN_", _name);
+ return _operator_plus;
+ } else {
+ String _name_1 = m.getName();
+ String _operator_plus_1 = StringExtensions.operator_plus("OUT_", _name_1);
+ return _operator_plus_1;
+ }
+ }
+
+ public boolean isLeaf(final State s) {
+ StateGraph _subgraph = s.getSubgraph();
+ boolean _operator_equals = ObjectExtensions.operator_equals(_subgraph, null);
+ return _operator_equals;
+ }
+
+ public List<State> getLeafStateList(final StateGraph sg) {
+ ArrayList<State> _arrayList = new ArrayList<State>();
+ ArrayList<State> res = _arrayList;
+ EList<State> _states = sg.getStates();
+ for (final State s : _states) {
+ List<State> _leafStateList = this.getLeafStateList(s);
+ res.addAll(_leafStateList);
+ }
+ return res;
+ }
+
+ public List<State> getLeafStateList(final State s) {
+ boolean _isLeaf = this.isLeaf(s);
+ if (_isLeaf) {
+ {
+ ArrayList<State> _arrayList = new ArrayList<State>();
+ ArrayList<State> res = _arrayList;
+ res.add(s);
+ return res;
+ }
+ } else {
+ StateGraph _subgraph = s.getSubgraph();
+ List<State> _leafStateList = this.getLeafStateList(_subgraph);
+ return _leafStateList;
+ }
+ }
+
+ public List<State> getStateList(final StateGraph sg) {
+ ArrayList<State> _arrayList = new ArrayList<State>();
+ ArrayList<State> ret = _arrayList;
+ EList<State> _states = sg.getStates();
+ for (final State e : _states) {
+ {
+ ret.add(e);
+ StateGraph _subgraph = e.getSubgraph();
+ StateGraph tmp = _subgraph;
+ boolean _operator_notEquals = ObjectExtensions.operator_notEquals(tmp, null);
+ if (_operator_notEquals) {
+ StateGraph _subgraph_1 = e.getSubgraph();
+ List<State> _stateList = this.getStateList(_subgraph_1);
+ ret.addAll(_stateList);
+ }
+ }
+ }
+ return ret;
+ }
+
+ public List<State> getBaseStateList(final StateGraph sg) {
+ ArrayList<State> _arrayList = new ArrayList<State>();
+ ArrayList<State> ret = _arrayList;
+ List<State> _stateList = this.getStateList(sg);
+ for (final State e : _stateList) {
+ if ((e instanceof BaseState)) {
+ ret.add(e);
+ }
+ }
+ return ret;
+ }
+
+ public List<State> getAllBaseStates(final ActorClass ac) {
+ List<State> _xifexpression = null;
+ ActorClass _base = ac.getBase();
+ boolean _operator_equals = ObjectExtensions.operator_equals(_base, null);
+ if (_operator_equals) {
+ StateMachine _stateMachine = ac.getStateMachine();
+ List<State> _baseStateList = this.getBaseStateList(_stateMachine);
+ return _baseStateList;
+ } else {
+ ActorClass _base_1 = ac.getBase();
+ List<State> _allBaseStates = this.getAllBaseStates(_base_1);
+ StateMachine _stateMachine_1 = ac.getStateMachine();
+ List<State> _baseStateList_1 = this.getBaseStateList(_stateMachine_1);
+ List<State> _union = this.<State>union(_allBaseStates, _baseStateList_1);
+ _xifexpression = _union;
+ }
+ return _xifexpression;
+ }
+
+ public boolean overridesStop(final ActorClass ac) {
+ boolean _operator_or = false;
+ EList<StandardOperation> _operations = ac.getOperations();
+ final Function1<StandardOperation,Boolean> _function = new Function1<StandardOperation,Boolean>() {
+ public Boolean apply(final StandardOperation e) {
+ boolean _operator_and = false;
+ boolean _operator_and_1 = false;
+ String _name = e.getName();
+ boolean _operator_equals = ObjectExtensions.operator_equals(_name, "stop");
+ if (!_operator_equals) {
+ _operator_and_1 = false;
+ } else {
+ EList<VarDecl> _arguments = e.getArguments();
+ boolean _isEmpty = _arguments.isEmpty();
+ _operator_and_1 = BooleanExtensions.operator_and(_operator_equals, _isEmpty);
+ }
+ if (!_operator_and_1) {
+ _operator_and = false;
+ } else {
+ RefableType _returntype = e.getReturntype();
+ boolean _operator_equals_1 = ObjectExtensions.operator_equals(_returntype, null);
+ _operator_and = BooleanExtensions.operator_and(_operator_and_1, _operator_equals_1);
+ }
+ return ((Boolean)_operator_and);
+ }
+ };
+ boolean _exists = IterableExtensions.<StandardOperation>exists(_operations, _function);
+ if (_exists) {
+ _operator_or = true;
+ } else {
+ boolean _operator_and = false;
+ ActorClass _base = ac.getBase();
+ boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_base, null);
+ if (!_operator_notEquals) {
+ _operator_and = false;
+ } else {
+ ActorClass _base_1 = ac.getBase();
+ boolean _overridesStop = this.overridesStop(_base_1);
+ _operator_and = BooleanExtensions.operator_and(_operator_notEquals, _overridesStop);
+ }
+ _operator_or = BooleanExtensions.operator_or(_exists, _operator_and);
+ }
+ return _operator_or;
+ }
+
+ public int getNumberOfInheritedStates(final ActorClass ac) {
+ ActorClass _base = ac.getBase();
+ boolean _operator_equals = ObjectExtensions.operator_equals(_base, null);
+ if (_operator_equals) {
+ return 0;
+ } else {
+ ActorClass _base_1 = ac.getBase();
+ StateMachine _stateMachine = _base_1.getStateMachine();
+ List<State> _stateList = this.getStateList(_stateMachine);
+ int _size = _stateList.size();
+ ActorClass _base_2 = ac.getBase();
+ int _numberOfInheritedStates = this.getNumberOfInheritedStates(_base_2);
+ int _operator_plus = IntegerExtensions.operator_plus(((Integer)_size), ((Integer)_numberOfInheritedStates));
+ return _operator_plus;
+ }
+ }
+
+ public int getNumberOfInheritedBaseStates(final ActorClass ac) {
+ ActorClass _base = ac.getBase();
+ boolean _operator_equals = ObjectExtensions.operator_equals(_base, null);
+ if (_operator_equals) {
+ return 0;
+ } else {
+ ActorClass _base_1 = ac.getBase();
+ StateMachine _stateMachine = _base_1.getStateMachine();
+ List<State> _baseStateList = this.getBaseStateList(_stateMachine);
+ int _size = _baseStateList.size();
+ ActorClass _base_2 = ac.getBase();
+ int _numberOfInheritedBaseStates = this.getNumberOfInheritedBaseStates(_base_2);
+ int _operator_plus = IntegerExtensions.operator_plus(((Integer)_size), ((Integer)_numberOfInheritedBaseStates));
+ return _operator_plus;
+ }
+ }
+
+ public String getStateId(final State s) {
+ String _genStateId = RoomNameProv.getGenStateId(s);
+ return _genStateId;
+ }
+
+ public String getStatePathName(final State s) {
+ String _genStatePathName = RoomNameProv.getGenStatePathName(s);
+ return _genStatePathName;
+ }
+
+ public String getChainId(final TransitionChain t) {
+ String _genChainId = RoomNameProv.getGenChainId(t);
+ return _genChainId;
+ }
+
+ public boolean hasGuard(final Trigger tr) {
+ boolean _operator_and = false;
+ boolean _operator_and_1 = false;
+ Guard _guard = tr.getGuard();
+ boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_guard, null);
+ if (!_operator_notEquals) {
+ _operator_and_1 = false;
+ } else {
+ Guard _guard_1 = tr.getGuard();
+ DetailCode _guard_2 = _guard_1.getGuard();
+ boolean _operator_notEquals_1 = ObjectExtensions.operator_notEquals(_guard_2, null);
+ _operator_and_1 = BooleanExtensions.operator_and(_operator_notEquals, _operator_notEquals_1);
+ }
+ if (!_operator_and_1) {
+ _operator_and = false;
+ } else {
+ Guard _guard_3 = tr.getGuard();
+ DetailCode _guard_4 = _guard_3.getGuard();
+ EList<String> _commands = _guard_4.getCommands();
+ int _size = _commands.size();
+ boolean _operator_greaterThan = ComparableExtensions.<Integer>operator_greaterThan(((Integer)_size), ((Integer)0));
+ _operator_and = BooleanExtensions.operator_and(_operator_and_1, _operator_greaterThan);
+ }
+ return _operator_and;
+ }
+
+ public boolean hasGuard(final ExpandedActorClass ac, final ActiveTrigger at) {
+ boolean hasGuard = false;
+ EList<TriggeredTransition> _transitions = at.getTransitions();
+ for (final TriggeredTransition t : _transitions) {
+ EList<Trigger> _triggers = t.getTriggers();
+ final Function1<Trigger,Boolean> _function = new Function1<Trigger,Boolean>() {
+ public Boolean apply(final Trigger e) {
+ boolean _operator_and = false;
+ String _trigger = at.getTrigger();
+ boolean _isMatching = ac.isMatching(e, _trigger);
+ if (!_isMatching) {
+ _operator_and = false;
+ } else {
+ boolean _hasGuard = RoomExtensions.this.hasGuard(e);
+ _operator_and = BooleanExtensions.operator_and(_isMatching, _hasGuard);
+ }
+ return ((Boolean)_operator_and);
+ }
+ };
+ boolean _exists = IterableExtensions.<Trigger>exists(_triggers, _function);
+ if (_exists) {
+ hasGuard = true;
+ }
+ }
+ return hasGuard;
+ }
+
+ public boolean hasEntryCode(final State s) {
+ boolean _operator_and = false;
+ DetailCode _entryCode = s.getEntryCode();
+ boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_entryCode, null);
+ if (!_operator_notEquals) {
+ _operator_and = false;
+ } else {
+ DetailCode _entryCode_1 = s.getEntryCode();
+ EList<String> _commands = _entryCode_1.getCommands();
+ int _size = _commands.size();
+ boolean _operator_greaterThan = ComparableExtensions.<Integer>operator_greaterThan(((Integer)_size), ((Integer)0));
+ _operator_and = BooleanExtensions.operator_and(_operator_notEquals, _operator_greaterThan);
+ }
+ return _operator_and;
+ }
+
+ public boolean hasExitCode(final State s) {
+ boolean _operator_and = false;
+ DetailCode _exitCode = s.getExitCode();
+ boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_exitCode, null);
+ if (!_operator_notEquals) {
+ _operator_and = false;
+ } else {
+ DetailCode _exitCode_1 = s.getExitCode();
+ EList<String> _commands = _exitCode_1.getCommands();
+ int _size = _commands.size();
+ boolean _operator_greaterThan = ComparableExtensions.<Integer>operator_greaterThan(((Integer)_size), ((Integer)0));
+ _operator_and = BooleanExtensions.operator_and(_operator_notEquals, _operator_greaterThan);
+ }
+ return _operator_and;
+ }
+
+ public String getEntryCode(final ExpandedActorClass ac, final State s) {
+ if ((s instanceof RefinedState)) {
+ String _entryCodeOperationName = RoomNameProv.getEntryCodeOperationName(s);
+ String _operator_plus = StringExtensions.operator_plus("super.", _entryCodeOperationName);
+ String _operator_plus_1 = StringExtensions.operator_plus(_operator_plus, "();\n");
+ DetailCode _entryCode = s.getEntryCode();
+ String _code = ac.getCode(_entryCode);
+ String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, _code);
+ return _operator_plus_2;
+ } else {
+ DetailCode _entryCode_1 = s.getEntryCode();
+ String _code_1 = ac.getCode(_entryCode_1);
+ return _code_1;
+ }
+ }
+
+ public String getExitCode(final ExpandedActorClass ac, final State s) {
+ String _xifexpression = null;
+ if ((s instanceof RefinedState)) {
+ DetailCode _exitCode = s.getExitCode();
+ String _code = ac.getCode(_exitCode);
+ String _operator_plus = StringExtensions.operator_plus(_code, "super.");
+ String _entryCodeOperationName = RoomNameProv.getEntryCodeOperationName(s);
+ String _operator_plus_1 = StringExtensions.operator_plus(_operator_plus, _entryCodeOperationName);
+ String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, "();\n");
+ return _operator_plus_2;
+ } else {
+ DetailCode _exitCode_1 = s.getExitCode();
+ String _code_1 = ac.getCode(_exitCode_1);
+ _xifexpression = _code_1;
+ }
+ return _xifexpression;
+ }
+
+ public boolean hasActionCode(final Transition t) {
+ boolean _operator_and = false;
+ DetailCode _action = t.getAction();
+ boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_action, null);
+ if (!_operator_notEquals) {
+ _operator_and = false;
+ } else {
+ DetailCode _action_1 = t.getAction();
+ EList<String> _commands = _action_1.getCommands();
+ int _size = _commands.size();
+ boolean _operator_greaterThan = ComparableExtensions.<Integer>operator_greaterThan(((Integer)_size), ((Integer)0));
+ _operator_and = BooleanExtensions.operator_and(_operator_notEquals, _operator_greaterThan);
+ }
+ return _operator_and;
+ }
+
+ public String getActionCode(final ExpandedActorClass ac, final Transition t) {
+ DetailCode _action = t.getAction();
+ String _code = ac.getCode(_action);
+ return _code;
+ }
+
+ public String getContextId(final TransitionChain tc) {
+ State _stateContext = tc.getStateContext();
+ String _stateId = this.getStateId(_stateContext);
+ return _stateId;
+ }
+
+ public Transition getInitTransition(final StateGraph sg) {
+ EList<Transition> _transitions = sg.getTransitions();
+ for (final Transition tr : _transitions) {
+ if ((tr instanceof InitialTransition)) {
+ return tr;
+ }
+ }
+ return null;
+ }
+
+ public boolean hasInitTransition(final StateGraph sg) {
+ EList<Transition> _transitions = sg.getTransitions();
+ for (final Transition tr : _transitions) {
+ if ((tr instanceof InitialTransition)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public List<Transition> getTransitionList(final State s) {
+ boolean _isLeaf = this.isLeaf(s);
+ if (_isLeaf) {
+ ArrayList<Transition> _arrayList = new ArrayList<Transition>();
+ return _arrayList;
+ } else {
+ StateGraph _subgraph = s.getSubgraph();
+ List<Transition> _transitionList = this.getTransitionList(_subgraph);
+ return _transitionList;
+ }
+ }
+
+ public List<Transition> getTransitionList(final StateGraph sg) {
+ EList<Transition> _transitions = sg.getTransitions();
+ ArrayList<Transition> _arrayList = new ArrayList<Transition>(_transitions);
+ ArrayList<Transition> res = _arrayList;
+ EList<State> _states = sg.getStates();
+ for (final State s : _states) {
+ List<Transition> _transitionList = this.getTransitionList(s);
+ res.addAll(_transitionList);
+ }
+ return res;
+ }
+}
diff --git a/runtime/org.eclipse.etrice.runtime.c/Debug/liborg.eclipse.etrice.runtime.c.a b/runtime/org.eclipse.etrice.runtime.c/Debug/liborg.eclipse.etrice.runtime.c.a
index 391fc12df..6e41f9bd0 100644
--- a/runtime/org.eclipse.etrice.runtime.c/Debug/liborg.eclipse.etrice.runtime.c.a
+++ b/runtime/org.eclipse.etrice.runtime.c/Debug/liborg.eclipse.etrice.runtime.c.a
Binary files differ
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/etPort.h b/runtime/org.eclipse.etrice.runtime.c/src/etPort.h
index c10abc870..901fe75e4 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/etPort.h
+++ b/runtime/org.eclipse.etrice.runtime.c/src/etPort.h
@@ -31,8 +31,7 @@ typedef struct {
etAddressId address;
/* thread ID from msg service: msgService->threadId */
#endif
-}
-etPort;
+} etPort;
void etPort_receive(etPort* self, etMessage* msg);
diff --git a/tests/org.eclipse.etrice.generator.c.tests/src-gen/cGenRef/CommunicationProtocol.h b/tests/org.eclipse.etrice.generator.c.tests/src-gen/cGenRef/CommunicationProtocol.h
deleted file mode 100644
index 937c181f6..000000000
--- a/tests/org.eclipse.etrice.generator.c.tests/src-gen/cGenRef/CommunicationProtocol.h
+++ /dev/null
@@ -1,50 +0,0 @@
-#ifndef _CommunicationProtocol_H_
-#define _CommunicationProtocol_H_
-
-#include "etDatatypes.h"
-
-
-#include "DataClass1.h"
-
-typedef struct {
-
-
-} CommunicationProtocol;
-
-/* message IDs */
-enum {
- CommunicationProtocol_MSG_MIN = 0,
- /* IDs for outgoing messages */
- CommunicationProtocol_OUT_receivedData = 1,
- /* IDs for incoming messages */
- CommunicationProtocol_IN_sendData = 2,
- CommunicationProtocol_IN_sendData2 = 3,
- /* error if msgID >= MSG_MAX */
- CommunicationProtocol_MSG_MAX = 4
-};
-
-/*--------------------- port classes */
-
-typedef struct etPort CommunicationProtocolPort;
-
-void CommunicationProtocolPort_MyOperation1(CommunicationProtocolPort* self, int a, int b);
-int CommunicationProtocolPort_MyOperation2(CommunicationProtocolPort* self);
-
-
-
-typedef struct etPort CommunicationProtocolConjPort;
-
-void CommunicationProtocolConjPort_MyOperation1(CommunicationProtocolConjPort* self, int a, int b);
-int CommunicationProtocolConjPort_MyOperation2(CommunicationProtocolConjPort* self);
-
-
-
-/*--------------------- debug helpers */
-
-/* get message string for message id */
-const char* CommunicationProtocol_getMessageString(int msg_id);
-
-
-
-#endif /* _CommunicationProtocol_H_ */
-

Back to the top