summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Schuetz2013-01-04 19:00:51 (EST)
committerThomas Schuetz2013-01-04 19:00:51 (EST)
commiteb28454f2975f5747427be583bfc89b0796265d4 (patch)
tree7a2660cf67bfa629673da0243da42d973ffeebb0
parentd098da1cde5c178c682c57533e514b3e4976250e (diff)
downloadorg.eclipse.etrice-eb28454f2975f5747427be583bfc89b0796265d4.zip
org.eclipse.etrice-eb28454f2975f5747427be583bfc89b0796265d4.tar.gz
org.eclipse.etrice-eb28454f2975f5747427be583bfc89b0796265d4.tar.bz2
[runtime.c , generator.c.reference] added src-gen folder with reference
code, synchronization for push and pop Change-Id: I03ca0251e622d862a34cfabc00dd615af7228160
-rw-r--r--examples/org.eclipse.etrice.generator.c.reference/.gitignore1
-rw-r--r--examples/org.eclipse.etrice.generator.c.reference/doc/physical-mapping.txt6
-rw-r--r--examples/org.eclipse.etrice.generator.c.reference/src-gen/cGenRef/CommunicationProtocol.c89
-rw-r--r--examples/org.eclipse.etrice.generator.c.reference/src-gen/cGenRef/CommunicationProtocol.h54
-rw-r--r--examples/org.eclipse.etrice.generator.c.reference/src-gen/cGenRef/DataClass1.c30
-rw-r--r--examples/org.eclipse.etrice.generator.c.reference/src-gen/cGenRef/DataClass1.h40
-rw-r--r--examples/org.eclipse.etrice.generator.c.reference/src-gen/cGenRef/DataClass2.c24
-rw-r--r--examples/org.eclipse.etrice.generator.c.reference/src-gen/cGenRef/DataClass2.h32
-rw-r--r--examples/org.eclipse.etrice.generator.c.reference/src-gen/cGenRef/Node1.c170
-rw-r--r--examples/org.eclipse.etrice.generator.c.reference/src-gen/cGenRef/Node1.h30
-rw-r--r--examples/org.eclipse.etrice.generator.c.reference/src-gen/cGenRef/Node1_Disp.h43
-rw-r--r--examples/org.eclipse.etrice.generator.c.reference/src-gen/cGenRef/Node1_Inst.h81
-rw-r--r--examples/org.eclipse.etrice.generator.c.reference/src-gen/cGenRef/Receiver.c199
-rw-r--r--examples/org.eclipse.etrice.generator.c.reference/src-gen/cGenRef/Receiver.h62
-rw-r--r--examples/org.eclipse.etrice.generator.c.reference/src-gen/cGenRef/Sender.c197
-rw-r--r--examples/org.eclipse.etrice.generator.c.reference/src-gen/cGenRef/Sender.h60
-rw-r--r--examples/org.eclipse.etrice.generator.c.reference/src-gen/cGenRef/SubSys_Runner.c49
-rw-r--r--examples/org.eclipse.etrice.generator.c.reference/tmp/msc.seq71
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessageService.c20
19 files changed, 1234 insertions, 24 deletions
diff --git a/examples/org.eclipse.etrice.generator.c.reference/.gitignore b/examples/org.eclipse.etrice.generator.c.reference/.gitignore
index bb84fd7..c46a13e 100644
--- a/examples/org.eclipse.etrice.generator.c.reference/.gitignore
+++ b/examples/org.eclipse.etrice.generator.c.reference/.gitignore
@@ -1,4 +1,3 @@
Debug
Release
-src-gen/*
!src-gen/readme.txt
diff --git a/examples/org.eclipse.etrice.generator.c.reference/doc/physical-mapping.txt b/examples/org.eclipse.etrice.generator.c.reference/doc/physical-mapping.txt
index 8089649..6231ad0 100644
--- a/examples/org.eclipse.etrice.generator.c.reference/doc/physical-mapping.txt
+++ b/examples/org.eclipse.etrice.generator.c.reference/doc/physical-mapping.txt
@@ -9,4 +9,10 @@ rename SubSysDisp -> NodeINstance_Disp.h
destruct functions for platform API and stop and destroy for message service -> implement for etSema
+Shutdown
+push / pop synchronization -> auch bei shutdown
+Logger / MSC-Logger Synchronization
+MSC Logger with Instances
+
+runtime.java : private synchronized void pollOneMessage() -> sync not needed any more
diff --git a/examples/org.eclipse.etrice.generator.c.reference/src-gen/cGenRef/CommunicationProtocol.c b/examples/org.eclipse.etrice.generator.c.reference/src-gen/cGenRef/CommunicationProtocol.c
new file mode 100644
index 0000000..63831f3
--- /dev/null
+++ b/examples/org.eclipse.etrice.generator.c.reference/src-gen/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/cGenRef/CommunicationProtocol.h b/examples/org.eclipse.etrice.generator.c.reference/src-gen/cGenRef/CommunicationProtocol.h
new file mode 100644
index 0000000..7fd2bf5
--- /dev/null
+++ b/examples/org.eclipse.etrice.generator.c.reference/src-gen/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/cGenRef/DataClass1.c b/examples/org.eclipse.etrice.generator.c.reference/src-gen/cGenRef/DataClass1.c
new file mode 100644
index 0000000..5ff2a95
--- /dev/null
+++ b/examples/org.eclipse.etrice.generator.c.reference/src-gen/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/cGenRef/DataClass1.h b/examples/org.eclipse.etrice.generator.c.reference/src-gen/cGenRef/DataClass1.h
new file mode 100644
index 0000000..4f3176f
--- /dev/null
+++ b/examples/org.eclipse.etrice.generator.c.reference/src-gen/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/cGenRef/DataClass2.c b/examples/org.eclipse.etrice.generator.c.reference/src-gen/cGenRef/DataClass2.c
new file mode 100644
index 0000000..ab4bbb2
--- /dev/null
+++ b/examples/org.eclipse.etrice.generator.c.reference/src-gen/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/cGenRef/DataClass2.h b/examples/org.eclipse.etrice.generator.c.reference/src-gen/cGenRef/DataClass2.h
new file mode 100644
index 0000000..ecfba3a
--- /dev/null
+++ b/examples/org.eclipse.etrice.generator.c.reference/src-gen/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/cGenRef/Node1.c b/examples/org.eclipse.etrice.generator.c.reference/src-gen/cGenRef/Node1.c
new file mode 100644
index 0000000..3e1e7e1
--- /dev/null
+++ b/examples/org.eclipse.etrice.generator.c.reference/src-gen/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 SubSysten SubSys */
+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/cGenRef/Node1.h b/examples/org.eclipse.etrice.generator.c.reference/src-gen/cGenRef/Node1.h
new file mode 100644
index 0000000..7fce4d2
--- /dev/null
+++ b/examples/org.eclipse.etrice.generator.c.reference/src-gen/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/cGenRef/Node1_Disp.h b/examples/org.eclipse.etrice.generator.c.reference/src-gen/cGenRef/Node1_Disp.h
new file mode 100644
index 0000000..38c3df5
--- /dev/null
+++ b/examples/org.eclipse.etrice.generator.c.reference/src-gen/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/cGenRef/Node1_Inst.h b/examples/org.eclipse.etrice.generator.c.reference/src-gen/cGenRef/Node1_Inst.h
new file mode 100644
index 0000000..75c0d0c
--- /dev/null
+++ b/examples/org.eclipse.etrice.generator.c.reference/src-gen/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/cGenRef/Receiver.c b/examples/org.eclipse.etrice.generator.c.reference/src-gen/cGenRef/Receiver.c
new file mode 100644
index 0000000..02fc5f2
--- /dev/null
+++ b/examples/org.eclipse.etrice.generator.c.reference/src-gen/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/cGenRef/Receiver.h b/examples/org.eclipse.etrice.generator.c.reference/src-gen/cGenRef/Receiver.h
new file mode 100644
index 0000000..6806a7d
--- /dev/null
+++ b/examples/org.eclipse.etrice.generator.c.reference/src-gen/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/cGenRef/Sender.c b/examples/org.eclipse.etrice.generator.c.reference/src-gen/cGenRef/Sender.c
new file mode 100644
index 0000000..ac71335
--- /dev/null
+++ b/examples/org.eclipse.etrice.generator.c.reference/src-gen/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/cGenRef/Sender.h b/examples/org.eclipse.etrice.generator.c.reference/src-gen/cGenRef/Sender.h
new file mode 100644
index 0000000..50b9824
--- /dev/null
+++ b/examples/org.eclipse.etrice.generator.c.reference/src-gen/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/cGenRef/SubSys_Runner.c b/examples/org.eclipse.etrice.generator.c.reference/src-gen/cGenRef/SubSys_Runner.c
new file mode 100644
index 0000000..12b91ea
--- /dev/null
+++ b/examples/org.eclipse.etrice.generator.c.reference/src-gen/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/tmp/msc.seq b/examples/org.eclipse.etrice.generator.c.reference/tmp/msc.seq
index 2221161..0fbca53 100644
--- a/examples/org.eclipse.etrice.generator.c.reference/tmp/msc.seq
+++ b/examples/org.eclipse.etrice.generator.c.reference/tmp/msc.seq
@@ -75,17 +75,26 @@ Node1 ==> Node1 initActorInstances
Node1 ==> Sender init
Sender ==> CommunicationProtocolConjPort sendData
CommunicationProtocolConjPort ==> etMessageService getMessageBuffer
+etMessageService ==> etMutex enter
+etMessageService <== etMutex
etMessageService ==> etMessageQueue pop
etMessageService <== etMessageQueue
CommunicationProtocolConjPort <== etMessageService
CommunicationProtocolConjPort ==> etMessageService pushMessage
+etMessageService ==> etMutex enter
+etMessageService <== etMutex
etMessageService ==> etMessageQueue push
etMessageService <== etMessageQueue
+etMessageService ==> etSema wakeup
+etMessageService <== etSema
+etMessageService ==> etMutex leave
+etMessageService <== etMutex
CommunicationProtocolConjPort <== etMessageService
Sender <== CommunicationProtocolConjPort
Sender >>> SendingData
Node1 <== Sender
Node1 ==> Receiver init
+Receiver >>> Idle
Node1 <== Receiver
Node1 <== Node1
main <== Node1
@@ -97,55 +106,79 @@ etMessageService <== etThread
Node1 <== etMessageService
Node1 ==> etMessageService start
etMessageService ==> etThread construct
+etThread ==> etMessageService execute
+etMessageService ==> etMessageService deliverAllMessages
+etMessageService ==> etMessageQueue isNotEmpty
+etMessageService <== etMessageQueue
+etMessageService ==> etSema waitForWakeup
etMessageService <== etThread
Node1 <== etMessageService
Node1 <== Node1
main <== Node1
main ==> Node1 run
Node1 ==> etThread sleep
-etThread ==> etMessageService execute
-etMessageService ==> etMessageService deliverAllMessages
-etMessageService ==> etMessageQueue isNotEmpty
-etMessageService <== etMessageQueue
-etMessageService <== etMessageService
-etThread <== etMessageService
-etThread ==> etMessageService execute
+etSema ==> etMessageService execute
etMessageService ==> etMessageService deliverAllMessages
etMessageService ==> etMessageQueue isNotEmpty
etMessageService <== etMessageQueue
etMessageService ==> etMessageService popMessage
+etMessageService ==> etMutex enter
+etMessageService <== etMutex
etMessageService ==> etMessageQueue pop
etMessageService <== etMessageQueue
+etMessageService ==> etMutex leave
+etMessageService <== etMutex
etMessageService <== etMessageService
etMessageService ==> MsgDispatcher_PhysicalThread2 receiveMessage
MsgDispatcher_PhysicalThread2 ==> Receiver receiveMessage
Receiver ==> Receiver receiveEvent
Receiver ==> CommunicationProtocolPort receivedData
CommunicationProtocolPort ==> etMessageService getMessageBuffer
+etMessageService ==> etMutex enter
+etMessageService <== etMutex
etMessageService ==> etMessageQueue pop
etMessageService <== etMessageQueue
CommunicationProtocolPort <== etMessageService
CommunicationProtocolPort ==> etMessageService pushMessage
+etMessageService ==> etMutex enter
+etMessageService <== etMutex
etMessageService ==> etMessageQueue push
-Node1 <== etThread
etMessageService <== etMessageQueue
-main <== Node1
+etMessageService ==> etSema wakeup
+etMessageService <== etSema
+etMessageService ==> etMutex leave
+etMessageService <== etMutex
+etMessageService <== etSema
CommunicationProtocolPort <== etMessageService
-main ==> Node1 stop
+etMessageService ==> etMessageQueue isNotEmpty
Receiver <== CommunicationProtocolPort
-Receiver ==> Node1 stopMessageServices
-Node1 ==> etMessageService stop
+etMessageService <== etMessageQueue
+etMessageService ==> etMessageService popMessage
+etMessageService ==> etMutex enter
+etMessageService <== etMutex
+Receiver >>> DataReceived
+etMessageService ==> etMessageQueue pop
Receiver <== Receiver
+etMessageService <== etMessageQueue
MsgDispatcher_PhysicalThread2 <== Receiver
+etMessageService ==> etMutex leave
etMessageService <== MsgDispatcher_PhysicalThread2
+etMessageService <== etMutex
etMessageService ==> etMessageService returnMessageBuffer
-etMessageService ==> etMessageQueue push
-etMessageService <== etMessageQueue
etMessageService <== etMessageService
-etMessageService ==> etMessageQueue isNotEmpty
-etMessageService <== etMessageQueue
-etMessageService <== etMessageService
-etThread <== etMessageService
+etMessageService ==> etMutex enter
+etMessageService ==> MsgDispatcher_PhysicalThread1 receiveMessage
+MsgDispatcher_PhysicalThread1 ==> Sender _receiveMessage
+Sender >>> Done
+MsgDispatcher_PhysicalThread1 <== Sender
+etMessageService <== MsgDispatcher_PhysicalThread1
+etMessageService ==> etMessageService returnMessageBuffer
+etMessageService ==> etMutex enter
+Node1 <== etThread
+main <== Node1
+main ==> Node1 stop
+Node1 ==> Node1 stopMessageServices
+Node1 ==> etMessageService stop
etMessageService ==> etThread destruct
etMessageService <== etThread
Node1 <== etMessageService
@@ -153,7 +186,7 @@ Node1 ==> etMessageService stop
etMessageService ==> etThread destruct
etMessageService <== etThread
Node1 <== etMessageService
-Receiver <== Node1
+Node1 <== Node1
main <== Node1
main ==> Node1 destroy
Node1 ==> Node1 destroyMessageServices
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessageService.c b/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessageService.c
index 59e205e..d602edb 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessageService.c
+++ b/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessageService.c
@@ -83,13 +83,18 @@ void etMessageService_initMessagePool(etMessageService* self){
void etMessageService_pushMessage(etMessageService* self, etMessage* msg){
ET_MSC_LOGGER_SYNC_ENTRY("etMessageService", "pushMessage")
+ etMutex_enter(&self->queueMutex);
etMessageQueue_push(&self->messageQueue, msg);
+ etSema_wakeup(&self->executionSemaphore);
+ etMutex_leave(&self->queueMutex);
ET_MSC_LOGGER_SYNC_EXIT
}
etMessage* etMessageService_popMessage(etMessageService* self){
ET_MSC_LOGGER_SYNC_ENTRY("etMessageService", "popMessage")
+ etMutex_enter(&self->queueMutex);
etMessage* msg = etMessageQueue_pop(&self->messageQueue);
+ etMutex_leave(&self->queueMutex);
ET_MSC_LOGGER_SYNC_EXIT
return msg;
}
@@ -97,6 +102,7 @@ etMessage* etMessageService_popMessage(etMessageService* self){
etMessage* etMessageService_getMessageBuffer(etMessageService* self, etUInt16 size){
ET_MSC_LOGGER_SYNC_ENTRY("etMessageService", "getMessageBuffer")
+ etMutex_enter(&self->poolMutex);
if (size<=self->messageBuffer.blockSize){
if (self->messagePool.size>0){
etMessage* msg = etMessageQueue_pop(&self->messagePool);
@@ -104,22 +110,28 @@ etMessage* etMessageService_getMessageBuffer(etMessageService* self, etUInt16 si
return msg;
}
}
+ etMutex_leave(&self->poolMutex);
ET_MSC_LOGGER_SYNC_EXIT
return NULL;
}
void etMessageService_returnMessageBuffer(etMessageService* self, etMessage* buffer){
ET_MSC_LOGGER_SYNC_ENTRY("etMessageService", "returnMessageBuffer")
+ etMutex_enter(&self->poolMutex);
etMessageQueue_push(&self->messagePool, buffer);
+ etMutex_leave(&self->poolMutex);
ET_MSC_LOGGER_SYNC_EXIT
}
void etMessageService_deliverAllMessages(etMessageService* self){
ET_MSC_LOGGER_SYNC_ENTRY("etMessageService", "deliverAllMessages")
- while (etMessageQueue_isNotEmpty(&self->messageQueue)){
- etMessage* msg = etMessageService_popMessage(self);
- self->msgDispatcher(msg);
- etMessageService_returnMessageBuffer(self, msg);
+ while (TRUE){
+ while (etMessageQueue_isNotEmpty(&self->messageQueue)){
+ etMessage* msg = etMessageService_popMessage(self);
+ self->msgDispatcher(msg);
+ etMessageService_returnMessageBuffer(self, msg);
+ }
+ etSema_waitForWakeup(&self->executionSemaphore);
}
ET_MSC_LOGGER_SYNC_EXIT
}