Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'examples/org.eclipse.etrice.generator.c.reference')
-rw-r--r--examples/org.eclipse.etrice.generator.c.reference/.cproject26
-rw-r--r--examples/org.eclipse.etrice.generator.c.reference/Henrik-Test.launch7
-rw-r--r--examples/org.eclipse.etrice.generator.c.reference/model/cGenRef.etmap16
-rw-r--r--examples/org.eclipse.etrice.generator.c.reference/model/cGenRef.etphys33
-rw-r--r--examples/org.eclipse.etrice.generator.c.reference/model/cGenRef.room11
-rw-r--r--examples/org.eclipse.etrice.generator.c.reference/model/diagrams/cGenRef.SubSys.structure2
-rw-r--r--examples/org.eclipse.etrice.generator.c.reference/src-gen-ts/cGenRef/CommunicationProtocol.c89
-rw-r--r--examples/org.eclipse.etrice.generator.c.reference/src-gen-ts/cGenRef/CommunicationProtocol.h54
-rw-r--r--examples/org.eclipse.etrice.generator.c.reference/src-gen-ts/cGenRef/DataClass1.c30
-rw-r--r--examples/org.eclipse.etrice.generator.c.reference/src-gen-ts/cGenRef/DataClass1.h40
-rw-r--r--examples/org.eclipse.etrice.generator.c.reference/src-gen-ts/cGenRef/DataClass2.c24
-rw-r--r--examples/org.eclipse.etrice.generator.c.reference/src-gen-ts/cGenRef/DataClass2.h32
-rw-r--r--examples/org.eclipse.etrice.generator.c.reference/src-gen-ts/cGenRef/Node1.c170
-rw-r--r--examples/org.eclipse.etrice.generator.c.reference/src-gen-ts/cGenRef/Node1.h30
-rw-r--r--examples/org.eclipse.etrice.generator.c.reference/src-gen-ts/cGenRef/Node1_Disp.h43
-rw-r--r--examples/org.eclipse.etrice.generator.c.reference/src-gen-ts/cGenRef/Node1_Inst.h81
-rw-r--r--examples/org.eclipse.etrice.generator.c.reference/src-gen-ts/cGenRef/Receiver.c199
-rw-r--r--examples/org.eclipse.etrice.generator.c.reference/src-gen-ts/cGenRef/Receiver.h62
-rw-r--r--examples/org.eclipse.etrice.generator.c.reference/src-gen-ts/cGenRef/Sender.c197
-rw-r--r--examples/org.eclipse.etrice.generator.c.reference/src-gen-ts/cGenRef/Sender.h60
-rw-r--r--examples/org.eclipse.etrice.generator.c.reference/src-gen-ts/cGenRef/SubSys_Runner.c49
-rw-r--r--examples/org.eclipse.etrice.generator.c.reference/src-gen-ts/readme.txt4
22 files changed, 1251 insertions, 8 deletions
diff --git a/examples/org.eclipse.etrice.generator.c.reference/.cproject b/examples/org.eclipse.etrice.generator.c.reference/.cproject
index 495d5ed4d..3c63ede5c 100644
--- a/examples/org.eclipse.etrice.generator.c.reference/.cproject
+++ b/examples/org.eclipse.etrice.generator.c.reference/.cproject
@@ -65,9 +65,18 @@
<tool id="cdt.managedbuild.tool.gnu.cpp.linker.mingw.exe.debug.1915798937" name="MinGW C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.mingw.exe.debug"/>
</toolChain>
</folderInfo>
+ <folderInfo id="cdt.managedbuild.config.gnu.mingw.exe.debug.54263550.834203625" name="/" resourcePath="src-gen-ts">
+ <toolChain id="cdt.managedbuild.toolchain.gnu.mingw.exe.debug.1267442943" name="MinGW GCC" superClass="cdt.managedbuild.toolchain.gnu.mingw.exe.debug" unusedChildren="">
+ <tool id="cdt.managedbuild.tool.gnu.assembler.mingw.exe.debug.989031536" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.mingw.exe.debug.2128193487"/>
+ <tool id="cdt.managedbuild.tool.gnu.archiver.mingw.base.2002258166" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.mingw.base.1852443642"/>
+ <tool id="cdt.managedbuild.tool.gnu.cpp.compiler.mingw.exe.debug.936216193" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.mingw.exe.debug.1864486752"/>
+ <tool id="cdt.managedbuild.tool.gnu.c.compiler.mingw.exe.debug.262501100" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.mingw.exe.debug.1547425303"/>
+ <tool id="cdt.managedbuild.tool.gnu.c.linker.mingw.exe.debug.2064786241" name="MinGW C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.mingw.exe.debug.2141539090"/>
+ <tool id="cdt.managedbuild.tool.gnu.cpp.linker.mingw.exe.debug.213598096" name="MinGW C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.mingw.exe.debug.1915798937"/>
+ </toolChain>
+ </folderInfo>
<sourceEntries>
- <entry excluding="src-gen|src" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/>
- <entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src-gen"/>
+ <entry excluding="src-gen-ts|src" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/>
</sourceEntries>
</configuration>
</storageModule>
@@ -132,8 +141,8 @@
</toolChain>
</folderInfo>
<sourceEntries>
- <entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src-gen"/>
- <entry excluding="src-gen|src" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/>
+ <entry excluding="src-gen-ts|src" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/>
+ <entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src-gen-ts"/>
</sourceEntries>
</configuration>
</storageModule>
@@ -160,8 +169,13 @@
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"/>
</scannerConfigBuildInfo>
</storageModule>
- <storageModule moduleId="refreshScope" versionNumber="1">
- <resource resourceType="PROJECT" workspacePath="/org.eclipse.etrice.generator.c.reference"/>
+ <storageModule moduleId="refreshScope" versionNumber="2">
+ <configuration configurationName="Release">
+ <resource resourceType="PROJECT" workspacePath="/org.eclipse.etrice.generator.c.reference"/>
+ </configuration>
+ <configuration configurationName="Debug">
+ <resource resourceType="PROJECT" workspacePath="/org.eclipse.etrice.generator.c.reference"/>
+ </configuration>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.internal.ui.text.commentOwnerProjectMappings"/>
<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
diff --git a/examples/org.eclipse.etrice.generator.c.reference/Henrik-Test.launch b/examples/org.eclipse.etrice.generator.c.reference/Henrik-Test.launch
index 9931b7b5c..6f1c46e59 100644
--- a/examples/org.eclipse.etrice.generator.c.reference/Henrik-Test.launch
+++ b/examples/org.eclipse.etrice.generator.c.reference/Henrik-Test.launch
@@ -1,10 +1,15 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="org.eclipse.etrice.generator.launch.c.launchConfigurationType">
+<booleanAttribute key="Debug" value="false"/>
+<booleanAttribute key="GenDocumentation" value="false"/>
<booleanAttribute key="GenInstanceDiagram" value="false"/>
<stringAttribute key="GenModelPath" value=""/>
<booleanAttribute key="Lib" value="false"/>
+<booleanAttribute key="MSC" value="false"/>
<listAttribute key="ModelFiles">
-<listEntry value="${workspace_loc:/org.eclipse.etrice.generator.c.reference/model/generic_fsm_gen.room}"/>
+<listEntry value="${workspace_loc:/org.eclipse.etrice.generator.c.reference/model/cGenRef.etmap}"/>
</listAttribute>
<booleanAttribute key="SaveGenModel" value="false"/>
+<booleanAttribute key="Verbose" value="false"/>
+<stringAttribute key="org.eclipse.debug.core.ATTR_REFRESH_SCOPE" value="${workspace}"/>
</launchConfiguration>
diff --git a/examples/org.eclipse.etrice.generator.c.reference/model/cGenRef.etmap b/examples/org.eclipse.etrice.generator.c.reference/model/cGenRef.etmap
new file mode 100644
index 000000000..5bb318343
--- /dev/null
+++ b/examples/org.eclipse.etrice.generator.c.reference/model/cGenRef.etmap
@@ -0,0 +1,16 @@
+MappingModel cgenRef {
+
+ import cGenRef from "cGenRef.room"
+ import cGenRef from "cGenRef.etphys"
+
+ Mapping cGenRef.LS -> cGenRef.Sys {
+ SubSystemMapping sys1 -> node1 {
+ ThreadMapping dflt_thread -> PhysicalThread1
+ ThreadMapping other_thread -> PhysicalThread2
+ }
+ SubSystemMapping sys2 -> node2 {
+ ThreadMapping dflt_thread -> PhysicalThread1
+ ThreadMapping other_thread -> PhysicalThread2
+ }
+ }
+} \ No newline at end of file
diff --git a/examples/org.eclipse.etrice.generator.c.reference/model/cGenRef.etphys b/examples/org.eclipse.etrice.generator.c.reference/model/cGenRef.etphys
new file mode 100644
index 000000000..f900efe41
--- /dev/null
+++ b/examples/org.eclipse.etrice.generator.c.reference/model/cGenRef.etphys
@@ -0,0 +1,33 @@
+PhysicalModel cGenRef {
+
+ PhysicalSystem Sys {
+ NodeRef node1: PC
+ NodeRef node2: PC
+ }
+
+ NodeClass PC {
+ runtime = PC
+ priomin = 1
+ priomax = 5
+
+ DefaultThread PhysicalThread1 {
+ execmode = blocked
+ prio = 5
+ stacksize = 1024
+ msgblocksize = 64
+ msgpoolsize = 256
+ }
+
+ Thread PhysicalThread2 {
+ execmode = blocked
+ prio = 5
+ stacksize = 1024
+ msgblocksize = 64
+ msgpoolsize = 256
+ }
+ }
+
+ RuntimeClass PC {
+ model = multiThreaded
+ }
+} \ No newline at end of file
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 417f1c792..f37b6bcc7 100644
--- a/examples/org.eclipse.etrice.generator.c.reference/model/cGenRef.room
+++ b/examples/org.eclipse.etrice.generator.c.reference/model/cGenRef.room
@@ -1,10 +1,21 @@
RoomModel cGenRef {
import room.basic.types.* from "Types.room"
+ LogicalSystem LS {
+ SubSystemRef sys1: SubSys
+ SubSystemRef sys2: SubSys
+ }
+
SubSystemClass SubSys {
ActorRef Sender: Sender
ActorRef Receiver: Receiver
Binding Sender.dataOut and Receiver.dataIn
+
+ LogicalThread dflt_thread
+ LogicalThread other_thread
+
+ ActorInstanceMapping Receiver -> dflt_thread
+ ActorInstanceMapping Sender -> other_thread
}
// SubSystemClass SubSysSomewhatBigger {
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 4946537b8..27bbaaa4b 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" version="0.9.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.0/@children.1/@link //@children.0/@children.1/@link //@children.0/@children.1/@children.1/@link //@connections.0/@link" verticalGridUnit="0" version="0.9.1">
<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"/>
diff --git a/examples/org.eclipse.etrice.generator.c.reference/src-gen-ts/cGenRef/CommunicationProtocol.c b/examples/org.eclipse.etrice.generator.c.reference/src-gen-ts/cGenRef/CommunicationProtocol.c
new file mode 100644
index 000000000..63831f3f3
--- /dev/null
+++ b/examples/org.eclipse.etrice.generator.c.reference/src-gen-ts/cGenRef/CommunicationProtocol.c
@@ -0,0 +1,89 @@
+/**
+ * @author generated by eTrice
+ *
+ * Source File of ProtocolClass CommunicationProtocol
+ *
+ */
+
+#include "CommunicationProtocol.h"
+#include "debugging/etMSCLogger.h"
+
+
+/*--------------------- port methods */
+
+void CommunicationProtocolPort_receivedData(const CommunicationProtocolPort* self) {
+ ET_MSC_LOGGER_SYNC_ENTRY("CommunicationProtocolPort", "receivedData")
+ etPort_sendMessage(self, CommunicationProtocol_OUT_receivedData, 0, NULL);
+ ET_MSC_LOGGER_SYNC_EXIT
+}
+
+void CommunicationProtocolReplPort_receivedData_broadcast(const CommunicationProtocolReplPort* self) {
+ int i;
+ ET_MSC_LOGGER_SYNC_ENTRY("CommunicationProtocolReplPort", "receivedData")
+ for (i=0; i<((etReplPort*)self)->size; ++i) {
+ etPort_sendMessage(((etPort*)&((etReplPort*)self)->ports[i]), CommunicationProtocol_OUT_receivedData, 0, NULL);
+ }
+ ET_MSC_LOGGER_SYNC_EXIT
+}
+
+void CommunicationProtocolReplPort_receivedData(const CommunicationProtocolReplPort* self, int idx) {
+ ET_MSC_LOGGER_SYNC_ENTRY("CommunicationProtocolReplPort", "receivedData")
+ if (0<=idx && idx<((etReplPort*)self)->size) {
+ etPort_sendMessage(((etPort*)&((etReplPort*)self)->ports[idx]), CommunicationProtocol_OUT_receivedData, 0, NULL);
+ }
+ ET_MSC_LOGGER_SYNC_EXIT
+}
+
+
+// getReplication
+etInt32 CommunicationProtocolReplPort_getReplication(const CommunicationProtocolReplPort* self) {
+ return ((etReplPort*)self)->size;
+}
+
+
+
+void CommunicationProtocolConjPort_sendData(const CommunicationProtocolConjPort* self) {
+ ET_MSC_LOGGER_SYNC_ENTRY("CommunicationProtocolConjPort", "sendData")
+ etPort_sendMessage(self, CommunicationProtocol_IN_sendData, 0, NULL);
+ ET_MSC_LOGGER_SYNC_EXIT
+}
+
+void CommunicationProtocolConjReplPort_sendData_broadcast(const CommunicationProtocolConjReplPort* self) {
+ int i;
+ ET_MSC_LOGGER_SYNC_ENTRY("CommunicationProtocolConjReplPort", "sendData")
+ for (i=0; i<((etReplPort*)self)->size; ++i) {
+ etPort_sendMessage(((etPort*)&((etReplPort*)self)->ports[i]), CommunicationProtocol_IN_sendData, 0, NULL);
+ }
+ ET_MSC_LOGGER_SYNC_EXIT
+}
+
+void CommunicationProtocolConjReplPort_sendData(const CommunicationProtocolConjReplPort* self, int idx) {
+ ET_MSC_LOGGER_SYNC_ENTRY("CommunicationProtocolConjReplPort", "sendData")
+ if (0<=idx && idx<((etReplPort*)self)->size) {
+ etPort_sendMessage(((etPort*)&((etReplPort*)self)->ports[idx]), CommunicationProtocol_IN_sendData, 0, NULL);
+ }
+ ET_MSC_LOGGER_SYNC_EXIT
+}
+
+
+// getReplication
+etInt32 CommunicationProtocolConjReplPort_getReplication(const CommunicationProtocolConjReplPort* self) {
+ return ((etReplPort*)self)->size;
+}
+
+
+
+/*--------------------- debug helpers */
+
+/* message names as strings for debugging (generate MSC) */
+static const char* const CommunicationProtocol_messageStrings[] = {"MIN", "receivedData","sendData", "MAX"};
+
+const char* CommunicationProtocol_getMessageString(int msg_id) {
+ if (msg_id<CommunicationProtocol_MSG_MIN || msg_id>CommunicationProtocol_MSG_MAX+1){
+ /* id out of range */
+ return "Message ID out of range";
+ }
+ else{
+ return CommunicationProtocol_messageStrings[msg_id];
+ }
+}
diff --git a/examples/org.eclipse.etrice.generator.c.reference/src-gen-ts/cGenRef/CommunicationProtocol.h b/examples/org.eclipse.etrice.generator.c.reference/src-gen-ts/cGenRef/CommunicationProtocol.h
new file mode 100644
index 000000000..7fd2bf544
--- /dev/null
+++ b/examples/org.eclipse.etrice.generator.c.reference/src-gen-ts/cGenRef/CommunicationProtocol.h
@@ -0,0 +1,54 @@
+/**
+ * @author generated by eTrice
+ *
+ * Header File of ProtocolClass CommunicationProtocol
+ *
+ */
+
+#ifndef _COMMUNICATIONPROTOCOL_H_
+#define _COMMUNICATIONPROTOCOL_H_
+
+#include "etDatatypes.h"
+#include "modelbase/etPort.h"
+
+
+
+
+/* message IDs */
+enum CommunicationProtocol_msg_ids {
+ CommunicationProtocol_MSG_MIN = 0,
+ CommunicationProtocol_OUT_receivedData = 1,
+ CommunicationProtocol_IN_sendData = 2,
+ CommunicationProtocol_MSG_MAX = 3
+};
+
+/*--------------------- port structs and methods */
+typedef etPort CommunicationProtocolPort;
+typedef etReplPort CommunicationProtocolReplPort;
+
+
+void CommunicationProtocolPort_receivedData(const CommunicationProtocolPort* self);
+void CommunicationProtocolReplPort_receivedData_broadcast(const CommunicationProtocolReplPort* self);
+void CommunicationProtocolReplPort_receivedData(const CommunicationProtocolReplPort* self, int idx);
+
+
+etInt32 CommunicationProtocolReplPort_getReplication(const CommunicationProtocolReplPort* self);
+typedef etPort CommunicationProtocolConjPort;
+typedef etReplPort CommunicationProtocolConjReplPort;
+
+
+void CommunicationProtocolConjPort_sendData(const CommunicationProtocolConjPort* self);
+void CommunicationProtocolConjReplPort_sendData_broadcast(const CommunicationProtocolConjReplPort* self);
+void CommunicationProtocolConjReplPort_sendData(const CommunicationProtocolConjReplPort* self, int idx);
+
+
+etInt32 CommunicationProtocolConjReplPort_getReplication(const CommunicationProtocolConjReplPort* self);
+
+/*--------------------- 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-ts/cGenRef/DataClass1.c b/examples/org.eclipse.etrice.generator.c.reference/src-gen-ts/cGenRef/DataClass1.c
new file mode 100644
index 000000000..5ff2a95d4
--- /dev/null
+++ b/examples/org.eclipse.etrice.generator.c.reference/src-gen-ts/cGenRef/DataClass1.c
@@ -0,0 +1,30 @@
+/**
+ * @author generated by eTrice
+ *
+ * Source File of DataClass DataClass1
+ *
+ */
+
+#include "DataClass1.h"
+
+#include <string.h>
+
+/*--------------------- begin user code ---------------------*/
+// usercode3
+/*--------------------- end user code ---------------------*/
+
+
+/*--------------------- operations ---------------------*/
+int32 DataClass1_MultiplyWithAttr1(DataClass1* self, int32 value) {
+ return self->Attr1 /* ORIG: Attr1 */*value;
+}
+float32 DataClass1_MultiplyWithAttr3(DataClass1* self, float32 value) {
+ return self->Attr3 /* ORIG: Attr3 */*value;
+}
+
+// deep copy
+void DataClass1_deepCopy(DataClass1* source, DataClass1* target) {
+ memcpy(target, source, sizeof(DataClass1));
+}
+
+
diff --git a/examples/org.eclipse.etrice.generator.c.reference/src-gen-ts/cGenRef/DataClass1.h b/examples/org.eclipse.etrice.generator.c.reference/src-gen-ts/cGenRef/DataClass1.h
new file mode 100644
index 000000000..4f3176f62
--- /dev/null
+++ b/examples/org.eclipse.etrice.generator.c.reference/src-gen-ts/cGenRef/DataClass1.h
@@ -0,0 +1,40 @@
+/**
+ * @author generated by eTrice
+ *
+ * Header File of DataClass DataClass1
+ *
+ */
+
+#ifndef _DATACLASS1_H_
+#define _DATACLASS1_H_
+
+#include "etDatatypes.h"
+
+#include "DataClass2.h"
+
+/*--------------------- begin user code ---------------------*/
+// usercode1
+/*--------------------- end user code ---------------------*/
+
+typedef struct {
+ /*--------------------- attributes ---------------------*/
+ int32 Attr1;
+ DataClass2 ComplexAttr;
+ float32 Attr3;
+} DataClass1;
+
+
+
+/*--------------------- operations ---------------------*/
+int32 DataClass1_MultiplyWithAttr1(DataClass1* self, int32 value);
+float32 DataClass1_MultiplyWithAttr3(DataClass1* self, float32 value);
+
+/* deep copy */
+void DataClass1_deepCopy(DataClass1* source, DataClass1* target);
+
+/*--------------------- begin user code ---------------------*/
+// usercode2
+/*--------------------- end user code ---------------------*/
+
+#endif /* _DATACLASS1_H_ */
+
diff --git a/examples/org.eclipse.etrice.generator.c.reference/src-gen-ts/cGenRef/DataClass2.c b/examples/org.eclipse.etrice.generator.c.reference/src-gen-ts/cGenRef/DataClass2.c
new file mode 100644
index 000000000..ab4bbb274
--- /dev/null
+++ b/examples/org.eclipse.etrice.generator.c.reference/src-gen-ts/cGenRef/DataClass2.c
@@ -0,0 +1,24 @@
+/**
+ * @author generated by eTrice
+ *
+ * Source File of DataClass DataClass2
+ *
+ */
+
+#include "DataClass2.h"
+
+#include <string.h>
+
+
+
+/*--------------------- operations ---------------------*/
+void DataClass2_Operation1(DataClass2* self) {
+ /*nothing to do*/
+}
+
+// deep copy
+void DataClass2_deepCopy(DataClass2* source, DataClass2* target) {
+ memcpy(target, source, sizeof(DataClass2));
+}
+
+
diff --git a/examples/org.eclipse.etrice.generator.c.reference/src-gen-ts/cGenRef/DataClass2.h b/examples/org.eclipse.etrice.generator.c.reference/src-gen-ts/cGenRef/DataClass2.h
new file mode 100644
index 000000000..ecfba3a42
--- /dev/null
+++ b/examples/org.eclipse.etrice.generator.c.reference/src-gen-ts/cGenRef/DataClass2.h
@@ -0,0 +1,32 @@
+/**
+ * @author generated by eTrice
+ *
+ * Header File of DataClass DataClass2
+ *
+ */
+
+#ifndef _DATACLASS2_H_
+#define _DATACLASS2_H_
+
+#include "etDatatypes.h"
+
+
+
+typedef struct {
+ /*--------------------- attributes ---------------------*/
+ int32 Attr1;
+ float32 Attr2;
+ int32 Attr3;
+} DataClass2;
+
+
+
+/*--------------------- operations ---------------------*/
+void DataClass2_Operation1(DataClass2* self);
+
+/* deep copy */
+void DataClass2_deepCopy(DataClass2* source, DataClass2* target);
+
+
+#endif /* _DATACLASS2_H_ */
+
diff --git a/examples/org.eclipse.etrice.generator.c.reference/src-gen-ts/cGenRef/Node1.c b/examples/org.eclipse.etrice.generator.c.reference/src-gen-ts/cGenRef/Node1.c
new file mode 100644
index 000000000..098b84220
--- /dev/null
+++ b/examples/org.eclipse.etrice.generator.c.reference/src-gen-ts/cGenRef/Node1.c
@@ -0,0 +1,170 @@
+/**
+ * @author generated by eTrice
+ *
+ * Source File of SubSystemClass SubSys
+ *
+ */
+
+#include "Node1.h"
+
+/* include instances for all classes */
+#include "Node1_Inst.h"
+#include "Node1_Disp.h"
+
+#include "debugging/etLogger.h"
+#include "debugging/etMSCLogger.h"
+
+#include "platform/etTimer.h"
+#include "etRuntimeConfig.h"
+#include "messaging/etMessageService.h"
+
+/* data for Node1 */
+typedef struct Node1 {
+ char *name;
+ volatile int shutdownRequest;
+} Node1;
+
+static Node1 Node1Inst = {"Node1",0};
+
+void Node1_initActorInstances(void);
+void Node1_constructActorInstances(void);
+
+
+void Node1_initMessageServices(void){
+ ET_MSC_LOGGER_SYNC_ENTRY("Node1", "initMessageServices")
+
+ /* filling all message service threads with data */
+ /*PhysicalThread1*/
+ // TODO: gen
+ msgService_PhysicalThread1.thread.stacksize = 1024;
+ msgService_PhysicalThread1.thread.priority = 0;
+ msgService_PhysicalThread1.thread.threadName = "PhysicalThread1";
+ msgService_PhysicalThread1.thread.threadFunction = (etThreadFunction) etMessageService_execute;
+ msgService_PhysicalThread1.thread.threadFunctionData = &msgService_PhysicalThread1;
+
+
+ /*PhysicalThread2*/
+ // TODO: gen
+ msgService_PhysicalThread2.thread.stacksize = 1024;
+ msgService_PhysicalThread2.thread.priority = 0;
+ msgService_PhysicalThread2.thread.threadName = "PhysicalThread2";
+ msgService_PhysicalThread2.thread.threadFunction = (etThreadFunction) etMessageService_execute;
+ msgService_PhysicalThread2.thread.threadFunctionData = &msgService_PhysicalThread2;
+
+ /* initialization of all message services */
+ etMessageService_init(&msgService_PhysicalThread1, msgBuffer_PhysicalThread1, MESSAGE_POOL_MAX, MESSAGE_BLOCK_SIZE, MsgDispatcher_PhysicalThread1_receiveMessage);
+ etMessageService_init(&msgService_PhysicalThread2, msgBuffer_PhysicalThread2, MESSAGE_POOL_MAX, MESSAGE_BLOCK_SIZE, MsgDispatcher_PhysicalThread2_receiveMessage);
+
+ ET_MSC_LOGGER_SYNC_EXIT
+}
+
+void Node1_startMessageServices(void){
+ ET_MSC_LOGGER_SYNC_ENTRY("Node1", "startMessageServices")
+
+ etMessageService_start(&msgService_PhysicalThread1);
+ etMessageService_start(&msgService_PhysicalThread2);
+
+ ET_MSC_LOGGER_SYNC_EXIT
+}
+
+void Node1_stopMessageServices(void){
+ ET_MSC_LOGGER_SYNC_ENTRY("Node1", "stopMessageServices")
+
+ etMessageService_stop(&msgService_PhysicalThread1);
+ etMessageService_stop(&msgService_PhysicalThread2);
+
+ ET_MSC_LOGGER_SYNC_EXIT
+}
+
+void Node1_destroyMessageServices(void){
+ ET_MSC_LOGGER_SYNC_ENTRY("Node1", "destroyMessageServices")
+
+ etMessageService_destroy(&msgService_PhysicalThread1);
+ etMessageService_destroy(&msgService_PhysicalThread2);
+
+ ET_MSC_LOGGER_SYNC_EXIT
+}
+
+void Node1_init(void){
+ ET_MSC_LOGGER_SYNC_ENTRY("Node1", "init")
+ etLogger_logInfoF("%s_init", Node1Inst.name);
+
+ /* construct all actors */
+ Node1_constructActorInstances();
+
+ Node1_initMessageServices();
+
+ /* init all actors */
+ Node1_initActorInstances();
+
+ ET_MSC_LOGGER_SYNC_EXIT
+}
+
+void Node1_start(void){
+ ET_MSC_LOGGER_SYNC_ENTRY("Node1", "start")
+ etLogger_logInfoF("%s_start", Node1Inst.name);
+ Node1_startMessageServices();
+ ET_MSC_LOGGER_SYNC_EXIT
+}
+
+void Node1_run(void){
+ ET_MSC_LOGGER_SYNC_ENTRY("Node1", "run")
+
+ etThread_sleep(1000);
+
+// #ifdef ET_RUNTIME_ENDLESS
+// while(!(Node1Inst.shutdownRequest)){
+// if (etTimer_executeNeeded()){
+// etMessageService_execute(&msgService_PhysicalThread1);
+// }
+// }
+// #else
+// uint32 loopCounter = 0;
+// while(!(Node1Inst.shutdownRequest)){
+// if (etTimer_executeNeeded()){
+// etMessageService_execute(&msgService_PhysicalThread1);
+// etLogger_logInfo("Execute");
+// if (loopCounter++ > ET_RUNTIME_MAXLOOP){
+// break;
+// }
+// }
+// }
+// #endif
+
+ ET_MSC_LOGGER_SYNC_EXIT
+}
+
+void Node1_stop(void){
+ ET_MSC_LOGGER_SYNC_ENTRY("Node1", "stop")
+ etLogger_logInfoF("%s_stop", Node1Inst.name);
+ Node1_stopMessageServices();
+ ET_MSC_LOGGER_SYNC_EXIT
+}
+
+void Node1_destroy(void){
+ ET_MSC_LOGGER_SYNC_ENTRY("Node1", "destroy")
+ etLogger_logInfoF("%s_destroy", Node1Inst.name);
+ Node1_destroyMessageServices();
+ ET_MSC_LOGGER_SYNC_EXIT
+}
+
+void Node1_shutdown(void){
+ ET_MSC_LOGGER_SYNC_ENTRY("Node1", "shutdown")
+ etLogger_logInfoF("%s_shutdown", Node1Inst.name);
+ Node1Inst.shutdownRequest = 1;
+ ET_MSC_LOGGER_SYNC_EXIT
+}
+
+
+void Node1_constructActorInstances(void){
+ ET_MSC_LOGGER_SYNC_ENTRY("Node1", "constructActorInstances")
+ ET_MSC_LOGGER_SYNC_EXIT
+}
+
+void Node1_initActorInstances(void){
+ ET_MSC_LOGGER_SYNC_ENTRY("Node1", "initActorInstances")
+ Sender_init(&_SubSys_Sender);
+ Receiver_init(&_SubSys_Receiver);
+ ET_MSC_LOGGER_SYNC_EXIT
+}
+
diff --git a/examples/org.eclipse.etrice.generator.c.reference/src-gen-ts/cGenRef/Node1.h b/examples/org.eclipse.etrice.generator.c.reference/src-gen-ts/cGenRef/Node1.h
new file mode 100644
index 000000000..7fce4d2cb
--- /dev/null
+++ b/examples/org.eclipse.etrice.generator.c.reference/src-gen-ts/cGenRef/Node1.h
@@ -0,0 +1,30 @@
+/**
+ * @author generated by eTrice
+ *
+ * Header File of SubSystemClass SubSys
+ *
+ */
+
+#ifndef _NODE1_H_
+#define _NODE1_H_
+
+
+
+/* lifecycle functions
+ * init -> start -> run (loop) -> stop -> destroy
+ */
+
+void Node1_init(void); /* lifecycle init */
+void Node1_start(void); /* lifecycle start */
+
+void Node1_run(void); /* lifecycle run */
+
+void Node1_stop(void); /* lifecycle stop */
+void Node1_destroy(void); /* lifecycle destroy */
+
+void Node1_shutdown(void); /* shutdown the dispatcher loop */
+
+
+#endif /* _NODE1_H_ */
+
+
diff --git a/examples/org.eclipse.etrice.generator.c.reference/src-gen-ts/cGenRef/Node1_Disp.h b/examples/org.eclipse.etrice.generator.c.reference/src-gen-ts/cGenRef/Node1_Disp.h
new file mode 100644
index 000000000..38c3df51f
--- /dev/null
+++ b/examples/org.eclipse.etrice.generator.c.reference/src-gen-ts/cGenRef/Node1_Disp.h
@@ -0,0 +1,43 @@
+/**
+ * @author generated by eTrice
+ *
+ * Dispatcher File of SubSystemClass SubSys
+ * - one generated dispatcher for each MessageService (Thread)
+ */
+
+#include "messaging/etMessageReceiver.h"
+#include "debugging/etLogger.h"
+#include "debugging/etMSCLogger.h"
+
+static void MsgDispatcher_PhysicalThread1_receiveMessage(const etMessage* msg){
+ ET_MSC_LOGGER_SYNC_ENTRY("MsgDispatcher_PhysicalThread1", "receiveMessage")
+ switch(msg->address){
+
+ /* interface items of /SubSys/Sender */
+ case 102:
+ Sender_receiveMessage((void*)&_SubSys_Sender,(etPort*)&_SubSys_Sender_const.dataOut, msg);
+ break;
+
+ default:
+ etLogger_logErrorF("MessageService_Thread1_receiveMessage: address %d does not exist ", msg->address);
+ break;
+ }
+ ET_MSC_LOGGER_SYNC_EXIT
+}
+
+static void MsgDispatcher_PhysicalThread2_receiveMessage(const etMessage* msg){
+ ET_MSC_LOGGER_SYNC_ENTRY("MsgDispatcher_PhysicalThread2", "receiveMessage")
+ switch(msg->address){
+
+ /* interface items of /SubSys/Receiver */
+ case 104:
+ Receiver_receiveMessage((void*)&_SubSys_Receiver,(etPort*)&_SubSys_Receiver_const.dataIn, msg);
+ break;
+
+ default:
+ etLogger_logErrorF("MessageService_Thread1_receiveMessage: address %d does not exist ", msg->address);
+ break;
+ }
+ ET_MSC_LOGGER_SYNC_EXIT
+}
+
diff --git a/examples/org.eclipse.etrice.generator.c.reference/src-gen-ts/cGenRef/Node1_Inst.h b/examples/org.eclipse.etrice.generator.c.reference/src-gen-ts/cGenRef/Node1_Inst.h
new file mode 100644
index 000000000..75c0d0cbf
--- /dev/null
+++ b/examples/org.eclipse.etrice.generator.c.reference/src-gen-ts/cGenRef/Node1_Inst.h
@@ -0,0 +1,81 @@
+/**
+ * @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 "platform/etMemory.h"
+
+/* include all used ActorClasses */
+#include "Receiver.h"
+#include "Sender.h"
+
+/* include all used ProtcolClasses */
+#include "CommunicationProtocol.h"
+
+
+/* instantiation of message services */
+/* PhysicalThread1 */
+// TODO: generate sizes
+static uint8 msgBuffer_PhysicalThread1[MESSAGE_POOL_MAX*MESSAGE_BLOCK_SIZE];
+static etMessageService msgService_PhysicalThread1;
+
+/* PhysicalThread2 */
+static uint8 msgBuffer_PhysicalThread2[MESSAGE_POOL_MAX*MESSAGE_BLOCK_SIZE];
+static etMessageService msgService_PhysicalThread2;
+
+/* declarations of all ActorClass instances (const and variable structs) */
+
+/* forward declaration of variable actor structs */
+static Sender _SubSys_Sender;
+static Receiver _SubSys_Receiver;
+
+/* forward declaration of variable port structs */
+
+
+/* instance _SubSys_Sender */
+static const Sender_const _SubSys_Sender_const = {
+ /* Ports: {varData, msgService, peerAddress, localId} */
+ {0,&msgService_PhysicalThread2, 104, 1} /* Port dataOut */
+
+ /* data receive ports */
+};
+static Sender _SubSys_Sender = {
+ &_SubSys_Sender_const,
+
+ /* data send ports */
+
+ /* attributes */
+
+ /* state and history are initialized in init fuction */
+};
+
+/* instance _SubSys_Receiver */
+static const Receiver_const _SubSys_Receiver_const = {
+ /* Ports: {varData, msgService, peerAddress, localId} */
+ {0,&msgService_PhysicalThread1, 102, 1} /* Port dataIn */
+
+ /* data receive ports */
+};
+static Receiver _SubSys_Receiver = {
+ &_SubSys_Receiver_const,
+
+ /* data send ports */
+
+ /* attributes */
+ {
+ 0,
+ {
+ 0,
+ 0,
+ 0
+ },
+ 0
+ }
+ , /* attr1 */
+
+ /* state and history are initialized in init fuction */
+};
+
diff --git a/examples/org.eclipse.etrice.generator.c.reference/src-gen-ts/cGenRef/Receiver.c b/examples/org.eclipse.etrice.generator.c.reference/src-gen-ts/cGenRef/Receiver.c
new file mode 100644
index 000000000..02fc5f28f
--- /dev/null
+++ b/examples/org.eclipse.etrice.generator.c.reference/src-gen-ts/cGenRef/Receiver.c
@@ -0,0 +1,199 @@
+/**
+ * @author generated by eTrice
+ *
+ * Source File of ActorClass Receiver
+ *
+ */
+
+#include "Receiver.h"
+
+#include "modelbase/etActor.h"
+#include "debugging/etLogger.h"
+#include "debugging/etMSCLogger.h"
+#include "etUnit/etUnit.h"
+#include "platform/etMemory.h"
+
+#include "CommunicationProtocol.h"
+
+
+/* interface item IDs */
+enum interface_items {
+ IFITEM_dataIn = 1
+};
+
+
+/* state IDs */
+enum state_ids {
+ NO_STATE = 0,
+ STATE_TOP = 1,
+ STATE_Idle = 2,
+ STATE_DataReceived = 3
+};
+
+static char* state_names[] = {
+ "NO_STATE", "TOP", "Idle", "DataReceived"
+};
+
+/* transition chains */
+enum chain_ids {
+ CHAIN_TRANS_INITIAL_TO__Idle = 1,
+ CHAIN_TRANS_tr0_FROM_Idle_TO_DataReceived_BY_sendDatadataIn = 2
+};
+
+/* triggers */
+enum triggers {
+ POLLING = 0,
+ TRIG_dataIn__sendData = IFITEM_dataIn + EVT_SHIFT*CommunicationProtocol_IN_sendData
+};
+
+
+static void setState(Receiver* self, int new_state) {
+ etLogger_logInfoF("Receiver: setState: new state=%d", new_state);
+ ET_MSC_LOGGER_CHANGE_STATE("Receiver", state_names[new_state]);
+ self->state = new_state;
+}
+
+/* Entry and Exit Codes */
+
+/* Action Codes */
+static void action_TRANS_tr0_FROM_Idle_TO_DataReceived_BY_sendDatadataIn(Receiver* self, InterfaceItemBase *ifitem) {
+ CommunicationProtocolPort_receivedData(&self->constData->dataIn) /* ORIG: dataIn.receivedData() */;
+}
+
+/**
+ * calls exit codes while exiting from the current state to one of its
+ * parent states while remembering the history
+ * @param current - the current state
+ * @param to - the final parent state
+ * @param handler - entry and exit codes are called only if not handler (for handler TransitionPoints)
+ */
+static void exitTo(Receiver* self, int current, int to, boolean handler) {
+ while (current!=to) {
+ switch (current) {
+ case STATE_Idle:
+ self->history[STATE_TOP] = STATE_Idle;
+ current = STATE_TOP;
+ break;
+ case STATE_DataReceived:
+ self->history[STATE_TOP] = STATE_DataReceived;
+ current = STATE_TOP;
+ break;
+ }
+ }
+}
+
+/**
+ * calls action, entry and exit codes along a transition chain. The generic data are cast to typed data
+ * matching the trigger of this chain. The ID of the final state is returned
+ * @param chain - the chain ID
+ * @param generic_data - the generic data pointer
+ * @return the ID of the final state
+ */
+static int executeTransitionChain(Receiver* self, int chain, InterfaceItemBase *ifitem, void* generic_data) {
+ switch (chain) {
+ case CHAIN_TRANS_INITIAL_TO__Idle:
+ {
+ return STATE_Idle;
+ }
+ case CHAIN_TRANS_tr0_FROM_Idle_TO_DataReceived_BY_sendDatadataIn:
+ {
+ action_TRANS_tr0_FROM_Idle_TO_DataReceived_BY_sendDatadataIn(self, ifitem);
+ return STATE_DataReceived;
+ }
+ }
+ return NO_STATE;
+}
+
+/**
+ * calls entry codes while entering a state's history. The ID of the final leaf state is returned
+ * @param state - the state which is entered
+ * @param handler - entry code is executed if not handler
+ * @return - the ID of the final leaf state
+ */
+static int enterHistory(Receiver* self, int state, boolean handler, boolean skip_entry) {
+ while (TRUE) {
+ switch (state) {
+ case STATE_Idle:
+ // in leaf state: return state id
+ return STATE_Idle;
+ case STATE_DataReceived:
+ // in leaf state: return state id
+ return STATE_DataReceived;
+ case STATE_TOP:
+ state = self->history[STATE_TOP];
+ break;
+ }
+ skip_entry = FALSE;
+ }
+ //return NO_STATE; // required by CDT but detected as unreachable by JDT because of while (true)
+}
+
+static void executeInitTransition(Receiver* self) {
+ int chain = CHAIN_TRANS_INITIAL_TO__Idle;
+ int next = executeTransitionChain(self, chain, NULL, NULL);
+ next = enterHistory(self, next, FALSE, FALSE);
+ setState(self, next);
+}
+
+/* receiveEvent contains the main implementation of the FSM */
+static void receiveEvent(Receiver* self, InterfaceItemBase *ifitem, int evt, void* generic_data) {
+ int trigger = ifitem->localId + EVT_SHIFT*evt;
+ int chain = NOT_CAUGHT;
+ int catching_state = NO_STATE;
+ boolean is_handler = FALSE;
+ boolean skip_entry = FALSE;
+ ET_MSC_LOGGER_SYNC_ENTRY("Receiver", "receiveEvent")
+
+ if (!handleSystemEvent(ifitem, evt, generic_data)) {
+ switch (self->state) {
+ case STATE_Idle:
+ switch(trigger) {
+ case TRIG_dataIn__sendData:
+ {
+ chain = CHAIN_TRANS_tr0_FROM_Idle_TO_DataReceived_BY_sendDatadataIn;
+ catching_state = STATE_TOP;
+ }
+ break;
+ }
+ break;
+ case STATE_DataReceived:
+ break;
+ }
+ }
+ if (chain != NOT_CAUGHT) {
+ exitTo(self, self->state, catching_state, is_handler);
+ int next = executeTransitionChain(self, chain, ifitem, generic_data);
+ next = enterHistory(self, next, is_handler, skip_entry);
+ setState(self, next);
+ }
+ ET_MSC_LOGGER_SYNC_EXIT
+}
+
+//******************************************
+// END of generated code for FSM
+//******************************************
+
+void Receiver_init(Receiver* self){
+ ET_MSC_LOGGER_SYNC_ENTRY("Receiver", "init")
+ self->state = STATE_TOP;
+ {
+ int i;
+ for (i=0; i<RECEIVER_HISTORY_SIZE; ++i)
+ self->history[i] = NO_STATE;
+ }
+ executeInitTransition(self);
+ ET_MSC_LOGGER_SYNC_EXIT
+}
+
+
+void Receiver_receiveMessage(void* self, void* ifitem, const etMessage* msg){
+ ET_MSC_LOGGER_SYNC_ENTRY("Receiver", "receiveMessage")
+
+ receiveEvent(self, (etPort*)ifitem, msg->evtID, (void*)(((char*)msg)+MEM_CEIL(sizeof(etMessage))));
+
+ ET_MSC_LOGGER_SYNC_EXIT
+}
+
+
+/*--------------------- operations ---------------------*/
+
diff --git a/examples/org.eclipse.etrice.generator.c.reference/src-gen-ts/cGenRef/Receiver.h b/examples/org.eclipse.etrice.generator.c.reference/src-gen-ts/cGenRef/Receiver.h
new file mode 100644
index 000000000..6806a7d96
--- /dev/null
+++ b/examples/org.eclipse.etrice.generator.c.reference/src-gen-ts/cGenRef/Receiver.h
@@ -0,0 +1,62 @@
+/**
+ * @author generated by eTrice
+ *
+ * Header File of ActorClass Receiver
+ *
+ */
+
+#ifndef _RECEIVER_H_
+#define _RECEIVER_H_
+
+#include "etDatatypes.h"
+#include "messaging/etMessage.h"
+
+#include "DataClass1.h"
+#include "CommunicationProtocol.h"
+
+
+typedef struct Receiver Receiver;
+
+/* const part of ActorClass (ROM) */
+typedef struct Receiver_const {
+ /* simple ports */
+ const CommunicationProtocolPort dataIn;
+
+ /* data receive ports */
+
+ /* saps */
+
+ /* replicated ports */
+
+ /* services */
+} Receiver_const;
+
+
+/* constant for state machine data */
+#define RECEIVER_HISTORY_SIZE 2
+
+/* variable part of ActorClass (RAM) */
+struct Receiver {
+ const Receiver_const* const constData;
+
+ /* data send ports */
+
+ /*--------------------- attributes ---------------------*/
+ DataClass1 attr1;
+
+
+ /* state machine variables */
+ etInt16 state;
+ etInt16 history[RECEIVER_HISTORY_SIZE];
+};
+
+void Receiver_init(Receiver* self);
+
+void Receiver_receiveMessage(void* self, void* ifitem, const etMessage* msg);
+
+
+/*--------------------- operations ---------------------*/
+
+
+#endif /* _RECEIVER_H_ */
+
diff --git a/examples/org.eclipse.etrice.generator.c.reference/src-gen-ts/cGenRef/Sender.c b/examples/org.eclipse.etrice.generator.c.reference/src-gen-ts/cGenRef/Sender.c
new file mode 100644
index 000000000..ac71335e8
--- /dev/null
+++ b/examples/org.eclipse.etrice.generator.c.reference/src-gen-ts/cGenRef/Sender.c
@@ -0,0 +1,197 @@
+/**
+ * @author generated by eTrice
+ *
+ * Source File of ActorClass Sender
+ *
+ */
+
+#include "Sender.h"
+
+#include "modelbase/etActor.h"
+#include "debugging/etLogger.h"
+#include "debugging/etMSCLogger.h"
+#include "etUnit/etUnit.h"
+#include "platform/etMemory.h"
+
+#include "CommunicationProtocol.h"
+
+
+/* interface item IDs */
+enum interface_items {
+ IFITEM_dataOut = 1
+};
+
+
+/* state IDs */
+enum state_ids {
+ NO_STATE = 0,
+ STATE_TOP = 1,
+ STATE_SendingData = 2,
+ STATE_Done = 3
+};
+
+static char* state_names[] = {
+ "NO_STATE", "TOP", "SendingData", "Done"
+};
+
+/* transition chains */
+enum chain_ids {
+ CHAIN_TRANS_INITIAL_TO__SendingData = 1,
+ CHAIN_TRANS_tr0_FROM_SendingData_TO_Done_BY_receivedDatadataOut = 2
+};
+
+/* triggers */
+enum triggers {
+ POLLING = 0,
+ TRIG_dataOut__receivedData = IFITEM_dataOut + EVT_SHIFT*CommunicationProtocol_OUT_receivedData
+};
+
+
+static void setState(Sender* self, int new_state) {
+ etLogger_logInfoF("Sender: setState: new state=%d", new_state);
+ ET_MSC_LOGGER_CHANGE_STATE("Sender", state_names[new_state]);
+ self->state = new_state;
+}
+
+/* Entry and Exit Codes */
+static void entry_SendingData(Sender* self) {
+ CommunicationProtocolConjPort_sendData(&self->constData->dataOut) /* ORIG: dataOut.sendData() */;
+}
+
+/* Action Codes */
+
+/**
+ * calls exit codes while exiting from the current state to one of its
+ * parent states while remembering the history
+ * @param current - the current state
+ * @param to - the final parent state
+ * @param handler - entry and exit codes are called only if not handler (for handler TransitionPoints)
+ */
+static void exitTo(Sender* self, int current, int to, boolean handler) {
+ while (current!=to) {
+ switch (current) {
+ case STATE_SendingData:
+ self->history[STATE_TOP] = STATE_SendingData;
+ current = STATE_TOP;
+ break;
+ case STATE_Done:
+ self->history[STATE_TOP] = STATE_Done;
+ current = STATE_TOP;
+ break;
+ }
+ }
+}
+
+/**
+ * calls action, entry and exit codes along a transition chain. The generic data are cast to typed data
+ * matching the trigger of this chain. The ID of the final state is returned
+ * @param chain - the chain ID
+ * @param generic_data - the generic data pointer
+ * @return the ID of the final state
+ */
+static int executeTransitionChain(Sender* self, int chain, InterfaceItemBase* ifitem, void* generic_data) {
+ switch (chain) {
+ case CHAIN_TRANS_INITIAL_TO__SendingData:
+ {
+ return STATE_SendingData;
+ }
+ case CHAIN_TRANS_tr0_FROM_SendingData_TO_Done_BY_receivedDatadataOut:
+ {
+ return STATE_Done;
+ }
+ }
+ return NO_STATE;
+}
+
+/**
+ * calls entry codes while entering a state's history. The ID of the final leaf state is returned
+ * @param state - the state which is entered
+ * @param handler - entry code is executed if not handler
+ * @return - the ID of the final leaf state
+ */
+static int enterHistory(Sender* self, int state, boolean handler, boolean skip_entry) {
+ while (TRUE) {
+ switch (state) {
+ case STATE_SendingData:
+ if (!(skip_entry || handler)) entry_SendingData(self);
+ // in leaf state: return state id
+ return STATE_SendingData;
+ case STATE_Done:
+ // in leaf state: return state id
+ return STATE_Done;
+ case STATE_TOP:
+ state = self->history[STATE_TOP];
+ break;
+ }
+ skip_entry = FALSE;
+ }
+ //return NO_STATE; // required by CDT but detected as unreachable by JDT because of while (true)
+}
+
+static void executeInitTransition(Sender* self) {
+ int chain = CHAIN_TRANS_INITIAL_TO__SendingData;
+ int next = executeTransitionChain(self, chain, NULL, NULL);
+ next = enterHistory(self, next, FALSE, FALSE);
+ setState(self, next);
+}
+
+/* receiveEvent contains the main implementation of the FSM */
+static void receiveEvent(Sender* self, InterfaceItemBase *ifitem, int evt, void* generic_data) {
+ int trigger = ifitem->localId + EVT_SHIFT*evt;
+ int chain = NOT_CAUGHT;
+ int catching_state = NO_STATE;
+ boolean is_handler = FALSE;
+ boolean skip_entry = FALSE;
+
+ if (!handleSystemEvent(ifitem, evt, generic_data)) {
+ switch (self->state) {
+ case STATE_SendingData:
+ switch(trigger) {
+ case TRIG_dataOut__receivedData:
+ {
+ chain = CHAIN_TRANS_tr0_FROM_SendingData_TO_Done_BY_receivedDatadataOut;
+ catching_state = STATE_TOP;
+ }
+ break;
+ }
+ break;
+ case STATE_Done:
+ break;
+ }
+ }
+ if (chain != NOT_CAUGHT) {
+ exitTo(self, self->state, catching_state, is_handler);
+ int next = executeTransitionChain(self, chain, ifitem, generic_data);
+ next = enterHistory(self, next, is_handler, skip_entry);
+ setState(self, next);
+ }
+}
+
+//******************************************
+// END of generated code for FSM
+//******************************************
+
+void Sender_init(Sender* self){
+ ET_MSC_LOGGER_SYNC_ENTRY("Sender", "init")
+ self->state = STATE_TOP;
+ {
+ int i;
+ for (i=0; i<SENDER_HISTORY_SIZE; ++i)
+ self->history[i] = NO_STATE;
+ }
+ executeInitTransition(self);
+ ET_MSC_LOGGER_SYNC_EXIT
+}
+
+
+void Sender_receiveMessage(void* self, void* ifitem, const etMessage* msg){
+ ET_MSC_LOGGER_SYNC_ENTRY("Sender", "_receiveMessage")
+
+ receiveEvent(self, (etPort*)ifitem, msg->evtID, (void*)(((char*)msg)+MEM_CEIL(sizeof(etMessage))));
+
+ ET_MSC_LOGGER_SYNC_EXIT
+}
+
+
+/*--------------------- operations ---------------------*/
+
diff --git a/examples/org.eclipse.etrice.generator.c.reference/src-gen-ts/cGenRef/Sender.h b/examples/org.eclipse.etrice.generator.c.reference/src-gen-ts/cGenRef/Sender.h
new file mode 100644
index 000000000..50b982497
--- /dev/null
+++ b/examples/org.eclipse.etrice.generator.c.reference/src-gen-ts/cGenRef/Sender.h
@@ -0,0 +1,60 @@
+/**
+ * @author generated by eTrice
+ *
+ * Header File of ActorClass Sender
+ *
+ */
+
+#ifndef _SENDER_H_
+#define _SENDER_H_
+
+#include "etDatatypes.h"
+#include "messaging/etMessage.h"
+
+#include "CommunicationProtocol.h"
+
+
+typedef struct Sender Sender;
+
+/* const part of ActorClass (ROM) */
+typedef struct Sender_const {
+ /* simple ports */
+ const CommunicationProtocolConjPort dataOut;
+
+ /* data receive ports */
+
+ /* saps */
+
+ /* replicated ports */
+
+ /* services */
+} Sender_const;
+
+
+/* constant for state machine data */
+#define SENDER_HISTORY_SIZE 2
+
+/* variable part of ActorClass (RAM) */
+struct Sender {
+ const Sender_const* const constData;
+
+ /* data send ports */
+
+ /*--------------------- attributes ---------------------*/
+
+
+ /* state machine variables */
+ etInt16 state;
+ etInt16 history[SENDER_HISTORY_SIZE];
+};
+
+void Sender_init(Sender* self);
+
+void Sender_receiveMessage(void* self, void* ifitem, const etMessage* msg);
+
+
+/*--------------------- operations ---------------------*/
+
+
+#endif /* _SENDER_H_ */
+
diff --git a/examples/org.eclipse.etrice.generator.c.reference/src-gen-ts/cGenRef/SubSys_Runner.c b/examples/org.eclipse.etrice.generator.c.reference/src-gen-ts/cGenRef/SubSys_Runner.c
new file mode 100644
index 000000000..12b91ea00
--- /dev/null
+++ b/examples/org.eclipse.etrice.generator.c.reference/src-gen-ts/cGenRef/SubSys_Runner.c
@@ -0,0 +1,49 @@
+/**
+ * @author generated by eTrice
+ *
+ * this class contains the main function running component SubSys
+ * it instantiates SubSys and starts and ends the lifecycle
+ */
+
+
+#include "Node1.h"
+
+#include "debugging/etLogger.h"
+#include "debugging/etMSCLogger.h"
+#include "platform/etPlatform.h"
+
+
+/**
+ * main function
+ * creates component and starts and stops the lifecycle
+ */
+
+int main(void) {
+ etUserEntry(); /* platform specific */
+
+ etLogger_logInfo("*** T H E B E G I N ***");
+ ET_MSC_LOGGER_OPEN("main");
+
+ /* startup sequence of lifecycle */
+ Node1_init(); /* lifecycle init */
+ Node1_start(); /* lifecycle start */
+
+ etUserPreRun(); /* platform specific */
+
+ /* run Scheduler */
+ Node1_run();
+
+ etUserPostRun(); /* platform specific */
+
+ /* shutdown sequence of lifecycle */
+ Node1_stop(); /* lifecycle stop */
+ Node1_destroy(); /* lifecycle destroy */
+
+ ET_MSC_LOGGER_CLOSE
+ etLogger_logInfo("*** T H E E N D ***");
+
+ etUserExit(); /* platform specific */
+
+ return 0;
+}
+
diff --git a/examples/org.eclipse.etrice.generator.c.reference/src-gen-ts/readme.txt b/examples/org.eclipse.etrice.generator.c.reference/src-gen-ts/readme.txt
new file mode 100644
index 000000000..c3b99d458
--- /dev/null
+++ b/examples/org.eclipse.etrice.generator.c.reference/src-gen-ts/readme.txt
@@ -0,0 +1,4 @@
+This directory is an eTrice code generation target.
+It will be erased every time the generator is executed.
+
+DO NOT PLACE OTHER FILES HERE!

Back to the top