Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/ActorClassGen.xtend32
-rw-r--r--plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/CTranslationProvider.java88
-rw-r--r--plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/ProtocolClassGen.xtend57
-rw-r--r--plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/SubSystemClassGen.xtend229
-rw-r--r--plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/setup/GeneratorModule.java3
-rw-r--r--plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/ActorClassGen.java126
-rw-r--r--plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/ProtocolClassGen.java206
-rw-r--r--plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/SubSystemClassGen.java384
-rw-r--r--plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/setup/GeneratorModule.java5
-rw-r--r--plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/DefaultTranslationProvider.java65
-rw-r--r--plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/DetailCodeTranslator.java11
-rw-r--r--plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/ITranslationProvider.java35
-rw-r--r--plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/extensions/RoomExtensions.xtend52
-rw-r--r--plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/GenericStateMachineGenerator.xtend27
-rw-r--r--plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/extensions/RoomExtensions.java81
-rw-r--r--plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/GenericStateMachineGenerator.java1625
-rw-r--r--plugins/org.eclipse.etrice.logging/build.properties3
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/etPort.c7
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/etPort.h21
-rw-r--r--tests/org.eclipse.etrice.generator.tests/src/org/eclipse/etrice/generator/base/TestDetailCodeTranslator.java5
20 files changed, 1828 insertions, 1234 deletions
diff --git a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/ActorClassGen.xtend b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/ActorClassGen.xtend
index 608f61ab1..d1e052c41 100644
--- a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/ActorClassGen.xtend
+++ b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/ActorClassGen.xtend
@@ -94,19 +94,35 @@ class ActorClassGen extends GenericActorClassGenerator {
typedef struct «xpac.name» «xpac.name»;
/* const part of ActorClass (ROM) */
- typedef struct «xpac.name»_const {
-««« TODO: needed? const «xpac.name»* actor;
- /* Ports */
- «FOR ep : ac.getEndPorts()»
- const «ep.getPortClassName()» «ep.name»;
- «ENDFOR»
- } «xpac.name»_const;
+ «IF ac.allEndPorts.empty»
+ /* this actor class has no ports and thus no constant data */
+ «ELSE»
+ typedef struct «xpac.name»_const {
+ /* simple ports */
+ «FOR ep : ac.allEndPorts»
+ «IF ep.multiplicity==1»
+ const «ep.getPortClassName()» «ep.name»;
+ «ENDIF»
+ «ENDFOR»
+
+ /* replicated ports */
+ «FOR ep : ac.allEndPorts»
+ «IF ep.multiplicity!=1»
+ const etReplPort «ep.name»;
+ «ENDIF»
+ «ENDFOR»
+ } «xpac.name»_const;
+ «ENDIF»
/* variable part of ActorClass (RAM) */
struct «xpac.name» {
- const «xpac.name»_const* constData;
+ «IF !ac.allEndPorts.empty»
+ const «xpac.name»_const* constData;
+
+ «ENDIF»
«helpers.attributes(ac.allAttributes)»
«IF xpac.hasNonEmptyStateMachine»
+
«stateMachineGen.genDataMembers(xpac, ac)»
«ENDIF»
};
diff --git a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/CTranslationProvider.java b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/CTranslationProvider.java
new file mode 100644
index 000000000..64a7a3b86
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/CTranslationProvider.java
@@ -0,0 +1,88 @@
+/*******************************************************************************
+ * 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:
+ * Henrik Rentz-Reichert (initial contribution)
+ *
+ *******************************************************************************/
+
+package org.eclipse.etrice.generator.c.gen;
+
+import java.util.ArrayList;
+
+import org.eclipse.etrice.core.room.ActorClass;
+import org.eclipse.etrice.core.room.Attribute;
+import org.eclipse.etrice.core.room.DetailCode;
+import org.eclipse.etrice.core.room.InterfaceItem;
+import org.eclipse.etrice.core.room.Message;
+import org.eclipse.etrice.core.room.Operation;
+import org.eclipse.etrice.core.room.Port;
+import org.eclipse.etrice.generator.base.ITranslationProvider;
+import org.eclipse.etrice.generator.extensions.RoomExtensions;
+
+import com.google.inject.Inject;
+
+public class CTranslationProvider implements ITranslationProvider {
+
+ @Inject private RoomExtensions roomExt;
+
+ @Override
+ public void setActorClass(ActorClass ac) {
+ }
+
+ @Override
+ public boolean translateMembers() {
+ return true;
+ }
+
+ @Override
+ public String getAttributeText(Attribute att, String orig) {
+ return "self->"+att.getName();
+ }
+
+ @Override
+ public String getOperationText(Operation op, ArrayList<String> args, String orig) {
+ StringBuilder result = new StringBuilder();
+ result.append(op.getName()+"(self");
+ for (String arg : args) {
+ result.append(", "+arg);
+ }
+ result.append(") /* ORIG: "+orig+" */");
+ return result.toString();
+ }
+
+ @Override
+ public String getInterfaceItemMessageText(InterfaceItem item, Message msg, ArrayList<String> args, String orig) {
+ String result = orig;
+ if (item instanceof Port) {
+ Port p = (Port) item;
+ if (p.getMultiplicity()==1)
+ result = roomExt.getPortClassName(p)+"_"+msg.getName()+"(&self->constData->"+item.getName()+")";
+ else
+ result = roomExt.getPortClassName(p)+"_"+msg.getName()+"_broadcast(&self->constData->"+item.getName()+")";
+
+ result += " /* "+orig+" */";
+ }
+ return result;
+ }
+
+ @Override
+ public String getInterfaceItemMessageValue(InterfaceItem item, Message msg, String orig) {
+ return null;
+ }
+
+ @Override
+ public boolean translateTags() {
+ return false;
+ }
+
+ @Override
+ public String translateTag(String tag, DetailCode code) {
+ return null;
+ }
+
+}
diff --git a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/ProtocolClassGen.xtend b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/ProtocolClassGen.xtend
index d3b0dfd12..09e8012cc 100644
--- a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/ProtocolClassGen.xtend
+++ b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/ProtocolClassGen.xtend
@@ -46,7 +46,6 @@ class ProtocolClassGen extends GenericProtocolClassGenerator {
logger.logInfo("generating ProtocolClass source '"+pc.getCSourceFileName+"' in '"+path+"'")
fileAccess.setOutputPath(path)
fileAccess.generateFile(pc.getCSourceFileName, root.generateSourceFile(pc))
-
}
}
@@ -86,7 +85,6 @@ class ProtocolClassGen extends GenericProtocolClassGenerator {
«helpers.userCode(pc.userCode2)»
-
«generateIncludeGuardEnd(pc.name)»
'''
@@ -233,51 +231,58 @@ class ProtocolClassGen extends GenericProtocolClassGenerator {
}
def portClassHeader(ProtocolClass pc, Boolean conj){
- '''
- «var portClassName = pc.getPortClassName(conj)»
- «var pClass = pc.getPortClass(conj)»
+ var portClassName = pc.getPortClassName(conj)
+ var replPortClassName = pc.getPortClassName(conj, true)
+ var pClass = pc.getPortClass(conj)
+ var ports = if (conj) pc.getAllIncomingMessages() else pc.getAllOutgoingMessages()
- typedef etPort «portClassName»;
+ '''
- «IF !conj»
-««« send functions for outgoing messages
- «FOR message : pc.getAllOutgoingMessages()»
- void «portClassName»_«message.name»(const «portClassName»* self);
- «ENDFOR»
- «ELSE»
-««« send functions for incoming messages
- «FOR message : pc.getAllIncomingMessages()»
+ typedef etPort «portClassName»;
+ typedef etReplPort «replPortClassName»;
+
+ «FOR message : ports»
void «portClassName»_«message.name»(const «portClassName»* self);
+ void «replPortClassName»_«message.name»_broadcast(const «replPortClassName»* self);
+ void «replPortClassName»_«message.name»(const «replPortClassName»* self, int idx);
«ENDFOR»
- «ENDIF»
-
-
-««« «ClassOperationSignature(portClassName, "MyOperation1", "int a, int b", "void", true)»
-««« «ClassOperationSignature(portClassName, "MyOperation2", "", "int", false)»
-
-
'''
}
def portClassSource(ProtocolClass pc, Boolean conj){
var portClassName = pc.getPortClassName(conj)
+ var replPortClassName = pc.getPortClassName(conj, true)
var pClass = pc.getPortClass(conj)
var messages = if (conj) pc.allIncomingMessages else pc.allOutgoingMessages
var dir = if (conj) "IN_" else "OUT_"
'''
«FOR message : messages»
- void «portClassName»_«message.name»(const «portClassName»* self){
+
+ void «portClassName»_«message.name»(const «portClassName»* self) {
ET_MSC_LOGGER_SYNC_ENTRY("«portClassName»", "«message.name»")
if (self->receiveMessageFunc!=NULL) {
- etMessage* msg = etMessageService_getMessageBuffer(self->msgService, sizeof(etMessage));
- msg->address = self->peerAddress;
- msg->evtID = «memberInUse(pc.name, dir+message.name)»;
- etMessageService_pushMessage(self->msgService, msg);
+ etPort_sendMessage(self, «memberInUse(pc.name, dir+message.name)»);
+ }
+ ET_MSC_LOGGER_SYNC_EXIT
+ }
+
+ void «replPortClassName»_«message.name»_broadcast(const «replPortClassName»* self) {
+ int i;
+ ET_MSC_LOGGER_SYNC_ENTRY("«replPortClassName»", "«message.name»")
+ for (i=0; i<self->size; ++i) {
+ etPort_sendMessage((etPort*)(&self->ports[i]), «memberInUse(pc.name, dir+message.name)»);
}
ET_MSC_LOGGER_SYNC_EXIT
}
+ void «replPortClassName»_«message.name»(const «replPortClassName»* self, int idx) {
+ ET_MSC_LOGGER_SYNC_ENTRY("«replPortClassName»", "«message.name»")
+ if (0<=idx && idx<self->size) {
+ etPort_sendMessage((etPort*)(&self->ports[idx]), «memberInUse(pc.name, dir+message.name)»);
+ }
+ ET_MSC_LOGGER_SYNC_EXIT
+ }
«ENDFOR»
'''
}
diff --git a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/SubSystemClassGen.xtend b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/SubSystemClassGen.xtend
index c8ae1a94d..ce83ef9c1 100644
--- a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/SubSystemClassGen.xtend
+++ b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/SubSystemClassGen.xtend
@@ -13,6 +13,8 @@
package org.eclipse.etrice.generator.c.gen
+import java.util.HashMap
+import java.util.ArrayList
import com.google.inject.Inject
import com.google.inject.Singleton
import org.eclipse.etrice.core.room.SubSystemClass
@@ -217,54 +219,89 @@ class SubSystemClassGen {
«FOR ai : ssi.allContainedInstances»
/* instance «ai.path.getPathName()» */
- static const «ai.actorClass.name»_const «ai.path.getPathName()»_const = {
-««« TODO: needed? &«ai.path.getPathName()»,
- /* Ports: {myActor, etReceiveMessage, msgService, peerAddress, localId} */
- «FOR pi : ai.ports»
- «genPortInitializer(root, ai, pi)»
- «ENDFOR»
-
- };
- static «ai.actorClass.name» «ai.path.getPathName()» = {&«ai.path.getPathName()»_const};
+ «IF ai.ports.empty»
+ /* no ports, nothing to initialize statically */
+ «ELSE»
+ «genActorInstanceInitializer(root, ai)»
+ «ENDIF»
«ENDFOR»
+ '''
+ }
+
+ def private genActorInstanceInitializer(Root root, ActorInstance ai) {
+ var instName = ai.path.pathName
-
+ // list of replicated ports
+ var replPorts = new ArrayList<PortInstance>()
+ replPorts.addAll(ai.ports.filter(e|e.kind.literal!="RELAY" && e.port.multiplicity!=1))
+
+ // list of ports, simple first, then replicated
+ var ports = new ArrayList<PortInstance>()
+ ports.addAll(ai.ports.filter(e|e.kind.literal!="RELAY" && e.port.multiplicity==1).union(replPorts))
-««« «FOR ai : ssi.allContainedInstances»
-««« // actor instance «ai.path» itself => Systemport Address
-««« // TODOTJ: For each Actor, multiple addresses should be generated (actor?, systemport, debugport)
-««« Address addr_item_«ai.path.getPathName()» = new Address(0,«ai.threadId»,«ai.objId»);
-««« // interface items of «ai.path»
-««« «FOR pi : ai.orderedIfItemInstances»
-««« «IF pi instanceof ServiceImplInstance || pi.peers.size>1»
-««« «FOR peer : pi.peers»
-««« «var i = pi.peers.indexOf(peer)»
-««« Address addr_item_«pi.path.getPathName()»_«i» = new Address(0,«pi.threadId»,«pi.objId+i»);
-««« «ENDFOR»
-««« «ELSE»
-««« Address addr_item_«pi.path.getPathName()» = new Address(0,«ai.threadId»,«pi.objId»);
-««« «ENDIF»
-««« «ENDFOR»
-««« «ENDFOR»
+ // compute replicated port offsets
+ var offsets = new HashMap<PortInstance, Integer>()
+ var offset = 0
+ for (p: replPorts) {
+ offsets.put(p, offset)
+ offset = offset + p.peers.size
+ }
'''
- }
-
+ «IF !replPorts.empty»
+ static const etReplSubPort «instName»_repl_sub_ports[«offset»] = {
+ /* Replicated Sub Ports: {myActor, etReceiveMessage, msgService, peerAddress, localId, idx} */
+ «FOR pi : replPorts SEPARATOR ","»
+ «genReplSubPortInitializers(root, ai, pi)»
+ «ENDFOR»
+ };
+ «ENDIF»
+ static const «ai.actorClass.name»_const «instName»_const = {
+ /* Ports: {myActor, etReceiveMessage, msgService, peerAddress, localId} */
+ «FOR pi : ports SEPARATOR ","»
+ «IF pi.port.multiplicity==1»
+ «genPortInitializer(root, ai, pi)»
+ «ELSE»
+ {«pi.peers.size», «instName»_repl_sub_ports+«offsets.get(pi)»}
+ «ENDIF»
+ «ENDFOR»
+ };
+ static «ai.actorClass.name» «instName» = {&«instName»_const};
+ '''}
+
def private String genPortInitializer(Root root, ActorInstance ai, PortInstance pi) {
var recvMsg = if (pi.peers.empty) "NULL" else ai.actorClass.name+"_ReceiveMessage"
var objId = if (pi.peers.empty) 0 else pi.peers.get(0).objId
-
- // TODO: no replicated ports yet
+ var idx = if (pi.peers.empty) 0 else pi.peers.get(0).peers.indexOf(pi)
"{&"+ai.path.getPathName()+", "
+recvMsg+", "
+"&msgService_Thread1, "
- +objId+", "
+ +(objId+idx)+", "
+(root.getExpandedActorClass(ai).getInterfaceItemLocalId(pi.port)+1)
+"} /* Port "+pi.name+" */"
}
+ def private String genReplSubPortInitializers(Root root, ActorInstance ai, PortInstance pi) {
+ var result = ""
+
+ for (p: pi.peers) {
+ var idx = pi.peers.indexOf(p)
+ var comma = if (idx<pi.peers.size-1) "," else ""
+ result = result +
+ "{&"+ai.path.getPathName()+", "
+ +ai.actorClass.name+"_ReceiveMessage, "
+ +"&msgService_Thread1, "
+ +p.objId+", "
+ +(root.getExpandedActorClass(ai).getInterfaceItemLocalId(pi.port)+1)+", "
+ +idx
+ +"}"+comma+" /* Repl Sub Port "+pi.name+" idx +"+idx+"*/\n"
+ }
+
+ return result
+ }
+
def generateDispatcherFile(Root root, SubSystemInstance ssi, SubSystemClass ssc) {'''
/**
* @author generated by eTrice
@@ -284,9 +321,17 @@ class SubSystemClassGen {
«FOR ai : ssi.allContainedInstances»
/* interface items of «ai.path» */
«FOR pi : ai.orderedIfItemInstances»
- case «pi.objId»:
- etPort_receive(&«ai.path.pathName»_const.«pi.name», msg);
- break;
+ «IF pi instanceof PortInstance && (pi as PortInstance).port.multiplicity!=1»
+ «FOR peer: pi.peers»
+ case «pi.objId+pi.peers.indexOf(peer)»:
+ etPort_receive((etPort*)&«ai.path.pathName»_const.«pi.name».ports[«pi.peers.indexOf(peer)»], msg);
+ break;
+ «ENDFOR»
+ «ELSE»
+ case «pi.objId»:
+ etPort_receive(&«ai.path.pathName»_const.«pi.name», msg);
+ break;
+ «ENDIF»
«ENDFOR»
«ENDFOR»
@@ -299,121 +344,5 @@ class SubSystemClassGen {
'''
}
-// «var models = root.getReferencedModels(ssc)»
-// «FOR model : models»import «model.name».*;«ENDFOR»
-//
-//
-// «helpers.UserCode(ssc.userCode1)»
-//
-// public class «ssi.name» extends SubSystemClassBase{
-//
-// «helpers.UserCode(ssc.userCode2)»
-//
-// public «ssi.name»(IRTObject parent, String name) {
-// super(parent, name);
-// }
-//
-// @Override
-// public void receiveEvent(InterfaceItemBase ifitem, int evt, Object data){
-// }
-//
-// @Override
-// public void instantiateMessageServices(){
-//
-// RTServices.getInstance().getMsgSvcCtrl().addMsgSvc(new MessageService(this, new Address(0, 0, 0),"MessageService_Main"));
-// «FOR thread : ssc.threads»
-// RTServices.getInstance().getMsgSvcCtrl().addMsgSvc(new MessageService(this, new Address(0, «ssc.threads.indexOf(thread)+1», 0),"MessageService_«thread.name»", «thread.prio»));
-// «ENDFOR»
-// }
-//
-// @Override
-// public void instantiateActors(){
-// // all addresses
-// // Addresses for the Subsystem Systemport
-// «FOR ai : ssi.allContainedInstances.indexed(ssi.maxObjId)»
-// Address addr_item_SystemPort_«ssi.allContainedInstances.indexOf(ai.value)» = new Address(0,0,«ai.index1»);
-// «ENDFOR»
-//
-// «FOR ai : ssi.allContainedInstances»
-// // actor instance «ai.path» itself => Systemport Address
-// // TODOTJ: For each Actor, multiple addresses should be generated (actor?, systemport, debugport)
-// Address addr_item_«ai.path.getPathName()» = new Address(0,«ai.threadId»,«ai.objId»);
-// // interface items of «ai.path»
-// «FOR pi : ai.orderedIfItemInstances»
-// «IF pi instanceof ServiceImplInstance || pi.peers.size>1»
-// «FOR peer : pi.peers»
-// «var i = pi.peers.indexOf(peer)»
-// Address addr_item_«pi.path.getPathName()»_«i» = new Address(0,«pi.threadId»,«pi.objId+i»);
-// «ENDFOR»
-// «ELSE»
-// Address addr_item_«pi.path.getPathName()» = new Address(0,«ai.threadId»,«pi.objId»);
-// «ENDIF»
-// «ENDFOR»
-// «ENDFOR»
-//
-// // instantiate all actor instances
-// instances = new ActorClassBase[«ssi.allContainedInstances.size»];
-// «FOR ai : ssi.allContainedInstances»
-// instances[«ssi.allContainedInstances.indexOf(ai)»] = new «ai.actorClass.name»(
-// «IF ai.eContainer instanceof SubSystemInstance»
-// this,
-// «ELSE»
-// instances[«ssi.allContainedInstances.indexOf(ai.eContainer)»],
-// «ENDIF»
-// "«ai.name»",
-// // own interface item addresses
-// new Address[][] {{addr_item_«ai.path.getPathName()»}«IF !ai.orderedIfItemInstances.empty»,«ENDIF»
-// «FOR pi : ai.orderedIfItemInstances SEPARATOR ","»
-// {
-// «IF pi instanceof ServiceImplInstance || pi.peers.size>1»
-// «FOR peer : pi.peers SEPARATOR ","»
-// addr_item_«pi.path.getPathName()»_«pi.peers.indexOf(peer)»
-// «ENDFOR»
-// «ELSE»
-// addr_item_«pi.path.getPathName()»
-// «ENDIF»
-// }
-// «ENDFOR»
-// },
-// // peer interface item addresses
-// new Address[][] {{addr_item_SystemPort_«ssi.allContainedInstances.indexOf(ai)»}«IF !ai.orderedIfItemInstances.empty»,«ENDIF»
-// «FOR pi : ai.orderedIfItemInstances SEPARATOR ","»
-// {
-// «IF !(pi instanceof ServiceImplInstance) && pi.peers.isEmpty»
-// null
-// «ELSE»
-// «FOR pp : pi.peers SEPARATOR ","»
-// «IF pp instanceof ServiceImplInstance || pp.peers.size>1»
-// addr_item_«pp.path.getPathName()»_«pp.peers.indexOf(pi)»
-// «ELSE»
-// addr_item_«pp.path.getPathName()»
-// «ENDIF»
-// «ENDFOR»
-// «ENDIF»
-// }
-// «ENDFOR»
-// }
-// );
-// «ENDFOR»
-//
-// // create the subsystem system port
-// RTSystemPort = new RTSystemServicesProtocolConjPortRepl(this, "RTSystemPort",
-// 0, //local ID
-// // own addresses
-// new Address[]{
-// «FOR ai : ssi.allContainedInstances SEPARATOR ","»
-// addr_item_SystemPort_«ssi.allContainedInstances.indexOf(ai)»
-// «ENDFOR»
-// },
-// // peer addresses
-// new Address[]{
-// «FOR ai : ssi.allContainedInstances SEPARATOR ","»
-// addr_item_«ai.path.getPathName()»
-// «ENDFOR»
-// });
-//
-// }
-// };
-
} \ No newline at end of file
diff --git a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/setup/GeneratorModule.java b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/setup/GeneratorModule.java
index 32deefc75..ef3849a1b 100644
--- a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/setup/GeneratorModule.java
+++ b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/setup/GeneratorModule.java
@@ -14,7 +14,9 @@ package org.eclipse.etrice.generator.c.setup;
import org.eclipse.etrice.generator.base.AbstractGenerator;
import org.eclipse.etrice.generator.base.GeneratorBaseModule;
+import org.eclipse.etrice.generator.base.ITranslationProvider;
import org.eclipse.etrice.generator.c.Main;
+import org.eclipse.etrice.generator.c.gen.CTranslationProvider;
import org.eclipse.etrice.generator.c.gen.MainGen;
import org.eclipse.etrice.generator.generic.ILanguageExtension;
import org.eclipse.xtext.generator.IGenerator;
@@ -34,6 +36,7 @@ public class GeneratorModule extends GeneratorBaseModule {
// bind language specific code to generic Interfaces
binder.bind(ILanguageExtension.class).to(CExtensions.class);
+ binder.bind(ITranslationProvider.class).to(CTranslationProvider.class);
}
}
diff --git a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/ActorClassGen.java b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/ActorClassGen.java
index 1d4ff0462..183b717b9 100644
--- a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/ActorClassGen.java
+++ b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/ActorClassGen.java
@@ -22,6 +22,7 @@ import org.eclipse.etrice.generator.generic.GenericActorClassGenerator;
import org.eclipse.etrice.generator.generic.ProcedureHelpers;
import org.eclipse.etrice.generator.generic.TypeHelpers;
import org.eclipse.xtext.generator.JavaIoFileSystemAccess;
+import org.eclipse.xtext.xbase.lib.BooleanExtensions;
import org.eclipse.xtext.xbase.lib.Functions.Function1;
import org.eclipse.xtext.xbase.lib.IterableExtensions;
import org.eclipse.xtext.xbase.lib.ObjectExtensions;
@@ -195,47 +196,93 @@ public class ActorClassGen extends GenericActorClassGenerator {
_builder.newLine();
_builder.append("/* const part of ActorClass (ROM) */");
_builder.newLine();
- _builder.append("typedef struct ");
- String _name_6 = xpac.getName();
- _builder.append(_name_6, "");
- _builder.append("_const {");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("/* Ports */");
- _builder.newLine();
{
- List<Port> _endPorts = this.roomExt.getEndPorts(ac);
- for(final Port ep : _endPorts) {
+ List<Port> _allEndPorts = this.roomExt.getAllEndPorts(ac);
+ boolean _isEmpty = _allEndPorts.isEmpty();
+ if (_isEmpty) {
+ _builder.append("/* this actor class has no ports and thus no constant data */");
+ _builder.newLine();
+ } else {
+ _builder.append("typedef struct ");
+ String _name_6 = xpac.getName();
+ _builder.append(_name_6, "");
+ _builder.append("_const {");
+ _builder.newLineIfNotEmpty();
_builder.append("\t");
- _builder.append("const ");
- String _portClassName = this.roomExt.getPortClassName(ep);
- _builder.append(_portClassName, " ");
- _builder.append(" ");
- String _name_7 = ep.getName();
- _builder.append(_name_7, " ");
- _builder.append(";");
+ _builder.append("/* simple ports */");
+ _builder.newLine();
+ {
+ List<Port> _allEndPorts_1 = this.roomExt.getAllEndPorts(ac);
+ for(final Port ep : _allEndPorts_1) {
+ {
+ int _multiplicity = ep.getMultiplicity();
+ boolean _operator_equals = ObjectExtensions.operator_equals(((Integer)_multiplicity), ((Integer)1));
+ if (_operator_equals) {
+ _builder.append("\t");
+ _builder.append("const ");
+ String _portClassName = this.roomExt.getPortClassName(ep);
+ _builder.append(_portClassName, " ");
+ _builder.append(" ");
+ String _name_7 = ep.getName();
+ _builder.append(_name_7, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ }
+ }
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("/* replicated ports */");
+ _builder.newLine();
+ {
+ List<Port> _allEndPorts_2 = this.roomExt.getAllEndPorts(ac);
+ for(final Port ep_1 : _allEndPorts_2) {
+ {
+ int _multiplicity_1 = ep_1.getMultiplicity();
+ boolean _operator_notEquals = ObjectExtensions.operator_notEquals(((Integer)_multiplicity_1), ((Integer)1));
+ if (_operator_notEquals) {
+ _builder.append("\t");
+ _builder.append("const etReplPort ");
+ String _name_8 = ep_1.getName();
+ _builder.append(_name_8, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ }
+ }
+ _builder.append("} ");
+ String _name_9 = xpac.getName();
+ _builder.append(_name_9, "");
+ _builder.append("_const;");
_builder.newLineIfNotEmpty();
}
}
- _builder.append("} ");
- String _name_8 = xpac.getName();
- _builder.append(_name_8, "");
- _builder.append("_const;");
- _builder.newLineIfNotEmpty();
_builder.newLine();
_builder.append("/* variable part of ActorClass (RAM) */");
_builder.newLine();
_builder.append("struct ");
- String _name_9 = xpac.getName();
- _builder.append(_name_9, "");
- _builder.append(" {");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("const ");
String _name_10 = xpac.getName();
- _builder.append(_name_10, " ");
- _builder.append("_const* constData;");
+ _builder.append(_name_10, "");
+ _builder.append(" {");
_builder.newLineIfNotEmpty();
+ {
+ List<Port> _allEndPorts_3 = this.roomExt.getAllEndPorts(ac);
+ boolean _isEmpty_1 = _allEndPorts_3.isEmpty();
+ boolean _operator_not = BooleanExtensions.operator_not(_isEmpty_1);
+ if (_operator_not) {
+ _builder.append("\t");
+ _builder.append("const ");
+ String _name_11 = xpac.getName();
+ _builder.append(_name_11, " ");
+ _builder.append("_const* constData;");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.newLine();
+ }
+ }
_builder.append("\t");
List<Attribute> _allAttributes = this.roomExt.getAllAttributes(ac);
StringConcatenation _attributes = this.helpers.attributes(_allAttributes);
@@ -245,8 +292,11 @@ public class ActorClassGen extends GenericActorClassGenerator {
boolean _hasNonEmptyStateMachine = this.roomExt.hasNonEmptyStateMachine(xpac);
if (_hasNonEmptyStateMachine) {
_builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("\t");
StringConcatenation _genDataMembers = this.stateMachineGen.genDataMembers(xpac, ac);
- _builder.append(_genDataMembers, " ");
+ _builder.append(_genDataMembers, " ");
_builder.newLineIfNotEmpty();
}
}
@@ -254,17 +304,17 @@ public class ActorClassGen extends GenericActorClassGenerator {
_builder.newLine();
_builder.newLine();
_builder.append("void ");
- String _name_11 = xpac.getName();
- _builder.append(_name_11, "");
- _builder.append("_init(");
String _name_12 = xpac.getName();
_builder.append(_name_12, "");
+ _builder.append("_init(");
+ String _name_13 = xpac.getName();
+ _builder.append(_name_13, "");
_builder.append("* self);");
_builder.newLineIfNotEmpty();
_builder.newLine();
_builder.append("void ");
- String _name_13 = xpac.getName();
- _builder.append(_name_13, "");
+ String _name_14 = xpac.getName();
+ _builder.append(_name_14, "");
_builder.append("_ReceiveMessage(void* self, void* ifitem, const etMessage* msg);");
_builder.newLineIfNotEmpty();
_builder.newLine();
@@ -273,8 +323,8 @@ public class ActorClassGen extends GenericActorClassGenerator {
_builder.append(_userCode_1, "");
_builder.newLineIfNotEmpty();
_builder.newLine();
- String _name_14 = xpac.getName();
- StringConcatenation _generateIncludeGuardEnd = this.stdExt.generateIncludeGuardEnd(_name_14);
+ String _name_15 = xpac.getName();
+ StringConcatenation _generateIncludeGuardEnd = this.stdExt.generateIncludeGuardEnd(_name_15);
_builder.append(_generateIncludeGuardEnd, "");
_builder.newLineIfNotEmpty();
_builder.newLine();
diff --git a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/ProtocolClassGen.java b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/ProtocolClassGen.java
index dced5185d..b2d9d327b 100644
--- a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/ProtocolClassGen.java
+++ b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/ProtocolClassGen.java
@@ -20,7 +20,6 @@ import org.eclipse.etrice.generator.extensions.RoomExtensions;
import org.eclipse.etrice.generator.generic.GenericProtocolClassGenerator;
import org.eclipse.etrice.generator.generic.ProcedureHelpers;
import org.eclipse.xtext.generator.JavaIoFileSystemAccess;
-import org.eclipse.xtext.xbase.lib.BooleanExtensions;
import org.eclipse.xtext.xbase.lib.ObjectExtensions;
import org.eclipse.xtext.xbase.lib.StringExtensions;
import org.eclipse.xtext.xtend2.lib.StringConcatenation;
@@ -154,7 +153,6 @@ public class ProtocolClassGen extends GenericProtocolClassGenerator {
_builder.append(_userCode_1, "");
_builder.newLineIfNotEmpty();
_builder.newLine();
- _builder.newLine();
String _name_4 = pc.getName();
StringConcatenation _generateIncludeGuardEnd = this.stdExt.generateIncludeGuardEnd(_name_4);
_builder.append(_generateIncludeGuardEnd, "");
@@ -227,58 +225,74 @@ public class ProtocolClassGen extends GenericProtocolClassGenerator {
}
public StringConcatenation portClassHeader(final ProtocolClass pc, final Boolean conj) {
- StringConcatenation _builder = new StringConcatenation();
- String _portClassName = this.roomExt.getPortClassName(pc, conj);
- String portClassName = _portClassName;
- _builder.newLineIfNotEmpty();
- PortClass _portClass = this.roomExt.getPortClass(pc, conj);
- PortClass pClass = _portClass;
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("typedef etPort ");
- _builder.append(portClassName, "");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
+ StringConcatenation _xblockexpression = null;
{
- boolean _operator_not = BooleanExtensions.operator_not(conj);
- if (_operator_not) {
- {
- List<Message> _allOutgoingMessages = this.roomExt.getAllOutgoingMessages(pc);
- for(final Message message : _allOutgoingMessages) {
- _builder.append("void ");
- _builder.append(portClassName, "");
- _builder.append("_");
- String _name = message.getName();
- _builder.append(_name, "");
- _builder.append("(const ");
- _builder.append(portClassName, "");
- _builder.append("* self);");
- _builder.newLineIfNotEmpty();
- }
- }
+ String _portClassName = this.roomExt.getPortClassName(pc, conj);
+ String portClassName = _portClassName;
+ String _portClassName_1 = this.roomExt.getPortClassName(pc, conj, true);
+ String replPortClassName = _portClassName_1;
+ PortClass _portClass = this.roomExt.getPortClass(pc, conj);
+ PortClass pClass = _portClass;
+ List<Message> _xifexpression = null;
+ if (conj) {
+ List<Message> _allIncomingMessages = this.roomExt.getAllIncomingMessages(pc);
+ _xifexpression = _allIncomingMessages;
} else {
- {
- List<Message> _allIncomingMessages = this.roomExt.getAllIncomingMessages(pc);
- for(final Message message_1 : _allIncomingMessages) {
- _builder.append("void ");
- _builder.append(portClassName, "");
- _builder.append("_");
- String _name_1 = message_1.getName();
- _builder.append(_name_1, "");
- _builder.append("(const ");
- _builder.append(portClassName, "");
- _builder.append("* self);");
- _builder.newLineIfNotEmpty();
- }
+ List<Message> _allOutgoingMessages = this.roomExt.getAllOutgoingMessages(pc);
+ _xifexpression = _allOutgoingMessages;
+ }
+ List<Message> ports = _xifexpression;
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("typedef etPort ");
+ _builder.append(portClassName, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("typedef etReplPort ");
+ _builder.append(replPortClassName, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.newLine();
+ {
+ for(final Message message : ports) {
+ _builder.append("\t");
+ _builder.append("void ");
+ _builder.append(portClassName, " ");
+ _builder.append("_");
+ String _name = message.getName();
+ _builder.append(_name, " ");
+ _builder.append("(const ");
+ _builder.append(portClassName, " ");
+ _builder.append("* self);");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("void ");
+ _builder.append(replPortClassName, " ");
+ _builder.append("_");
+ String _name_1 = message.getName();
+ _builder.append(_name_1, " ");
+ _builder.append("_broadcast(const ");
+ _builder.append(replPortClassName, " ");
+ _builder.append("* self);");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("void ");
+ _builder.append(replPortClassName, " ");
+ _builder.append("_");
+ String _name_2 = message.getName();
+ _builder.append(_name_2, " ");
+ _builder.append("(const ");
+ _builder.append(replPortClassName, " ");
+ _builder.append("* self, int idx);");
+ _builder.newLineIfNotEmpty();
}
}
+ _xblockexpression = (_builder);
}
- _builder.newLine();
- _builder.newLine();
- _builder.newLine();
- _builder.newLine();
- return _builder;
+ return _xblockexpression;
}
public StringConcatenation portClassSource(final ProtocolClass pc, final Boolean conj) {
@@ -286,6 +300,8 @@ public class ProtocolClassGen extends GenericProtocolClassGenerator {
{
String _portClassName = this.roomExt.getPortClassName(pc, conj);
String portClassName = _portClassName;
+ String _portClassName_1 = this.roomExt.getPortClassName(pc, conj, true);
+ String replPortClassName = _portClassName_1;
PortClass _portClass = this.roomExt.getPortClass(pc, conj);
PortClass pClass = _portClass;
List<Message> _xifexpression = null;
@@ -307,6 +323,7 @@ public class ProtocolClassGen extends GenericProtocolClassGenerator {
StringConcatenation _builder = new StringConcatenation();
{
for(final Message message : messages) {
+ _builder.newLine();
_builder.append("void ");
_builder.append(portClassName, "");
_builder.append("_");
@@ -314,7 +331,7 @@ public class ProtocolClassGen extends GenericProtocolClassGenerator {
_builder.append(_name, "");
_builder.append("(const ");
_builder.append(portClassName, "");
- _builder.append("* self){");
+ _builder.append("* self) {");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("ET_MSC_LOGGER_SYNC_ENTRY(\"");
@@ -328,23 +345,55 @@ public class ProtocolClassGen extends GenericProtocolClassGenerator {
_builder.append("if (self->receiveMessageFunc!=NULL) {");
_builder.newLine();
_builder.append("\t\t");
- _builder.append("etMessage* msg = etMessageService_getMessageBuffer(self->msgService, sizeof(etMessage));");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("msg->address = self->peerAddress;");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("msg->evtID = ");
+ _builder.append("etPort_sendMessage(self, ");
String _name_2 = pc.getName();
String _name_3 = message.getName();
String _operator_plus = StringExtensions.operator_plus(dir, _name_3);
String _memberInUse = this.stdExt.memberInUse(_name_2, _operator_plus);
_builder.append(_memberInUse, " ");
- _builder.append(";");
+ _builder.append(");");
_builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.append("etMessageService_pushMessage(self->msgService, msg);");
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("ET_MSC_LOGGER_SYNC_EXIT");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("void ");
+ _builder.append(replPortClassName, "");
+ _builder.append("_");
+ String _name_4 = message.getName();
+ _builder.append(_name_4, "");
+ _builder.append("_broadcast(const ");
+ _builder.append(replPortClassName, "");
+ _builder.append("* self) {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("int i;");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("ET_MSC_LOGGER_SYNC_ENTRY(\"");
+ _builder.append(replPortClassName, " ");
+ _builder.append("\", \"");
+ String _name_5 = message.getName();
+ _builder.append(_name_5, " ");
+ _builder.append("\")");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("for (i=0; i<self->size; ++i) {");
_builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("etPort_sendMessage((etPort*)(&self->ports[i]), ");
+ String _name_6 = pc.getName();
+ String _name_7 = message.getName();
+ String _operator_plus_1 = StringExtensions.operator_plus(dir, _name_7);
+ String _memberInUse_1 = this.stdExt.memberInUse(_name_6, _operator_plus_1);
+ _builder.append(_memberInUse_1, " ");
+ _builder.append(");");
+ _builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
@@ -354,6 +403,43 @@ public class ProtocolClassGen extends GenericProtocolClassGenerator {
_builder.append("}");
_builder.newLine();
_builder.newLine();
+ _builder.append("void ");
+ _builder.append(replPortClassName, "");
+ _builder.append("_");
+ String _name_8 = message.getName();
+ _builder.append(_name_8, "");
+ _builder.append("(const ");
+ _builder.append(replPortClassName, "");
+ _builder.append("* self, int idx) {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("ET_MSC_LOGGER_SYNC_ENTRY(\"");
+ _builder.append(replPortClassName, " ");
+ _builder.append("\", \"");
+ String _name_9 = message.getName();
+ _builder.append(_name_9, " ");
+ _builder.append("\")");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("if (0<=idx && idx<self->size) {");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("etPort_sendMessage((etPort*)(&self->ports[idx]), ");
+ String _name_10 = pc.getName();
+ String _name_11 = message.getName();
+ String _operator_plus_2 = StringExtensions.operator_plus(dir, _name_11);
+ String _memberInUse_2 = this.stdExt.memberInUse(_name_10, _operator_plus_2);
+ _builder.append(_memberInUse_2, " ");
+ _builder.append(");");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("ET_MSC_LOGGER_SYNC_EXIT");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
}
}
_xblockexpression = (_builder);
diff --git a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/SubSystemClassGen.java b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/SubSystemClassGen.java
index cfb0570b5..3ea4f0c18 100644
--- a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/SubSystemClassGen.java
+++ b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/SubSystemClassGen.java
@@ -2,6 +2,8 @@ package org.eclipse.etrice.generator.c.gen;
import com.google.inject.Inject;
import com.google.inject.Singleton;
+import java.util.ArrayList;
+import java.util.HashMap;
import org.eclipse.emf.common.util.EList;
import org.eclipse.etrice.core.room.ActorClass;
import org.eclipse.etrice.core.room.DetailCode;
@@ -14,12 +16,19 @@ import org.eclipse.etrice.generator.etricegen.ActorInstance;
import org.eclipse.etrice.generator.etricegen.ExpandedActorClass;
import org.eclipse.etrice.generator.etricegen.InterfaceItemInstance;
import org.eclipse.etrice.generator.etricegen.PortInstance;
+import org.eclipse.etrice.generator.etricegen.PortKind;
import org.eclipse.etrice.generator.etricegen.Root;
import org.eclipse.etrice.generator.etricegen.SubSystemInstance;
import org.eclipse.etrice.generator.extensions.RoomExtensions;
import org.eclipse.etrice.generator.generic.ProcedureHelpers;
import org.eclipse.xtext.generator.JavaIoFileSystemAccess;
+import org.eclipse.xtext.xbase.lib.BooleanExtensions;
+import org.eclipse.xtext.xbase.lib.CollectionExtensions;
+import org.eclipse.xtext.xbase.lib.ComparableExtensions;
+import org.eclipse.xtext.xbase.lib.Functions.Function1;
import org.eclipse.xtext.xbase.lib.IntegerExtensions;
+import org.eclipse.xtext.xbase.lib.IterableExtensions;
+import org.eclipse.xtext.xbase.lib.ObjectExtensions;
import org.eclipse.xtext.xbase.lib.StringExtensions;
import org.eclipse.xtext.xtend2.lib.StringConcatenation;
@@ -547,56 +556,181 @@ public class SubSystemClassGen {
_builder.append(_pathName_1, "");
_builder.append(" */");
_builder.newLineIfNotEmpty();
- _builder.append("static const ");
- ActorClass _actorClass_1 = ai_1.getActorClass();
- String _name_4 = _actorClass_1.getName();
- _builder.append(_name_4, "");
- _builder.append("_const ");
- String _path_2 = ai_1.getPath();
- String _pathName_2 = this.roomExt.getPathName(_path_2);
- _builder.append(_pathName_2, "");
- _builder.append("_const = {");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("/* Ports: {myActor, etReceiveMessage, msgService, peerAddress, localId} */");
- _builder.newLine();
{
EList<PortInstance> _ports = ai_1.getPorts();
- for(final PortInstance pi : _ports) {
- _builder.append("\t");
- String _genPortInitializer = this.genPortInitializer(root, ai_1, pi);
- _builder.append(_genPortInitializer, " ");
+ boolean _isEmpty = _ports.isEmpty();
+ if (_isEmpty) {
+ _builder.append("/* no ports, nothing to initialize statically */");
+ _builder.newLine();
+ } else {
+ StringConcatenation _genActorInstanceInitializer = this.genActorInstanceInitializer(root, ai_1);
+ _builder.append(_genActorInstanceInitializer, "");
_builder.newLineIfNotEmpty();
}
}
- _builder.append("\t");
- _builder.newLine();
- _builder.append("};");
- _builder.newLine();
- _builder.append("static ");
- ActorClass _actorClass_2 = ai_1.getActorClass();
- String _name_5 = _actorClass_2.getName();
- _builder.append(_name_5, "");
- _builder.append(" ");
- String _path_3 = ai_1.getPath();
- String _pathName_3 = this.roomExt.getPathName(_path_3);
- _builder.append(_pathName_3, "");
- _builder.append(" = {&");
- String _path_4 = ai_1.getPath();
- String _pathName_4 = this.roomExt.getPathName(_path_4);
- _builder.append(_pathName_4, "");
- _builder.append("_const};");
- _builder.newLineIfNotEmpty();
}
}
_builder.newLine();
- _builder.newLine();
- _builder.newLine();
- _builder.newLine();
- _builder.newLine();
return _builder;
}
+ private StringConcatenation genActorInstanceInitializer(final Root root, final ActorInstance ai) {
+ StringConcatenation _xblockexpression = null;
+ {
+ String _path = ai.getPath();
+ String _pathName = this.roomExt.getPathName(_path);
+ String instName = _pathName;
+ ArrayList<PortInstance> _arrayList = new ArrayList<PortInstance>();
+ ArrayList<PortInstance> replPorts = _arrayList;
+ EList<PortInstance> _ports = ai.getPorts();
+ final Function1<PortInstance,Boolean> _function = new Function1<PortInstance,Boolean>() {
+ public Boolean apply(final PortInstance e) {
+ boolean _operator_and = false;
+ PortKind _kind = e.getKind();
+ String _literal = _kind.getLiteral();
+ boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_literal, "RELAY");
+ if (!_operator_notEquals) {
+ _operator_and = false;
+ } else {
+ Port _port = e.getPort();
+ int _multiplicity = _port.getMultiplicity();
+ boolean _operator_notEquals_1 = ObjectExtensions.operator_notEquals(((Integer)_multiplicity), ((Integer)1));
+ _operator_and = BooleanExtensions.operator_and(_operator_notEquals, _operator_notEquals_1);
+ }
+ return ((Boolean)_operator_and);
+ }
+ };
+ Iterable<PortInstance> _filter = IterableExtensions.<PortInstance>filter(_ports, _function);
+ CollectionExtensions.<PortInstance>addAll(replPorts, _filter);
+ ArrayList<PortInstance> _arrayList_1 = new ArrayList<PortInstance>();
+ ArrayList<PortInstance> ports = _arrayList_1;
+ EList<PortInstance> _ports_1 = ai.getPorts();
+ final Function1<PortInstance,Boolean> _function_1 = new Function1<PortInstance,Boolean>() {
+ public Boolean apply(final PortInstance e) {
+ boolean _operator_and = false;
+ PortKind _kind = e.getKind();
+ String _literal = _kind.getLiteral();
+ boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_literal, "RELAY");
+ if (!_operator_notEquals) {
+ _operator_and = false;
+ } else {
+ Port _port = e.getPort();
+ int _multiplicity = _port.getMultiplicity();
+ boolean _operator_equals = ObjectExtensions.operator_equals(((Integer)_multiplicity), ((Integer)1));
+ _operator_and = BooleanExtensions.operator_and(_operator_notEquals, _operator_equals);
+ }
+ return ((Boolean)_operator_and);
+ }
+ };
+ Iterable<PortInstance> _filter_1 = IterableExtensions.<PortInstance>filter(_ports_1, _function_1);
+ Iterable<PortInstance> _union = this.roomExt.<PortInstance>union(_filter_1, replPorts);
+ CollectionExtensions.<PortInstance>addAll(ports, _union);
+ HashMap<PortInstance,Integer> _hashMap = new HashMap<PortInstance,Integer>();
+ HashMap<PortInstance,Integer> offsets = _hashMap;
+ int offset = 0;
+ for (final PortInstance p : replPorts) {
+ {
+ offsets.put(p, ((Integer)offset));
+ EList<InterfaceItemInstance> _peers = p.getPeers();
+ int _size = _peers.size();
+ int _operator_plus = IntegerExtensions.operator_plus(((Integer)offset), ((Integer)_size));
+ offset = _operator_plus;
+ }
+ }
+ StringConcatenation _builder = new StringConcatenation();
+ {
+ boolean _isEmpty = replPorts.isEmpty();
+ boolean _operator_not = BooleanExtensions.operator_not(_isEmpty);
+ if (_operator_not) {
+ _builder.append("static const etReplSubPort ");
+ _builder.append(instName, "");
+ _builder.append("_repl_sub_ports[");
+ _builder.append(offset, "");
+ _builder.append("] = {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("/* Replicated Sub Ports: {myActor, etReceiveMessage, msgService, peerAddress, localId, idx} */");
+ _builder.newLine();
+ {
+ boolean hasAnyElements = false;
+ for(final PortInstance pi : replPorts) {
+ if (!hasAnyElements) {
+ hasAnyElements = true;
+ } else {
+ _builder.appendImmediate(",", " ");
+ }
+ _builder.append("\t");
+ String _genReplSubPortInitializers = this.genReplSubPortInitializers(root, ai, pi);
+ _builder.append(_genReplSubPortInitializers, " ");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("};");
+ _builder.newLine();
+ }
+ }
+ _builder.append("static const ");
+ ActorClass _actorClass = ai.getActorClass();
+ String _name = _actorClass.getName();
+ _builder.append(_name, "");
+ _builder.append("_const ");
+ _builder.append(instName, "");
+ _builder.append("_const = {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("/* Ports: {myActor, etReceiveMessage, msgService, peerAddress, localId} */");
+ _builder.newLine();
+ {
+ boolean hasAnyElements_1 = false;
+ for(final PortInstance pi_1 : ports) {
+ if (!hasAnyElements_1) {
+ hasAnyElements_1 = true;
+ } else {
+ _builder.appendImmediate(",", " ");
+ }
+ {
+ Port _port = pi_1.getPort();
+ int _multiplicity = _port.getMultiplicity();
+ boolean _operator_equals = ObjectExtensions.operator_equals(((Integer)_multiplicity), ((Integer)1));
+ if (_operator_equals) {
+ _builder.append("\t");
+ String _genPortInitializer = this.genPortInitializer(root, ai, pi_1);
+ _builder.append(_genPortInitializer, " ");
+ _builder.newLineIfNotEmpty();
+ } else {
+ _builder.append("\t");
+ _builder.append("{");
+ EList<InterfaceItemInstance> _peers_1 = pi_1.getPeers();
+ int _size_1 = _peers_1.size();
+ _builder.append(_size_1, " ");
+ _builder.append(", ");
+ _builder.append(instName, " ");
+ _builder.append("_repl_sub_ports+");
+ Integer _get = offsets.get(pi_1);
+ _builder.append(_get, " ");
+ _builder.append("}");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ }
+ }
+ _builder.append("};");
+ _builder.newLine();
+ _builder.append("static ");
+ ActorClass _actorClass_1 = ai.getActorClass();
+ String _name_1 = _actorClass_1.getName();
+ _builder.append(_name_1, "");
+ _builder.append(" ");
+ _builder.append(instName, "");
+ _builder.append(" = {&");
+ _builder.append(instName, "");
+ _builder.append("_const};");
+ _builder.newLineIfNotEmpty();
+ _xblockexpression = (_builder);
+ }
+ return _xblockexpression;
+ }
+
private String genPortInitializer(final Root root, final ActorInstance ai, final PortInstance pi) {
String _xblockexpression = null;
{
@@ -624,6 +758,19 @@ public class SubSystemClassGen {
_xifexpression_1 = _objId;
}
int objId = _xifexpression_1;
+ int _xifexpression_2 = (int) 0;
+ EList<InterfaceItemInstance> _peers_3 = pi.getPeers();
+ boolean _isEmpty_2 = _peers_3.isEmpty();
+ if (_isEmpty_2) {
+ _xifexpression_2 = 0;
+ } else {
+ EList<InterfaceItemInstance> _peers_4 = pi.getPeers();
+ InterfaceItemInstance _get_1 = _peers_4.get(0);
+ EList<InterfaceItemInstance> _peers_5 = _get_1.getPeers();
+ int _indexOf = _peers_5.indexOf(pi);
+ _xifexpression_2 = _indexOf;
+ }
+ int idx = _xifexpression_2;
String _path = ai.getPath();
String _pathName = this.roomExt.getPathName(_path);
String _operator_plus_1 = StringExtensions.operator_plus("{&", _pathName);
@@ -631,22 +778,76 @@ public class SubSystemClassGen {
String _operator_plus_3 = StringExtensions.operator_plus(_operator_plus_2, recvMsg);
String _operator_plus_4 = StringExtensions.operator_plus(_operator_plus_3, ", ");
String _operator_plus_5 = StringExtensions.operator_plus(_operator_plus_4, "&msgService_Thread1, ");
- String _operator_plus_6 = StringExtensions.operator_plus(_operator_plus_5, ((Integer)objId));
- String _operator_plus_7 = StringExtensions.operator_plus(_operator_plus_6, ", ");
+ int _operator_plus_6 = IntegerExtensions.operator_plus(((Integer)objId), ((Integer)idx));
+ String _operator_plus_7 = StringExtensions.operator_plus(_operator_plus_5, ((Integer)_operator_plus_6));
+ String _operator_plus_8 = StringExtensions.operator_plus(_operator_plus_7, ", ");
ExpandedActorClass _expandedActorClass = root.getExpandedActorClass(ai);
Port _port = pi.getPort();
int _interfaceItemLocalId = _expandedActorClass.getInterfaceItemLocalId(_port);
- int _operator_plus_8 = IntegerExtensions.operator_plus(((Integer)_interfaceItemLocalId), ((Integer)1));
- String _operator_plus_9 = StringExtensions.operator_plus(_operator_plus_7, ((Integer)_operator_plus_8));
- String _operator_plus_10 = StringExtensions.operator_plus(_operator_plus_9, "} /* Port ");
+ int _operator_plus_9 = IntegerExtensions.operator_plus(((Integer)_interfaceItemLocalId), ((Integer)1));
+ String _operator_plus_10 = StringExtensions.operator_plus(_operator_plus_8, ((Integer)_operator_plus_9));
+ String _operator_plus_11 = StringExtensions.operator_plus(_operator_plus_10, "} /* Port ");
String _name_1 = pi.getName();
- String _operator_plus_11 = StringExtensions.operator_plus(_operator_plus_10, _name_1);
- String _operator_plus_12 = StringExtensions.operator_plus(_operator_plus_11, " */");
- _xblockexpression = (_operator_plus_12);
+ String _operator_plus_12 = StringExtensions.operator_plus(_operator_plus_11, _name_1);
+ String _operator_plus_13 = StringExtensions.operator_plus(_operator_plus_12, " */");
+ _xblockexpression = (_operator_plus_13);
}
return _xblockexpression;
}
+ private String genReplSubPortInitializers(final Root root, final ActorInstance ai, final PortInstance pi) {
+ String result = "";
+ EList<InterfaceItemInstance> _peers = pi.getPeers();
+ for (final InterfaceItemInstance p : _peers) {
+ {
+ EList<InterfaceItemInstance> _peers_1 = pi.getPeers();
+ int _indexOf = _peers_1.indexOf(p);
+ int idx = _indexOf;
+ String _xifexpression = null;
+ EList<InterfaceItemInstance> _peers_2 = pi.getPeers();
+ int _size = _peers_2.size();
+ int _operator_minus = IntegerExtensions.operator_minus(((Integer)_size), ((Integer)1));
+ boolean _operator_lessThan = ComparableExtensions.<Integer>operator_lessThan(((Integer)idx), ((Integer)_operator_minus));
+ if (_operator_lessThan) {
+ _xifexpression = ",";
+ } else {
+ _xifexpression = "";
+ }
+ String comma = _xifexpression;
+ String _operator_plus = StringExtensions.operator_plus(result, "{&");
+ String _path = ai.getPath();
+ String _pathName = this.roomExt.getPathName(_path);
+ String _operator_plus_1 = StringExtensions.operator_plus(_operator_plus, _pathName);
+ String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, ", ");
+ ActorClass _actorClass = ai.getActorClass();
+ String _name = _actorClass.getName();
+ String _operator_plus_3 = StringExtensions.operator_plus(_operator_plus_2, _name);
+ String _operator_plus_4 = StringExtensions.operator_plus(_operator_plus_3, "_ReceiveMessage, ");
+ String _operator_plus_5 = StringExtensions.operator_plus(_operator_plus_4, "&msgService_Thread1, ");
+ int _objId = p.getObjId();
+ String _operator_plus_6 = StringExtensions.operator_plus(_operator_plus_5, ((Integer)_objId));
+ String _operator_plus_7 = StringExtensions.operator_plus(_operator_plus_6, ", ");
+ ExpandedActorClass _expandedActorClass = root.getExpandedActorClass(ai);
+ Port _port = pi.getPort();
+ int _interfaceItemLocalId = _expandedActorClass.getInterfaceItemLocalId(_port);
+ int _operator_plus_8 = IntegerExtensions.operator_plus(((Integer)_interfaceItemLocalId), ((Integer)1));
+ String _operator_plus_9 = StringExtensions.operator_plus(_operator_plus_7, ((Integer)_operator_plus_8));
+ String _operator_plus_10 = StringExtensions.operator_plus(_operator_plus_9, ", ");
+ String _operator_plus_11 = StringExtensions.operator_plus(_operator_plus_10, ((Integer)idx));
+ String _operator_plus_12 = StringExtensions.operator_plus(_operator_plus_11, "}");
+ String _operator_plus_13 = StringExtensions.operator_plus(_operator_plus_12, comma);
+ String _operator_plus_14 = StringExtensions.operator_plus(_operator_plus_13, " /* Repl Sub Port ");
+ String _name_1 = pi.getName();
+ String _operator_plus_15 = StringExtensions.operator_plus(_operator_plus_14, _name_1);
+ String _operator_plus_16 = StringExtensions.operator_plus(_operator_plus_15, " idx +");
+ String _operator_plus_17 = StringExtensions.operator_plus(_operator_plus_16, ((Integer)idx));
+ String _operator_plus_18 = StringExtensions.operator_plus(_operator_plus_17, "*/\n");
+ result = _operator_plus_18;
+ }
+ }
+ return result;
+ }
+
public StringConcatenation generateDispatcherFile(final Root root, final SubSystemInstance ssi, final SubSystemClass ssc) {
StringConcatenation _builder = new StringConcatenation();
_builder.append("/**");
@@ -698,27 +899,74 @@ public class SubSystemClassGen {
{
EList<InterfaceItemInstance> _orderedIfItemInstances = ai.getOrderedIfItemInstances();
for(final InterfaceItemInstance pi : _orderedIfItemInstances) {
- _builder.append("\t\t");
- _builder.append("case ");
- int _objId = pi.getObjId();
- _builder.append(_objId, " ");
- _builder.append(":");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.append("\t");
- _builder.append("etPort_receive(&");
- String _path_1 = ai.getPath();
- String _pathName = this.roomExt.getPathName(_path_1);
- _builder.append(_pathName, " ");
- _builder.append("_const.");
- String _name_1 = pi.getName();
- _builder.append(_name_1, " ");
- _builder.append(", msg);");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.append("\t");
- _builder.append("break;");
- _builder.newLine();
+ {
+ boolean _operator_and = false;
+ if (!(pi instanceof PortInstance)) {
+ _operator_and = false;
+ } else {
+ Port _port = ((PortInstance) pi).getPort();
+ int _multiplicity = _port.getMultiplicity();
+ boolean _operator_notEquals = ObjectExtensions.operator_notEquals(((Integer)_multiplicity), ((Integer)1));
+ _operator_and = BooleanExtensions.operator_and((pi instanceof PortInstance), _operator_notEquals);
+ }
+ if (_operator_and) {
+ {
+ EList<InterfaceItemInstance> _peers = pi.getPeers();
+ for(final InterfaceItemInstance peer : _peers) {
+ _builder.append("\t\t");
+ _builder.append("case ");
+ int _objId = pi.getObjId();
+ EList<InterfaceItemInstance> _peers_1 = pi.getPeers();
+ int _indexOf = _peers_1.indexOf(peer);
+ int _operator_plus = IntegerExtensions.operator_plus(((Integer)_objId), ((Integer)_indexOf));
+ _builder.append(_operator_plus, " ");
+ _builder.append(":");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("\t");
+ _builder.append("etPort_receive((etPort*)&");
+ String _path_1 = ai.getPath();
+ String _pathName = this.roomExt.getPathName(_path_1);
+ _builder.append(_pathName, " ");
+ _builder.append("_const.");
+ String _name_1 = pi.getName();
+ _builder.append(_name_1, " ");
+ _builder.append(".ports[");
+ EList<InterfaceItemInstance> _peers_2 = pi.getPeers();
+ int _indexOf_1 = _peers_2.indexOf(peer);
+ _builder.append(_indexOf_1, " ");
+ _builder.append("], msg);");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("\t");
+ _builder.append("break;");
+ _builder.newLine();
+ }
+ }
+ } else {
+ _builder.append("\t\t");
+ _builder.append("case ");
+ int _objId_1 = pi.getObjId();
+ _builder.append(_objId_1, " ");
+ _builder.append(":");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("\t");
+ _builder.append("etPort_receive(&");
+ String _path_2 = ai.getPath();
+ String _pathName_1 = this.roomExt.getPathName(_path_2);
+ _builder.append(_pathName_1, " ");
+ _builder.append("_const.");
+ String _name_2 = pi.getName();
+ _builder.append(_name_2, " ");
+ _builder.append(", msg);");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("\t");
+ _builder.append("break;");
+ _builder.newLine();
+ }
+ }
}
}
}
diff --git a/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/setup/GeneratorModule.java b/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/setup/GeneratorModule.java
index 792cfe63f..b5518d6d8 100644
--- a/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/setup/GeneratorModule.java
+++ b/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/setup/GeneratorModule.java
@@ -13,7 +13,9 @@
package org.eclipse.etrice.generator.java.setup;
import org.eclipse.etrice.generator.base.AbstractGenerator;
+import org.eclipse.etrice.generator.base.DefaultTranslationProvider;
import org.eclipse.etrice.generator.base.GeneratorBaseModule;
+import org.eclipse.etrice.generator.base.ITranslationProvider;
import org.eclipse.etrice.generator.java.Main;
import org.eclipse.etrice.generator.java.gen.MainGen;
import org.eclipse.xtext.generator.IGenerator;
@@ -33,9 +35,10 @@ public class GeneratorModule extends GeneratorBaseModule {
binder.bind(AbstractGenerator.class).to(Main.class);
binder.bind(IGenerator.class).to(MainGen.class);
+ binder.bind(ITranslationProvider.class).to(DefaultTranslationProvider.class);
+
// bind language specific code to generic Interfaces
binder.bind(ILanguageExtension.class).to(JavaExtensions.class);
-
}
}
diff --git a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/DefaultTranslationProvider.java b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/DefaultTranslationProvider.java
new file mode 100644
index 000000000..7bbee1bca
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/DefaultTranslationProvider.java
@@ -0,0 +1,65 @@
+/*******************************************************************************
+ * 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:
+ * Henrik Rentz-Reichert (initial contribution)
+ *
+ *******************************************************************************/
+
+package org.eclipse.etrice.generator.base;
+
+import java.util.ArrayList;
+
+import org.eclipse.etrice.core.room.ActorClass;
+import org.eclipse.etrice.core.room.Attribute;
+import org.eclipse.etrice.core.room.DetailCode;
+import org.eclipse.etrice.core.room.InterfaceItem;
+import org.eclipse.etrice.core.room.Message;
+import org.eclipse.etrice.core.room.Operation;
+
+public class DefaultTranslationProvider implements ITranslationProvider {
+
+ @Override
+ public boolean translateMembers() {
+ return false;
+ }
+
+ @Override
+ public String getAttributeText(Attribute att, String orig) {
+ return orig;
+ }
+
+ @Override
+ public String getOperationText(Operation op, ArrayList<String> args, String orig) {
+ return orig;
+ }
+
+ @Override
+ public String getInterfaceItemMessageText(InterfaceItem item, Message msg, ArrayList<String> args, String orig) {
+ return orig;
+ }
+
+ @Override
+ public String getInterfaceItemMessageValue(InterfaceItem item, Message msg, String orig) {
+ return orig;
+ }
+
+ @Override
+ public boolean translateTags() {
+ return false;
+ }
+
+ @Override
+ public String translateTag(String tag, DetailCode code) {
+ return DetailCodeTranslator.TAG_START+tag+DetailCodeTranslator.TAG_END;
+ }
+
+ @Override
+ public void setActorClass(ActorClass ac) {
+ }
+
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/DetailCodeTranslator.java b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/DetailCodeTranslator.java
index de63454f3..88b164205 100644
--- a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/DetailCodeTranslator.java
+++ b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/DetailCodeTranslator.java
@@ -33,17 +33,6 @@ public class DetailCodeTranslator {
public static final String TAG_START = "<|";
public static final String TAG_END = "|>";
- public static interface ITranslationProvider {
- boolean translateMembers();
- String getAttributeText(Attribute att, String orig);
- String getOperationText(Operation op, ArrayList<String> args, String orig);
- String getInterfaceItemMessageText(InterfaceItem item, Message msg, ArrayList<String> args, String orig);
- String getInterfaceItemMessageValue(InterfaceItem item, Message msg, String orig);
-
- boolean translateTags();
- String translateTag(String tag, DetailCode code);
- }
-
private static class Position {
int pos = 0;
}
diff --git a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/ITranslationProvider.java b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/ITranslationProvider.java
new file mode 100644
index 000000000..bc42b4b2b
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/ITranslationProvider.java
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * 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:
+ * Henrik Rentz-Reichert (initial contribution)
+ *
+ *******************************************************************************/
+
+package org.eclipse.etrice.generator.base;
+
+import java.util.ArrayList;
+
+import org.eclipse.etrice.core.room.ActorClass;
+import org.eclipse.etrice.core.room.Attribute;
+import org.eclipse.etrice.core.room.DetailCode;
+import org.eclipse.etrice.core.room.InterfaceItem;
+import org.eclipse.etrice.core.room.Message;
+import org.eclipse.etrice.core.room.Operation;
+
+public interface ITranslationProvider {
+ void setActorClass(ActorClass ac);
+
+ boolean translateMembers();
+ String getAttributeText(Attribute att, String orig);
+ String getOperationText(Operation op, ArrayList<String> args, String orig);
+ String getInterfaceItemMessageText(InterfaceItem item, Message msg, ArrayList<String> args, String orig);
+ String getInterfaceItemMessageValue(InterfaceItem item, Message msg, String orig);
+
+ boolean translateTags();
+ String translateTag(String tag, DetailCode code);
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/extensions/RoomExtensions.xtend b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/extensions/RoomExtensions.xtend
index 34e418d15..eca848fea 100644
--- a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/extensions/RoomExtensions.xtend
+++ b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/extensions/RoomExtensions.xtend
@@ -45,6 +45,7 @@ import org.eclipse.etrice.core.room.RoomModel
import org.eclipse.etrice.generator.etricegen.ActiveTrigger
import org.eclipse.etrice.generator.etricegen.ExpandedActorClass
import org.eclipse.etrice.generator.etricegen.TransitionChain
+import org.eclipse.etrice.generator.base.DetailCodeTranslator
import static extension org.eclipse.etrice.generator.extensions.RoomNameProv.*
@@ -63,6 +64,13 @@ class RoomExtensions {
ret.addAll(l2)
return ret
}
+
+ def <T> Iterable<T> union(Iterable<T> l1, Iterable<T> l2) {
+ var ret = new ArrayList<T>()
+ ret.addAll(l1)
+ ret.addAll(l2)
+ return ret
+ }
def List<Port> punion(List<Port> in1, List<ExternalPort> in2){
var ret=new ArrayList<Port>();
@@ -192,21 +200,15 @@ class RoomExtensions {
// protocol related methods
def String getPortClassName(ProtocolClass p, boolean conj) {
- var ret=p.name
- if(conj) {
- ret=ret+"ConjPort"
- }else{
- ret=ret+"Port"
- }
- return ret
+ getPortClassName(p, conj, false)
+ }
+
+ def String getPortClassName(ProtocolClass p, boolean conj, boolean repl) {
+ p.name + (if (conj) "Conj" else "") + (if (repl) "Repl" else "") +"Port"
}
def String getPortClassName(Port p){
- var ret=p.protocol.getPortClassName(p.conjugated)
- if (p.replicated){
- ret = ret+"Repl"
- }
- return ret
+ p.protocol.getPortClassName(p.conjugated, p.replicated)
}
def String getPortClassName(ExternalPort p){
@@ -446,37 +448,39 @@ class RoomExtensions {
return hasGuard
}
+ // TODO. in the following methods handle inheritance language independent and proper
+
def boolean hasEntryCode(State s) {
- return s.entryCode!=null && s.entryCode.commands.size>0
+ s.entryCode!=null && s.entryCode.commands.size>0
}
def boolean hasExitCode(State s) {
- return s.exitCode!=null && s.exitCode.commands.size>0
+ s.exitCode!=null && s.exitCode.commands.size>0
}
- def String getEntryCode(ExpandedActorClass ac, State s) {
+ def String getEntryCode(ExpandedActorClass ac, State s, DetailCodeTranslator dct) {
if (s instanceof RefinedState)
- return "super."+s.getEntryCodeOperationName()+"();\n"+ac.getCode(s.entryCode)
+ "super."+s.getEntryCodeOperationName()+"();\n"+ac.getCode(s.entryCode)
else
- return ac.getCode(s.entryCode)
+ dct.translateDetailCode(s.entryCode)
}
- def String getExitCode(ExpandedActorClass ac, State s) {
+ def String getExitCode(ExpandedActorClass ac, State s, DetailCodeTranslator dct) {
if (s instanceof RefinedState)
- return ac.getCode(s.exitCode)+"super."+s.getEntryCodeOperationName()+"();\n"
+ ac.getCode(s.exitCode)+"super."+s.getEntryCodeOperationName()+"();\n"
else
- ac.getCode(s.exitCode)
+ dct.translateDetailCode(s.exitCode)
}
def boolean hasActionCode(Transition t) {
- return t.action!=null && t.action.commands.size>0
+ t.action!=null && t.action.commands.size>0
}
- def String getActionCode(ExpandedActorClass ac, Transition t) {
- return ac.getCode(t.action)
+ def String getActionCode(ExpandedActorClass ac, Transition t, DetailCodeTranslator dct) {
+ dct.translateDetailCode(t.action)
}
def String getContextId(TransitionChain tc) {
- return tc.getStateContext().getStateId()
+ tc.getStateContext().getStateId()
}
def Transition getInitTransition(StateGraph sg) {
diff --git a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/GenericStateMachineGenerator.xtend b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/GenericStateMachineGenerator.xtend
index bf81f38b3..2dbb1de1a 100644
--- a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/GenericStateMachineGenerator.xtend
+++ b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/GenericStateMachineGenerator.xtend
@@ -20,6 +20,8 @@ import org.eclipse.etrice.core.room.TriggeredTransition
import org.eclipse.etrice.core.room.NonInitialTransition
import org.eclipse.etrice.generator.etricegen.ExpandedActorClass
import org.eclipse.etrice.generator.extensions.RoomExtensions
+import org.eclipse.etrice.generator.base.DetailCodeTranslator
+import org.eclipse.etrice.generator.base.ITranslationProvider
import static extension org.eclipse.etrice.generator.extensions.RoomNameProv.*
import org.eclipse.xtext.util.Pair
import static org.eclipse.xtext.util.Tuples.*
@@ -30,6 +32,7 @@ class GenericStateMachineGenerator {
@Inject public extension RoomExtensions roomExt
@Inject public extension GenericProtocolClassGenerator pcGen
@Inject public extension LanguageGenerator languageGen
+ @Inject public ITranslationProvider translator
def private genStateIdConstants(ExpandedActorClass xpac, ActorClass ac) {
// with inheritance we exclude inherited base states
@@ -80,7 +83,11 @@ class GenericStateMachineGenerator {
return langExt.genEnumeration("triggers", list)
}
- def genStateMachine(ExpandedActorClass xpac, ActorClass ac) {'''
+ def genStateMachine(ExpandedActorClass xpac, ActorClass ac) {
+ translator.setActorClass(ac)
+ var dct = new DetailCodeTranslator(ac, translator)
+
+ '''
/* state IDs */
«genStateIdConstants(xpac, ac)»
@@ -98,12 +105,12 @@ class GenericStateMachineGenerator {
«IF xpac.isOwnObject(state)»
«IF state.hasEntryCode()»
«langExt.accessLevelProtected»void «state.getEntryCodeOperationName()»(«langExt.selfPointer(ac.name, false)») {
- «xpac.getEntryCode(state)»
+ «xpac.getEntryCode(state, dct)»
}
«ENDIF»
«IF state.hasExitCode()»
«langExt.accessLevelProtected»void «state.getExitCodeOperationName()»(«langExt.selfPointer(ac.name, false)») {
- «xpac.getExitCode(state)»
+ «xpac.getExitCode(state, dct)»
}
«ENDIF»
«ENDIF»
@@ -113,7 +120,7 @@ class GenericStateMachineGenerator {
«FOR tr : xpac.stateMachine.getTransitionList()»
«IF xpac.isOwnObject(tr) && tr.hasActionCode()»
«langExt.accessLevelProtected»void «tr.getActionCodeOperationName()»(«langExt.selfPointer(ac.name, tr instanceof NonInitialTransition)»«IF tr instanceof NonInitialTransition»InterfaceItemBase ifitem«languageGen.getArgumentList(xpac, tr)»«ENDIF») {
- «xpac.getActionCode(tr)»
+ «xpac.getActionCode(tr, dct)»
}
«ENDIF»
«ENDFOR»
@@ -230,7 +237,7 @@ class GenericStateMachineGenerator {
«IF needData»{ «at.msg.getTypedDataDefinition()»«ENDIF»
«FOR tt : at.transitions SEPARATOR " else "»
«var chain = xpac.getChain(tt)»
- «guard(chain.transition, at.trigger, xpac)»
+ «guard(chain.transition, at.trigger, xpac, dct)»
{
chain = «chain.getChainId()»;
catching_state = «chain.getContextId()»;
@@ -262,15 +269,17 @@ class GenericStateMachineGenerator {
def genExtra(ExpandedActorClass xpac, ActorClass ac) {''''''}
- def private dispatch guard(TriggeredTransition tt, String trigger, ExpandedActorClass ac) {'''
- «var tr = tt.triggers.findFirst(e|ac.isMatching(e, trigger))»
+ def private dispatch guard(TriggeredTransition tt, String trigger, ExpandedActorClass ac, DetailCodeTranslator dct) {
+ var tr = tt.triggers.findFirst(e|ac.isMatching(e, trigger))
+ '''
«IF tr.hasGuard()»
- if («ac.getCode(tr.guard.guard)»)
+ if («dct.translateDetailCode(tr.guard.guard)»)
«ENDIF»
'''
}
- def private dispatch guard(Transition t, String trigger, ExpandedActorClass ac) {'''
+ def private dispatch guard(Transition t, String trigger, ExpandedActorClass ac, DetailCodeTranslator dct) {
+ '''
/* error */
'''
}
diff --git a/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/extensions/RoomExtensions.java b/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/extensions/RoomExtensions.java
index 415d3eef8..b183c1473 100644
--- a/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/extensions/RoomExtensions.java
+++ b/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/extensions/RoomExtensions.java
@@ -36,11 +36,13 @@ import org.eclipse.etrice.core.room.Transition;
import org.eclipse.etrice.core.room.Trigger;
import org.eclipse.etrice.core.room.TriggeredTransition;
import org.eclipse.etrice.core.room.VarDecl;
+import org.eclipse.etrice.generator.base.DetailCodeTranslator;
import org.eclipse.etrice.generator.etricegen.ActiveTrigger;
import org.eclipse.etrice.generator.etricegen.ExpandedActorClass;
import org.eclipse.etrice.generator.etricegen.TransitionChain;
import org.eclipse.etrice.generator.extensions.RoomNameProv;
import org.eclipse.xtext.xbase.lib.BooleanExtensions;
+import org.eclipse.xtext.xbase.lib.CollectionExtensions;
import org.eclipse.xtext.xbase.lib.ComparableExtensions;
import org.eclipse.xtext.xbase.lib.Functions.Function1;
import org.eclipse.xtext.xbase.lib.IntegerExtensions;
@@ -62,6 +64,14 @@ public class RoomExtensions {
return ret;
}
+ public <T extends Object> Iterable<T> union(final Iterable<T> l1, final Iterable<T> l2) {
+ ArrayList<T> _arrayList = new ArrayList<T>();
+ ArrayList<T> ret = _arrayList;
+ CollectionExtensions.<T>addAll(ret, l1);
+ CollectionExtensions.<T>addAll(ret, l2);
+ return ret;
+ }
+
public List<Port> punion(final List<Port> in1, final List<ExternalPort> in2) {
ArrayList<Port> _arrayList = new ArrayList<Port>();
ArrayList<Port> ret = _arrayList;
@@ -275,29 +285,36 @@ public class RoomExtensions {
}
public String getPortClassName(final ProtocolClass p, final boolean conj) {
- String _name = p.getName();
- String ret = _name;
- if (conj) {
- String _operator_plus = StringExtensions.operator_plus(ret, "ConjPort");
- ret = _operator_plus;
- } else {
- String _operator_plus_1 = StringExtensions.operator_plus(ret, "Port");
- ret = _operator_plus_1;
- }
- return ret;
+ String _portClassName = this.getPortClassName(p, conj, false);
+ return _portClassName;
+ }
+
+ public String getPortClassName(final ProtocolClass p, final boolean conj, final boolean repl) {
+ String _name = p.getName();
+ String _xifexpression = null;
+ if (conj) {
+ _xifexpression = "Conj";
+ } else {
+ _xifexpression = "";
+ }
+ String _operator_plus = StringExtensions.operator_plus(_name, _xifexpression);
+ String _xifexpression_1 = null;
+ if (repl) {
+ _xifexpression_1 = "Repl";
+ } else {
+ _xifexpression_1 = "";
+ }
+ String _operator_plus_1 = StringExtensions.operator_plus(_operator_plus, _xifexpression_1);
+ String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, "Port");
+ return _operator_plus_2;
}
public String getPortClassName(final Port p) {
- ProtocolClass _protocol = p.getProtocol();
- boolean _isConjugated = p.isConjugated();
- String _portClassName = this.getPortClassName(_protocol, _isConjugated);
- String ret = _portClassName;
- boolean _isReplicated = p.isReplicated();
- if (_isReplicated) {
- String _operator_plus = StringExtensions.operator_plus(ret, "Repl");
- ret = _operator_plus;
- }
- return ret;
+ ProtocolClass _protocol = p.getProtocol();
+ boolean _isConjugated = p.isConjugated();
+ boolean _isReplicated = p.isReplicated();
+ String _portClassName = this.getPortClassName(_protocol, _isConjugated, _isReplicated);
+ return _portClassName;
}
public String getPortClassName(final ExternalPort p) {
@@ -827,7 +844,8 @@ public class RoomExtensions {
return _operator_and;
}
- public String getEntryCode(final ExpandedActorClass ac, final State s) {
+ public String getEntryCode(final ExpandedActorClass ac, final State s, final DetailCodeTranslator dct) {
+ String _xifexpression = null;
if ((s instanceof RefinedState)) {
String _entryCodeOperationName = RoomNameProv.getEntryCodeOperationName(s);
String _operator_plus = StringExtensions.operator_plus("super.", _entryCodeOperationName);
@@ -835,15 +853,16 @@ public class RoomExtensions {
DetailCode _entryCode = s.getEntryCode();
String _code = ac.getCode(_entryCode);
String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, _code);
- return _operator_plus_2;
+ _xifexpression = _operator_plus_2;
} else {
DetailCode _entryCode_1 = s.getEntryCode();
- String _code_1 = ac.getCode(_entryCode_1);
- return _code_1;
+ String _translateDetailCode = dct.translateDetailCode(_entryCode_1);
+ _xifexpression = _translateDetailCode;
}
+ return _xifexpression;
}
- public String getExitCode(final ExpandedActorClass ac, final State s) {
+ public String getExitCode(final ExpandedActorClass ac, final State s, final DetailCodeTranslator dct) {
String _xifexpression = null;
if ((s instanceof RefinedState)) {
DetailCode _exitCode = s.getExitCode();
@@ -852,11 +871,11 @@ public class RoomExtensions {
String _entryCodeOperationName = RoomNameProv.getEntryCodeOperationName(s);
String _operator_plus_1 = StringExtensions.operator_plus(_operator_plus, _entryCodeOperationName);
String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, "();\n");
- return _operator_plus_2;
+ _xifexpression = _operator_plus_2;
} else {
DetailCode _exitCode_1 = s.getExitCode();
- String _code_1 = ac.getCode(_exitCode_1);
- _xifexpression = _code_1;
+ String _translateDetailCode = dct.translateDetailCode(_exitCode_1);
+ _xifexpression = _translateDetailCode;
}
return _xifexpression;
}
@@ -877,10 +896,10 @@ public class RoomExtensions {
return _operator_and;
}
- public String getActionCode(final ExpandedActorClass ac, final Transition t) {
+ public String getActionCode(final ExpandedActorClass ac, final Transition t, final DetailCodeTranslator dct) {
DetailCode _action = t.getAction();
- String _code = ac.getCode(_action);
- return _code;
+ String _translateDetailCode = dct.translateDetailCode(_action);
+ return _translateDetailCode;
}
public String getContextId(final TransitionChain tc) {
diff --git a/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/GenericStateMachineGenerator.java b/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/GenericStateMachineGenerator.java
index 17a49d91c..cc45783bd 100644
--- a/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/GenericStateMachineGenerator.java
+++ b/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/GenericStateMachineGenerator.java
@@ -16,6 +16,8 @@ import org.eclipse.etrice.core.room.StateGraph;
import org.eclipse.etrice.core.room.Transition;
import org.eclipse.etrice.core.room.Trigger;
import org.eclipse.etrice.core.room.TriggeredTransition;
+import org.eclipse.etrice.generator.base.DetailCodeTranslator;
+import org.eclipse.etrice.generator.base.ITranslationProvider;
import org.eclipse.etrice.generator.etricegen.ActiveTrigger;
import org.eclipse.etrice.generator.etricegen.ExpandedActorClass;
import org.eclipse.etrice.generator.etricegen.TransitionChain;
@@ -47,6 +49,9 @@ public class GenericStateMachineGenerator {
@Inject
public LanguageGenerator languageGen;
+ @Inject
+ public ITranslationProvider translator;
+
private String genStateIdConstants(final ExpandedActorClass xpac, final ActorClass ac) {
int _xifexpression = (int) 0;
boolean _usesInheritance = this.langExt.usesInheritance();
@@ -166,823 +171,830 @@ public class GenericStateMachineGenerator {
}
public StringConcatenation genStateMachine(final ExpandedActorClass xpac, final ActorClass ac) {
- StringConcatenation _builder = new StringConcatenation();
- _builder.newLine();
- _builder.append("/* state IDs */");
- _builder.newLine();
- String _genStateIdConstants = this.genStateIdConstants(xpac, ac);
- _builder.append(_genStateIdConstants, "");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("/* transition chains */");
- _builder.newLine();
- String _genTransitionChainConstants = this.genTransitionChainConstants(xpac, ac);
- _builder.append(_genTransitionChainConstants, "");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("/* triggers */");
- _builder.newLine();
- String _genTriggerConstants = this.genTriggerConstants(xpac, ac);
- _builder.append(_genTriggerConstants, "");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- StringConcatenation _genExtra = this.genExtra(xpac, ac);
- _builder.append(_genExtra, "");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("//*** Entry and Exit Codes");
- _builder.newLine();
+ StringConcatenation _xblockexpression = null;
{
- StateGraph _stateMachine = xpac.getStateMachine();
- List<State> _stateList = this.roomExt.getStateList(_stateMachine);
- for(final State state : _stateList) {
- {
- boolean _isOwnObject = xpac.isOwnObject(state);
- if (_isOwnObject) {
- {
- boolean _hasEntryCode = this.roomExt.hasEntryCode(state);
- if (_hasEntryCode) {
- String _accessLevelProtected = this.langExt.accessLevelProtected();
- _builder.append(_accessLevelProtected, "");
- _builder.append("void ");
- String _entryCodeOperationName = RoomNameProv.getEntryCodeOperationName(state);
- _builder.append(_entryCodeOperationName, "");
- _builder.append("(");
- String _name = ac.getName();
- String _selfPointer = this.langExt.selfPointer(_name, false);
- _builder.append(_selfPointer, "");
- _builder.append(") {");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- String _entryCode = this.roomExt.getEntryCode(xpac, state);
- _builder.append(_entryCode, " ");
- _builder.newLineIfNotEmpty();
- _builder.append("}");
- _builder.newLine();
+ this.translator.setActorClass(ac);
+ DetailCodeTranslator _detailCodeTranslator = new DetailCodeTranslator(ac, this.translator);
+ DetailCodeTranslator dct = _detailCodeTranslator;
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.newLine();
+ _builder.append("/* state IDs */");
+ _builder.newLine();
+ String _genStateIdConstants = this.genStateIdConstants(xpac, ac);
+ _builder.append(_genStateIdConstants, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("/* transition chains */");
+ _builder.newLine();
+ String _genTransitionChainConstants = this.genTransitionChainConstants(xpac, ac);
+ _builder.append(_genTransitionChainConstants, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("/* triggers */");
+ _builder.newLine();
+ String _genTriggerConstants = this.genTriggerConstants(xpac, ac);
+ _builder.append(_genTriggerConstants, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ StringConcatenation _genExtra = this.genExtra(xpac, ac);
+ _builder.append(_genExtra, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("//*** Entry and Exit Codes");
+ _builder.newLine();
+ {
+ StateGraph _stateMachine = xpac.getStateMachine();
+ List<State> _stateList = this.roomExt.getStateList(_stateMachine);
+ for(final State state : _stateList) {
+ {
+ boolean _isOwnObject = xpac.isOwnObject(state);
+ if (_isOwnObject) {
+ {
+ boolean _hasEntryCode = this.roomExt.hasEntryCode(state);
+ if (_hasEntryCode) {
+ String _accessLevelProtected = this.langExt.accessLevelProtected();
+ _builder.append(_accessLevelProtected, "");
+ _builder.append("void ");
+ String _entryCodeOperationName = RoomNameProv.getEntryCodeOperationName(state);
+ _builder.append(_entryCodeOperationName, "");
+ _builder.append("(");
+ String _name = ac.getName();
+ String _selfPointer = this.langExt.selfPointer(_name, false);
+ _builder.append(_selfPointer, "");
+ _builder.append(") {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ String _entryCode = this.roomExt.getEntryCode(xpac, state, dct);
+ _builder.append(_entryCode, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("}");
+ _builder.newLine();
+ }
}
- }
- {
- boolean _hasExitCode = this.roomExt.hasExitCode(state);
- if (_hasExitCode) {
- String _accessLevelProtected_1 = this.langExt.accessLevelProtected();
- _builder.append(_accessLevelProtected_1, "");
- _builder.append("void ");
- String _exitCodeOperationName = RoomNameProv.getExitCodeOperationName(state);
- _builder.append(_exitCodeOperationName, "");
- _builder.append("(");
- String _name_1 = ac.getName();
- String _selfPointer_1 = this.langExt.selfPointer(_name_1, false);
- _builder.append(_selfPointer_1, "");
- _builder.append(") {");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- String _exitCode = this.roomExt.getExitCode(xpac, state);
- _builder.append(_exitCode, " ");
- _builder.newLineIfNotEmpty();
- _builder.append("}");
- _builder.newLine();
+ {
+ boolean _hasExitCode = this.roomExt.hasExitCode(state);
+ if (_hasExitCode) {
+ String _accessLevelProtected_1 = this.langExt.accessLevelProtected();
+ _builder.append(_accessLevelProtected_1, "");
+ _builder.append("void ");
+ String _exitCodeOperationName = RoomNameProv.getExitCodeOperationName(state);
+ _builder.append(_exitCodeOperationName, "");
+ _builder.append("(");
+ String _name_1 = ac.getName();
+ String _selfPointer_1 = this.langExt.selfPointer(_name_1, false);
+ _builder.append(_selfPointer_1, "");
+ _builder.append(") {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ String _exitCode = this.roomExt.getExitCode(xpac, state, dct);
+ _builder.append(_exitCode, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("}");
+ _builder.newLine();
+ }
}
}
}
}
}
- }
- _builder.newLine();
- _builder.append("//*** Action Codes");
- _builder.newLine();
- {
- StateGraph _stateMachine_1 = xpac.getStateMachine();
- List<Transition> _transitionList = this.roomExt.getTransitionList(_stateMachine_1);
- for(final Transition tr : _transitionList) {
- {
- boolean _operator_and = false;
- boolean _isOwnObject_1 = xpac.isOwnObject(tr);
- if (!_isOwnObject_1) {
- _operator_and = false;
- } else {
- boolean _hasActionCode = this.roomExt.hasActionCode(tr);
- _operator_and = BooleanExtensions.operator_and(_isOwnObject_1, _hasActionCode);
- }
- if (_operator_and) {
- String _accessLevelProtected_2 = this.langExt.accessLevelProtected();
- _builder.append(_accessLevelProtected_2, "");
- _builder.append("void ");
- String _actionCodeOperationName = RoomNameProv.getActionCodeOperationName(tr);
- _builder.append(_actionCodeOperationName, "");
- _builder.append("(");
- String _name_2 = ac.getName();
- String _selfPointer_2 = this.langExt.selfPointer(_name_2, (tr instanceof NonInitialTransition));
- _builder.append(_selfPointer_2, "");
- {
- if ((tr instanceof NonInitialTransition)) {
- _builder.append("InterfaceItemBase ifitem");
- String _argumentList = this.languageGen.getArgumentList(xpac, tr);
- _builder.append(_argumentList, "");
+ _builder.newLine();
+ _builder.append("//*** Action Codes");
+ _builder.newLine();
+ {
+ StateGraph _stateMachine_1 = xpac.getStateMachine();
+ List<Transition> _transitionList = this.roomExt.getTransitionList(_stateMachine_1);
+ for(final Transition tr : _transitionList) {
+ {
+ boolean _operator_and = false;
+ boolean _isOwnObject_1 = xpac.isOwnObject(tr);
+ if (!_isOwnObject_1) {
+ _operator_and = false;
+ } else {
+ boolean _hasActionCode = this.roomExt.hasActionCode(tr);
+ _operator_and = BooleanExtensions.operator_and(_isOwnObject_1, _hasActionCode);
+ }
+ if (_operator_and) {
+ String _accessLevelProtected_2 = this.langExt.accessLevelProtected();
+ _builder.append(_accessLevelProtected_2, "");
+ _builder.append("void ");
+ String _actionCodeOperationName = RoomNameProv.getActionCodeOperationName(tr);
+ _builder.append(_actionCodeOperationName, "");
+ _builder.append("(");
+ String _name_2 = ac.getName();
+ String _selfPointer_2 = this.langExt.selfPointer(_name_2, (tr instanceof NonInitialTransition));
+ _builder.append(_selfPointer_2, "");
+ {
+ if ((tr instanceof NonInitialTransition)) {
+ _builder.append("InterfaceItemBase ifitem");
+ String _argumentList = this.languageGen.getArgumentList(xpac, tr);
+ _builder.append(_argumentList, "");
+ }
}
+ _builder.append(") {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ String _actionCode = this.roomExt.getActionCode(xpac, tr, dct);
+ _builder.append(_actionCode, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("}");
+ _builder.newLine();
}
- _builder.append(") {");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- String _actionCode = this.roomExt.getActionCode(xpac, tr);
- _builder.append(_actionCode, " ");
- _builder.newLineIfNotEmpty();
- _builder.append("}");
- _builder.newLine();
}
}
}
- }
- _builder.newLine();
- _builder.append("/**");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("* calls exit codes while exiting from the current state to one of its");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("* parent states while remembering the history");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("* @param current - the current state");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("* @param to - the final parent state");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("* @param handler - entry and exit codes are called only if not handler (for handler TransitionPoints)");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("*/");
- _builder.newLine();
- String _accessLevelPrivate = this.langExt.accessLevelPrivate();
- _builder.append(_accessLevelPrivate, "");
- _builder.append("void exitTo(");
- String _name_3 = ac.getName();
- String _selfPointer_3 = this.langExt.selfPointer(_name_3, true);
- _builder.append(_selfPointer_3, "");
- _builder.append("int current, int to, boolean handler) {");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("while (current!=to) {");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("switch (current) {");
- _builder.newLine();
- {
- StateGraph _stateMachine_2 = xpac.getStateMachine();
- List<State> _baseStateList = this.roomExt.getBaseStateList(_stateMachine_2);
- for(final State state_1 : _baseStateList) {
- _builder.append("\t\t\t");
- _builder.append("case ");
- String _stateId = this.roomExt.getStateId(state_1);
- _builder.append(_stateId, " ");
- _builder.append(":");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t\t");
- _builder.append("\t");
- {
- boolean _hasExitCode_1 = this.roomExt.hasExitCode(state_1);
- if (_hasExitCode_1) {
- _builder.append("if (!handler) ");
- String _exitCodeOperationName_1 = RoomNameProv.getExitCodeOperationName(state_1);
- _builder.append(_exitCodeOperationName_1, " ");
- _builder.append("(");
- String _selfPointer_4 = this.langExt.selfPointer(false);
- _builder.append(_selfPointer_4, " ");
- _builder.append(");");
+ _builder.newLine();
+ _builder.append("/**");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* calls exit codes while exiting from the current state to one of its");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* parent states while remembering the history");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* @param current - the current state");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* @param to - the final parent state");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* @param handler - entry and exit codes are called only if not handler (for handler TransitionPoints)");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("*/");
+ _builder.newLine();
+ String _accessLevelPrivate = this.langExt.accessLevelPrivate();
+ _builder.append(_accessLevelPrivate, "");
+ _builder.append("void exitTo(");
+ String _name_3 = ac.getName();
+ String _selfPointer_3 = this.langExt.selfPointer(_name_3, true);
+ _builder.append(_selfPointer_3, "");
+ _builder.append("int current, int to, boolean handler) {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("while (current!=to) {");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("switch (current) {");
+ _builder.newLine();
+ {
+ StateGraph _stateMachine_2 = xpac.getStateMachine();
+ List<State> _baseStateList = this.roomExt.getBaseStateList(_stateMachine_2);
+ for(final State state_1 : _baseStateList) {
+ _builder.append("\t\t\t");
+ _builder.append("case ");
+ String _stateId = this.roomExt.getStateId(state_1);
+ _builder.append(_stateId, " ");
+ _builder.append(":");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t\t");
+ _builder.append("\t");
+ {
+ boolean _hasExitCode_1 = this.roomExt.hasExitCode(state_1);
+ if (_hasExitCode_1) {
+ _builder.append("if (!handler) ");
+ String _exitCodeOperationName_1 = RoomNameProv.getExitCodeOperationName(state_1);
+ _builder.append(_exitCodeOperationName_1, " ");
+ _builder.append("(");
+ String _selfPointer_4 = this.langExt.selfPointer(false);
+ _builder.append(_selfPointer_4, " ");
+ _builder.append(");");
+ }
}
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t\t");
+ _builder.append("\t");
+ String _memberAccess = this.langExt.memberAccess();
+ _builder.append(_memberAccess, " ");
+ _builder.append("history[");
+ String _parentStateId = RoomNameProv.getParentStateId(state_1);
+ _builder.append(_parentStateId, " ");
+ _builder.append("] = ");
+ String _stateId_1 = this.roomExt.getStateId(state_1);
+ _builder.append(_stateId_1, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t\t");
+ _builder.append("\t");
+ _builder.append("current = ");
+ String _parentStateId_1 = RoomNameProv.getParentStateId(state_1);
+ _builder.append(_parentStateId_1, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t\t");
+ _builder.append("\t");
+ _builder.append("break;");
+ _builder.newLine();
}
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t\t");
- _builder.append("\t");
- String _memberAccess = this.langExt.memberAccess();
- _builder.append(_memberAccess, " ");
- _builder.append("history[");
- String _parentStateId = RoomNameProv.getParentStateId(state_1);
- _builder.append(_parentStateId, " ");
- _builder.append("] = ");
- String _stateId_1 = this.roomExt.getStateId(state_1);
- _builder.append(_stateId_1, " ");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t\t");
- _builder.append("\t");
- _builder.append("current = ");
- String _parentStateId_1 = RoomNameProv.getParentStateId(state_1);
- _builder.append(_parentStateId_1, " ");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t\t");
- _builder.append("\t");
- _builder.append("break;");
- _builder.newLine();
}
- }
- _builder.append("\t\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("}");
- _builder.newLine();
- _builder.newLine();
- _builder.append("/**");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("* calls action, entry and exit codes along a transition chain. The generic data are cast to typed data");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("* matching the trigger of this chain. The ID of the final state is returned");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("* @param chain - the chain ID");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("* @param generic_data - the generic data pointer");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("* @return the ID of the final state");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("*/");
- _builder.newLine();
- String _accessLevelPrivate_1 = this.langExt.accessLevelPrivate();
- _builder.append(_accessLevelPrivate_1, "");
- _builder.append("int executeTransitionChain(");
- String _name_4 = ac.getName();
- String _selfPointer_5 = this.langExt.selfPointer(_name_4, true);
- _builder.append(_selfPointer_5, "");
- _builder.append("int chain, InterfaceItemBase ifitem, ");
- String _voidPointer = this.langExt.voidPointer();
- _builder.append(_voidPointer, "");
- _builder.append(" generic_data) {");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("switch (chain) {");
- _builder.newLine();
- _builder.append("\t\t");
- EList<TransitionChain> _transitionChains = xpac.getTransitionChains();
- EList<TransitionChain> allchains = _transitionChains;
- _builder.newLineIfNotEmpty();
- {
- for(final TransitionChain tc : allchains) {
- _builder.append("\t\t");
- _builder.append("case ");
- String _chainId = this.roomExt.getChainId(tc);
- _builder.append(_chainId, " ");
- _builder.append(":");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.append("{");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("\t");
- String _executeChain = this.languageGen.getExecuteChain(xpac, tc);
- _builder.append(_executeChain, " ");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.append("}");
- _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("/**");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* calls action, entry and exit codes along a transition chain. The generic data are cast to typed data");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* matching the trigger of this chain. The ID of the final state is returned");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* @param chain - the chain ID");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* @param generic_data - the generic data pointer");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* @return the ID of the final state");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("*/");
+ _builder.newLine();
+ String _accessLevelPrivate_1 = this.langExt.accessLevelPrivate();
+ _builder.append(_accessLevelPrivate_1, "");
+ _builder.append("int executeTransitionChain(");
+ String _name_4 = ac.getName();
+ String _selfPointer_5 = this.langExt.selfPointer(_name_4, true);
+ _builder.append(_selfPointer_5, "");
+ _builder.append("int chain, InterfaceItemBase ifitem, ");
+ String _voidPointer = this.langExt.voidPointer();
+ _builder.append(_voidPointer, "");
+ _builder.append(" generic_data) {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("switch (chain) {");
+ _builder.newLine();
+ _builder.append("\t\t");
+ EList<TransitionChain> _transitionChains = xpac.getTransitionChains();
+ EList<TransitionChain> allchains = _transitionChains;
+ _builder.newLineIfNotEmpty();
+ {
+ for(final TransitionChain tc : allchains) {
+ _builder.append("\t\t");
+ _builder.append("case ");
+ String _chainId = this.roomExt.getChainId(tc);
+ _builder.append(_chainId, " ");
+ _builder.append(":");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("{");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("\t");
+ String _executeChain = this.languageGen.getExecuteChain(xpac, tc);
+ _builder.append(_executeChain, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("}");
+ _builder.newLine();
+ }
}
- }
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("return NO_STATE;");
- _builder.newLine();
- _builder.append("}");
- _builder.newLine();
- _builder.newLine();
- _builder.append("/**");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("* calls entry codes while entering a state\'s history. The ID of the final leaf state is returned");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("* @param state - the state which is entered");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("* @param handler - entry code is executed if not handler");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("* @return - the ID of the final leaf state");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("*/");
- _builder.newLine();
- String _accessLevelPrivate_2 = this.langExt.accessLevelPrivate();
- _builder.append(_accessLevelPrivate_2, "");
- _builder.append("int enterHistory(");
- String _name_5 = ac.getName();
- String _selfPointer_6 = this.langExt.selfPointer(_name_5, true);
- _builder.append(_selfPointer_6, "");
- _builder.append("int state, boolean handler, boolean skip_entry) {");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("while (");
- String _booleanConstant = this.langExt.booleanConstant(true);
- _builder.append(_booleanConstant, " ");
- _builder.append(") {");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.append("switch (state) {");
- _builder.newLine();
- {
- StateGraph _stateMachine_3 = xpac.getStateMachine();
- List<State> _baseStateList_1 = this.roomExt.getBaseStateList(_stateMachine_3);
- for(final State state_2 : _baseStateList_1) {
- _builder.append("\t\t\t");
- _builder.append("case ");
- String _stateId_2 = this.roomExt.getStateId(state_2);
- _builder.append(_stateId_2, " ");
- _builder.append(":");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t\t");
- _builder.append("\t");
- {
- boolean _hasEntryCode_1 = this.roomExt.hasEntryCode(state_2);
- if (_hasEntryCode_1) {
- _builder.append("if (!(skip_entry || handler)) ");
- String _entryCodeOperationName_1 = RoomNameProv.getEntryCodeOperationName(state_2);
- _builder.append(_entryCodeOperationName_1, " ");
- _builder.append("(");
- String _selfPointer_7 = this.langExt.selfPointer(false);
- _builder.append(_selfPointer_7, " ");
- _builder.append(");");
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("return NO_STATE;");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("/**");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* calls entry codes while entering a state\'s history. The ID of the final leaf state is returned");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* @param state - the state which is entered");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* @param handler - entry code is executed if not handler");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* @return - the ID of the final leaf state");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("*/");
+ _builder.newLine();
+ String _accessLevelPrivate_2 = this.langExt.accessLevelPrivate();
+ _builder.append(_accessLevelPrivate_2, "");
+ _builder.append("int enterHistory(");
+ String _name_5 = ac.getName();
+ String _selfPointer_6 = this.langExt.selfPointer(_name_5, true);
+ _builder.append(_selfPointer_6, "");
+ _builder.append("int state, boolean handler, boolean skip_entry) {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("while (");
+ String _booleanConstant = this.langExt.booleanConstant(true);
+ _builder.append(_booleanConstant, " ");
+ _builder.append(") {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("switch (state) {");
+ _builder.newLine();
+ {
+ StateGraph _stateMachine_3 = xpac.getStateMachine();
+ List<State> _baseStateList_1 = this.roomExt.getBaseStateList(_stateMachine_3);
+ for(final State state_2 : _baseStateList_1) {
+ _builder.append("\t\t\t");
+ _builder.append("case ");
+ String _stateId_2 = this.roomExt.getStateId(state_2);
+ _builder.append(_stateId_2, " ");
+ _builder.append(":");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t\t");
+ _builder.append("\t");
+ {
+ boolean _hasEntryCode_1 = this.roomExt.hasEntryCode(state_2);
+ if (_hasEntryCode_1) {
+ _builder.append("if (!(skip_entry || handler)) ");
+ String _entryCodeOperationName_1 = RoomNameProv.getEntryCodeOperationName(state_2);
+ _builder.append(_entryCodeOperationName_1, " ");
+ _builder.append("(");
+ String _selfPointer_7 = this.langExt.selfPointer(false);
+ _builder.append(_selfPointer_7, " ");
+ _builder.append(");");
+ }
}
- }
- _builder.newLineIfNotEmpty();
- {
- boolean _isLeaf = this.roomExt.isLeaf(state_2);
- if (_isLeaf) {
- _builder.append("\t\t\t");
- _builder.append("\t");
- _builder.append("// in leaf state: return state id");
- _builder.newLine();
- _builder.append("\t\t\t");
- _builder.append("\t");
- _builder.append("return ");
- String _stateId_3 = this.roomExt.getStateId(state_2);
- _builder.append(_stateId_3, " ");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- } else {
- _builder.append("\t\t\t");
- _builder.append("\t");
- _builder.append("// state has a sub graph");
- _builder.newLine();
- {
- StateGraph _subgraph = state_2.getSubgraph();
- boolean _hasInitTransition = this.roomExt.hasInitTransition(_subgraph);
- if (_hasInitTransition) {
- _builder.append("\t\t\t");
- _builder.append("\t");
- _builder.append("// with init transition");
- _builder.newLine();
- _builder.append("\t\t\t");
- _builder.append("\t");
- _builder.append("if (");
- String _memberAccess_1 = this.langExt.memberAccess();
- _builder.append(_memberAccess_1, " ");
- _builder.append("history[");
- String _stateId_4 = this.roomExt.getStateId(state_2);
- _builder.append(_stateId_4, " ");
- _builder.append("]==NO_STATE) {");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t\t");
- _builder.append("\t");
- _builder.append("\t");
- StateGraph _subgraph_1 = state_2.getSubgraph();
- Transition _initTransition = this.roomExt.getInitTransition(_subgraph_1);
- Transition sub_initt = _initTransition;
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t\t");
- _builder.append("\t");
- _builder.append("\t");
- _builder.append("state = executeTransitionChain(");
- String _selfPointer_8 = this.langExt.selfPointer(true);
- _builder.append(_selfPointer_8, " ");
- TransitionChain _chain = xpac.getChain(sub_initt);
- String _chainId_1 = this.roomExt.getChainId(_chain);
- _builder.append(_chainId_1, " ");
- _builder.append(", ");
- String _nullPointer = this.langExt.nullPointer();
- _builder.append(_nullPointer, " ");
- _builder.append(", ");
- String _nullPointer_1 = this.langExt.nullPointer();
- _builder.append(_nullPointer_1, " ");
- _builder.append(");");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t\t");
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("\t\t\t");
- _builder.append("\t");
- _builder.append("else {");
- _builder.newLine();
- _builder.append("\t\t\t");
- _builder.append("\t");
- _builder.append("\t");
- _builder.append("state = ");
- String _memberAccess_2 = this.langExt.memberAccess();
- _builder.append(_memberAccess_2, " ");
- _builder.append("history[");
- String _stateId_5 = this.roomExt.getStateId(state_2);
- _builder.append(_stateId_5, " ");
- _builder.append("];");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t\t");
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- } else {
- _builder.append("\t\t\t");
- _builder.append("\t");
- _builder.append("// without init transition");
- _builder.newLine();
- _builder.append("\t\t\t");
- _builder.append("\t");
- _builder.append("state = ");
- String _memberAccess_3 = this.langExt.memberAccess();
- _builder.append(_memberAccess_3, " ");
- _builder.append("history[");
- String _stateId_6 = this.roomExt.getStateId(state_2);
- _builder.append(_stateId_6, " ");
- _builder.append("];");
- _builder.newLineIfNotEmpty();
+ _builder.newLineIfNotEmpty();
+ {
+ boolean _isLeaf = this.roomExt.isLeaf(state_2);
+ if (_isLeaf) {
+ _builder.append("\t\t\t");
+ _builder.append("\t");
+ _builder.append("// in leaf state: return state id");
+ _builder.newLine();
+ _builder.append("\t\t\t");
+ _builder.append("\t");
+ _builder.append("return ");
+ String _stateId_3 = this.roomExt.getStateId(state_2);
+ _builder.append(_stateId_3, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ } else {
+ _builder.append("\t\t\t");
+ _builder.append("\t");
+ _builder.append("// state has a sub graph");
+ _builder.newLine();
+ {
+ StateGraph _subgraph = state_2.getSubgraph();
+ boolean _hasInitTransition = this.roomExt.hasInitTransition(_subgraph);
+ if (_hasInitTransition) {
+ _builder.append("\t\t\t");
+ _builder.append("\t");
+ _builder.append("// with init transition");
+ _builder.newLine();
+ _builder.append("\t\t\t");
+ _builder.append("\t");
+ _builder.append("if (");
+ String _memberAccess_1 = this.langExt.memberAccess();
+ _builder.append(_memberAccess_1, " ");
+ _builder.append("history[");
+ String _stateId_4 = this.roomExt.getStateId(state_2);
+ _builder.append(_stateId_4, " ");
+ _builder.append("]==NO_STATE) {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t\t");
+ _builder.append("\t");
+ _builder.append("\t");
+ StateGraph _subgraph_1 = state_2.getSubgraph();
+ Transition _initTransition = this.roomExt.getInitTransition(_subgraph_1);
+ Transition sub_initt = _initTransition;
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t\t");
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("state = executeTransitionChain(");
+ String _selfPointer_8 = this.langExt.selfPointer(true);
+ _builder.append(_selfPointer_8, " ");
+ TransitionChain _chain = xpac.getChain(sub_initt);
+ String _chainId_1 = this.roomExt.getChainId(_chain);
+ _builder.append(_chainId_1, " ");
+ _builder.append(", ");
+ String _nullPointer = this.langExt.nullPointer();
+ _builder.append(_nullPointer, " ");
+ _builder.append(", ");
+ String _nullPointer_1 = this.langExt.nullPointer();
+ _builder.append(_nullPointer_1, " ");
+ _builder.append(");");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t\t");
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t\t\t");
+ _builder.append("\t");
+ _builder.append("else {");
+ _builder.newLine();
+ _builder.append("\t\t\t");
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("state = ");
+ String _memberAccess_2 = this.langExt.memberAccess();
+ _builder.append(_memberAccess_2, " ");
+ _builder.append("history[");
+ String _stateId_5 = this.roomExt.getStateId(state_2);
+ _builder.append(_stateId_5, " ");
+ _builder.append("];");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t\t");
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ } else {
+ _builder.append("\t\t\t");
+ _builder.append("\t");
+ _builder.append("// without init transition");
+ _builder.newLine();
+ _builder.append("\t\t\t");
+ _builder.append("\t");
+ _builder.append("state = ");
+ String _memberAccess_3 = this.langExt.memberAccess();
+ _builder.append(_memberAccess_3, " ");
+ _builder.append("history[");
+ String _stateId_6 = this.roomExt.getStateId(state_2);
+ _builder.append(_stateId_6, " ");
+ _builder.append("];");
+ _builder.newLineIfNotEmpty();
+ }
}
+ _builder.append("\t\t\t");
+ _builder.append("\t");
+ _builder.append("break;");
+ _builder.newLine();
}
- _builder.append("\t\t\t");
- _builder.append("\t");
- _builder.append("break;");
- _builder.newLine();
}
}
}
- }
- _builder.append("\t\t\t");
- _builder.append("case STATE_TOP:");
- _builder.newLine();
- _builder.append("\t\t\t\t");
- _builder.append("state = ");
- String _memberAccess_4 = this.langExt.memberAccess();
- _builder.append(_memberAccess_4, " ");
- _builder.append("history[STATE_TOP];");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t\t\t");
- _builder.append("break;");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("skip_entry = ");
- String _booleanConstant_1 = this.langExt.booleanConstant(false);
- _builder.append(_booleanConstant_1, " ");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("//return NO_STATE; // required by CDT but detected as unreachable by JDT because of while (true)");
- _builder.newLine();
- _builder.append("}");
- _builder.newLine();
- _builder.newLine();
- {
- boolean _usesInheritance = this.langExt.usesInheritance();
- if (_usesInheritance) {
- String _accessLevelPublic = this.langExt.accessLevelPublic();
- _builder.append(_accessLevelPublic, "");
- } else {
- String _accessLevelPrivate_3 = this.langExt.accessLevelPrivate();
- _builder.append(_accessLevelPrivate_3, "");
+ _builder.append("\t\t\t");
+ _builder.append("case STATE_TOP:");
+ _builder.newLine();
+ _builder.append("\t\t\t\t");
+ _builder.append("state = ");
+ String _memberAccess_4 = this.langExt.memberAccess();
+ _builder.append(_memberAccess_4, " ");
+ _builder.append("history[STATE_TOP];");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t\t\t");
+ _builder.append("break;");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("skip_entry = ");
+ String _booleanConstant_1 = this.langExt.booleanConstant(false);
+ _builder.append(_booleanConstant_1, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("//return NO_STATE; // required by CDT but detected as unreachable by JDT because of while (true)");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ _builder.newLine();
+ {
+ boolean _usesInheritance = this.langExt.usesInheritance();
+ if (_usesInheritance) {
+ String _accessLevelPublic = this.langExt.accessLevelPublic();
+ _builder.append(_accessLevelPublic, "");
+ } else {
+ String _accessLevelPrivate_3 = this.langExt.accessLevelPrivate();
+ _builder.append(_accessLevelPrivate_3, "");
+ }
}
- }
- _builder.append("void executeInitTransition(");
- String _name_6 = ac.getName();
- String _selfPointer_9 = this.langExt.selfPointer(_name_6, false);
- _builder.append(_selfPointer_9, "");
- _builder.append(") {");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- StateGraph _stateMachine_4 = xpac.getStateMachine();
- Transition _initTransition_1 = this.roomExt.getInitTransition(_stateMachine_4);
- Transition initt = _initTransition_1;
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("int chain = ");
- TransitionChain _chain_1 = xpac.getChain(initt);
- String _chainId_2 = this.roomExt.getChainId(_chain_1);
- _builder.append(_chainId_2, " ");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("int next = executeTransitionChain(");
- String _selfPointer_10 = this.langExt.selfPointer(true);
- _builder.append(_selfPointer_10, " ");
- _builder.append("chain, ");
- String _nullPointer_2 = this.langExt.nullPointer();
- _builder.append(_nullPointer_2, " ");
- _builder.append(", ");
- String _nullPointer_3 = this.langExt.nullPointer();
- _builder.append(_nullPointer_3, " ");
- _builder.append(");");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("next = enterHistory(");
- String _selfPointer_11 = this.langExt.selfPointer(true);
- _builder.append(_selfPointer_11, " ");
- _builder.append("next, ");
- String _booleanConstant_2 = this.langExt.booleanConstant(false);
- _builder.append(_booleanConstant_2, " ");
- _builder.append(", ");
- String _booleanConstant_3 = this.langExt.booleanConstant(false);
- _builder.append(_booleanConstant_3, " ");
- _builder.append(");");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("setState(");
- String _selfPointer_12 = this.langExt.selfPointer(true);
- _builder.append(_selfPointer_12, " ");
- _builder.append("next);");
- _builder.newLineIfNotEmpty();
- _builder.append("}");
- _builder.newLine();
- _builder.newLine();
- _builder.append("/* receiveEvent contains the main implementation of the FSM */");
- _builder.newLine();
- {
- boolean _usesInheritance_1 = this.langExt.usesInheritance();
- if (_usesInheritance_1) {
- String _accessLevelPublic_1 = this.langExt.accessLevelPublic();
- _builder.append(_accessLevelPublic_1, "");
- } else {
- String _accessLevelPrivate_4 = this.langExt.accessLevelPrivate();
- _builder.append(_accessLevelPrivate_4, "");
+ _builder.append("void executeInitTransition(");
+ String _name_6 = ac.getName();
+ String _selfPointer_9 = this.langExt.selfPointer(_name_6, false);
+ _builder.append(_selfPointer_9, "");
+ _builder.append(") {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ StateGraph _stateMachine_4 = xpac.getStateMachine();
+ Transition _initTransition_1 = this.roomExt.getInitTransition(_stateMachine_4);
+ Transition initt = _initTransition_1;
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("int chain = ");
+ TransitionChain _chain_1 = xpac.getChain(initt);
+ String _chainId_2 = this.roomExt.getChainId(_chain_1);
+ _builder.append(_chainId_2, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("int next = executeTransitionChain(");
+ String _selfPointer_10 = this.langExt.selfPointer(true);
+ _builder.append(_selfPointer_10, " ");
+ _builder.append("chain, ");
+ String _nullPointer_2 = this.langExt.nullPointer();
+ _builder.append(_nullPointer_2, " ");
+ _builder.append(", ");
+ String _nullPointer_3 = this.langExt.nullPointer();
+ _builder.append(_nullPointer_3, " ");
+ _builder.append(");");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("next = enterHistory(");
+ String _selfPointer_11 = this.langExt.selfPointer(true);
+ _builder.append(_selfPointer_11, " ");
+ _builder.append("next, ");
+ String _booleanConstant_2 = this.langExt.booleanConstant(false);
+ _builder.append(_booleanConstant_2, " ");
+ _builder.append(", ");
+ String _booleanConstant_3 = this.langExt.booleanConstant(false);
+ _builder.append(_booleanConstant_3, " ");
+ _builder.append(");");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("setState(");
+ String _selfPointer_12 = this.langExt.selfPointer(true);
+ _builder.append(_selfPointer_12, " ");
+ _builder.append("next);");
+ _builder.newLineIfNotEmpty();
+ _builder.append("}");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("/* receiveEvent contains the main implementation of the FSM */");
+ _builder.newLine();
+ {
+ boolean _usesInheritance_1 = this.langExt.usesInheritance();
+ if (_usesInheritance_1) {
+ String _accessLevelPublic_1 = this.langExt.accessLevelPublic();
+ _builder.append(_accessLevelPublic_1, "");
+ } else {
+ String _accessLevelPrivate_4 = this.langExt.accessLevelPrivate();
+ _builder.append(_accessLevelPrivate_4, "");
+ }
}
- }
- _builder.append("void receiveEvent(");
- String _name_7 = ac.getName();
- String _selfPointer_13 = this.langExt.selfPointer(_name_7, true);
- _builder.append(_selfPointer_13, "");
- _builder.append("InterfaceItemBase ifitem, int evt, ");
- String _voidPointer_1 = this.langExt.voidPointer();
- _builder.append(_voidPointer_1, "");
- _builder.append(" generic_data) {");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("int trigger = ");
- {
- boolean _usesInheritance_2 = this.langExt.usesInheritance();
- if (_usesInheritance_2) {
- _builder.append("ifitem.getLocalId()");
- } else {
- _builder.append("ifitem->localId");
+ _builder.append("void receiveEvent(");
+ String _name_7 = ac.getName();
+ String _selfPointer_13 = this.langExt.selfPointer(_name_7, true);
+ _builder.append(_selfPointer_13, "");
+ _builder.append("InterfaceItemBase ifitem, int evt, ");
+ String _voidPointer_1 = this.langExt.voidPointer();
+ _builder.append(_voidPointer_1, "");
+ _builder.append(" generic_data) {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("int trigger = ");
+ {
+ boolean _usesInheritance_2 = this.langExt.usesInheritance();
+ if (_usesInheritance_2) {
+ _builder.append("ifitem.getLocalId()");
+ } else {
+ _builder.append("ifitem->localId");
+ }
}
- }
- _builder.append(" + EVT_SHIFT*evt;");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("int chain = NOT_CAUGHT;");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("int catching_state = NO_STATE;");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("boolean is_handler = ");
- String _booleanConstant_4 = this.langExt.booleanConstant(false);
- _builder.append(_booleanConstant_4, " ");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("boolean skip_entry = ");
- String _booleanConstant_5 = this.langExt.booleanConstant(false);
- _builder.append(_booleanConstant_5, " ");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("if (!handleSystemEvent(ifitem, evt, generic_data)) {");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("switch (");
- String _memberAccess_5 = this.langExt.memberAccess();
- _builder.append(_memberAccess_5, " ");
- _builder.append("state) {");
- _builder.newLineIfNotEmpty();
- {
- StateGraph _stateMachine_5 = xpac.getStateMachine();
- List<State> _leafStateList = this.roomExt.getLeafStateList(_stateMachine_5);
- for(final State state_3 : _leafStateList) {
- _builder.append("\t\t\t");
- _builder.append("case ");
- String _stateId_7 = this.roomExt.getStateId(state_3);
- _builder.append(_stateId_7, " ");
- _builder.append(":");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t\t");
- _builder.append("\t");
- EList<ActiveTrigger> _activeTriggers = xpac.getActiveTriggers(state_3);
- EList<ActiveTrigger> atlist = _activeTriggers;
- _builder.newLineIfNotEmpty();
- {
- boolean _isEmpty = atlist.isEmpty();
- boolean _operator_not = BooleanExtensions.operator_not(_isEmpty);
- if (_operator_not) {
- _builder.append("\t\t\t");
- _builder.append("\t");
- _builder.append("switch(trigger) {");
- _builder.newLine();
- {
- for(final ActiveTrigger at : atlist) {
- _builder.append("\t\t\t");
- _builder.append("\t");
- _builder.append("case ");
- String _trigger = at.getTrigger();
- String _triggerCodeName = xpac.getTriggerCodeName(_trigger);
- _builder.append(_triggerCodeName, " ");
- _builder.append(":");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t\t");
- _builder.append("\t");
- _builder.append("\t");
- boolean _hasGuard = this.roomExt.hasGuard(xpac, at);
- boolean needData = _hasGuard;
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t\t");
- _builder.append("\t");
- _builder.append("\t");
- {
- if (needData) {
- _builder.append("{ ");
- Message _msg = at.getMsg();
- String _typedDataDefinition = this.langExt.getTypedDataDefinition(_msg);
- _builder.append(_typedDataDefinition, " ");
- }
- }
- _builder.newLineIfNotEmpty();
- {
- EList<TriggeredTransition> _transitions = at.getTransitions();
- boolean hasAnyElements = false;
- for(final TriggeredTransition tt : _transitions) {
- if (!hasAnyElements) {
- hasAnyElements = true;
- } else {
- _builder.appendImmediate(" else ", " ");
+ _builder.append(" + EVT_SHIFT*evt;");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("int chain = NOT_CAUGHT;");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("int catching_state = NO_STATE;");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("boolean is_handler = ");
+ String _booleanConstant_4 = this.langExt.booleanConstant(false);
+ _builder.append(_booleanConstant_4, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("boolean skip_entry = ");
+ String _booleanConstant_5 = this.langExt.booleanConstant(false);
+ _builder.append(_booleanConstant_5, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("if (!handleSystemEvent(ifitem, evt, generic_data)) {");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("switch (");
+ String _memberAccess_5 = this.langExt.memberAccess();
+ _builder.append(_memberAccess_5, " ");
+ _builder.append("state) {");
+ _builder.newLineIfNotEmpty();
+ {
+ StateGraph _stateMachine_5 = xpac.getStateMachine();
+ List<State> _leafStateList = this.roomExt.getLeafStateList(_stateMachine_5);
+ for(final State state_3 : _leafStateList) {
+ _builder.append("\t\t\t");
+ _builder.append("case ");
+ String _stateId_7 = this.roomExt.getStateId(state_3);
+ _builder.append(_stateId_7, " ");
+ _builder.append(":");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t\t");
+ _builder.append("\t");
+ EList<ActiveTrigger> _activeTriggers = xpac.getActiveTriggers(state_3);
+ EList<ActiveTrigger> atlist = _activeTriggers;
+ _builder.newLineIfNotEmpty();
+ {
+ boolean _isEmpty = atlist.isEmpty();
+ boolean _operator_not = BooleanExtensions.operator_not(_isEmpty);
+ if (_operator_not) {
+ _builder.append("\t\t\t");
+ _builder.append("\t");
+ _builder.append("switch(trigger) {");
+ _builder.newLine();
+ {
+ for(final ActiveTrigger at : atlist) {
+ _builder.append("\t\t\t");
+ _builder.append("\t");
+ _builder.append("case ");
+ String _trigger = at.getTrigger();
+ String _triggerCodeName = xpac.getTriggerCodeName(_trigger);
+ _builder.append(_triggerCodeName, " ");
+ _builder.append(":");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t\t");
+ _builder.append("\t");
+ _builder.append("\t");
+ boolean _hasGuard = this.roomExt.hasGuard(xpac, at);
+ boolean needData = _hasGuard;
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t\t");
+ _builder.append("\t");
+ _builder.append("\t");
+ {
+ if (needData) {
+ _builder.append("{ ");
+ Message _msg = at.getMsg();
+ String _typedDataDefinition = this.langExt.getTypedDataDefinition(_msg);
+ _builder.append(_typedDataDefinition, " ");
}
- _builder.append("\t\t\t");
- _builder.append("\t");
- _builder.append("\t");
- TransitionChain _chain_2 = xpac.getChain(tt);
- TransitionChain chain = _chain_2;
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t\t");
- _builder.append("\t");
- _builder.append("\t");
- Transition _transition = chain.getTransition();
- String _trigger_1 = at.getTrigger();
- StringConcatenation _guard = this.guard(_transition, _trigger_1, xpac);
- _builder.append(_guard, " ");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t\t");
- _builder.append("\t");
- _builder.append("\t");
- _builder.append("{");
- _builder.newLine();
- _builder.append("\t\t\t");
- _builder.append("\t");
- _builder.append("\t");
- _builder.append("\t");
- _builder.append("chain = ");
- String _chainId_3 = this.roomExt.getChainId(chain);
- _builder.append(_chainId_3, " ");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t\t");
- _builder.append("\t");
- _builder.append("\t");
- _builder.append("\t");
- _builder.append("catching_state = ");
- String _contextId = this.roomExt.getContextId(chain);
- _builder.append(_contextId, " ");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t\t");
- _builder.append("\t");
- _builder.append("\t");
- _builder.append("\t");
- {
- boolean _isHandler = chain.isHandler();
- if (_isHandler) {
- _builder.append("is_handler = ");
- String _booleanConstant_6 = this.langExt.booleanConstant(true);
- _builder.append(_booleanConstant_6, " ");
- _builder.append(";");
+ }
+ _builder.newLineIfNotEmpty();
+ {
+ EList<TriggeredTransition> _transitions = at.getTransitions();
+ boolean hasAnyElements = false;
+ for(final TriggeredTransition tt : _transitions) {
+ if (!hasAnyElements) {
+ hasAnyElements = true;
+ } else {
+ _builder.appendImmediate(" else ", " ");
}
- }
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t\t");
- _builder.append("\t");
- _builder.append("\t");
- _builder.append("\t");
- {
- boolean _isSkipEntry = chain.isSkipEntry();
- if (_isSkipEntry) {
- _builder.append("skip_entry = ");
- String _booleanConstant_7 = this.langExt.booleanConstant(true);
- _builder.append(_booleanConstant_7, " ");
- _builder.append(";");
+ _builder.append("\t\t\t");
+ _builder.append("\t");
+ _builder.append("\t");
+ TransitionChain _chain_2 = xpac.getChain(tt);
+ TransitionChain chain = _chain_2;
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t\t");
+ _builder.append("\t");
+ _builder.append("\t");
+ Transition _transition = chain.getTransition();
+ String _trigger_1 = at.getTrigger();
+ StringConcatenation _guard = this.guard(_transition, _trigger_1, xpac, dct);
+ _builder.append(_guard, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t\t");
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("{");
+ _builder.newLine();
+ _builder.append("\t\t\t");
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("chain = ");
+ String _chainId_3 = this.roomExt.getChainId(chain);
+ _builder.append(_chainId_3, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t\t");
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("catching_state = ");
+ String _contextId = this.roomExt.getContextId(chain);
+ _builder.append(_contextId, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t\t");
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("\t");
+ {
+ boolean _isHandler = chain.isHandler();
+ if (_isHandler) {
+ _builder.append("is_handler = ");
+ String _booleanConstant_6 = this.langExt.booleanConstant(true);
+ _builder.append(_booleanConstant_6, " ");
+ _builder.append(";");
+ }
}
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t\t");
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("\t");
+ {
+ boolean _isSkipEntry = chain.isSkipEntry();
+ if (_isSkipEntry) {
+ _builder.append("skip_entry = ");
+ String _booleanConstant_7 = this.langExt.booleanConstant(true);
+ _builder.append(_booleanConstant_7, " ");
+ _builder.append(";");
+ }
+ }
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t\t");
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
}
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t\t");
- _builder.append("\t");
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
}
- }
- _builder.append("\t\t\t");
- _builder.append("\t");
- _builder.append("\t");
- {
- if (needData) {
- _builder.append("}");
+ _builder.append("\t\t\t");
+ _builder.append("\t");
+ _builder.append("\t");
+ {
+ if (needData) {
+ _builder.append("}");
+ }
}
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t\t");
+ _builder.append("\t");
+ _builder.append("break;");
+ _builder.newLine();
}
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t\t");
- _builder.append("\t");
- _builder.append("break;");
- _builder.newLine();
}
+ _builder.append("\t\t\t");
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
}
- _builder.append("\t\t\t");
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
}
+ _builder.append("\t\t\t");
+ _builder.append("\t");
+ _builder.append("break;");
+ _builder.newLine();
}
- _builder.append("\t\t\t");
- _builder.append("\t");
- _builder.append("break;");
- _builder.newLine();
}
+ _builder.append("\t\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("if (chain != NOT_CAUGHT) {");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("exitTo(");
+ String _selfPointer_14 = this.langExt.selfPointer(true);
+ _builder.append(_selfPointer_14, " ");
+ String _memberAccess_6 = this.langExt.memberAccess();
+ _builder.append(_memberAccess_6, " ");
+ _builder.append("state, catching_state, is_handler);");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("int next = executeTransitionChain(");
+ String _selfPointer_15 = this.langExt.selfPointer(true);
+ _builder.append(_selfPointer_15, " ");
+ _builder.append("chain, ifitem, generic_data);");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("next = enterHistory(");
+ String _selfPointer_16 = this.langExt.selfPointer(true);
+ _builder.append(_selfPointer_16, " ");
+ _builder.append("next, is_handler, skip_entry);");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("setState(");
+ String _selfPointer_17 = this.langExt.selfPointer(true);
+ _builder.append(_selfPointer_17, " ");
+ _builder.append("next);");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t ");
+ _builder.newLine();
+ _builder.append("//******************************************");
+ _builder.newLine();
+ _builder.append("// END of generated code for FSM");
+ _builder.newLine();
+ _builder.append("//******************************************");
+ _builder.newLine();
+ _xblockexpression = (_builder);
}
- _builder.append("\t\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("if (chain != NOT_CAUGHT) {");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("exitTo(");
- String _selfPointer_14 = this.langExt.selfPointer(true);
- _builder.append(_selfPointer_14, " ");
- String _memberAccess_6 = this.langExt.memberAccess();
- _builder.append(_memberAccess_6, " ");
- _builder.append("state, catching_state, is_handler);");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.append("int next = executeTransitionChain(");
- String _selfPointer_15 = this.langExt.selfPointer(true);
- _builder.append(_selfPointer_15, " ");
- _builder.append("chain, ifitem, generic_data);");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.append("next = enterHistory(");
- String _selfPointer_16 = this.langExt.selfPointer(true);
- _builder.append(_selfPointer_16, " ");
- _builder.append("next, is_handler, skip_entry);");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.append("setState(");
- String _selfPointer_17 = this.langExt.selfPointer(true);
- _builder.append(_selfPointer_17, " ");
- _builder.append("next);");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("}");
- _builder.newLine();
- _builder.append("\t ");
- _builder.newLine();
- _builder.append("//******************************************");
- _builder.newLine();
- _builder.append("// END of generated code for FSM");
- _builder.newLine();
- _builder.append("//******************************************");
- _builder.newLine();
- return _builder;
+ return _xblockexpression;
}
public StringConcatenation genExtra(final ExpandedActorClass xpac, final ActorClass ac) {
@@ -990,45 +1002,48 @@ public class GenericStateMachineGenerator {
return _builder;
}
- private StringConcatenation _guard(final TriggeredTransition tt, final String trigger, final ExpandedActorClass ac) {
- StringConcatenation _builder = new StringConcatenation();
- EList<Trigger> _triggers = tt.getTriggers();
- final Function1<Trigger,Boolean> _function = new Function1<Trigger,Boolean>() {
- public Boolean apply(final Trigger e) {
- boolean _isMatching = ac.isMatching(e, trigger);
- return ((Boolean)_isMatching);
- }
- };
- Trigger _findFirst = IterableExtensions.<Trigger>findFirst(_triggers, _function);
- Trigger tr = _findFirst;
- _builder.newLineIfNotEmpty();
+ private StringConcatenation _guard(final TriggeredTransition tt, final String trigger, final ExpandedActorClass ac, final DetailCodeTranslator dct) {
+ StringConcatenation _xblockexpression = null;
{
- boolean _hasGuard = this.roomExt.hasGuard(tr);
- if (_hasGuard) {
- _builder.append("if (");
- Guard _guard = tr.getGuard();
- DetailCode _guard_1 = _guard.getGuard();
- String _code = ac.getCode(_guard_1);
- _builder.append(_code, "");
- _builder.append(")");
- _builder.newLineIfNotEmpty();
+ EList<Trigger> _triggers = tt.getTriggers();
+ final Function1<Trigger,Boolean> _function = new Function1<Trigger,Boolean>() {
+ public Boolean apply(final Trigger e) {
+ boolean _isMatching = ac.isMatching(e, trigger);
+ return ((Boolean)_isMatching);
+ }
+ };
+ Trigger _findFirst = IterableExtensions.<Trigger>findFirst(_triggers, _function);
+ Trigger tr = _findFirst;
+ StringConcatenation _builder = new StringConcatenation();
+ {
+ boolean _hasGuard = this.roomExt.hasGuard(tr);
+ if (_hasGuard) {
+ _builder.append("if (");
+ Guard _guard = tr.getGuard();
+ DetailCode _guard_1 = _guard.getGuard();
+ String _translateDetailCode = dct.translateDetailCode(_guard_1);
+ _builder.append(_translateDetailCode, "");
+ _builder.append(")");
+ _builder.newLineIfNotEmpty();
+ }
}
+ _xblockexpression = (_builder);
}
- return _builder;
+ return _xblockexpression;
}
- private StringConcatenation _guard(final Transition t, final String trigger, final ExpandedActorClass ac) {
+ private StringConcatenation _guard(final Transition t, final String trigger, final ExpandedActorClass ac, final DetailCodeTranslator dct) {
StringConcatenation _builder = new StringConcatenation();
_builder.append("/* error */");
_builder.newLine();
return _builder;
}
- private StringConcatenation guard(final Transition tt, final String trigger, final ExpandedActorClass ac) {
+ private StringConcatenation guard(final Transition tt, final String trigger, final ExpandedActorClass ac, final DetailCodeTranslator dct) {
if (tt instanceof TriggeredTransition) {
- return _guard((TriggeredTransition)tt, trigger, ac);
+ return _guard((TriggeredTransition)tt, trigger, ac, dct);
} else {
- return _guard(tt, trigger, ac);
+ return _guard(tt, trigger, ac, dct);
}
}
}
diff --git a/plugins/org.eclipse.etrice.logging/build.properties b/plugins/org.eclipse.etrice.logging/build.properties
index 41eb6ade2..aed1551c5 100644
--- a/plugins/org.eclipse.etrice.logging/build.properties
+++ b/plugins/org.eclipse.etrice.logging/build.properties
@@ -1,4 +1,5 @@
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
- .
+ .,\
+ src/
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/etPort.c b/runtime/org.eclipse.etrice.runtime.c/src/etPort.c
index ce8c5045c..24f22043d 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/etPort.c
+++ b/runtime/org.eclipse.etrice.runtime.c/src/etPort.c
@@ -21,3 +21,10 @@ void etPort_receive(const etPort* self, const etMessage* msg) {
ET_MSC_LOGGER_SYNC_EXIT
}
+
+void etPort_sendMessage(const etPort* self, etInt16 evtId) {
+ etMessage* msg = etMessageService_getMessageBuffer(self->msgService, sizeof(etMessage));
+ msg->address = self->peerAddress;
+ msg->evtID = evtId;
+ etMessageService_pushMessage(self->msgService, msg);
+}
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/etPort.h b/runtime/org.eclipse.etrice.runtime.c/src/etPort.h
index 3e7bd617b..797adb9ad 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/etPort.h
+++ b/runtime/org.eclipse.etrice.runtime.c/src/etPort.h
@@ -33,10 +33,29 @@ typedef struct {
#endif
} etPort;
+typedef struct {
+ void* myActor;
+ etActorReceiveMessage receiveMessageFunc;
+ etMessageService* msgService;
+ etAddressId peerAddress;
+ etAddressId localId;
+ etAddressId index;
+
+ #ifdef etDEBUG
+ etAddressId address;
+ /* thread ID from msg service: msgService->threadId */
+ #endif
+} etReplSubPort;
+
+typedef struct {
+ etInt16 size;
+ const etReplSubPort* ports;
+} etReplPort;
+
typedef etPort* InterfaceItemBase;
void etPort_receive(const etPort* self, const etMessage* msg);
-
+void etPort_sendMessage(const etPort* self, etInt16 evtId);
diff --git a/tests/org.eclipse.etrice.generator.tests/src/org/eclipse/etrice/generator/base/TestDetailCodeTranslator.java b/tests/org.eclipse.etrice.generator.tests/src/org/eclipse/etrice/generator/base/TestDetailCodeTranslator.java
index 464f327e4..28d9cc2bf 100644
--- a/tests/org.eclipse.etrice.generator.tests/src/org/eclipse/etrice/generator/base/TestDetailCodeTranslator.java
+++ b/tests/org.eclipse.etrice.generator.tests/src/org/eclipse/etrice/generator/base/TestDetailCodeTranslator.java
@@ -40,7 +40,6 @@ import org.eclipse.etrice.core.room.StandardOperation;
import org.eclipse.etrice.core.room.VarDecl;
import org.eclipse.etrice.core.room.util.RoomHelpers;
import org.eclipse.etrice.generator.InstanceTestsActivator;
-import org.eclipse.etrice.generator.base.DetailCodeTranslator.ITranslationProvider;
import org.junit.Before;
import org.junit.Test;
@@ -100,6 +99,10 @@ public class TestDetailCodeTranslator {
public String translateTag(String tag, DetailCode code) {
return ">"+tag+"<";
}
+
+ @Override
+ public void setActorClass(ActorClass ac) {
+ }
}
private RoomModel model;

Back to the top