Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/org.eclipse.etrice.runtime.c/src/common/messaging')
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessage.c50
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessage.h52
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessageQueue.c230
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessageQueue.h88
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessageReceiver.h48
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessageService.c412
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessageService.h166
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etSystemProtocol.c178
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etSystemProtocol.h102
9 files changed, 663 insertions, 663 deletions
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessage.c b/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessage.c
index 49772f7b6..224461432 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessage.c
+++ b/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessage.c
@@ -1,25 +1,25 @@
-/*******************************************************************************
- * Copyright (c) 2011 protos software gmbh (http://www.protos.de).
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * CONTRIBUTORS:
- * Thomas Schuetz (initial contribution)
- *
- *******************************************************************************/
-
-#include "messaging/etMessage.h"
-
-#include "debugging/etMSCLogger.h"
-
-#include <stddef.h>
-
-void etMessage_init(etMessage* self){
- ET_MSC_LOGGER_SYNC_ENTRY("etMessage", "init")
- self->next = NULL;
- self->address = 0;
- self->evtID = 0;
- ET_MSC_LOGGER_SYNC_EXIT
-}
+/*******************************************************************************
+ * Copyright (c) 2011 protos software gmbh (http://www.protos.de).
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * CONTRIBUTORS:
+ * Thomas Schuetz (initial contribution)
+ *
+ *******************************************************************************/
+
+#include "messaging/etMessage.h"
+
+#include "debugging/etMSCLogger.h"
+
+#include <stddef.h>
+
+void etMessage_init(etMessage* self){
+ ET_MSC_LOGGER_SYNC_ENTRY("etMessage", "init")
+ self->next = NULL;
+ self->address = 0;
+ self->evtID = 0;
+ ET_MSC_LOGGER_SYNC_EXIT
+}
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessage.h b/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessage.h
index 698a89c09..7bba6a1f3 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessage.h
+++ b/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessage.h
@@ -1,26 +1,26 @@
-/*******************************************************************************
- * Copyright (c) 2011 protos software gmbh (http://www.protos.de).
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * CONTRIBUTORS:
- * Thomas Schuetz (initial contribution)
- *
- *******************************************************************************/
-
-#ifndef _ETMESSAGE_H_
-#define _ETMESSAGE_H_
-
-#include "etDatatypes.h"
-
-typedef struct etMessage{
- struct etMessage* next;
- etInt16 address;
- etInt16 evtID;
-} etMessage;
-
-void etMessage_init(etMessage* self);
-
-#endif /* _ETMESSAGE_H_ */
+/*******************************************************************************
+ * Copyright (c) 2011 protos software gmbh (http://www.protos.de).
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * CONTRIBUTORS:
+ * Thomas Schuetz (initial contribution)
+ *
+ *******************************************************************************/
+
+#ifndef _ETMESSAGE_H_
+#define _ETMESSAGE_H_
+
+#include "etDatatypes.h"
+
+typedef struct etMessage{
+ struct etMessage* next;
+ etInt16 address;
+ etInt16 evtID;
+} etMessage;
+
+void etMessage_init(etMessage* self);
+
+#endif /* _ETMESSAGE_H_ */
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessageQueue.c b/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessageQueue.c
index 145432dd1..96a86b046 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessageQueue.c
+++ b/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessageQueue.c
@@ -1,115 +1,115 @@
-/*******************************************************************************
- * Copyright (c) 2011 protos software gmbh (http://www.protos.de).
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * CONTRIBUTORS:
- * Thomas Schuetz (initial contribution)
- *
- *******************************************************************************/
-
-#include "messaging/etMessageQueue.h"
-
-#include "debugging/etMSCLogger.h"
-
-void etMessageQueue_init(etMessageQueue* self){
- ET_MSC_LOGGER_SYNC_ENTRY("etMessageQueue", "init")
- self->first = NULL;
- self->last = NULL;
- self->highWaterMark = 0;
- self->lowWaterMark = 0;
- self->size = 0;
- ET_MSC_LOGGER_SYNC_EXIT
-}
-
-
-void etMessageQueue_push(etMessageQueue* self, etMessage* msg){
- /* TODO: optimize queue for concurrent push / pop */
- ET_MSC_LOGGER_SYNC_ENTRY("etMessageQueue", "push")
- if (self->first == NULL) {
- /*no message in queue*/
- self->first = self->last = msg;
- }
- else {
- /*at least one message in queue*/
- self->last->next = msg;
- self->last = msg;
- }
- msg->next = NULL; /*TODO: optimization: this line could be removed if we assume that all messages are initialized*/
-
- if (++self->size > self->highWaterMark)
- self->highWaterMark++;
-
- ET_MSC_LOGGER_SYNC_EXIT
-}
-
-etMessage* etMessageQueue_pop(etMessageQueue* self){
- ET_MSC_LOGGER_SYNC_ENTRY("etMessageQueue", "pop")
- etMessage* pop_msg = self->first;
- if(self->first == NULL){
- /*no message in queue*/
- ET_MSC_LOGGER_SYNC_EXIT
- return NULL;
- }
- if (self->first->next==NULL){
- /*only one message in queue*/
- self->first = self->last = NULL;
- }
- else {
- /*more than one message in queue -> set first to nex message*/
- self->first = self->first->next;
- }
-
- pop_msg->next=NULL;
- self->size--;
-
- if (self->size < self->lowWaterMark)
- self->lowWaterMark--;
-
- ET_MSC_LOGGER_SYNC_EXIT
- return pop_msg;
-}
-
-etInt16 etMessageQueue_getSize(etMessageQueue* self) {
- ET_MSC_LOGGER_SYNC_ENTRY("etMessageQueue", "getSize")
- ET_MSC_LOGGER_SYNC_EXIT
- return self->size;
-}
-
-etMessage* etMessageQueue_getFirst(etMessageQueue* self){
- ET_MSC_LOGGER_SYNC_ENTRY("etMessageQueue", "getFirst")
- ET_MSC_LOGGER_SYNC_EXIT
- return self->first;
-}
-
-etMessage* etMessageQueue_getLast(etMessageQueue* self){
- ET_MSC_LOGGER_SYNC_ENTRY("etMessageQueue", "getLast")
- ET_MSC_LOGGER_SYNC_EXIT
- return self->last;
-}
-
-etBool etMessageQueue_isNotEmpty(etMessageQueue* self){
- ET_MSC_LOGGER_SYNC_ENTRY("etMessageQueue", "isNotEmpty")
- ET_MSC_LOGGER_SYNC_EXIT
- return self->last != NULL;
-}
-
-etInt16 etMessageQueue_getHighWaterMark(etMessageQueue* self) {
- ET_MSC_LOGGER_SYNC_ENTRY("etMessageQueue", "getHighWaterMark")
- ET_MSC_LOGGER_SYNC_EXIT
- return self->highWaterMark;
-}
-
-etInt16 etMessageQueue_getLowWaterMark(etMessageQueue* self) {
- ET_MSC_LOGGER_SYNC_ENTRY("etMessageQueue", "getLowWaterMark")
- ET_MSC_LOGGER_SYNC_EXIT
- return self->lowWaterMark;
-}
-
-void etMessageQueue_resetLowWaterMark(etMessageQueue* self) {
- ET_MSC_LOGGER_SYNC_ENTRY("etMessageQueue", "resetLowWaterMark")
- self->lowWaterMark = self->size;
- ET_MSC_LOGGER_SYNC_EXIT
-}
+/*******************************************************************************
+ * Copyright (c) 2011 protos software gmbh (http://www.protos.de).
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * CONTRIBUTORS:
+ * Thomas Schuetz (initial contribution)
+ *
+ *******************************************************************************/
+
+#include "messaging/etMessageQueue.h"
+
+#include "debugging/etMSCLogger.h"
+
+void etMessageQueue_init(etMessageQueue* self){
+ ET_MSC_LOGGER_SYNC_ENTRY("etMessageQueue", "init")
+ self->first = NULL;
+ self->last = NULL;
+ self->highWaterMark = 0;
+ self->lowWaterMark = 0;
+ self->size = 0;
+ ET_MSC_LOGGER_SYNC_EXIT
+}
+
+
+void etMessageQueue_push(etMessageQueue* self, etMessage* msg){
+ /* TODO: optimize queue for concurrent push / pop */
+ ET_MSC_LOGGER_SYNC_ENTRY("etMessageQueue", "push")
+ if (self->first == NULL) {
+ /*no message in queue*/
+ self->first = self->last = msg;
+ }
+ else {
+ /*at least one message in queue*/
+ self->last->next = msg;
+ self->last = msg;
+ }
+ msg->next = NULL; /*TODO: optimization: this line could be removed if we assume that all messages are initialized*/
+
+ if (++self->size > self->highWaterMark)
+ self->highWaterMark++;
+
+ ET_MSC_LOGGER_SYNC_EXIT
+}
+
+etMessage* etMessageQueue_pop(etMessageQueue* self){
+ ET_MSC_LOGGER_SYNC_ENTRY("etMessageQueue", "pop")
+ etMessage* pop_msg = self->first;
+ if(self->first == NULL){
+ /*no message in queue*/
+ ET_MSC_LOGGER_SYNC_EXIT
+ return NULL;
+ }
+ if (self->first->next==NULL){
+ /*only one message in queue*/
+ self->first = self->last = NULL;
+ }
+ else {
+ /*more than one message in queue -> set first to nex message*/
+ self->first = self->first->next;
+ }
+
+ pop_msg->next=NULL;
+ self->size--;
+
+ if (self->size < self->lowWaterMark)
+ self->lowWaterMark--;
+
+ ET_MSC_LOGGER_SYNC_EXIT
+ return pop_msg;
+}
+
+etInt16 etMessageQueue_getSize(etMessageQueue* self) {
+ ET_MSC_LOGGER_SYNC_ENTRY("etMessageQueue", "getSize")
+ ET_MSC_LOGGER_SYNC_EXIT
+ return self->size;
+}
+
+etMessage* etMessageQueue_getFirst(etMessageQueue* self){
+ ET_MSC_LOGGER_SYNC_ENTRY("etMessageQueue", "getFirst")
+ ET_MSC_LOGGER_SYNC_EXIT
+ return self->first;
+}
+
+etMessage* etMessageQueue_getLast(etMessageQueue* self){
+ ET_MSC_LOGGER_SYNC_ENTRY("etMessageQueue", "getLast")
+ ET_MSC_LOGGER_SYNC_EXIT
+ return self->last;
+}
+
+etBool etMessageQueue_isNotEmpty(etMessageQueue* self){
+ ET_MSC_LOGGER_SYNC_ENTRY("etMessageQueue", "isNotEmpty")
+ ET_MSC_LOGGER_SYNC_EXIT
+ return self->last != NULL;
+}
+
+etInt16 etMessageQueue_getHighWaterMark(etMessageQueue* self) {
+ ET_MSC_LOGGER_SYNC_ENTRY("etMessageQueue", "getHighWaterMark")
+ ET_MSC_LOGGER_SYNC_EXIT
+ return self->highWaterMark;
+}
+
+etInt16 etMessageQueue_getLowWaterMark(etMessageQueue* self) {
+ ET_MSC_LOGGER_SYNC_ENTRY("etMessageQueue", "getLowWaterMark")
+ ET_MSC_LOGGER_SYNC_EXIT
+ return self->lowWaterMark;
+}
+
+void etMessageQueue_resetLowWaterMark(etMessageQueue* self) {
+ ET_MSC_LOGGER_SYNC_ENTRY("etMessageQueue", "resetLowWaterMark")
+ self->lowWaterMark = self->size;
+ ET_MSC_LOGGER_SYNC_EXIT
+}
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessageQueue.h b/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessageQueue.h
index a9a6cb13e..e79b57347 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessageQueue.h
+++ b/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessageQueue.h
@@ -1,44 +1,44 @@
-/*******************************************************************************
- * Copyright (c) 2011 protos software gmbh (http://www.protos.de).
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * CONTRIBUTORS:
- * Thomas Schuetz (initial contribution)
- *
- *******************************************************************************/
-
-#ifndef _ETMESSAGEQUEUE_H_
-#define _ETMESSAGEQUEUE_H_
-
-#include "messaging/etMessage.h"
-#include <stddef.h>
-
-typedef struct etMessageQueue {
- etMessage* first;
- etMessage* last;
- etInt16 highWaterMark;
- etInt16 lowWaterMark;
- etInt16 size;
-
-} etMessageQueue;
-
-void etMessageQueue_init(etMessageQueue* self);
-
-void etMessageQueue_push(etMessageQueue* self, etMessage* msg);
-etMessage* etMessageQueue_pop(etMessageQueue* self);
-
-etMessage* etMessageQueue_getFirst(etMessageQueue* self);
-etMessage* etMessageQueue_getLast(etMessageQueue* self);
-
-etBool etMessageQueue_isNotEmpty(etMessageQueue* self);
-
-etInt16 etMessageQueue_getSize(etMessageQueue* self);
-etInt16 etMessageQueue_getHighWaterMark(etMessageQueue* self);
-etInt16 etMessageQueue_getLowWaterMark(etMessageQueue* self);
-void etMessageQueue_resetLowWaterMark(etMessageQueue* self);
-
-
-#endif /* _RMESSAGEQUEUE_H_ */
+/*******************************************************************************
+ * Copyright (c) 2011 protos software gmbh (http://www.protos.de).
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * CONTRIBUTORS:
+ * Thomas Schuetz (initial contribution)
+ *
+ *******************************************************************************/
+
+#ifndef _ETMESSAGEQUEUE_H_
+#define _ETMESSAGEQUEUE_H_
+
+#include "messaging/etMessage.h"
+#include <stddef.h>
+
+typedef struct etMessageQueue {
+ etMessage* first;
+ etMessage* last;
+ etInt16 highWaterMark;
+ etInt16 lowWaterMark;
+ etInt16 size;
+
+} etMessageQueue;
+
+void etMessageQueue_init(etMessageQueue* self);
+
+void etMessageQueue_push(etMessageQueue* self, etMessage* msg);
+etMessage* etMessageQueue_pop(etMessageQueue* self);
+
+etMessage* etMessageQueue_getFirst(etMessageQueue* self);
+etMessage* etMessageQueue_getLast(etMessageQueue* self);
+
+etBool etMessageQueue_isNotEmpty(etMessageQueue* self);
+
+etInt16 etMessageQueue_getSize(etMessageQueue* self);
+etInt16 etMessageQueue_getHighWaterMark(etMessageQueue* self);
+etInt16 etMessageQueue_getLowWaterMark(etMessageQueue* self);
+void etMessageQueue_resetLowWaterMark(etMessageQueue* self);
+
+
+#endif /* _RMESSAGEQUEUE_H_ */
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessageReceiver.h b/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessageReceiver.h
index 2eca06ebe..06cd7df78 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessageReceiver.h
+++ b/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessageReceiver.h
@@ -1,24 +1,24 @@
-/*******************************************************************************
- * Copyright (c) 2012 protos software gmbh (http://www.protos.de).
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * CONTRIBUTORS:
- * Thomas Schuetz (initial contribution)
- *
- *******************************************************************************/
-
-
-
-#ifndef _ETMESSAGERECEIVER_H_
-#define _ETMESSAGERECEIVER_H_
-
-#include "messaging/etMessage.h"
-
-typedef void (*etActorReceiveMessage)(void* self, const void* ifitem, const etMessage* msg);
-typedef etBool (*etDispatcherReceiveMessage)(const etMessage* msg);
-typedef void (*etDispatcherExecute)(void);
-
-#endif /* _ETMESSAGERECEIVER_H_ */
+/*******************************************************************************
+ * Copyright (c) 2012 protos software gmbh (http://www.protos.de).
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * CONTRIBUTORS:
+ * Thomas Schuetz (initial contribution)
+ *
+ *******************************************************************************/
+
+
+
+#ifndef _ETMESSAGERECEIVER_H_
+#define _ETMESSAGERECEIVER_H_
+
+#include "messaging/etMessage.h"
+
+typedef void (*etActorReceiveMessage)(void* self, const void* ifitem, const etMessage* msg);
+typedef etBool (*etDispatcherReceiveMessage)(const etMessage* msg);
+typedef void (*etDispatcherExecute)(void);
+
+#endif /* _ETMESSAGERECEIVER_H_ */
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 b2140166a..7b6d4c344 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
@@ -1,206 +1,206 @@
-/*******************************************************************************
- * Copyright (c) 2011 protos software gmbh (http://www.protos.de).
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * CONTRIBUTORS:
- * Thomas Schuetz (initial contribution)
- *
- *******************************************************************************/
-
-
-#include "etMessageService.h"
-
-
-#include "etSystemProtocol.h"
-#include "debugging/etLogger.h"
-#include "debugging/etMSCLogger.h"
-
-static void etMessageService_timerCallback(void* data);
-static void etMessageService_deliverAllMessages(etMessageService* self);
-
-/*
- * initialize message service with all needed data and initialize message queue and message pool
- *
- */
-void etMessageService_init(
- etMessageService* self,
- etUInt8* buffer,
- etUInt16 maxBlocks,
- etUInt16 blockSize,
- etStacksize stacksize,
- etPriority priority,
- etTime interval,
- etDispatcherReceiveMessage msgDispatcher,
- etMessageService_execmode execmode){
- ET_MSC_LOGGER_SYNC_ENTRY("etMessageService", "init")
-
- /* copy init data to self */
- self->messageBuffer.buffer = buffer;
- self->messageBuffer.maxBlocks = maxBlocks;
- self->messageBuffer.blockSize = blockSize;
- self->msgDispatcher = msgDispatcher;
- self->execmode = execmode;
-
- /* init queue and pool */
- etMessageQueue_init( &(self->messagePool) ); /* the pool is also a queue*/
- etMessageQueue_init( &(self->messageQueue) );
- etMessageService_initMessagePool(self);
-
- /* init mutexes and semaphores */
- etMutex_construct( &(self->poolMutex) );
- etMutex_construct( &(self->queueMutex) );
- etSema_construct( &(self->executionSemaphore) );
-
- /* init thread */
- etThread_construct(&self->thread, stacksize, priority, "MessageService", (etThreadFunction) etMessageService_deliverAllMessages, self);
-
- if (execmode==EXECMODE_POLLED || execmode==EXECMODE_MIXED) {
- /* init timer */
- etTimer_construct(&self->timer, &interval, etMessageService_timerCallback, self);
- }
-
- ET_MSC_LOGGER_SYNC_EXIT
-}
-
-void etMessageService_start(etMessageService* self){
- ET_MSC_LOGGER_SYNC_ENTRY("etMessageService", "start")
- etThread_start( &(self->thread) );
- if (self->execmode==EXECMODE_POLLED || self->execmode==EXECMODE_MIXED) {
- etTimer_start(&self->timer);
- }
- ET_MSC_LOGGER_SYNC_EXIT
-}
-
-void etMessageService_stop(etMessageService* self){
- ET_MSC_LOGGER_SYNC_ENTRY("etMessageService", "stop")
-
- if (self->execmode==EXECMODE_POLLED || self->execmode==EXECMODE_MIXED) {
- etTimer_stop(&self->timer);
- }
-
- /* create a temporary port struct and send the terminate message */
- etSystemProtocolConjPort port;
- port.localId = 0;
- port.msgService = self;
- port.peerAddress = MESSAGESERVICE_ADDRESS;
- etSystemProtocolConjPort_terminate(&port);
-
- ET_MSC_LOGGER_SYNC_EXIT
-}
-
-void etMessageService_destroy(etMessageService* self){
- ET_MSC_LOGGER_SYNC_ENTRY("etMessageService", "destroy")
- etMutex_destruct( &(self->poolMutex) );
- etMutex_destruct( &(self->queueMutex) );
- etSema_destruct( &(self->executionSemaphore) );
- ET_MSC_LOGGER_SYNC_EXIT
-}
-
-
-/*
- * initialize message pool with block buffer
- * all blocks are added to pool
- */
-void etMessageService_initMessagePool(etMessageService* self){
- ET_MSC_LOGGER_SYNC_ENTRY("etMessageService", "initMessagePool")
- etInt16 i;
-
- for (i=0; i<self->messageBuffer.maxBlocks; i++){
- etMessage* block = (etMessage*) &self->messageBuffer.buffer[i*self->messageBuffer.blockSize];
- etMessageQueue_push(&self->messagePool, block);
- }
- etMessageQueue_resetLowWaterMark(&self->messagePool);
- ET_MSC_LOGGER_SYNC_EXIT
-}
-
-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;
-}
-
-
-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);
- etMutex_leave(&self->poolMutex);
- ET_MSC_LOGGER_SYNC_EXIT
- return msg;
- }
- else {
- etLogger_logErrorF("etMessageService_getMessageBuffer: message pool empty: %d", etMessageService_getMessagePoolLowWaterMark(self));
- }
- }
- else {
- etLogger_logErrorF("etMessageService_getMessageBuffer: message too big: %d, blockSize: %d", size, self->messageBuffer.blockSize);
- }
- 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
-}
-
-static void etMessageService_deliverAllMessages(etMessageService* self){
- ET_MSC_LOGGER_SYNC_ENTRY("etMessageService", "deliverAllMessages")
- {
- etBool cont = TRUE;
- while (cont){
- while (etMessageQueue_isNotEmpty(&self->messageQueue) && cont){
- etMessage* msg = etMessageService_popMessage(self);
- if (!self->msgDispatcher(msg))
- cont = FALSE;
- etMessageService_returnMessageBuffer(self, msg);
- }
- if (cont)
- etSema_waitForWakeup(&self->executionSemaphore);
- }
- }
- ET_MSC_LOGGER_SYNC_EXIT
-}
-
-etInt16 etMessageService_getMessagePoolLowWaterMark(etMessageService* self){
- ET_MSC_LOGGER_SYNC_ENTRY("etMessageService", "getMessagePoolLowWaterMark")
- etInt16 lowWaterMark = etMessageQueue_getLowWaterMark(&self->messagePool);
- ET_MSC_LOGGER_SYNC_EXIT
- return lowWaterMark;
-}
-
-static void etMessageService_timerCallback(void* data) {
- ET_MSC_LOGGER_SYNC_ENTRY("etMessageService", "timerCallback")
- {
- etMessageService* self = (etMessageService*) data;
-
- /* create a temporary port struct and send the terminate message */
- etSystemProtocolConjPort port;
- port.localId = 0;
- port.msgService = self;
- port.peerAddress = MESSAGESERVICE_ADDRESS;
- etSystemProtocolConjPort_poll(&port);
- }
- ET_MSC_LOGGER_SYNC_EXIT
-}
+/*******************************************************************************
+ * Copyright (c) 2011 protos software gmbh (http://www.protos.de).
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * CONTRIBUTORS:
+ * Thomas Schuetz (initial contribution)
+ *
+ *******************************************************************************/
+
+
+#include "etMessageService.h"
+
+
+#include "etSystemProtocol.h"
+#include "debugging/etLogger.h"
+#include "debugging/etMSCLogger.h"
+
+static void etMessageService_timerCallback(void* data);
+static void etMessageService_deliverAllMessages(etMessageService* self);
+
+/*
+ * initialize message service with all needed data and initialize message queue and message pool
+ *
+ */
+void etMessageService_init(
+ etMessageService* self,
+ etUInt8* buffer,
+ etUInt16 maxBlocks,
+ etUInt16 blockSize,
+ etStacksize stacksize,
+ etPriority priority,
+ etTime interval,
+ etDispatcherReceiveMessage msgDispatcher,
+ etMessageService_execmode execmode){
+ ET_MSC_LOGGER_SYNC_ENTRY("etMessageService", "init")
+
+ /* copy init data to self */
+ self->messageBuffer.buffer = buffer;
+ self->messageBuffer.maxBlocks = maxBlocks;
+ self->messageBuffer.blockSize = blockSize;
+ self->msgDispatcher = msgDispatcher;
+ self->execmode = execmode;
+
+ /* init queue and pool */
+ etMessageQueue_init( &(self->messagePool) ); /* the pool is also a queue*/
+ etMessageQueue_init( &(self->messageQueue) );
+ etMessageService_initMessagePool(self);
+
+ /* init mutexes and semaphores */
+ etMutex_construct( &(self->poolMutex) );
+ etMutex_construct( &(self->queueMutex) );
+ etSema_construct( &(self->executionSemaphore) );
+
+ /* init thread */
+ etThread_construct(&self->thread, stacksize, priority, "MessageService", (etThreadFunction) etMessageService_deliverAllMessages, self);
+
+ if (execmode==EXECMODE_POLLED || execmode==EXECMODE_MIXED) {
+ /* init timer */
+ etTimer_construct(&self->timer, &interval, etMessageService_timerCallback, self);
+ }
+
+ ET_MSC_LOGGER_SYNC_EXIT
+}
+
+void etMessageService_start(etMessageService* self){
+ ET_MSC_LOGGER_SYNC_ENTRY("etMessageService", "start")
+ etThread_start( &(self->thread) );
+ if (self->execmode==EXECMODE_POLLED || self->execmode==EXECMODE_MIXED) {
+ etTimer_start(&self->timer);
+ }
+ ET_MSC_LOGGER_SYNC_EXIT
+}
+
+void etMessageService_stop(etMessageService* self){
+ ET_MSC_LOGGER_SYNC_ENTRY("etMessageService", "stop")
+
+ if (self->execmode==EXECMODE_POLLED || self->execmode==EXECMODE_MIXED) {
+ etTimer_stop(&self->timer);
+ }
+
+ /* create a temporary port struct and send the terminate message */
+ etSystemProtocolConjPort port;
+ port.localId = 0;
+ port.msgService = self;
+ port.peerAddress = MESSAGESERVICE_ADDRESS;
+ etSystemProtocolConjPort_terminate(&port);
+
+ ET_MSC_LOGGER_SYNC_EXIT
+}
+
+void etMessageService_destroy(etMessageService* self){
+ ET_MSC_LOGGER_SYNC_ENTRY("etMessageService", "destroy")
+ etMutex_destruct( &(self->poolMutex) );
+ etMutex_destruct( &(self->queueMutex) );
+ etSema_destruct( &(self->executionSemaphore) );
+ ET_MSC_LOGGER_SYNC_EXIT
+}
+
+
+/*
+ * initialize message pool with block buffer
+ * all blocks are added to pool
+ */
+void etMessageService_initMessagePool(etMessageService* self){
+ ET_MSC_LOGGER_SYNC_ENTRY("etMessageService", "initMessagePool")
+ etInt16 i;
+
+ for (i=0; i<self->messageBuffer.maxBlocks; i++){
+ etMessage* block = (etMessage*) &self->messageBuffer.buffer[i*self->messageBuffer.blockSize];
+ etMessageQueue_push(&self->messagePool, block);
+ }
+ etMessageQueue_resetLowWaterMark(&self->messagePool);
+ ET_MSC_LOGGER_SYNC_EXIT
+}
+
+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;
+}
+
+
+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);
+ etMutex_leave(&self->poolMutex);
+ ET_MSC_LOGGER_SYNC_EXIT
+ return msg;
+ }
+ else {
+ etLogger_logErrorF("etMessageService_getMessageBuffer: message pool empty: %d", etMessageService_getMessagePoolLowWaterMark(self));
+ }
+ }
+ else {
+ etLogger_logErrorF("etMessageService_getMessageBuffer: message too big: %d, blockSize: %d", size, self->messageBuffer.blockSize);
+ }
+ 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
+}
+
+static void etMessageService_deliverAllMessages(etMessageService* self){
+ ET_MSC_LOGGER_SYNC_ENTRY("etMessageService", "deliverAllMessages")
+ {
+ etBool cont = TRUE;
+ while (cont){
+ while (etMessageQueue_isNotEmpty(&self->messageQueue) && cont){
+ etMessage* msg = etMessageService_popMessage(self);
+ if (!self->msgDispatcher(msg))
+ cont = FALSE;
+ etMessageService_returnMessageBuffer(self, msg);
+ }
+ if (cont)
+ etSema_waitForWakeup(&self->executionSemaphore);
+ }
+ }
+ ET_MSC_LOGGER_SYNC_EXIT
+}
+
+etInt16 etMessageService_getMessagePoolLowWaterMark(etMessageService* self){
+ ET_MSC_LOGGER_SYNC_ENTRY("etMessageService", "getMessagePoolLowWaterMark")
+ etInt16 lowWaterMark = etMessageQueue_getLowWaterMark(&self->messagePool);
+ ET_MSC_LOGGER_SYNC_EXIT
+ return lowWaterMark;
+}
+
+static void etMessageService_timerCallback(void* data) {
+ ET_MSC_LOGGER_SYNC_ENTRY("etMessageService", "timerCallback")
+ {
+ etMessageService* self = (etMessageService*) data;
+
+ /* create a temporary port struct and send the terminate message */
+ etSystemProtocolConjPort port;
+ port.localId = 0;
+ port.msgService = self;
+ port.peerAddress = MESSAGESERVICE_ADDRESS;
+ etSystemProtocolConjPort_poll(&port);
+ }
+ ET_MSC_LOGGER_SYNC_EXIT
+}
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessageService.h b/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessageService.h
index c06898f2b..a59ed2178 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessageService.h
+++ b/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessageService.h
@@ -1,83 +1,83 @@
-/*******************************************************************************
- * Copyright (c) 2011 protos software gmbh (http://www.protos.de).
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * CONTRIBUTORS:
- * Thomas Schuetz (initial contribution)
- *
- *******************************************************************************/
-
-#ifndef _ETMESSAGESERVICE_H_
-#define _ETMESSAGESERVICE_H_
-
-#include <stddef.h>
-#include "etDatatypes.h"
-#include "messaging/etMessageQueue.h"
-#include "messaging/etMessageReceiver.h"
-
-#include "osal/etMutex.h"
-#include "osal/etThread.h"
-#include "osal/etSema.h"
-#include "osal/etTimer.h"
-
-#define MESSAGESERVICE_ADDRESS 1
-#define BASE_ADDRESS 32
-
-typedef enum etMessageService_execmode {
- EXECMODE_POLLED, EXECMODE_BLOCKED, EXECMODE_MIXED
-} etMessageService_execmode;
-
-typedef struct etBuffer{
- etUInt8 *buffer; /** buffer points to the actual memory position for the message pool */
- etUInt16 maxBlocks; /** number of blocks for the message pool */
- etUInt16 blockSize; /** size of blocks for the message pool */
-} etBuffer;
-
-typedef struct etMessageService {
- etMessageQueue messageQueue; /** message queue that holds all used messages */
- etMessageQueue messagePool; /** message pool that holds all free messages */
- etBuffer messageBuffer; /** information about the message buffer that holds information about the actual memory position and size for the message pool */
- etDispatcherReceiveMessage msgDispatcher; /** function pointer to the generated message dispatcher function */
- etThread thread; /** thread for the execution of the message service */
- etMutex poolMutex; /** mutex for synchronizing the access to the message pool */
- etMutex queueMutex; /** mutex for synchronizing the access to the message queue */
- etSema executionSemaphore; /** semaphore for waiting and waking up the execution */
- etTimer timer; /** timer for cyclic calls */
- etMessageService_execmode execmode; /** execution mode*/
-} etMessageService;
-
-/* lifecycle functions to startup, execute and shutdown the message service */
-void etMessageService_init(
- etMessageService* self,
- etUInt8* buffer,
- etUInt16 maxBlocks,
- etUInt16 blockSize,
- etStacksize stacksize,
- etPriority priority,
- etTime interval,
- etDispatcherReceiveMessage msgDispatcher,
- etMessageService_execmode execmode);
-void etMessageService_start(etMessageService* self);
-void etMessageService_execute(etMessageService* self);
-void etMessageService_stop(etMessageService* self);
-void etMessageService_destroy(etMessageService* self);
-
-/* initialization of message pool */
-void etMessageService_initMessagePool(etMessageService* self);
-
-/* message queue interface for push and pop messages */
-void etMessageService_pushMessage(etMessageService* self, etMessage* msg);
-etMessage* etMessageService_popMessage(etMessageService* self);
-
-/* message pool interface to get and return (push and pop) messages */
-etMessage* etMessageService_getMessageBuffer(etMessageService* self, etUInt16 size);
-void etMessageService_returnMessageBuffer(etMessageService* self, etMessage* buffer);
-
-/* functions for debug and service information */
-etInt16 etMessageService_getMessagePoolLowWaterMark(etMessageService* self);
-
-
-#endif /* RMESSAGESERVICE_H_ */
+/*******************************************************************************
+ * Copyright (c) 2011 protos software gmbh (http://www.protos.de).
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * CONTRIBUTORS:
+ * Thomas Schuetz (initial contribution)
+ *
+ *******************************************************************************/
+
+#ifndef _ETMESSAGESERVICE_H_
+#define _ETMESSAGESERVICE_H_
+
+#include <stddef.h>
+#include "etDatatypes.h"
+#include "messaging/etMessageQueue.h"
+#include "messaging/etMessageReceiver.h"
+
+#include "osal/etMutex.h"
+#include "osal/etThread.h"
+#include "osal/etSema.h"
+#include "osal/etTimer.h"
+
+#define MESSAGESERVICE_ADDRESS 1
+#define BASE_ADDRESS 32
+
+typedef enum etMessageService_execmode {
+ EXECMODE_POLLED, EXECMODE_BLOCKED, EXECMODE_MIXED
+} etMessageService_execmode;
+
+typedef struct etBuffer{
+ etUInt8 *buffer; /** buffer points to the actual memory position for the message pool */
+ etUInt16 maxBlocks; /** number of blocks for the message pool */
+ etUInt16 blockSize; /** size of blocks for the message pool */
+} etBuffer;
+
+typedef struct etMessageService {
+ etMessageQueue messageQueue; /** message queue that holds all used messages */
+ etMessageQueue messagePool; /** message pool that holds all free messages */
+ etBuffer messageBuffer; /** information about the message buffer that holds information about the actual memory position and size for the message pool */
+ etDispatcherReceiveMessage msgDispatcher; /** function pointer to the generated message dispatcher function */
+ etThread thread; /** thread for the execution of the message service */
+ etMutex poolMutex; /** mutex for synchronizing the access to the message pool */
+ etMutex queueMutex; /** mutex for synchronizing the access to the message queue */
+ etSema executionSemaphore; /** semaphore for waiting and waking up the execution */
+ etTimer timer; /** timer for cyclic calls */
+ etMessageService_execmode execmode; /** execution mode*/
+} etMessageService;
+
+/* lifecycle functions to startup, execute and shutdown the message service */
+void etMessageService_init(
+ etMessageService* self,
+ etUInt8* buffer,
+ etUInt16 maxBlocks,
+ etUInt16 blockSize,
+ etStacksize stacksize,
+ etPriority priority,
+ etTime interval,
+ etDispatcherReceiveMessage msgDispatcher,
+ etMessageService_execmode execmode);
+void etMessageService_start(etMessageService* self);
+void etMessageService_execute(etMessageService* self);
+void etMessageService_stop(etMessageService* self);
+void etMessageService_destroy(etMessageService* self);
+
+/* initialization of message pool */
+void etMessageService_initMessagePool(etMessageService* self);
+
+/* message queue interface for push and pop messages */
+void etMessageService_pushMessage(etMessageService* self, etMessage* msg);
+etMessage* etMessageService_popMessage(etMessageService* self);
+
+/* message pool interface to get and return (push and pop) messages */
+etMessage* etMessageService_getMessageBuffer(etMessageService* self, etUInt16 size);
+void etMessageService_returnMessageBuffer(etMessageService* self, etMessage* buffer);
+
+/* functions for debug and service information */
+etInt16 etMessageService_getMessagePoolLowWaterMark(etMessageService* self);
+
+
+#endif /* RMESSAGESERVICE_H_ */
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etSystemProtocol.c b/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etSystemProtocol.c
index 40be5342a..0f8ace1fb 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etSystemProtocol.c
+++ b/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etSystemProtocol.c
@@ -1,89 +1,89 @@
-/**
- * @author generated by eTrice
- *
- * Source File of ProtocolClass etSystemProtocol
- *
- */
-
-#include "etSystemProtocol.h"
-#include "debugging/etMSCLogger.h"
-
-
-/*--------------------- port methods */
-
-
-/* getReplication */
-etInt32 etSystemProtocolReplPort_getReplication(const etSystemProtocolReplPort* self) {
- return ((etReplPort*)self)->size;
-}
-
-
-
-void etSystemProtocolConjPort_poll(const etSystemProtocolConjPort* self) {
- ET_MSC_LOGGER_SYNC_ENTRY("etSystemProtocolConjPort", "poll")
- etPort_sendMessage(self, etSystemProtocol_IN_poll, 0, NULL);
- ET_MSC_LOGGER_SYNC_EXIT
-}
-
-void etSystemProtocolConjReplPort_poll_broadcast(const etSystemProtocolConjReplPort* self) {
- int i;
- ET_MSC_LOGGER_SYNC_ENTRY("etSystemProtocolConjReplPort", "poll")
- for (i=0; i<((etReplPort*)self)->size; ++i) {
- etPort_sendMessage(((etPort*)&((etReplPort*)self)->ports[i]), etSystemProtocol_IN_poll, 0, NULL);
- }
- ET_MSC_LOGGER_SYNC_EXIT
-}
-
-void etSystemProtocolConjReplPort_poll(const etSystemProtocolConjReplPort* self, int idx) {
- ET_MSC_LOGGER_SYNC_ENTRY("etSystemProtocolConjReplPort", "poll")
- if (0<=idx && idx<((etReplPort*)self)->size) {
- etPort_sendMessage(((etPort*)&((etReplPort*)self)->ports[idx]), etSystemProtocol_IN_poll, 0, NULL);
- }
- ET_MSC_LOGGER_SYNC_EXIT
-}
-
-void etSystemProtocolConjPort_terminate(const etSystemProtocolConjPort* self) {
- ET_MSC_LOGGER_SYNC_ENTRY("etSystemProtocolConjPort", "terminate")
- etPort_sendMessage(self, etSystemProtocol_IN_terminate, 0, NULL);
- ET_MSC_LOGGER_SYNC_EXIT
-}
-
-void etSystemProtocolConjReplPort_terminate_broadcast(const etSystemProtocolConjReplPort* self) {
- int i;
- ET_MSC_LOGGER_SYNC_ENTRY("etSystemProtocolConjReplPort", "terminate")
- for (i=0; i<((etReplPort*)self)->size; ++i) {
- etPort_sendMessage(((etPort*)&((etReplPort*)self)->ports[i]), etSystemProtocol_IN_terminate, 0, NULL);
- }
- ET_MSC_LOGGER_SYNC_EXIT
-}
-
-void etSystemProtocolConjReplPort_terminate(const etSystemProtocolConjReplPort* self, int idx) {
- ET_MSC_LOGGER_SYNC_ENTRY("etSystemProtocolConjReplPort", "terminate")
- if (0<=idx && idx<((etReplPort*)self)->size) {
- etPort_sendMessage(((etPort*)&((etReplPort*)self)->ports[idx]), etSystemProtocol_IN_terminate, 0, NULL);
- }
- ET_MSC_LOGGER_SYNC_EXIT
-}
-
-
-/* getReplication */
-etInt32 etSystemProtocolConjReplPort_getReplication(const etSystemProtocolConjReplPort* self) {
- return ((etReplPort*)self)->size;
-}
-
-
-
-/*--------------------- debug helpers */
-
-/* message names as strings for debugging (generate MSC) */
-static const char* const etSystemProtocol_messageStrings[] = {"MIN", "poll", "terminate", "MAX"};
-
-const char* etSystemProtocol_getMessageString(int msg_id) {
- if (msg_id<etSystemProtocol_MSG_MIN || msg_id>etSystemProtocol_MSG_MAX+1){
- /* id out of range */
- return "Message ID out of range";
- }
- else{
- return etSystemProtocol_messageStrings[msg_id];
- }
-}
+/**
+ * @author generated by eTrice
+ *
+ * Source File of ProtocolClass etSystemProtocol
+ *
+ */
+
+#include "etSystemProtocol.h"
+#include "debugging/etMSCLogger.h"
+
+
+/*--------------------- port methods */
+
+
+/* getReplication */
+etInt32 etSystemProtocolReplPort_getReplication(const etSystemProtocolReplPort* self) {
+ return ((etReplPort*)self)->size;
+}
+
+
+
+void etSystemProtocolConjPort_poll(const etSystemProtocolConjPort* self) {
+ ET_MSC_LOGGER_SYNC_ENTRY("etSystemProtocolConjPort", "poll")
+ etPort_sendMessage(self, etSystemProtocol_IN_poll, 0, NULL);
+ ET_MSC_LOGGER_SYNC_EXIT
+}
+
+void etSystemProtocolConjReplPort_poll_broadcast(const etSystemProtocolConjReplPort* self) {
+ int i;
+ ET_MSC_LOGGER_SYNC_ENTRY("etSystemProtocolConjReplPort", "poll")
+ for (i=0; i<((etReplPort*)self)->size; ++i) {
+ etPort_sendMessage(((etPort*)&((etReplPort*)self)->ports[i]), etSystemProtocol_IN_poll, 0, NULL);
+ }
+ ET_MSC_LOGGER_SYNC_EXIT
+}
+
+void etSystemProtocolConjReplPort_poll(const etSystemProtocolConjReplPort* self, int idx) {
+ ET_MSC_LOGGER_SYNC_ENTRY("etSystemProtocolConjReplPort", "poll")
+ if (0<=idx && idx<((etReplPort*)self)->size) {
+ etPort_sendMessage(((etPort*)&((etReplPort*)self)->ports[idx]), etSystemProtocol_IN_poll, 0, NULL);
+ }
+ ET_MSC_LOGGER_SYNC_EXIT
+}
+
+void etSystemProtocolConjPort_terminate(const etSystemProtocolConjPort* self) {
+ ET_MSC_LOGGER_SYNC_ENTRY("etSystemProtocolConjPort", "terminate")
+ etPort_sendMessage(self, etSystemProtocol_IN_terminate, 0, NULL);
+ ET_MSC_LOGGER_SYNC_EXIT
+}
+
+void etSystemProtocolConjReplPort_terminate_broadcast(const etSystemProtocolConjReplPort* self) {
+ int i;
+ ET_MSC_LOGGER_SYNC_ENTRY("etSystemProtocolConjReplPort", "terminate")
+ for (i=0; i<((etReplPort*)self)->size; ++i) {
+ etPort_sendMessage(((etPort*)&((etReplPort*)self)->ports[i]), etSystemProtocol_IN_terminate, 0, NULL);
+ }
+ ET_MSC_LOGGER_SYNC_EXIT
+}
+
+void etSystemProtocolConjReplPort_terminate(const etSystemProtocolConjReplPort* self, int idx) {
+ ET_MSC_LOGGER_SYNC_ENTRY("etSystemProtocolConjReplPort", "terminate")
+ if (0<=idx && idx<((etReplPort*)self)->size) {
+ etPort_sendMessage(((etPort*)&((etReplPort*)self)->ports[idx]), etSystemProtocol_IN_terminate, 0, NULL);
+ }
+ ET_MSC_LOGGER_SYNC_EXIT
+}
+
+
+/* getReplication */
+etInt32 etSystemProtocolConjReplPort_getReplication(const etSystemProtocolConjReplPort* self) {
+ return ((etReplPort*)self)->size;
+}
+
+
+
+/*--------------------- debug helpers */
+
+/* message names as strings for debugging (generate MSC) */
+static const char* const etSystemProtocol_messageStrings[] = {"MIN", "poll", "terminate", "MAX"};
+
+const char* etSystemProtocol_getMessageString(int msg_id) {
+ if (msg_id<etSystemProtocol_MSG_MIN || msg_id>etSystemProtocol_MSG_MAX+1){
+ /* id out of range */
+ return "Message ID out of range";
+ }
+ else{
+ return etSystemProtocol_messageStrings[msg_id];
+ }
+}
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etSystemProtocol.h b/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etSystemProtocol.h
index 730d5dbce..260e15608 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etSystemProtocol.h
+++ b/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etSystemProtocol.h
@@ -1,51 +1,51 @@
-/**
- * @author generated by eTrice
- *
- * Header File of ProtocolClass etSystemProtocol
- *
- */
-
-#ifndef _ETSYSTEMPROTOCOL_H_
-#define _ETSYSTEMPROTOCOL_H_
-
-#include "etDatatypes.h"
-#include "modelbase/etPort.h"
-
-/* message IDs */
-enum etSystemProtocol_msg_ids {
- etSystemProtocol_MSG_MIN = 0,
- etSystemProtocol_IN_poll = 1,
- etSystemProtocol_IN_terminate = 2,
- etSystemProtocol_MSG_MAX = 3
-};
-
-/*--------------------- port structs and methods */
-typedef etPort etSystemProtocolPort;
-typedef etReplPort etSystemProtocolReplPort;
-
-
-
-
-etInt32 etSystemProtocolReplPort_getReplication(const etSystemProtocolReplPort* self);
-typedef etPort etSystemProtocolConjPort;
-typedef etReplPort etSystemProtocolConjReplPort;
-
-
-void etSystemProtocolConjPort_poll(const etSystemProtocolConjPort* self);
-void etSystemProtocolConjReplPort_poll_broadcast(const etSystemProtocolConjReplPort* self);
-void etSystemProtocolConjReplPort_poll(const etSystemProtocolConjReplPort* self, int idx);
-void etSystemProtocolConjPort_terminate(const etSystemProtocolConjPort* self);
-void etSystemProtocolConjReplPort_terminate_broadcast(const etSystemProtocolConjReplPort* self);
-void etSystemProtocolConjReplPort_terminate(const etSystemProtocolConjReplPort* self, int idx);
-
-
-etInt32 etSystemProtocolConjReplPort_getReplication(const etSystemProtocolConjReplPort* self);
-
-/*--------------------- debug helpers */
-
-/* get message string for message id */
-const char* etSystemProtocol_getMessageString(int msg_id);
-
-
-#endif /* _ETSYSTEMPROTOCOL_H_ */
-
+/**
+ * @author generated by eTrice
+ *
+ * Header File of ProtocolClass etSystemProtocol
+ *
+ */
+
+#ifndef _ETSYSTEMPROTOCOL_H_
+#define _ETSYSTEMPROTOCOL_H_
+
+#include "etDatatypes.h"
+#include "modelbase/etPort.h"
+
+/* message IDs */
+enum etSystemProtocol_msg_ids {
+ etSystemProtocol_MSG_MIN = 0,
+ etSystemProtocol_IN_poll = 1,
+ etSystemProtocol_IN_terminate = 2,
+ etSystemProtocol_MSG_MAX = 3
+};
+
+/*--------------------- port structs and methods */
+typedef etPort etSystemProtocolPort;
+typedef etReplPort etSystemProtocolReplPort;
+
+
+
+
+etInt32 etSystemProtocolReplPort_getReplication(const etSystemProtocolReplPort* self);
+typedef etPort etSystemProtocolConjPort;
+typedef etReplPort etSystemProtocolConjReplPort;
+
+
+void etSystemProtocolConjPort_poll(const etSystemProtocolConjPort* self);
+void etSystemProtocolConjReplPort_poll_broadcast(const etSystemProtocolConjReplPort* self);
+void etSystemProtocolConjReplPort_poll(const etSystemProtocolConjReplPort* self, int idx);
+void etSystemProtocolConjPort_terminate(const etSystemProtocolConjPort* self);
+void etSystemProtocolConjReplPort_terminate_broadcast(const etSystemProtocolConjReplPort* self);
+void etSystemProtocolConjReplPort_terminate(const etSystemProtocolConjReplPort* self, int idx);
+
+
+etInt32 etSystemProtocolConjReplPort_getReplication(const etSystemProtocolConjReplPort* self);
+
+/*--------------------- debug helpers */
+
+/* get message string for message id */
+const char* etSystemProtocol_getMessageString(int msg_id);
+
+
+#endif /* _ETSYSTEMPROTOCOL_H_ */
+

Back to the top