Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/ProtocolClassGen.xtend')
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/ProtocolClassGen.xtend133
1 files changed, 71 insertions, 62 deletions
diff --git a/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/ProtocolClassGen.xtend b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/ProtocolClassGen.xtend
index acae5bb1d..6697ec6bb 100644
--- a/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/ProtocolClassGen.xtend
+++ b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/ProtocolClassGen.xtend
@@ -1,35 +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:
- * Henrik Rentz-Reichert (initial contribution)
- * Thomas Schuetz (changed for C code generator)
- *
- *******************************************************************************/
-package org.eclipse.etrice.generator.cpp.gen
-
-import com.google.inject.Inject
-import com.google.inject.Singleton
-import org.eclipse.etrice.core.room.CommunicationType
-import org.eclipse.etrice.core.room.DataClass
-import org.eclipse.etrice.core.room.Message
-import org.eclipse.etrice.core.room.PrimitiveType
-import org.eclipse.etrice.core.room.ProtocolClass
-
-import org.eclipse.etrice.generator.generic.GenericProtocolClassGenerator
-import org.eclipse.etrice.generator.generic.ProcedureHelpers
-import org.eclipse.etrice.generator.generic.RoomExtensions
-import org.eclipse.etrice.generator.generic.TypeHelpers
-
-import org.eclipse.xtext.generator.JavaIoFileSystemAccess
+package org.eclipse.etrice.generator.cpp.gen
+
+import com.google.inject.Inject
+import com.google.inject.Singleton
import org.eclipse.etrice.core.genmodel.base.ILogger
import org.eclipse.etrice.core.genmodel.etricegen.Root
+import org.eclipse.etrice.core.room.CommunicationType
+import org.eclipse.etrice.core.room.DataClass
+import org.eclipse.etrice.core.room.Message
+import org.eclipse.etrice.core.room.PrimitiveType
+import org.eclipse.etrice.core.room.ProtocolClass
+import org.eclipse.etrice.generator.generic.GenericProtocolClassGenerator
+import org.eclipse.etrice.generator.generic.ProcedureHelpers
+import org.eclipse.etrice.generator.generic.RoomExtensions
+import org.eclipse.etrice.generator.generic.TypeHelpers
+import org.eclipse.xtext.generator.JavaIoFileSystemAccess
+import org.eclipse.etrice.core.room.InterfaceItem
+import org.eclipse.etrice.core.room.Port
+import org.eclipse.etrice.core.room.SAPRef
+import org.eclipse.etrice.core.room.SPPRef
@Singleton
@@ -159,7 +149,6 @@ class ProtocolClassGen extends GenericProtocolClassGenerator {
int getIndexOf(const etRuntime::InterfaceItemBase& ifitem){ return ifitem.getIdx(); }
«portClassName» get(int i) {return m_ports.at(i);}
- virtual void receive(etRuntime::Message* m);
«IF pc.commType==CommunicationType::EVENT_DRIVEN»
// outgoing messages
«FOR m : pc.getOutgoing(conj)»
@@ -171,6 +160,37 @@ class ProtocolClassGen extends GenericProtocolClassGenerator {
'''
}
+ def private generateSourceFile(Root root, ProtocolClass pc) {'''
+ /**
+ * @author generated by eTrice
+ *
+ * Source File of ProtocolClass «pc.name»
+ *
+ */
+
+ #include "«pc.getCppHeaderFileName»"
+ #include "common/debugging/DebuggingService.h"
+ #include <iostream>
+
+ using namespace etRuntime;
+
+ «helpers.userCode(pc.userCode3)»
+
+ «IF pc.commType==CommunicationType::EVENT_DRIVEN»
+ «helpers.userCode(pc.userCode2)»
+
+ «portClassImplementation(pc, false)»
+ «portClassImplementation(pc, true)»
+
+ /*--------------------- debug helpers */
+ «generateDebugHelpersImplementation(root, pc)»
+ «ENDIF»
+
+
+ '''
+ }
+
+
def portClassImplementation(ProtocolClass pc, Boolean conj) {
var pclass = pc.getPortClass(conj)
var portClassName = pc.getPortClassName(conj)
@@ -257,39 +277,6 @@ class ProtocolClassGen extends GenericProtocolClassGenerator {
'''
}
- def private generateSourceFile(Root root, ProtocolClass pc) {'''
- /**
- * @author generated by eTrice
- *
- * Source File of ProtocolClass «pc.name»
- *
- */
-
- #include "«pc.getCppHeaderFileName»"
- #include "common/debugging/DebuggingService.h"
- #include <iostream>
- «FOR classes : root.getReferencedDataClasses(pc)»
- #include "«classes.name».h"
- «ENDFOR»
-
- using namespace etRuntime;
-
- «helpers.userCode(pc.userCode3)»
-
- «IF pc.commType==CommunicationType::EVENT_DRIVEN»
- «helpers.userCode(pc.userCode2)»
-
- «portClassImplementation(pc, false)»
- «portClassImplementation(pc, true)»
-
- /*--------------------- debug helpers */
- «generateDebugHelpersImplementation(root, pc)»
- «ENDIF»
-
-
- '''
- }
-
@@ -387,4 +374,26 @@ class ProtocolClassGen extends GenericProtocolClassGenerator {
'''
//TODO derived data classes are not yet handled correctly
}
+
+ override getMessageID(Message msg, InterfaceItem item) {
+ if (item instanceof Port) {
+ var p = item as Port;
+ var direction = if (p.isConjugated())"OUT_" else "IN_"
+ return enumInUse(p.getProtocol().getName(), direction+msg.getName())
+ }
+ else if (item instanceof SAPRef) {
+ var sap = item as SAPRef;
+ return enumInUse(sap.getProtocol().getName(), "OUT_"+msg.getName())
+ }
+ else if (item instanceof SPPRef) {
+ var spp = item as SPPRef;
+ return enumInUse(spp.getProtocol().getName(), "IN_"+msg.getName())
+ }
+
+ return "unknown interface item";
+ }
+
+ def String enumInUse(String namespace, String member) {
+ return namespace+"::"+member
+ }
} \ No newline at end of file

Back to the top