Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenrik Rentz-Reichert2012-02-20 04:32:09 -0500
committerHenrik Rentz-Reichert2012-02-20 04:32:09 -0500
commitc4a795f431f8ee844b48a56016a0a9ab02ad4dd3 (patch)
treec823dbf412cca7e9b207bb27078225df11c5d1a9
parent90088f94927e0583d8d00bc824e92addd72184bf (diff)
downloadorg.eclipse.etrice-c4a795f431f8ee844b48a56016a0a9ab02ad4dd3.tar.gz
org.eclipse.etrice-c4a795f431f8ee844b48a56016a0a9ab02ad4dd3.tar.xz
org.eclipse.etrice-c4a795f431f8ee844b48a56016a0a9ab02ad4dd3.zip
[generator, generator.c, generator.java, runtime.c, runtime.java] unified code generation for Java and C including state machine generation
-rw-r--r--plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/ActorClassGen.xtend157
-rw-r--r--plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/CExtensions.xtend53
-rw-r--r--plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/DataClassGen.xtend18
-rw-r--r--plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/ProtocolClassGen.xtend30
-rw-r--r--plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/StateMachineGen.xtend264
-rw-r--r--plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/SubSystemClassGen.xtend4
-rw-r--r--plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/ActorClassGen.java183
-rw-r--r--plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/CExtensions.java95
-rw-r--r--plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/DataClassGen.java30
-rw-r--r--plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/ProtocolClassGen.java100
-rw-r--r--plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/StateMachineGen.java866
-rw-r--r--plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/SubSystemClassGen.java5
-rw-r--r--plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/ActorClassGen.xtend34
-rw-r--r--plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/DataClassGen.xtend10
-rw-r--r--plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/JavaExtensions.xtend34
-rw-r--r--plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/ProtocolClassGen.xtend31
-rw-r--r--plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/StateMachineGen.xtend232
-rw-r--r--plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/SubSystemClassGen.xtend4
-rw-r--r--plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/ActorClassGen.java195
-rw-r--r--plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/DataClassGen.java30
-rw-r--r--plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/JavaExtensions.java56
-rw-r--r--plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/ProtocolClassGen.java115
-rw-r--r--plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/StateMachineGen.java819
-rw-r--r--plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/SubSystemClassGen.java8
-rw-r--r--plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/extensions/RoomExtensions.xtend49
-rw-r--r--plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/GenericActorClassGenerator.xtend49
-rw-r--r--plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/GenericProtocolClassGenerator.xtend74
-rw-r--r--plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/GenericStateMachineGenerator.xtend277
-rw-r--r--plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/ILanguageExtension.java78
-rw-r--r--plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/ProcedureHelpers.xtend59
-rw-r--r--plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/extensions/RoomExtensions.java109
-rw-r--r--plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/ProcedureHelpers.java84
-rw-r--r--runtime/org.eclipse.etrice.modellib/models/TimingService.room2
-rw-r--r--runtime/org.eclipse.etrice.modellib/src-gen/room/basic/service/timing/ATimingService.java199
-rw-r--r--runtime/org.eclipse.etrice.modellib/src-gen/room/basic/service/timing/PTimeout.java19
-rw-r--r--runtime/org.eclipse.etrice.modellib/src-gen/room/basic/service/timing/PTimer.java19
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/Debug/liborg.eclipse.etrice.runtime.c.abin129984 -> 144124 bytes
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/etActor.c18
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/etActor.h24
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/etDatatypes.h1
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/etMessageReceiver.h2
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/etPort.h2
-rw-r--r--runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/ActorClassBase.java2
-rw-r--r--tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/ChoicePointTest/CPTest_Top.java2
-rw-r--r--tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/ChoicePointTest/CPTester.java131
-rw-r--r--tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/ChoicePointTest/CPUser.java439
-rw-r--r--tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/ChoicePointTest/TestProtocol.java9
-rw-r--r--tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/HandlerTest/HandlerTest_Top.java2
-rw-r--r--tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/HandlerTest/HandlerUser.java881
-rw-r--r--tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/HandlerTest/TestProtocol.java9
-rw-r--r--tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/HandlerTest/Tester.java157
-rw-r--r--tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/PingPongThreadTest/MrPingActor.java203
-rw-r--r--tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/PingPongThreadTest/MrPongActor1.java121
-rw-r--r--tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/PingPongThreadTest/MrPongActor2.java133
-rw-r--r--tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/PingPongThreadTest/PingPongProtocol.java9
-rw-r--r--tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/PingPongThreadTest/PingPongTop.java2
-rw-r--r--tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/PingPongThreadTestReplPort/MrPingActor.java197
-rw-r--r--tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/PingPongThreadTestReplPort/MrPongActor1.java121
-rw-r--r--tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/PingPongThreadTestReplPort/PingPongProtocol.java9
-rw-r--r--tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/PingPongThreadTestReplPort/PingPongTop.java2
-rw-r--r--tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/SendingDataByValueTest/MrPing.java588
-rw-r--r--tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/SendingDataByValueTest/MrPong.java147
-rw-r--r--tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/SendingDataByValueTest/PingPongProtocol.java9
-rw-r--r--tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/SendingDataByValueTest/SendingDataTop.java2
-rw-r--r--tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/tests/App_SubSystemHFSMTest.java2
-rw-r--r--tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/tests/a_HFSM.java603
-rw-r--r--tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/tests/a_HFSM_Tester.java315
-rw-r--r--tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/tests/a_HFSM_Tests.java2
-rw-r--r--tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/tests/p_HFSM.java9
-rw-r--r--tests/org.eclipse.etrice.runtime.java.tests/src/org/eclipse/etrice/runtime/java/modelbase/ActorClassBaseTest.java1
-rw-r--r--tests/org.eclipse.etrice.runtime.java.tests/src/org/eclipse/etrice/runtime/java/modelbase/PortBaseTest.java5
71 files changed, 3451 insertions, 5099 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 d94aa703b..8dcd831d5 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
@@ -16,7 +16,6 @@ package org.eclipse.etrice.generator.c.gen
import com.google.inject.Inject
import com.google.inject.Singleton
import org.eclipse.etrice.core.room.ActorClass
-import org.eclipse.etrice.core.room.Message
import org.eclipse.etrice.generator.base.ILogger
import org.eclipse.etrice.generator.etricegen.ExpandedActorClass
import org.eclipse.etrice.generator.etricegen.Root
@@ -25,10 +24,11 @@ import org.eclipse.xtext.generator.JavaIoFileSystemAccess
import org.eclipse.etrice.generator.extensions.RoomExtensions
import org.eclipse.etrice.generator.generic.ProcedureHelpers
import org.eclipse.etrice.generator.generic.TypeHelpers
+import org.eclipse.etrice.generator.generic.GenericActorClassGenerator
@Singleton
-class ActorClassGen {
+class ActorClassGen extends GenericActorClassGenerator {
@Inject extension JavaIoFileSystemAccess fileAccess
@Inject extension CExtensions stdExt
@@ -49,8 +49,11 @@ class ActorClassGen {
fileAccess.generateFile(xpac.actorClass.getCHeaderFileName, root.generateHeaderFile(xpac, xpac.actorClass))
// source file
- if(hasBehaviorAnnotation(xpac, "BehaviorManual") == false){
- logger.logInfo("generating ActorClass header '"+xpac.actorClass.getCSourceFileName +"' in '"+path+"'")
+ if (hasBehaviorAnnotation(xpac, "BehaviorManual")) {
+ logger.logInfo("omitting ActorClass source for '"+xpac.actorClass.name+"' since @BehaviorManual is specified")
+ }
+ else {
+ logger.logInfo("generating ActorClass source '"+xpac.actorClass.getCSourceFileName +"' in '"+path+"'")
fileAccess.setOutputPath(path)
fileAccess.generateFile(xpac.actorClass.getCSourceFileName , root.generateSourceFile(xpac, xpac.actorClass))
}
@@ -77,14 +80,14 @@ class ActorClassGen {
«generateIncludeGuardBegin(xpac.name)»
#include "etDatatypes.h"
-
- «FOR dataClass : root.getReferencedDataClasses(ac)»#include "«dataClass.name».h"
+ «FOR dataClass : root.getReferencedDataClasses(ac)»
+ #include "«dataClass.name».h"
«ENDFOR»
-
- «FOR pc : root.getReferencedProtocolClasses(ac)»#include "«pc.name».h"
+ «FOR pc : root.getReferencedProtocolClasses(ac)»
+ #include "«pc.name».h"
«ENDFOR»
- «helpers.UserCode(ac.userCode1)»
+ «helpers.userCode(ac.userCode1)»
typedef struct «xpac.name» «xpac.name»;
@@ -95,112 +98,21 @@ class ActorClassGen {
«FOR ep : ac.getEndPorts()»
const «ep.getPortClassName()» «ep.name»;
«ENDFOR»
-
} «xpac.name»_const;
/* variable part of ActorClass (RAM) */
struct «xpac.name» {
const «xpac.name»_const* constData;
+ «IF xpac.stateMachine!=null»
+ «stateMachineGen.genDataMembers(xpac, ac)»
+ «ENDIF»
};
void «xpac.name»_init(«xpac.name»* self);
- void «xpac.name»_ReceiveMessage(void* self, etInt16 localId, const etMessage* msg);
+ void «xpac.name»_ReceiveMessage(void* self, void* ifitem, const etMessage* msg);
-
-««« public «IF ac.abstract»abstract «ENDIF»class «ac.name» extends «IF ac.base!=null»«ac.base.name»«ELSE»ActorClassBase«ENDIF» {
-«««
-«««
-««« //--------------------- ports
-««« «FOR ep : ac.getEndPorts()»
-««« protected «ep.getPortClassName()» «ep.name» = null;
-««« «ENDFOR»
-««« //--------------------- saps
-««« «FOR sap : ac.strSAPs»
-««« protected «sap.getPortClassName()» «sap.name» = null;
-««« «ENDFOR»
-««« //--------------------- services
-««« «FOR svc : ac.serviceImplementations»
-««« protected «svc.getPortClassName()» «svc.spp.name» = null;
-««« «ENDFOR»
-«««
-««« //--------------------- interface item IDs
-««« «FOR ep : ac.getEndPorts()»
-««« protected static final int IFITEM_«ep.name» = «xpac.getInterfaceItemLocalId(ep)+1»;
-««« «ENDFOR»
-««« «FOR sap : ac.strSAPs»
-««« protected static final int IFITEM_«sap.name» = «xpac.getInterfaceItemLocalId(sap)+1»;
-««« «ENDFOR»
-««« «FOR svc : ac.serviceImplementations»
-««« protected static final int IFITEM_«svc.spp.name» = «xpac.getInterfaceItemLocalId(svc.spp)+1»;
-««« «ENDFOR»
-«««
-««« «helpers.Attributes(ac.attributes)»
-««« «helpers.OperationsDeclaration(ac.operations, ac.name)»
-«««
-««« //--------------------- construction
-««« public «ac.name»(IRTObject parent, String name, Address[][] port_addr, Address[][] peer_addr){
-««« «IF ac.base==null»
-««« super(parent, name, port_addr[0][0], peer_addr[0][0]);
-««« «ELSE»
-««« super(parent, name, port_addr, peer_addr);
-««« «ENDIF»
-««« setClassName("«ac.name»");
-«««
-««« «ac.attributes.attributeInitialization»
-«««
-««« // own ports
-««« «FOR ep : ac.getEndPorts()»
-««« «ep.name» = new «ep.getPortClassName()»(this, "«ep.name»", IFITEM_«ep.name», «IF ep.multiplicity==1»0, «ENDIF»port_addr[IFITEM_«ep.name»]«IF ep.multiplicity==1»[0]«ENDIF», peer_addr[IFITEM_«ep.name»]«IF ep.multiplicity==1»[0]«ENDIF»);
-««« «ENDFOR»
-««« // own saps
-««« «FOR sap : ac.strSAPs»
-««« «sap.name» = new «sap.getPortClassName()»(this, "«sap.name»", IFITEM_«sap.name», 0, port_addr[IFITEM_«sap.name»][0], peer_addr[IFITEM_«sap.name»][0]);
-««« «ENDFOR»
-««« // own service implementations
-««« «FOR svc : ac.serviceImplementations»
-««« «svc.spp.name» = new «svc.getPortClassName()»(this, "«svc.spp.name»", IFITEM_«svc.spp.name», port_addr[IFITEM_«svc.spp.name»], peer_addr[IFITEM_«svc.spp.name»]);
-««« «ENDFOR»
-««« }
-«««
-«««
-««« //--------------------- lifecycle functions
-««« public void init(){
-««« initUser();
-««« }
-«««
-««« public void start(){
-««« startUser();
-««« }
-«««
-««« «IF !ac.overridesStop()»
-««« public void stop(){
-««« stopUser();
-««« }
-««« «ENDIF»
-«««
-««« public void destroy(){
-««« destroyUser();
-««« }
-«««
-«««
-«««
-««« «IF ac.stateMachine != null»
-««« «stateMachineGen.genStateMachine(xpac, ac)»
-««« «ELSEIF !xpac.hasStateMachine()»
-««« //--------------------- no state machine
-««« @Override
-««« public void receiveEvent(InterfaceItemBase ifitem, int evt, Object data) {
-««« handleSystemEvent(ifitem, evt, data);
-««« }
-«««
-««« @Override
-««« public void executeInitTransition(){
-««« }
-««« «ENDIF»
-««« };
-
- «helpers.UserCode(ac.userCode2)»
+ «helpers.userCode(ac.userCode2)»
«generateIncludeGuardEnd(xpac.name)»
@@ -217,30 +129,39 @@ class ActorClassGen {
#include "«xpac.getCHeaderFileName»"
+ #include "etActor.h"
#include "etLogger.h"
-
#include "etMSCLogger.h"
+
+ «FOR pc : root.getReferencedProtocolClasses(ac)»
+ #include "«pc.getCHeaderFileName»"
+ «ENDFOR»
- «helpers.UserCode(xpac.userCode3)»
+ «helpers.userCode(xpac.userCode3)»
+
+ /* interface item IDs */
+ «genInterfaceItemConstants(xpac, ac)»
+
+ «IF xpac.stateMachine != null»
+ «stateMachineGen.genStateMachine(xpac, ac)»
+ «ENDIF»
void «xpac.name»_init(«xpac.name»* self){
ET_MSC_LOGGER_SYNC_ENTRY("«xpac.name»", "init")
- «FOR port : xpac.actorClass.endPorts.filter(e|e.conjugated)»
- «FOR message : port.protocol.incomingMessages»
- «port.getPortClassName()»_«message.name»(&self->constData->«port.name»);
- «ENDFOR»
- «ENDFOR»
- «FOR port : xpac.actorClass.endPorts.filter(e| !e.conjugated)»
- «FOR message : port.protocol.outgoingMessages»
- «port.getPortClassName()»_«message.name»(&self->constData->«port.name»);
- «ENDFOR»
- «ENDFOR»
+ «IF xpac.stateMachine != null»
+ «stateMachineGen.genInitialization(xpac, ac)»
+ «ENDIF»
ET_MSC_LOGGER_SYNC_EXIT
}
- void «xpac.name»_ReceiveMessage(void* self, etInt16 localId, const etMessage* msg){
+ void «xpac.name»_ReceiveMessage(void* self, void* ifitem, const etMessage* msg){
ET_MSC_LOGGER_SYNC_ENTRY("«xpac.name»", "ReceiveMessage")
+ «IF xpac.stateMachine != null»
+
+ receiveEvent(self, (etPort*)ifitem, msg->evtID, (void*)(&msg[1]));
+ «ENDIF»
+
ET_MSC_LOGGER_SYNC_EXIT
}
diff --git a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/CExtensions.xtend b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/CExtensions.xtend
index 921c79d4f..f6c264741 100644
--- a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/CExtensions.xtend
+++ b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/CExtensions.xtend
@@ -26,6 +26,8 @@ import org.eclipse.etrice.generator.etricegen.ExpandedActorClass
import org.eclipse.etrice.generator.etricegen.TransitionChain
import org.eclipse.etrice.generator.generic.ILanguageExtension
import org.eclipse.etrice.generator.generic.LanguageGenerator
+import java.util.List
+import org.eclipse.xtext.util.Pair
@@ -40,34 +42,32 @@ class CExtensions implements ILanguageExtension {
}
// in C no access levels can be defined
- override String accessLevelPrivate(){""}
- override String accessLevelProtected(){""}
+ override String accessLevelPrivate(){"static "}
+ override String accessLevelProtected(){"static "}
override String accessLevelPublic(){""}
override String memberAccess(){"self->"}
- override String selfPointer(String classname, int argumentCount){
- if (argumentCount>0){
- classname+"* self, "
- }
- else {
- classname+"* self"
- }
+ override String selfPointer(String classname, boolean hasArgs){
+ classname+
+ if (hasArgs)
+ "* self, "
+ else
+ "* self"
}
+
+ override String selfPointer(boolean hasArgs) { if (hasArgs) "self, " else "self" }
override String operationScope(String classname, boolean isDeclaration){classname+"_"}
- /* TODO: unify OUT and in an add for loop (also for Java) */
- override String outMessageId(String classname, String messagename){
- return classname+"_OUT_"+messagename;
+ override String memberInDeclaration(String namespace, String member) {
+ return namespace+"_"+member
}
- override String inMessageId(String classname, String messagename){
- return classname+"_IN_"+messagename;
+ override String memberInUse(String namespace, String member) {
+ return namespace+"_"+member
}
-
-
//**** C-Specific
/* TODO: move specific code elsewhere */
// used
@@ -102,7 +102,28 @@ class CExtensions implements ILanguageExtension {
#endif /* «filename.getIncludeGuardString» */
'''
}
+
+ override boolean usesInheritance() {
+ return false
+ }
+
+ override String genEnumeration(String name, List<Pair<String, String>> entries) {
+ '''
+ enum «name» {
+ «FOR entry: entries SEPARATOR ","»
+ «entry.first» = «entry.second»
+ «ENDFOR»
+ };
+ '''.toString
+ }
+ override String booleanConstant(boolean b) {
+ if (b) "TRUE" else "FALSE"
+ }
+
+ override String nullPointer() { "NULL" }
+ override String voidPointer() { "void*" }
+
//-------------------------------------------------------
// transition chain visitor
diff --git a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/DataClassGen.xtend b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/DataClassGen.xtend
index 3cb344415..9799a6883 100644
--- a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/DataClassGen.xtend
+++ b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/DataClassGen.xtend
@@ -61,21 +61,21 @@ class DataClassGen {
#include "etDatatypes.h"
- /* TODO: includes only for used DataClasses, also for other models */
+««« TODO: includes only for used DataClasses, also for other models
«FOR dataClass : root.getReferencedDataClasses(dc)»
#include "«dataClass.name».h"
«ENDFOR»
- «helpers.UserCode(dc.userCode1)»
+ «helpers.userCode(dc.userCode1)»
typedef struct {
- «helpers.UserCode(dc.userCode2)»
- «helpers.Attributes(dc.attributes)»
+ «helpers.userCode(dc.userCode2)»
+ «helpers.attributes(dc.attributes)»
} «dc.name»«IF dc.base!=null» /* extends -> inheritance not implemented yet */ «dc.base.name»«ENDIF»;
- // TODO: do we need setters and getters for C and C++ ?
+««« TODO: do we need setters and getters for C and C++ ?
- «helpers.OperationsDeclaration(dc.operations, dc.name)»
+ «helpers.operationsDeclaration(dc.operations, dc.name)»
// deep copy
void «dc.name»_deepCopy(«dc.name»* source, «dc.name»* target);
@@ -97,11 +97,11 @@ class DataClassGen {
#include <string.h>
- «helpers.UserCode(dc.userCode3)»
+ «helpers.userCode(dc.userCode3)»
- // TODO: do we need setters and getters for C and C++ ?
+««« TODO: do we need setters and getters for C and C++ ?
- «helpers.OperationsImplementation(dc.operations, dc.name)»
+ «helpers.operationsImplementation(dc.operations, dc.name)»
// deep copy
void «dc.name»_deepCopy(«dc.name»* source, «dc.name»* target) {
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 318ff490e..45e65d5a1 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
@@ -23,10 +23,11 @@ import org.eclipse.xtext.generator.JavaIoFileSystemAccess
import org.eclipse.etrice.generator.extensions.RoomExtensions
import org.eclipse.etrice.generator.generic.ProcedureHelpers
+import org.eclipse.etrice.generator.generic.GenericProtocolClassGenerator
@Singleton
-class ProtocolClassGen {
+class ProtocolClassGen extends GenericProtocolClassGenerator {
@Inject extension JavaIoFileSystemAccess fileAccess
@Inject extension CExtensions stdExt
@@ -63,25 +64,14 @@ class ProtocolClassGen {
#include "etDatatypes.h"
#include "etPort.h"
- «helpers.UserCode(pc.userCode1)»
+ «helpers.userCode(pc.userCode1)»
- «FOR dataClass : root.getReferencedDataClasses(pc)»#include "«dataClass.name».h"
+ «FOR dataClass : root.getReferencedDataClasses(pc)»
+ #include "«dataClass.name».h"
«ENDFOR»
/* message IDs */
- enum {
- «pc.name»_MSG_MIN = 0,
- /* IDs for outgoing messages */
- «FOR message : pc.getAllOutgoingMessages()»
- «outMessageId(pc.name, message.name)» = «pc.getAllOutgoingMessages().indexOf(message)+1»,
- «ENDFOR»
- /* IDs for incoming messages */
- «FOR message : pc.getAllIncomingMessages()»
- «inMessageId(pc.name, message.name)» = «pc.getAllIncomingMessages().indexOf(message)+pc.getAllOutgoingMessages().size+1»,
- «ENDFOR»
- /* error if msgID >= MSG_MAX */
- «pc.name»_MSG_MAX = «pc.getAllOutgoingMessages().size + pc.getAllIncomingMessages().size+1»
- };
+ «genMessageIDs(pc)»
/*--------------------- port classes */
«portClassHeader(pc, false)»
@@ -94,7 +84,7 @@ class ProtocolClassGen {
/* get message string for message id */
const char* «pc.name»_getMessageString(int msg_id);
- «helpers.UserCode(pc.userCode2)»
+ «helpers.userCode(pc.userCode2)»
«generateIncludeGuardEnd(pc.name)»
@@ -280,7 +270,7 @@ class ProtocolClassGen {
ET_MSC_LOGGER_SYNC_ENTRY("«portClassName»", "«message.name»")
etMessage* msg = etMessageService_getMessageBuffer(self->msgService, sizeof(etMessage));
msg->address = self->peerAddress;
- msg->evtID = «outMessageId(pc.name, message.name)»;
+ msg->evtID = «memberInUse(pc.name, "OUT_"+message.name)»;
etMessageService_pushMessage(self->msgService, msg);
ET_MSC_LOGGER_SYNC_EXIT
}
@@ -292,7 +282,7 @@ class ProtocolClassGen {
ET_MSC_LOGGER_SYNC_ENTRY("«portClassName»", "«message.name»")
etMessage* msg = etMessageService_getMessageBuffer(self->msgService, sizeof(etMessage));
msg->address = self->peerAddress;
- msg->evtID = «inMessageId(pc.name, message.name)»;
+ msg->evtID = «memberInUse(pc.name, "IN_"+message.name)»;
etMessageService_pushMessage(self->msgService, msg);
ET_MSC_LOGGER_SYNC_EXIT
}
@@ -327,7 +317,7 @@ class ProtocolClassGen {
def generateDebugHelpersImplementation(Root root, ProtocolClass pc){'''
- /* TODO: make this optional or different for smaller footprint */
+««« TODO: make this optional or different for smaller footprint
/* message names as strings for debugging (generate MSC) */
static const char* «pc.name»_messageStrings[] = {"MIN", «FOR m : pc.getAllOutgoingMessages()»"«m.name»",«ENDFOR»«FOR m : pc.getAllIncomingMessages()»"«m.name»", «ENDFOR»"MAX"};
diff --git a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/StateMachineGen.xtend b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/StateMachineGen.xtend
index d5d802277..4cae655ad 100644
--- a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/StateMachineGen.xtend
+++ b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/StateMachineGen.xtend
@@ -10,249 +10,41 @@
*
*******************************************************************************/
-package org.eclipse.etrice.generator.c.gen
-
-import com.google.inject.Inject
-import com.google.inject.Singleton
-import java.util.List
-import org.eclipse.etrice.core.room.ActorClass
-import org.eclipse.etrice.core.room.NonInitialTransition
-import org.eclipse.etrice.core.room.Transition
-import org.eclipse.etrice.core.room.TriggeredTransition
-import org.eclipse.etrice.generator.etricegen.ExpandedActorClass
-import org.eclipse.etrice.generator.etricegen.TransitionChain
-import static extension org.eclipse.etrice.generator.extensions.RoomNameProv.*
-import org.eclipse.etrice.generator.extensions.RoomExtensions
-import org.eclipse.etrice.generator.generic.LanguageGenerator
-
+package org.eclipse.etrice.generator.c.gen
+
+import com.google.inject.Inject
+import com.google.inject.Singleton
+import org.eclipse.etrice.core.room.ActorClass
+import org.eclipse.etrice.generator.etricegen.ExpandedActorClass
+import org.eclipse.etrice.generator.extensions.RoomExtensions
+import org.eclipse.etrice.generator.generic.GenericStateMachineGenerator
@Singleton
-class StateMachineGen {
+class StateMachineGen extends GenericStateMachineGenerator {
- @Inject extension CExtensions stdExt
- @Inject extension RoomExtensions roomExt
- @Inject LanguageGenerator languageGen
+ @Inject extension RoomExtensions
- def genStateMachine(ExpandedActorClass xpac, ActorClass ac) {'''
- //******************************************
- // START of generated code for FSM
- //******************************************
-
- // State IDs for FSM
- «var offset = ac.getNumberOfInheritedBaseStates()»
- «var baseStates = ac.stateMachine.getBaseStateList()»
- «FOR state : baseStates»
- protected static final int «state.getStateId()» = «baseStates.indexOf(state)+2+offset»;
- «ENDFOR»
- protected static final String stateStrings[] = {"<no state>","<top>",«FOR state : ac.getAllBaseStates() SEPARATOR ","»"«state.getStatePathName()»"
- «ENDFOR»};
-
- // history
- // TODOHRR: history defined in ActorClassBase, init in constructor
- // history = new int[5];
- // for (int i = 0; i < history.length; i++) {
- // history[i] = NO_STATE;
- // }
- protected int history[] = {NO_STATE,NO_STATE«FOR state : ac.getAllBaseStates()»,NO_STATE«ENDFOR»};
-
- «var List<TransitionChain> chains = xpac.getOwnTransitionChains()»
- «var offset_tc = xpac.getTransitionChains().size-chains.size»
- // transition chains
- «FOR tc : chains»
- protected static final int «tc.getChainId()» = «chains.indexOf(tc)+1+offset_tc»;
- «ENDFOR»
-
- «var triggers = xpac.getOwnTriggers()»
- // triggers for FSM
- «FOR mif : triggers»protected static final int «xpac.getTriggerCodeName(mif)» = IFITEM_«mif.from.name» + EVT_SHIFT*«xpac.getMessageID(mif)»;
- «ENDFOR»
-
- // receiveEvent contains the main implementation of the FSM
- @Override
- public void receiveEvent(InterfaceItemBase ifitem, int evt, Object generic_data) {
- int trigger = ifitem.getLocalId() + EVT_SHIFT*evt;
- int chain = NOT_CAUGHT;
- int catching_state = NO_STATE;
- boolean is_handler = false;
- boolean skip_entry = false;
-
- if (!handleSystemEvent(ifitem, evt, generic_data)) {
- switch (state) {
- «FOR state : xpac.stateMachine.getLeafStateList()»
- case «state.getStateId()»:
- «var atlist = xpac.getActiveTriggers(state)»
- «IF !atlist.isEmpty»
- switch(trigger) {
- «FOR at : atlist»
- case «xpac.getTriggerCodeName(at.trigger)»:
- «var needData = xpac.hasGuard(at)»
- «IF needData»{ «at.msg.getTypedDataDefinition()»«ENDIF»
- «FOR tt : at.transitions SEPARATOR " else "»
- «var chain = xpac.getChain(tt)»
- «guard(chain.transition, at.trigger, xpac)»
- {
- chain = «chain.getChainId()»;
- catching_state = «chain.getContextId()»;
- «IF chain.isHandler()»is_handler = true;«ENDIF»
- «IF chain.skipEntry»skip_entry = true;«ENDIF»
- }
- «ENDFOR»
- «IF needData»}«ENDIF»
- break;
- «ENDFOR»
- }
- «ENDIF»
- break;
- «ENDFOR»
- }
- }
- if (chain != NOT_CAUGHT) {
- exitTo(state, catching_state, is_handler);
- int next = executeTransitionChain(chain, ifitem, generic_data);
- next = enterHistory(next, is_handler, skip_entry);
- setState(next);
- }
- }
-
- private void setState(int new_state) {
- DebuggingService.getInstance().addActorState(this,stateStrings[new_state]);
- if (stateStrings[new_state]!="Idle") {
- // TODOTS: model switch for activation
- System.out.println(getInstancePath() + " -> " + stateStrings[new_state]);
- }
- this.state = new_state;
- }
-
- @Override
- public void executeInitTransition() {
- «var initt = xpac.stateMachine.getInitTransition()»
- int chain = «xpac.getChain(initt).getChainId()»;
- int next = executeTransitionChain(chain, null, null);
- next = enterHistory(next, false, false);
- setState(next);
- }
-
- /**
- * calls exit codes while exiting from the current state to one of its
- * parent states while remembering the history
- * @param current - the current state
- * @param to - the final parent state
- * @param handler - entry and exit codes are called only if not handler (for handler TransitionPoints)
- */
- private void exitTo(int current, int to, boolean handler) {
- while (current!=to) {
- switch (current) {
- «FOR state : xpac.stateMachine.getBaseStateList()»
- case «state.getStateId()»:
- «IF state.hasExitCode()»if (!handler) «state.getExitCodeOperationName()»();«ENDIF»
- history[«state.getParentStateId()»] = «state.getStateId()»;
- current = «state.getParentStateId()»;
- break;
- «ENDFOR»
- }
- }
- }
- /**
- * calls action, entry and exit codes along a transition chain. The generic data are cast to typed data
- * matching the trigger of this chain. The ID of the final state is returned
- * @param chain - the chain ID
- * @param generic_data - the generic data pointer
- * @return the ID of the final state
- */
- private int executeTransitionChain(int chain, InterfaceItemBase ifitem, Object generic_data) {
- switch (chain) {
- «var allchains = xpac.getTransitionChains()»
- «FOR tc : allchains»
- case «tc.getChainId()»:
- {
- «xpac.getExecuteChainCode(tc)»
- }
- «ENDFOR»
- }
- return NO_STATE;
- }
- /**
- * calls entry codes while entering a state's history. The ID of the final leaf state is returned
- * @param state - the state which is entered
- * @param handler - entry code is executed if not handler
- * @return - the ID of the final leaf state
- */
- private int enterHistory(int state, boolean handler, boolean skip_entry) {
- while (true) {
- switch (state) {
- «FOR state : xpac.stateMachine.getBaseStateList()»
- case «state.getStateId()»:
- «IF state.hasEntryCode()»if (!(skip_entry || handler)) «state.getEntryCodeOperationName()»();«ENDIF»
- «IF state.isLeaf()»
- // in leaf state: return state id
- return «state.getStateId()»;
- «ELSE»
- // state has a sub graph
- «IF state.subgraph.hasInitTransition()»
- // with init transition
- if (history[«state.getStateId()»]==NO_STATE) {
- «var sub_initt = state.subgraph.getInitTransition()»
- state = executeTransitionChain(«xpac.getChain(sub_initt).getChainId()», null, null);
- }
- else {
- state = history[«state.getStateId()»];
- }
- «ELSE»
- // without init transition
- state = history[«state.getStateId()»];
- «ENDIF»
- break;
- «ENDIF»
- «ENDFOR»
- case STATE_TOP:
- state = history[STATE_TOP];
- break;
- }
- skip_entry = false;
- }
- //return NO_STATE; // required by CDT but detected as unreachable by JDT because of while (true)
+ def genDataMembers(ExpandedActorClass xpac, ActorClass ac) {'''
+ /* state machine variables */
+ etInt16 state;
+ etInt16 history[«xpac.allLeafStates.size»];
+ '''}
+
+ def genInitialization(ExpandedActorClass xpac, ActorClass ac) {'''
+ self->state = STATE_TOP;
+ {
+ int i;
+ for (i=0; i<«xpac.allLeafStates.size»; ++i)
+ self->history[i] = NO_STATE;
}
-
- //*** Entry and Exit Codes
- «FOR state : xpac.stateMachine.getStateList()»
- «IF xpac.isOwnObject(state)»
- «IF state.hasEntryCode()»
- protected void «state.getEntryCodeOperationName()»() {
- «xpac.getEntryCode(state)»
- }
- «ENDIF»
- «IF state.hasExitCode()»
- protected void «state.getExitCodeOperationName()»() {
- «xpac.getExitCode(state)»
- }
- «ENDIF»
- «ENDIF»
- «ENDFOR»
-
- //*** Action Codes
- «FOR tr : xpac.stateMachine.getTransitionList()»
- «IF xpac.isOwnObject(tr) && tr.hasActionCode()»
- protected void «tr.getActionCodeOperationName()»(«IF tr instanceof NonInitialTransition»InterfaceItemBase ifitem«languageGen.getArgumentList(xpac, tr)»«ENDIF») {
- «xpac.getActionCode(tr)»
- }
- «ENDIF»
- «ENDFOR»
-
- //******************************************
- // END of generated code for FSM
- //******************************************
+ executeInitTransition(self);
'''}
-
- def dispatch guard(TriggeredTransition tt, String trigger, ExpandedActorClass ac) {'''
- «var tr = tt.triggers.findFirst(e|ac.isMatching(e, trigger))»
- «IF tr.hasGuard()»
- if («ac.getCode(tr.guard.guard)»)
- «ENDIF»
- '''
- }
+
+ override genExtra(ExpandedActorClass xpac, ActorClass ac) {'''
- def dispatch guard(Transition t, String trigger, ExpandedActorClass ac) {'''
- /* error */
+ «langExt.accessLevelPrivate»void setState(«ac.name»* self, int new_state) {
+ self->state = new_state;
+ }
'''
}
}
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 bdff5037b..1f9252755 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
@@ -189,7 +189,7 @@ class SubSystemClassGen {
/* include all used ActorClasses */
- /* TODO: only include used Actor Classes for current SubSystem */
+««« TODO: only include used Actor Classes for current SubSystem
«FOR actorClass : root.getUsedActorClasses()»#include "«actorClass.name».h"
«ENDFOR»
@@ -212,7 +212,7 @@ class SubSystemClassGen {
&«ai.path.getPathName()»,
/* Ports: {myActor, etReceiveMessage, msgService, peerAddress, localId} */
«FOR pi : ai.ports»
- /* TODO: not robust if not connected and not implemented for replication */
+««« TODO: not robust if not connected and not implemented for replication
{&«ai.path.getPathName()», «ai.actorClass.name»_ReceiveMessage, &msgService_Thread1, «pi.peers.get(0).objId», 123} /* Port «pi.name» */
«ENDFOR»
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 dd8db7d10..b9af2e5e1 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
@@ -9,19 +9,19 @@ import org.eclipse.etrice.core.room.ActorClass;
import org.eclipse.etrice.core.room.Annotation;
import org.eclipse.etrice.core.room.DataClass;
import org.eclipse.etrice.core.room.DetailCode;
-import org.eclipse.etrice.core.room.Message;
import org.eclipse.etrice.core.room.Port;
import org.eclipse.etrice.core.room.ProtocolClass;
+import org.eclipse.etrice.core.room.StateGraph;
import org.eclipse.etrice.generator.base.ILogger;
import org.eclipse.etrice.generator.c.gen.CExtensions;
import org.eclipse.etrice.generator.c.gen.StateMachineGen;
import org.eclipse.etrice.generator.etricegen.ExpandedActorClass;
import org.eclipse.etrice.generator.etricegen.Root;
import org.eclipse.etrice.generator.extensions.RoomExtensions;
+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;
@@ -30,7 +30,7 @@ import org.eclipse.xtext.xtend2.lib.StringConcatenation;
@SuppressWarnings("all")
@Singleton
-public class ActorClassGen {
+public class ActorClassGen extends GenericActorClassGenerator {
@Inject
private JavaIoFileSystemAccess fileAccess;
@@ -76,21 +76,26 @@ public class ActorClassGen {
StringConcatenation _generateHeaderFile = this.generateHeaderFile(root, xpac, _actorClass_4);
this.fileAccess.generateFile(_cHeaderFileName_1, _generateHeaderFile);
boolean _hasBehaviorAnnotation = this.hasBehaviorAnnotation(xpac, "BehaviorManual");
- boolean _operator_equals = ObjectExtensions.operator_equals(((Boolean)_hasBehaviorAnnotation), ((Boolean)false));
- if (_operator_equals) {
+ if (_hasBehaviorAnnotation) {
+ ActorClass _actorClass_5 = xpac.getActorClass();
+ String _name = _actorClass_5.getName();
+ String _operator_plus_5 = StringExtensions.operator_plus("omitting ActorClass source for \'", _name);
+ String _operator_plus_6 = StringExtensions.operator_plus(_operator_plus_5, "\' since @BehaviorManual is specified");
+ this.logger.logInfo(_operator_plus_6);
+ } else {
{
- ActorClass _actorClass_5 = xpac.getActorClass();
- String _cSourceFileName = this.stdExt.getCSourceFileName(_actorClass_5);
- String _operator_plus_5 = StringExtensions.operator_plus("generating ActorClass header \'", _cSourceFileName);
- String _operator_plus_6 = StringExtensions.operator_plus(_operator_plus_5, "\' in \'");
- String _operator_plus_7 = StringExtensions.operator_plus(_operator_plus_6, path);
- String _operator_plus_8 = StringExtensions.operator_plus(_operator_plus_7, "\'");
- this.logger.logInfo(_operator_plus_8);
- this.fileAccess.setOutputPath(path);
ActorClass _actorClass_6 = xpac.getActorClass();
- String _cSourceFileName_1 = this.stdExt.getCSourceFileName(_actorClass_6);
+ String _cSourceFileName = this.stdExt.getCSourceFileName(_actorClass_6);
+ String _operator_plus_7 = StringExtensions.operator_plus("generating ActorClass source \'", _cSourceFileName);
+ String _operator_plus_8 = StringExtensions.operator_plus(_operator_plus_7, "\' in \'");
+ String _operator_plus_9 = StringExtensions.operator_plus(_operator_plus_8, path);
+ String _operator_plus_10 = StringExtensions.operator_plus(_operator_plus_9, "\'");
+ this.logger.logInfo(_operator_plus_10);
+ this.fileAccess.setOutputPath(path);
ActorClass _actorClass_7 = xpac.getActorClass();
- StringConcatenation _generateSourceFile = this.generateSourceFile(root, xpac, _actorClass_7);
+ String _cSourceFileName_1 = this.stdExt.getCSourceFileName(_actorClass_7);
+ ActorClass _actorClass_8 = xpac.getActorClass();
+ StringConcatenation _generateSourceFile = this.generateSourceFile(root, xpac, _actorClass_8);
this.fileAccess.generateFile(_cSourceFileName_1, _generateSourceFile);
}
}
@@ -150,7 +155,6 @@ public class ActorClassGen {
_builder.newLine();
_builder.append("#include \"etDatatypes.h\"");
_builder.newLine();
- _builder.newLine();
{
HashSet<DataClass> _referencedDataClasses = root.getReferencedDataClasses(ac);
for(final DataClass dataClass : _referencedDataClasses) {
@@ -161,7 +165,6 @@ public class ActorClassGen {
_builder.newLineIfNotEmpty();
}
}
- _builder.newLine();
{
EList<ProtocolClass> _referencedProtocolClasses = root.getReferencedProtocolClasses(ac);
for(final ProtocolClass pc : _referencedProtocolClasses) {
@@ -174,8 +177,8 @@ public class ActorClassGen {
}
_builder.newLine();
DetailCode _userCode1 = ac.getUserCode1();
- StringConcatenation _UserCode = this.helpers.UserCode(_userCode1);
- _builder.append(_UserCode, "");
+ StringConcatenation _userCode = this.helpers.userCode(_userCode1);
+ _builder.append(_userCode, "");
_builder.newLineIfNotEmpty();
_builder.newLine();
_builder.append("typedef struct ");
@@ -217,8 +220,6 @@ public class ActorClassGen {
_builder.newLineIfNotEmpty();
}
}
- _builder.append("\t");
- _builder.newLine();
_builder.append("} ");
String _name_9 = xpac.getName();
_builder.append(_name_9, "");
@@ -238,6 +239,16 @@ public class ActorClassGen {
_builder.append(_name_11, " ");
_builder.append("_const* constData;");
_builder.newLineIfNotEmpty();
+ {
+ StateGraph _stateMachine = xpac.getStateMachine();
+ boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_stateMachine, null);
+ if (_operator_notEquals) {
+ _builder.append("\t");
+ StringConcatenation _genDataMembers = this.stateMachineGen.genDataMembers(xpac, ac);
+ _builder.append(_genDataMembers, " ");
+ _builder.newLineIfNotEmpty();
+ }
+ }
_builder.append("};");
_builder.newLine();
_builder.newLine();
@@ -253,14 +264,12 @@ public class ActorClassGen {
_builder.append("void ");
String _name_14 = xpac.getName();
_builder.append(_name_14, "");
- _builder.append("_ReceiveMessage(void* self, etInt16 localId, const etMessage* msg);");
+ _builder.append("_ReceiveMessage(void* self, void* ifitem, const etMessage* msg);");
_builder.newLineIfNotEmpty();
_builder.newLine();
- _builder.newLine();
- _builder.newLine();
DetailCode _userCode2 = ac.getUserCode2();
- StringConcatenation _UserCode_1 = this.helpers.UserCode(_userCode2);
- _builder.append(_UserCode_1, "");
+ StringConcatenation _userCode_1 = this.helpers.userCode(_userCode2);
+ _builder.append(_userCode_1, "");
_builder.newLineIfNotEmpty();
_builder.newLine();
String _name_15 = xpac.getName();
@@ -299,17 +308,45 @@ public class ActorClassGen {
_builder.append("\"");
_builder.newLineIfNotEmpty();
_builder.newLine();
- _builder.append("#include \"etLogger.h\"");
+ _builder.append("#include \"etActor.h\"");
_builder.newLine();
+ _builder.append("#include \"etLogger.h\"");
_builder.newLine();
_builder.append("#include \"etMSCLogger.h\"");
_builder.newLine();
_builder.newLine();
+ {
+ EList<ProtocolClass> _referencedProtocolClasses = root.getReferencedProtocolClasses(ac);
+ for(final ProtocolClass pc : _referencedProtocolClasses) {
+ _builder.append("#include \"");
+ String _cHeaderFileName_1 = this.stdExt.getCHeaderFileName(pc);
+ _builder.append(_cHeaderFileName_1, "");
+ _builder.append("\"");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.newLine();
DetailCode _userCode3 = xpac.getUserCode3();
- StringConcatenation _UserCode = this.helpers.UserCode(_userCode3);
- _builder.append(_UserCode, "");
+ StringConcatenation _userCode = this.helpers.userCode(_userCode3);
+ _builder.append(_userCode, "");
_builder.newLineIfNotEmpty();
_builder.newLine();
+ _builder.append("/* interface item IDs */");
+ _builder.newLine();
+ String _genInterfaceItemConstants = this.genInterfaceItemConstants(xpac, ac);
+ _builder.append(_genInterfaceItemConstants, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ {
+ StateGraph _stateMachine = xpac.getStateMachine();
+ boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_stateMachine, null);
+ if (_operator_notEquals) {
+ StringConcatenation _genStateMachine = this.stateMachineGen.genStateMachine(xpac, ac);
+ _builder.append(_genStateMachine, "");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.newLine();
_builder.append("void ");
String _name_1 = xpac.getName();
_builder.append(_name_1, "");
@@ -325,64 +362,13 @@ public class ActorClassGen {
_builder.append("\", \"init\")");
_builder.newLineIfNotEmpty();
{
- ActorClass _actorClass = xpac.getActorClass();
- List<Port> _endPorts = this.roomExt.getEndPorts(_actorClass);
- final Function1<Port,Boolean> _function = new Function1<Port,Boolean>() {
- public Boolean apply(final Port e) {
- boolean _isConjugated = e.isConjugated();
- return ((Boolean)_isConjugated);
- }
- };
- Iterable<Port> _filter = IterableExtensions.<Port>filter(_endPorts, _function);
- for(final Port port : _filter) {
- {
- ProtocolClass _protocol = port.getProtocol();
- EList<Message> _incomingMessages = _protocol.getIncomingMessages();
- for(final Message message : _incomingMessages) {
- _builder.append("\t");
- String _portClassName = this.roomExt.getPortClassName(port);
- _builder.append(_portClassName, " ");
- _builder.append("_");
- String _name_4 = message.getName();
- _builder.append(_name_4, " ");
- _builder.append("(&self->constData->");
- String _name_5 = port.getName();
- _builder.append(_name_5, " ");
- _builder.append(");");
- _builder.newLineIfNotEmpty();
- }
- }
- }
- }
- {
- ActorClass _actorClass_1 = xpac.getActorClass();
- List<Port> _endPorts_1 = this.roomExt.getEndPorts(_actorClass_1);
- final Function1<Port,Boolean> _function_1 = new Function1<Port,Boolean>() {
- public Boolean apply(final Port e) {
- boolean _isConjugated = e.isConjugated();
- boolean _operator_not = BooleanExtensions.operator_not(_isConjugated);
- return ((Boolean)_operator_not);
- }
- };
- Iterable<Port> _filter_1 = IterableExtensions.<Port>filter(_endPorts_1, _function_1);
- for(final Port port_1 : _filter_1) {
- {
- ProtocolClass _protocol_1 = port_1.getProtocol();
- EList<Message> _outgoingMessages = _protocol_1.getOutgoingMessages();
- for(final Message message_1 : _outgoingMessages) {
- _builder.append("\t");
- String _portClassName_1 = this.roomExt.getPortClassName(port_1);
- _builder.append(_portClassName_1, " ");
- _builder.append("_");
- String _name_6 = message_1.getName();
- _builder.append(_name_6, " ");
- _builder.append("(&self->constData->");
- String _name_7 = port_1.getName();
- _builder.append(_name_7, " ");
- _builder.append(");");
- _builder.newLineIfNotEmpty();
- }
- }
+ StateGraph _stateMachine_1 = xpac.getStateMachine();
+ boolean _operator_notEquals_1 = ObjectExtensions.operator_notEquals(_stateMachine_1, null);
+ if (_operator_notEquals_1) {
+ _builder.append("\t");
+ StringConcatenation _genInitialization = this.stateMachineGen.genInitialization(xpac, ac);
+ _builder.append(_genInitialization, " ");
+ _builder.newLineIfNotEmpty();
}
}
_builder.append("\t");
@@ -393,16 +379,29 @@ public class ActorClassGen {
_builder.newLine();
_builder.newLine();
_builder.append("void ");
- String _name_8 = xpac.getName();
- _builder.append(_name_8, "");
- _builder.append("_ReceiveMessage(void* self, etInt16 localId, const etMessage* msg){");
+ String _name_4 = xpac.getName();
+ _builder.append(_name_4, "");
+ _builder.append("_ReceiveMessage(void* self, void* ifitem, const etMessage* msg){");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("ET_MSC_LOGGER_SYNC_ENTRY(\"");
- String _name_9 = xpac.getName();
- _builder.append(_name_9, " ");
+ String _name_5 = xpac.getName();
+ _builder.append(_name_5, " ");
_builder.append("\", \"ReceiveMessage\")");
_builder.newLineIfNotEmpty();
+ {
+ StateGraph _stateMachine_2 = xpac.getStateMachine();
+ boolean _operator_notEquals_2 = ObjectExtensions.operator_notEquals(_stateMachine_2, null);
+ if (_operator_notEquals_2) {
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("receiveEvent(self, (etPort*)ifitem, msg->evtID, (void*)(&msg[1]));");
+ _builder.newLine();
+ }
+ }
+ _builder.append("\t");
+ _builder.newLine();
_builder.append("\t");
_builder.append("ET_MSC_LOGGER_SYNC_EXIT");
_builder.newLine();
diff --git a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/CExtensions.java b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/CExtensions.java
index dc5554b8d..c84d2992b 100644
--- a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/CExtensions.java
+++ b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/CExtensions.java
@@ -2,13 +2,14 @@ package org.eclipse.etrice.generator.c.gen;
import com.google.inject.Inject;
import com.google.inject.Singleton;
+import java.util.List;
import org.eclipse.etrice.core.room.Message;
import org.eclipse.etrice.core.room.RoomClass;
import org.eclipse.etrice.generator.etricegen.ExpandedActorClass;
import org.eclipse.etrice.generator.etricegen.TransitionChain;
import org.eclipse.etrice.generator.generic.ILanguageExtension;
import org.eclipse.etrice.generator.generic.LanguageGenerator;
-import org.eclipse.xtext.xbase.lib.ComparableExtensions;
+import org.eclipse.xtext.util.Pair;
import org.eclipse.xtext.xbase.lib.StringExtensions;
import org.eclipse.xtext.xtend2.lib.StringConcatenation;
@@ -24,11 +25,11 @@ public class CExtensions implements ILanguageExtension {
}
public String accessLevelPrivate() {
- return "";
+ return "static ";
}
public String accessLevelProtected() {
- return "";
+ return "static ";
}
public String accessLevelPublic() {
@@ -39,15 +40,23 @@ public class CExtensions implements ILanguageExtension {
return "self->";
}
- public String selfPointer(final String classname, final int argumentCount) {
+ public String selfPointer(final String classname, final boolean hasArgs) {
+ String _xifexpression = null;
+ if (hasArgs) {
+ _xifexpression = "* self, ";
+ } else {
+ _xifexpression = "* self";
+ }
+ String _operator_plus = StringExtensions.operator_plus(classname, _xifexpression);
+ return _operator_plus;
+ }
+
+ public String selfPointer(final boolean hasArgs) {
String _xifexpression = null;
- boolean _operator_greaterThan = ComparableExtensions.<Integer>operator_greaterThan(((Integer)argumentCount), ((Integer)0));
- if (_operator_greaterThan) {
- String _operator_plus = StringExtensions.operator_plus(classname, "* self, ");
- _xifexpression = _operator_plus;
+ if (hasArgs) {
+ _xifexpression = "self, ";
} else {
- String _operator_plus_1 = StringExtensions.operator_plus(classname, "* self");
- _xifexpression = _operator_plus_1;
+ _xifexpression = "self";
}
return _xifexpression;
}
@@ -57,18 +66,15 @@ public class CExtensions implements ILanguageExtension {
return _operator_plus;
}
- /**
- * TODO: unify OUT and in an add for loop (also for Java)
- */
- public String outMessageId(final String classname, final String messagename) {
- String _operator_plus = StringExtensions.operator_plus(classname, "_OUT_");
- String _operator_plus_1 = StringExtensions.operator_plus(_operator_plus, messagename);
+ public String memberInDeclaration(final String namespace, final String member) {
+ String _operator_plus = StringExtensions.operator_plus(namespace, "_");
+ String _operator_plus_1 = StringExtensions.operator_plus(_operator_plus, member);
return _operator_plus_1;
}
- public String inMessageId(final String classname, final String messagename) {
- String _operator_plus = StringExtensions.operator_plus(classname, "_IN_");
- String _operator_plus_1 = StringExtensions.operator_plus(_operator_plus, messagename);
+ public String memberInUse(final String namespace, final String member) {
+ String _operator_plus = StringExtensions.operator_plus(namespace, "_");
+ String _operator_plus_1 = StringExtensions.operator_plus(_operator_plus, member);
return _operator_plus_1;
}
@@ -131,6 +137,57 @@ public class CExtensions implements ILanguageExtension {
return _builder;
}
+ public boolean usesInheritance() {
+ return false;
+ }
+
+ public String genEnumeration(final String name, final List<Pair<String,String>> entries) {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("enum ");
+ _builder.append(name, "");
+ _builder.append(" {");
+ _builder.newLineIfNotEmpty();
+ {
+ boolean hasAnyElements = false;
+ for(final Pair<String,String> entry : entries) {
+ if (!hasAnyElements) {
+ hasAnyElements = true;
+ } else {
+ _builder.appendImmediate(",", " ");
+ }
+ _builder.append("\t");
+ String _first = entry.getFirst();
+ _builder.append(_first, " ");
+ _builder.append(" = ");
+ String _second = entry.getSecond();
+ _builder.append(_second, " ");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("};");
+ _builder.newLine();
+ String _string = _builder.toString();
+ return _string;
+ }
+
+ public String booleanConstant(final boolean b) {
+ String _xifexpression = null;
+ if (b) {
+ _xifexpression = "TRUE";
+ } else {
+ _xifexpression = "FALSE";
+ }
+ return _xifexpression;
+ }
+
+ public String nullPointer() {
+ return "NULL";
+ }
+
+ public String voidPointer() {
+ return "void*";
+ }
+
public String getExecuteChainCode(final ExpandedActorClass ac, final TransitionChain tc) {
String _executeChain = this.languageGen.getExecuteChain(ac, tc);
return _executeChain;
diff --git a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/DataClassGen.java b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/DataClassGen.java
index 0dced56c4..08e72ad83 100644
--- a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/DataClassGen.java
+++ b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/DataClassGen.java
@@ -98,8 +98,6 @@ public class DataClassGen {
_builder.append("#include \"etDatatypes.h\"");
_builder.newLine();
_builder.newLine();
- _builder.append("/* TODO: includes only for used DataClasses, also for other models */");
- _builder.newLine();
{
HashSet<DataClass> _referencedDataClasses = root.getReferencedDataClasses(dc);
for(final DataClass dataClass : _referencedDataClasses) {
@@ -112,8 +110,8 @@ public class DataClassGen {
}
_builder.newLine();
DetailCode _userCode1 = dc.getUserCode1();
- StringConcatenation _UserCode = this.helpers.UserCode(_userCode1);
- _builder.append(_UserCode, "");
+ StringConcatenation _userCode = this.helpers.userCode(_userCode1);
+ _builder.append(_userCode, "");
_builder.newLineIfNotEmpty();
_builder.append("\t\t");
_builder.newLine();
@@ -121,13 +119,13 @@ public class DataClassGen {
_builder.newLine();
_builder.append("\t");
DetailCode _userCode2 = dc.getUserCode2();
- StringConcatenation _UserCode_1 = this.helpers.UserCode(_userCode2);
- _builder.append(_UserCode_1, " ");
+ StringConcatenation _userCode_1 = this.helpers.userCode(_userCode2);
+ _builder.append(_userCode_1, " ");
_builder.newLineIfNotEmpty();
_builder.append("\t");
EList<Attribute> _attributes = dc.getAttributes();
- StringConcatenation _Attributes = this.helpers.Attributes(_attributes);
- _builder.append(_Attributes, " ");
+ StringConcatenation _attributes_1 = this.helpers.attributes(_attributes);
+ _builder.append(_attributes_1, " ");
_builder.newLineIfNotEmpty();
_builder.append("} ");
String _name_3 = dc.getName();
@@ -145,13 +143,11 @@ public class DataClassGen {
_builder.append(";");
_builder.newLineIfNotEmpty();
_builder.newLine();
- _builder.append("// TODO: do we need setters and getters for C and C++ ?");
- _builder.newLine();
_builder.newLine();
EList<StandardOperation> _operations = dc.getOperations();
String _name_5 = dc.getName();
- StringConcatenation _OperationsDeclaration = this.helpers.OperationsDeclaration(_operations, _name_5);
- _builder.append(_OperationsDeclaration, "");
+ StringConcatenation _operationsDeclaration = this.helpers.operationsDeclaration(_operations, _name_5);
+ _builder.append(_operationsDeclaration, "");
_builder.newLineIfNotEmpty();
_builder.newLine();
_builder.append("// deep copy");
@@ -208,17 +204,15 @@ public class DataClassGen {
_builder.newLine();
_builder.newLine();
DetailCode _userCode3 = dc.getUserCode3();
- StringConcatenation _UserCode = this.helpers.UserCode(_userCode3);
- _builder.append(_UserCode, "");
+ StringConcatenation _userCode = this.helpers.userCode(_userCode3);
+ _builder.append(_userCode, "");
_builder.newLineIfNotEmpty();
_builder.newLine();
- _builder.append("// TODO: do we need setters and getters for C and C++ ?");
- _builder.newLine();
_builder.newLine();
EList<StandardOperation> _operations = dc.getOperations();
String _name_1 = dc.getName();
- StringConcatenation _OperationsImplementation = this.helpers.OperationsImplementation(_operations, _name_1);
- _builder.append(_OperationsImplementation, "");
+ StringConcatenation _operationsImplementation = this.helpers.operationsImplementation(_operations, _name_1);
+ _builder.append(_operationsImplementation, "");
_builder.newLineIfNotEmpty();
_builder.newLine();
_builder.append("// deep copy");
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 a31787853..6ce0965e9 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
@@ -17,17 +17,17 @@ import org.eclipse.etrice.generator.base.ILogger;
import org.eclipse.etrice.generator.c.gen.CExtensions;
import org.eclipse.etrice.generator.etricegen.Root;
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.IntegerExtensions;
import org.eclipse.xtext.xbase.lib.ObjectExtensions;
import org.eclipse.xtext.xbase.lib.StringExtensions;
import org.eclipse.xtext.xtend2.lib.StringConcatenation;
@SuppressWarnings("all")
@Singleton
-public class ProtocolClassGen {
+public class ProtocolClassGen extends GenericProtocolClassGenerator {
@Inject
private JavaIoFileSystemAccess fileAccess;
@@ -108,8 +108,8 @@ public class ProtocolClassGen {
_builder.newLine();
_builder.newLine();
DetailCode _userCode1 = pc.getUserCode1();
- StringConcatenation _UserCode = this.helpers.UserCode(_userCode1);
- _builder.append(_UserCode, "");
+ StringConcatenation _userCode = this.helpers.userCode(_userCode1);
+ _builder.append(_userCode, "");
_builder.newLineIfNotEmpty();
_builder.newLine();
{
@@ -125,73 +125,9 @@ public class ProtocolClassGen {
_builder.newLine();
_builder.append("/* message IDs */");
_builder.newLine();
- _builder.append("enum {");
- _builder.newLine();
- _builder.append("\t");
- String _name_3 = pc.getName();
- _builder.append(_name_3, " ");
- _builder.append("_MSG_MIN = 0, ");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("/* IDs for outgoing messages */");
- _builder.newLine();
- {
- List<Message> _allOutgoingMessages = this.roomExt.getAllOutgoingMessages(pc);
- for(final Message message : _allOutgoingMessages) {
- _builder.append("\t");
- String _name_4 = pc.getName();
- String _name_5 = message.getName();
- String _outMessageId = this.stdExt.outMessageId(_name_4, _name_5);
- _builder.append(_outMessageId, " ");
- _builder.append(" = ");
- List<Message> _allOutgoingMessages_1 = this.roomExt.getAllOutgoingMessages(pc);
- int _indexOf = _allOutgoingMessages_1.indexOf(message);
- int _operator_plus = IntegerExtensions.operator_plus(((Integer)_indexOf), ((Integer)1));
- _builder.append(_operator_plus, " ");
- _builder.append(",");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("\t");
- _builder.append("/* IDs for incoming messages */");
- _builder.newLine();
- {
- List<Message> _allIncomingMessages = this.roomExt.getAllIncomingMessages(pc);
- for(final Message message_1 : _allIncomingMessages) {
- _builder.append("\t");
- String _name_6 = pc.getName();
- String _name_7 = message_1.getName();
- String _inMessageId = this.stdExt.inMessageId(_name_6, _name_7);
- _builder.append(_inMessageId, " ");
- _builder.append(" = ");
- List<Message> _allIncomingMessages_1 = this.roomExt.getAllIncomingMessages(pc);
- int _indexOf_1 = _allIncomingMessages_1.indexOf(message_1);
- List<Message> _allOutgoingMessages_2 = this.roomExt.getAllOutgoingMessages(pc);
- int _size = _allOutgoingMessages_2.size();
- int _operator_plus_1 = IntegerExtensions.operator_plus(((Integer)_indexOf_1), ((Integer)_size));
- int _operator_plus_2 = IntegerExtensions.operator_plus(((Integer)_operator_plus_1), ((Integer)1));
- _builder.append(_operator_plus_2, " ");
- _builder.append(",");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("\t");
- _builder.append("/* error if msgID >= MSG_MAX */");
- _builder.newLine();
- _builder.append("\t");
- String _name_8 = pc.getName();
- _builder.append(_name_8, " ");
- _builder.append("_MSG_MAX = ");
- List<Message> _allOutgoingMessages_3 = this.roomExt.getAllOutgoingMessages(pc);
- int _size_1 = _allOutgoingMessages_3.size();
- List<Message> _allIncomingMessages_2 = this.roomExt.getAllIncomingMessages(pc);
- int _size_2 = _allIncomingMessages_2.size();
- int _operator_plus_3 = IntegerExtensions.operator_plus(((Integer)_size_1), ((Integer)_size_2));
- int _operator_plus_4 = IntegerExtensions.operator_plus(((Integer)_operator_plus_3), ((Integer)1));
- _builder.append(_operator_plus_4, " ");
+ String _genMessageIDs = this.genMessageIDs(pc);
+ _builder.append(_genMessageIDs, "");
_builder.newLineIfNotEmpty();
- _builder.append("};");
- _builder.newLine();
_builder.newLine();
_builder.append("/*--------------------- port classes */");
_builder.newLine();
@@ -208,19 +144,19 @@ public class ProtocolClassGen {
_builder.append("/* get message string for message id */");
_builder.newLine();
_builder.append("const char* ");
- String _name_9 = pc.getName();
- _builder.append(_name_9, "");
+ String _name_3 = pc.getName();
+ _builder.append(_name_3, "");
_builder.append("_getMessageString(int msg_id);");
_builder.newLineIfNotEmpty();
_builder.newLine();
DetailCode _userCode2 = pc.getUserCode2();
- StringConcatenation _UserCode_1 = this.helpers.UserCode(_userCode2);
- _builder.append(_UserCode_1, "");
+ StringConcatenation _userCode_1 = this.helpers.userCode(_userCode2);
+ _builder.append(_userCode_1, "");
_builder.newLineIfNotEmpty();
_builder.newLine();
_builder.newLine();
- String _name_10 = pc.getName();
- StringConcatenation _generateIncludeGuardEnd = this.stdExt.generateIncludeGuardEnd(_name_10);
+ String _name_4 = pc.getName();
+ StringConcatenation _generateIncludeGuardEnd = this.stdExt.generateIncludeGuardEnd(_name_4);
_builder.append(_generateIncludeGuardEnd, "");
_builder.newLineIfNotEmpty();
_builder.newLine();
@@ -383,8 +319,9 @@ public class ProtocolClassGen {
_builder.append("msg->evtID = ");
String _name_2 = pc.getName();
String _name_3 = message.getName();
- String _outMessageId = this.stdExt.outMessageId(_name_2, _name_3);
- _builder.append(_outMessageId, " ");
+ String _operator_plus = StringExtensions.operator_plus("OUT_", _name_3);
+ String _memberInUse = this.stdExt.memberInUse(_name_2, _operator_plus);
+ _builder.append(_memberInUse, " ");
_builder.append(";");
_builder.newLineIfNotEmpty();
_builder.append("\t");
@@ -428,8 +365,9 @@ public class ProtocolClassGen {
_builder.append("msg->evtID = ");
String _name_6 = pc.getName();
String _name_7 = message_1.getName();
- String _inMessageId = this.stdExt.inMessageId(_name_6, _name_7);
- _builder.append(_inMessageId, " ");
+ String _operator_plus_1 = StringExtensions.operator_plus("IN_", _name_7);
+ String _memberInUse_1 = this.stdExt.memberInUse(_name_6, _operator_plus_1);
+ _builder.append(_memberInUse_1, " ");
_builder.append(";");
_builder.newLineIfNotEmpty();
_builder.append("\t");
@@ -501,8 +439,6 @@ public class ProtocolClassGen {
public StringConcatenation generateDebugHelpersImplementation(final Root root, final ProtocolClass pc) {
StringConcatenation _builder = new StringConcatenation();
_builder.newLine();
- _builder.append("/* TODO: make this optional or different for smaller footprint */");
- _builder.newLine();
_builder.append("/* message names as strings for debugging (generate MSC) */");
_builder.newLine();
_builder.append("static const char* ");
diff --git a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/StateMachineGen.java b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/StateMachineGen.java
index 65863e4ca..cc1106cfe 100644
--- a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/StateMachineGen.java
+++ b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/StateMachineGen.java
@@ -3,865 +3,75 @@ package org.eclipse.etrice.generator.c.gen;
import com.google.inject.Inject;
import com.google.inject.Singleton;
import java.util.List;
-import org.eclipse.emf.common.util.EList;
import org.eclipse.etrice.core.room.ActorClass;
-import org.eclipse.etrice.core.room.DetailCode;
-import org.eclipse.etrice.core.room.Guard;
-import org.eclipse.etrice.core.room.InterfaceItem;
-import org.eclipse.etrice.core.room.Message;
-import org.eclipse.etrice.core.room.MessageFromIf;
-import org.eclipse.etrice.core.room.NonInitialTransition;
import org.eclipse.etrice.core.room.State;
-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.c.gen.CExtensions;
-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.RoomExtensions;
-import org.eclipse.etrice.generator.extensions.RoomNameProv;
-import org.eclipse.etrice.generator.generic.LanguageGenerator;
-import org.eclipse.xtext.xbase.lib.BooleanExtensions;
-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.etrice.generator.generic.GenericStateMachineGenerator;
import org.eclipse.xtext.xtend2.lib.StringConcatenation;
@SuppressWarnings("all")
@Singleton
-public class StateMachineGen {
+public class StateMachineGen extends GenericStateMachineGenerator {
@Inject
- private CExtensions stdExt;
+ private RoomExtensions _roomExtensions;
- @Inject
- private RoomExtensions roomExt;
-
- @Inject
- private LanguageGenerator languageGen;
-
- public StringConcatenation genStateMachine(final ExpandedActorClass xpac, final ActorClass ac) {
+ public StringConcatenation genDataMembers(final ExpandedActorClass xpac, final ActorClass ac) {
StringConcatenation _builder = new StringConcatenation();
- _builder.append("//******************************************");
- _builder.newLine();
- _builder.append("// START of generated code for FSM");
- _builder.newLine();
- _builder.append("//******************************************");
- _builder.newLine();
- _builder.newLine();
- _builder.append("// State IDs for FSM");
- _builder.newLine();
- int _numberOfInheritedBaseStates = this.roomExt.getNumberOfInheritedBaseStates(ac);
- int offset = _numberOfInheritedBaseStates;
- _builder.newLineIfNotEmpty();
- StateGraph _stateMachine = ac.getStateMachine();
- List<State> _baseStateList = this.roomExt.getBaseStateList(_stateMachine);
- List<State> baseStates = _baseStateList;
- _builder.newLineIfNotEmpty();
- {
- for(final State state : baseStates) {
- _builder.append("protected static final int ");
- String _stateId = this.roomExt.getStateId(state);
- _builder.append(_stateId, "");
- _builder.append(" = ");
- int _indexOf = baseStates.indexOf(state);
- int _operator_plus = IntegerExtensions.operator_plus(((Integer)_indexOf), ((Integer)2));
- int _operator_plus_1 = IntegerExtensions.operator_plus(((Integer)_operator_plus), ((Integer)offset));
- _builder.append(_operator_plus_1, "");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("\t");
- _builder.append("protected static final String stateStrings[] = {\"<no state>\",\"<top>\",");
- {
- List<State> _allBaseStates = this.roomExt.getAllBaseStates(ac);
- boolean hasAnyElements = false;
- for(final State state_1 : _allBaseStates) {
- if (!hasAnyElements) {
- hasAnyElements = true;
- } else {
- _builder.appendImmediate(",", " ");
- }
- _builder.append("\"");
- String _statePathName = this.roomExt.getStatePathName(state_1);
- _builder.append(_statePathName, " ");
- _builder.append("\"");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- }
- }
- _builder.append("};");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("// history");
- _builder.newLine();
- _builder.append("// TODOHRR: history defined in ActorClassBase, init in constructor");
- _builder.newLine();
- _builder.append("//\t\thistory = new int[5];");
- _builder.newLine();
- _builder.append("//\t\tfor (int i = 0; i < history.length; i++) {");
- _builder.newLine();
- _builder.append("//\t\t\thistory[i] = NO_STATE;");
- _builder.newLine();
- _builder.append("//\t\t}");
- _builder.newLine();
- _builder.append("protected int history[] = {NO_STATE,NO_STATE");
- {
- List<State> _allBaseStates_1 = this.roomExt.getAllBaseStates(ac);
- for(final State state_2 : _allBaseStates_1) {
- _builder.append(",NO_STATE");
- }
- }
- _builder.append("};");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- EList<TransitionChain> _ownTransitionChains = xpac.getOwnTransitionChains();
- List<TransitionChain> chains = _ownTransitionChains;
- _builder.newLineIfNotEmpty();
- EList<TransitionChain> _transitionChains = xpac.getTransitionChains();
- int _size = _transitionChains.size();
- int _size_1 = chains.size();
- int _operator_minus = IntegerExtensions.operator_minus(((Integer)_size), ((Integer)_size_1));
- int offset_tc = _operator_minus;
- _builder.newLineIfNotEmpty();
- _builder.append("// transition chains");
- _builder.newLine();
- {
- for(final TransitionChain tc : chains) {
- _builder.append("protected static final int ");
- String _chainId = this.roomExt.getChainId(tc);
- _builder.append(_chainId, "");
- _builder.append(" = ");
- int _indexOf_1 = chains.indexOf(tc);
- int _operator_plus_2 = IntegerExtensions.operator_plus(((Integer)_indexOf_1), ((Integer)1));
- int _operator_plus_3 = IntegerExtensions.operator_plus(((Integer)_operator_plus_2), ((Integer)offset_tc));
- _builder.append(_operator_plus_3, "");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.newLine();
- EList<MessageFromIf> _ownTriggers = xpac.getOwnTriggers();
- EList<MessageFromIf> triggers = _ownTriggers;
- _builder.newLineIfNotEmpty();
- _builder.append("// triggers for FSM");
- _builder.newLine();
- {
- for(final MessageFromIf mif : triggers) {
- _builder.append("protected static final int ");
- String _triggerCodeName = xpac.getTriggerCodeName(mif);
- _builder.append(_triggerCodeName, "");
- _builder.append(" = IFITEM_");
- InterfaceItem _from = mif.getFrom();
- String _name = _from.getName();
- _builder.append(_name, "");
- _builder.append(" + EVT_SHIFT*");
- String _messageID = xpac.getMessageID(mif);
- _builder.append(_messageID, "");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.newLine();
- _builder.append("// receiveEvent contains the main implementation of the FSM");
- _builder.newLine();
- _builder.append("@Override");
- _builder.newLine();
- _builder.append("public void receiveEvent(InterfaceItemBase ifitem, int evt, Object generic_data) {");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("int trigger = ifitem.getLocalId() + EVT_SHIFT*evt;");
+ _builder.append("/* state machine variables */");
_builder.newLine();
- _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 = false;");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("boolean skip_entry = false;");
- _builder.newLine();
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("if (!handleSystemEvent(ifitem, evt, generic_data)) {");
+ _builder.append("etInt16 state;");
_builder.newLine();
- _builder.append("\t\t");
- _builder.append("switch (state) {");
- _builder.newLine();
- {
- StateGraph _stateMachine_1 = xpac.getStateMachine();
- List<State> _leafStateList = this.roomExt.getLeafStateList(_stateMachine_1);
- for(final State state_3 : _leafStateList) {
- _builder.append("\t\t\t");
- _builder.append("case ");
- String _stateId_1 = this.roomExt.getStateId(state_3);
- _builder.append(_stateId_1, " ");
- _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_1 = xpac.getTriggerCodeName(_trigger);
- _builder.append(_triggerCodeName_1, " ");
- _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.stdExt.getTypedDataDefinition(_msg);
- _builder.append(_typedDataDefinition, " ");
- }
- }
- _builder.newLineIfNotEmpty();
- {
- EList<TriggeredTransition> _transitions = at.getTransitions();
- boolean hasAnyElements_1 = false;
- for(final TriggeredTransition tt : _transitions) {
- if (!hasAnyElements_1) {
- hasAnyElements_1 = true;
- } else {
- _builder.appendImmediate(" else ", " ");
- }
- _builder.append("\t\t\t");
- _builder.append("\t");
- _builder.append("\t");
- TransitionChain _chain = xpac.getChain(tt);
- TransitionChain chain = _chain;
- _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_1 = this.roomExt.getChainId(chain);
- _builder.append(_chainId_1, " ");
- _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 = true;");
- }
- }
- _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 = true;");
- }
- }
- _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.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("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(state, catching_state, is_handler);");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("int next = executeTransitionChain(chain, ifitem, generic_data);");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("next = enterHistory(next, is_handler, skip_entry);");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("setState(next);");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("}");
- _builder.newLine();
- _builder.newLine();
- _builder.append("private void setState(int new_state) {");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("DebuggingService.getInstance().addActorState(this,stateStrings[new_state]);");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("if (stateStrings[new_state]!=\"Idle\") {");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("// TODOTS: model switch for activation");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("System.out.println(getInstancePath() + \" -> \" + stateStrings[new_state]);");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("}\t");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("this.state = new_state;");
- _builder.newLine();
- _builder.append("}");
- _builder.newLine();
- _builder.newLine();
- _builder.append("@Override");
- _builder.newLine();
- _builder.append("public void executeInitTransition() {");
- _builder.newLine();
- _builder.append("\t");
- StateGraph _stateMachine_2 = xpac.getStateMachine();
- Transition _initTransition = this.roomExt.getInitTransition(_stateMachine_2);
- Transition initt = _initTransition;
+ _builder.append("etInt16 history[");
+ List<State> _allLeafStates = this._roomExtensions.getAllLeafStates(xpac);
+ int _size = _allLeafStates.size();
+ _builder.append(_size, "");
+ _builder.append("];");
_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(chain, null, null);");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("next = enterHistory(next, false, false);");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("setState(next);");
- _builder.newLine();
- _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();
- _builder.append("private void exitTo(int current, int to, boolean handler) {");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("while (current!=to) {");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("switch (current) {");
+ return _builder;
+ }
+
+ public StringConcatenation genInitialization(final ExpandedActorClass xpac, final ActorClass ac) {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("self->state = STATE_TOP;");
_builder.newLine();
- {
- StateGraph _stateMachine_3 = xpac.getStateMachine();
- List<State> _baseStateList_1 = this.roomExt.getBaseStateList(_stateMachine_3);
- for(final State state_4 : _baseStateList_1) {
- _builder.append("\t\t\t");
- _builder.append("case ");
- String _stateId_2 = this.roomExt.getStateId(state_4);
- _builder.append(_stateId_2, " ");
- _builder.append(":");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t\t");
- _builder.append("\t");
- {
- boolean _hasExitCode = this.roomExt.hasExitCode(state_4);
- if (_hasExitCode) {
- _builder.append("if (!handler) ");
- String _exitCodeOperationName = RoomNameProv.getExitCodeOperationName(state_4);
- _builder.append(_exitCodeOperationName, " ");
- _builder.append("();");
- }
- }
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t\t");
- _builder.append("\t");
- _builder.append("history[");
- String _parentStateId = RoomNameProv.getParentStateId(state_4);
- _builder.append(_parentStateId, " ");
- _builder.append("] = ");
- String _stateId_3 = this.roomExt.getStateId(state_4);
- _builder.append(_stateId_3, " ");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t\t");
- _builder.append("\t");
- _builder.append("current = ");
- String _parentStateId_1 = RoomNameProv.getParentStateId(state_4);
- _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.append("{");
_builder.newLine();
_builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("}");
- _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();
- _builder.append("private int executeTransitionChain(int chain, InterfaceItemBase ifitem, Object generic_data) {");
+ _builder.append("int i;");
_builder.newLine();
_builder.append("\t");
- _builder.append("switch (chain) {");
- _builder.newLine();
- _builder.append("\t\t");
- EList<TransitionChain> _transitionChains_1 = xpac.getTransitionChains();
- EList<TransitionChain> allchains = _transitionChains_1;
+ _builder.append("for (i=0; i<");
+ List<State> _allLeafStates = this._roomExtensions.getAllLeafStates(xpac);
+ int _size = _allLeafStates.size();
+ _builder.append(_size, " ");
+ _builder.append("; ++i)");
_builder.newLineIfNotEmpty();
- {
- for(final TransitionChain tc_1 : allchains) {
- _builder.append("\t\t");
- _builder.append("case ");
- String _chainId_3 = this.roomExt.getChainId(tc_1);
- _builder.append(_chainId_3, " ");
- _builder.append(":");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.append("{");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("\t");
- String _executeChainCode = this.stdExt.getExecuteChainCode(xpac, tc_1);
- _builder.append(_executeChainCode, " ");
- _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.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();
- _builder.append("private int enterHistory(int state, boolean handler, boolean skip_entry) {");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("while (true) {");
- _builder.newLine();
_builder.append("\t\t");
- _builder.append("switch (state) {");
- _builder.newLine();
- {
- StateGraph _stateMachine_4 = xpac.getStateMachine();
- List<State> _baseStateList_2 = this.roomExt.getBaseStateList(_stateMachine_4);
- for(final State state_5 : _baseStateList_2) {
- _builder.append("\t\t\t");
- _builder.append("case ");
- String _stateId_4 = this.roomExt.getStateId(state_5);
- _builder.append(_stateId_4, " ");
- _builder.append(":");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t\t");
- _builder.append("\t");
- {
- boolean _hasEntryCode = this.roomExt.hasEntryCode(state_5);
- if (_hasEntryCode) {
- _builder.append("if (!(skip_entry || handler)) ");
- String _entryCodeOperationName = RoomNameProv.getEntryCodeOperationName(state_5);
- _builder.append(_entryCodeOperationName, " ");
- _builder.append("();");
- }
- }
- _builder.newLineIfNotEmpty();
- {
- boolean _isLeaf = this.roomExt.isLeaf(state_5);
- 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_5 = this.roomExt.getStateId(state_5);
- _builder.append(_stateId_5, " ");
- _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_5.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 (history[");
- String _stateId_6 = this.roomExt.getStateId(state_5);
- _builder.append(_stateId_6, " ");
- _builder.append("]==NO_STATE) {");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t\t");
- _builder.append("\t");
- _builder.append("\t");
- StateGraph _subgraph_1 = state_5.getSubgraph();
- Transition _initTransition_1 = this.roomExt.getInitTransition(_subgraph_1);
- Transition sub_initt = _initTransition_1;
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t\t");
- _builder.append("\t");
- _builder.append("\t");
- _builder.append("state = executeTransitionChain(");
- TransitionChain _chain_2 = xpac.getChain(sub_initt);
- String _chainId_4 = this.roomExt.getChainId(_chain_2);
- _builder.append(_chainId_4, " ");
- _builder.append(", null, null);");
- _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 = history[");
- String _stateId_7 = this.roomExt.getStateId(state_5);
- _builder.append(_stateId_7, " ");
- _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 = history[");
- String _stateId_8 = this.roomExt.getStateId(state_5);
- _builder.append(_stateId_8, " ");
- _builder.append("];");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("\t\t\t");
- _builder.append("\t");
- _builder.append("break;");
- _builder.newLine();
- }
- }
- }
- }
- _builder.append("\t\t\t");
- _builder.append("case STATE_TOP:");
+ _builder.append("self->history[i] = NO_STATE;");
_builder.newLine();
- _builder.append("\t\t\t\t");
- _builder.append("state = history[STATE_TOP];");
- _builder.newLine();
- _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 = false;");
- _builder.newLine();
- _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();
- _builder.append("//*** Entry and Exit Codes");
- _builder.newLine();
- {
- StateGraph _stateMachine_5 = xpac.getStateMachine();
- List<State> _stateList = this.roomExt.getStateList(_stateMachine_5);
- for(final State state_6 : _stateList) {
- {
- boolean _isOwnObject = xpac.isOwnObject(state_6);
- if (_isOwnObject) {
- {
- boolean _hasEntryCode_1 = this.roomExt.hasEntryCode(state_6);
- if (_hasEntryCode_1) {
- _builder.append("protected void ");
- String _entryCodeOperationName_1 = RoomNameProv.getEntryCodeOperationName(state_6);
- _builder.append(_entryCodeOperationName_1, "");
- _builder.append("() {");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- String _entryCode = this.roomExt.getEntryCode(xpac, state_6);
- _builder.append(_entryCode, " ");
- _builder.newLineIfNotEmpty();
- _builder.append("}");
- _builder.newLine();
- }
- }
- {
- boolean _hasExitCode_1 = this.roomExt.hasExitCode(state_6);
- if (_hasExitCode_1) {
- _builder.append("protected void ");
- String _exitCodeOperationName_1 = RoomNameProv.getExitCodeOperationName(state_6);
- _builder.append(_exitCodeOperationName_1, "");
- _builder.append("() {");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- String _exitCode = this.roomExt.getExitCode(xpac, state_6);
- _builder.append(_exitCode, " ");
- _builder.newLineIfNotEmpty();
- _builder.append("}");
- _builder.newLine();
- }
- }
- }
- }
- }
- }
- _builder.newLine();
- _builder.append("//*** Action Codes");
- _builder.newLine();
- {
- StateGraph _stateMachine_6 = xpac.getStateMachine();
- List<Transition> _transitionList = this.roomExt.getTransitionList(_stateMachine_6);
- 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) {
- _builder.append("protected void ");
- String _actionCodeOperationName = RoomNameProv.getActionCodeOperationName(tr);
- _builder.append(_actionCodeOperationName, "");
- _builder.append("(");
- {
- 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);
- _builder.append(_actionCode, " ");
- _builder.newLineIfNotEmpty();
- _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.append("executeInitTransition(self);");
_builder.newLine();
return _builder;
}
- protected StringConcatenation _guard(final TriggeredTransition tt, final String trigger, final ExpandedActorClass ac) {
+ public StringConcatenation genExtra(final ExpandedActorClass xpac, final ActorClass 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.newLine();
+ String _accessLevelPrivate = this.langExt.accessLevelPrivate();
+ _builder.append(_accessLevelPrivate, "");
+ _builder.append("void setState(");
+ String _name = ac.getName();
+ _builder.append(_name, "");
+ _builder.append("* self, int new_state) {");
_builder.newLineIfNotEmpty();
- {
- 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();
- }
- }
- return _builder;
- }
-
- protected StringConcatenation _guard(final Transition t, final String trigger, final ExpandedActorClass ac) {
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("/* error */");
+ _builder.append("\t");
+ _builder.append("self->state = new_state;");
+ _builder.newLine();
+ _builder.append("}");
_builder.newLine();
return _builder;
}
-
- public StringConcatenation guard(final Transition tt, final String trigger, final ExpandedActorClass ac) {
- if (tt instanceof TriggeredTransition) {
- return _guard((TriggeredTransition)tt, trigger, ac);
- } else {
- return _guard(tt, trigger, ac);
- }
- }
}
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 6cb97488f..5586c9f97 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
@@ -469,8 +469,6 @@ public class SubSystemClassGen {
_builder.newLine();
_builder.append("/* include all used ActorClasses */");
_builder.newLine();
- _builder.append("/* TODO: only include used Actor Classes for current SubSystem */");
- _builder.newLine();
{
EList<ActorClass> _usedActorClasses = root.getUsedActorClasses();
for(final ActorClass actorClass : _usedActorClasses) {
@@ -551,9 +549,6 @@ public class SubSystemClassGen {
EList<PortInstance> _ports = ai_1.getPorts();
for(final PortInstance pi : _ports) {
_builder.append("\t");
- _builder.append("/* TODO: not robust if not connected and not implemented for replication */");
- _builder.newLine();
- _builder.append("\t");
_builder.append("{&");
String _path_4 = ai_1.getPath();
String _pathName_4 = this.roomExt.getPathName(_path_4);
diff --git a/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/ActorClassGen.xtend b/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/ActorClassGen.xtend
index f6b01032d..d49669449 100644
--- a/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/ActorClassGen.xtend
+++ b/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/ActorClassGen.xtend
@@ -15,7 +15,6 @@ package org.eclipse.etrice.generator.java.gen
import com.google.inject.Inject
import com.google.inject.Singleton
import org.eclipse.etrice.core.room.ActorClass
-import org.eclipse.etrice.core.room.Message
import org.eclipse.etrice.generator.base.ILogger
import org.eclipse.etrice.generator.etricegen.ExpandedActorClass
import org.eclipse.etrice.generator.etricegen.Root
@@ -24,9 +23,10 @@ import org.eclipse.xtext.generator.JavaIoFileSystemAccess
import org.eclipse.etrice.generator.extensions.RoomExtensions
import org.eclipse.etrice.generator.generic.ProcedureHelpers
import org.eclipse.etrice.generator.generic.TypeHelpers
+import org.eclipse.etrice.generator.generic.GenericActorClassGenerator
@Singleton
-class ActorClassGen {
+class ActorClassGen extends GenericActorClassGenerator {
@Inject extension JavaIoFileSystemAccess fileAccess
@Inject extension JavaExtensions stdExt
@@ -58,18 +58,20 @@ class ActorClassGen {
import org.eclipse.etrice.runtime.java.modelbase.InterfaceItemBase;
import org.eclipse.etrice.runtime.java.debugging.DebuggingService;
- «FOR model : root.getReferencedModels(ac)»import «model.name».*;
+ «FOR model : root.getReferencedModels(ac)»
+ import «model.name».*;
«ENDFOR»
- «FOR pc : root.getReferencedProtocolClasses(ac)»import «pc.^package».«pc.name».*;
+ «FOR pc : root.getReferencedProtocolClasses(ac)»
+ import «pc.^package».«pc.name».*;
«ENDFOR»
- «helpers.UserCode(ac.userCode1)»
+ «helpers.userCode(ac.userCode1)»
public «IF ac.abstract»abstract «ENDIF»class «ac.name» extends «IF ac.base!=null»«ac.base.name»«ELSE»ActorClassBase«ENDIF» {
- «helpers.UserCode(ac.userCode2)»
+ «helpers.userCode(ac.userCode2)»
//--------------------- ports
«FOR ep : ac.getEndPorts()»
@@ -85,18 +87,10 @@ class ActorClassGen {
«ENDFOR»
//--------------------- interface item IDs
- «FOR ep : ac.getEndPorts()»
- protected static final int IFITEM_«ep.name» = «xpac.getInterfaceItemLocalId(ep)+1»;
- «ENDFOR»
- «FOR sap : ac.strSAPs»
- protected static final int IFITEM_«sap.name» = «xpac.getInterfaceItemLocalId(sap)+1»;
- «ENDFOR»
- «FOR svc : ac.serviceImplementations»
- protected static final int IFITEM_«svc.spp.name» = «xpac.getInterfaceItemLocalId(svc.spp)+1»;
- «ENDFOR»
-
- «helpers.Attributes(ac.attributes)»
- «helpers.OperationsImplementation(ac.operations, ac.name)»
+ «genInterfaceItemConstants(xpac, ac)»
+
+ «helpers.attributes(ac.attributes)»
+ «helpers.operationsImplementation(ac.operations, ac.name)»
//--------------------- construction
public «ac.name»(IRTObject parent, String name, Address[][] port_addr, Address[][] peer_addr){
@@ -159,8 +153,4 @@ class ActorClassGen {
};
'''
}
-
- def msgArgs(Message msg) {
- '''«IF msg.data!=null»«msg.data.defaultValue()»«ENDIF»'''
- }
} \ No newline at end of file
diff --git a/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/DataClassGen.xtend b/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/DataClassGen.xtend
index a04326b12..9e702f449 100644
--- a/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/DataClassGen.xtend
+++ b/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/DataClassGen.xtend
@@ -53,18 +53,18 @@ class DataClassGen {
«FOR model : models»import «model.name».*;
«ENDFOR»
- «helpers.UserCode(dc.userCode1)»
+ «helpers.userCode(dc.userCode1)»
public class «dc.name»«IF dc.base!=null» extends «dc.base.name»«ENDIF» {
- «helpers.UserCode(dc.userCode2)»
+ «helpers.userCode(dc.userCode2)»
- «helpers.Attributes(dc.attributes)»
+ «helpers.attributes(dc.attributes)»
- «helpers.AttributeSettersGettersImplementation(dc.attributes, dc.name)»
+ «helpers.attributeSettersGettersImplementation(dc.attributes, dc.name)»
- «helpers.OperationsImplementation(dc.operations, dc.name)»
+ «helpers.operationsImplementation(dc.operations, dc.name)»
// default constructor
public «dc.name»() {
diff --git a/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/JavaExtensions.xtend b/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/JavaExtensions.xtend
index 38fae556b..51a8bd24d 100644
--- a/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/JavaExtensions.xtend
+++ b/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/JavaExtensions.xtend
@@ -25,6 +25,8 @@ import org.eclipse.etrice.generator.etricegen.ExpandedActorClass
import org.eclipse.etrice.generator.etricegen.TransitionChain
import org.eclipse.etrice.generator.generic.LanguageGenerator
import org.eclipse.etrice.generator.generic.ILanguageExtension
+import java.util.List
+import org.eclipse.xtext.util.Pair
@Singleton
@@ -45,12 +47,38 @@ class JavaExtensions implements ILanguageExtension {
override String accessLevelPublic() {"public "}
override String memberAccess() {"this."}
- override String selfPointer(String classname, int argumentCount) {""}
+ override String selfPointer(String classname, boolean hasArgs) {""}
+ override String selfPointer(boolean hasArgs) { "" }
override String operationScope(String classname, boolean isDeclaration) {""}
- override String outMessageId(String classname, String messagename) {"OUT_"+messagename}
- override String inMessageId(String classname, String messagename) {"IN_"+messagename}
+
+ override String memberInDeclaration(String namespace, String member) {
+ return member
+ }
+
+ override String memberInUse(String namespace, String member) {
+ return namespace+"."+member
+ }
+
+ override boolean usesInheritance() {
+ return true
+ }
+
+ override String genEnumeration(String name, List<Pair<String, String>> entries) {
+ '''
+ «FOR entry: entries»
+ public static final int «entry.first» = «entry.second»;
+ «ENDFOR»
+ '''.toString
+ }
+
+ override String booleanConstant(boolean b) {
+ b.toString
+ }
+
+ override String nullPointer() { "null" }
+ override String voidPointer() { "Object" }
//-------------------------------------------------------
// transition chain visitor
diff --git a/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/ProtocolClassGen.xtend b/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/ProtocolClassGen.xtend
index 78d11fd99..ded007498 100644
--- a/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/ProtocolClassGen.xtend
+++ b/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/ProtocolClassGen.xtend
@@ -25,10 +25,11 @@ import org.eclipse.xtext.generator.JavaIoFileSystemAccess
import org.eclipse.etrice.generator.extensions.RoomExtensions
import org.eclipse.etrice.generator.generic.ProcedureHelpers
import org.eclipse.etrice.generator.generic.TypeHelpers
+import org.eclipse.etrice.generator.generic.GenericProtocolClassGenerator
@Singleton
-class ProtocolClassGen {
+class ProtocolClassGen extends GenericProtocolClassGenerator {
@Inject extension JavaIoFileSystemAccess fileAccess
@Inject extension JavaExtensions stdExt
@@ -57,7 +58,7 @@ class ProtocolClassGen {
import org.eclipse.etrice.runtime.java.modelbase.*;
import org.eclipse.etrice.runtime.java.debugging.DebuggingService;
- «helpers.UserCode(pc.userCode1)»
+ «helpers.userCode(pc.userCode1)»
«var models = root.getReferencedModels(pc)»
«FOR model : models»import «model.name».*;
@@ -65,21 +66,9 @@ class ProtocolClassGen {
public class «pc.name» {
// message IDs
- // TODO: separate class for message IDs: class MSG{public static volatile int MSG_MIN = 0; ...} -> better structure
- // error if msgID <= MSG_MIN
- public static final int MSG_MIN = 0;
- //IDs for outgoing messages
- «FOR message : pc.getAllOutgoingMessages()»
- public static final int «outMessageId(pc.name, message.name)» = «pc.getAllOutgoingMessages().indexOf(message)+1»;
- «ENDFOR»
- //IDs for incoming messages
- «FOR message : pc.getAllIncomingMessages()»
- public static final int «inMessageId(pc.name, message.name)» = «pc.getAllIncomingMessages().indexOf(message)+pc.getAllOutgoingMessages().size+1»;
- «ENDFOR»
- //error if msgID >= MSG_MAX
- public static final int MSG_MAX = «pc.getAllOutgoingMessages().size + pc.getAllIncomingMessages().size+1»;
+ «genMessageIDs(pc)»
- «helpers.UserCode(pc.userCode2)»
+ «helpers.userCode(pc.userCode2)»
private static String messageStrings[] = {"MIN", «FOR m : pc.getAllOutgoingMessages()»"«m.name»",«ENDFOR» «FOR m : pc.getAllIncomingMessages()»"«m.name»",«ENDFOR»"MAX"};
@@ -106,7 +95,7 @@ class ProtocolClassGen {
// port class
static public class «name» extends PortBase {
«IF pclass!=null»
- «helpers.UserCode(pclass.userCode)»
+ «helpers.userCode(pclass.userCode)»
«ENDIF»
// constructors
public «name»(IEventReceiver actor, String name, int localId, Address addr, Address peerAddress) {
@@ -127,7 +116,7 @@ class ProtocolClassGen {
System.out.println("unknown");
else {
if (messageStrings[msg.getEvtId()] != "timerTick"){
- // TODOTS: model switch for activation
+««« TODOTS: model switch for activation
DebuggingService.getInstance().addMessageAsyncIn(getPeerAddress(), getAddress(), messageStrings[msg.getEvtId()]);
}
«IF pc.handlesReceive(conj)»
@@ -154,8 +143,8 @@ class ProtocolClassGen {
}
«IF pclass!=null»
- «helpers.Attributes(pclass.attributes)»
- «helpers.OperationsImplementation(pclass.operations, name)»
+ «helpers.attributes(pclass.attributes)»
+ «helpers.operationsImplementation(pclass.operations, name)»
«ENDIF»
// sent messages
@@ -250,7 +239,7 @@ class ProtocolClassGen {
«ENDFOR»
«ELSE»
if (messageStrings[ «dir»_«m.name»] != "timerTick"){
- // TODOTS: model switch for activation
+««« TODOTS: model switch for activation
DebuggingService.getInstance().addMessageAsyncOut(getAddress(), getPeerAddress(), messageStrings[«dir»_«m.name»]);
}
if (getPeerAddress()!=null)
diff --git a/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/StateMachineGen.xtend b/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/StateMachineGen.xtend
index 23f94c57a..463899e10 100644
--- a/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/StateMachineGen.xtend
+++ b/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/StateMachineGen.xtend
@@ -14,245 +14,37 @@ package org.eclipse.etrice.generator.java.gen
import com.google.inject.Inject
import com.google.inject.Singleton
-import java.util.List
import org.eclipse.etrice.core.room.ActorClass
-import org.eclipse.etrice.core.room.NonInitialTransition
-import org.eclipse.etrice.core.room.Transition
-import org.eclipse.etrice.core.room.TriggeredTransition
import org.eclipse.etrice.generator.etricegen.ExpandedActorClass
-import org.eclipse.etrice.generator.etricegen.TransitionChain
import static extension org.eclipse.etrice.generator.extensions.RoomNameProv.*
import org.eclipse.etrice.generator.extensions.RoomExtensions
-import org.eclipse.etrice.generator.generic.TypeHelpers
+import org.eclipse.etrice.generator.generic.GenericStateMachineGenerator
@Singleton
-class StateMachineGen {
+class StateMachineGen extends GenericStateMachineGenerator {
- @Inject extension JavaExtensions stdExt
- @Inject extension RoomExtensions roomExt
- @Inject extension TypeHelpers
- @Inject org.eclipse.etrice.generator.generic.LanguageGenerator languageGen
+ @Inject extension RoomExtensions
- def genStateMachine(ExpandedActorClass xpac, ActorClass ac) {'''
- //******************************************
- // START of generated code for FSM
- //******************************************
-
- // State IDs for FSM
- «var offset = ac.getNumberOfInheritedBaseStates()»
- «var baseStates = ac.stateMachine.getBaseStateList()»
- «FOR state : baseStates»
- protected static final int «state.getStateId()» = «baseStates.indexOf(state)+2+offset»;
- «ENDFOR»
- protected static final String stateStrings[] = {"<no state>","<top>",«FOR state : ac.getAllBaseStates() SEPARATOR ","»"«state.getStatePathName()»"
+ override genExtra(ExpandedActorClass xpac, ActorClass ac) {'''
+ // state names
+ protected static final String stateStrings[] = {"<no state>","<top>",«FOR state : ac.getAllBaseStatesLeavesFirst() SEPARATOR ","»"«state.getStatePathName()»"
«ENDFOR»};
+««« TODOHRR: history defined in ActorClassBase, init in constructor
+««« history = new int[5];
+««« for (int i = 0; i < history.length; i++) {
+««« history[i] = NO_STATE;
+««« }
// history
- // TODOHRR: history defined in ActorClassBase, init in constructor
- // history = new int[5];
- // for (int i = 0; i < history.length; i++) {
- // history[i] = NO_STATE;
- // }
protected int history[] = {NO_STATE,NO_STATE«FOR state : ac.getAllBaseStates()»,NO_STATE«ENDFOR»};
- «var List<TransitionChain> chains = xpac.getOwnTransitionChains()»
- «var offset_tc = xpac.getTransitionChains().size-chains.size»
- // transition chains
- «FOR tc : chains»
- protected static final int «tc.getChainId()» = «chains.indexOf(tc)+1+offset_tc»;
- «ENDFOR»
-
- «var triggers = xpac.getOwnTriggers()»
- // triggers for FSM
- «FOR mif : triggers»protected static final int «xpac.getTriggerCodeName(mif)» = IFITEM_«mif.from.name» + EVT_SHIFT*«xpac.getMessageID(mif)»;
- «ENDFOR»
-
- // receiveEvent contains the main implementation of the FSM
- @Override
- public void receiveEvent(InterfaceItemBase ifitem, int evt, Object generic_data) {
- int trigger = ifitem.getLocalId() + EVT_SHIFT*evt;
- int chain = NOT_CAUGHT;
- int catching_state = NO_STATE;
- boolean is_handler = false;
- boolean skip_entry = false;
-
- if (!handleSystemEvent(ifitem, evt, generic_data)) {
- switch (state) {
- «FOR state : xpac.stateMachine.getLeafStateList()»
- case «state.getStateId()»:
- «var atlist = xpac.getActiveTriggers(state)»
- «IF !atlist.isEmpty»
- switch(trigger) {
- «FOR at : atlist»
- case «xpac.getTriggerCodeName(at.trigger)»:
- «var needData = xpac.hasGuard(at)»
- «IF needData»{ «at.msg.getTypedDataDefinition()»«ENDIF»
- «FOR tt : at.transitions SEPARATOR " else "»
- «var chain = xpac.getChain(tt)»
- «guard(chain.transition, at.trigger, xpac)»
- {
- chain = «chain.getChainId()»;
- catching_state = «chain.getContextId()»;
- «IF chain.isHandler()»is_handler = true;«ENDIF»
- «IF chain.skipEntry»skip_entry = true;«ENDIF»
- }
- «ENDFOR»
- «IF needData»}«ENDIF»
- break;
- «ENDFOR»
- }
- «ENDIF»
- break;
- «ENDFOR»
- }
- }
- if (chain != NOT_CAUGHT) {
- exitTo(state, catching_state, is_handler);
- int next = executeTransitionChain(chain, ifitem, generic_data);
- next = enterHistory(next, is_handler, skip_entry);
- setState(next);
- }
- }
-
private void setState(int new_state) {
DebuggingService.getInstance().addActorState(this,stateStrings[new_state]);
if (stateStrings[new_state]!="Idle") {
- // TODOTS: model switch for activation
+««« TODOTS: model switch for activation
System.out.println(getInstancePath() + " -> " + stateStrings[new_state]);
}
this.state = new_state;
}
-
- @Override
- public void executeInitTransition() {
- «var initt = xpac.stateMachine.getInitTransition()»
- int chain = «xpac.getChain(initt).getChainId()»;
- int next = executeTransitionChain(chain, null, null);
- next = enterHistory(next, false, false);
- setState(next);
- }
-
- /**
- * calls exit codes while exiting from the current state to one of its
- * parent states while remembering the history
- * @param current - the current state
- * @param to - the final parent state
- * @param handler - entry and exit codes are called only if not handler (for handler TransitionPoints)
- */
- private void exitTo(int current, int to, boolean handler) {
- while (current!=to) {
- switch (current) {
- «FOR state : xpac.stateMachine.getBaseStateList()»
- case «state.getStateId()»:
- «IF state.hasExitCode()»if (!handler) «state.getExitCodeOperationName()»();«ENDIF»
- history[«state.getParentStateId()»] = «state.getStateId()»;
- current = «state.getParentStateId()»;
- break;
- «ENDFOR»
- }
- }
- }
- /**
- * calls action, entry and exit codes along a transition chain. The generic data are cast to typed data
- * matching the trigger of this chain. The ID of the final state is returned
- * @param chain - the chain ID
- * @param generic_data - the generic data pointer
- * @return the ID of the final state
- */
- private int executeTransitionChain(int chain, InterfaceItemBase ifitem, Object generic_data) {
- switch (chain) {
- «var allchains = xpac.getTransitionChains()»
- «FOR tc : allchains»
- case «tc.getChainId()»:
- {
- «xpac.getExecuteChainCode(tc)»
- }
- «ENDFOR»
- }
- return NO_STATE;
- }
- /**
- * calls entry codes while entering a state's history. The ID of the final leaf state is returned
- * @param state - the state which is entered
- * @param handler - entry code is executed if not handler
- * @return - the ID of the final leaf state
- */
- private int enterHistory(int state, boolean handler, boolean skip_entry) {
- while (true) {
- switch (state) {
- «FOR state : xpac.stateMachine.getBaseStateList()»
- case «state.getStateId()»:
- «IF state.hasEntryCode()»if (!(skip_entry || handler)) «state.getEntryCodeOperationName()»();«ENDIF»
- «IF state.isLeaf()»
- // in leaf state: return state id
- return «state.getStateId()»;
- «ELSE»
- // state has a sub graph
- «IF state.subgraph.hasInitTransition()»
- // with init transition
- if (history[«state.getStateId()»]==NO_STATE) {
- «var sub_initt = state.subgraph.getInitTransition()»
- state = executeTransitionChain(«xpac.getChain(sub_initt).getChainId()», null, null);
- }
- else {
- state = history[«state.getStateId()»];
- }
- «ELSE»
- // without init transition
- state = history[«state.getStateId()»];
- «ENDIF»
- break;
- «ENDIF»
- «ENDFOR»
- case STATE_TOP:
- state = history[STATE_TOP];
- break;
- }
- skip_entry = false;
- }
- //return NO_STATE; // required by CDT but detected as unreachable by JDT because of while (true)
- }
-
- //*** Entry and Exit Codes
- «FOR state : xpac.stateMachine.getStateList()»
- «IF xpac.isOwnObject(state)»
- «IF state.hasEntryCode()»
- protected void «state.getEntryCodeOperationName()»() {
- «xpac.getEntryCode(state)»
- }
- «ENDIF»
- «IF state.hasExitCode()»
- protected void «state.getExitCodeOperationName()»() {
- «xpac.getExitCode(state)»
- }
- «ENDIF»
- «ENDIF»
- «ENDFOR»
-
- //*** Action Codes
- «FOR tr : xpac.stateMachine.getTransitionList()»
- «IF xpac.isOwnObject(tr) && tr.hasActionCode()»
- protected void «tr.getActionCodeOperationName()»(«IF tr instanceof NonInitialTransition»InterfaceItemBase ifitem«languageGen.getArgumentList(xpac, tr)»«ENDIF») {
- «xpac.getActionCode(tr)»
- }
- «ENDIF»
- «ENDFOR»
-
- //******************************************
- // END of generated code for FSM
- //******************************************
'''}
-
- def dispatch guard(TriggeredTransition tt, String trigger, ExpandedActorClass ac) {'''
- «var tr = tt.triggers.findFirst(e|ac.isMatching(e, trigger))»
- «IF tr.hasGuard()»
- if («ac.getCode(tr.guard.guard)»)
- «ENDIF»
- '''
- }
-
- def dispatch guard(Transition t, String trigger, ExpandedActorClass ac) {'''
- /* error */
- '''
- }
}
diff --git a/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/SubSystemClassGen.xtend b/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/SubSystemClassGen.xtend
index ec915e98d..c0cfeed8e 100644
--- a/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/SubSystemClassGen.xtend
+++ b/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/SubSystemClassGen.xtend
@@ -62,11 +62,11 @@ class SubSystemClassGen {
«FOR model : models»import «model.name».*;«ENDFOR»
- «helpers.UserCode(cc.userCode1)»
+ «helpers.userCode(cc.userCode1)»
public class «comp.name» extends SubSystemClassBase{
- «helpers.UserCode(cc.userCode2)»
+ «helpers.userCode(cc.userCode2)»
public «comp.name»(IRTObject parent, String name) {
super(parent, name);
diff --git a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/ActorClassGen.java b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/ActorClassGen.java
index 0b9b4bb78..8b63bdc54 100644
--- a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/ActorClassGen.java
+++ b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/ActorClassGen.java
@@ -7,7 +7,6 @@ import org.eclipse.emf.common.util.EList;
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.Message;
import org.eclipse.etrice.core.room.Port;
import org.eclipse.etrice.core.room.ProtocolClass;
import org.eclipse.etrice.core.room.RoomModel;
@@ -16,25 +15,24 @@ import org.eclipse.etrice.core.room.SPPRef;
import org.eclipse.etrice.core.room.ServiceImplementation;
import org.eclipse.etrice.core.room.StandardOperation;
import org.eclipse.etrice.core.room.StateGraph;
-import org.eclipse.etrice.core.room.VarDecl;
import org.eclipse.etrice.generator.base.ILogger;
import org.eclipse.etrice.generator.etricegen.ExpandedActorClass;
import org.eclipse.etrice.generator.etricegen.Root;
import org.eclipse.etrice.generator.extensions.RoomExtensions;
+import org.eclipse.etrice.generator.generic.GenericActorClassGenerator;
import org.eclipse.etrice.generator.generic.ProcedureHelpers;
import org.eclipse.etrice.generator.generic.TypeHelpers;
import org.eclipse.etrice.generator.java.gen.JavaExtensions;
import org.eclipse.etrice.generator.java.gen.StateMachineGen;
import org.eclipse.xtext.generator.JavaIoFileSystemAccess;
import org.eclipse.xtext.xbase.lib.BooleanExtensions;
-import org.eclipse.xtext.xbase.lib.IntegerExtensions;
import org.eclipse.xtext.xbase.lib.ObjectExtensions;
import org.eclipse.xtext.xbase.lib.StringExtensions;
import org.eclipse.xtext.xtend2.lib.StringConcatenation;
@SuppressWarnings("all")
@Singleton
-public class ActorClassGen {
+public class ActorClassGen extends GenericActorClassGenerator {
@Inject
private JavaIoFileSystemAccess fileAccess;
@@ -131,8 +129,8 @@ public class ActorClassGen {
}
_builder.newLine();
DetailCode _userCode1 = ac.getUserCode1();
- StringConcatenation _UserCode = this.helpers.UserCode(_userCode1);
- _builder.append(_UserCode, "");
+ StringConcatenation _userCode = this.helpers.userCode(_userCode1);
+ _builder.append(_userCode, "");
_builder.newLineIfNotEmpty();
_builder.newLine();
_builder.newLine();
@@ -163,8 +161,8 @@ public class ActorClassGen {
_builder.newLine();
_builder.append("\t");
DetailCode _userCode2 = ac.getUserCode2();
- StringConcatenation _UserCode_1 = this.helpers.UserCode(_userCode2);
- _builder.append(_UserCode_1, " ");
+ StringConcatenation _userCode_1 = this.helpers.userCode(_userCode2);
+ _builder.append(_userCode_1, " ");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.newLine();
@@ -224,65 +222,22 @@ public class ActorClassGen {
_builder.append("\t");
_builder.append("//--------------------- interface item IDs");
_builder.newLine();
- {
- List<Port> _endPorts_1 = this.roomExt.getEndPorts(ac);
- for(final Port ep_1 : _endPorts_1) {
- _builder.append("\t");
- _builder.append("protected static final int IFITEM_");
- String _name_7 = ep_1.getName();
- _builder.append(_name_7, " ");
- _builder.append(" = ");
- int _interfaceItemLocalId = xpac.getInterfaceItemLocalId(ep_1);
- int _operator_plus = IntegerExtensions.operator_plus(((Integer)_interfaceItemLocalId), ((Integer)1));
- _builder.append(_operator_plus, " ");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- }
- }
- {
- EList<SAPRef> _strSAPs_1 = ac.getStrSAPs();
- for(final SAPRef sap_1 : _strSAPs_1) {
- _builder.append("\t");
- _builder.append("protected static final int IFITEM_");
- String _name_8 = sap_1.getName();
- _builder.append(_name_8, " ");
- _builder.append(" = ");
- int _interfaceItemLocalId_1 = xpac.getInterfaceItemLocalId(sap_1);
- int _operator_plus_1 = IntegerExtensions.operator_plus(((Integer)_interfaceItemLocalId_1), ((Integer)1));
- _builder.append(_operator_plus_1, " ");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- }
- }
- {
- EList<ServiceImplementation> _serviceImplementations_1 = ac.getServiceImplementations();
- for(final ServiceImplementation svc_1 : _serviceImplementations_1) {
- _builder.append("\t");
- _builder.append("protected static final int IFITEM_");
- SPPRef _spp_1 = svc_1.getSpp();
- String _name_9 = _spp_1.getName();
- _builder.append(_name_9, " ");
- _builder.append(" = ");
- SPPRef _spp_2 = svc_1.getSpp();
- int _interfaceItemLocalId_2 = xpac.getInterfaceItemLocalId(_spp_2);
- int _operator_plus_2 = IntegerExtensions.operator_plus(((Integer)_interfaceItemLocalId_2), ((Integer)1));
- _builder.append(_operator_plus_2, " ");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- }
- }
_builder.append("\t");
+ String _genInterfaceItemConstants = this.genInterfaceItemConstants(xpac, ac);
+ _builder.append(_genInterfaceItemConstants, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
_builder.newLine();
_builder.append("\t");
EList<Attribute> _attributes = ac.getAttributes();
- StringConcatenation _Attributes = this.helpers.Attributes(_attributes);
- _builder.append(_Attributes, " ");
+ StringConcatenation _attributes_1 = this.helpers.attributes(_attributes);
+ _builder.append(_attributes_1, " ");
_builder.newLineIfNotEmpty();
_builder.append("\t");
EList<StandardOperation> _operations = ac.getOperations();
- String _name_10 = ac.getName();
- StringConcatenation _OperationsImplementation = this.helpers.OperationsImplementation(_operations, _name_10);
- _builder.append(_OperationsImplementation, " ");
+ String _name_7 = ac.getName();
+ StringConcatenation _operationsImplementation = this.helpers.operationsImplementation(_operations, _name_7);
+ _builder.append(_operationsImplementation, " ");
_builder.newLineIfNotEmpty();
_builder.newLine();
_builder.append("\t");
@@ -290,8 +245,8 @@ public class ActorClassGen {
_builder.newLine();
_builder.append("\t");
_builder.append("public ");
- String _name_11 = ac.getName();
- _builder.append(_name_11, " ");
+ String _name_8 = ac.getName();
+ _builder.append(_name_8, " ");
_builder.append("(IRTObject parent, String name, Address[][] port_addr, Address[][] peer_addr){");
_builder.newLineIfNotEmpty();
{
@@ -309,15 +264,15 @@ public class ActorClassGen {
}
_builder.append("\t\t");
_builder.append("setClassName(\"");
- String _name_12 = ac.getName();
- _builder.append(_name_12, " ");
+ String _name_9 = ac.getName();
+ _builder.append(_name_9, " ");
_builder.append("\");");
_builder.newLineIfNotEmpty();
_builder.append("\t\t");
_builder.newLine();
_builder.append("\t\t");
- EList<Attribute> _attributes_1 = ac.getAttributes();
- StringConcatenation _attributeInitialization = this.helpers.attributeInitialization(_attributes_1);
+ EList<Attribute> _attributes_2 = ac.getAttributes();
+ StringConcatenation _attributeInitialization = this.helpers.attributeInitialization(_attributes_2);
_builder.append(_attributeInitialization, " ");
_builder.newLineIfNotEmpty();
_builder.newLine();
@@ -325,45 +280,45 @@ public class ActorClassGen {
_builder.append("// own ports");
_builder.newLine();
{
- List<Port> _endPorts_2 = this.roomExt.getEndPorts(ac);
- for(final Port ep_2 : _endPorts_2) {
+ List<Port> _endPorts_1 = this.roomExt.getEndPorts(ac);
+ for(final Port ep_1 : _endPorts_1) {
_builder.append("\t\t");
- String _name_13 = ep_2.getName();
- _builder.append(_name_13, " ");
+ String _name_10 = ep_1.getName();
+ _builder.append(_name_10, " ");
_builder.append(" = new ");
- String _portClassName_3 = this.roomExt.getPortClassName(ep_2);
+ String _portClassName_3 = this.roomExt.getPortClassName(ep_1);
_builder.append(_portClassName_3, " ");
_builder.append("(this, \"");
- String _name_14 = ep_2.getName();
- _builder.append(_name_14, " ");
+ String _name_11 = ep_1.getName();
+ _builder.append(_name_11, " ");
_builder.append("\", IFITEM_");
- String _name_15 = ep_2.getName();
- _builder.append(_name_15, " ");
+ String _name_12 = ep_1.getName();
+ _builder.append(_name_12, " ");
_builder.append(", ");
{
- int _multiplicity = ep_2.getMultiplicity();
+ int _multiplicity = ep_1.getMultiplicity();
boolean _operator_equals_1 = ObjectExtensions.operator_equals(((Integer)_multiplicity), ((Integer)1));
if (_operator_equals_1) {
_builder.append("0, ");
}
}
_builder.append("port_addr[IFITEM_");
- String _name_16 = ep_2.getName();
- _builder.append(_name_16, " ");
+ String _name_13 = ep_1.getName();
+ _builder.append(_name_13, " ");
_builder.append("]");
{
- int _multiplicity_1 = ep_2.getMultiplicity();
+ int _multiplicity_1 = ep_1.getMultiplicity();
boolean _operator_equals_2 = ObjectExtensions.operator_equals(((Integer)_multiplicity_1), ((Integer)1));
if (_operator_equals_2) {
_builder.append("[0]");
}
}
_builder.append(", peer_addr[IFITEM_");
- String _name_17 = ep_2.getName();
- _builder.append(_name_17, " ");
+ String _name_14 = ep_1.getName();
+ _builder.append(_name_14, " ");
_builder.append("]");
{
- int _multiplicity_2 = ep_2.getMultiplicity();
+ int _multiplicity_2 = ep_1.getMultiplicity();
boolean _operator_equals_3 = ObjectExtensions.operator_equals(((Integer)_multiplicity_2), ((Integer)1));
if (_operator_equals_3) {
_builder.append("[0]");
@@ -377,26 +332,26 @@ public class ActorClassGen {
_builder.append("// own saps");
_builder.newLine();
{
- EList<SAPRef> _strSAPs_2 = ac.getStrSAPs();
- for(final SAPRef sap_2 : _strSAPs_2) {
+ EList<SAPRef> _strSAPs_1 = ac.getStrSAPs();
+ for(final SAPRef sap_1 : _strSAPs_1) {
_builder.append("\t\t");
- String _name_18 = sap_2.getName();
- _builder.append(_name_18, " ");
+ String _name_15 = sap_1.getName();
+ _builder.append(_name_15, " ");
_builder.append(" = new ");
- String _portClassName_4 = this.roomExt.getPortClassName(sap_2);
+ String _portClassName_4 = this.roomExt.getPortClassName(sap_1);
_builder.append(_portClassName_4, " ");
_builder.append("(this, \"");
- String _name_19 = sap_2.getName();
- _builder.append(_name_19, " ");
+ String _name_16 = sap_1.getName();
+ _builder.append(_name_16, " ");
_builder.append("\", IFITEM_");
- String _name_20 = sap_2.getName();
- _builder.append(_name_20, " ");
+ String _name_17 = sap_1.getName();
+ _builder.append(_name_17, " ");
_builder.append(", 0, port_addr[IFITEM_");
- String _name_21 = sap_2.getName();
- _builder.append(_name_21, " ");
+ String _name_18 = sap_1.getName();
+ _builder.append(_name_18, " ");
_builder.append("][0], peer_addr[IFITEM_");
- String _name_22 = sap_2.getName();
- _builder.append(_name_22, " ");
+ String _name_19 = sap_1.getName();
+ _builder.append(_name_19, " ");
_builder.append("][0]); ");
_builder.newLineIfNotEmpty();
}
@@ -405,31 +360,31 @@ public class ActorClassGen {
_builder.append("// own service implementations");
_builder.newLine();
{
- EList<ServiceImplementation> _serviceImplementations_2 = ac.getServiceImplementations();
- for(final ServiceImplementation svc_2 : _serviceImplementations_2) {
+ EList<ServiceImplementation> _serviceImplementations_1 = ac.getServiceImplementations();
+ for(final ServiceImplementation svc_1 : _serviceImplementations_1) {
_builder.append("\t\t");
- SPPRef _spp_3 = svc_2.getSpp();
- String _name_23 = _spp_3.getName();
- _builder.append(_name_23, " ");
+ SPPRef _spp_1 = svc_1.getSpp();
+ String _name_20 = _spp_1.getName();
+ _builder.append(_name_20, " ");
_builder.append(" = new ");
- String _portClassName_5 = this.roomExt.getPortClassName(svc_2);
+ String _portClassName_5 = this.roomExt.getPortClassName(svc_1);
_builder.append(_portClassName_5, " ");
_builder.append("(this, \"");
- SPPRef _spp_4 = svc_2.getSpp();
- String _name_24 = _spp_4.getName();
- _builder.append(_name_24, " ");
+ SPPRef _spp_2 = svc_1.getSpp();
+ String _name_21 = _spp_2.getName();
+ _builder.append(_name_21, " ");
_builder.append("\", IFITEM_");
- SPPRef _spp_5 = svc_2.getSpp();
- String _name_25 = _spp_5.getName();
- _builder.append(_name_25, " ");
+ SPPRef _spp_3 = svc_1.getSpp();
+ String _name_22 = _spp_3.getName();
+ _builder.append(_name_22, " ");
_builder.append(", port_addr[IFITEM_");
- SPPRef _spp_6 = svc_2.getSpp();
- String _name_26 = _spp_6.getName();
- _builder.append(_name_26, " ");
+ SPPRef _spp_4 = svc_1.getSpp();
+ String _name_23 = _spp_4.getName();
+ _builder.append(_name_23, " ");
_builder.append("], peer_addr[IFITEM_");
- SPPRef _spp_7 = svc_2.getSpp();
- String _name_27 = _spp_7.getName();
- _builder.append(_name_27, " ");
+ SPPRef _spp_5 = svc_1.getSpp();
+ String _name_24 = _spp_5.getName();
+ _builder.append(_name_24, " ");
_builder.append("]); ");
_builder.newLineIfNotEmpty();
}
@@ -536,18 +491,4 @@ public class ActorClassGen {
_builder.newLine();
return _builder;
}
-
- public StringConcatenation msgArgs(final Message msg) {
- StringConcatenation _builder = new StringConcatenation();
- {
- VarDecl _data = msg.getData();
- boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_data, null);
- if (_operator_notEquals) {
- VarDecl _data_1 = msg.getData();
- String _defaultValue = this._typeHelpers.defaultValue(_data_1);
- _builder.append(_defaultValue, "");
- }
- }
- return _builder;
- }
}
diff --git a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/DataClassGen.java b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/DataClassGen.java
index 491ab4c25..fafac19ed 100644
--- a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/DataClassGen.java
+++ b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/DataClassGen.java
@@ -88,8 +88,8 @@ public class DataClassGen {
}
_builder.newLine();
DetailCode _userCode1 = dc.getUserCode1();
- StringConcatenation _UserCode = this.helpers.UserCode(_userCode1);
- _builder.append(_UserCode, "");
+ StringConcatenation _userCode = this.helpers.userCode(_userCode1);
+ _builder.append(_userCode, "");
_builder.newLineIfNotEmpty();
_builder.newLine();
_builder.newLine();
@@ -112,31 +112,31 @@ public class DataClassGen {
_builder.newLine();
_builder.append("\t");
DetailCode _userCode2 = dc.getUserCode2();
- StringConcatenation _UserCode_1 = this.helpers.UserCode(_userCode2);
- _builder.append(_UserCode_1, " ");
+ StringConcatenation _userCode_1 = this.helpers.userCode(_userCode2);
+ _builder.append(_userCode_1, " ");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.newLine();
_builder.append("\t");
EList<Attribute> _attributes = dc.getAttributes();
- StringConcatenation _Attributes = this.helpers.Attributes(_attributes);
- _builder.append(_Attributes, " ");
+ StringConcatenation _attributes_1 = this.helpers.attributes(_attributes);
+ _builder.append(_attributes_1, " ");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.newLine();
_builder.append("\t");
- EList<Attribute> _attributes_1 = dc.getAttributes();
+ EList<Attribute> _attributes_2 = dc.getAttributes();
String _name_3 = dc.getName();
- StringConcatenation _AttributeSettersGettersImplementation = this.helpers.AttributeSettersGettersImplementation(_attributes_1, _name_3);
- _builder.append(_AttributeSettersGettersImplementation, " ");
+ StringConcatenation _attributeSettersGettersImplementation = this.helpers.attributeSettersGettersImplementation(_attributes_2, _name_3);
+ _builder.append(_attributeSettersGettersImplementation, " ");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.newLine();
_builder.append("\t");
EList<StandardOperation> _operations = dc.getOperations();
String _name_4 = dc.getName();
- StringConcatenation _OperationsImplementation = this.helpers.OperationsImplementation(_operations, _name_4);
- _builder.append(_OperationsImplementation, " ");
+ StringConcatenation _operationsImplementation = this.helpers.operationsImplementation(_operations, _name_4);
+ _builder.append(_operationsImplementation, " ");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.newLine();
@@ -155,8 +155,8 @@ public class DataClassGen {
_builder.append("\t\t");
_builder.newLine();
_builder.append("\t\t");
- EList<Attribute> _attributes_2 = dc.getAttributes();
- StringConcatenation _attributeInitialization = this.helpers.attributeInitialization(_attributes_2);
+ EList<Attribute> _attributes_3 = dc.getAttributes();
+ StringConcatenation _attributeInitialization = this.helpers.attributeInitialization(_attributes_3);
_builder.append(_attributeInitialization, " ");
_builder.newLineIfNotEmpty();
_builder.append("\t");
@@ -196,8 +196,8 @@ public class DataClassGen {
_builder.append("\t\t");
_builder.newLine();
{
- EList<Attribute> _attributes_3 = dc.getAttributes();
- for(final Attribute a : _attributes_3) {
+ EList<Attribute> _attributes_4 = dc.getAttributes();
+ for(final Attribute a : _attributes_4) {
_builder.append("\t\t");
_builder.append("this.");
String _name_7 = a.getName();
diff --git a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/JavaExtensions.java b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/JavaExtensions.java
index 91db89536..04905d5dd 100644
--- a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/JavaExtensions.java
+++ b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/JavaExtensions.java
@@ -2,13 +2,16 @@ package org.eclipse.etrice.generator.java.gen;
import com.google.inject.Inject;
import com.google.inject.Singleton;
+import java.util.List;
import org.eclipse.etrice.core.room.Message;
import org.eclipse.etrice.core.room.RoomClass;
import org.eclipse.etrice.generator.etricegen.ExpandedActorClass;
import org.eclipse.etrice.generator.etricegen.TransitionChain;
import org.eclipse.etrice.generator.generic.ILanguageExtension;
import org.eclipse.etrice.generator.generic.LanguageGenerator;
+import org.eclipse.xtext.util.Pair;
import org.eclipse.xtext.xbase.lib.StringExtensions;
+import org.eclipse.xtext.xtend2.lib.StringConcatenation;
@SuppressWarnings("all")
@Singleton
@@ -43,7 +46,11 @@ public class JavaExtensions implements ILanguageExtension {
return "this.";
}
- public String selfPointer(final String classname, final int argumentCount) {
+ public String selfPointer(final String classname, final boolean hasArgs) {
+ return "";
+ }
+
+ public String selfPointer(final boolean hasArgs) {
return "";
}
@@ -51,14 +58,49 @@ public class JavaExtensions implements ILanguageExtension {
return "";
}
- public String outMessageId(final String classname, final String messagename) {
- String _operator_plus = StringExtensions.operator_plus("OUT_", messagename);
- return _operator_plus;
+ public String memberInDeclaration(final String namespace, final String member) {
+ return member;
}
- public String inMessageId(final String classname, final String messagename) {
- String _operator_plus = StringExtensions.operator_plus("IN_", messagename);
- return _operator_plus;
+ public String memberInUse(final String namespace, final String member) {
+ String _operator_plus = StringExtensions.operator_plus(namespace, ".");
+ String _operator_plus_1 = StringExtensions.operator_plus(_operator_plus, member);
+ return _operator_plus_1;
+ }
+
+ public boolean usesInheritance() {
+ return true;
+ }
+
+ public String genEnumeration(final String name, final List<Pair<String,String>> entries) {
+ StringConcatenation _builder = new StringConcatenation();
+ {
+ for(final Pair<String,String> entry : entries) {
+ _builder.append("public static final int ");
+ String _first = entry.getFirst();
+ _builder.append(_first, "");
+ _builder.append(" = ");
+ String _second = entry.getSecond();
+ _builder.append(_second, "");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ String _string = _builder.toString();
+ return _string;
+ }
+
+ public String booleanConstant(final boolean b) {
+ String _string = ((Boolean)b).toString();
+ return _string;
+ }
+
+ public String nullPointer() {
+ return "null";
+ }
+
+ public String voidPointer() {
+ return "Object";
}
public String getExecuteChainCode(final ExpandedActorClass ac, final TransitionChain tc) {
diff --git a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/ProtocolClassGen.java b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/ProtocolClassGen.java
index 4b4c10a6b..a7e5011a1 100644
--- a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/ProtocolClassGen.java
+++ b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/ProtocolClassGen.java
@@ -20,20 +20,20 @@ import org.eclipse.etrice.core.room.VarDecl;
import org.eclipse.etrice.generator.base.ILogger;
import org.eclipse.etrice.generator.etricegen.Root;
import org.eclipse.etrice.generator.extensions.RoomExtensions;
+import org.eclipse.etrice.generator.generic.GenericProtocolClassGenerator;
import org.eclipse.etrice.generator.generic.ProcedureHelpers;
import org.eclipse.etrice.generator.generic.TypeHelpers;
import org.eclipse.etrice.generator.java.gen.JavaExtensions;
import org.eclipse.xtext.generator.JavaIoFileSystemAccess;
import org.eclipse.xtext.xbase.lib.BooleanExtensions;
import org.eclipse.xtext.xbase.lib.ComparableExtensions;
-import org.eclipse.xtext.xbase.lib.IntegerExtensions;
import org.eclipse.xtext.xbase.lib.ObjectExtensions;
import org.eclipse.xtext.xbase.lib.StringExtensions;
import org.eclipse.xtext.xtend2.lib.StringConcatenation;
@SuppressWarnings("all")
@Singleton
-public class ProtocolClassGen {
+public class ProtocolClassGen extends GenericProtocolClassGenerator {
@Inject
private JavaIoFileSystemAccess fileAccess;
@@ -95,8 +95,8 @@ public class ProtocolClassGen {
_builder.newLine();
_builder.newLine();
DetailCode _userCode1 = pc.getUserCode1();
- StringConcatenation _UserCode = this.helpers.UserCode(_userCode1);
- _builder.append(_UserCode, "");
+ StringConcatenation _userCode = this.helpers.userCode(_userCode1);
+ _builder.append(_userCode, "");
_builder.newLineIfNotEmpty();
_builder.newLine();
EList<RoomModel> _referencedModels = root.getReferencedModels(pc);
@@ -121,98 +121,34 @@ public class ProtocolClassGen {
_builder.append("// message IDs");
_builder.newLine();
_builder.append("\t");
- _builder.append("// TODO: separate class for message IDs: class MSG{public static volatile int MSG_MIN = 0; ...} -> better structure");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("// error if msgID <= MSG_MIN");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("public static final int MSG_MIN = 0; ");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("//IDs for outgoing messages");
- _builder.newLine();
- {
- List<Message> _allOutgoingMessages = this.roomExt.getAllOutgoingMessages(pc);
- for(final Message message : _allOutgoingMessages) {
- _builder.append("\t");
- _builder.append("public static final int ");
- String _name_2 = pc.getName();
- String _name_3 = message.getName();
- String _outMessageId = this.stdExt.outMessageId(_name_2, _name_3);
- _builder.append(_outMessageId, " ");
- _builder.append(" = ");
- List<Message> _allOutgoingMessages_1 = this.roomExt.getAllOutgoingMessages(pc);
- int _indexOf = _allOutgoingMessages_1.indexOf(message);
- int _operator_plus = IntegerExtensions.operator_plus(((Integer)_indexOf), ((Integer)1));
- _builder.append(_operator_plus, " ");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("\t");
- _builder.append("//IDs for incoming messages");
- _builder.newLine();
- {
- List<Message> _allIncomingMessages = this.roomExt.getAllIncomingMessages(pc);
- for(final Message message_1 : _allIncomingMessages) {
- _builder.append("\t");
- _builder.append("public static final int ");
- String _name_4 = pc.getName();
- String _name_5 = message_1.getName();
- String _inMessageId = this.stdExt.inMessageId(_name_4, _name_5);
- _builder.append(_inMessageId, " ");
- _builder.append(" = ");
- List<Message> _allIncomingMessages_1 = this.roomExt.getAllIncomingMessages(pc);
- int _indexOf_1 = _allIncomingMessages_1.indexOf(message_1);
- List<Message> _allOutgoingMessages_2 = this.roomExt.getAllOutgoingMessages(pc);
- int _size = _allOutgoingMessages_2.size();
- int _operator_plus_1 = IntegerExtensions.operator_plus(((Integer)_indexOf_1), ((Integer)_size));
- int _operator_plus_2 = IntegerExtensions.operator_plus(((Integer)_operator_plus_1), ((Integer)1));
- _builder.append(_operator_plus_2, " ");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("\t");
- _builder.append("//error if msgID >= MSG_MAX");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("public static final int MSG_MAX = ");
- List<Message> _allOutgoingMessages_3 = this.roomExt.getAllOutgoingMessages(pc);
- int _size_1 = _allOutgoingMessages_3.size();
- List<Message> _allIncomingMessages_2 = this.roomExt.getAllIncomingMessages(pc);
- int _size_2 = _allIncomingMessages_2.size();
- int _operator_plus_3 = IntegerExtensions.operator_plus(((Integer)_size_1), ((Integer)_size_2));
- int _operator_plus_4 = IntegerExtensions.operator_plus(((Integer)_operator_plus_3), ((Integer)1));
- _builder.append(_operator_plus_4, " ");
- _builder.append("; ");
+ String _genMessageIDs = this.genMessageIDs(pc);
+ _builder.append(_genMessageIDs, " ");
_builder.newLineIfNotEmpty();
_builder.newLine();
_builder.append("\t");
DetailCode _userCode2 = pc.getUserCode2();
- StringConcatenation _UserCode_1 = this.helpers.UserCode(_userCode2);
- _builder.append(_UserCode_1, " ");
+ StringConcatenation _userCode_1 = this.helpers.userCode(_userCode2);
+ _builder.append(_userCode_1, " ");
_builder.newLineIfNotEmpty();
_builder.newLine();
_builder.append("\t");
_builder.append("private static String messageStrings[] = {\"MIN\", ");
{
- List<Message> _allOutgoingMessages_4 = this.roomExt.getAllOutgoingMessages(pc);
- for(final Message m : _allOutgoingMessages_4) {
+ List<Message> _allOutgoingMessages = this.roomExt.getAllOutgoingMessages(pc);
+ for(final Message m : _allOutgoingMessages) {
_builder.append("\"");
- String _name_6 = m.getName();
- _builder.append(_name_6, " ");
+ String _name_2 = m.getName();
+ _builder.append(_name_2, " ");
_builder.append("\",");
}
}
_builder.append(" ");
{
- List<Message> _allIncomingMessages_3 = this.roomExt.getAllIncomingMessages(pc);
- for(final Message m_1 : _allIncomingMessages_3) {
+ List<Message> _allIncomingMessages = this.roomExt.getAllIncomingMessages(pc);
+ for(final Message m_1 : _allIncomingMessages) {
_builder.append("\"");
- String _name_7 = m_1.getName();
- _builder.append(_name_7, " ");
+ String _name_3 = m_1.getName();
+ _builder.append(_name_3, " ");
_builder.append("\",");
}
}
@@ -280,8 +216,8 @@ public class ProtocolClassGen {
if (_operator_notEquals) {
_builder.append("\t");
DetailCode _userCode = pclass.getUserCode();
- StringConcatenation _UserCode = this.helpers.UserCode(_userCode);
- _builder.append(_UserCode, " ");
+ StringConcatenation _userCode_1 = this.helpers.userCode(_userCode);
+ _builder.append(_userCode_1, " ");
_builder.newLineIfNotEmpty();
}
}
@@ -345,9 +281,6 @@ public class ProtocolClassGen {
_builder.append("if (messageStrings[msg.getEvtId()] != \"timerTick\"){");
_builder.newLine();
_builder.append("\t\t\t\t\t");
- _builder.append("// TODOTS: model switch for activation");
- _builder.newLine();
- _builder.append("\t\t\t\t\t");
_builder.append("DebuggingService.getInstance().addMessageAsyncIn(getPeerAddress(), getAddress(), messageStrings[msg.getEvtId()]);");
_builder.newLine();
_builder.append("\t\t\t\t");
@@ -433,13 +366,13 @@ public class ProtocolClassGen {
if (_operator_notEquals_1) {
_builder.append("\t");
EList<Attribute> _attributes = pclass.getAttributes();
- StringConcatenation _Attributes = this.helpers.Attributes(_attributes);
- _builder.append(_Attributes, " ");
+ StringConcatenation _attributes_1 = this.helpers.attributes(_attributes);
+ _builder.append(_attributes_1, " ");
_builder.newLineIfNotEmpty();
_builder.append("\t");
EList<PortOperation> _operations = pclass.getOperations();
- StringConcatenation _OperationsImplementation = this.helpers.OperationsImplementation(_operations, name);
- _builder.append(_OperationsImplementation, " ");
+ StringConcatenation _operationsImplementation = this.helpers.operationsImplementation(_operations, name);
+ _builder.append(_operationsImplementation, " ");
_builder.newLineIfNotEmpty();
}
}
@@ -766,10 +699,6 @@ public class ProtocolClassGen {
_builder.append("] != \"timerTick\"){");
_builder.newLineIfNotEmpty();
_builder.append("\t");
- _builder.append("\t");
- _builder.append("// TODOTS: model switch for activation");
- _builder.newLine();
- _builder.append("\t");
_builder.append("DebuggingService.getInstance().addMessageAsyncOut(getAddress(), getPeerAddress(), messageStrings[");
_builder.append(dir, " ");
_builder.append("_");
diff --git a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/StateMachineGen.java b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/StateMachineGen.java
index 70ea09bb1..a6649675f 100644
--- a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/StateMachineGen.java
+++ b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/StateMachineGen.java
@@ -3,97 +3,38 @@ package org.eclipse.etrice.generator.java.gen;
import com.google.inject.Inject;
import com.google.inject.Singleton;
import java.util.List;
-import org.eclipse.emf.common.util.EList;
import org.eclipse.etrice.core.room.ActorClass;
-import org.eclipse.etrice.core.room.DetailCode;
-import org.eclipse.etrice.core.room.Guard;
-import org.eclipse.etrice.core.room.InterfaceItem;
-import org.eclipse.etrice.core.room.Message;
-import org.eclipse.etrice.core.room.MessageFromIf;
-import org.eclipse.etrice.core.room.NonInitialTransition;
import org.eclipse.etrice.core.room.State;
-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.etricegen.ActiveTrigger;
import org.eclipse.etrice.generator.etricegen.ExpandedActorClass;
-import org.eclipse.etrice.generator.etricegen.TransitionChain;
import org.eclipse.etrice.generator.extensions.RoomExtensions;
-import org.eclipse.etrice.generator.extensions.RoomNameProv;
-import org.eclipse.etrice.generator.generic.LanguageGenerator;
-import org.eclipse.etrice.generator.generic.TypeHelpers;
-import org.eclipse.etrice.generator.java.gen.JavaExtensions;
-import org.eclipse.xtext.xbase.lib.BooleanExtensions;
-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.etrice.generator.generic.GenericStateMachineGenerator;
import org.eclipse.xtext.xtend2.lib.StringConcatenation;
@SuppressWarnings("all")
@Singleton
-public class StateMachineGen {
+public class StateMachineGen extends GenericStateMachineGenerator {
@Inject
- private JavaExtensions stdExt;
+ private RoomExtensions _roomExtensions;
- @Inject
- private RoomExtensions roomExt;
-
- @Inject
- private TypeHelpers _typeHelpers;
-
- @Inject
- private LanguageGenerator languageGen;
-
- public StringConcatenation genStateMachine(final ExpandedActorClass xpac, final ActorClass ac) {
+ public StringConcatenation genExtra(final ExpandedActorClass xpac, final ActorClass ac) {
StringConcatenation _builder = new StringConcatenation();
- _builder.append("//******************************************");
- _builder.newLine();
- _builder.append("// START of generated code for FSM");
+ _builder.append("// state names");
_builder.newLine();
- _builder.append("//******************************************");
- _builder.newLine();
- _builder.newLine();
- _builder.append("// State IDs for FSM");
- _builder.newLine();
- int _numberOfInheritedBaseStates = this.roomExt.getNumberOfInheritedBaseStates(ac);
- int offset = _numberOfInheritedBaseStates;
- _builder.newLineIfNotEmpty();
- StateGraph _stateMachine = ac.getStateMachine();
- List<State> _baseStateList = this.roomExt.getBaseStateList(_stateMachine);
- List<State> baseStates = _baseStateList;
- _builder.newLineIfNotEmpty();
- {
- for(final State state : baseStates) {
- _builder.append("protected static final int ");
- String _stateId = this.roomExt.getStateId(state);
- _builder.append(_stateId, "");
- _builder.append(" = ");
- int _indexOf = baseStates.indexOf(state);
- int _operator_plus = IntegerExtensions.operator_plus(((Integer)_indexOf), ((Integer)2));
- int _operator_plus_1 = IntegerExtensions.operator_plus(((Integer)_operator_plus), ((Integer)offset));
- _builder.append(_operator_plus_1, "");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("\t");
_builder.append("protected static final String stateStrings[] = {\"<no state>\",\"<top>\",");
{
- List<State> _allBaseStates = this.roomExt.getAllBaseStates(ac);
+ List<State> _allBaseStatesLeavesFirst = this._roomExtensions.getAllBaseStatesLeavesFirst(ac);
boolean hasAnyElements = false;
- for(final State state_1 : _allBaseStates) {
+ for(final State state : _allBaseStatesLeavesFirst) {
if (!hasAnyElements) {
hasAnyElements = true;
} else {
- _builder.appendImmediate(",", " ");
+ _builder.appendImmediate(",", "");
}
_builder.append("\"");
- String _statePathName = this.roomExt.getStatePathName(state_1);
- _builder.append(_statePathName, " ");
+ String _statePathName = this._roomExtensions.getStatePathName(state);
+ _builder.append(_statePathName, "");
_builder.append("\"");
_builder.newLineIfNotEmpty();
- _builder.append("\t\t");
}
}
_builder.append("};");
@@ -101,283 +42,16 @@ public class StateMachineGen {
_builder.newLine();
_builder.append("// history");
_builder.newLine();
- _builder.append("// TODOHRR: history defined in ActorClassBase, init in constructor");
- _builder.newLine();
- _builder.append("//\t\thistory = new int[5];");
- _builder.newLine();
- _builder.append("//\t\tfor (int i = 0; i < history.length; i++) {");
- _builder.newLine();
- _builder.append("//\t\t\thistory[i] = NO_STATE;");
- _builder.newLine();
- _builder.append("//\t\t}");
- _builder.newLine();
_builder.append("protected int history[] = {NO_STATE,NO_STATE");
{
- List<State> _allBaseStates_1 = this.roomExt.getAllBaseStates(ac);
- for(final State state_2 : _allBaseStates_1) {
+ List<State> _allBaseStates = this._roomExtensions.getAllBaseStates(ac);
+ for(final State state_1 : _allBaseStates) {
_builder.append(",NO_STATE");
}
}
_builder.append("};");
_builder.newLineIfNotEmpty();
_builder.newLine();
- EList<TransitionChain> _ownTransitionChains = xpac.getOwnTransitionChains();
- List<TransitionChain> chains = _ownTransitionChains;
- _builder.newLineIfNotEmpty();
- EList<TransitionChain> _transitionChains = xpac.getTransitionChains();
- int _size = _transitionChains.size();
- int _size_1 = chains.size();
- int _operator_minus = IntegerExtensions.operator_minus(((Integer)_size), ((Integer)_size_1));
- int offset_tc = _operator_minus;
- _builder.newLineIfNotEmpty();
- _builder.append("// transition chains");
- _builder.newLine();
- {
- for(final TransitionChain tc : chains) {
- _builder.append("protected static final int ");
- String _chainId = this.roomExt.getChainId(tc);
- _builder.append(_chainId, "");
- _builder.append(" = ");
- int _indexOf_1 = chains.indexOf(tc);
- int _operator_plus_2 = IntegerExtensions.operator_plus(((Integer)_indexOf_1), ((Integer)1));
- int _operator_plus_3 = IntegerExtensions.operator_plus(((Integer)_operator_plus_2), ((Integer)offset_tc));
- _builder.append(_operator_plus_3, "");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.newLine();
- EList<MessageFromIf> _ownTriggers = xpac.getOwnTriggers();
- EList<MessageFromIf> triggers = _ownTriggers;
- _builder.newLineIfNotEmpty();
- _builder.append("// triggers for FSM");
- _builder.newLine();
- {
- for(final MessageFromIf mif : triggers) {
- _builder.append("protected static final int ");
- String _triggerCodeName = xpac.getTriggerCodeName(mif);
- _builder.append(_triggerCodeName, "");
- _builder.append(" = IFITEM_");
- InterfaceItem _from = mif.getFrom();
- String _name = _from.getName();
- _builder.append(_name, "");
- _builder.append(" + EVT_SHIFT*");
- String _messageID = xpac.getMessageID(mif);
- _builder.append(_messageID, "");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.newLine();
- _builder.append("// receiveEvent contains the main implementation of the FSM");
- _builder.newLine();
- _builder.append("@Override");
- _builder.newLine();
- _builder.append("public void receiveEvent(InterfaceItemBase ifitem, int evt, Object generic_data) {");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("int trigger = ifitem.getLocalId() + EVT_SHIFT*evt;");
- _builder.newLine();
- _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 = false;");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("boolean skip_entry = false;");
- _builder.newLine();
- _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 (state) {");
- _builder.newLine();
- {
- StateGraph _stateMachine_1 = xpac.getStateMachine();
- List<State> _leafStateList = this.roomExt.getLeafStateList(_stateMachine_1);
- for(final State state_3 : _leafStateList) {
- _builder.append("\t\t\t");
- _builder.append("case ");
- String _stateId_1 = this.roomExt.getStateId(state_3);
- _builder.append(_stateId_1, " ");
- _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_1 = xpac.getTriggerCodeName(_trigger);
- _builder.append(_triggerCodeName_1, " ");
- _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._typeHelpers.getTypedDataDefinition(_msg);
- _builder.append(_typedDataDefinition, " ");
- }
- }
- _builder.newLineIfNotEmpty();
- {
- EList<TriggeredTransition> _transitions = at.getTransitions();
- boolean hasAnyElements_1 = false;
- for(final TriggeredTransition tt : _transitions) {
- if (!hasAnyElements_1) {
- hasAnyElements_1 = true;
- } else {
- _builder.appendImmediate(" else ", " ");
- }
- _builder.append("\t\t\t");
- _builder.append("\t");
- _builder.append("\t");
- TransitionChain _chain = xpac.getChain(tt);
- TransitionChain chain = _chain;
- _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_1 = this.roomExt.getChainId(chain);
- _builder.append(_chainId_1, " ");
- _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 = true;");
- }
- }
- _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 = true;");
- }
- }
- _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.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("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(state, catching_state, is_handler);");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("int next = executeTransitionChain(chain, ifitem, generic_data);");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("next = enterHistory(next, is_handler, skip_entry);");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("setState(next);");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("}");
- _builder.newLine();
- _builder.newLine();
_builder.append("private void setState(int new_state) {");
_builder.newLine();
_builder.append("\t");
@@ -387,9 +61,6 @@ public class StateMachineGen {
_builder.append("if (stateStrings[new_state]!=\"Idle\") {");
_builder.newLine();
_builder.append("\t\t");
- _builder.append("// TODOTS: model switch for activation");
- _builder.newLine();
- _builder.append("\t\t");
_builder.append("System.out.println(getInstancePath() + \" -> \" + stateStrings[new_state]);");
_builder.newLine();
_builder.append("\t");
@@ -400,472 +71,6 @@ public class StateMachineGen {
_builder.newLine();
_builder.append("}");
_builder.newLine();
- _builder.newLine();
- _builder.append("@Override");
- _builder.newLine();
- _builder.append("public void executeInitTransition() {");
- _builder.newLine();
- _builder.append("\t");
- StateGraph _stateMachine_2 = xpac.getStateMachine();
- Transition _initTransition = this.roomExt.getInitTransition(_stateMachine_2);
- Transition initt = _initTransition;
- _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(chain, null, null);");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("next = enterHistory(next, false, false);");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("setState(next);");
- _builder.newLine();
- _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();
- _builder.append("private void exitTo(int current, int to, boolean handler) {");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("while (current!=to) {");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("switch (current) {");
- _builder.newLine();
- {
- StateGraph _stateMachine_3 = xpac.getStateMachine();
- List<State> _baseStateList_1 = this.roomExt.getBaseStateList(_stateMachine_3);
- for(final State state_4 : _baseStateList_1) {
- _builder.append("\t\t\t");
- _builder.append("case ");
- String _stateId_2 = this.roomExt.getStateId(state_4);
- _builder.append(_stateId_2, " ");
- _builder.append(":");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t\t");
- _builder.append("\t");
- {
- boolean _hasExitCode = this.roomExt.hasExitCode(state_4);
- if (_hasExitCode) {
- _builder.append("if (!handler) ");
- String _exitCodeOperationName = RoomNameProv.getExitCodeOperationName(state_4);
- _builder.append(_exitCodeOperationName, " ");
- _builder.append("();");
- }
- }
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t\t");
- _builder.append("\t");
- _builder.append("history[");
- String _parentStateId = RoomNameProv.getParentStateId(state_4);
- _builder.append(_parentStateId, " ");
- _builder.append("] = ");
- String _stateId_3 = this.roomExt.getStateId(state_4);
- _builder.append(_stateId_3, " ");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t\t");
- _builder.append("\t");
- _builder.append("current = ");
- String _parentStateId_1 = RoomNameProv.getParentStateId(state_4);
- _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.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();
- _builder.append("private int executeTransitionChain(int chain, InterfaceItemBase ifitem, Object generic_data) {");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("switch (chain) {");
- _builder.newLine();
- _builder.append("\t\t");
- EList<TransitionChain> _transitionChains_1 = xpac.getTransitionChains();
- EList<TransitionChain> allchains = _transitionChains_1;
- _builder.newLineIfNotEmpty();
- {
- for(final TransitionChain tc_1 : allchains) {
- _builder.append("\t\t");
- _builder.append("case ");
- String _chainId_3 = this.roomExt.getChainId(tc_1);
- _builder.append(_chainId_3, " ");
- _builder.append(":");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.append("{");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("\t");
- String _executeChainCode = this.stdExt.getExecuteChainCode(xpac, tc_1);
- _builder.append(_executeChainCode, " ");
- _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.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();
- _builder.append("private int enterHistory(int state, boolean handler, boolean skip_entry) {");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("while (true) {");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("switch (state) {");
- _builder.newLine();
- {
- StateGraph _stateMachine_4 = xpac.getStateMachine();
- List<State> _baseStateList_2 = this.roomExt.getBaseStateList(_stateMachine_4);
- for(final State state_5 : _baseStateList_2) {
- _builder.append("\t\t\t");
- _builder.append("case ");
- String _stateId_4 = this.roomExt.getStateId(state_5);
- _builder.append(_stateId_4, " ");
- _builder.append(":");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t\t");
- _builder.append("\t");
- {
- boolean _hasEntryCode = this.roomExt.hasEntryCode(state_5);
- if (_hasEntryCode) {
- _builder.append("if (!(skip_entry || handler)) ");
- String _entryCodeOperationName = RoomNameProv.getEntryCodeOperationName(state_5);
- _builder.append(_entryCodeOperationName, " ");
- _builder.append("();");
- }
- }
- _builder.newLineIfNotEmpty();
- {
- boolean _isLeaf = this.roomExt.isLeaf(state_5);
- 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_5 = this.roomExt.getStateId(state_5);
- _builder.append(_stateId_5, " ");
- _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_5.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 (history[");
- String _stateId_6 = this.roomExt.getStateId(state_5);
- _builder.append(_stateId_6, " ");
- _builder.append("]==NO_STATE) {");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t\t");
- _builder.append("\t");
- _builder.append("\t");
- StateGraph _subgraph_1 = state_5.getSubgraph();
- Transition _initTransition_1 = this.roomExt.getInitTransition(_subgraph_1);
- Transition sub_initt = _initTransition_1;
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t\t");
- _builder.append("\t");
- _builder.append("\t");
- _builder.append("state = executeTransitionChain(");
- TransitionChain _chain_2 = xpac.getChain(sub_initt);
- String _chainId_4 = this.roomExt.getChainId(_chain_2);
- _builder.append(_chainId_4, " ");
- _builder.append(", null, null);");
- _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 = history[");
- String _stateId_7 = this.roomExt.getStateId(state_5);
- _builder.append(_stateId_7, " ");
- _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 = history[");
- String _stateId_8 = this.roomExt.getStateId(state_5);
- _builder.append(_stateId_8, " ");
- _builder.append("];");
- _builder.newLineIfNotEmpty();
- }
- }
- _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 = history[STATE_TOP];");
- _builder.newLine();
- _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 = false;");
- _builder.newLine();
- _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();
- _builder.append("//*** Entry and Exit Codes");
- _builder.newLine();
- {
- StateGraph _stateMachine_5 = xpac.getStateMachine();
- List<State> _stateList = this.roomExt.getStateList(_stateMachine_5);
- for(final State state_6 : _stateList) {
- {
- boolean _isOwnObject = xpac.isOwnObject(state_6);
- if (_isOwnObject) {
- {
- boolean _hasEntryCode_1 = this.roomExt.hasEntryCode(state_6);
- if (_hasEntryCode_1) {
- _builder.append("protected void ");
- String _entryCodeOperationName_1 = RoomNameProv.getEntryCodeOperationName(state_6);
- _builder.append(_entryCodeOperationName_1, "");
- _builder.append("() {");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- String _entryCode = this.roomExt.getEntryCode(xpac, state_6);
- _builder.append(_entryCode, " ");
- _builder.newLineIfNotEmpty();
- _builder.append("}");
- _builder.newLine();
- }
- }
- {
- boolean _hasExitCode_1 = this.roomExt.hasExitCode(state_6);
- if (_hasExitCode_1) {
- _builder.append("protected void ");
- String _exitCodeOperationName_1 = RoomNameProv.getExitCodeOperationName(state_6);
- _builder.append(_exitCodeOperationName_1, "");
- _builder.append("() {");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- String _exitCode = this.roomExt.getExitCode(xpac, state_6);
- _builder.append(_exitCode, " ");
- _builder.newLineIfNotEmpty();
- _builder.append("}");
- _builder.newLine();
- }
- }
- }
- }
- }
- }
- _builder.newLine();
- _builder.append("//*** Action Codes");
- _builder.newLine();
- {
- StateGraph _stateMachine_6 = xpac.getStateMachine();
- List<Transition> _transitionList = this.roomExt.getTransitionList(_stateMachine_6);
- 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) {
- _builder.append("protected void ");
- String _actionCodeOperationName = RoomNameProv.getActionCodeOperationName(tr);
- _builder.append(_actionCodeOperationName, "");
- _builder.append("(");
- {
- 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);
- _builder.append(_actionCode, " ");
- _builder.newLineIfNotEmpty();
- _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;
}
-
- protected 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();
- {
- 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();
- }
- }
- return _builder;
- }
-
- protected StringConcatenation _guard(final Transition t, final String trigger, final ExpandedActorClass ac) {
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("/* error */");
- _builder.newLine();
- return _builder;
- }
-
- public StringConcatenation guard(final Transition tt, final String trigger, final ExpandedActorClass ac) {
- if (tt instanceof TriggeredTransition) {
- return _guard((TriggeredTransition)tt, trigger, ac);
- } else {
- return _guard(tt, trigger, ac);
- }
- }
}
diff --git a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/SubSystemClassGen.java b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/SubSystemClassGen.java
index 852a87265..1909e266b 100644
--- a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/SubSystemClassGen.java
+++ b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/SubSystemClassGen.java
@@ -110,8 +110,8 @@ public class SubSystemClassGen {
_builder.newLine();
_builder.newLine();
DetailCode _userCode1 = cc.getUserCode1();
- StringConcatenation _UserCode = this.helpers.UserCode(_userCode1);
- _builder.append(_UserCode, "");
+ StringConcatenation _userCode = this.helpers.userCode(_userCode1);
+ _builder.append(_userCode, "");
_builder.newLineIfNotEmpty();
_builder.newLine();
_builder.append("public class ");
@@ -122,8 +122,8 @@ public class SubSystemClassGen {
_builder.newLine();
_builder.append("\t");
DetailCode _userCode2 = cc.getUserCode2();
- StringConcatenation _UserCode_1 = this.helpers.UserCode(_userCode2);
- _builder.append(_UserCode_1, " ");
+ StringConcatenation _userCode_1 = this.helpers.userCode(_userCode2);
+ _builder.append(_userCode_1, " ");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.newLine();
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 b3627952f..eff79f6e3 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
@@ -145,6 +145,27 @@ class RoomExtensions {
def List<Port> getEndPorts(ActorClass ac) {
ac.intPorts.punion(ac.extPorts)
}
+
+ def List<Port> getAllEndPorts(ActorClass ac) {
+ if (ac.base==null)
+ return ac.getEndPorts()
+ else
+ ac.base.getAllEndPorts().union(ac.getEndPorts())
+ }
+
+ def List<SAPRef> getAllSAPs(ActorClass ac) {
+ if (ac.base==null)
+ return ac.strSAPs
+ else
+ ac.base.strSAPs.union(ac.strSAPs)
+ }
+
+ def List<ServiceImplementation> getAllServiceImplementations(ActorClass ac) {
+ if (ac.base==null)
+ return ac.serviceImplementations
+ else
+ ac.base.serviceImplementations.union(ac.serviceImplementations)
+ }
// make a valid identifier from a path string
def String getPathName(String path){
@@ -330,6 +351,20 @@ class RoomExtensions {
return ret
}
+ def getLeafStatesFirst(List<State> states) {
+ var leaf = new ArrayList<State>()
+ var nonLeaf = new ArrayList<State>()
+ for (state : states) {
+ if (state.leaf)
+ leaf.add(state)
+ else
+ nonLeaf.add(state)
+ }
+ leaf.addAll(nonLeaf)
+
+ return leaf
+ }
+
def List<State> getAllBaseStates(ActorClass ac) {
if (ac.base==null)
return ac.stateMachine.getBaseStateList()
@@ -337,6 +372,20 @@ class RoomExtensions {
ac.base.getAllBaseStates().union(ac.stateMachine.getBaseStateList())
}
+ def List<State> getAllBaseStatesLeavesFirst(ActorClass ac) {
+ if (ac.base==null)
+ return ac.stateMachine.getBaseStateList().getLeafStatesFirst
+ else
+ ac.base.getAllBaseStates().getLeafStatesFirst.union(ac.stateMachine.getBaseStateList().getLeafStatesFirst)
+ }
+
+ def List<State> getAllLeafStates(ActorClass ac) {
+ if (ac.base==null)
+ return ac.stateMachine.getLeafStateList()
+ else
+ ac.base.getAllLeafStates().union(ac.stateMachine.getLeafStateList())
+ }
+
def boolean overridesStop(ActorClass ac) {
return ac.operations.exists(e|e.name=="stop"&&e.arguments.isEmpty&&e.returntype==null)
|| (ac.base!=null && ac.base.overridesStop())
diff --git a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/GenericActorClassGenerator.xtend b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/GenericActorClassGenerator.xtend
new file mode 100644
index 000000000..96b74de87
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/GenericActorClassGenerator.xtend
@@ -0,0 +1,49 @@
+/*******************************************************************************
+ * 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.generic
+
+import com.google.inject.Inject
+import java.util.ArrayList
+import org.eclipse.etrice.core.room.ActorClass
+import org.eclipse.etrice.generator.etricegen.ExpandedActorClass
+import org.eclipse.etrice.generator.extensions.RoomExtensions
+import org.eclipse.xtext.util.Pair
+import static org.eclipse.xtext.util.Tuples.*
+
+class GenericActorClassGenerator {
+
+ @Inject extension ILanguageExtension langExt
+ @Inject extension RoomExtensions roomExt
+
+ def genInterfaceItemConstants(ExpandedActorClass xpac, ActorClass ac) {
+ var endPorts = if (langExt.usesInheritance)
+ ac.endPorts else ac.allEndPorts
+ var strSAPs = if (langExt.usesInheritance)
+ ac.strSAPs else ac.getAllSAPs
+ var svcImpls = if (langExt.usesInheritance)
+ ac.serviceImplementations else ac.allServiceImplementations
+
+ var list = new ArrayList<Pair<String, String>>()
+ for (ep : endPorts) {
+ list.add(pair("IFITEM_"+ep.name, (1+xpac.getInterfaceItemLocalId(ep)).toString))
+ }
+ for (sap : strSAPs) {
+ list.add(pair("IFITEM_"+sap.name, (1+xpac.getInterfaceItemLocalId(sap)).toString))
+ }
+ for (svc : svcImpls) {
+ list.add(pair("IFITEM_"+svc.spp.name, (1+xpac.getInterfaceItemLocalId(svc.spp)).toString))
+ }
+
+ return langExt.genEnumeration("interface_items", list)
+ }
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/GenericProtocolClassGenerator.xtend b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/GenericProtocolClassGenerator.xtend
new file mode 100644
index 000000000..265cc8df5
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/GenericProtocolClassGenerator.xtend
@@ -0,0 +1,74 @@
+/*******************************************************************************
+ * 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.generic
+
+import com.google.inject.Inject
+import java.util.ArrayList
+import org.eclipse.etrice.core.room.ProtocolClass
+import org.eclipse.etrice.core.room.Port
+import org.eclipse.etrice.core.room.InterfaceItem
+import org.eclipse.etrice.core.room.SAPRef
+import org.eclipse.etrice.core.room.SPPRef
+import org.eclipse.etrice.core.room.Message
+import org.eclipse.etrice.core.room.MessageFromIf
+import org.eclipse.etrice.generator.extensions.RoomExtensions
+import org.eclipse.xtext.util.Pair
+import static org.eclipse.xtext.util.Tuples.*
+
+
+class GenericProtocolClassGenerator {
+
+ @Inject extension ILanguageExtension langExt
+ @Inject extension RoomExtensions roomExt
+
+ def genMessageIDs(ProtocolClass pc) {
+ var offset = 0
+
+ var list = new ArrayList<Pair<String, String>>()
+ list.add(pair(memberInDeclaration(pc.name, "MSG_MIN"), offset.toString))
+ for (msg : pc.allOutgoingMessages) {
+ offset = offset+1
+ list.add(pair(memberInDeclaration(pc.name, "OUT_"+msg.name), offset.toString))
+ }
+ for (msg : pc.allIncomingMessages) {
+ offset = offset+1
+ list.add(pair(memberInDeclaration(pc.name, "IN_"+msg.name), offset.toString))
+ }
+ offset = offset+1
+ list.add(pair(memberInDeclaration(pc.name, "MSG_MAX"), offset.toString))
+
+ return langExt.genEnumeration("msg_ids", list)
+ }
+
+ def getMessageID(MessageFromIf mif) {
+ return getMessageID(mif.message, mif.from)
+ }
+
+ def getMessageID(Message msg, InterfaceItem item) {
+ if (item instanceof Port) {
+ var p = item as Port;
+ var direction = if (p.isConjugated())"OUT_" else "IN_"
+ return memberInUse(p.getProtocol().getName(), direction+msg.getName())
+ }
+ else if (item instanceof SAPRef) {
+ var sap = item as SAPRef;
+ return memberInUse(sap.getProtocol().getName(), "OUT_"+msg.getName())
+ }
+ else if (item instanceof SPPRef) {
+ var spp = item as SPPRef;
+ return memberInUse(spp.getProtocol().getName(), "IN_"+msg.getName())
+ }
+
+ return "unknown interface item";
+ }
+} \ No newline at end of file
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
new file mode 100644
index 000000000..a0638cc73
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/GenericStateMachineGenerator.xtend
@@ -0,0 +1,277 @@
+/*******************************************************************************
+ * 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.generic
+
+import com.google.inject.Inject
+import java.util.ArrayList
+import org.eclipse.etrice.core.room.ActorClass
+import org.eclipse.etrice.core.room.Transition
+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 static extension org.eclipse.etrice.generator.extensions.RoomNameProv.*
+import org.eclipse.xtext.util.Pair
+import static org.eclipse.xtext.util.Tuples.*
+
+class GenericStateMachineGenerator {
+
+ @Inject public extension ILanguageExtension langExt
+ @Inject public extension RoomExtensions roomExt
+ @Inject public extension GenericProtocolClassGenerator pcGen
+ @Inject public extension LanguageGenerator languageGen
+
+ def private genStateIdConstants(ExpandedActorClass xpac, ActorClass ac) {
+ // with inheritance we exclude inherited base states
+ var offset = 2 + if (langExt.usesInheritance)
+ ac.getNumberOfInheritedBaseStates() else 0
+ var baseStates = if (langExt.usesInheritance)
+ ac.stateMachine.getBaseStateList else xpac.stateMachine.getBaseStateList
+
+ baseStates = baseStates.leafStatesFirst
+
+ var list = new ArrayList<Pair<String, String>>()
+ if (!langExt.usesInheritance) {
+ list.add(pair("NO_STATE","0"))
+ list.add(pair("STATE_TOP","1"))
+ }
+ for (state : baseStates) {
+ list.add(pair(state.getStateId, offset.toString))
+ offset = offset+1;
+ }
+
+ return langExt.genEnumeration("state_ids", list)
+ }
+
+ def private genTransitionChainConstants(ExpandedActorClass xpac, ActorClass ac) {
+ var chains = if (langExt.usesInheritance)
+ xpac.getOwnTransitionChains() else xpac.transitionChains
+ var offset = if (langExt.usesInheritance)
+ xpac.getTransitionChains().size-chains.size else 0
+
+ var list = new ArrayList<Pair<String, String>>()
+ for (chain : chains) {
+ offset = offset+1;
+ list.add(pair(chain.getChainId, offset.toString))
+ }
+
+ return langExt.genEnumeration("chain_ids", list)
+ }
+
+ def private genTriggerConstants(ExpandedActorClass xpac, ActorClass ac) {
+ var triggers = if (langExt.usesInheritance)
+ xpac.getOwnTriggers() else xpac.triggers
+
+ var list = new ArrayList<Pair<String, String>>()
+ for (mif : triggers) {
+ list.add(pair(xpac.getTriggerCodeName(mif), "IFITEM_"+mif.from.name+" + EVT_SHIFT*"+pcGen.getMessageID(mif)))
+ }
+
+ return langExt.genEnumeration("triggers", list)
+ }
+
+ def genStateMachine(ExpandedActorClass xpac, ActorClass ac) {'''
+
+ /* state IDs */
+ «genStateIdConstants(xpac, ac)»
+
+ /* transition chains */
+ «genTransitionChainConstants(xpac, ac)»
+
+ /* triggers */
+ «genTriggerConstants(xpac, ac)»
+
+ «genExtra(xpac, ac)»
+
+ //*** Entry and Exit Codes
+ «FOR state : xpac.stateMachine.getStateList()»
+ «IF xpac.isOwnObject(state)»
+ «IF state.hasEntryCode()»
+ «langExt.accessLevelProtected»void «state.getEntryCodeOperationName()»(«langExt.selfPointer(ac.name, false)») {
+ «xpac.getEntryCode(state)»
+ }
+ «ENDIF»
+ «IF state.hasExitCode()»
+ «langExt.accessLevelProtected»void «state.getExitCodeOperationName()»(«langExt.selfPointer(ac.name, false)») {
+ «xpac.getExitCode(state)»
+ }
+ «ENDIF»
+ «ENDIF»
+ «ENDFOR»
+
+ //*** Action Codes
+ «FOR tr : xpac.stateMachine.getTransitionList()»
+ «IF xpac.isOwnObject(tr) && tr.hasActionCode()»
+ protected void «tr.getActionCodeOperationName()»(«IF tr instanceof NonInitialTransition»InterfaceItemBase ifitem«languageGen.getArgumentList(xpac, tr)»«ENDIF») {
+ «xpac.getActionCode(tr)»
+ }
+ «ENDIF»
+ «ENDFOR»
+
+ /**
+ * calls exit codes while exiting from the current state to one of its
+ * parent states while remembering the history
+ * @param current - the current state
+ * @param to - the final parent state
+ * @param handler - entry and exit codes are called only if not handler (for handler TransitionPoints)
+ */
+ «langExt.accessLevelPrivate»void exitTo(«langExt.selfPointer(ac.name, true)»int current, int to, boolean handler) {
+ while (current!=to) {
+ switch (current) {
+ «FOR state : xpac.stateMachine.getBaseStateList()»
+ case «state.getStateId()»:
+ «IF state.hasExitCode()»if (!handler) «state.getExitCodeOperationName()»();«ENDIF»
+ «langExt.memberAccess»history[«state.getParentStateId()»] = «state.getStateId()»;
+ current = «state.getParentStateId()»;
+ break;
+ «ENDFOR»
+ }
+ }
+ }
+
+ /**
+ * calls action, entry and exit codes along a transition chain. The generic data are cast to typed data
+ * matching the trigger of this chain. The ID of the final state is returned
+ * @param chain - the chain ID
+ * @param generic_data - the generic data pointer
+ * @return the ID of the final state
+ */
+ «langExt.accessLevelPrivate»int executeTransitionChain(«langExt.selfPointer(ac.name, true)»int chain, InterfaceItemBase ifitem, «langExt.voidPointer» generic_data) {
+ switch (chain) {
+ «var allchains = xpac.getTransitionChains()»
+ «FOR tc : allchains»
+ case «tc.getChainId()»:
+ {
+ «xpac.getExecuteChain(tc)»
+ }
+ «ENDFOR»
+ }
+ return NO_STATE;
+ }
+
+ /**
+ * calls entry codes while entering a state's history. The ID of the final leaf state is returned
+ * @param state - the state which is entered
+ * @param handler - entry code is executed if not handler
+ * @return - the ID of the final leaf state
+ */
+ «langExt.accessLevelPrivate»int enterHistory(«langExt.selfPointer(ac.name, true)»int state, boolean handler, boolean skip_entry) {
+ while («langExt.booleanConstant(true)») {
+ switch (state) {
+ «FOR state : xpac.stateMachine.getBaseStateList()»
+ case «state.getStateId()»:
+ «IF state.hasEntryCode()»if (!(skip_entry || handler)) «state.getEntryCodeOperationName()»();«ENDIF»
+ «IF state.isLeaf()»
+ // in leaf state: return state id
+ return «state.getStateId()»;
+ «ELSE»
+ // state has a sub graph
+ «IF state.subgraph.hasInitTransition()»
+ // with init transition
+ if («langExt.memberAccess»history[«state.getStateId()»]==NO_STATE) {
+ «var sub_initt = state.subgraph.getInitTransition()»
+ state = executeTransitionChain(«langExt.selfPointer(true)»«xpac.getChain(sub_initt).getChainId()», «langExt.nullPointer», «langExt.nullPointer»);
+ }
+ else {
+ state = «langExt.memberAccess»history[«state.getStateId()»];
+ }
+ «ELSE»
+ // without init transition
+ state = «langExt.memberAccess»history[«state.getStateId()»];
+ «ENDIF»
+ break;
+ «ENDIF»
+ «ENDFOR»
+ case STATE_TOP:
+ state = «langExt.memberAccess»history[STATE_TOP];
+ break;
+ }
+ skip_entry = «langExt.booleanConstant(false)»;
+ }
+ //return NO_STATE; // required by CDT but detected as unreachable by JDT because of while (true)
+ }
+
+ «IF langExt.usesInheritance»«langExt.accessLevelPublic»«ELSE»«langExt.accessLevelPrivate»«ENDIF»void executeInitTransition(«langExt.selfPointer(ac.name, false)») {
+ «var initt = xpac.stateMachine.getInitTransition()»
+ int chain = «xpac.getChain(initt).getChainId()»;
+ int next = executeTransitionChain(«langExt.selfPointer(true)»chain, «langExt.nullPointer», «langExt.nullPointer»);
+ next = enterHistory(«langExt.selfPointer(true)»next, «langExt.booleanConstant(false)», «langExt.booleanConstant(false)»);
+ setState(«langExt.selfPointer(true)»next);
+ }
+
+ /* receiveEvent contains the main implementation of the FSM */
+ «IF langExt.usesInheritance»«langExt.accessLevelPublic»«ELSE»«langExt.accessLevelPrivate»«ENDIF»void receiveEvent(«langExt.selfPointer(ac.name, true)»InterfaceItemBase ifitem, int evt, «langExt.voidPointer» generic_data) {
+ int trigger = «IF langExt.usesInheritance»ifitem.getLocalId()«ELSE»ifitem->localId«ENDIF» + EVT_SHIFT*evt;
+ int chain = NOT_CAUGHT;
+ int catching_state = NO_STATE;
+ boolean is_handler = «langExt.booleanConstant(false)»;
+ boolean skip_entry = «langExt.booleanConstant(false)»;
+
+ if (!handleSystemEvent(ifitem, evt, generic_data)) {
+ switch («langExt.memberAccess»state) {
+ «FOR state : xpac.stateMachine.getLeafStateList()»
+ case «state.getStateId()»:
+ «var atlist = xpac.getActiveTriggers(state)»
+ «IF !atlist.isEmpty»
+ switch(trigger) {
+ «FOR at : atlist»
+ case «xpac.getTriggerCodeName(at.trigger)»:
+ «var needData = xpac.hasGuard(at)»
+ «IF needData»{ «at.msg.getTypedDataDefinition()»«ENDIF»
+ «FOR tt : at.transitions SEPARATOR " else "»
+ «var chain = xpac.getChain(tt)»
+ «guard(chain.transition, at.trigger, xpac)»
+ {
+ chain = «chain.getChainId()»;
+ catching_state = «chain.getContextId()»;
+ «IF chain.isHandler()»is_handler = true;«ENDIF»
+ «IF chain.skipEntry»skip_entry = true;«ENDIF»
+ }
+ «ENDFOR»
+ «IF needData»}«ENDIF»
+ break;
+ «ENDFOR»
+ }
+ «ENDIF»
+ break;
+ «ENDFOR»
+ }
+ }
+ if (chain != NOT_CAUGHT) {
+ exitTo(«langExt.selfPointer(true)»«langExt.memberAccess»state, catching_state, is_handler);
+ int next = executeTransitionChain(«langExt.selfPointer(true)»chain, ifitem, generic_data);
+ next = enterHistory(«langExt.selfPointer(true)»next, is_handler, skip_entry);
+ setState(«langExt.selfPointer(true)»next);
+ }
+ }
+
+ //******************************************
+ // END of generated code for FSM
+ //******************************************
+ '''}
+
+ 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))»
+ «IF tr.hasGuard()»
+ if («ac.getCode(tr.guard.guard)»)
+ «ENDIF»
+ '''
+ }
+
+ def private dispatch guard(Transition t, String trigger, ExpandedActorClass ac) {'''
+ /* error */
+ '''
+ }
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/ILanguageExtension.java b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/ILanguageExtension.java
index 44501ac78..6195e41e3 100644
--- a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/ILanguageExtension.java
+++ b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/ILanguageExtension.java
@@ -2,9 +2,14 @@
package org.eclipse.etrice.generator.generic;
import org.eclipse.etrice.core.room.Message;
+import java.util.List;
+import org.eclipse.xtext.util.Pair;
-
+/**
+ * @author hrentz
+ *
+ */
public interface ILanguageExtension {
String getTypedDataDefinition(Message m);
@@ -14,17 +19,20 @@ public interface ILanguageExtension {
* @return e.g. "private " for Java, nothing for C and C++ (no access level before the individual member)
*/
String accessLevelPrivate();
+
/**
* unification of access level for all Languages before each member
* @return e.g. "protected " for Java, nothing for C and C++ (no access level before the individual member)
*/
String accessLevelProtected();
+
/**
* unification of access level for all Languages before each member
* @return e.g. "public " for Java, nothing for C and C++ (no access level before the individual member)
*/
String accessLevelPublic();
+
// Strings for member access
/**
@@ -36,19 +44,79 @@ public interface ILanguageExtension {
/**
* self pointer for building class mechanism in C,
* e.g. MyClass_function1(MyClass *self, int32 argument1)
+ * @param classname the class name
+ * @param hasArgs true if functions has further arguments
* @return "classname *self, " for C / for Java and C++ nothing
*/
- String selfPointer(String classname, int argumentCount);
+ String selfPointer(String classname, boolean hasArgs);
+
+ /**
+ * self pointer for function calls
+ * @param hasArgs true if functions has further arguments
+ * @return "self, " for C / for Java and C++ nothing
+ */
+ String selfPointer(boolean hasArgs);
/**
* language specific scoping string for operations
* e.g. nothing in Java (only inside class declaration), nothing and classname:: for C++ and classname_ for C
- * @return "classname *self, " for C / for Java and C++ nothing
+ * @param classname the class name
+ * @param isDeclaration true if it is a declaration
+ * @return "classname_" for C / for Java and C++ nothing
*/
String operationScope(String classname, boolean isDeclaration);
+
+ /**
+ * member declaration
+ *
+ * @param namespace the namespace or class name
+ * @param member the member name
+ * @return for C: namespace_member, for Java namespace.member
+ */
+ String memberInDeclaration(String namespace, String member);
- String outMessageId(String classname, String messagename);
- String inMessageId(String classname, String messagename);
+ /**
+ * member usage
+ *
+ * @param namespace the namespace or class name
+ * @param member the member name
+ * @return for C: namespace_member, for Java namespace.member
+ */
+ String memberInUse(String namespace, String member);
+ /**
+ * does the target language offer inheritance
+ *
+ * @return true for C++ and Java, false for C
+ */
+ boolean usesInheritance();
+ /**
+ * generate an enumeration (enum in C, int constants in Java)
+ * @param name the enumeration name
+ * @param entries a list of name/value pairs
+ * @return a string defining the enumeration in the target language
+ */
+ String genEnumeration(String name, List<Pair<String, String>> entries);
+
+ /**
+ * literals for boolean constants
+ * @param b the boolean value
+ * @return TRUE/FALSE for C/C++, true/false for Java
+ */
+ String booleanConstant(boolean b);
+
+ /**
+ * a literal for the null pointer
+ *
+ * @return NULL for C/C++, null for Java
+ */
+ String nullPointer();
+
+ /**
+ * a generic pointer
+ *
+ * @return void* for C/C++, Object for Java
+ */
+ String voidPointer();
} \ No newline at end of file
diff --git a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/ProcedureHelpers.xtend b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/ProcedureHelpers.xtend
index c8d163777..31feeff47 100644
--- a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/ProcedureHelpers.xtend
+++ b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/ProcedureHelpers.xtend
@@ -34,7 +34,7 @@ class ProcedureHelpers {
@Inject extension TypeHelpers
@Inject ILogger logger
- def UserCode(DetailCode dc) {'''
+ def userCode(DetailCode dc) {'''
«IF dc!=null»
//--------------------- begin user code
«FOR command : dc.commands» «command»
@@ -46,7 +46,7 @@ class ProcedureHelpers {
// Attributes
/* TODO: add ref type */
- def Attributes(List<Attribute> attribs) {'''
+ def attributes(List<Attribute> attribs) {'''
//--------------------- attributes
«FOR attribute : attribs»
«IF attribute.size==0»
@@ -109,32 +109,32 @@ class ProcedureHelpers {
}
// Attribute setters & getters
- def AttributeSettersGettersDeclaration(List<Attribute> attribs, String classname) {'''
+ def attributeSettersGettersDeclaration(List<Attribute> attribs, String classname) {'''
//--------------------- attribute setters and getters
«FOR attribute : attribs»
- «SetterHeader(attribute, classname)»;
- «GetterHeader(attribute, classname)»;
+ «setterHeader(attribute, classname)»;
+ «getterHeader(attribute, classname)»;
«ENDFOR»
'''
}
- def AttributeSettersGettersImplementation(List<Attribute> attribs, String classname) {'''
+ def attributeSettersGettersImplementation(List<Attribute> attribs, String classname) {'''
//--------------------- attribute setters and getters
- «FOR attribute : attribs»«SetterHeader(attribute, classname)» {
+ «FOR attribute : attribs»«setterHeader(attribute, classname)» {
«languageExt.memberAccess()»«attribute.name» = «attribute.name»;
}
- «GetterHeader(attribute, classname)» {
+ «getterHeader(attribute, classname)» {
return «languageExt.memberAccess()»«attribute.name»;
}
«ENDFOR»
'''
}
- def private SetterHeader(Attribute attribute, String classname){'''
- «languageExt.accessLevelPublic()»void set«attribute.name.toFirstUpper()» («languageExt.selfPointer(classname, 1)»«attribute.refType.type.typeName»«IF attribute.size!=0»[]«ENDIF» «attribute.name»)'''
+ def private setterHeader(Attribute attribute, String classname){'''
+ «languageExt.accessLevelPublic()»void set«attribute.name.toFirstUpper()» («languageExt.selfPointer(classname, true)»«attribute.refType.type.typeName»«IF attribute.size!=0»[]«ENDIF» «attribute.name»)'''
}
- def private GetterHeader(Attribute attribute, String classname){'''
- «languageExt.accessLevelPublic()»«attribute.refType.type.typeName»«IF attribute.size!=0»[]«ENDIF» get«attribute.name.toFirstUpper()» («languageExt.selfPointer(classname, 0)»)'''
+ def private getterHeader(Attribute attribute, String classname){'''
+ «languageExt.accessLevelPublic()»«attribute.refType.type.typeName»«IF attribute.size!=0»[]«ENDIF» get«attribute.name.toFirstUpper()» («languageExt.selfPointer(classname, false)»)'''
}
def argList(List<Attribute> attributes) {
@@ -143,34 +143,36 @@ class ProcedureHelpers {
// Operations
- def OperationsDeclaration(List<? extends Operation> operations, String classname) {'''
+ def operationsDeclaration(List<? extends Operation> operations, String classname) {'''
//--------------------- operations
- «FOR operation : operations»«OperationSignature(operation, classname, true)»;
+ «FOR operation : operations»
+ «operationSignature(operation, classname, true)»;
«ENDFOR»
'''
}
- def OperationsImplementation(List<? extends Operation> operations, String classname) {'''
+ def operationsImplementation(List<? extends Operation> operations, String classname) {'''
//--------------------- operations
- «FOR operation : operations»«OperationSignature(operation, classname, false)» {
- «FOR command : operation.detailCode.commands» «command»
- «ENDFOR»
- }
+ «FOR operation : operations»
+ «operationSignature(operation, classname, false)» {
+ «FOR command : operation.detailCode.commands»
+ «command»
+ «ENDFOR»
+ }
«ENDFOR»
'''
}
- def private OperationSignature(Operation operation, String classname, boolean isDeclaration) {
- ClassOperationSignature(classname, operation.name, BuildArgumentList(operation.arguments).toString, DataTypeToString(operation.returntype), isDeclaration);
+ def private operationSignature(Operation operation, String classname, boolean isDeclaration) {
+ classOperationSignature(classname, operation.name, BuildArgumentList(operation.arguments).toString, dataTypeToString(operation.returntype), isDeclaration);
}
- def private DataTypeToString(RefableType type){
-
- if(type==null)
- return "void"
+ def private dataTypeToString(RefableType type) {
+ return if (type==null)
+ "void"
else
- return type.type.typeName
+ type.type.typeName
}
/*
@@ -180,9 +182,8 @@ class ProcedureHelpers {
'''«FOR argument : arguments SEPARATOR ", "»«argument.refType.type.typeName» «argument.name»«ENDFOR»'''
}
-// def ClassFunctionSignature(String classname, String functionname, EList<VarDecl> arguments, ){
- def ClassOperationSignature(String classname, String operationname, String argumentList, String returnType, boolean isDeclaration){'''
- «languageExt.accessLevelPublic()»«IF returnType==""»void«ELSE»«returnType»«ENDIF» «languageExt.operationScope(classname, isDeclaration)»«operationname»(«languageExt.selfPointer(classname, argumentList.length)»«argumentList»)'''
+ def private classOperationSignature(String classname, String operationname, String argumentList, String returnType, boolean isDeclaration){
+ '''«languageExt.accessLevelPublic()»«returnType» «memberInDeclaration(classname, operationname)»(«languageExt.selfPointer(classname, !argumentList.empty)»«argumentList»)'''
}
} \ No newline at end of file
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 4fd4f6a2e..d917be566 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
@@ -182,6 +182,57 @@ public class RoomExtensions {
return _punion;
}
+ public List<Port> getAllEndPorts(final ActorClass ac) {
+ List<Port> _xifexpression = null;
+ ActorClass _base = ac.getBase();
+ boolean _operator_equals = ObjectExtensions.operator_equals(_base, null);
+ if (_operator_equals) {
+ List<Port> _endPorts = this.getEndPorts(ac);
+ return _endPorts;
+ } else {
+ ActorClass _base_1 = ac.getBase();
+ List<Port> _allEndPorts = this.getAllEndPorts(_base_1);
+ List<Port> _endPorts_1 = this.getEndPorts(ac);
+ List<Port> _union = this.<Port>union(_allEndPorts, _endPorts_1);
+ _xifexpression = _union;
+ }
+ return _xifexpression;
+ }
+
+ public List<SAPRef> getAllSAPs(final ActorClass ac) {
+ List<SAPRef> _xifexpression = null;
+ ActorClass _base = ac.getBase();
+ boolean _operator_equals = ObjectExtensions.operator_equals(_base, null);
+ if (_operator_equals) {
+ EList<SAPRef> _strSAPs = ac.getStrSAPs();
+ return _strSAPs;
+ } else {
+ ActorClass _base_1 = ac.getBase();
+ EList<SAPRef> _strSAPs_1 = _base_1.getStrSAPs();
+ EList<SAPRef> _strSAPs_2 = ac.getStrSAPs();
+ List<SAPRef> _union = this.<SAPRef>union(_strSAPs_1, _strSAPs_2);
+ _xifexpression = _union;
+ }
+ return _xifexpression;
+ }
+
+ public List<ServiceImplementation> getAllServiceImplementations(final ActorClass ac) {
+ List<ServiceImplementation> _xifexpression = null;
+ ActorClass _base = ac.getBase();
+ boolean _operator_equals = ObjectExtensions.operator_equals(_base, null);
+ if (_operator_equals) {
+ EList<ServiceImplementation> _serviceImplementations = ac.getServiceImplementations();
+ return _serviceImplementations;
+ } else {
+ ActorClass _base_1 = ac.getBase();
+ EList<ServiceImplementation> _serviceImplementations_1 = _base_1.getServiceImplementations();
+ EList<ServiceImplementation> _serviceImplementations_2 = ac.getServiceImplementations();
+ List<ServiceImplementation> _union = this.<ServiceImplementation>union(_serviceImplementations_1, _serviceImplementations_2);
+ _xifexpression = _union;
+ }
+ return _xifexpression;
+ }
+
public String getPathName(final String path) {
String _replaceAll = path.replaceAll("/", "_");
return _replaceAll;
@@ -484,6 +535,23 @@ public class RoomExtensions {
return ret;
}
+ public ArrayList<State> getLeafStatesFirst(final List<State> states) {
+ ArrayList<State> _arrayList = new ArrayList<State>();
+ ArrayList<State> leaf = _arrayList;
+ ArrayList<State> _arrayList_1 = new ArrayList<State>();
+ ArrayList<State> nonLeaf = _arrayList_1;
+ for (final State state : states) {
+ boolean _isLeaf = this.isLeaf(state);
+ if (_isLeaf) {
+ leaf.add(state);
+ } else {
+ nonLeaf.add(state);
+ }
+ }
+ leaf.addAll(nonLeaf);
+ return leaf;
+ }
+
public List<State> getAllBaseStates(final ActorClass ac) {
List<State> _xifexpression = null;
ActorClass _base = ac.getBase();
@@ -503,6 +571,47 @@ public class RoomExtensions {
return _xifexpression;
}
+ public List<State> getAllBaseStatesLeavesFirst(final ActorClass ac) {
+ List<State> _xifexpression = null;
+ ActorClass _base = ac.getBase();
+ boolean _operator_equals = ObjectExtensions.operator_equals(_base, null);
+ if (_operator_equals) {
+ StateGraph _stateMachine = ac.getStateMachine();
+ List<State> _baseStateList = this.getBaseStateList(_stateMachine);
+ ArrayList<State> _leafStatesFirst = this.getLeafStatesFirst(_baseStateList);
+ return _leafStatesFirst;
+ } else {
+ ActorClass _base_1 = ac.getBase();
+ List<State> _allBaseStates = this.getAllBaseStates(_base_1);
+ ArrayList<State> _leafStatesFirst_1 = this.getLeafStatesFirst(_allBaseStates);
+ StateGraph _stateMachine_1 = ac.getStateMachine();
+ List<State> _baseStateList_1 = this.getBaseStateList(_stateMachine_1);
+ ArrayList<State> _leafStatesFirst_2 = this.getLeafStatesFirst(_baseStateList_1);
+ List<State> _union = this.<State>union(_leafStatesFirst_1, _leafStatesFirst_2);
+ _xifexpression = _union;
+ }
+ return _xifexpression;
+ }
+
+ public List<State> getAllLeafStates(final ActorClass ac) {
+ List<State> _xifexpression = null;
+ ActorClass _base = ac.getBase();
+ boolean _operator_equals = ObjectExtensions.operator_equals(_base, null);
+ if (_operator_equals) {
+ StateGraph _stateMachine = ac.getStateMachine();
+ List<State> _leafStateList = this.getLeafStateList(_stateMachine);
+ return _leafStateList;
+ } else {
+ ActorClass _base_1 = ac.getBase();
+ List<State> _allLeafStates = this.getAllLeafStates(_base_1);
+ StateGraph _stateMachine_1 = ac.getStateMachine();
+ List<State> _leafStateList_1 = this.getLeafStateList(_stateMachine_1);
+ List<State> _union = this.<State>union(_allLeafStates, _leafStateList_1);
+ _xifexpression = _union;
+ }
+ return _xifexpression;
+ }
+
public boolean overridesStop(final ActorClass ac) {
boolean _operator_or = false;
EList<StandardOperation> _operations = ac.getOperations();
diff --git a/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/ProcedureHelpers.java b/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/ProcedureHelpers.java
index d6c354193..a027bb9d0 100644
--- a/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/ProcedureHelpers.java
+++ b/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/ProcedureHelpers.java
@@ -13,6 +13,7 @@ import org.eclipse.etrice.core.room.VarDecl;
import org.eclipse.etrice.generator.base.ILogger;
import org.eclipse.etrice.generator.generic.ILanguageExtension;
import org.eclipse.etrice.generator.generic.TypeHelpers;
+import org.eclipse.xtext.xbase.lib.BooleanExtensions;
import org.eclipse.xtext.xbase.lib.ComparableExtensions;
import org.eclipse.xtext.xbase.lib.Conversions;
import org.eclipse.xtext.xbase.lib.IntegerExtensions;
@@ -32,7 +33,7 @@ public class ProcedureHelpers {
@Inject
private ILogger logger;
- public StringConcatenation UserCode(final DetailCode dc) {
+ public StringConcatenation userCode(final DetailCode dc) {
StringConcatenation _builder = new StringConcatenation();
{
boolean _operator_notEquals = ObjectExtensions.operator_notEquals(dc, null);
@@ -57,7 +58,7 @@ public class ProcedureHelpers {
/**
* TODO: add ref type
*/
- public StringConcatenation Attributes(final List<Attribute> attribs) {
+ public StringConcatenation attributes(final List<Attribute> attribs) {
StringConcatenation _builder = new StringConcatenation();
_builder.append("//--------------------- attributes");
_builder.newLine();
@@ -279,18 +280,18 @@ public class ProcedureHelpers {
return _builder;
}
- public StringConcatenation AttributeSettersGettersDeclaration(final List<Attribute> attribs, final String classname) {
+ public StringConcatenation attributeSettersGettersDeclaration(final List<Attribute> attribs, final String classname) {
StringConcatenation _builder = new StringConcatenation();
_builder.append("//--------------------- attribute setters and getters");
_builder.newLine();
{
for(final Attribute attribute : attribs) {
- StringConcatenation _SetterHeader = this.SetterHeader(attribute, classname);
- _builder.append(_SetterHeader, "");
+ StringConcatenation _setterHeader = this.setterHeader(attribute, classname);
+ _builder.append(_setterHeader, "");
_builder.append(";");
_builder.newLineIfNotEmpty();
- StringConcatenation _GetterHeader = this.GetterHeader(attribute, classname);
- _builder.append(_GetterHeader, "");
+ StringConcatenation _terHeader = this.getterHeader(attribute, classname);
+ _builder.append(_terHeader, "");
_builder.append(";");
_builder.newLineIfNotEmpty();
}
@@ -298,14 +299,14 @@ public class ProcedureHelpers {
return _builder;
}
- public StringConcatenation AttributeSettersGettersImplementation(final List<Attribute> attribs, final String classname) {
+ public StringConcatenation attributeSettersGettersImplementation(final List<Attribute> attribs, final String classname) {
StringConcatenation _builder = new StringConcatenation();
_builder.append("//--------------------- attribute setters and getters");
_builder.newLine();
{
for(final Attribute attribute : attribs) {
- StringConcatenation _SetterHeader = this.SetterHeader(attribute, classname);
- _builder.append(_SetterHeader, "");
+ StringConcatenation _setterHeader = this.setterHeader(attribute, classname);
+ _builder.append(_setterHeader, "");
_builder.append(" {");
_builder.newLineIfNotEmpty();
_builder.append("\t ");
@@ -320,8 +321,8 @@ public class ProcedureHelpers {
_builder.newLineIfNotEmpty();
_builder.append("}");
_builder.newLine();
- StringConcatenation _GetterHeader = this.GetterHeader(attribute, classname);
- _builder.append(_GetterHeader, "");
+ StringConcatenation _terHeader = this.getterHeader(attribute, classname);
+ _builder.append(_terHeader, "");
_builder.append(" {");
_builder.newLineIfNotEmpty();
_builder.append("\t");
@@ -339,7 +340,7 @@ public class ProcedureHelpers {
return _builder;
}
- private StringConcatenation SetterHeader(final Attribute attribute, final String classname) {
+ private StringConcatenation setterHeader(final Attribute attribute, final String classname) {
StringConcatenation _builder = new StringConcatenation();
String _accessLevelPublic = this.languageExt.accessLevelPublic();
_builder.append(_accessLevelPublic, "");
@@ -348,7 +349,7 @@ public class ProcedureHelpers {
String _firstUpper = StringExtensions.toFirstUpper(_name);
_builder.append(_firstUpper, "");
_builder.append(" (");
- String _selfPointer = this.languageExt.selfPointer(classname, 1);
+ String _selfPointer = this.languageExt.selfPointer(classname, true);
_builder.append(_selfPointer, "");
RefableType _refType = attribute.getRefType();
DataType _type = _refType.getType();
@@ -368,7 +369,7 @@ public class ProcedureHelpers {
return _builder;
}
- private StringConcatenation GetterHeader(final Attribute attribute, final String classname) {
+ private StringConcatenation getterHeader(final Attribute attribute, final String classname) {
StringConcatenation _builder = new StringConcatenation();
String _accessLevelPublic = this.languageExt.accessLevelPublic();
_builder.append(_accessLevelPublic, "");
@@ -388,7 +389,7 @@ public class ProcedureHelpers {
String _firstUpper = StringExtensions.toFirstUpper(_name);
_builder.append(_firstUpper, "");
_builder.append(" (");
- String _selfPointer = this.languageExt.selfPointer(classname, 0);
+ String _selfPointer = this.languageExt.selfPointer(classname, false);
_builder.append(_selfPointer, "");
_builder.append(")");
return _builder;
@@ -423,14 +424,14 @@ public class ProcedureHelpers {
return _builder;
}
- public StringConcatenation OperationsDeclaration(final List<? extends Operation> operations, final String classname) {
+ public StringConcatenation operationsDeclaration(final List<? extends Operation> operations, final String classname) {
StringConcatenation _builder = new StringConcatenation();
_builder.append("//--------------------- operations");
_builder.newLine();
{
for(final Operation operation : operations) {
- StringConcatenation _OperationSignature = this.OperationSignature(operation, classname, true);
- _builder.append(_OperationSignature, "");
+ StringConcatenation _operationSignature = this.operationSignature(operation, classname, true);
+ _builder.append(_operationSignature, "");
_builder.append(";");
_builder.newLineIfNotEmpty();
}
@@ -438,14 +439,14 @@ public class ProcedureHelpers {
return _builder;
}
- public StringConcatenation OperationsImplementation(final List<? extends Operation> operations, final String classname) {
+ public StringConcatenation operationsImplementation(final List<? extends Operation> operations, final String classname) {
StringConcatenation _builder = new StringConcatenation();
_builder.append("//--------------------- operations");
_builder.newLine();
{
for(final Operation operation : operations) {
- StringConcatenation _OperationSignature = this.OperationSignature(operation, classname, false);
- _builder.append(_OperationSignature, "");
+ StringConcatenation _operationSignature = this.operationSignature(operation, classname, false);
+ _builder.append(_operationSignature, "");
_builder.append(" {");
_builder.newLineIfNotEmpty();
{
@@ -453,7 +454,7 @@ public class ProcedureHelpers {
EList<String> _commands = _detailCode.getCommands();
for(final String command : _commands) {
_builder.append("\t");
- _builder.append(command, "");
+ _builder.append(command, " ");
_builder.newLineIfNotEmpty();
}
}
@@ -464,26 +465,28 @@ public class ProcedureHelpers {
return _builder;
}
- private StringConcatenation OperationSignature(final Operation operation, final String classname, final boolean isDeclaration) {
+ private StringConcatenation operationSignature(final Operation operation, final String classname, final boolean isDeclaration) {
String _name = operation.getName();
EList<VarDecl> _arguments = operation.getArguments();
StringConcatenation _BuildArgumentList = this.BuildArgumentList(_arguments);
String _string = _BuildArgumentList.toString();
RefableType _returntype = operation.getReturntype();
- String _DataTypeToString = this.DataTypeToString(_returntype);
- StringConcatenation _ClassOperationSignature = this.ClassOperationSignature(classname, _name, _string, _DataTypeToString, isDeclaration);
- return _ClassOperationSignature;
+ String _dataTypeToString = this.dataTypeToString(_returntype);
+ StringConcatenation _classOperationSignature = this.classOperationSignature(classname, _name, _string, _dataTypeToString, isDeclaration);
+ return _classOperationSignature;
}
- private String DataTypeToString(final RefableType type) {
+ private String dataTypeToString(final RefableType type) {
+ String _xifexpression = null;
boolean _operator_equals = ObjectExtensions.operator_equals(type, null);
if (_operator_equals) {
- return "void";
+ _xifexpression = "void";
} else {
DataType _type = type.getType();
String _typeName = this._typeHelpers.typeName(_type);
- return _typeName;
+ _xifexpression = _typeName;
}
+ return _xifexpression;
}
/**
@@ -511,25 +514,18 @@ public class ProcedureHelpers {
return _builder;
}
- public StringConcatenation ClassOperationSignature(final String classname, final String operationname, final String argumentList, final String returnType, final boolean isDeclaration) {
+ private StringConcatenation classOperationSignature(final String classname, final String operationname, final String argumentList, final String returnType, final boolean isDeclaration) {
StringConcatenation _builder = new StringConcatenation();
String _accessLevelPublic = this.languageExt.accessLevelPublic();
_builder.append(_accessLevelPublic, "");
- {
- boolean _operator_equals = ObjectExtensions.operator_equals(returnType, "");
- if (_operator_equals) {
- _builder.append("void");
- } else {
- _builder.append(returnType, "");
- }
- }
+ _builder.append(returnType, "");
_builder.append(" ");
- String _operationScope = this.languageExt.operationScope(classname, isDeclaration);
- _builder.append(_operationScope, "");
- _builder.append(operationname, "");
+ String _memberInDeclaration = this.languageExt.memberInDeclaration(classname, operationname);
+ _builder.append(_memberInDeclaration, "");
_builder.append("(");
- int _length = argumentList.length();
- String _selfPointer = this.languageExt.selfPointer(classname, _length);
+ boolean _isEmpty = argumentList.isEmpty();
+ boolean _operator_not = BooleanExtensions.operator_not(_isEmpty);
+ String _selfPointer = this.languageExt.selfPointer(classname, _operator_not);
_builder.append(_selfPointer, "");
_builder.append(argumentList, "");
_builder.append(")");
diff --git a/runtime/org.eclipse.etrice.modellib/models/TimingService.room b/runtime/org.eclipse.etrice.modellib/models/TimingService.room
index 2498d0947..8fccf01e5 100644
--- a/runtime/org.eclipse.etrice.modellib/models/TimingService.room
+++ b/runtime/org.eclipse.etrice.modellib/models/TimingService.room
@@ -40,7 +40,7 @@ RoomModel room.basic.service.timing {
action {
"// start timeout"
"taskCount++;"
- "if (taskCount>PURGE_LIMIT) timerService.purge();"
+ "if (taskCount>PURGE_LIMIT) timerService.purge();"
"timerService.schedule(((PTimeoutPort)ifitem).getTask(), time_ms);"
}
}
diff --git a/runtime/org.eclipse.etrice.modellib/src-gen/room/basic/service/timing/ATimingService.java b/runtime/org.eclipse.etrice.modellib/src-gen/room/basic/service/timing/ATimingService.java
index 2f23163f0..f30bfda23 100644
--- a/runtime/org.eclipse.etrice.modellib/src-gen/room/basic/service/timing/ATimingService.java
+++ b/runtime/org.eclipse.etrice.modellib/src-gen/room/basic/service/timing/ATimingService.java
@@ -32,9 +32,9 @@ public class ATimingService extends ActorClassBase {
protected PTimeoutPortRepl timeout = null;
//--------------------- interface item IDs
- protected static final int IFITEM_timer = 1;
- protected static final int IFITEM_timeout = 2;
-
+ public static final int IFITEM_timer = 1;
+ public static final int IFITEM_timeout = 2;
+
//--------------------- attributes
//--------------------- operations
public void stop() {
@@ -72,100 +72,58 @@ public class ATimingService extends ActorClassBase {
destroyUser();
}
- //******************************************
- // START of generated code for FSM
- //******************************************
- // State IDs for FSM
- protected static final int STATE_Operational = 2;
- protected static final String stateStrings[] = {"<no state>","<top>","Operational"
- };
+ /* state IDs */
+ public static final int STATE_Operational = 2;
- // history
- // TODOHRR: history defined in ActorClassBase, init in constructor
- // history = new int[5];
- // for (int i = 0; i < history.length; i++) {
- // history[i] = NO_STATE;
- // }
- protected int history[] = {NO_STATE,NO_STATE,NO_STATE};
+ /* transition chains */
+ public static final int CHAIN_TRANS_INITIAL_TO__Operational = 1;
+ public static final int CHAIN_TRANS_Operational_TO_Operational_BY_Killtimeout_tr2 = 2;
+ public static final int CHAIN_TRANS_Operational_TO_Operational_BY_Killtimer_tr4 = 3;
+ public static final int CHAIN_TRANS_Operational_TO_Operational_BY_Starttimeout_tr1 = 4;
+ public static final int CHAIN_TRANS_Operational_TO_Operational_BY_Starttimer_tr3 = 5;
- // transition chains
- protected static final int CHAIN_TRANS_INITIAL_TO__Operational = 1;
- protected static final int CHAIN_TRANS_Operational_TO_Operational_BY_Killtimeout_tr2 = 2;
- protected static final int CHAIN_TRANS_Operational_TO_Operational_BY_Killtimer_tr4 = 3;
- protected static final int CHAIN_TRANS_Operational_TO_Operational_BY_Starttimeout_tr1 = 4;
- protected static final int CHAIN_TRANS_Operational_TO_Operational_BY_Starttimer_tr3 = 5;
+ /* triggers */
+ public static final int TRIG_timeout__Kill = IFITEM_timeout + EVT_SHIFT*PTimeout.IN_Kill;
+ public static final int TRIG_timeout__Start = IFITEM_timeout + EVT_SHIFT*PTimeout.IN_Start;
+ public static final int TRIG_timer__Kill = IFITEM_timer + EVT_SHIFT*PTimer.IN_Kill;
+ public static final int TRIG_timer__Start = IFITEM_timer + EVT_SHIFT*PTimer.IN_Start;
- // triggers for FSM
- protected static final int TRIG_timeout__Kill = IFITEM_timeout + EVT_SHIFT*PTimeout.IN_Kill;
- protected static final int TRIG_timeout__Start = IFITEM_timeout + EVT_SHIFT*PTimeout.IN_Start;
- protected static final int TRIG_timer__Kill = IFITEM_timer + EVT_SHIFT*PTimer.IN_Kill;
- protected static final int TRIG_timer__Start = IFITEM_timer + EVT_SHIFT*PTimer.IN_Start;
+ // state names
+ protected static final String stateStrings[] = {"<no state>","<top>","Operational"
+ };
- // receiveEvent contains the main implementation of the FSM
- @Override
- public void receiveEvent(InterfaceItemBase ifitem, int evt, Object generic_data) {
- int trigger = ifitem.getLocalId() + EVT_SHIFT*evt;
- int chain = NOT_CAUGHT;
- int catching_state = NO_STATE;
- boolean is_handler = false;
- boolean skip_entry = false;
-
- if (!handleSystemEvent(ifitem, evt, generic_data)) {
- switch (state) {
- case STATE_Operational:
- switch(trigger) {
- case TRIG_timeout__Start:
- {
- chain = CHAIN_TRANS_Operational_TO_Operational_BY_Starttimeout_tr1;
- catching_state = STATE_TOP;
- }
- break;
- case TRIG_timeout__Kill:
- {
- chain = CHAIN_TRANS_Operational_TO_Operational_BY_Killtimeout_tr2;
- catching_state = STATE_TOP;
- }
- break;
- case TRIG_timer__Start:
- {
- chain = CHAIN_TRANS_Operational_TO_Operational_BY_Starttimer_tr3;
- catching_state = STATE_TOP;
- }
- break;
- case TRIG_timer__Kill:
- {
- chain = CHAIN_TRANS_Operational_TO_Operational_BY_Killtimer_tr4;
- catching_state = STATE_TOP;
- }
- break;
- }
- break;
- }
- }
- if (chain != NOT_CAUGHT) {
- exitTo(state, catching_state, is_handler);
- int next = executeTransitionChain(chain, ifitem, generic_data);
- next = enterHistory(next, is_handler, skip_entry);
- setState(next);
- }
- }
+ // history
+ protected int history[] = {NO_STATE,NO_STATE,NO_STATE};
private void setState(int new_state) {
DebuggingService.getInstance().addActorState(this,stateStrings[new_state]);
if (stateStrings[new_state]!="Idle") {
- // TODOTS: model switch for activation
System.out.println(getInstancePath() + " -> " + stateStrings[new_state]);
}
this.state = new_state;
}
- @Override
- public void executeInitTransition() {
- int chain = CHAIN_TRANS_INITIAL_TO__Operational;
- int next = executeTransitionChain(chain, null, null);
- next = enterHistory(next, false, false);
- setState(next);
+ //*** Entry and Exit Codes
+ protected void entry_Operational() {
+ // prepare
+ }
+
+ //*** Action Codes
+ protected void action_TRANS_INITIAL_TO__Operational() {
+ timerService = new Timer();
+ }
+ protected void action_TRANS_Operational_TO_Operational_BY_Starttimeout_tr1(InterfaceItemBase ifitem, int time_ms) {
+ // start timeout
+ taskCount++;
+ if (taskCount>PURGE_LIMIT) timerService.purge();
+ timerService.schedule(((PTimeoutPort)ifitem).getTask(), time_ms);
+ }
+ protected void action_TRANS_Operational_TO_Operational_BY_Starttimer_tr3(InterfaceItemBase ifitem, int time_ms) {
+ // start timer
+ taskCount++;
+ if (taskCount>PURGE_LIMIT) timerService.purge();
+ timerService.scheduleAtFixedRate(((PTimerPort)ifitem).getTask(), time_ms, time_ms);
}
/**
@@ -179,12 +137,13 @@ public class ATimingService extends ActorClassBase {
while (current!=to) {
switch (current) {
case STATE_Operational:
- history[STATE_TOP] = STATE_Operational;
+ this.history[STATE_TOP] = STATE_Operational;
current = STATE_TOP;
break;
}
}
}
+
/**
* calls action, entry and exit codes along a transition chain. The generic data are cast to typed data
* matching the trigger of this chain. The ID of the final state is returned
@@ -222,6 +181,7 @@ public class ATimingService extends ActorClassBase {
}
return NO_STATE;
}
+
/**
* calls entry codes while entering a state's history. The ID of the final leaf state is returned
* @param state - the state which is entered
@@ -236,7 +196,7 @@ public class ATimingService extends ActorClassBase {
// in leaf state: return state id
return STATE_Operational;
case STATE_TOP:
- state = history[STATE_TOP];
+ state = this.history[STATE_TOP];
break;
}
skip_entry = false;
@@ -244,26 +204,59 @@ public class ATimingService extends ActorClassBase {
//return NO_STATE; // required by CDT but detected as unreachable by JDT because of while (true)
}
- //*** Entry and Exit Codes
- protected void entry_Operational() {
- // prepare
+ public void executeInitTransition() {
+ int chain = CHAIN_TRANS_INITIAL_TO__Operational;
+ int next = executeTransitionChain(chain, null, null);
+ next = enterHistory(next, false, false);
+ setState(next);
}
- //*** Action Codes
- protected void action_TRANS_INITIAL_TO__Operational() {
- timerService = new Timer();
- }
- protected void action_TRANS_Operational_TO_Operational_BY_Starttimeout_tr1(InterfaceItemBase ifitem, int time_ms) {
- // start timeout
- taskCount++;
- if (taskCount>PURGE_LIMIT) timerService.purge();
- timerService.schedule(((PTimeoutPort)ifitem).getTask(), time_ms);
- }
- protected void action_TRANS_Operational_TO_Operational_BY_Starttimer_tr3(InterfaceItemBase ifitem, int time_ms) {
- // start timer
- taskCount++;
- if (taskCount>PURGE_LIMIT) timerService.purge();
- timerService.scheduleAtFixedRate(((PTimerPort)ifitem).getTask(), time_ms, time_ms);
+ /* receiveEvent contains the main implementation of the FSM */
+ public void receiveEvent(InterfaceItemBase ifitem, int evt, Object generic_data) {
+ int trigger = ifitem.getLocalId() + EVT_SHIFT*evt;
+ int chain = NOT_CAUGHT;
+ int catching_state = NO_STATE;
+ boolean is_handler = false;
+ boolean skip_entry = false;
+
+ if (!handleSystemEvent(ifitem, evt, generic_data)) {
+ switch (this.state) {
+ case STATE_Operational:
+ switch(trigger) {
+ case TRIG_timeout__Start:
+ {
+ chain = CHAIN_TRANS_Operational_TO_Operational_BY_Starttimeout_tr1;
+ catching_state = STATE_TOP;
+ }
+ break;
+ case TRIG_timeout__Kill:
+ {
+ chain = CHAIN_TRANS_Operational_TO_Operational_BY_Killtimeout_tr2;
+ catching_state = STATE_TOP;
+ }
+ break;
+ case TRIG_timer__Start:
+ {
+ chain = CHAIN_TRANS_Operational_TO_Operational_BY_Starttimer_tr3;
+ catching_state = STATE_TOP;
+ }
+ break;
+ case TRIG_timer__Kill:
+ {
+ chain = CHAIN_TRANS_Operational_TO_Operational_BY_Killtimer_tr4;
+ catching_state = STATE_TOP;
+ }
+ break;
+ }
+ break;
+ }
+ }
+ if (chain != NOT_CAUGHT) {
+ exitTo(this.state, catching_state, is_handler);
+ int next = executeTransitionChain(chain, ifitem, generic_data);
+ next = enterHistory(next, is_handler, skip_entry);
+ setState(next);
+ }
}
//******************************************
diff --git a/runtime/org.eclipse.etrice.modellib/src-gen/room/basic/service/timing/PTimeout.java b/runtime/org.eclipse.etrice.modellib/src-gen/room/basic/service/timing/PTimeout.java
index 1df8619e3..3f06d4ae0 100644
--- a/runtime/org.eclipse.etrice.modellib/src-gen/room/basic/service/timing/PTimeout.java
+++ b/runtime/org.eclipse.etrice.modellib/src-gen/room/basic/service/timing/PTimeout.java
@@ -14,16 +14,11 @@ import org.eclipse.etrice.runtime.java.debugging.DebuggingService;
public class PTimeout {
// message IDs
- // TODO: separate class for message IDs: class MSG{public static volatile int MSG_MIN = 0; ...} -> better structure
- // error if msgID <= MSG_MIN
- public static final int MSG_MIN = 0;
- //IDs for outgoing messages
+ public static final int MSG_MIN = 0;
public static final int OUT_timeoutTick = 1;
- //IDs for incoming messages
public static final int IN_Start = 2;
public static final int IN_Kill = 3;
- //error if msgID >= MSG_MAX
- public static final int MSG_MAX = 4;
+ public static final int MSG_MAX = 4;
//--------------------- begin user code
static protected class FireTimeoutTask extends TimerTask {
@@ -137,11 +132,11 @@ public class PTimeout {
//--------------------- operations
public void timeout(Integer id) {
//regular PortClass Operation timeout
- DebuggingService.getInstance().addMessageAsyncOut(getAddress(),
- getPeerAddress(), messageStrings[OUT_timeoutTick]);
-
- getPeerMsgReceiver().receive(
- new EventWithDataMessage(getPeerAddress(), OUT_timeoutTick, id));
+ DebuggingService.getInstance().addMessageAsyncOut(getAddress(),
+ getPeerAddress(), messageStrings[OUT_timeoutTick]);
+
+ getPeerMsgReceiver().receive(
+ new EventWithDataMessage(getPeerAddress(), OUT_timeoutTick, id));
}
// sent messages
diff --git a/runtime/org.eclipse.etrice.modellib/src-gen/room/basic/service/timing/PTimer.java b/runtime/org.eclipse.etrice.modellib/src-gen/room/basic/service/timing/PTimer.java
index 426cafb1f..aaa64e4bc 100644
--- a/runtime/org.eclipse.etrice.modellib/src-gen/room/basic/service/timing/PTimer.java
+++ b/runtime/org.eclipse.etrice.modellib/src-gen/room/basic/service/timing/PTimer.java
@@ -14,16 +14,11 @@ import org.eclipse.etrice.runtime.java.debugging.DebuggingService;
public class PTimer {
// message IDs
- // TODO: separate class for message IDs: class MSG{public static volatile int MSG_MIN = 0; ...} -> better structure
- // error if msgID <= MSG_MIN
- public static final int MSG_MIN = 0;
- //IDs for outgoing messages
+ public static final int MSG_MIN = 0;
public static final int OUT_timerTick = 1;
- //IDs for incoming messages
public static final int IN_Start = 2;
public static final int IN_Kill = 3;
- //error if msgID >= MSG_MAX
- public static final int MSG_MAX = 4;
+ public static final int MSG_MAX = 4;
//--------------------- begin user code
static protected class FireTimerTask extends TimerTask {
@@ -137,11 +132,11 @@ public class PTimer {
//--------------------- operations
public void timer(Integer id) {
//regular PortClass Operation timer
- DebuggingService.getInstance().addMessageAsyncOut(getAddress(),
- getPeerAddress(), messageStrings[OUT_timerTick]);
-
- getPeerMsgReceiver().receive(
- new EventWithDataMessage(getPeerAddress(), OUT_timerTick, id));
+ DebuggingService.getInstance().addMessageAsyncOut(getAddress(),
+ getPeerAddress(), messageStrings[OUT_timerTick]);
+
+ getPeerMsgReceiver().receive(
+ new EventWithDataMessage(getPeerAddress(), OUT_timerTick, id));
}
// sent messages
diff --git a/runtime/org.eclipse.etrice.runtime.c/Debug/liborg.eclipse.etrice.runtime.c.a b/runtime/org.eclipse.etrice.runtime.c/Debug/liborg.eclipse.etrice.runtime.c.a
index 7ec20988a..6824bf738 100644
--- a/runtime/org.eclipse.etrice.runtime.c/Debug/liborg.eclipse.etrice.runtime.c.a
+++ b/runtime/org.eclipse.etrice.runtime.c/Debug/liborg.eclipse.etrice.runtime.c.a
Binary files differ
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/etActor.c b/runtime/org.eclipse.etrice.runtime.c/src/etActor.c
new file mode 100644
index 000000000..008a6474d
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.c/src/etActor.c
@@ -0,0 +1,18 @@
+/*******************************************************************************
+ * 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)
+ *
+ *******************************************************************************/
+
+#include "etActor.h"
+
+boolean handleSystemEvent(InterfaceItemBase ifitem, int evt, void* generic_data) {
+ /* TODO */
+ return FALSE;
+}
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/etActor.h b/runtime/org.eclipse.etrice.runtime.c/src/etActor.h
new file mode 100644
index 000000000..5cd70f694
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.c/src/etActor.h
@@ -0,0 +1,24 @@
+/*******************************************************************************
+ * Copyright (c) 2012 protos software gmbh (http://www.protos.de).
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * CONTRIBUTORS:
+ * Henrik Rentz-Reichert (initial contribution)
+ *
+ *******************************************************************************/
+
+#ifndef _ETACTOR_H_
+#define _ETACTOR_H_
+
+#include "etDataTypes.h"
+#include "etPort.h"
+
+#define NOT_CAUGHT 0
+#define EVT_SHIFT 100
+
+boolean handleSystemEvent(InterfaceItemBase ifitem, int evt, void* generic_data);
+
+#endif /* _ETACTOR_H_ */
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/etDatatypes.h b/runtime/org.eclipse.etrice.runtime.c/src/etDatatypes.h
index e49ebf53a..bf161f396 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/etDatatypes.h
+++ b/runtime/org.eclipse.etrice.runtime.c/src/etDatatypes.h
@@ -39,6 +39,7 @@ typedef double float64;
/* boolean datatypes and values */
typedef char bool; /* TODO: bool, Bool, Boolean, and boolean are already defined in some platforms*/
+typedef bool boolean;
#ifndef TRUE
#define TRUE 1
#endif
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/etMessageReceiver.h b/runtime/org.eclipse.etrice.runtime.c/src/etMessageReceiver.h
index 4d5c35680..c75686654 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/etMessageReceiver.h
+++ b/runtime/org.eclipse.etrice.runtime.c/src/etMessageReceiver.h
@@ -17,7 +17,7 @@
#include "etMessage.h"
-typedef void (*etActorReceiveMessage)(void* self, etInt16 localId, const etMessage* msg);
+typedef void (*etActorReceiveMessage)(void* self, void* ifitem, const etMessage* msg);
typedef void (*etDispatcherReceiveMessage)(const etMessage* msg);
#endif /* _ETMESSAGERECEIVER_H_ */
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/etPort.h b/runtime/org.eclipse.etrice.runtime.c/src/etPort.h
index f7b4ea81e..3e7bd617b 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/etPort.h
+++ b/runtime/org.eclipse.etrice.runtime.c/src/etPort.h
@@ -33,6 +33,8 @@ typedef struct {
#endif
} etPort;
+typedef etPort* InterfaceItemBase;
+
void etPort_receive(const etPort* self, const etMessage* msg);
diff --git a/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/ActorClassBase.java b/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/ActorClassBase.java
index ad67fc2c0..8cef1e8f0 100644
--- a/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/ActorClassBase.java
+++ b/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/ActorClassBase.java
@@ -99,7 +99,7 @@ public abstract class ActorClassBase extends EventReceiver implements IMessageRe
return ownMsgsvc;
}
- protected boolean handleSystemEvent(InterfaceItemBase ifitem, int evt, Object... generic_data){
+ protected boolean handleSystemEvent(InterfaceItemBase ifitem, int evt, Object generic_data){
if (ifitem.getLocalId()!=0){
return false;
}
diff --git a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/ChoicePointTest/CPTest_Top.java b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/ChoicePointTest/CPTest_Top.java
index f3b1e6372..d58277e17 100644
--- a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/ChoicePointTest/CPTest_Top.java
+++ b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/ChoicePointTest/CPTest_Top.java
@@ -20,7 +20,7 @@ public class CPTest_Top extends ActorClassBase {
//--------------------- services
//--------------------- interface item IDs
-
+
//--------------------- attributes
//--------------------- operations
diff --git a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/ChoicePointTest/CPTester.java b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/ChoicePointTest/CPTester.java
index 6d53af0bc..d0f1564b3 100644
--- a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/ChoicePointTest/CPTester.java
+++ b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/ChoicePointTest/CPTester.java
@@ -22,8 +22,8 @@ public class CPTester extends ActorClassBase {
//--------------------- services
//--------------------- interface item IDs
- protected static final int IFITEM_TestPort1 = 1;
-
+ public static final int IFITEM_TestPort1 = 1;
+
//--------------------- attributes
//--------------------- operations
@@ -58,66 +58,51 @@ public class CPTester extends ActorClassBase {
destroyUser();
}
- //******************************************
- // START of generated code for FSM
- //******************************************
- // State IDs for FSM
- protected static final int STATE_state0 = 2;
- protected static final String stateStrings[] = {"<no state>","<top>","state0"
- };
+ /* state IDs */
+ public static final int STATE_state0 = 2;
- // history
- // TODOHRR: history defined in ActorClassBase, init in constructor
- // history = new int[5];
- // for (int i = 0; i < history.length; i++) {
- // history[i] = NO_STATE;
- // }
- protected int history[] = {NO_STATE,NO_STATE,NO_STATE};
+ /* transition chains */
+ public static final int CHAIN_TRANS_INITIAL_TO__state0 = 1;
- // transition chains
- protected static final int CHAIN_TRANS_INITIAL_TO__state0 = 1;
+ /* triggers */
- // triggers for FSM
+ // state names
+ protected static final String stateStrings[] = {"<no state>","<top>","state0"
+ };
- // receiveEvent contains the main implementation of the FSM
- @Override
- public void receiveEvent(InterfaceItemBase ifitem, int evt, Object generic_data) {
- int trigger = ifitem.getLocalId() + EVT_SHIFT*evt;
- int chain = NOT_CAUGHT;
- int catching_state = NO_STATE;
- boolean is_handler = false;
- boolean skip_entry = false;
-
- if (!handleSystemEvent(ifitem, evt, generic_data)) {
- switch (state) {
- case STATE_state0:
- break;
- }
- }
- if (chain != NOT_CAUGHT) {
- exitTo(state, catching_state, is_handler);
- int next = executeTransitionChain(chain, ifitem, generic_data);
- next = enterHistory(next, is_handler, skip_entry);
- setState(next);
- }
- }
+ // history
+ protected int history[] = {NO_STATE,NO_STATE,NO_STATE};
private void setState(int new_state) {
DebuggingService.getInstance().addActorState(this,stateStrings[new_state]);
if (stateStrings[new_state]!="Idle") {
- // TODOTS: model switch for activation
System.out.println(getInstancePath() + " -> " + stateStrings[new_state]);
}
this.state = new_state;
}
- @Override
- public void executeInitTransition() {
- int chain = CHAIN_TRANS_INITIAL_TO__state0;
- int next = executeTransitionChain(chain, null, null);
- next = enterHistory(next, false, false);
- setState(next);
+ //*** Entry and Exit Codes
+
+ //*** Action Codes
+ protected void action_TRANS_INITIAL_TO__state0() {
+ TestPort1.msg1();
+ System.out.println("msg1 sent ");
+
+ TestPort1.msg1();
+ System.out.println("msg1 sent ");
+
+ TestPort1.msg1();
+ System.out.println("msg1 sent ");
+
+ TestPort1.msg1();
+ System.out.println("msg1 sent ");
+
+ TestPort1.msg1();
+ System.out.println("msg1 sent ");
+
+ TestPort1.msg1();
+ System.out.println("msg1 sent ");
}
/**
@@ -131,12 +116,13 @@ public class CPTester extends ActorClassBase {
while (current!=to) {
switch (current) {
case STATE_state0:
- history[STATE_TOP] = STATE_state0;
+ this.history[STATE_TOP] = STATE_state0;
current = STATE_TOP;
break;
}
}
}
+
/**
* calls action, entry and exit codes along a transition chain. The generic data are cast to typed data
* matching the trigger of this chain. The ID of the final state is returned
@@ -154,6 +140,7 @@ public class CPTester extends ActorClassBase {
}
return NO_STATE;
}
+
/**
* calls entry codes while entering a state's history. The ID of the final leaf state is returned
* @param state - the state which is entered
@@ -167,7 +154,7 @@ public class CPTester extends ActorClassBase {
// in leaf state: return state id
return STATE_state0;
case STATE_TOP:
- state = history[STATE_TOP];
+ state = this.history[STATE_TOP];
break;
}
skip_entry = false;
@@ -175,27 +162,33 @@ public class CPTester extends ActorClassBase {
//return NO_STATE; // required by CDT but detected as unreachable by JDT because of while (true)
}
- //*** Entry and Exit Codes
+ public void executeInitTransition() {
+ int chain = CHAIN_TRANS_INITIAL_TO__state0;
+ int next = executeTransitionChain(chain, null, null);
+ next = enterHistory(next, false, false);
+ setState(next);
+ }
- //*** Action Codes
- protected void action_TRANS_INITIAL_TO__state0() {
- TestPort1.msg1();
- System.out.println("msg1 sent ");
-
- TestPort1.msg1();
- System.out.println("msg1 sent ");
-
- TestPort1.msg1();
- System.out.println("msg1 sent ");
-
- TestPort1.msg1();
- System.out.println("msg1 sent ");
-
- TestPort1.msg1();
- System.out.println("msg1 sent ");
+ /* receiveEvent contains the main implementation of the FSM */
+ public void receiveEvent(InterfaceItemBase ifitem, int evt, Object generic_data) {
+ int trigger = ifitem.getLocalId() + EVT_SHIFT*evt;
+ int chain = NOT_CAUGHT;
+ int catching_state = NO_STATE;
+ boolean is_handler = false;
+ boolean skip_entry = false;
- TestPort1.msg1();
- System.out.println("msg1 sent ");
+ if (!handleSystemEvent(ifitem, evt, generic_data)) {
+ switch (this.state) {
+ case STATE_state0:
+ break;
+ }
+ }
+ if (chain != NOT_CAUGHT) {
+ exitTo(this.state, catching_state, is_handler);
+ int next = executeTransitionChain(chain, ifitem, generic_data);
+ next = enterHistory(next, is_handler, skip_entry);
+ setState(next);
+ }
}
//******************************************
diff --git a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/ChoicePointTest/CPUser.java b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/ChoicePointTest/CPUser.java
index 1172d9aca..9258c5c2a 100644
--- a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/ChoicePointTest/CPUser.java
+++ b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/ChoicePointTest/CPUser.java
@@ -29,8 +29,8 @@ public class CPUser extends ActorClassBase {
//--------------------- services
//--------------------- interface item IDs
- protected static final int IFITEM_TestPort1 = 1;
-
+ public static final int IFITEM_TestPort1 = 1;
+
//--------------------- attributes
protected int counter;
//--------------------- operations
@@ -67,138 +67,141 @@ public class CPUser extends ActorClassBase {
destroyUser();
}
- //******************************************
- // START of generated code for FSM
- //******************************************
- // State IDs for FSM
- protected static final int STATE_state0 = 2;
- protected static final int STATE_state1 = 3;
- protected static final int STATE_state1_state0 = 4;
- protected static final int STATE_testOk = 5;
- protected static final int STATE_testFalse = 6;
- protected static final String stateStrings[] = {"<no state>","<top>","state0",
- "state1",
- "state1_state0",
- "testOk",
- "testFalse"
- };
+ /* state IDs */
+ public static final int STATE_state0 = 2;
+ public static final int STATE_state1_state0 = 3;
+ public static final int STATE_testOk = 4;
+ public static final int STATE_testFalse = 5;
+ public static final int STATE_state1 = 6;
- // history
- // TODOHRR: history defined in ActorClassBase, init in constructor
- // history = new int[5];
- // for (int i = 0; i < history.length; i++) {
- // history[i] = NO_STATE;
- // }
- protected int history[] = {NO_STATE,NO_STATE,NO_STATE,NO_STATE,NO_STATE,NO_STATE,NO_STATE};
+ /* transition chains */
+ public static final int CHAIN_TRANS_INITIAL_TO__cp0 = 1;
+ public static final int CHAIN_TRANS_state0_TO_cp1_BY_msg1TestPort1 = 2;
+ public static final int CHAIN_TRANS_state1_TO_cp2_BY_msg1TestPort1 = 3;
+ public static final int CHAIN_TRANS_state1_TO_state0_BY_msg1TestPort1 = 4;
+ public static final int CHAIN_TRANS_tp0_TO_tp0_BY_msg1TestPort1_tr8 = 5;
+ public static final int CHAIN_state1_TRANS_INITIAL_TO__state0 = 6;
- // transition chains
- protected static final int CHAIN_TRANS_INITIAL_TO__cp0 = 1;
- protected static final int CHAIN_TRANS_state0_TO_cp1_BY_msg1TestPort1 = 2;
- protected static final int CHAIN_TRANS_state1_TO_cp2_BY_msg1TestPort1 = 3;
- protected static final int CHAIN_TRANS_state1_TO_state0_BY_msg1TestPort1 = 4;
- protected static final int CHAIN_TRANS_tp0_TO_tp0_BY_msg1TestPort1_tr8 = 5;
- protected static final int CHAIN_state1_TRANS_INITIAL_TO__state0 = 6;
+ /* triggers */
+ public static final int TRIG_TestPort1__msg1 = IFITEM_TestPort1 + EVT_SHIFT*TestProtocol.IN_msg1;
- // triggers for FSM
- protected static final int TRIG_TestPort1__msg1 = IFITEM_TestPort1 + EVT_SHIFT*TestProtocol.IN_msg1;
+ // state names
+ protected static final String stateStrings[] = {"<no state>","<top>","state0",
+ "state1_state0",
+ "testOk",
+ "testFalse",
+ "state1"
+ };
- // receiveEvent contains the main implementation of the FSM
- @Override
- public void receiveEvent(InterfaceItemBase ifitem, int evt, Object generic_data) {
- int trigger = ifitem.getLocalId() + EVT_SHIFT*evt;
- int chain = NOT_CAUGHT;
- int catching_state = NO_STATE;
- boolean is_handler = false;
- boolean skip_entry = false;
-
- if (!handleSystemEvent(ifitem, evt, generic_data)) {
- switch (state) {
- case STATE_state0:
- switch(trigger) {
- case TRIG_TestPort1__msg1:
- {
- chain = CHAIN_TRANS_state0_TO_cp1_BY_msg1TestPort1;
- catching_state = STATE_TOP;
- }
- break;
- }
- break;
- case STATE_state1_state0:
- switch(trigger) {
- case TRIG_TestPort1__msg1:
- {
- if (counter==2
- )
- {
- chain = CHAIN_TRANS_state1_TO_cp2_BY_msg1TestPort1;
- catching_state = STATE_TOP;
- } else
- if (counter==1
- )
- {
- chain = CHAIN_TRANS_state1_TO_state0_BY_msg1TestPort1;
- catching_state = STATE_TOP;
- } else
- {
- chain = CHAIN_TRANS_tp0_TO_tp0_BY_msg1TestPort1_tr8;
- catching_state = STATE_TOP;
- is_handler = true;
- skip_entry = true;
- }
- }
- break;
- }
- break;
- case STATE_testOk:
- switch(trigger) {
- case TRIG_TestPort1__msg1:
- {
- chain = CHAIN_TRANS_tp0_TO_tp0_BY_msg1TestPort1_tr8;
- catching_state = STATE_TOP;
- is_handler = true;
- skip_entry = true;
- }
- break;
- }
- break;
- case STATE_testFalse:
- switch(trigger) {
- case TRIG_TestPort1__msg1:
- {
- chain = CHAIN_TRANS_tp0_TO_tp0_BY_msg1TestPort1_tr8;
- catching_state = STATE_TOP;
- is_handler = true;
- skip_entry = true;
- }
- break;
- }
- break;
- }
- }
- if (chain != NOT_CAUGHT) {
- exitTo(state, catching_state, is_handler);
- int next = executeTransitionChain(chain, ifitem, generic_data);
- next = enterHistory(next, is_handler, skip_entry);
- setState(next);
- }
- }
+ // history
+ protected int history[] = {NO_STATE,NO_STATE,NO_STATE,NO_STATE,NO_STATE,NO_STATE,NO_STATE};
private void setState(int new_state) {
DebuggingService.getInstance().addActorState(this,stateStrings[new_state]);
if (stateStrings[new_state]!="Idle") {
- // TODOTS: model switch for activation
System.out.println(getInstancePath() + " -> " + stateStrings[new_state]);
}
this.state = new_state;
}
- @Override
- public void executeInitTransition() {
- int chain = CHAIN_TRANS_INITIAL_TO__cp0;
- int next = executeTransitionChain(chain, null, null);
- next = enterHistory(next, false, false);
- setState(next);
+ //*** Entry and Exit Codes
+ protected void entry_state0() {
+ System.out.println("state0: entry code");
+ crcGen.update(12);
+ }
+ protected void exit_state0() {
+ System.out.println("state0: exit code");
+ crcGen.update(13);
+ }
+ protected void entry_state1() {
+ System.out.println("state1: entry code");
+ crcGen.update(20);
+ }
+ protected void exit_state1() {
+ System.out.println("state1: exit code");
+ crcGen.update(21);
+ }
+ protected void entry_state1_state0() {
+ System.out.println("state1\\0: entry code");
+ System.out.printf("counter => %d\n",counter);
+ crcGen.update(22);
+ }
+ protected void exit_state1_state0() {
+ System.out.println("state1\\0: exit code");
+ crcGen.update(23);
+ }
+
+ //*** Action Codes
+ protected void action_TRANS_INITIAL_TO__cp0() {
+ System.out.println("Top Level init transition");
+ crcGen.update(10);
+ counter = 0;
+ }
+ protected void action_TRANS_cp0_TO_state0(InterfaceItemBase ifitem) {
+ System.out.println("choice0: else code");
+ crcGen.update(17);
+ }
+ protected void action_TRANS_cp0_TO_state0_COND_LastCheck(InterfaceItemBase ifitem) {
+ System.out.println("choice0: true code");
+ crcGen.update(15);
+ }
+ protected void action_TRANS_state0_TO_cp1_BY_msg1TestPort1(InterfaceItemBase ifitem) {
+ System.out.println("state0: msg1: transition code");
+ crcGen.update(18);
+ }
+ protected void action_TRANS_cp1_TO_state0(InterfaceItemBase ifitem) {
+ System.out.println("choice1: else code");
+ crcGen.update(10);
+ counter=3;
+ }
+ protected void action_TRANS_cp1_TO_state1_tp0_COND_tr3(InterfaceItemBase ifitem) {
+ System.out.println("choice1: to entry state1 code");
+ crcGen.update(30);
+ }
+ protected void action_TRANS_state1_TO_cp2_BY_msg1TestPort1(InterfaceItemBase ifitem) {
+ System.out.println("state1: msg1: transition code");
+ crcGen.update(30);
+ System.out.printf("CRC: %d \n", crcGen.getCrc());
+ }
+ protected void action_TRANS_cp2_TO_testFalse(InterfaceItemBase ifitem) {
+ System.out.println("Test false");
+ RTServices.getInstance().getSubSystem().testFinished(1);
+ }
+ protected void action_TRANS_cp2_TO_testOk_COND_tr6(InterfaceItemBase ifitem) {
+ System.out.println("Test ok");
+ RTServices.getInstance().getSubSystem().testFinished(0);
+ }
+ protected void action_TRANS_cp1_TO_state1_COND_tr11(InterfaceItemBase ifitem) {
+ System.out.println("choice1: history to State1 transition code");
+ crcGen.update(25);
+ counter = 1;
+ }
+ protected void action_TRANS_state1_TO_state0_BY_msg1TestPort1(InterfaceItemBase ifitem) {
+ System.out.println("state1: msg1: transition code to state0");
+ crcGen.update(51);
+ counter=4;
+ }
+ protected void action_TRANS_tp0_TO_tp0_BY_msg1TestPort1_tr8(InterfaceItemBase ifitem) {
+ System.out.println("Handler: msg1 received ");
+ crcGen.update(115);
+ counter = 2;
+ }
+ protected void action_state1_TRANS_tp0_TO_cp0(InterfaceItemBase ifitem) {
+ System.out.println("state1: tp0: transition code");
+ crcGen.update(25);
+ }
+ protected void action_state1_TRANS_cp0_TO_state0(InterfaceItemBase ifitem) {
+ System.out.println("state1: choice false code");
+ crcGen.update(57);
+ }
+ protected void action_state1_TRANS_cp0_TO_state0_COND_tr0(InterfaceItemBase ifitem) {
+ System.out.println("state1 choice: true code");
+ crcGen.update(56);
+ }
+ protected void action_state1_TRANS_INITIAL_TO__state0() {
+ System.out.println("state1 initial transition code");
+ crcGen.update(53);
}
/**
@@ -213,30 +216,31 @@ public class CPUser extends ActorClassBase {
switch (current) {
case STATE_state0:
if (!handler) exit_state0();
- history[STATE_TOP] = STATE_state0;
+ this.history[STATE_TOP] = STATE_state0;
current = STATE_TOP;
break;
case STATE_state1:
if (!handler) exit_state1();
- history[STATE_TOP] = STATE_state1;
+ this.history[STATE_TOP] = STATE_state1;
current = STATE_TOP;
break;
case STATE_state1_state0:
if (!handler) exit_state1_state0();
- history[STATE_state1] = STATE_state1_state0;
+ this.history[STATE_state1] = STATE_state1_state0;
current = STATE_state1;
break;
case STATE_testOk:
- history[STATE_TOP] = STATE_testOk;
+ this.history[STATE_TOP] = STATE_testOk;
current = STATE_TOP;
break;
case STATE_testFalse:
- history[STATE_TOP] = STATE_testFalse;
+ this.history[STATE_TOP] = STATE_testFalse;
current = STATE_TOP;
break;
}
}
}
+
/**
* calls action, entry and exit codes along a transition chain. The generic data are cast to typed data
* matching the trigger of this chain. The ID of the final state is returned
@@ -310,6 +314,7 @@ public class CPUser extends ActorClassBase {
}
return NO_STATE;
}
+
/**
* calls entry codes while entering a state's history. The ID of the final leaf state is returned
* @param state - the state which is entered
@@ -327,11 +332,11 @@ public class CPUser extends ActorClassBase {
if (!(skip_entry || handler)) entry_state1();
// state has a sub graph
// with init transition
- if (history[STATE_state1]==NO_STATE) {
+ if (this.history[STATE_state1]==NO_STATE) {
state = executeTransitionChain(CHAIN_state1_TRANS_INITIAL_TO__state0, null, null);
}
else {
- state = history[STATE_state1];
+ state = this.history[STATE_state1];
}
break;
case STATE_state1_state0:
@@ -345,7 +350,7 @@ public class CPUser extends ActorClassBase {
// in leaf state: return state id
return STATE_testFalse;
case STATE_TOP:
- state = history[STATE_TOP];
+ state = this.history[STATE_TOP];
break;
}
skip_entry = false;
@@ -353,103 +358,91 @@ public class CPUser extends ActorClassBase {
//return NO_STATE; // required by CDT but detected as unreachable by JDT because of while (true)
}
- //*** Entry and Exit Codes
- protected void entry_state0() {
- System.out.println("state0: entry code");
- crcGen.update(12);
- }
- protected void exit_state0() {
- System.out.println("state0: exit code");
- crcGen.update(13);
- }
- protected void entry_state1() {
- System.out.println("state1: entry code");
- crcGen.update(20);
- }
- protected void exit_state1() {
- System.out.println("state1: exit code");
- crcGen.update(21);
- }
- protected void entry_state1_state0() {
- System.out.println("state1\\0: entry code");
- System.out.printf("counter => %d\n",counter);
- crcGen.update(22);
- }
- protected void exit_state1_state0() {
- System.out.println("state1\\0: exit code");
- crcGen.update(23);
+ public void executeInitTransition() {
+ int chain = CHAIN_TRANS_INITIAL_TO__cp0;
+ int next = executeTransitionChain(chain, null, null);
+ next = enterHistory(next, false, false);
+ setState(next);
}
- //*** Action Codes
- protected void action_TRANS_INITIAL_TO__cp0() {
- System.out.println("Top Level init transition");
- crcGen.update(10);
- counter = 0;
- }
- protected void action_TRANS_cp0_TO_state0(InterfaceItemBase ifitem) {
- System.out.println("choice0: else code");
- crcGen.update(17);
- }
- protected void action_TRANS_cp0_TO_state0_COND_LastCheck(InterfaceItemBase ifitem) {
- System.out.println("choice0: true code");
- crcGen.update(15);
- }
- protected void action_TRANS_state0_TO_cp1_BY_msg1TestPort1(InterfaceItemBase ifitem) {
- System.out.println("state0: msg1: transition code");
- crcGen.update(18);
- }
- protected void action_TRANS_cp1_TO_state0(InterfaceItemBase ifitem) {
- System.out.println("choice1: else code");
- crcGen.update(10);
- counter=3;
- }
- protected void action_TRANS_cp1_TO_state1_tp0_COND_tr3(InterfaceItemBase ifitem) {
- System.out.println("choice1: to entry state1 code");
- crcGen.update(30);
- }
- protected void action_TRANS_state1_TO_cp2_BY_msg1TestPort1(InterfaceItemBase ifitem) {
- System.out.println("state1: msg1: transition code");
- crcGen.update(30);
- System.out.printf("CRC: %d \n", crcGen.getCrc());
- }
- protected void action_TRANS_cp2_TO_testFalse(InterfaceItemBase ifitem) {
- System.out.println("Test false");
- RTServices.getInstance().getSubSystem().testFinished(1);
- }
- protected void action_TRANS_cp2_TO_testOk_COND_tr6(InterfaceItemBase ifitem) {
- System.out.println("Test ok");
- RTServices.getInstance().getSubSystem().testFinished(0);
- }
- protected void action_TRANS_cp1_TO_state1_COND_tr11(InterfaceItemBase ifitem) {
- System.out.println("choice1: history to State1 transition code");
- crcGen.update(25);
- counter = 1;
- }
- protected void action_TRANS_state1_TO_state0_BY_msg1TestPort1(InterfaceItemBase ifitem) {
- System.out.println("state1: msg1: transition code to state0");
- crcGen.update(51);
- counter=4;
- }
- protected void action_TRANS_tp0_TO_tp0_BY_msg1TestPort1_tr8(InterfaceItemBase ifitem) {
- System.out.println("Handler: msg1 received ");
- crcGen.update(115);
- counter = 2;
- }
- protected void action_state1_TRANS_tp0_TO_cp0(InterfaceItemBase ifitem) {
- System.out.println("state1: tp0: transition code");
- crcGen.update(25);
- }
- protected void action_state1_TRANS_cp0_TO_state0(InterfaceItemBase ifitem) {
- System.out.println("state1: choice false code");
- crcGen.update(57);
- }
- protected void action_state1_TRANS_cp0_TO_state0_COND_tr0(InterfaceItemBase ifitem) {
- System.out.println("state1 choice: true code");
- crcGen.update(56);
- }
- protected void action_state1_TRANS_INITIAL_TO__state0() {
- System.out.println("state1 initial transition code");
- crcGen.update(53);
+ /* receiveEvent contains the main implementation of the FSM */
+ public void receiveEvent(InterfaceItemBase ifitem, int evt, Object generic_data) {
+ int trigger = ifitem.getLocalId() + EVT_SHIFT*evt;
+ int chain = NOT_CAUGHT;
+ int catching_state = NO_STATE;
+ boolean is_handler = false;
+ boolean skip_entry = false;
+
+ if (!handleSystemEvent(ifitem, evt, generic_data)) {
+ switch (this.state) {
+ case STATE_state0:
+ switch(trigger) {
+ case TRIG_TestPort1__msg1:
+ {
+ chain = CHAIN_TRANS_state0_TO_cp1_BY_msg1TestPort1;
+ catching_state = STATE_TOP;
+ }
+ break;
+ }
+ break;
+ case STATE_state1_state0:
+ switch(trigger) {
+ case TRIG_TestPort1__msg1:
+ {
+ if (counter==2
+ )
+ {
+ chain = CHAIN_TRANS_state1_TO_cp2_BY_msg1TestPort1;
+ catching_state = STATE_TOP;
+ } else
+ if (counter==1
+ )
+ {
+ chain = CHAIN_TRANS_state1_TO_state0_BY_msg1TestPort1;
+ catching_state = STATE_TOP;
+ } else
+ {
+ chain = CHAIN_TRANS_tp0_TO_tp0_BY_msg1TestPort1_tr8;
+ catching_state = STATE_TOP;
+ is_handler = true;
+ skip_entry = true;
+ }
+ }
+ break;
+ }
+ break;
+ case STATE_testOk:
+ switch(trigger) {
+ case TRIG_TestPort1__msg1:
+ {
+ chain = CHAIN_TRANS_tp0_TO_tp0_BY_msg1TestPort1_tr8;
+ catching_state = STATE_TOP;
+ is_handler = true;
+ skip_entry = true;
+ }
+ break;
+ }
+ break;
+ case STATE_testFalse:
+ switch(trigger) {
+ case TRIG_TestPort1__msg1:
+ {
+ chain = CHAIN_TRANS_tp0_TO_tp0_BY_msg1TestPort1_tr8;
+ catching_state = STATE_TOP;
+ is_handler = true;
+ skip_entry = true;
+ }
+ break;
+ }
+ break;
+ }
+ }
+ if (chain != NOT_CAUGHT) {
+ exitTo(this.state, catching_state, is_handler);
+ int next = executeTransitionChain(chain, ifitem, generic_data);
+ next = enterHistory(next, is_handler, skip_entry);
+ setState(next);
+ }
}
//******************************************
diff --git a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/ChoicePointTest/TestProtocol.java b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/ChoicePointTest/TestProtocol.java
index 91279a2c3..af6cd90ec 100644
--- a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/ChoicePointTest/TestProtocol.java
+++ b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/ChoicePointTest/TestProtocol.java
@@ -11,18 +11,13 @@ import org.eclipse.etrice.runtime.java.debugging.DebuggingService;
public class TestProtocol {
// message IDs
- // TODO: separate class for message IDs: class MSG{public static volatile int MSG_MIN = 0; ...} -> better structure
- // error if msgID <= MSG_MIN
- public static final int MSG_MIN = 0;
- //IDs for outgoing messages
- //IDs for incoming messages
+ public static final int MSG_MIN = 0;
public static final int IN_msg1 = 1;
public static final int IN_msg2 = 2;
public static final int IN_msg3 = 3;
public static final int IN_msg4 = 4;
public static final int IN_msg5 = 5;
- //error if msgID >= MSG_MAX
- public static final int MSG_MAX = 6;
+ public static final int MSG_MAX = 6;
private static String messageStrings[] = {"MIN", "msg1","msg2","msg3","msg4","msg5","MAX"};
diff --git a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/HandlerTest/HandlerTest_Top.java b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/HandlerTest/HandlerTest_Top.java
index 400196a6f..6db277e1f 100644
--- a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/HandlerTest/HandlerTest_Top.java
+++ b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/HandlerTest/HandlerTest_Top.java
@@ -20,7 +20,7 @@ public class HandlerTest_Top extends ActorClassBase {
//--------------------- services
//--------------------- interface item IDs
-
+
//--------------------- attributes
//--------------------- operations
diff --git a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/HandlerTest/HandlerUser.java b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/HandlerTest/HandlerUser.java
index a43945dd1..cad856bf7 100644
--- a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/HandlerTest/HandlerUser.java
+++ b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/HandlerTest/HandlerUser.java
@@ -29,8 +29,8 @@ public class HandlerUser extends ActorClassBase {
//--------------------- services
//--------------------- interface item IDs
- protected static final int IFITEM_TestPort1 = 1;
-
+ public static final int IFITEM_TestPort1 = 1;
+
//--------------------- attributes
protected int counter;
//--------------------- operations
@@ -67,65 +67,446 @@ public class HandlerUser extends ActorClassBase {
destroyUser();
}
- //******************************************
- // START of generated code for FSM
- //******************************************
- // State IDs for FSM
- protected static final int STATE_state0 = 2;
- protected static final int STATE_state0_state1 = 3;
- protected static final int STATE_state0_state1_state7 = 4;
- protected static final int STATE_state0_state2 = 5;
- protected static final int STATE_testOk = 6;
- protected static final int STATE_testFalse = 7;
- protected static final int STATE_state1 = 8;
- protected static final String stateStrings[] = {"<no state>","<top>","state0",
- "state0_state1",
- "state0_state1_state7",
- "state0_state2",
- "testOk",
- "testFalse",
- "state1"
- };
+ /* state IDs */
+ public static final int STATE_state0_state1_state7 = 2;
+ public static final int STATE_state0_state2 = 3;
+ public static final int STATE_testOk = 4;
+ public static final int STATE_testFalse = 5;
+ public static final int STATE_state1 = 6;
+ public static final int STATE_state0 = 7;
+ public static final int STATE_state0_state1 = 8;
+
+ /* transition chains */
+ public static final int CHAIN_TRANS_INITIAL_TO__state0_tp2 = 1;
+ public static final int CHAIN_TRANS_state0_TO_cp1_BY_msg1TestPort1 = 2;
+ public static final int CHAIN_TRANS_tp0_TO_state0_BY_msg1TestPort1 = 3;
+ public static final int CHAIN_TRANS_tp0_TO_tp0_BY_msg1TestPort1_tr0 = 4;
+ public static final int CHAIN_TRANS_tp0_TO_tp0_BY_msg1TestPort1_tr6 = 5;
+ public static final int CHAIN_TRANS_tp1_TO_cp0_BY_msg6TestPort1 = 6;
+ public static final int CHAIN_TRANS_tp1_TO_tp1_BY_msg1TestPort1_tr1 = 7;
+ public static final int CHAIN_TRANS_tp1_TO_tp1_BY_msg2TestPort1_tr5 = 8;
+ public static final int CHAIN_state0_TRANS_INITIAL_TO__state2 = 9;
+ public static final int CHAIN_state0_TRANS_state1_TO_state1_BY_msg1TestPort1_tr6 = 10;
+ public static final int CHAIN_state0_TRANS_state1_TO_state2_BY_msg5TestPort1 = 11;
+ public static final int CHAIN_state0_TRANS_state2_TO_state2_BY_msg1TestPort1_tr3 = 12;
+ public static final int CHAIN_state0_TRANS_tp0_TO_tp0_BY_msg1TestPort1_tr5 = 13;
+ public static final int CHAIN_state0_TRANS_tp0_TO_tp0_BY_msg3TestPort1_tr1 = 14;
+ public static final int CHAIN_state0_TRANS_tp1_TO_state1_BY_msg2TestPort1 = 15;
+ public static final int CHAIN_state0_TRANS_tp1_TO_state2_BY_msg2TestPort1 = 16;
+ public static final int CHAIN_state0_TRANS_tp1_TO_tp1_BY_msg4TestPort1_tr2 = 17;
+ public static final int CHAIN_state0_state1_TRANS_INITIAL_TO__state7 = 18;
+
+ /* triggers */
+ public static final int TRIG_TestPort1__msg1 = IFITEM_TestPort1 + EVT_SHIFT*TestProtocol.IN_msg1;
+ public static final int TRIG_TestPort1__msg2 = IFITEM_TestPort1 + EVT_SHIFT*TestProtocol.IN_msg2;
+ public static final int TRIG_TestPort1__msg3 = IFITEM_TestPort1 + EVT_SHIFT*TestProtocol.IN_msg3;
+ public static final int TRIG_TestPort1__msg4 = IFITEM_TestPort1 + EVT_SHIFT*TestProtocol.IN_msg4;
+ public static final int TRIG_TestPort1__msg5 = IFITEM_TestPort1 + EVT_SHIFT*TestProtocol.IN_msg5;
+ public static final int TRIG_TestPort1__msg6 = IFITEM_TestPort1 + EVT_SHIFT*TestProtocol.IN_msg6;
+
+ // state names
+ protected static final String stateStrings[] = {"<no state>","<top>","state0_state1_state7",
+ "state0_state2",
+ "testOk",
+ "testFalse",
+ "state1",
+ "state0",
+ "state0_state1"
+ };
// history
- // TODOHRR: history defined in ActorClassBase, init in constructor
- // history = new int[5];
- // for (int i = 0; i < history.length; i++) {
- // history[i] = NO_STATE;
- // }
protected int history[] = {NO_STATE,NO_STATE,NO_STATE,NO_STATE,NO_STATE,NO_STATE,NO_STATE,NO_STATE,NO_STATE};
- // transition chains
- protected static final int CHAIN_TRANS_INITIAL_TO__state0_tp2 = 1;
- protected static final int CHAIN_TRANS_state0_TO_cp1_BY_msg1TestPort1 = 2;
- protected static final int CHAIN_TRANS_tp0_TO_state0_BY_msg1TestPort1 = 3;
- protected static final int CHAIN_TRANS_tp0_TO_tp0_BY_msg1TestPort1_tr0 = 4;
- protected static final int CHAIN_TRANS_tp0_TO_tp0_BY_msg1TestPort1_tr6 = 5;
- protected static final int CHAIN_TRANS_tp1_TO_cp0_BY_msg6TestPort1 = 6;
- protected static final int CHAIN_TRANS_tp1_TO_tp1_BY_msg1TestPort1_tr1 = 7;
- protected static final int CHAIN_TRANS_tp1_TO_tp1_BY_msg2TestPort1_tr5 = 8;
- protected static final int CHAIN_state0_TRANS_INITIAL_TO__state2 = 9;
- protected static final int CHAIN_state0_TRANS_state1_TO_state1_BY_msg1TestPort1_tr6 = 10;
- protected static final int CHAIN_state0_TRANS_state1_TO_state2_BY_msg5TestPort1 = 11;
- protected static final int CHAIN_state0_TRANS_state2_TO_state2_BY_msg1TestPort1_tr3 = 12;
- protected static final int CHAIN_state0_TRANS_tp0_TO_tp0_BY_msg1TestPort1_tr5 = 13;
- protected static final int CHAIN_state0_TRANS_tp0_TO_tp0_BY_msg3TestPort1_tr1 = 14;
- protected static final int CHAIN_state0_TRANS_tp1_TO_state1_BY_msg2TestPort1 = 15;
- protected static final int CHAIN_state0_TRANS_tp1_TO_state2_BY_msg2TestPort1 = 16;
- protected static final int CHAIN_state0_TRANS_tp1_TO_tp1_BY_msg4TestPort1_tr2 = 17;
- protected static final int CHAIN_state0_state1_TRANS_INITIAL_TO__state7 = 18;
+ private void setState(int new_state) {
+ DebuggingService.getInstance().addActorState(this,stateStrings[new_state]);
+ if (stateStrings[new_state]!="Idle") {
+ System.out.println(getInstancePath() + " -> " + stateStrings[new_state]);
+ }
+ this.state = new_state;
+ }
+
+ //*** Entry and Exit Codes
+ protected void entry_state0() {
+ System.out.println("state 0 entry action");
+ crcGen.update(13);
+ }
+ protected void exit_state0() {
+ System.out.println("state 0 exit action");
+ crcGen.update(14);
+ }
+ protected void entry_state0_state1() {
+ System.out.println("state 0/1 entry action");
+ crcGen.update(16);
+ }
+ protected void exit_state0_state1() {
+ System.out.println("state 0/1 exit action");
+ crcGen.update(17);
+ }
+ protected void entry_state0_state1_state7() {
+ System.out.println("state 0/1/7 entry action");
+ crcGen.update(23);
+ }
+ protected void exit_state0_state1_state7() {
+ System.out.println("state 0/1/7 exit action");
+ crcGen.update(24);
+ }
+ protected void entry_state0_state2() {
+ System.out.println("state 0/2 entry action");
+ crcGen.update(18);
+ }
+ protected void exit_state0_state2() {
+ System.out.println("state 0/2 exit action");
+ crcGen.update(19);
+ }
+ protected void entry_state1() {
+ System.out.println("state 1 entry action");
+ crcGen.update(111);
+ }
+ protected void exit_state1() {
+ System.out.println("state 1 exit action");
+ crcGen.update(112);
+ }
+
+ //*** Action Codes
+ protected void action_TRANS_tp0_TO_tp0_BY_msg1TestPort1_tr0(InterfaceItemBase ifitem, int p1) {
+ System.out.println("top level handler action no guard ");
+ crcGen.update(11);
+ }
+ protected void action_TRANS_tp1_TO_tp1_BY_msg1TestPort1_tr1(InterfaceItemBase ifitem, int p1) {
+ System.out.println("top level self transition action P1=>3");
+ crcGen.update(12);
+ }
+ protected void action_TRANS_INITIAL_TO__state0_tp2() {
+ System.out.println("top level initial transition");
+ crcGen.update(10);
+ }
+ protected void action_TRANS_cp0_TO_testFalse(InterfaceItemBase ifitem, int p1) {
+ System.out.println("Test false");
+ RTServices.getInstance().getSubSystem().testFinished(1);
+ }
+ protected void action_TRANS_cp0_TO_testOk_COND_tr3(InterfaceItemBase ifitem, int p1) {
+ System.out.println("Test ok");
+ RTServices.getInstance().getSubSystem().testFinished(0);
+ }
+ protected void action_TRANS_state0_TO_cp1_BY_msg1TestPort1(InterfaceItemBase ifitem, int p1) {
+ System.out.println("tr9 transition action");
+ crcGen.update(114);
+ }
+ protected void action_TRANS_tp1_TO_tp1_BY_msg2TestPort1_tr5(InterfaceItemBase ifitem, int p1) {
+ System.out.println("top level self transition action P1=>4");
+ crcGen.update(50);
+ }
+ protected void action_TRANS_tp0_TO_state0_BY_msg1TestPort1(InterfaceItemBase ifitem, int p1) {
+ System.out.println("top level handler action p1=>7 ");
+ crcGen.update(70);
+ }
+ protected void action_TRANS_tp0_TO_tp0_BY_msg1TestPort1_tr6(InterfaceItemBase ifitem, int p1) {
+ System.out.println("top level handler action p1=>12 ");
+ crcGen.update(110);
+ }
+ protected void action_TRANS_cp1_TO_state1(InterfaceItemBase ifitem, int p1) {
+ System.out.println("tr8 transition action");
+ crcGen.update(113);
+ }
+ protected void action_TRANS_cp1_TO_state0_COND_tr10(InterfaceItemBase ifitem, int p1) {
+ System.out.println("tr4 transition action");
+ crcGen.update(115);
+ }
+ protected void action_TRANS_tp1_TO_cp0_BY_msg6TestPort1(InterfaceItemBase ifitem, int p1) {
+ System.out.println("tp1 transition to choice action");
+ crcGen.update(117);
+ System.out.printf("CRC: %d \n", crcGen.getCrc());
+ }
+ protected void action_state0_TRANS_tp0_TO_tp0_BY_msg3TestPort1_tr1(InterfaceItemBase ifitem) {
+ System.out.println("state 0 handler action no guard");
+ crcGen.update(20);
+ }
+ protected void action_state0_TRANS_tp1_TO_tp1_BY_msg4TestPort1_tr2(InterfaceItemBase ifitem) {
+ System.out.println("state 0 tp1 self transition action");
+ crcGen.update(21);
+ }
+ protected void action_state0_TRANS_state2_TO_state2_BY_msg1TestPort1_tr3(InterfaceItemBase ifitem, int p1) {
+ System.out.println("state 0/2 self transition action");
+ crcGen.update(25);
+ }
+ protected void action_state0_TRANS_tp2_TO_state0_state1_tp0(InterfaceItemBase ifitem) {
+ System.out.println("state 0 tp2 transition action");
+ crcGen.update(15);
+ }
+ protected void action_state0_TRANS_tp0_TO_tp0_BY_msg1TestPort1_tr5(InterfaceItemBase ifitem, int p1) {
+ System.out.println("state 0 handler action P1 => 5");
+ crcGen.update(52);
+ }
+ protected void action_state0_TRANS_INITIAL_TO__state2() {
+ System.out.println("state 0 initial transition");
+ crcGen.update(53);
+ }
+ protected void action_state0_TRANS_state1_TO_state1_BY_msg1TestPort1_tr6(InterfaceItemBase ifitem, int p1) {
+ System.out.println("state 0/1 self transition");
+ crcGen.update(54);
+ }
+ protected void action_state0_TRANS_tp1_TO_state1_BY_msg2TestPort1(InterfaceItemBase ifitem, int p1) {
+ System.out.println("state 0 tp1 p1=>5");
+ crcGen.update(120);
+ }
+ protected void action_state0_TRANS_tp1_TO_state2_BY_msg2TestPort1(InterfaceItemBase ifitem, int p1) {
+ System.out.println("state 0 tp1 action P1 => 6");
+ crcGen.update(121);
+ }
+ protected void action_state0_state1_TRANS_tp0_TO_state7(InterfaceItemBase ifitem) {
+ System.out.println("state 0/1 transition entry action");
+ crcGen.update(22);
+ }
+ protected void action_state0_state1_TRANS_INITIAL_TO__state7() {
+ System.out.println("state 0/1 initial transition");
+ crcGen.update(121);
+ }
+
+ /**
+ * calls exit codes while exiting from the current state to one of its
+ * parent states while remembering the history
+ * @param current - the current state
+ * @param to - the final parent state
+ * @param handler - entry and exit codes are called only if not handler (for handler TransitionPoints)
+ */
+ private void exitTo(int current, int to, boolean handler) {
+ while (current!=to) {
+ switch (current) {
+ case STATE_state0:
+ if (!handler) exit_state0();
+ this.history[STATE_TOP] = STATE_state0;
+ current = STATE_TOP;
+ break;
+ case STATE_state0_state1:
+ if (!handler) exit_state0_state1();
+ this.history[STATE_state0] = STATE_state0_state1;
+ current = STATE_state0;
+ break;
+ case STATE_state0_state1_state7:
+ if (!handler) exit_state0_state1_state7();
+ this.history[STATE_state0_state1] = STATE_state0_state1_state7;
+ current = STATE_state0_state1;
+ break;
+ case STATE_state0_state2:
+ if (!handler) exit_state0_state2();
+ this.history[STATE_state0] = STATE_state0_state2;
+ current = STATE_state0;
+ break;
+ case STATE_testOk:
+ this.history[STATE_TOP] = STATE_testOk;
+ current = STATE_TOP;
+ break;
+ case STATE_testFalse:
+ this.history[STATE_TOP] = STATE_testFalse;
+ current = STATE_TOP;
+ break;
+ case STATE_state1:
+ if (!handler) exit_state1();
+ this.history[STATE_TOP] = STATE_state1;
+ current = STATE_TOP;
+ break;
+ }
+ }
+ }
+
+ /**
+ * calls action, entry and exit codes along a transition chain. The generic data are cast to typed data
+ * matching the trigger of this chain. The ID of the final state is returned
+ * @param chain - the chain ID
+ * @param generic_data - the generic data pointer
+ * @return the ID of the final state
+ */
+ private int executeTransitionChain(int chain, InterfaceItemBase ifitem, Object generic_data) {
+ switch (chain) {
+ case CHAIN_TRANS_tp0_TO_tp0_BY_msg1TestPort1_tr0:
+ {
+ int p1 = (Integer) generic_data;
+ action_TRANS_tp0_TO_tp0_BY_msg1TestPort1_tr0(ifitem, p1);
+ return STATE_TOP;
+ }
+ case CHAIN_TRANS_tp1_TO_tp1_BY_msg1TestPort1_tr1:
+ {
+ int p1 = (Integer) generic_data;
+ action_TRANS_tp1_TO_tp1_BY_msg1TestPort1_tr1(ifitem, p1);
+ return STATE_TOP;
+ }
+ case CHAIN_TRANS_INITIAL_TO__state0_tp2:
+ {
+ action_TRANS_INITIAL_TO__state0_tp2();
+ entry_state0();
+ action_state0_TRANS_tp2_TO_state0_state1_tp0(ifitem);
+ entry_state0_state1();
+ action_state0_state1_TRANS_tp0_TO_state7(ifitem);
+ return STATE_state0_state1_state7;
+ }
+ case CHAIN_TRANS_state0_TO_cp1_BY_msg1TestPort1:
+ {
+ int p1 = (Integer) generic_data;
+ action_TRANS_state0_TO_cp1_BY_msg1TestPort1(ifitem, p1);
+ if (p1!=4
+ ) {
+ action_TRANS_cp1_TO_state0_COND_tr10(ifitem, p1);
+ return STATE_state0;}
+ else {
+ action_TRANS_cp1_TO_state1(ifitem, p1);
+ return STATE_state1;}
+ }
+ case CHAIN_TRANS_tp1_TO_tp1_BY_msg2TestPort1_tr5:
+ {
+ int p1 = (Integer) generic_data;
+ action_TRANS_tp1_TO_tp1_BY_msg2TestPort1_tr5(ifitem, p1);
+ return STATE_TOP;
+ }
+ case CHAIN_TRANS_tp0_TO_state0_BY_msg1TestPort1:
+ {
+ int p1 = (Integer) generic_data;
+ action_TRANS_tp0_TO_state0_BY_msg1TestPort1(ifitem, p1);
+ return STATE_state0;
+ }
+ case CHAIN_TRANS_tp0_TO_tp0_BY_msg1TestPort1_tr6:
+ {
+ int p1 = (Integer) generic_data;
+ action_TRANS_tp0_TO_tp0_BY_msg1TestPort1_tr6(ifitem, p1);
+ return STATE_TOP;
+ }
+ case CHAIN_TRANS_tp1_TO_cp0_BY_msg6TestPort1:
+ {
+ int p1 = (Integer) generic_data;
+ action_TRANS_tp1_TO_cp0_BY_msg6TestPort1(ifitem, p1);
+ if (crcGen.getCrc()==7268
+ ) {
+ action_TRANS_cp0_TO_testOk_COND_tr3(ifitem, p1);
+ return STATE_testOk;}
+ else {
+ action_TRANS_cp0_TO_testFalse(ifitem, p1);
+ return STATE_testFalse;}
+ }
+ case CHAIN_state0_TRANS_state1_TO_state2_BY_msg5TestPort1:
+ {
+ int p1 = (Integer) generic_data;
+ return STATE_state0_state2;
+ }
+ case CHAIN_state0_TRANS_tp0_TO_tp0_BY_msg3TestPort1_tr1:
+ {
+ action_state0_TRANS_tp0_TO_tp0_BY_msg3TestPort1_tr1(ifitem);
+ return STATE_state0;
+ }
+ case CHAIN_state0_TRANS_tp1_TO_tp1_BY_msg4TestPort1_tr2:
+ {
+ action_state0_TRANS_tp1_TO_tp1_BY_msg4TestPort1_tr2(ifitem);
+ return STATE_state0;
+ }
+ case CHAIN_state0_TRANS_state2_TO_state2_BY_msg1TestPort1_tr3:
+ {
+ int p1 = (Integer) generic_data;
+ action_state0_TRANS_state2_TO_state2_BY_msg1TestPort1_tr3(ifitem, p1);
+ return STATE_state0_state2;
+ }
+ case CHAIN_state0_TRANS_tp0_TO_tp0_BY_msg1TestPort1_tr5:
+ {
+ int p1 = (Integer) generic_data;
+ action_state0_TRANS_tp0_TO_tp0_BY_msg1TestPort1_tr5(ifitem, p1);
+ return STATE_state0;
+ }
+ case CHAIN_state0_TRANS_INITIAL_TO__state2:
+ {
+ action_state0_TRANS_INITIAL_TO__state2();
+ return STATE_state0_state2;
+ }
+ case CHAIN_state0_TRANS_state1_TO_state1_BY_msg1TestPort1_tr6:
+ {
+ int p1 = (Integer) generic_data;
+ action_state0_TRANS_state1_TO_state1_BY_msg1TestPort1_tr6(ifitem, p1);
+ return STATE_state0_state1;
+ }
+ case CHAIN_state0_TRANS_tp1_TO_state1_BY_msg2TestPort1:
+ {
+ int p1 = (Integer) generic_data;
+ action_state0_TRANS_tp1_TO_state1_BY_msg2TestPort1(ifitem, p1);
+ return STATE_state0_state1;
+ }
+ case CHAIN_state0_TRANS_tp1_TO_state2_BY_msg2TestPort1:
+ {
+ int p1 = (Integer) generic_data;
+ action_state0_TRANS_tp1_TO_state2_BY_msg2TestPort1(ifitem, p1);
+ return STATE_state0_state2;
+ }
+ case CHAIN_state0_state1_TRANS_INITIAL_TO__state7:
+ {
+ action_state0_state1_TRANS_INITIAL_TO__state7();
+ return STATE_state0_state1_state7;
+ }
+ }
+ return NO_STATE;
+ }
+
+ /**
+ * calls entry codes while entering a state's history. The ID of the final leaf state is returned
+ * @param state - the state which is entered
+ * @param handler - entry code is executed if not handler
+ * @return - the ID of the final leaf state
+ */
+ private int enterHistory(int state, boolean handler, boolean skip_entry) {
+ while (true) {
+ switch (state) {
+ case STATE_state0:
+ if (!(skip_entry || handler)) entry_state0();
+ // state has a sub graph
+ // with init transition
+ if (this.history[STATE_state0]==NO_STATE) {
+ state = executeTransitionChain(CHAIN_state0_TRANS_INITIAL_TO__state2, null, null);
+ }
+ else {
+ state = this.history[STATE_state0];
+ }
+ break;
+ case STATE_state0_state1:
+ if (!(skip_entry || handler)) entry_state0_state1();
+ // state has a sub graph
+ // with init transition
+ if (this.history[STATE_state0_state1]==NO_STATE) {
+ state = executeTransitionChain(CHAIN_state0_state1_TRANS_INITIAL_TO__state7, null, null);
+ }
+ else {
+ state = this.history[STATE_state0_state1];
+ }
+ break;
+ case STATE_state0_state1_state7:
+ if (!(skip_entry || handler)) entry_state0_state1_state7();
+ // in leaf state: return state id
+ return STATE_state0_state1_state7;
+ case STATE_state0_state2:
+ if (!(skip_entry || handler)) entry_state0_state2();
+ // in leaf state: return state id
+ return STATE_state0_state2;
+ case STATE_testOk:
+ // in leaf state: return state id
+ return STATE_testOk;
+ case STATE_testFalse:
+ // in leaf state: return state id
+ return STATE_testFalse;
+ case STATE_state1:
+ if (!(skip_entry || handler)) entry_state1();
+ // in leaf state: return state id
+ return STATE_state1;
+ case STATE_TOP:
+ state = this.history[STATE_TOP];
+ break;
+ }
+ skip_entry = false;
+ }
+ //return NO_STATE; // required by CDT but detected as unreachable by JDT because of while (true)
+ }
- // triggers for FSM
- protected static final int TRIG_TestPort1__msg1 = IFITEM_TestPort1 + EVT_SHIFT*TestProtocol.IN_msg1;
- protected static final int TRIG_TestPort1__msg2 = IFITEM_TestPort1 + EVT_SHIFT*TestProtocol.IN_msg2;
- protected static final int TRIG_TestPort1__msg3 = IFITEM_TestPort1 + EVT_SHIFT*TestProtocol.IN_msg3;
- protected static final int TRIG_TestPort1__msg4 = IFITEM_TestPort1 + EVT_SHIFT*TestProtocol.IN_msg4;
- protected static final int TRIG_TestPort1__msg5 = IFITEM_TestPort1 + EVT_SHIFT*TestProtocol.IN_msg5;
- protected static final int TRIG_TestPort1__msg6 = IFITEM_TestPort1 + EVT_SHIFT*TestProtocol.IN_msg6;
+ public void executeInitTransition() {
+ int chain = CHAIN_TRANS_INITIAL_TO__state0_tp2;
+ int next = executeTransitionChain(chain, null, null);
+ next = enterHistory(next, false, false);
+ setState(next);
+ }
- // receiveEvent contains the main implementation of the FSM
- @Override
+ /* receiveEvent contains the main implementation of the FSM */
public void receiveEvent(InterfaceItemBase ifitem, int evt, Object generic_data) {
int trigger = ifitem.getLocalId() + EVT_SHIFT*evt;
int chain = NOT_CAUGHT;
@@ -134,7 +515,7 @@ public class HandlerUser extends ActorClassBase {
boolean skip_entry = false;
if (!handleSystemEvent(ifitem, evt, generic_data)) {
- switch (state) {
+ switch (this.state) {
case STATE_state0_state1_state7:
switch(trigger) {
case TRIG_TestPort1__msg5:
@@ -457,400 +838,12 @@ public class HandlerUser extends ActorClassBase {
}
}
if (chain != NOT_CAUGHT) {
- exitTo(state, catching_state, is_handler);
+ exitTo(this.state, catching_state, is_handler);
int next = executeTransitionChain(chain, ifitem, generic_data);
next = enterHistory(next, is_handler, skip_entry);
setState(next);
}
}
-
- private void setState(int new_state) {
- DebuggingService.getInstance().addActorState(this,stateStrings[new_state]);
- if (stateStrings[new_state]!="Idle") {
- // TODOTS: model switch for activation
- System.out.println(getInstancePath() + " -> " + stateStrings[new_state]);
- }
- this.state = new_state;
- }
-
- @Override
- public void executeInitTransition() {
- int chain = CHAIN_TRANS_INITIAL_TO__state0_tp2;
- int next = executeTransitionChain(chain, null, null);
- next = enterHistory(next, false, false);
- setState(next);
- }
-
- /**
- * calls exit codes while exiting from the current state to one of its
- * parent states while remembering the history
- * @param current - the current state
- * @param to - the final parent state
- * @param handler - entry and exit codes are called only if not handler (for handler TransitionPoints)
- */
- private void exitTo(int current, int to, boolean handler) {
- while (current!=to) {
- switch (current) {
- case STATE_state0:
- if (!handler) exit_state0();
- history[STATE_TOP] = STATE_state0;
- current = STATE_TOP;
- break;
- case STATE_state0_state1:
- if (!handler) exit_state0_state1();
- history[STATE_state0] = STATE_state0_state1;
- current = STATE_state0;
- break;
- case STATE_state0_state1_state7:
- if (!handler) exit_state0_state1_state7();
- history[STATE_state0_state1] = STATE_state0_state1_state7;
- current = STATE_state0_state1;
- break;
- case STATE_state0_state2:
- if (!handler) exit_state0_state2();
- history[STATE_state0] = STATE_state0_state2;
- current = STATE_state0;
- break;
- case STATE_testOk:
- history[STATE_TOP] = STATE_testOk;
- current = STATE_TOP;
- break;
- case STATE_testFalse:
- history[STATE_TOP] = STATE_testFalse;
- current = STATE_TOP;
- break;
- case STATE_state1:
- if (!handler) exit_state1();
- history[STATE_TOP] = STATE_state1;
- current = STATE_TOP;
- break;
- }
- }
- }
- /**
- * calls action, entry and exit codes along a transition chain. The generic data are cast to typed data
- * matching the trigger of this chain. The ID of the final state is returned
- * @param chain - the chain ID
- * @param generic_data - the generic data pointer
- * @return the ID of the final state
- */
- private int executeTransitionChain(int chain, InterfaceItemBase ifitem, Object generic_data) {
- switch (chain) {
- case CHAIN_TRANS_tp0_TO_tp0_BY_msg1TestPort1_tr0:
- {
- int p1 = (Integer) generic_data;
- action_TRANS_tp0_TO_tp0_BY_msg1TestPort1_tr0(ifitem, p1);
- return STATE_TOP;
- }
- case CHAIN_TRANS_tp1_TO_tp1_BY_msg1TestPort1_tr1:
- {
- int p1 = (Integer) generic_data;
- action_TRANS_tp1_TO_tp1_BY_msg1TestPort1_tr1(ifitem, p1);
- return STATE_TOP;
- }
- case CHAIN_TRANS_INITIAL_TO__state0_tp2:
- {
- action_TRANS_INITIAL_TO__state0_tp2();
- entry_state0();
- action_state0_TRANS_tp2_TO_state0_state1_tp0(ifitem);
- entry_state0_state1();
- action_state0_state1_TRANS_tp0_TO_state7(ifitem);
- return STATE_state0_state1_state7;
- }
- case CHAIN_TRANS_state0_TO_cp1_BY_msg1TestPort1:
- {
- int p1 = (Integer) generic_data;
- action_TRANS_state0_TO_cp1_BY_msg1TestPort1(ifitem, p1);
- if (p1!=4
- ) {
- action_TRANS_cp1_TO_state0_COND_tr10(ifitem, p1);
- return STATE_state0;}
- else {
- action_TRANS_cp1_TO_state1(ifitem, p1);
- return STATE_state1;}
- }
- case CHAIN_TRANS_tp1_TO_tp1_BY_msg2TestPort1_tr5:
- {
- int p1 = (Integer) generic_data;
- action_TRANS_tp1_TO_tp1_BY_msg2TestPort1_tr5(ifitem, p1);
- return STATE_TOP;
- }
- case CHAIN_TRANS_tp0_TO_state0_BY_msg1TestPort1:
- {
- int p1 = (Integer) generic_data;
- action_TRANS_tp0_TO_state0_BY_msg1TestPort1(ifitem, p1);
- return STATE_state0;
- }
- case CHAIN_TRANS_tp0_TO_tp0_BY_msg1TestPort1_tr6:
- {
- int p1 = (Integer) generic_data;
- action_TRANS_tp0_TO_tp0_BY_msg1TestPort1_tr6(ifitem, p1);
- return STATE_TOP;
- }
- case CHAIN_TRANS_tp1_TO_cp0_BY_msg6TestPort1:
- {
- int p1 = (Integer) generic_data;
- action_TRANS_tp1_TO_cp0_BY_msg6TestPort1(ifitem, p1);
- if (crcGen.getCrc()==7268
- ) {
- action_TRANS_cp0_TO_testOk_COND_tr3(ifitem, p1);
- return STATE_testOk;}
- else {
- action_TRANS_cp0_TO_testFalse(ifitem, p1);
- return STATE_testFalse;}
- }
- case CHAIN_state0_TRANS_state1_TO_state2_BY_msg5TestPort1:
- {
- int p1 = (Integer) generic_data;
- return STATE_state0_state2;
- }
- case CHAIN_state0_TRANS_tp0_TO_tp0_BY_msg3TestPort1_tr1:
- {
- action_state0_TRANS_tp0_TO_tp0_BY_msg3TestPort1_tr1(ifitem);
- return STATE_state0;
- }
- case CHAIN_state0_TRANS_tp1_TO_tp1_BY_msg4TestPort1_tr2:
- {
- action_state0_TRANS_tp1_TO_tp1_BY_msg4TestPort1_tr2(ifitem);
- return STATE_state0;
- }
- case CHAIN_state0_TRANS_state2_TO_state2_BY_msg1TestPort1_tr3:
- {
- int p1 = (Integer) generic_data;
- action_state0_TRANS_state2_TO_state2_BY_msg1TestPort1_tr3(ifitem, p1);
- return STATE_state0_state2;
- }
- case CHAIN_state0_TRANS_tp0_TO_tp0_BY_msg1TestPort1_tr5:
- {
- int p1 = (Integer) generic_data;
- action_state0_TRANS_tp0_TO_tp0_BY_msg1TestPort1_tr5(ifitem, p1);
- return STATE_state0;
- }
- case CHAIN_state0_TRANS_INITIAL_TO__state2:
- {
- action_state0_TRANS_INITIAL_TO__state2();
- return STATE_state0_state2;
- }
- case CHAIN_state0_TRANS_state1_TO_state1_BY_msg1TestPort1_tr6:
- {
- int p1 = (Integer) generic_data;
- action_state0_TRANS_state1_TO_state1_BY_msg1TestPort1_tr6(ifitem, p1);
- return STATE_state0_state1;
- }
- case CHAIN_state0_TRANS_tp1_TO_state1_BY_msg2TestPort1:
- {
- int p1 = (Integer) generic_data;
- action_state0_TRANS_tp1_TO_state1_BY_msg2TestPort1(ifitem, p1);
- return STATE_state0_state1;
- }
- case CHAIN_state0_TRANS_tp1_TO_state2_BY_msg2TestPort1:
- {
- int p1 = (Integer) generic_data;
- action_state0_TRANS_tp1_TO_state2_BY_msg2TestPort1(ifitem, p1);
- return STATE_state0_state2;
- }
- case CHAIN_state0_state1_TRANS_INITIAL_TO__state7:
- {
- action_state0_state1_TRANS_INITIAL_TO__state7();
- return STATE_state0_state1_state7;
- }
- }
- return NO_STATE;
- }
- /**
- * calls entry codes while entering a state's history. The ID of the final leaf state is returned
- * @param state - the state which is entered
- * @param handler - entry code is executed if not handler
- * @return - the ID of the final leaf state
- */
- private int enterHistory(int state, boolean handler, boolean skip_entry) {
- while (true) {
- switch (state) {
- case STATE_state0:
- if (!(skip_entry || handler)) entry_state0();
- // state has a sub graph
- // with init transition
- if (history[STATE_state0]==NO_STATE) {
- state = executeTransitionChain(CHAIN_state0_TRANS_INITIAL_TO__state2, null, null);
- }
- else {
- state = history[STATE_state0];
- }
- break;
- case STATE_state0_state1:
- if (!(skip_entry || handler)) entry_state0_state1();
- // state has a sub graph
- // with init transition
- if (history[STATE_state0_state1]==NO_STATE) {
- state = executeTransitionChain(CHAIN_state0_state1_TRANS_INITIAL_TO__state7, null, null);
- }
- else {
- state = history[STATE_state0_state1];
- }
- break;
- case STATE_state0_state1_state7:
- if (!(skip_entry || handler)) entry_state0_state1_state7();
- // in leaf state: return state id
- return STATE_state0_state1_state7;
- case STATE_state0_state2:
- if (!(skip_entry || handler)) entry_state0_state2();
- // in leaf state: return state id
- return STATE_state0_state2;
- case STATE_testOk:
- // in leaf state: return state id
- return STATE_testOk;
- case STATE_testFalse:
- // in leaf state: return state id
- return STATE_testFalse;
- case STATE_state1:
- if (!(skip_entry || handler)) entry_state1();
- // in leaf state: return state id
- return STATE_state1;
- case STATE_TOP:
- state = history[STATE_TOP];
- break;
- }
- skip_entry = false;
- }
- //return NO_STATE; // required by CDT but detected as unreachable by JDT because of while (true)
- }
-
- //*** Entry and Exit Codes
- protected void entry_state0() {
- System.out.println("state 0 entry action");
- crcGen.update(13);
- }
- protected void exit_state0() {
- System.out.println("state 0 exit action");
- crcGen.update(14);
- }
- protected void entry_state0_state1() {
- System.out.println("state 0/1 entry action");
- crcGen.update(16);
- }
- protected void exit_state0_state1() {
- System.out.println("state 0/1 exit action");
- crcGen.update(17);
- }
- protected void entry_state0_state1_state7() {
- System.out.println("state 0/1/7 entry action");
- crcGen.update(23);
- }
- protected void exit_state0_state1_state7() {
- System.out.println("state 0/1/7 exit action");
- crcGen.update(24);
- }
- protected void entry_state0_state2() {
- System.out.println("state 0/2 entry action");
- crcGen.update(18);
- }
- protected void exit_state0_state2() {
- System.out.println("state 0/2 exit action");
- crcGen.update(19);
- }
- protected void entry_state1() {
- System.out.println("state 1 entry action");
- crcGen.update(111);
- }
- protected void exit_state1() {
- System.out.println("state 1 exit action");
- crcGen.update(112);
- }
-
- //*** Action Codes
- protected void action_TRANS_tp0_TO_tp0_BY_msg1TestPort1_tr0(InterfaceItemBase ifitem, int p1) {
- System.out.println("top level handler action no guard ");
- crcGen.update(11);
- }
- protected void action_TRANS_tp1_TO_tp1_BY_msg1TestPort1_tr1(InterfaceItemBase ifitem, int p1) {
- System.out.println("top level self transition action P1=>3");
- crcGen.update(12);
- }
- protected void action_TRANS_INITIAL_TO__state0_tp2() {
- System.out.println("top level initial transition");
- crcGen.update(10);
- }
- protected void action_TRANS_cp0_TO_testFalse(InterfaceItemBase ifitem, int p1) {
- System.out.println("Test false");
- RTServices.getInstance().getSubSystem().testFinished(1);
- }
- protected void action_TRANS_cp0_TO_testOk_COND_tr3(InterfaceItemBase ifitem, int p1) {
- System.out.println("Test ok");
- RTServices.getInstance().getSubSystem().testFinished(0);
- }
- protected void action_TRANS_state0_TO_cp1_BY_msg1TestPort1(InterfaceItemBase ifitem, int p1) {
- System.out.println("tr9 transition action");
- crcGen.update(114);
- }
- protected void action_TRANS_tp1_TO_tp1_BY_msg2TestPort1_tr5(InterfaceItemBase ifitem, int p1) {
- System.out.println("top level self transition action P1=>4");
- crcGen.update(50);
- }
- protected void action_TRANS_tp0_TO_state0_BY_msg1TestPort1(InterfaceItemBase ifitem, int p1) {
- System.out.println("top level handler action p1=>7 ");
- crcGen.update(70);
- }
- protected void action_TRANS_tp0_TO_tp0_BY_msg1TestPort1_tr6(InterfaceItemBase ifitem, int p1) {
- System.out.println("top level handler action p1=>12 ");
- crcGen.update(110);
- }
- protected void action_TRANS_cp1_TO_state1(InterfaceItemBase ifitem, int p1) {
- System.out.println("tr8 transition action");
- crcGen.update(113);
- }
- protected void action_TRANS_cp1_TO_state0_COND_tr10(InterfaceItemBase ifitem, int p1) {
- System.out.println("tr4 transition action");
- crcGen.update(115);
- }
- protected void action_TRANS_tp1_TO_cp0_BY_msg6TestPort1(InterfaceItemBase ifitem, int p1) {
- System.out.println("tp1 transition to choice action");
- crcGen.update(117);
- System.out.printf("CRC: %d \n", crcGen.getCrc());
- }
- protected void action_state0_TRANS_tp0_TO_tp0_BY_msg3TestPort1_tr1(InterfaceItemBase ifitem) {
- System.out.println("state 0 handler action no guard");
- crcGen.update(20);
- }
- protected void action_state0_TRANS_tp1_TO_tp1_BY_msg4TestPort1_tr2(InterfaceItemBase ifitem) {
- System.out.println("state 0 tp1 self transition action");
- crcGen.update(21);
- }
- protected void action_state0_TRANS_state2_TO_state2_BY_msg1TestPort1_tr3(InterfaceItemBase ifitem, int p1) {
- System.out.println("state 0/2 self transition action");
- crcGen.update(25);
- }
- protected void action_state0_TRANS_tp2_TO_state0_state1_tp0(InterfaceItemBase ifitem) {
- System.out.println("state 0 tp2 transition action");
- crcGen.update(15);
- }
- protected void action_state0_TRANS_tp0_TO_tp0_BY_msg1TestPort1_tr5(InterfaceItemBase ifitem, int p1) {
- System.out.println("state 0 handler action P1 => 5");
- crcGen.update(52);
- }
- protected void action_state0_TRANS_INITIAL_TO__state2() {
- System.out.println("state 0 initial transition");
- crcGen.update(53);
- }
- protected void action_state0_TRANS_state1_TO_state1_BY_msg1TestPort1_tr6(InterfaceItemBase ifitem, int p1) {
- System.out.println("state 0/1 self transition");
- crcGen.update(54);
- }
- protected void action_state0_TRANS_tp1_TO_state1_BY_msg2TestPort1(InterfaceItemBase ifitem, int p1) {
- System.out.println("state 0 tp1 p1=>5");
- crcGen.update(120);
- }
- protected void action_state0_TRANS_tp1_TO_state2_BY_msg2TestPort1(InterfaceItemBase ifitem, int p1) {
- System.out.println("state 0 tp1 action P1 => 6");
- crcGen.update(121);
- }
- protected void action_state0_state1_TRANS_tp0_TO_state7(InterfaceItemBase ifitem) {
- System.out.println("state 0/1 transition entry action");
- crcGen.update(22);
- }
- protected void action_state0_state1_TRANS_INITIAL_TO__state7() {
- System.out.println("state 0/1 initial transition");
- crcGen.update(121);
- }
//******************************************
// END of generated code for FSM
diff --git a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/HandlerTest/TestProtocol.java b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/HandlerTest/TestProtocol.java
index 05ab66eae..3d0437aa7 100644
--- a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/HandlerTest/TestProtocol.java
+++ b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/HandlerTest/TestProtocol.java
@@ -11,19 +11,14 @@ import org.eclipse.etrice.runtime.java.debugging.DebuggingService;
public class TestProtocol {
// message IDs
- // TODO: separate class for message IDs: class MSG{public static volatile int MSG_MIN = 0; ...} -> better structure
- // error if msgID <= MSG_MIN
- public static final int MSG_MIN = 0;
- //IDs for outgoing messages
- //IDs for incoming messages
+ public static final int MSG_MIN = 0;
public static final int IN_msg1 = 1;
public static final int IN_msg2 = 2;
public static final int IN_msg3 = 3;
public static final int IN_msg4 = 4;
public static final int IN_msg5 = 5;
public static final int IN_msg6 = 6;
- //error if msgID >= MSG_MAX
- public static final int MSG_MAX = 7;
+ public static final int MSG_MAX = 7;
private static String messageStrings[] = {"MIN", "msg1","msg2","msg3","msg4","msg5","msg6","MAX"};
diff --git a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/HandlerTest/Tester.java b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/HandlerTest/Tester.java
index 3224bfaed..745fde1a6 100644
--- a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/HandlerTest/Tester.java
+++ b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/HandlerTest/Tester.java
@@ -25,9 +25,9 @@ public class Tester extends ActorClassBase {
//--------------------- services
//--------------------- interface item IDs
- protected static final int IFITEM_TestPort1 = 1;
- protected static final int IFITEM_timer = 2;
-
+ public static final int IFITEM_TestPort1 = 1;
+ public static final int IFITEM_timer = 2;
+
//--------------------- attributes
//--------------------- operations
@@ -63,66 +63,63 @@ public class Tester extends ActorClassBase {
destroyUser();
}
- //******************************************
- // START of generated code for FSM
- //******************************************
- // State IDs for FSM
- protected static final int STATE_state0 = 2;
- protected static final String stateStrings[] = {"<no state>","<top>","state0"
- };
+ /* state IDs */
+ public static final int STATE_state0 = 2;
- // history
- // TODOHRR: history defined in ActorClassBase, init in constructor
- // history = new int[5];
- // for (int i = 0; i < history.length; i++) {
- // history[i] = NO_STATE;
- // }
- protected int history[] = {NO_STATE,NO_STATE,NO_STATE};
+ /* transition chains */
+ public static final int CHAIN_TRANS_INITIAL_TO__state0 = 1;
- // transition chains
- protected static final int CHAIN_TRANS_INITIAL_TO__state0 = 1;
+ /* triggers */
- // triggers for FSM
+ // state names
+ protected static final String stateStrings[] = {"<no state>","<top>","state0"
+ };
- // receiveEvent contains the main implementation of the FSM
- @Override
- public void receiveEvent(InterfaceItemBase ifitem, int evt, Object generic_data) {
- int trigger = ifitem.getLocalId() + EVT_SHIFT*evt;
- int chain = NOT_CAUGHT;
- int catching_state = NO_STATE;
- boolean is_handler = false;
- boolean skip_entry = false;
-
- if (!handleSystemEvent(ifitem, evt, generic_data)) {
- switch (state) {
- case STATE_state0:
- break;
- }
- }
- if (chain != NOT_CAUGHT) {
- exitTo(state, catching_state, is_handler);
- int next = executeTransitionChain(chain, ifitem, generic_data);
- next = enterHistory(next, is_handler, skip_entry);
- setState(next);
- }
- }
+ // history
+ protected int history[] = {NO_STATE,NO_STATE,NO_STATE};
private void setState(int new_state) {
DebuggingService.getInstance().addActorState(this,stateStrings[new_state]);
if (stateStrings[new_state]!="Idle") {
- // TODOTS: model switch for activation
System.out.println(getInstancePath() + " -> " + stateStrings[new_state]);
}
this.state = new_state;
}
- @Override
- public void executeInitTransition() {
- int chain = CHAIN_TRANS_INITIAL_TO__state0;
- int next = executeTransitionChain(chain, null, null);
- next = enterHistory(next, false, false);
- setState(next);
+ //*** Entry and Exit Codes
+
+ //*** Action Codes
+ protected void action_TRANS_INITIAL_TO__state0() {
+ TestPort1.msg1(2);
+ System.out.println("msg1(2) sent ");
+ TestPort1.msg1(3);
+ System.out.println("msg1(3) sent ");
+ TestPort1.msg1(7);
+ System.out.println("msg1(7) sent ");
+ TestPort1.msg1(4);
+ System.out.println("msg1(4) sent ");
+ TestPort1.msg1(5);
+ System.out.println("msg1(5) sent ");
+ TestPort1.msg1(7);
+ System.out.println("msg1(7) sent ");
+ TestPort1.msg2(5);
+ System.out.println("msg2(5) sent ");
+ TestPort1.msg2(6);
+ System.out.println("msg2(6) sent ");
+
+
+
+ TestPort1.msg1(5);
+ System.out.println("msg1(5) sent ");
+ TestPort1.msg3();
+ System.out.println("msg3() sent ");
+ TestPort1.msg4();
+ System.out.println("msg4() sent ");
+ TestPort1.msg1(8);
+ System.out.println("msg1(8) sent ");
+ TestPort1.msg6(12);
+ System.out.println("msg6(12) sent ");
}
/**
@@ -136,12 +133,13 @@ public class Tester extends ActorClassBase {
while (current!=to) {
switch (current) {
case STATE_state0:
- history[STATE_TOP] = STATE_state0;
+ this.history[STATE_TOP] = STATE_state0;
current = STATE_TOP;
break;
}
}
}
+
/**
* calls action, entry and exit codes along a transition chain. The generic data are cast to typed data
* matching the trigger of this chain. The ID of the final state is returned
@@ -159,6 +157,7 @@ public class Tester extends ActorClassBase {
}
return NO_STATE;
}
+
/**
* calls entry codes while entering a state's history. The ID of the final leaf state is returned
* @param state - the state which is entered
@@ -172,7 +171,7 @@ public class Tester extends ActorClassBase {
// in leaf state: return state id
return STATE_state0;
case STATE_TOP:
- state = history[STATE_TOP];
+ state = this.history[STATE_TOP];
break;
}
skip_entry = false;
@@ -180,39 +179,33 @@ public class Tester extends ActorClassBase {
//return NO_STATE; // required by CDT but detected as unreachable by JDT because of while (true)
}
- //*** Entry and Exit Codes
+ public void executeInitTransition() {
+ int chain = CHAIN_TRANS_INITIAL_TO__state0;
+ int next = executeTransitionChain(chain, null, null);
+ next = enterHistory(next, false, false);
+ setState(next);
+ }
- //*** Action Codes
- protected void action_TRANS_INITIAL_TO__state0() {
- TestPort1.msg1(2);
- System.out.println("msg1(2) sent ");
- TestPort1.msg1(3);
- System.out.println("msg1(3) sent ");
- TestPort1.msg1(7);
- System.out.println("msg1(7) sent ");
- TestPort1.msg1(4);
- System.out.println("msg1(4) sent ");
- TestPort1.msg1(5);
- System.out.println("msg1(5) sent ");
- TestPort1.msg1(7);
- System.out.println("msg1(7) sent ");
- TestPort1.msg2(5);
- System.out.println("msg2(5) sent ");
- TestPort1.msg2(6);
- System.out.println("msg2(6) sent ");
-
-
+ /* receiveEvent contains the main implementation of the FSM */
+ public void receiveEvent(InterfaceItemBase ifitem, int evt, Object generic_data) {
+ int trigger = ifitem.getLocalId() + EVT_SHIFT*evt;
+ int chain = NOT_CAUGHT;
+ int catching_state = NO_STATE;
+ boolean is_handler = false;
+ boolean skip_entry = false;
- TestPort1.msg1(5);
- System.out.println("msg1(5) sent ");
- TestPort1.msg3();
- System.out.println("msg3() sent ");
- TestPort1.msg4();
- System.out.println("msg4() sent ");
- TestPort1.msg1(8);
- System.out.println("msg1(8) sent ");
- TestPort1.msg6(12);
- System.out.println("msg6(12) sent ");
+ if (!handleSystemEvent(ifitem, evt, generic_data)) {
+ switch (this.state) {
+ case STATE_state0:
+ break;
+ }
+ }
+ if (chain != NOT_CAUGHT) {
+ exitTo(this.state, catching_state, is_handler);
+ int next = executeTransitionChain(chain, ifitem, generic_data);
+ next = enterHistory(next, is_handler, skip_entry);
+ setState(next);
+ }
}
//******************************************
diff --git a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/PingPongThreadTest/MrPingActor.java b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/PingPongThreadTest/MrPingActor.java
index e6d4384c4..5cea29de5 100644
--- a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/PingPongThreadTest/MrPingActor.java
+++ b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/PingPongThreadTest/MrPingActor.java
@@ -30,11 +30,11 @@ public class MrPingActor extends ActorClassBase {
//--------------------- services
//--------------------- interface item IDs
- protected static final int IFITEM_PingPongPort = 1;
- protected static final int IFITEM_PingPongPort2 = 2;
- protected static final int IFITEM_PingPongPort3 = 3;
- protected static final int IFITEM_timer = 4;
-
+ public static final int IFITEM_PingPongPort = 1;
+ public static final int IFITEM_PingPongPort2 = 2;
+ public static final int IFITEM_PingPongPort3 = 3;
+ public static final int IFITEM_timer = 4;
+
//--------------------- attributes
protected int count;
protected int pongCount;
@@ -76,97 +76,58 @@ public class MrPingActor extends ActorClassBase {
destroyUser();
}
- //******************************************
- // START of generated code for FSM
- //******************************************
- // State IDs for FSM
- protected static final int STATE_waitForTimer = 2;
- protected static final int STATE_waitForPong = 3;
- protected static final String stateStrings[] = {"<no state>","<top>","waitForTimer",
- "waitForPong"
- };
+ /* state IDs */
+ public static final int STATE_waitForTimer = 2;
+ public static final int STATE_waitForPong = 3;
- // history
- // TODOHRR: history defined in ActorClassBase, init in constructor
- // history = new int[5];
- // for (int i = 0; i < history.length; i++) {
- // history[i] = NO_STATE;
- // }
- protected int history[] = {NO_STATE,NO_STATE,NO_STATE,NO_STATE};
+ /* transition chains */
+ public static final int CHAIN_TRANS_INITIAL_TO__waitForTimer = 1;
+ public static final int CHAIN_TRANS_waitForPong_TO_cp0_BY_pongPingPongPort2pongPingPongPort = 2;
+ public static final int CHAIN_TRANS_waitForTimer_TO_waitForPong_BY_timeoutTicktimer = 3;
- // transition chains
- protected static final int CHAIN_TRANS_INITIAL_TO__waitForTimer = 1;
- protected static final int CHAIN_TRANS_waitForPong_TO_cp0_BY_pongPingPongPort2pongPingPongPort = 2;
- protected static final int CHAIN_TRANS_waitForTimer_TO_waitForPong_BY_timeoutTicktimer = 3;
+ /* triggers */
+ public static final int TRIG_PingPongPort2__pong = IFITEM_PingPongPort2 + EVT_SHIFT*PingPongProtocol.OUT_pong;
+ public static final int TRIG_PingPongPort__pong = IFITEM_PingPongPort + EVT_SHIFT*PingPongProtocol.OUT_pong;
+ public static final int TRIG_timer__timeoutTick = IFITEM_timer + EVT_SHIFT*PTimeout.OUT_timeoutTick;
- // triggers for FSM
- protected static final int TRIG_PingPongPort2__pong = IFITEM_PingPongPort2 + EVT_SHIFT*PingPongProtocol.OUT_pong;
- protected static final int TRIG_PingPongPort__pong = IFITEM_PingPongPort + EVT_SHIFT*PingPongProtocol.OUT_pong;
- protected static final int TRIG_timer__timeoutTick = IFITEM_timer + EVT_SHIFT*PTimeout.OUT_timeoutTick;
+ // state names
+ protected static final String stateStrings[] = {"<no state>","<top>","waitForTimer",
+ "waitForPong"
+ };
- // receiveEvent contains the main implementation of the FSM
- @Override
- public void receiveEvent(InterfaceItemBase ifitem, int evt, Object generic_data) {
- int trigger = ifitem.getLocalId() + EVT_SHIFT*evt;
- int chain = NOT_CAUGHT;
- int catching_state = NO_STATE;
- boolean is_handler = false;
- boolean skip_entry = false;
-
- if (!handleSystemEvent(ifitem, evt, generic_data)) {
- switch (state) {
- case STATE_waitForTimer:
- switch(trigger) {
- case TRIG_timer__timeoutTick:
- {
- chain = CHAIN_TRANS_waitForTimer_TO_waitForPong_BY_timeoutTicktimer;
- catching_state = STATE_TOP;
- }
- break;
- }
- break;
- case STATE_waitForPong:
- switch(trigger) {
- case TRIG_PingPongPort2__pong:
- {
- chain = CHAIN_TRANS_waitForPong_TO_cp0_BY_pongPingPongPort2pongPingPongPort;
- catching_state = STATE_TOP;
- }
- break;
- case TRIG_PingPongPort__pong:
- {
- chain = CHAIN_TRANS_waitForPong_TO_cp0_BY_pongPingPongPort2pongPingPongPort;
- catching_state = STATE_TOP;
- }
- break;
- }
- break;
- }
- }
- if (chain != NOT_CAUGHT) {
- exitTo(state, catching_state, is_handler);
- int next = executeTransitionChain(chain, ifitem, generic_data);
- next = enterHistory(next, is_handler, skip_entry);
- setState(next);
- }
- }
+ // history
+ protected int history[] = {NO_STATE,NO_STATE,NO_STATE,NO_STATE};
private void setState(int new_state) {
DebuggingService.getInstance().addActorState(this,stateStrings[new_state]);
if (stateStrings[new_state]!="Idle") {
- // TODOTS: model switch for activation
System.out.println(getInstancePath() + " -> " + stateStrings[new_state]);
}
this.state = new_state;
}
- @Override
- public void executeInitTransition() {
- int chain = CHAIN_TRANS_INITIAL_TO__waitForTimer;
- int next = executeTransitionChain(chain, null, null);
- next = enterHistory(next, false, false);
- setState(next);
+ //*** Entry and Exit Codes
+
+ //*** Action Codes
+ protected void action_TRANS_INITIAL_TO__waitForTimer() {
+ count = 0;
+ timer.Start(10);
+ }
+ protected void action_TRANS_waitForTimer_TO_waitForPong_BY_timeoutTicktimer(InterfaceItemBase ifitem) {
+ PingPongPort.ping();
+ PingPongPort2.ping();
+ pongCount = 0;
+ }
+ protected void action_TRANS_waitForPong_TO_cp0_BY_pongPingPongPort2pongPingPongPort(InterfaceItemBase ifitem) {
+ pongCount++;
+ }
+ protected void action_TRANS_cp0_TO_waitForTimer(InterfaceItemBase ifitem) {
+ if (count++ > 100) {
+ RTServices.getInstance().getSubSystem().testFinished(0);
+ } else {
+ System.out.println(count);
+ timer.Start(5);}
}
/**
@@ -180,16 +141,17 @@ public class MrPingActor extends ActorClassBase {
while (current!=to) {
switch (current) {
case STATE_waitForTimer:
- history[STATE_TOP] = STATE_waitForTimer;
+ this.history[STATE_TOP] = STATE_waitForTimer;
current = STATE_TOP;
break;
case STATE_waitForPong:
- history[STATE_TOP] = STATE_waitForPong;
+ this.history[STATE_TOP] = STATE_waitForPong;
current = STATE_TOP;
break;
}
}
}
+
/**
* calls action, entry and exit codes along a transition chain. The generic data are cast to typed data
* matching the trigger of this chain. The ID of the final state is returned
@@ -222,6 +184,7 @@ public class MrPingActor extends ActorClassBase {
}
return NO_STATE;
}
+
/**
* calls entry codes while entering a state's history. The ID of the final leaf state is returned
* @param state - the state which is entered
@@ -238,7 +201,7 @@ public class MrPingActor extends ActorClassBase {
// in leaf state: return state id
return STATE_waitForPong;
case STATE_TOP:
- state = history[STATE_TOP];
+ state = this.history[STATE_TOP];
break;
}
skip_entry = false;
@@ -246,27 +209,57 @@ public class MrPingActor extends ActorClassBase {
//return NO_STATE; // required by CDT but detected as unreachable by JDT because of while (true)
}
- //*** Entry and Exit Codes
-
- //*** Action Codes
- protected void action_TRANS_INITIAL_TO__waitForTimer() {
- count = 0;
- timer.Start(10);
- }
- protected void action_TRANS_waitForTimer_TO_waitForPong_BY_timeoutTicktimer(InterfaceItemBase ifitem) {
- PingPongPort.ping();
- PingPongPort2.ping();
- pongCount = 0;
- }
- protected void action_TRANS_waitForPong_TO_cp0_BY_pongPingPongPort2pongPingPongPort(InterfaceItemBase ifitem) {
- pongCount++;
+ public void executeInitTransition() {
+ int chain = CHAIN_TRANS_INITIAL_TO__waitForTimer;
+ int next = executeTransitionChain(chain, null, null);
+ next = enterHistory(next, false, false);
+ setState(next);
}
- protected void action_TRANS_cp0_TO_waitForTimer(InterfaceItemBase ifitem) {
- if (count++ > 100) {
- RTServices.getInstance().getSubSystem().testFinished(0);
- } else {
- System.out.println(count);
- timer.Start(5);}
+
+ /* receiveEvent contains the main implementation of the FSM */
+ public void receiveEvent(InterfaceItemBase ifitem, int evt, Object generic_data) {
+ int trigger = ifitem.getLocalId() + EVT_SHIFT*evt;
+ int chain = NOT_CAUGHT;
+ int catching_state = NO_STATE;
+ boolean is_handler = false;
+ boolean skip_entry = false;
+
+ if (!handleSystemEvent(ifitem, evt, generic_data)) {
+ switch (this.state) {
+ case STATE_waitForTimer:
+ switch(trigger) {
+ case TRIG_timer__timeoutTick:
+ {
+ chain = CHAIN_TRANS_waitForTimer_TO_waitForPong_BY_timeoutTicktimer;
+ catching_state = STATE_TOP;
+ }
+ break;
+ }
+ break;
+ case STATE_waitForPong:
+ switch(trigger) {
+ case TRIG_PingPongPort2__pong:
+ {
+ chain = CHAIN_TRANS_waitForPong_TO_cp0_BY_pongPingPongPort2pongPingPongPort;
+ catching_state = STATE_TOP;
+ }
+ break;
+ case TRIG_PingPongPort__pong:
+ {
+ chain = CHAIN_TRANS_waitForPong_TO_cp0_BY_pongPingPongPort2pongPingPongPort;
+ catching_state = STATE_TOP;
+ }
+ break;
+ }
+ break;
+ }
+ }
+ if (chain != NOT_CAUGHT) {
+ exitTo(this.state, catching_state, is_handler);
+ int next = executeTransitionChain(chain, ifitem, generic_data);
+ next = enterHistory(next, is_handler, skip_entry);
+ setState(next);
+ }
}
//******************************************
diff --git a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/PingPongThreadTest/MrPongActor1.java b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/PingPongThreadTest/MrPongActor1.java
index 5a532b646..1df1c9646 100644
--- a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/PingPongThreadTest/MrPongActor1.java
+++ b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/PingPongThreadTest/MrPongActor1.java
@@ -22,8 +22,8 @@ public class MrPongActor1 extends ActorClassBase {
//--------------------- services
//--------------------- interface item IDs
- protected static final int IFITEM_PingPongPort = 1;
-
+ public static final int IFITEM_PingPongPort = 1;
+
//--------------------- attributes
//--------------------- operations
@@ -58,76 +58,37 @@ public class MrPongActor1 extends ActorClassBase {
destroyUser();
}
- //******************************************
- // START of generated code for FSM
- //******************************************
- // State IDs for FSM
- protected static final int STATE_waitForPing = 2;
- protected static final String stateStrings[] = {"<no state>","<top>","waitForPing"
- };
+ /* state IDs */
+ public static final int STATE_waitForPing = 2;
- // history
- // TODOHRR: history defined in ActorClassBase, init in constructor
- // history = new int[5];
- // for (int i = 0; i < history.length; i++) {
- // history[i] = NO_STATE;
- // }
- protected int history[] = {NO_STATE,NO_STATE,NO_STATE};
+ /* transition chains */
+ public static final int CHAIN_TRANS_INITIAL_TO__waitForPing = 1;
+ public static final int CHAIN_TRANS_waitForPing_TO_waitForPing_BY_pingPingPongPort_myTrigger = 2;
- // transition chains
- protected static final int CHAIN_TRANS_INITIAL_TO__waitForPing = 1;
- protected static final int CHAIN_TRANS_waitForPing_TO_waitForPing_BY_pingPingPongPort_myTrigger = 2;
+ /* triggers */
+ public static final int TRIG_PingPongPort__ping = IFITEM_PingPongPort + EVT_SHIFT*PingPongProtocol.IN_ping;
- // triggers for FSM
- protected static final int TRIG_PingPongPort__ping = IFITEM_PingPongPort + EVT_SHIFT*PingPongProtocol.IN_ping;
+ // state names
+ protected static final String stateStrings[] = {"<no state>","<top>","waitForPing"
+ };
- // receiveEvent contains the main implementation of the FSM
- @Override
- public void receiveEvent(InterfaceItemBase ifitem, int evt, Object generic_data) {
- int trigger = ifitem.getLocalId() + EVT_SHIFT*evt;
- int chain = NOT_CAUGHT;
- int catching_state = NO_STATE;
- boolean is_handler = false;
- boolean skip_entry = false;
-
- if (!handleSystemEvent(ifitem, evt, generic_data)) {
- switch (state) {
- case STATE_waitForPing:
- switch(trigger) {
- case TRIG_PingPongPort__ping:
- {
- chain = CHAIN_TRANS_waitForPing_TO_waitForPing_BY_pingPingPongPort_myTrigger;
- catching_state = STATE_TOP;
- }
- break;
- }
- break;
- }
- }
- if (chain != NOT_CAUGHT) {
- exitTo(state, catching_state, is_handler);
- int next = executeTransitionChain(chain, ifitem, generic_data);
- next = enterHistory(next, is_handler, skip_entry);
- setState(next);
- }
- }
+ // history
+ protected int history[] = {NO_STATE,NO_STATE,NO_STATE};
private void setState(int new_state) {
DebuggingService.getInstance().addActorState(this,stateStrings[new_state]);
if (stateStrings[new_state]!="Idle") {
- // TODOTS: model switch for activation
System.out.println(getInstancePath() + " -> " + stateStrings[new_state]);
}
this.state = new_state;
}
- @Override
- public void executeInitTransition() {
- int chain = CHAIN_TRANS_INITIAL_TO__waitForPing;
- int next = executeTransitionChain(chain, null, null);
- next = enterHistory(next, false, false);
- setState(next);
+ //*** Entry and Exit Codes
+
+ //*** Action Codes
+ protected void action_TRANS_waitForPing_TO_waitForPing_BY_pingPingPongPort_myTrigger(InterfaceItemBase ifitem) {
+ PingPongPort.pong();
}
/**
@@ -141,12 +102,13 @@ public class MrPongActor1 extends ActorClassBase {
while (current!=to) {
switch (current) {
case STATE_waitForPing:
- history[STATE_TOP] = STATE_waitForPing;
+ this.history[STATE_TOP] = STATE_waitForPing;
current = STATE_TOP;
break;
}
}
}
+
/**
* calls action, entry and exit codes along a transition chain. The generic data are cast to typed data
* matching the trigger of this chain. The ID of the final state is returned
@@ -168,6 +130,7 @@ public class MrPongActor1 extends ActorClassBase {
}
return NO_STATE;
}
+
/**
* calls entry codes while entering a state's history. The ID of the final leaf state is returned
* @param state - the state which is entered
@@ -181,7 +144,7 @@ public class MrPongActor1 extends ActorClassBase {
// in leaf state: return state id
return STATE_waitForPing;
case STATE_TOP:
- state = history[STATE_TOP];
+ state = this.history[STATE_TOP];
break;
}
skip_entry = false;
@@ -189,11 +152,41 @@ public class MrPongActor1 extends ActorClassBase {
//return NO_STATE; // required by CDT but detected as unreachable by JDT because of while (true)
}
- //*** Entry and Exit Codes
+ public void executeInitTransition() {
+ int chain = CHAIN_TRANS_INITIAL_TO__waitForPing;
+ int next = executeTransitionChain(chain, null, null);
+ next = enterHistory(next, false, false);
+ setState(next);
+ }
- //*** Action Codes
- protected void action_TRANS_waitForPing_TO_waitForPing_BY_pingPingPongPort_myTrigger(InterfaceItemBase ifitem) {
- PingPongPort.pong();
+ /* receiveEvent contains the main implementation of the FSM */
+ public void receiveEvent(InterfaceItemBase ifitem, int evt, Object generic_data) {
+ int trigger = ifitem.getLocalId() + EVT_SHIFT*evt;
+ int chain = NOT_CAUGHT;
+ int catching_state = NO_STATE;
+ boolean is_handler = false;
+ boolean skip_entry = false;
+
+ if (!handleSystemEvent(ifitem, evt, generic_data)) {
+ switch (this.state) {
+ case STATE_waitForPing:
+ switch(trigger) {
+ case TRIG_PingPongPort__ping:
+ {
+ chain = CHAIN_TRANS_waitForPing_TO_waitForPing_BY_pingPingPongPort_myTrigger;
+ catching_state = STATE_TOP;
+ }
+ break;
+ }
+ break;
+ }
+ }
+ if (chain != NOT_CAUGHT) {
+ exitTo(this.state, catching_state, is_handler);
+ int next = executeTransitionChain(chain, ifitem, generic_data);
+ next = enterHistory(next, is_handler, skip_entry);
+ setState(next);
+ }
}
//******************************************
diff --git a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/PingPongThreadTest/MrPongActor2.java b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/PingPongThreadTest/MrPongActor2.java
index bbd1adb1c..82fdf30ed 100644
--- a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/PingPongThreadTest/MrPongActor2.java
+++ b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/PingPongThreadTest/MrPongActor2.java
@@ -22,8 +22,8 @@ public class MrPongActor2 extends ActorClassBase {
//--------------------- services
//--------------------- interface item IDs
- protected static final int IFITEM_PingPongPort = 1;
-
+ public static final int IFITEM_PingPongPort = 1;
+
//--------------------- attributes
//--------------------- operations
@@ -58,76 +58,43 @@ public class MrPongActor2 extends ActorClassBase {
destroyUser();
}
- //******************************************
- // START of generated code for FSM
- //******************************************
- // State IDs for FSM
- protected static final int STATE_waitForPing = 2;
- protected static final String stateStrings[] = {"<no state>","<top>","waitForPing"
- };
+ /* state IDs */
+ public static final int STATE_waitForPing = 2;
- // history
- // TODOHRR: history defined in ActorClassBase, init in constructor
- // history = new int[5];
- // for (int i = 0; i < history.length; i++) {
- // history[i] = NO_STATE;
- // }
- protected int history[] = {NO_STATE,NO_STATE,NO_STATE};
+ /* transition chains */
+ public static final int CHAIN_TRANS_INITIAL_TO__waitForPing = 1;
+ public static final int CHAIN_TRANS_waitForPing_TO_waitForPing_BY_pingPingPongPort_myTrigger = 2;
- // transition chains
- protected static final int CHAIN_TRANS_INITIAL_TO__waitForPing = 1;
- protected static final int CHAIN_TRANS_waitForPing_TO_waitForPing_BY_pingPingPongPort_myTrigger = 2;
+ /* triggers */
+ public static final int TRIG_PingPongPort__ping = IFITEM_PingPongPort + EVT_SHIFT*PingPongProtocol.IN_ping;
- // triggers for FSM
- protected static final int TRIG_PingPongPort__ping = IFITEM_PingPongPort + EVT_SHIFT*PingPongProtocol.IN_ping;
+ // state names
+ protected static final String stateStrings[] = {"<no state>","<top>","waitForPing"
+ };
- // receiveEvent contains the main implementation of the FSM
- @Override
- public void receiveEvent(InterfaceItemBase ifitem, int evt, Object generic_data) {
- int trigger = ifitem.getLocalId() + EVT_SHIFT*evt;
- int chain = NOT_CAUGHT;
- int catching_state = NO_STATE;
- boolean is_handler = false;
- boolean skip_entry = false;
-
- if (!handleSystemEvent(ifitem, evt, generic_data)) {
- switch (state) {
- case STATE_waitForPing:
- switch(trigger) {
- case TRIG_PingPongPort__ping:
- {
- chain = CHAIN_TRANS_waitForPing_TO_waitForPing_BY_pingPingPongPort_myTrigger;
- catching_state = STATE_TOP;
- }
- break;
- }
- break;
- }
- }
- if (chain != NOT_CAUGHT) {
- exitTo(state, catching_state, is_handler);
- int next = executeTransitionChain(chain, ifitem, generic_data);
- next = enterHistory(next, is_handler, skip_entry);
- setState(next);
- }
- }
+ // history
+ protected int history[] = {NO_STATE,NO_STATE,NO_STATE};
private void setState(int new_state) {
DebuggingService.getInstance().addActorState(this,stateStrings[new_state]);
if (stateStrings[new_state]!="Idle") {
- // TODOTS: model switch for activation
System.out.println(getInstancePath() + " -> " + stateStrings[new_state]);
}
this.state = new_state;
}
- @Override
- public void executeInitTransition() {
- int chain = CHAIN_TRANS_INITIAL_TO__waitForPing;
- int next = executeTransitionChain(chain, null, null);
- next = enterHistory(next, false, false);
- setState(next);
+ //*** Entry and Exit Codes
+
+ //*** Action Codes
+ protected void action_TRANS_INITIAL_TO__waitForPing() {
+ // simulate blocking call e.g. Queue
+ try{
+ Thread.sleep(5000);
+ }catch (InterruptedException e){}
+ }
+ protected void action_TRANS_waitForPing_TO_waitForPing_BY_pingPingPongPort_myTrigger(InterfaceItemBase ifitem) {
+ PingPongPort.pong();
}
/**
@@ -141,12 +108,13 @@ public class MrPongActor2 extends ActorClassBase {
while (current!=to) {
switch (current) {
case STATE_waitForPing:
- history[STATE_TOP] = STATE_waitForPing;
+ this.history[STATE_TOP] = STATE_waitForPing;
current = STATE_TOP;
break;
}
}
}
+
/**
* calls action, entry and exit codes along a transition chain. The generic data are cast to typed data
* matching the trigger of this chain. The ID of the final state is returned
@@ -169,6 +137,7 @@ public class MrPongActor2 extends ActorClassBase {
}
return NO_STATE;
}
+
/**
* calls entry codes while entering a state's history. The ID of the final leaf state is returned
* @param state - the state which is entered
@@ -182,7 +151,7 @@ public class MrPongActor2 extends ActorClassBase {
// in leaf state: return state id
return STATE_waitForPing;
case STATE_TOP:
- state = history[STATE_TOP];
+ state = this.history[STATE_TOP];
break;
}
skip_entry = false;
@@ -190,17 +159,41 @@ public class MrPongActor2 extends ActorClassBase {
//return NO_STATE; // required by CDT but detected as unreachable by JDT because of while (true)
}
- //*** Entry and Exit Codes
-
- //*** Action Codes
- protected void action_TRANS_INITIAL_TO__waitForPing() {
- // simulate blocking call e.g. Queue
- try{
- Thread.sleep(5000);
- }catch (InterruptedException e){}
+ public void executeInitTransition() {
+ int chain = CHAIN_TRANS_INITIAL_TO__waitForPing;
+ int next = executeTransitionChain(chain, null, null);
+ next = enterHistory(next, false, false);
+ setState(next);
}
- protected void action_TRANS_waitForPing_TO_waitForPing_BY_pingPingPongPort_myTrigger(InterfaceItemBase ifitem) {
- PingPongPort.pong();
+
+ /* receiveEvent contains the main implementation of the FSM */
+ public void receiveEvent(InterfaceItemBase ifitem, int evt, Object generic_data) {
+ int trigger = ifitem.getLocalId() + EVT_SHIFT*evt;
+ int chain = NOT_CAUGHT;
+ int catching_state = NO_STATE;
+ boolean is_handler = false;
+ boolean skip_entry = false;
+
+ if (!handleSystemEvent(ifitem, evt, generic_data)) {
+ switch (this.state) {
+ case STATE_waitForPing:
+ switch(trigger) {
+ case TRIG_PingPongPort__ping:
+ {
+ chain = CHAIN_TRANS_waitForPing_TO_waitForPing_BY_pingPingPongPort_myTrigger;
+ catching_state = STATE_TOP;
+ }
+ break;
+ }
+ break;
+ }
+ }
+ if (chain != NOT_CAUGHT) {
+ exitTo(this.state, catching_state, is_handler);
+ int next = executeTransitionChain(chain, ifitem, generic_data);
+ next = enterHistory(next, is_handler, skip_entry);
+ setState(next);
+ }
}
//******************************************
diff --git a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/PingPongThreadTest/PingPongProtocol.java b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/PingPongThreadTest/PingPongProtocol.java
index 0fbce52c7..19fba6c6c 100644
--- a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/PingPongThreadTest/PingPongProtocol.java
+++ b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/PingPongThreadTest/PingPongProtocol.java
@@ -11,15 +11,10 @@ import org.eclipse.etrice.runtime.java.debugging.DebuggingService;
public class PingPongProtocol {
// message IDs
- // TODO: separate class for message IDs: class MSG{public static volatile int MSG_MIN = 0; ...} -> better structure
- // error if msgID <= MSG_MIN
- public static final int MSG_MIN = 0;
- //IDs for outgoing messages
+ public static final int MSG_MIN = 0;
public static final int OUT_pong = 1;
- //IDs for incoming messages
public static final int IN_ping = 2;
- //error if msgID >= MSG_MAX
- public static final int MSG_MAX = 3;
+ public static final int MSG_MAX = 3;
private static String messageStrings[] = {"MIN", "pong", "ping","MAX"};
diff --git a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/PingPongThreadTest/PingPongTop.java b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/PingPongThreadTest/PingPongTop.java
index a2a19212a..16d6cbe55 100644
--- a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/PingPongThreadTest/PingPongTop.java
+++ b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/PingPongThreadTest/PingPongTop.java
@@ -20,7 +20,7 @@ public class PingPongTop extends ActorClassBase {
//--------------------- services
//--------------------- interface item IDs
-
+
//--------------------- attributes
//--------------------- operations
diff --git a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/PingPongThreadTestReplPort/MrPingActor.java b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/PingPongThreadTestReplPort/MrPingActor.java
index cd19c4098..1b479af2e 100644
--- a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/PingPongThreadTestReplPort/MrPingActor.java
+++ b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/PingPongThreadTestReplPort/MrPingActor.java
@@ -28,9 +28,9 @@ public class MrPingActor extends ActorClassBase {
//--------------------- services
//--------------------- interface item IDs
- protected static final int IFITEM_PingPongPort = 1;
- protected static final int IFITEM_timer = 2;
-
+ public static final int IFITEM_PingPongPort = 1;
+ public static final int IFITEM_timer = 2;
+
//--------------------- attributes
protected int count;
protected int pongCount;
@@ -70,90 +70,64 @@ public class MrPingActor extends ActorClassBase {
destroyUser();
}
- //******************************************
- // START of generated code for FSM
- //******************************************
- // State IDs for FSM
- protected static final int STATE_waitForTimer = 2;
- protected static final int STATE_waitForPong = 3;
- protected static final String stateStrings[] = {"<no state>","<top>","waitForTimer",
- "waitForPong"
- };
+ /* state IDs */
+ public static final int STATE_waitForTimer = 2;
+ public static final int STATE_waitForPong = 3;
- // history
- // TODOHRR: history defined in ActorClassBase, init in constructor
- // history = new int[5];
- // for (int i = 0; i < history.length; i++) {
- // history[i] = NO_STATE;
- // }
- protected int history[] = {NO_STATE,NO_STATE,NO_STATE,NO_STATE};
+ /* transition chains */
+ public static final int CHAIN_TRANS_INITIAL_TO__waitForTimer = 1;
+ public static final int CHAIN_TRANS_waitForPong_TO_cp0_BY_pongPingPongPort = 2;
+ public static final int CHAIN_TRANS_waitForTimer_TO_waitForPong_BY_timeoutTicktimer = 3;
- // transition chains
- protected static final int CHAIN_TRANS_INITIAL_TO__waitForTimer = 1;
- protected static final int CHAIN_TRANS_waitForPong_TO_cp0_BY_pongPingPongPort = 2;
- protected static final int CHAIN_TRANS_waitForTimer_TO_waitForPong_BY_timeoutTicktimer = 3;
+ /* triggers */
+ public static final int TRIG_PingPongPort__pong = IFITEM_PingPongPort + EVT_SHIFT*PingPongProtocol.OUT_pong;
+ public static final int TRIG_timer__timeoutTick = IFITEM_timer + EVT_SHIFT*PTimeout.OUT_timeoutTick;
- // triggers for FSM
- protected static final int TRIG_PingPongPort__pong = IFITEM_PingPongPort + EVT_SHIFT*PingPongProtocol.OUT_pong;
- protected static final int TRIG_timer__timeoutTick = IFITEM_timer + EVT_SHIFT*PTimeout.OUT_timeoutTick;
+ // state names
+ protected static final String stateStrings[] = {"<no state>","<top>","waitForTimer",
+ "waitForPong"
+ };
- // receiveEvent contains the main implementation of the FSM
- @Override
- public void receiveEvent(InterfaceItemBase ifitem, int evt, Object generic_data) {
- int trigger = ifitem.getLocalId() + EVT_SHIFT*evt;
- int chain = NOT_CAUGHT;
- int catching_state = NO_STATE;
- boolean is_handler = false;
- boolean skip_entry = false;
-
- if (!handleSystemEvent(ifitem, evt, generic_data)) {
- switch (state) {
- case STATE_waitForTimer:
- switch(trigger) {
- case TRIG_timer__timeoutTick:
- {
- chain = CHAIN_TRANS_waitForTimer_TO_waitForPong_BY_timeoutTicktimer;
- catching_state = STATE_TOP;
- }
- break;
- }
- break;
- case STATE_waitForPong:
- switch(trigger) {
- case TRIG_PingPongPort__pong:
- {
- chain = CHAIN_TRANS_waitForPong_TO_cp0_BY_pongPingPongPort;
- catching_state = STATE_TOP;
- }
- break;
- }
- break;
- }
- }
- if (chain != NOT_CAUGHT) {
- exitTo(state, catching_state, is_handler);
- int next = executeTransitionChain(chain, ifitem, generic_data);
- next = enterHistory(next, is_handler, skip_entry);
- setState(next);
- }
- }
+ // history
+ protected int history[] = {NO_STATE,NO_STATE,NO_STATE,NO_STATE};
private void setState(int new_state) {
DebuggingService.getInstance().addActorState(this,stateStrings[new_state]);
if (stateStrings[new_state]!="Idle") {
- // TODOTS: model switch for activation
System.out.println(getInstancePath() + " -> " + stateStrings[new_state]);
}
this.state = new_state;
}
- @Override
- public void executeInitTransition() {
- int chain = CHAIN_TRANS_INITIAL_TO__waitForTimer;
- int next = executeTransitionChain(chain, null, null);
- next = enterHistory(next, false, false);
- setState(next);
+ //*** Entry and Exit Codes
+
+ //*** Action Codes
+ protected void action_TRANS_INITIAL_TO__waitForTimer() {
+ count = 0;
+ timer.Start(1000);
+ }
+ protected void action_TRANS_waitForTimer_TO_waitForPong_BY_timeoutTicktimer(InterfaceItemBase ifitem) {
+ PingPongPort.get(0).ping();
+ PingPongPort.get(1).ping();
+ PingPongPort.get(2).ping();
+ pongCount = 0;
+ }
+ protected void action_TRANS_waitForPong_TO_cp0_BY_pongPingPongPort(InterfaceItemBase ifitem) {
+ pongCount++;
+ }
+ protected void action_TRANS_cp0_TO_waitForTimer(InterfaceItemBase ifitem) {
+ if (count++ > 1000) {
+ RTServices.getInstance().getSubSystem().testFinished(0);
+ } else {
+ //PingPongPort.get(0).ping();
+ //PingPongPort.get(1).ping();
+ //PingPongPort.get(2).ping();
+ System.out.println(pongCount);
+ System.out.println(count);
+ pongCount = 0;
+ timer.Start(10);
+ }
}
/**
@@ -167,16 +141,17 @@ public class MrPingActor extends ActorClassBase {
while (current!=to) {
switch (current) {
case STATE_waitForTimer:
- history[STATE_TOP] = STATE_waitForTimer;
+ this.history[STATE_TOP] = STATE_waitForTimer;
current = STATE_TOP;
break;
case STATE_waitForPong:
- history[STATE_TOP] = STATE_waitForPong;
+ this.history[STATE_TOP] = STATE_waitForPong;
current = STATE_TOP;
break;
}
}
}
+
/**
* calls action, entry and exit codes along a transition chain. The generic data are cast to typed data
* matching the trigger of this chain. The ID of the final state is returned
@@ -209,6 +184,7 @@ public class MrPingActor extends ActorClassBase {
}
return NO_STATE;
}
+
/**
* calls entry codes while entering a state's history. The ID of the final leaf state is returned
* @param state - the state which is entered
@@ -225,7 +201,7 @@ public class MrPingActor extends ActorClassBase {
// in leaf state: return state id
return STATE_waitForPong;
case STATE_TOP:
- state = history[STATE_TOP];
+ state = this.history[STATE_TOP];
break;
}
skip_entry = false;
@@ -233,33 +209,50 @@ public class MrPingActor extends ActorClassBase {
//return NO_STATE; // required by CDT but detected as unreachable by JDT because of while (true)
}
- //*** Entry and Exit Codes
-
- //*** Action Codes
- protected void action_TRANS_INITIAL_TO__waitForTimer() {
- count = 0;
- timer.Start(1000);
- }
- protected void action_TRANS_waitForTimer_TO_waitForPong_BY_timeoutTicktimer(InterfaceItemBase ifitem) {
- PingPongPort.get(0).ping();
- PingPongPort.get(1).ping();
- PingPongPort.get(2).ping();
- pongCount = 0;
- }
- protected void action_TRANS_waitForPong_TO_cp0_BY_pongPingPongPort(InterfaceItemBase ifitem) {
- pongCount++;
+ public void executeInitTransition() {
+ int chain = CHAIN_TRANS_INITIAL_TO__waitForTimer;
+ int next = executeTransitionChain(chain, null, null);
+ next = enterHistory(next, false, false);
+ setState(next);
}
- protected void action_TRANS_cp0_TO_waitForTimer(InterfaceItemBase ifitem) {
- if (count++ > 1000) {
- RTServices.getInstance().getSubSystem().testFinished(0);
- } else {
- //PingPongPort.get(0).ping();
- //PingPongPort.get(1).ping();
- //PingPongPort.get(2).ping();
- System.out.println(pongCount);
- System.out.println(count);
- pongCount = 0;
- timer.Start(10);
+
+ /* receiveEvent contains the main implementation of the FSM */
+ public void receiveEvent(InterfaceItemBase ifitem, int evt, Object generic_data) {
+ int trigger = ifitem.getLocalId() + EVT_SHIFT*evt;
+ int chain = NOT_CAUGHT;
+ int catching_state = NO_STATE;
+ boolean is_handler = false;
+ boolean skip_entry = false;
+
+ if (!handleSystemEvent(ifitem, evt, generic_data)) {
+ switch (this.state) {
+ case STATE_waitForTimer:
+ switch(trigger) {
+ case TRIG_timer__timeoutTick:
+ {
+ chain = CHAIN_TRANS_waitForTimer_TO_waitForPong_BY_timeoutTicktimer;
+ catching_state = STATE_TOP;
+ }
+ break;
+ }
+ break;
+ case STATE_waitForPong:
+ switch(trigger) {
+ case TRIG_PingPongPort__pong:
+ {
+ chain = CHAIN_TRANS_waitForPong_TO_cp0_BY_pongPingPongPort;
+ catching_state = STATE_TOP;
+ }
+ break;
+ }
+ break;
+ }
+ }
+ if (chain != NOT_CAUGHT) {
+ exitTo(this.state, catching_state, is_handler);
+ int next = executeTransitionChain(chain, ifitem, generic_data);
+ next = enterHistory(next, is_handler, skip_entry);
+ setState(next);
}
}
diff --git a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/PingPongThreadTestReplPort/MrPongActor1.java b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/PingPongThreadTestReplPort/MrPongActor1.java
index 873548bb4..f89cd5ec0 100644
--- a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/PingPongThreadTestReplPort/MrPongActor1.java
+++ b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/PingPongThreadTestReplPort/MrPongActor1.java
@@ -22,8 +22,8 @@ public class MrPongActor1 extends ActorClassBase {
//--------------------- services
//--------------------- interface item IDs
- protected static final int IFITEM_PingPongPort = 1;
-
+ public static final int IFITEM_PingPongPort = 1;
+
//--------------------- attributes
//--------------------- operations
@@ -58,76 +58,37 @@ public class MrPongActor1 extends ActorClassBase {
destroyUser();
}
- //******************************************
- // START of generated code for FSM
- //******************************************
- // State IDs for FSM
- protected static final int STATE_waitForPing = 2;
- protected static final String stateStrings[] = {"<no state>","<top>","waitForPing"
- };
+ /* state IDs */
+ public static final int STATE_waitForPing = 2;
- // history
- // TODOHRR: history defined in ActorClassBase, init in constructor
- // history = new int[5];
- // for (int i = 0; i < history.length; i++) {
- // history[i] = NO_STATE;
- // }
- protected int history[] = {NO_STATE,NO_STATE,NO_STATE};
+ /* transition chains */
+ public static final int CHAIN_TRANS_INITIAL_TO__waitForPing = 1;
+ public static final int CHAIN_TRANS_waitForPing_TO_waitForPing_BY_pingPingPongPort_myTrigger = 2;
- // transition chains
- protected static final int CHAIN_TRANS_INITIAL_TO__waitForPing = 1;
- protected static final int CHAIN_TRANS_waitForPing_TO_waitForPing_BY_pingPingPongPort_myTrigger = 2;
+ /* triggers */
+ public static final int TRIG_PingPongPort__ping = IFITEM_PingPongPort + EVT_SHIFT*PingPongProtocol.IN_ping;
- // triggers for FSM
- protected static final int TRIG_PingPongPort__ping = IFITEM_PingPongPort + EVT_SHIFT*PingPongProtocol.IN_ping;
+ // state names
+ protected static final String stateStrings[] = {"<no state>","<top>","waitForPing"
+ };
- // receiveEvent contains the main implementation of the FSM
- @Override
- public void receiveEvent(InterfaceItemBase ifitem, int evt, Object generic_data) {
- int trigger = ifitem.getLocalId() + EVT_SHIFT*evt;
- int chain = NOT_CAUGHT;
- int catching_state = NO_STATE;
- boolean is_handler = false;
- boolean skip_entry = false;
-
- if (!handleSystemEvent(ifitem, evt, generic_data)) {
- switch (state) {
- case STATE_waitForPing:
- switch(trigger) {
- case TRIG_PingPongPort__ping:
- {
- chain = CHAIN_TRANS_waitForPing_TO_waitForPing_BY_pingPingPongPort_myTrigger;
- catching_state = STATE_TOP;
- }
- break;
- }
- break;
- }
- }
- if (chain != NOT_CAUGHT) {
- exitTo(state, catching_state, is_handler);
- int next = executeTransitionChain(chain, ifitem, generic_data);
- next = enterHistory(next, is_handler, skip_entry);
- setState(next);
- }
- }
+ // history
+ protected int history[] = {NO_STATE,NO_STATE,NO_STATE};
private void setState(int new_state) {
DebuggingService.getInstance().addActorState(this,stateStrings[new_state]);
if (stateStrings[new_state]!="Idle") {
- // TODOTS: model switch for activation
System.out.println(getInstancePath() + " -> " + stateStrings[new_state]);
}
this.state = new_state;
}
- @Override
- public void executeInitTransition() {
- int chain = CHAIN_TRANS_INITIAL_TO__waitForPing;
- int next = executeTransitionChain(chain, null, null);
- next = enterHistory(next, false, false);
- setState(next);
+ //*** Entry and Exit Codes
+
+ //*** Action Codes
+ protected void action_TRANS_waitForPing_TO_waitForPing_BY_pingPingPongPort_myTrigger(InterfaceItemBase ifitem) {
+ PingPongPort.pong();
}
/**
@@ -141,12 +102,13 @@ public class MrPongActor1 extends ActorClassBase {
while (current!=to) {
switch (current) {
case STATE_waitForPing:
- history[STATE_TOP] = STATE_waitForPing;
+ this.history[STATE_TOP] = STATE_waitForPing;
current = STATE_TOP;
break;
}
}
}
+
/**
* calls action, entry and exit codes along a transition chain. The generic data are cast to typed data
* matching the trigger of this chain. The ID of the final state is returned
@@ -168,6 +130,7 @@ public class MrPongActor1 extends ActorClassBase {
}
return NO_STATE;
}
+
/**
* calls entry codes while entering a state's history. The ID of the final leaf state is returned
* @param state - the state which is entered
@@ -181,7 +144,7 @@ public class MrPongActor1 extends ActorClassBase {
// in leaf state: return state id
return STATE_waitForPing;
case STATE_TOP:
- state = history[STATE_TOP];
+ state = this.history[STATE_TOP];
break;
}
skip_entry = false;
@@ -189,11 +152,41 @@ public class MrPongActor1 extends ActorClassBase {
//return NO_STATE; // required by CDT but detected as unreachable by JDT because of while (true)
}
- //*** Entry and Exit Codes
+ public void executeInitTransition() {
+ int chain = CHAIN_TRANS_INITIAL_TO__waitForPing;
+ int next = executeTransitionChain(chain, null, null);
+ next = enterHistory(next, false, false);
+ setState(next);
+ }
- //*** Action Codes
- protected void action_TRANS_waitForPing_TO_waitForPing_BY_pingPingPongPort_myTrigger(InterfaceItemBase ifitem) {
- PingPongPort.pong();
+ /* receiveEvent contains the main implementation of the FSM */
+ public void receiveEvent(InterfaceItemBase ifitem, int evt, Object generic_data) {
+ int trigger = ifitem.getLocalId() + EVT_SHIFT*evt;
+ int chain = NOT_CAUGHT;
+ int catching_state = NO_STATE;
+ boolean is_handler = false;
+ boolean skip_entry = false;
+
+ if (!handleSystemEvent(ifitem, evt, generic_data)) {
+ switch (this.state) {
+ case STATE_waitForPing:
+ switch(trigger) {
+ case TRIG_PingPongPort__ping:
+ {
+ chain = CHAIN_TRANS_waitForPing_TO_waitForPing_BY_pingPingPongPort_myTrigger;
+ catching_state = STATE_TOP;
+ }
+ break;
+ }
+ break;
+ }
+ }
+ if (chain != NOT_CAUGHT) {
+ exitTo(this.state, catching_state, is_handler);
+ int next = executeTransitionChain(chain, ifitem, generic_data);
+ next = enterHistory(next, is_handler, skip_entry);
+ setState(next);
+ }
}
//******************************************
diff --git a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/PingPongThreadTestReplPort/PingPongProtocol.java b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/PingPongThreadTestReplPort/PingPongProtocol.java
index 373a12637..1e8b223b2 100644
--- a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/PingPongThreadTestReplPort/PingPongProtocol.java
+++ b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/PingPongThreadTestReplPort/PingPongProtocol.java
@@ -11,15 +11,10 @@ import org.eclipse.etrice.runtime.java.debugging.DebuggingService;
public class PingPongProtocol {
// message IDs
- // TODO: separate class for message IDs: class MSG{public static volatile int MSG_MIN = 0; ...} -> better structure
- // error if msgID <= MSG_MIN
- public static final int MSG_MIN = 0;
- //IDs for outgoing messages
+ public static final int MSG_MIN = 0;
public static final int OUT_pong = 1;
- //IDs for incoming messages
public static final int IN_ping = 2;
- //error if msgID >= MSG_MAX
- public static final int MSG_MAX = 3;
+ public static final int MSG_MAX = 3;
private static String messageStrings[] = {"MIN", "pong", "ping","MAX"};
diff --git a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/PingPongThreadTestReplPort/PingPongTop.java b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/PingPongThreadTestReplPort/PingPongTop.java
index 9dc2141f2..23368aad6 100644
--- a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/PingPongThreadTestReplPort/PingPongTop.java
+++ b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/PingPongThreadTestReplPort/PingPongTop.java
@@ -20,7 +20,7 @@ public class PingPongTop extends ActorClassBase {
//--------------------- services
//--------------------- interface item IDs
-
+
//--------------------- attributes
//--------------------- operations
diff --git a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/SendingDataByValueTest/MrPing.java b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/SendingDataByValueTest/MrPing.java
index 5cefa4b1f..8b1c3ad3f 100644
--- a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/SendingDataByValueTest/MrPing.java
+++ b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/SendingDataByValueTest/MrPing.java
@@ -29,8 +29,8 @@ public class MrPing extends ActorClassBase {
//--------------------- services
//--------------------- interface item IDs
- protected static final int IFITEM_PingPongPort = 1;
-
+ public static final int IFITEM_PingPongPort = 1;
+
//--------------------- attributes
protected int[] i32Array;
protected PingPongData data;
@@ -84,195 +84,161 @@ public class MrPing extends ActorClassBase {
destroyUser();
}
- //******************************************
- // START of generated code for FSM
- //******************************************
- // State IDs for FSM
- protected static final int STATE_waitForPong = 2;
- protected static final int STATE_state0 = 3;
- protected static final int STATE_state1 = 4;
- protected static final int STATE_state2 = 5;
- protected static final int STATE_TestFalse = 6;
- protected static final int STATE_TestOk = 7;
- protected static final String stateStrings[] = {"<no state>","<top>","waitForPong",
- "state0",
- "state1",
- "state2",
- "TestFalse",
- "TestOk"
- };
+ /* state IDs */
+ public static final int STATE_waitForPong = 2;
+ public static final int STATE_state0 = 3;
+ public static final int STATE_state1 = 4;
+ public static final int STATE_state2 = 5;
+ public static final int STATE_TestFalse = 6;
+ public static final int STATE_TestOk = 7;
- // history
- // TODOHRR: history defined in ActorClassBase, init in constructor
- // history = new int[5];
- // for (int i = 0; i < history.length; i++) {
- // history[i] = NO_STATE;
- // }
- protected int history[] = {NO_STATE,NO_STATE,NO_STATE,NO_STATE,NO_STATE,NO_STATE,NO_STATE,NO_STATE};
+ /* transition chains */
+ public static final int CHAIN_TRANS_INITIAL_TO__waitForPong = 1;
+ public static final int CHAIN_TRANS_state0_TO_state1_BY_pongPingPongPort = 2;
+ public static final int CHAIN_TRANS_state1_TO_state2_BY_pongSimplePingPongPort = 3;
+ public static final int CHAIN_TRANS_state2_TO_cp1_BY_pongSimplePingPongPort = 4;
+ public static final int CHAIN_TRANS_tp0_TO_tp0_BY_pongPingPongPort_tr0 = 5;
+ public static final int CHAIN_TRANS_tp0_TO_tp0_BY_pongSimplePingPongPort_tr1 = 6;
+ public static final int CHAIN_TRANS_waitForPong_TO_cp0_BY_pongPingPongPort = 7;
- // transition chains
- protected static final int CHAIN_TRANS_INITIAL_TO__waitForPong = 1;
- protected static final int CHAIN_TRANS_state0_TO_state1_BY_pongPingPongPort = 2;
- protected static final int CHAIN_TRANS_state1_TO_state2_BY_pongSimplePingPongPort = 3;
- protected static final int CHAIN_TRANS_state2_TO_cp1_BY_pongSimplePingPongPort = 4;
- protected static final int CHAIN_TRANS_tp0_TO_tp0_BY_pongPingPongPort_tr0 = 5;
- protected static final int CHAIN_TRANS_tp0_TO_tp0_BY_pongSimplePingPongPort_tr1 = 6;
- protected static final int CHAIN_TRANS_waitForPong_TO_cp0_BY_pongPingPongPort = 7;
+ /* triggers */
+ public static final int TRIG_PingPongPort__pong = IFITEM_PingPongPort + EVT_SHIFT*PingPongProtocol.OUT_pong;
+ public static final int TRIG_PingPongPort__pongSimple = IFITEM_PingPongPort + EVT_SHIFT*PingPongProtocol.OUT_pongSimple;
- // triggers for FSM
- protected static final int TRIG_PingPongPort__pong = IFITEM_PingPongPort + EVT_SHIFT*PingPongProtocol.OUT_pong;
- protected static final int TRIG_PingPongPort__pongSimple = IFITEM_PingPongPort + EVT_SHIFT*PingPongProtocol.OUT_pongSimple;
+ // state names
+ protected static final String stateStrings[] = {"<no state>","<top>","waitForPong",
+ "state0",
+ "state1",
+ "state2",
+ "TestFalse",
+ "TestOk"
+ };
- // receiveEvent contains the main implementation of the FSM
- @Override
- public void receiveEvent(InterfaceItemBase ifitem, int evt, Object generic_data) {
- int trigger = ifitem.getLocalId() + EVT_SHIFT*evt;
- int chain = NOT_CAUGHT;
- int catching_state = NO_STATE;
- boolean is_handler = false;
- boolean skip_entry = false;
-
- if (!handleSystemEvent(ifitem, evt, generic_data)) {
- switch (state) {
- case STATE_waitForPong:
- switch(trigger) {
- case TRIG_PingPongPort__pong:
- {
- chain = CHAIN_TRANS_waitForPong_TO_cp0_BY_pongPingPongPort;
- catching_state = STATE_TOP;
- }
- break;
- case TRIG_PingPongPort__pongSimple:
- {
- chain = CHAIN_TRANS_tp0_TO_tp0_BY_pongSimplePingPongPort_tr1;
- catching_state = STATE_TOP;
- skip_entry = true;
- }
- break;
- }
- break;
- case STATE_state0:
- switch(trigger) {
- case TRIG_PingPongPort__pong:
- { PingPongData p = (PingPongData) generic_data;
- if (p.getI32Val()==3
- )
- {
- chain = CHAIN_TRANS_state0_TO_state1_BY_pongPingPongPort;
- catching_state = STATE_TOP;
- } else
- {
- chain = CHAIN_TRANS_tp0_TO_tp0_BY_pongPingPongPort_tr0;
- catching_state = STATE_TOP;
- skip_entry = true;
- }
- }
- break;
- case TRIG_PingPongPort__pongSimple:
- {
- chain = CHAIN_TRANS_tp0_TO_tp0_BY_pongSimplePingPongPort_tr1;
- catching_state = STATE_TOP;
- skip_entry = true;
- }
- break;
- }
- break;
- case STATE_state1:
- switch(trigger) {
- case TRIG_PingPongPort__pongSimple:
- {
- chain = CHAIN_TRANS_state1_TO_state2_BY_pongSimplePingPongPort;
- catching_state = STATE_TOP;
- }
- break;
- case TRIG_PingPongPort__pong:
- {
- chain = CHAIN_TRANS_tp0_TO_tp0_BY_pongPingPongPort_tr0;
- catching_state = STATE_TOP;
- skip_entry = true;
- }
- break;
- }
- break;
- case STATE_state2:
- switch(trigger) {
- case TRIG_PingPongPort__pongSimple:
- {
- chain = CHAIN_TRANS_state2_TO_cp1_BY_pongSimplePingPongPort;
- catching_state = STATE_TOP;
- }
- break;
- case TRIG_PingPongPort__pong:
- {
- chain = CHAIN_TRANS_tp0_TO_tp0_BY_pongPingPongPort_tr0;
- catching_state = STATE_TOP;
- skip_entry = true;
- }
- break;
- }
- break;
- case STATE_TestFalse:
- switch(trigger) {
- case TRIG_PingPongPort__pong:
- {
- chain = CHAIN_TRANS_tp0_TO_tp0_BY_pongPingPongPort_tr0;
- catching_state = STATE_TOP;
- skip_entry = true;
- }
- break;
- case TRIG_PingPongPort__pongSimple:
- {
- chain = CHAIN_TRANS_tp0_TO_tp0_BY_pongSimplePingPongPort_tr1;
- catching_state = STATE_TOP;
- skip_entry = true;
- }
- break;
- }
- break;
- case STATE_TestOk:
- switch(trigger) {
- case TRIG_PingPongPort__pong:
- {
- chain = CHAIN_TRANS_tp0_TO_tp0_BY_pongPingPongPort_tr0;
- catching_state = STATE_TOP;
- skip_entry = true;
- }
- break;
- case TRIG_PingPongPort__pongSimple:
- {
- chain = CHAIN_TRANS_tp0_TO_tp0_BY_pongSimplePingPongPort_tr1;
- catching_state = STATE_TOP;
- skip_entry = true;
- }
- break;
- }
- break;
- }
- }
- if (chain != NOT_CAUGHT) {
- exitTo(state, catching_state, is_handler);
- int next = executeTransitionChain(chain, ifitem, generic_data);
- next = enterHistory(next, is_handler, skip_entry);
- setState(next);
- }
- }
+ // history
+ protected int history[] = {NO_STATE,NO_STATE,NO_STATE,NO_STATE,NO_STATE,NO_STATE,NO_STATE,NO_STATE};
private void setState(int new_state) {
DebuggingService.getInstance().addActorState(this,stateStrings[new_state]);
if (stateStrings[new_state]!="Idle") {
- // TODOTS: model switch for activation
System.out.println(getInstancePath() + " -> " + stateStrings[new_state]);
}
this.state = new_state;
}
- @Override
- public void executeInitTransition() {
- int chain = CHAIN_TRANS_INITIAL_TO__waitForPong;
- int next = executeTransitionChain(chain, null, null);
- next = enterHistory(next, false, false);
- setState(next);
+ //*** Entry and Exit Codes
+
+ //*** Action Codes
+ protected void action_TRANS_INITIAL_TO__waitForPong() {
+ int i;
+ int[] intArray;
+ this.data=new PingPongData();
+
+ // send default data
+ PingPongData d = new PingPongData();
+ PingPongPort.ping(d);
+
+ d.setI8Val((byte) 45);
+ d.setI16Val((short) 34);
+ d.setI32Val(2);
+ d.setF32Val((float)3.14);
+ d.setF64Val(7.12345);
+ d.setStringVal("Hase !");
+
+ d.getOwnType().setI8Val((byte)10);
+ d.getOwnType().setI16Val((short)17);
+ d.getOwnType().setI32Val(4711);
+ d.getOwnType().setF32Val((float)3.0815);
+ d.getOwnType().setF64Val(123.45678);
+ d.getOwnType().setStringVal("Deep Hase !");
+ intArray = d.getOwnType().getArrayFromInt32();
+ for (i=0;i<intArray.length;i++) {intArray[i] = 10+i;}
+ d.getOwnType().setArrayFromInt32(intArray);
+
+ PingPongPort.ping(d);
+
+ d.setI8Val((byte) 55);
+ d.setI16Val((short) 44);
+ d.setI32Val(3);
+ d.setF32Val((float)24.4563458);
+ d.setF64Val(2347.2342312345);
+ d.setStringVal("Mein Hase !");
+
+ d.getOwnType().setI8Val((byte)15);
+ d.getOwnType().setI16Val((short)23);
+ d.getOwnType().setI32Val(4812);
+ d.getOwnType().setF32Val((float)2453.30815);
+ d.getOwnType().setF64Val(125332.42342);
+ d.getOwnType().setStringVal("Mein Deep Hase !");
+ intArray = d.getOwnType().getArrayFromInt32();
+ for (i=0;i<intArray.length;i++) {intArray[i] = 30+i;}
+ d.getOwnType().setArrayFromInt32(intArray);
+
+ PingPongPort.ping(d);
+ PingPongPort.ping(data);
+
+ data.setI8Val((byte) 67);
+ data.setI16Val((short) 97);
+ data.setI32Val(70);
+ data.setF32Val((float)233.14);
+ data.setF64Val(723434.12345);
+ data.setStringVal("Falscher Hase !");
+
+ crcGen.update(10);
+ }
+ protected void action_TRANS_tp0_TO_tp0_BY_pongPingPongPort_tr0(InterfaceItemBase ifitem, PingPongData p) {
+ System.out.printf("Top Level : \n");
+ printData(p);
+ crcGen.update(20);
+ }
+ protected void action_TRANS_tp0_TO_tp0_BY_pongSimplePingPongPort_tr1(InterfaceItemBase ifitem, int p) {
+ System.out.printf("Top Level Simple: \n");
+ crcGen.update(35);
+ }
+ protected void action_TRANS_waitForPong_TO_cp0_BY_pongPingPongPort(InterfaceItemBase ifitem, PingPongData p) {
+ printData(p);
+ crcGen.update(11);
+ }
+ protected void action_TRANS_cp0_TO_waitForPong(InterfaceItemBase ifitem, PingPongData p) {
+ crcGen.update(12);
+ }
+ protected void action_TRANS_cp0_TO_state0_COND_tr3(InterfaceItemBase ifitem, PingPongData p) {
+ // send default values
+ PingPongPort.ping(data);
+
+ data.getOwnType().setI8Val((byte)10);
+ data.getOwnType().setI16Val((short)17);
+ data.getOwnType().setI32Val(4711);
+ data.getOwnType().setF32Val((float)3.0815);
+ data.getOwnType().setF64Val(123.45678);
+ data.getOwnType().setStringVal("Deep Hase !");
+ int[] intArray = data.getOwnType().getArrayFromInt32();
+ for (int i=0;i<intArray.length;i++) {intArray[i] = 10+i;}
+ data.getOwnType().setArrayFromInt32(intArray);
+
+ // use convenient function
+ PingPongPort.ping((byte)45,(short)34,80,'c',(float)3.14,7.12345,"Hase !",intArray,data.getOwnType());
+
+ crcGen.update(13);
+ }
+ protected void action_TRANS_state0_TO_state1_BY_pongPingPongPort(InterfaceItemBase ifitem, PingPongData p) {
+ printData(p);
+ PingPongPort.pingSimple(12);
+ PingPongPort.pingSimple(27);
+ crcGen.update(14);
+ }
+ protected void action_TRANS_state1_TO_state2_BY_pongSimplePingPongPort(InterfaceItemBase ifitem, int p) {
+ crcGen.update(15);
+ }
+ protected void action_TRANS_state2_TO_cp1_BY_pongSimplePingPongPort(InterfaceItemBase ifitem, int p) {
+ crcGen.update(16);
+ System.out.printf("CRC: %d \n", crcGen.getCrc());
+ }
+ protected void action_TRANS_cp1_TO_TestFalse(InterfaceItemBase ifitem, int p) {
+ RTServices.getInstance().getSubSystem().testFinished(1);
+ }
+ protected void action_TRANS_cp1_TO_TestOk_COND_tr9(InterfaceItemBase ifitem, int p) {
+ RTServices.getInstance().getSubSystem().testFinished(0);
}
/**
@@ -286,32 +252,33 @@ public class MrPing extends ActorClassBase {
while (current!=to) {
switch (current) {
case STATE_waitForPong:
- history[STATE_TOP] = STATE_waitForPong;
+ this.history[STATE_TOP] = STATE_waitForPong;
current = STATE_TOP;
break;
case STATE_state0:
- history[STATE_TOP] = STATE_state0;
+ this.history[STATE_TOP] = STATE_state0;
current = STATE_TOP;
break;
case STATE_state1:
- history[STATE_TOP] = STATE_state1;
+ this.history[STATE_TOP] = STATE_state1;
current = STATE_TOP;
break;
case STATE_state2:
- history[STATE_TOP] = STATE_state2;
+ this.history[STATE_TOP] = STATE_state2;
current = STATE_TOP;
break;
case STATE_TestFalse:
- history[STATE_TOP] = STATE_TestFalse;
+ this.history[STATE_TOP] = STATE_TestFalse;
current = STATE_TOP;
break;
case STATE_TestOk:
- history[STATE_TOP] = STATE_TestOk;
+ this.history[STATE_TOP] = STATE_TestOk;
current = STATE_TOP;
break;
}
}
}
+
/**
* calls action, entry and exit codes along a transition chain. The generic data are cast to typed data
* matching the trigger of this chain. The ID of the final state is returned
@@ -377,6 +344,7 @@ public class MrPing extends ActorClassBase {
}
return NO_STATE;
}
+
/**
* calls entry codes while entering a state's history. The ID of the final leaf state is returned
* @param state - the state which is entered
@@ -405,7 +373,7 @@ public class MrPing extends ActorClassBase {
// in leaf state: return state id
return STATE_TestOk;
case STATE_TOP:
- state = history[STATE_TOP];
+ state = this.history[STATE_TOP];
break;
}
skip_entry = false;
@@ -413,124 +381,144 @@ public class MrPing extends ActorClassBase {
//return NO_STATE; // required by CDT but detected as unreachable by JDT because of while (true)
}
- //*** Entry and Exit Codes
-
- //*** Action Codes
- protected void action_TRANS_INITIAL_TO__waitForPong() {
- int i;
- int[] intArray;
- this.data=new PingPongData();
-
- // send default data
- PingPongData d = new PingPongData();
- PingPongPort.ping(d);
-
- d.setI8Val((byte) 45);
- d.setI16Val((short) 34);
- d.setI32Val(2);
- d.setF32Val((float)3.14);
- d.setF64Val(7.12345);
- d.setStringVal("Hase !");
-
- d.getOwnType().setI8Val((byte)10);
- d.getOwnType().setI16Val((short)17);
- d.getOwnType().setI32Val(4711);
- d.getOwnType().setF32Val((float)3.0815);
- d.getOwnType().setF64Val(123.45678);
- d.getOwnType().setStringVal("Deep Hase !");
- intArray = d.getOwnType().getArrayFromInt32();
- for (i=0;i<intArray.length;i++) {intArray[i] = 10+i;}
- d.getOwnType().setArrayFromInt32(intArray);
-
- PingPongPort.ping(d);
-
- d.setI8Val((byte) 55);
- d.setI16Val((short) 44);
- d.setI32Val(3);
- d.setF32Val((float)24.4563458);
- d.setF64Val(2347.2342312345);
- d.setStringVal("Mein Hase !");
-
- d.getOwnType().setI8Val((byte)15);
- d.getOwnType().setI16Val((short)23);
- d.getOwnType().setI32Val(4812);
- d.getOwnType().setF32Val((float)2453.30815);
- d.getOwnType().setF64Val(125332.42342);
- d.getOwnType().setStringVal("Mein Deep Hase !");
- intArray = d.getOwnType().getArrayFromInt32();
- for (i=0;i<intArray.length;i++) {intArray[i] = 30+i;}
- d.getOwnType().setArrayFromInt32(intArray);
-
- PingPongPort.ping(d);
- PingPongPort.ping(data);
-
- data.setI8Val((byte) 67);
- data.setI16Val((short) 97);
- data.setI32Val(70);
- data.setF32Val((float)233.14);
- data.setF64Val(723434.12345);
- data.setStringVal("Falscher Hase !");
-
- crcGen.update(10);
- }
- protected void action_TRANS_tp0_TO_tp0_BY_pongPingPongPort_tr0(InterfaceItemBase ifitem, PingPongData p) {
- System.out.printf("Top Level : \n");
- printData(p);
- crcGen.update(20);
- }
- protected void action_TRANS_tp0_TO_tp0_BY_pongSimplePingPongPort_tr1(InterfaceItemBase ifitem, int p) {
- System.out.printf("Top Level Simple: \n");
- crcGen.update(35);
- }
- protected void action_TRANS_waitForPong_TO_cp0_BY_pongPingPongPort(InterfaceItemBase ifitem, PingPongData p) {
- printData(p);
- crcGen.update(11);
- }
- protected void action_TRANS_cp0_TO_waitForPong(InterfaceItemBase ifitem, PingPongData p) {
- crcGen.update(12);
+ public void executeInitTransition() {
+ int chain = CHAIN_TRANS_INITIAL_TO__waitForPong;
+ int next = executeTransitionChain(chain, null, null);
+ next = enterHistory(next, false, false);
+ setState(next);
}
- protected void action_TRANS_cp0_TO_state0_COND_tr3(InterfaceItemBase ifitem, PingPongData p) {
- // send default values
- PingPongPort.ping(data);
-
- data.setI8Val((byte) 45);
- data.setI16Val((short) 34);
- data.setI32Val(80);
- data.setF32Val((float)3.14);
- data.setF64Val(7.12345);
- data.setStringVal("Hase !");
-
- data.getOwnType().setI8Val((byte)10);
- data.getOwnType().setI16Val((short)17);
- data.getOwnType().setI32Val(4711);
- data.getOwnType().setF32Val((float)3.0815);
- data.getOwnType().setF64Val(123.45678);
- data.getOwnType().setStringVal("Deep Hase !");
- int[] intArray = data.getOwnType().getArrayFromInt32();
- for (int i=0;i<intArray.length;i++) {intArray[i] = 10+i;}
- data.getOwnType().setArrayFromInt32(intArray);
+
+ /* receiveEvent contains the main implementation of the FSM */
+ public void receiveEvent(InterfaceItemBase ifitem, int evt, Object generic_data) {
+ int trigger = ifitem.getLocalId() + EVT_SHIFT*evt;
+ int chain = NOT_CAUGHT;
+ int catching_state = NO_STATE;
+ boolean is_handler = false;
+ boolean skip_entry = false;
- PingPongPort.ping(data);
- crcGen.update(13);
- }
- protected void action_TRANS_state0_TO_state1_BY_pongPingPongPort(InterfaceItemBase ifitem, PingPongData p) {
- printData(p);
- PingPongPort.pingSimple(12);
- PingPongPort.pingSimple(27);
- crcGen.update(14);
- }
- protected void action_TRANS_state1_TO_state2_BY_pongSimplePingPongPort(InterfaceItemBase ifitem, int p) {
- crcGen.update(15);
- }
- protected void action_TRANS_state2_TO_cp1_BY_pongSimplePingPongPort(InterfaceItemBase ifitem, int p) {
- crcGen.update(16);
- System.out.printf("CRC: %d \n", crcGen.getCrc());
- }
- protected void action_TRANS_cp1_TO_TestFalse(InterfaceItemBase ifitem, int p) {
- RTServices.getInstance().getSubSystem().testFinished(1);
- }
- protected void action_TRANS_cp1_TO_TestOk_COND_tr9(InterfaceItemBase ifitem, int p) {
- RTServices.getInstance().getSubSystem().testFinished(0);
+ if (!handleSystemEvent(ifitem, evt, generic_data)) {
+ switch (this.state) {
+ case STATE_waitForPong:
+ switch(trigger) {
+ case TRIG_PingPongPort__pong:
+ {
+ chain = CHAIN_TRANS_waitForPong_TO_cp0_BY_pongPingPongPort;
+ catching_state = STATE_TOP;
+ }
+ break;
+ case TRIG_PingPongPort__pongSimple:
+ {
+ chain = CHAIN_TRANS_tp0_TO_tp0_BY_pongSimplePingPongPort_tr1;
+ catching_state = STATE_TOP;
+ skip_entry = true;
+ }
+ break;
+ }
+ break;
+ case STATE_state0:
+ switch(trigger) {
+ case TRIG_PingPongPort__pong:
+ { PingPongData p = (PingPongData) generic_data;
+ if (p.getI32Val()==3
+ )
+ {
+ chain = CHAIN_TRANS_state0_TO_state1_BY_pongPingPongPort;
+ catching_state = STATE_TOP;
+ } else
+ {
+ chain = CHAIN_TRANS_tp0_TO_tp0_BY_pongPingPongPort_tr0;
+ catching_state = STATE_TOP;
+ skip_entry = true;
+ }
+ }
+ break;
+ case TRIG_PingPongPort__pongSimple:
+ {
+ chain = CHAIN_TRANS_tp0_TO_tp0_BY_pongSimplePingPongPort_tr1;
+ catching_state = STATE_TOP;
+ skip_entry = true;
+ }
+ break;
+ }
+ break;
+ case STATE_state1:
+ switch(trigger) {
+ case TRIG_PingPongPort__pongSimple:
+ {
+ chain = CHAIN_TRANS_state1_TO_state2_BY_pongSimplePingPongPort;
+ catching_state = STATE_TOP;
+ }
+ break;
+ case TRIG_PingPongPort__pong:
+ {
+ chain = CHAIN_TRANS_tp0_TO_tp0_BY_pongPingPongPort_tr0;
+ catching_state = STATE_TOP;
+ skip_entry = true;
+ }
+ break;
+ }
+ break;
+ case STATE_state2:
+ switch(trigger) {
+ case TRIG_PingPongPort__pongSimple:
+ {
+ chain = CHAIN_TRANS_state2_TO_cp1_BY_pongSimplePingPongPort;
+ catching_state = STATE_TOP;
+ }
+ break;
+ case TRIG_PingPongPort__pong:
+ {
+ chain = CHAIN_TRANS_tp0_TO_tp0_BY_pongPingPongPort_tr0;
+ catching_state = STATE_TOP;
+ skip_entry = true;
+ }
+ break;
+ }
+ break;
+ case STATE_TestFalse:
+ switch(trigger) {
+ case TRIG_PingPongPort__pong:
+ {
+ chain = CHAIN_TRANS_tp0_TO_tp0_BY_pongPingPongPort_tr0;
+ catching_state = STATE_TOP;
+ skip_entry = true;
+ }
+ break;
+ case TRIG_PingPongPort__pongSimple:
+ {
+ chain = CHAIN_TRANS_tp0_TO_tp0_BY_pongSimplePingPongPort_tr1;
+ catching_state = STATE_TOP;
+ skip_entry = true;
+ }
+ break;
+ }
+ break;
+ case STATE_TestOk:
+ switch(trigger) {
+ case TRIG_PingPongPort__pong:
+ {
+ chain = CHAIN_TRANS_tp0_TO_tp0_BY_pongPingPongPort_tr0;
+ catching_state = STATE_TOP;
+ skip_entry = true;
+ }
+ break;
+ case TRIG_PingPongPort__pongSimple:
+ {
+ chain = CHAIN_TRANS_tp0_TO_tp0_BY_pongSimplePingPongPort_tr1;
+ catching_state = STATE_TOP;
+ skip_entry = true;
+ }
+ break;
+ }
+ break;
+ }
+ }
+ if (chain != NOT_CAUGHT) {
+ exitTo(this.state, catching_state, is_handler);
+ int next = executeTransitionChain(chain, ifitem, generic_data);
+ next = enterHistory(next, is_handler, skip_entry);
+ setState(next);
+ }
}
//******************************************
diff --git a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/SendingDataByValueTest/MrPong.java b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/SendingDataByValueTest/MrPong.java
index eb010beb2..b43af07da 100644
--- a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/SendingDataByValueTest/MrPong.java
+++ b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/SendingDataByValueTest/MrPong.java
@@ -22,8 +22,8 @@ public class MrPong extends ActorClassBase {
//--------------------- services
//--------------------- interface item IDs
- protected static final int IFITEM_PingPongPort = 1;
-
+ public static final int IFITEM_PingPongPort = 1;
+
//--------------------- attributes
//--------------------- operations
public void printData(PingPongData d) {
@@ -70,84 +70,45 @@ public class MrPong extends ActorClassBase {
destroyUser();
}
- //******************************************
- // START of generated code for FSM
- //******************************************
- // State IDs for FSM
- protected static final int STATE_reply = 2;
- protected static final String stateStrings[] = {"<no state>","<top>","reply"
- };
+ /* state IDs */
+ public static final int STATE_reply = 2;
- // history
- // TODOHRR: history defined in ActorClassBase, init in constructor
- // history = new int[5];
- // for (int i = 0; i < history.length; i++) {
- // history[i] = NO_STATE;
- // }
- protected int history[] = {NO_STATE,NO_STATE,NO_STATE};
+ /* transition chains */
+ public static final int CHAIN_TRANS_INITIAL_TO__reply = 1;
+ public static final int CHAIN_TRANS_reply_TO_reply_BY_pingPingPongPort_tr0 = 2;
+ public static final int CHAIN_TRANS_reply_TO_reply_BY_pingSimplePingPongPort_tr1 = 3;
- // transition chains
- protected static final int CHAIN_TRANS_INITIAL_TO__reply = 1;
- protected static final int CHAIN_TRANS_reply_TO_reply_BY_pingPingPongPort_tr0 = 2;
- protected static final int CHAIN_TRANS_reply_TO_reply_BY_pingSimplePingPongPort_tr1 = 3;
+ /* triggers */
+ public static final int TRIG_PingPongPort__ping = IFITEM_PingPongPort + EVT_SHIFT*PingPongProtocol.IN_ping;
+ public static final int TRIG_PingPongPort__pingSimple = IFITEM_PingPongPort + EVT_SHIFT*PingPongProtocol.IN_pingSimple;
- // triggers for FSM
- protected static final int TRIG_PingPongPort__ping = IFITEM_PingPongPort + EVT_SHIFT*PingPongProtocol.IN_ping;
- protected static final int TRIG_PingPongPort__pingSimple = IFITEM_PingPongPort + EVT_SHIFT*PingPongProtocol.IN_pingSimple;
+ // state names
+ protected static final String stateStrings[] = {"<no state>","<top>","reply"
+ };
- // receiveEvent contains the main implementation of the FSM
- @Override
- public void receiveEvent(InterfaceItemBase ifitem, int evt, Object generic_data) {
- int trigger = ifitem.getLocalId() + EVT_SHIFT*evt;
- int chain = NOT_CAUGHT;
- int catching_state = NO_STATE;
- boolean is_handler = false;
- boolean skip_entry = false;
-
- if (!handleSystemEvent(ifitem, evt, generic_data)) {
- switch (state) {
- case STATE_reply:
- switch(trigger) {
- case TRIG_PingPongPort__ping:
- {
- chain = CHAIN_TRANS_reply_TO_reply_BY_pingPingPongPort_tr0;
- catching_state = STATE_TOP;
- }
- break;
- case TRIG_PingPongPort__pingSimple:
- {
- chain = CHAIN_TRANS_reply_TO_reply_BY_pingSimplePingPongPort_tr1;
- catching_state = STATE_TOP;
- }
- break;
- }
- break;
- }
- }
- if (chain != NOT_CAUGHT) {
- exitTo(state, catching_state, is_handler);
- int next = executeTransitionChain(chain, ifitem, generic_data);
- next = enterHistory(next, is_handler, skip_entry);
- setState(next);
- }
- }
+ // history
+ protected int history[] = {NO_STATE,NO_STATE,NO_STATE};
private void setState(int new_state) {
DebuggingService.getInstance().addActorState(this,stateStrings[new_state]);
if (stateStrings[new_state]!="Idle") {
- // TODOTS: model switch for activation
System.out.println(getInstancePath() + " -> " + stateStrings[new_state]);
}
this.state = new_state;
}
- @Override
- public void executeInitTransition() {
- int chain = CHAIN_TRANS_INITIAL_TO__reply;
- int next = executeTransitionChain(chain, null, null);
- next = enterHistory(next, false, false);
- setState(next);
+ //*** Entry and Exit Codes
+
+ //*** Action Codes
+ protected void action_TRANS_reply_TO_reply_BY_pingPingPongPort_tr0(InterfaceItemBase ifitem, PingPongData p) {
+ p.setI8Val((byte)(p.getI8Val()+1));
+
+
+ PingPongPort.pong(p);
+ }
+ protected void action_TRANS_reply_TO_reply_BY_pingSimplePingPongPort_tr1(InterfaceItemBase ifitem, int p) {
+ PingPongPort.pongSimple(++p);
}
/**
@@ -161,12 +122,13 @@ public class MrPong extends ActorClassBase {
while (current!=to) {
switch (current) {
case STATE_reply:
- history[STATE_TOP] = STATE_reply;
+ this.history[STATE_TOP] = STATE_reply;
current = STATE_TOP;
break;
}
}
}
+
/**
* calls action, entry and exit codes along a transition chain. The generic data are cast to typed data
* matching the trigger of this chain. The ID of the final state is returned
@@ -195,6 +157,7 @@ public class MrPong extends ActorClassBase {
}
return NO_STATE;
}
+
/**
* calls entry codes while entering a state's history. The ID of the final leaf state is returned
* @param state - the state which is entered
@@ -208,7 +171,7 @@ public class MrPong extends ActorClassBase {
// in leaf state: return state id
return STATE_reply;
case STATE_TOP:
- state = history[STATE_TOP];
+ state = this.history[STATE_TOP];
break;
}
skip_entry = false;
@@ -216,17 +179,47 @@ public class MrPong extends ActorClassBase {
//return NO_STATE; // required by CDT but detected as unreachable by JDT because of while (true)
}
- //*** Entry and Exit Codes
+ public void executeInitTransition() {
+ int chain = CHAIN_TRANS_INITIAL_TO__reply;
+ int next = executeTransitionChain(chain, null, null);
+ next = enterHistory(next, false, false);
+ setState(next);
+ }
- //*** Action Codes
- protected void action_TRANS_reply_TO_reply_BY_pingPingPongPort_tr0(InterfaceItemBase ifitem, PingPongData p) {
- p.setI8Val((byte)(p.getI8Val()+1));
-
+ /* receiveEvent contains the main implementation of the FSM */
+ public void receiveEvent(InterfaceItemBase ifitem, int evt, Object generic_data) {
+ int trigger = ifitem.getLocalId() + EVT_SHIFT*evt;
+ int chain = NOT_CAUGHT;
+ int catching_state = NO_STATE;
+ boolean is_handler = false;
+ boolean skip_entry = false;
- PingPongPort.pong(p);
- }
- protected void action_TRANS_reply_TO_reply_BY_pingSimplePingPongPort_tr1(InterfaceItemBase ifitem, int p) {
- PingPongPort.pongSimple(++p);
+ if (!handleSystemEvent(ifitem, evt, generic_data)) {
+ switch (this.state) {
+ case STATE_reply:
+ switch(trigger) {
+ case TRIG_PingPongPort__ping:
+ {
+ chain = CHAIN_TRANS_reply_TO_reply_BY_pingPingPongPort_tr0;
+ catching_state = STATE_TOP;
+ }
+ break;
+ case TRIG_PingPongPort__pingSimple:
+ {
+ chain = CHAIN_TRANS_reply_TO_reply_BY_pingSimplePingPongPort_tr1;
+ catching_state = STATE_TOP;
+ }
+ break;
+ }
+ break;
+ }
+ }
+ if (chain != NOT_CAUGHT) {
+ exitTo(this.state, catching_state, is_handler);
+ int next = executeTransitionChain(chain, ifitem, generic_data);
+ next = enterHistory(next, is_handler, skip_entry);
+ setState(next);
+ }
}
//******************************************
diff --git a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/SendingDataByValueTest/PingPongProtocol.java b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/SendingDataByValueTest/PingPongProtocol.java
index 8afe13cdf..150e4c74c 100644
--- a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/SendingDataByValueTest/PingPongProtocol.java
+++ b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/SendingDataByValueTest/PingPongProtocol.java
@@ -11,17 +11,12 @@ import org.eclipse.etrice.runtime.java.debugging.DebuggingService;
public class PingPongProtocol {
// message IDs
- // TODO: separate class for message IDs: class MSG{public static volatile int MSG_MIN = 0; ...} -> better structure
- // error if msgID <= MSG_MIN
- public static final int MSG_MIN = 0;
- //IDs for outgoing messages
+ public static final int MSG_MIN = 0;
public static final int OUT_pong = 1;
public static final int OUT_pongSimple = 2;
- //IDs for incoming messages
public static final int IN_ping = 3;
public static final int IN_pingSimple = 4;
- //error if msgID >= MSG_MAX
- public static final int MSG_MAX = 5;
+ public static final int MSG_MAX = 5;
private static String messageStrings[] = {"MIN", "pong","pongSimple", "ping","pingSimple","MAX"};
diff --git a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/SendingDataByValueTest/SendingDataTop.java b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/SendingDataByValueTest/SendingDataTop.java
index e11a120d9..f6b63e592 100644
--- a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/SendingDataByValueTest/SendingDataTop.java
+++ b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/SendingDataByValueTest/SendingDataTop.java
@@ -20,7 +20,7 @@ public class SendingDataTop extends ActorClassBase {
//--------------------- services
//--------------------- interface item IDs
-
+
//--------------------- attributes
//--------------------- operations
diff --git a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/tests/App_SubSystemHFSMTest.java b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/tests/App_SubSystemHFSMTest.java
index b21d3c4d5..1385ab5ff 100644
--- a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/tests/App_SubSystemHFSMTest.java
+++ b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/tests/App_SubSystemHFSMTest.java
@@ -20,7 +20,7 @@ public class App_SubSystemHFSMTest extends ActorClassBase {
//--------------------- services
//--------------------- interface item IDs
-
+
//--------------------- attributes
//--------------------- operations
diff --git a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/tests/a_HFSM.java b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/tests/a_HFSM.java
index 1fd781be3..b6f3a4ca2 100644
--- a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/tests/a_HFSM.java
+++ b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/tests/a_HFSM.java
@@ -22,8 +22,8 @@ public class a_HFSM extends ActorClassBase {
//--------------------- services
//--------------------- interface item IDs
- protected static final int IFITEM_fct = 1;
-
+ public static final int IFITEM_fct = 1;
+
//--------------------- attributes
//--------------------- operations
@@ -58,60 +58,307 @@ public class a_HFSM extends ActorClassBase {
destroyUser();
}
- //******************************************
- // START of generated code for FSM
- //******************************************
- // State IDs for FSM
- protected static final int STATE_State1 = 2;
- protected static final int STATE_State2 = 3;
- protected static final int STATE_State2_State1 = 4;
- protected static final int STATE_State2_State2 = 5;
- protected static final int STATE_State3 = 6;
- protected static final int STATE_State4 = 7;
- protected static final String stateStrings[] = {"<no state>","<top>","State1",
- "State2",
- "State2_State1",
- "State2_State2",
- "State3",
- "State4"
- };
+ /* state IDs */
+ public static final int STATE_State1 = 2;
+ public static final int STATE_State2_State1 = 3;
+ public static final int STATE_State2_State2 = 4;
+ public static final int STATE_State3 = 5;
+ public static final int STATE_State4 = 6;
+ public static final int STATE_State2 = 7;
+
+ /* transition chains */
+ public static final int CHAIN_State2_TRANS_State1_TO_State2_BY_m2fct = 1;
+ public static final int CHAIN_State2_TRANS_State2_TO_tp1_BY_m3fct = 2;
+ public static final int CHAIN_State2_TRANS_tp3_TO_tp3_BY_m5fct_tr3 = 3;
+ public static final int CHAIN_State2_TRANS_tp4_TO_tp4_BY_m6fct_tr4 = 4;
+ public static final int CHAIN_TRANS_INITIAL_TO__State1 = 5;
+ public static final int CHAIN_TRANS_State1_TO_State2_tp0_BY_m1fct = 6;
+ public static final int CHAIN_TRANS_State2_TO_State2_BY_m7fct_tr5 = 7;
+ public static final int CHAIN_TRANS_State2_TO_State4_BY_m4fct = 8;
+ public static final int CHAIN_TRANS_tp0_TO_State1_BY_resetfct = 9;
+ public static final int CHAIN_TRANS_tp1_TO_tp1_BY_m8fct_tr6 = 10;
+ public static final int CHAIN_TRANS_tp2_TO_tp2_BY_m9fct_tr7 = 11;
+
+ /* triggers */
+ public static final int TRIG_fct__m1 = IFITEM_fct + EVT_SHIFT*p_HFSM.IN_m1;
+ public static final int TRIG_fct__m2 = IFITEM_fct + EVT_SHIFT*p_HFSM.IN_m2;
+ public static final int TRIG_fct__m3 = IFITEM_fct + EVT_SHIFT*p_HFSM.IN_m3;
+ public static final int TRIG_fct__m4 = IFITEM_fct + EVT_SHIFT*p_HFSM.IN_m4;
+ public static final int TRIG_fct__m5 = IFITEM_fct + EVT_SHIFT*p_HFSM.IN_m5;
+ public static final int TRIG_fct__m6 = IFITEM_fct + EVT_SHIFT*p_HFSM.IN_m6;
+ public static final int TRIG_fct__m7 = IFITEM_fct + EVT_SHIFT*p_HFSM.IN_m7;
+ public static final int TRIG_fct__m8 = IFITEM_fct + EVT_SHIFT*p_HFSM.IN_m8;
+ public static final int TRIG_fct__m9 = IFITEM_fct + EVT_SHIFT*p_HFSM.IN_m9;
+ public static final int TRIG_fct__reset = IFITEM_fct + EVT_SHIFT*p_HFSM.IN_reset;
+
+ // state names
+ protected static final String stateStrings[] = {"<no state>","<top>","State1",
+ "State2_State1",
+ "State2_State2",
+ "State3",
+ "State4",
+ "State2"
+ };
// history
- // TODOHRR: history defined in ActorClassBase, init in constructor
- // history = new int[5];
- // for (int i = 0; i < history.length; i++) {
- // history[i] = NO_STATE;
- // }
protected int history[] = {NO_STATE,NO_STATE,NO_STATE,NO_STATE,NO_STATE,NO_STATE,NO_STATE,NO_STATE};
- // transition chains
- protected static final int CHAIN_State2_TRANS_State1_TO_State2_BY_m2fct = 1;
- protected static final int CHAIN_State2_TRANS_State2_TO_tp1_BY_m3fct = 2;
- protected static final int CHAIN_State2_TRANS_tp3_TO_tp3_BY_m5fct_tr3 = 3;
- protected static final int CHAIN_State2_TRANS_tp4_TO_tp4_BY_m6fct_tr4 = 4;
- protected static final int CHAIN_TRANS_INITIAL_TO__State1 = 5;
- protected static final int CHAIN_TRANS_State1_TO_State2_tp0_BY_m1fct = 6;
- protected static final int CHAIN_TRANS_State2_TO_State2_BY_m7fct_tr5 = 7;
- protected static final int CHAIN_TRANS_State2_TO_State4_BY_m4fct = 8;
- protected static final int CHAIN_TRANS_tp0_TO_State1_BY_resetfct = 9;
- protected static final int CHAIN_TRANS_tp1_TO_tp1_BY_m8fct_tr6 = 10;
- protected static final int CHAIN_TRANS_tp2_TO_tp2_BY_m9fct_tr7 = 11;
+ private void setState(int new_state) {
+ DebuggingService.getInstance().addActorState(this,stateStrings[new_state]);
+ if (stateStrings[new_state]!="Idle") {
+ System.out.println(getInstancePath() + " -> " + stateStrings[new_state]);
+ }
+ this.state = new_state;
+ }
+
+ //*** Entry and Exit Codes
+ protected void entry_State1() {
+ fct.s1_entry();
+ }
+ protected void exit_State1() {
+ fct.s1_exit();
+ }
+ protected void entry_State2() {
+ fct.s2_entry();
+ }
+ protected void exit_State2() {
+ fct.s2_exit();
+ }
+ protected void entry_State2_State1() {
+ fct.s2s1_entry();
+ }
+ protected void exit_State2_State1() {
+ fct.s2s1_exit();
+ }
+ protected void entry_State2_State2() {
+ fct.s2s2_entry();
+ }
+ protected void exit_State2_State2() {
+ fct.s2s2_exit();
+ }
+ protected void entry_State3() {
+ fct.s3_entry();
+ }
+ protected void exit_State3() {
+ fct.s3_exit();
+ }
+ protected void entry_State4() {
+ fct.s4_entry();
+ }
+ protected void exit_State4() {
+ fct.s4_exit();
+ }
+
+ //*** Action Codes
+ protected void action_TRANS_INITIAL_TO__State1() {
+ fct.init_action();
+ }
+ protected void action_TRANS_State1_TO_State2_tp0_BY_m1fct(InterfaceItemBase ifitem) {
+ fct.s1_m1_s2_action();
+ }
+ protected void action_TRANS_State2_tp1_TO_State3(InterfaceItemBase ifitem) {
+ fct.s2__s3_action();
+ }
+ protected void action_TRANS_State2_TO_State4_BY_m4fct(InterfaceItemBase ifitem) {
+ fct.s2_m4_s4_action();
+ }
+ protected void action_TRANS_tp0_TO_State1_BY_resetfct(InterfaceItemBase ifitem) {
+ fct.top_reset_s2_action();
+ }
+ protected void action_TRANS_State2_TO_State2_BY_m7fct_tr5(InterfaceItemBase ifitem) {
+ fct.s2_m7_s2_action();
+ }
+ protected void action_TRANS_tp1_TO_tp1_BY_m8fct_tr6(InterfaceItemBase ifitem) {
+ fct.top_s8_top_action();
+ }
+ protected void action_TRANS_tp2_TO_tp2_BY_m9fct_tr7(InterfaceItemBase ifitem) {
+ fct.top_s9_top_action();
+ }
+ protected void action_State2_TRANS_tp0_TO_State1(InterfaceItemBase ifitem) {
+ fct.s2_m1_s2s1_action();
+ }
+ protected void action_State2_TRANS_State1_TO_State2_BY_m2fct(InterfaceItemBase ifitem) {
+ fct.s2s1_m2_s2s2_action();
+ }
+ protected void action_State2_TRANS_State2_TO_tp1_BY_m3fct(InterfaceItemBase ifitem) {
+ fct.s2s2_m3_action();
+ }
+ protected void action_State2_TRANS_tp3_TO_tp3_BY_m5fct_tr3(InterfaceItemBase ifitem) {
+ fct.s2_m5_s2_action();
+ }
+ protected void action_State2_TRANS_tp4_TO_tp4_BY_m6fct_tr4(InterfaceItemBase ifitem) {
+ fct.s2_m6_s2_action();
+ }
+
+ /**
+ * calls exit codes while exiting from the current state to one of its
+ * parent states while remembering the history
+ * @param current - the current state
+ * @param to - the final parent state
+ * @param handler - entry and exit codes are called only if not handler (for handler TransitionPoints)
+ */
+ private void exitTo(int current, int to, boolean handler) {
+ while (current!=to) {
+ switch (current) {
+ case STATE_State1:
+ if (!handler) exit_State1();
+ this.history[STATE_TOP] = STATE_State1;
+ current = STATE_TOP;
+ break;
+ case STATE_State2:
+ if (!handler) exit_State2();
+ this.history[STATE_TOP] = STATE_State2;
+ current = STATE_TOP;
+ break;
+ case STATE_State2_State1:
+ if (!handler) exit_State2_State1();
+ this.history[STATE_State2] = STATE_State2_State1;
+ current = STATE_State2;
+ break;
+ case STATE_State2_State2:
+ if (!handler) exit_State2_State2();
+ this.history[STATE_State2] = STATE_State2_State2;
+ current = STATE_State2;
+ break;
+ case STATE_State3:
+ if (!handler) exit_State3();
+ this.history[STATE_TOP] = STATE_State3;
+ current = STATE_TOP;
+ break;
+ case STATE_State4:
+ if (!handler) exit_State4();
+ this.history[STATE_TOP] = STATE_State4;
+ current = STATE_TOP;
+ break;
+ }
+ }
+ }
+
+ /**
+ * calls action, entry and exit codes along a transition chain. The generic data are cast to typed data
+ * matching the trigger of this chain. The ID of the final state is returned
+ * @param chain - the chain ID
+ * @param generic_data - the generic data pointer
+ * @return the ID of the final state
+ */
+ private int executeTransitionChain(int chain, InterfaceItemBase ifitem, Object generic_data) {
+ switch (chain) {
+ case CHAIN_TRANS_INITIAL_TO__State1:
+ {
+ action_TRANS_INITIAL_TO__State1();
+ return STATE_State1;
+ }
+ case CHAIN_TRANS_State1_TO_State2_tp0_BY_m1fct:
+ {
+ action_TRANS_State1_TO_State2_tp0_BY_m1fct(ifitem);
+ entry_State2();
+ action_State2_TRANS_tp0_TO_State1(ifitem);
+ return STATE_State2_State1;
+ }
+ case CHAIN_TRANS_State2_TO_State4_BY_m4fct:
+ {
+ action_TRANS_State2_TO_State4_BY_m4fct(ifitem);
+ return STATE_State4;
+ }
+ case CHAIN_TRANS_tp0_TO_State1_BY_resetfct:
+ {
+ action_TRANS_tp0_TO_State1_BY_resetfct(ifitem);
+ return STATE_State1;
+ }
+ case CHAIN_TRANS_State2_TO_State2_BY_m7fct_tr5:
+ {
+ action_TRANS_State2_TO_State2_BY_m7fct_tr5(ifitem);
+ return STATE_State2;
+ }
+ case CHAIN_TRANS_tp1_TO_tp1_BY_m8fct_tr6:
+ {
+ action_TRANS_tp1_TO_tp1_BY_m8fct_tr6(ifitem);
+ return STATE_TOP;
+ }
+ case CHAIN_TRANS_tp2_TO_tp2_BY_m9fct_tr7:
+ {
+ action_TRANS_tp2_TO_tp2_BY_m9fct_tr7(ifitem);
+ return STATE_TOP;
+ }
+ case CHAIN_State2_TRANS_State1_TO_State2_BY_m2fct:
+ {
+ action_State2_TRANS_State1_TO_State2_BY_m2fct(ifitem);
+ return STATE_State2_State2;
+ }
+ case CHAIN_State2_TRANS_State2_TO_tp1_BY_m3fct:
+ {
+ action_State2_TRANS_State2_TO_tp1_BY_m3fct(ifitem);
+ exit_State2();
+ action_TRANS_State2_tp1_TO_State3(ifitem);
+ return STATE_State3;
+ }
+ case CHAIN_State2_TRANS_tp3_TO_tp3_BY_m5fct_tr3:
+ {
+ action_State2_TRANS_tp3_TO_tp3_BY_m5fct_tr3(ifitem);
+ return STATE_State2;
+ }
+ case CHAIN_State2_TRANS_tp4_TO_tp4_BY_m6fct_tr4:
+ {
+ action_State2_TRANS_tp4_TO_tp4_BY_m6fct_tr4(ifitem);
+ return STATE_State2;
+ }
+ }
+ return NO_STATE;
+ }
+
+ /**
+ * calls entry codes while entering a state's history. The ID of the final leaf state is returned
+ * @param state - the state which is entered
+ * @param handler - entry code is executed if not handler
+ * @return - the ID of the final leaf state
+ */
+ private int enterHistory(int state, boolean handler, boolean skip_entry) {
+ while (true) {
+ switch (state) {
+ case STATE_State1:
+ if (!(skip_entry || handler)) entry_State1();
+ // in leaf state: return state id
+ return STATE_State1;
+ case STATE_State2:
+ if (!(skip_entry || handler)) entry_State2();
+ // state has a sub graph
+ // without init transition
+ state = this.history[STATE_State2];
+ break;
+ case STATE_State2_State1:
+ if (!(skip_entry || handler)) entry_State2_State1();
+ // in leaf state: return state id
+ return STATE_State2_State1;
+ case STATE_State2_State2:
+ if (!(skip_entry || handler)) entry_State2_State2();
+ // in leaf state: return state id
+ return STATE_State2_State2;
+ case STATE_State3:
+ if (!(skip_entry || handler)) entry_State3();
+ // in leaf state: return state id
+ return STATE_State3;
+ case STATE_State4:
+ if (!(skip_entry || handler)) entry_State4();
+ // in leaf state: return state id
+ return STATE_State4;
+ case STATE_TOP:
+ state = this.history[STATE_TOP];
+ break;
+ }
+ skip_entry = false;
+ }
+ //return NO_STATE; // required by CDT but detected as unreachable by JDT because of while (true)
+ }
- // triggers for FSM
- protected static final int TRIG_fct__m1 = IFITEM_fct + EVT_SHIFT*p_HFSM.IN_m1;
- protected static final int TRIG_fct__m2 = IFITEM_fct + EVT_SHIFT*p_HFSM.IN_m2;
- protected static final int TRIG_fct__m3 = IFITEM_fct + EVT_SHIFT*p_HFSM.IN_m3;
- protected static final int TRIG_fct__m4 = IFITEM_fct + EVT_SHIFT*p_HFSM.IN_m4;
- protected static final int TRIG_fct__m5 = IFITEM_fct + EVT_SHIFT*p_HFSM.IN_m5;
- protected static final int TRIG_fct__m6 = IFITEM_fct + EVT_SHIFT*p_HFSM.IN_m6;
- protected static final int TRIG_fct__m7 = IFITEM_fct + EVT_SHIFT*p_HFSM.IN_m7;
- protected static final int TRIG_fct__m8 = IFITEM_fct + EVT_SHIFT*p_HFSM.IN_m8;
- protected static final int TRIG_fct__m9 = IFITEM_fct + EVT_SHIFT*p_HFSM.IN_m9;
- protected static final int TRIG_fct__reset = IFITEM_fct + EVT_SHIFT*p_HFSM.IN_reset;
+ public void executeInitTransition() {
+ int chain = CHAIN_TRANS_INITIAL_TO__State1;
+ int next = executeTransitionChain(chain, null, null);
+ next = enterHistory(next, false, false);
+ setState(next);
+ }
- // receiveEvent contains the main implementation of the FSM
- @Override
+ /* receiveEvent contains the main implementation of the FSM */
public void receiveEvent(InterfaceItemBase ifitem, int evt, Object generic_data) {
int trigger = ifitem.getLocalId() + EVT_SHIFT*evt;
int chain = NOT_CAUGHT;
@@ -120,7 +367,7 @@ public class a_HFSM extends ActorClassBase {
boolean skip_entry = false;
if (!handleSystemEvent(ifitem, evt, generic_data)) {
- switch (state) {
+ switch (this.state) {
case STATE_State1:
switch(trigger) {
case TRIG_fct__m1:
@@ -321,266 +568,12 @@ public class a_HFSM extends ActorClassBase {
}
}
if (chain != NOT_CAUGHT) {
- exitTo(state, catching_state, is_handler);
+ exitTo(this.state, catching_state, is_handler);
int next = executeTransitionChain(chain, ifitem, generic_data);
next = enterHistory(next, is_handler, skip_entry);
setState(next);
}
}
-
- private void setState(int new_state) {
- DebuggingService.getInstance().addActorState(this,stateStrings[new_state]);
- if (stateStrings[new_state]!="Idle") {
- // TODOTS: model switch for activation
- System.out.println(getInstancePath() + " -> " + stateStrings[new_state]);
- }
- this.state = new_state;
- }
-
- @Override
- public void executeInitTransition() {
- int chain = CHAIN_TRANS_INITIAL_TO__State1;
- int next = executeTransitionChain(chain, null, null);
- next = enterHistory(next, false, false);
- setState(next);
- }
-
- /**
- * calls exit codes while exiting from the current state to one of its
- * parent states while remembering the history
- * @param current - the current state
- * @param to - the final parent state
- * @param handler - entry and exit codes are called only if not handler (for handler TransitionPoints)
- */
- private void exitTo(int current, int to, boolean handler) {
- while (current!=to) {
- switch (current) {
- case STATE_State1:
- if (!handler) exit_State1();
- history[STATE_TOP] = STATE_State1;
- current = STATE_TOP;
- break;
- case STATE_State2:
- if (!handler) exit_State2();
- history[STATE_TOP] = STATE_State2;
- current = STATE_TOP;
- break;
- case STATE_State2_State1:
- if (!handler) exit_State2_State1();
- history[STATE_State2] = STATE_State2_State1;
- current = STATE_State2;
- break;
- case STATE_State2_State2:
- if (!handler) exit_State2_State2();
- history[STATE_State2] = STATE_State2_State2;
- current = STATE_State2;
- break;
- case STATE_State3:
- if (!handler) exit_State3();
- history[STATE_TOP] = STATE_State3;
- current = STATE_TOP;
- break;
- case STATE_State4:
- if (!handler) exit_State4();
- history[STATE_TOP] = STATE_State4;
- current = STATE_TOP;
- break;
- }
- }
- }
- /**
- * calls action, entry and exit codes along a transition chain. The generic data are cast to typed data
- * matching the trigger of this chain. The ID of the final state is returned
- * @param chain - the chain ID
- * @param generic_data - the generic data pointer
- * @return the ID of the final state
- */
- private int executeTransitionChain(int chain, InterfaceItemBase ifitem, Object generic_data) {
- switch (chain) {
- case CHAIN_TRANS_INITIAL_TO__State1:
- {
- action_TRANS_INITIAL_TO__State1();
- return STATE_State1;
- }
- case CHAIN_TRANS_State1_TO_State2_tp0_BY_m1fct:
- {
- action_TRANS_State1_TO_State2_tp0_BY_m1fct(ifitem);
- entry_State2();
- action_State2_TRANS_tp0_TO_State1(ifitem);
- return STATE_State2_State1;
- }
- case CHAIN_TRANS_State2_TO_State4_BY_m4fct:
- {
- action_TRANS_State2_TO_State4_BY_m4fct(ifitem);
- return STATE_State4;
- }
- case CHAIN_TRANS_tp0_TO_State1_BY_resetfct:
- {
- action_TRANS_tp0_TO_State1_BY_resetfct(ifitem);
- return STATE_State1;
- }
- case CHAIN_TRANS_State2_TO_State2_BY_m7fct_tr5:
- {
- action_TRANS_State2_TO_State2_BY_m7fct_tr5(ifitem);
- return STATE_State2;
- }
- case CHAIN_TRANS_tp1_TO_tp1_BY_m8fct_tr6:
- {
- action_TRANS_tp1_TO_tp1_BY_m8fct_tr6(ifitem);
- return STATE_TOP;
- }
- case CHAIN_TRANS_tp2_TO_tp2_BY_m9fct_tr7:
- {
- action_TRANS_tp2_TO_tp2_BY_m9fct_tr7(ifitem);
- return STATE_TOP;
- }
- case CHAIN_State2_TRANS_State1_TO_State2_BY_m2fct:
- {
- action_State2_TRANS_State1_TO_State2_BY_m2fct(ifitem);
- return STATE_State2_State2;
- }
- case CHAIN_State2_TRANS_State2_TO_tp1_BY_m3fct:
- {
- action_State2_TRANS_State2_TO_tp1_BY_m3fct(ifitem);
- exit_State2();
- action_TRANS_State2_tp1_TO_State3(ifitem);
- return STATE_State3;
- }
- case CHAIN_State2_TRANS_tp3_TO_tp3_BY_m5fct_tr3:
- {
- action_State2_TRANS_tp3_TO_tp3_BY_m5fct_tr3(ifitem);
- return STATE_State2;
- }
- case CHAIN_State2_TRANS_tp4_TO_tp4_BY_m6fct_tr4:
- {
- action_State2_TRANS_tp4_TO_tp4_BY_m6fct_tr4(ifitem);
- return STATE_State2;
- }
- }
- return NO_STATE;
- }
- /**
- * calls entry codes while entering a state's history. The ID of the final leaf state is returned
- * @param state - the state which is entered
- * @param handler - entry code is executed if not handler
- * @return - the ID of the final leaf state
- */
- private int enterHistory(int state, boolean handler, boolean skip_entry) {
- while (true) {
- switch (state) {
- case STATE_State1:
- if (!(skip_entry || handler)) entry_State1();
- // in leaf state: return state id
- return STATE_State1;
- case STATE_State2:
- if (!(skip_entry || handler)) entry_State2();
- // state has a sub graph
- // without init transition
- state = history[STATE_State2];
- break;
- case STATE_State2_State1:
- if (!(skip_entry || handler)) entry_State2_State1();
- // in leaf state: return state id
- return STATE_State2_State1;
- case STATE_State2_State2:
- if (!(skip_entry || handler)) entry_State2_State2();
- // in leaf state: return state id
- return STATE_State2_State2;
- case STATE_State3:
- if (!(skip_entry || handler)) entry_State3();
- // in leaf state: return state id
- return STATE_State3;
- case STATE_State4:
- if (!(skip_entry || handler)) entry_State4();
- // in leaf state: return state id
- return STATE_State4;
- case STATE_TOP:
- state = history[STATE_TOP];
- break;
- }
- skip_entry = false;
- }
- //return NO_STATE; // required by CDT but detected as unreachable by JDT because of while (true)
- }
-
- //*** Entry and Exit Codes
- protected void entry_State1() {
- fct.s1_entry();
- }
- protected void exit_State1() {
- fct.s1_exit();
- }
- protected void entry_State2() {
- fct.s2_entry();
- }
- protected void exit_State2() {
- fct.s2_exit();
- }
- protected void entry_State2_State1() {
- fct.s2s1_entry();
- }
- protected void exit_State2_State1() {
- fct.s2s1_exit();
- }
- protected void entry_State2_State2() {
- fct.s2s2_entry();
- }
- protected void exit_State2_State2() {
- fct.s2s2_exit();
- }
- protected void entry_State3() {
- fct.s3_entry();
- }
- protected void exit_State3() {
- fct.s3_exit();
- }
- protected void entry_State4() {
- fct.s4_entry();
- }
- protected void exit_State4() {
- fct.s4_exit();
- }
-
- //*** Action Codes
- protected void action_TRANS_INITIAL_TO__State1() {
- fct.init_action();
- }
- protected void action_TRANS_State1_TO_State2_tp0_BY_m1fct(InterfaceItemBase ifitem) {
- fct.s1_m1_s2_action();
- }
- protected void action_TRANS_State2_tp1_TO_State3(InterfaceItemBase ifitem) {
- fct.s2__s3_action();
- }
- protected void action_TRANS_State2_TO_State4_BY_m4fct(InterfaceItemBase ifitem) {
- fct.s2_m4_s4_action();
- }
- protected void action_TRANS_tp0_TO_State1_BY_resetfct(InterfaceItemBase ifitem) {
- fct.top_reset_s2_action();
- }
- protected void action_TRANS_State2_TO_State2_BY_m7fct_tr5(InterfaceItemBase ifitem) {
- fct.s2_m7_s2_action();
- }
- protected void action_TRANS_tp1_TO_tp1_BY_m8fct_tr6(InterfaceItemBase ifitem) {
- fct.top_s8_top_action();
- }
- protected void action_TRANS_tp2_TO_tp2_BY_m9fct_tr7(InterfaceItemBase ifitem) {
- fct.top_s9_top_action();
- }
- protected void action_State2_TRANS_tp0_TO_State1(InterfaceItemBase ifitem) {
- fct.s2_m1_s2s1_action();
- }
- protected void action_State2_TRANS_State1_TO_State2_BY_m2fct(InterfaceItemBase ifitem) {
- fct.s2s1_m2_s2s2_action();
- }
- protected void action_State2_TRANS_State2_TO_tp1_BY_m3fct(InterfaceItemBase ifitem) {
- fct.s2s2_m3_action();
- }
- protected void action_State2_TRANS_tp3_TO_tp3_BY_m5fct_tr3(InterfaceItemBase ifitem) {
- fct.s2_m5_s2_action();
- }
- protected void action_State2_TRANS_tp4_TO_tp4_BY_m6fct_tr4(InterfaceItemBase ifitem) {
- fct.s2_m6_s2_action();
- }
//******************************************
// END of generated code for FSM
diff --git a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/tests/a_HFSM_Tester.java b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/tests/a_HFSM_Tester.java
index ff1b43a98..4b2fc9419 100644
--- a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/tests/a_HFSM_Tester.java
+++ b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/tests/a_HFSM_Tester.java
@@ -25,8 +25,8 @@ public class a_HFSM_Tester extends ActorClassBase {
//--------------------- services
//--------------------- interface item IDs
- protected static final int IFITEM_testee = 1;
-
+ public static final int IFITEM_testee = 1;
+
//--------------------- attributes
//--------------------- operations
@@ -61,164 +61,66 @@ public class a_HFSM_Tester extends ActorClassBase {
destroyUser();
}
- //******************************************
- // START of generated code for FSM
- //******************************************
- // State IDs for FSM
- protected static final int STATE_State1 = 2;
- protected static final int STATE_State2 = 3;
- protected static final int STATE_State3 = 4;
- protected static final int STATE_State4 = 5;
- protected static final int STATE_State5 = 6;
- protected static final int STATE_State6 = 7;
- protected static final int STATE_State7 = 8;
- protected static final int STATE_TestPass = 9;
- protected static final String stateStrings[] = {"<no state>","<top>","State1",
- "State2",
- "State3",
- "State4",
- "State5",
- "State6",
- "State7",
- "TestPass"
- };
+ /* state IDs */
+ public static final int STATE_State1 = 2;
+ public static final int STATE_State2 = 3;
+ public static final int STATE_State3 = 4;
+ public static final int STATE_State4 = 5;
+ public static final int STATE_State5 = 6;
+ public static final int STATE_State6 = 7;
+ public static final int STATE_State7 = 8;
+ public static final int STATE_TestPass = 9;
- // history
- // TODOHRR: history defined in ActorClassBase, init in constructor
- // history = new int[5];
- // for (int i = 0; i < history.length; i++) {
- // history[i] = NO_STATE;
- // }
- protected int history[] = {NO_STATE,NO_STATE,NO_STATE,NO_STATE,NO_STATE,NO_STATE,NO_STATE,NO_STATE,NO_STATE,NO_STATE};
+ /* transition chains */
+ public static final int CHAIN_TRANS_INITIAL_TO__State1 = 1;
+ public static final int CHAIN_TRANS_State1_TO_State2_BY_init_actiontestee = 2;
+ public static final int CHAIN_TRANS_State2_TO_State3_BY_s1_entrytestee = 3;
+ public static final int CHAIN_TRANS_State3_TO_State4_BY_s1_exittestee = 4;
+ public static final int CHAIN_TRANS_State4_TO_State5_BY_s1_m1_s2_actiontestee = 5;
+ public static final int CHAIN_TRANS_State5_TO_State6_BY_s2_entrytestee = 6;
+ public static final int CHAIN_TRANS_State6_TO_State7_BY_s2_m1_s2s1_actiontestee = 7;
+ public static final int CHAIN_TRANS_State7_TO_TestPass_BY_s2s1_entrytestee = 8;
- // transition chains
- protected static final int CHAIN_TRANS_INITIAL_TO__State1 = 1;
- protected static final int CHAIN_TRANS_State1_TO_State2_BY_init_actiontestee = 2;
- protected static final int CHAIN_TRANS_State2_TO_State3_BY_s1_entrytestee = 3;
- protected static final int CHAIN_TRANS_State3_TO_State4_BY_s1_exittestee = 4;
- protected static final int CHAIN_TRANS_State4_TO_State5_BY_s1_m1_s2_actiontestee = 5;
- protected static final int CHAIN_TRANS_State5_TO_State6_BY_s2_entrytestee = 6;
- protected static final int CHAIN_TRANS_State6_TO_State7_BY_s2_m1_s2s1_actiontestee = 7;
- protected static final int CHAIN_TRANS_State7_TO_TestPass_BY_s2s1_entrytestee = 8;
+ /* triggers */
+ public static final int TRIG_testee__init_action = IFITEM_testee + EVT_SHIFT*p_HFSM.OUT_init_action;
+ public static final int TRIG_testee__s1_entry = IFITEM_testee + EVT_SHIFT*p_HFSM.OUT_s1_entry;
+ public static final int TRIG_testee__s1_exit = IFITEM_testee + EVT_SHIFT*p_HFSM.OUT_s1_exit;
+ public static final int TRIG_testee__s1_m1_s2_action = IFITEM_testee + EVT_SHIFT*p_HFSM.OUT_s1_m1_s2_action;
+ public static final int TRIG_testee__s2_entry = IFITEM_testee + EVT_SHIFT*p_HFSM.OUT_s2_entry;
+ public static final int TRIG_testee__s2_m1_s2s1_action = IFITEM_testee + EVT_SHIFT*p_HFSM.OUT_s2_m1_s2s1_action;
+ public static final int TRIG_testee__s2s1_entry = IFITEM_testee + EVT_SHIFT*p_HFSM.OUT_s2s1_entry;
- // triggers for FSM
- protected static final int TRIG_testee__init_action = IFITEM_testee + EVT_SHIFT*p_HFSM.OUT_init_action;
- protected static final int TRIG_testee__s1_entry = IFITEM_testee + EVT_SHIFT*p_HFSM.OUT_s1_entry;
- protected static final int TRIG_testee__s1_exit = IFITEM_testee + EVT_SHIFT*p_HFSM.OUT_s1_exit;
- protected static final int TRIG_testee__s1_m1_s2_action = IFITEM_testee + EVT_SHIFT*p_HFSM.OUT_s1_m1_s2_action;
- protected static final int TRIG_testee__s2_entry = IFITEM_testee + EVT_SHIFT*p_HFSM.OUT_s2_entry;
- protected static final int TRIG_testee__s2_m1_s2s1_action = IFITEM_testee + EVT_SHIFT*p_HFSM.OUT_s2_m1_s2s1_action;
- protected static final int TRIG_testee__s2s1_entry = IFITEM_testee + EVT_SHIFT*p_HFSM.OUT_s2s1_entry;
+ // state names
+ protected static final String stateStrings[] = {"<no state>","<top>","State1",
+ "State2",
+ "State3",
+ "State4",
+ "State5",
+ "State6",
+ "State7",
+ "TestPass"
+ };
- // receiveEvent contains the main implementation of the FSM
- @Override
- public void receiveEvent(InterfaceItemBase ifitem, int evt, Object generic_data) {
- int trigger = ifitem.getLocalId() + EVT_SHIFT*evt;
- int chain = NOT_CAUGHT;
- int catching_state = NO_STATE;
- boolean is_handler = false;
- boolean skip_entry = false;
-
- if (!handleSystemEvent(ifitem, evt, generic_data)) {
- switch (state) {
- case STATE_State1:
- switch(trigger) {
- case TRIG_testee__init_action:
- {
- chain = CHAIN_TRANS_State1_TO_State2_BY_init_actiontestee;
- catching_state = STATE_TOP;
- }
- break;
- }
- break;
- case STATE_State2:
- switch(trigger) {
- case TRIG_testee__s1_entry:
- {
- chain = CHAIN_TRANS_State2_TO_State3_BY_s1_entrytestee;
- catching_state = STATE_TOP;
- }
- break;
- }
- break;
- case STATE_State3:
- switch(trigger) {
- case TRIG_testee__s1_exit:
- {
- chain = CHAIN_TRANS_State3_TO_State4_BY_s1_exittestee;
- catching_state = STATE_TOP;
- }
- break;
- }
- break;
- case STATE_State4:
- switch(trigger) {
- case TRIG_testee__s1_m1_s2_action:
- {
- chain = CHAIN_TRANS_State4_TO_State5_BY_s1_m1_s2_actiontestee;
- catching_state = STATE_TOP;
- }
- break;
- }
- break;
- case STATE_State5:
- switch(trigger) {
- case TRIG_testee__s2_entry:
- {
- chain = CHAIN_TRANS_State5_TO_State6_BY_s2_entrytestee;
- catching_state = STATE_TOP;
- }
- break;
- }
- break;
- case STATE_State6:
- switch(trigger) {
- case TRIG_testee__s2_m1_s2s1_action:
- {
- chain = CHAIN_TRANS_State6_TO_State7_BY_s2_m1_s2s1_actiontestee;
- catching_state = STATE_TOP;
- }
- break;
- }
- break;
- case STATE_State7:
- switch(trigger) {
- case TRIG_testee__s2s1_entry:
- {
- chain = CHAIN_TRANS_State7_TO_TestPass_BY_s2s1_entrytestee;
- catching_state = STATE_TOP;
- }
- break;
- }
- break;
- case STATE_TestPass:
- break;
- }
- }
- if (chain != NOT_CAUGHT) {
- exitTo(state, catching_state, is_handler);
- int next = executeTransitionChain(chain, ifitem, generic_data);
- next = enterHistory(next, is_handler, skip_entry);
- setState(next);
- }
- }
+ // history
+ protected int history[] = {NO_STATE,NO_STATE,NO_STATE,NO_STATE,NO_STATE,NO_STATE,NO_STATE,NO_STATE,NO_STATE,NO_STATE};
private void setState(int new_state) {
DebuggingService.getInstance().addActorState(this,stateStrings[new_state]);
if (stateStrings[new_state]!="Idle") {
- // TODOTS: model switch for activation
System.out.println(getInstancePath() + " -> " + stateStrings[new_state]);
}
this.state = new_state;
}
- @Override
- public void executeInitTransition() {
- int chain = CHAIN_TRANS_INITIAL_TO__State1;
- int next = executeTransitionChain(chain, null, null);
- next = enterHistory(next, false, false);
- setState(next);
+ //*** Entry and Exit Codes
+ protected void entry_TestPass() {
+ RTServices.getInstance().getSubSystem().testFinished(0);
+ }
+
+ //*** Action Codes
+ protected void action_TRANS_State2_TO_State3_BY_s1_entrytestee(InterfaceItemBase ifitem) {
+ testee.m1();
}
/**
@@ -232,40 +134,41 @@ public class a_HFSM_Tester extends ActorClassBase {
while (current!=to) {
switch (current) {
case STATE_State1:
- history[STATE_TOP] = STATE_State1;
+ this.history[STATE_TOP] = STATE_State1;
current = STATE_TOP;
break;
case STATE_State2:
- history[STATE_TOP] = STATE_State2;
+ this.history[STATE_TOP] = STATE_State2;
current = STATE_TOP;
break;
case STATE_State3:
- history[STATE_TOP] = STATE_State3;
+ this.history[STATE_TOP] = STATE_State3;
current = STATE_TOP;
break;
case STATE_State4:
- history[STATE_TOP] = STATE_State4;
+ this.history[STATE_TOP] = STATE_State4;
current = STATE_TOP;
break;
case STATE_State5:
- history[STATE_TOP] = STATE_State5;
+ this.history[STATE_TOP] = STATE_State5;
current = STATE_TOP;
break;
case STATE_State6:
- history[STATE_TOP] = STATE_State6;
+ this.history[STATE_TOP] = STATE_State6;
current = STATE_TOP;
break;
case STATE_State7:
- history[STATE_TOP] = STATE_State7;
+ this.history[STATE_TOP] = STATE_State7;
current = STATE_TOP;
break;
case STATE_TestPass:
- history[STATE_TOP] = STATE_TestPass;
+ this.history[STATE_TOP] = STATE_TestPass;
current = STATE_TOP;
break;
}
}
}
+
/**
* calls action, entry and exit codes along a transition chain. The generic data are cast to typed data
* matching the trigger of this chain. The ID of the final state is returned
@@ -311,6 +214,7 @@ public class a_HFSM_Tester extends ActorClassBase {
}
return NO_STATE;
}
+
/**
* calls entry codes while entering a state's history. The ID of the final leaf state is returned
* @param state - the state which is entered
@@ -346,7 +250,7 @@ public class a_HFSM_Tester extends ActorClassBase {
// in leaf state: return state id
return STATE_TestPass;
case STATE_TOP:
- state = history[STATE_TOP];
+ state = this.history[STATE_TOP];
break;
}
skip_entry = false;
@@ -354,14 +258,103 @@ public class a_HFSM_Tester extends ActorClassBase {
//return NO_STATE; // required by CDT but detected as unreachable by JDT because of while (true)
}
- //*** Entry and Exit Codes
- protected void entry_TestPass() {
- RTServices.getInstance().getSubSystem().testFinished(0);
+ public void executeInitTransition() {
+ int chain = CHAIN_TRANS_INITIAL_TO__State1;
+ int next = executeTransitionChain(chain, null, null);
+ next = enterHistory(next, false, false);
+ setState(next);
}
- //*** Action Codes
- protected void action_TRANS_State2_TO_State3_BY_s1_entrytestee(InterfaceItemBase ifitem) {
- testee.m1();
+ /* receiveEvent contains the main implementation of the FSM */
+ public void receiveEvent(InterfaceItemBase ifitem, int evt, Object generic_data) {
+ int trigger = ifitem.getLocalId() + EVT_SHIFT*evt;
+ int chain = NOT_CAUGHT;
+ int catching_state = NO_STATE;
+ boolean is_handler = false;
+ boolean skip_entry = false;
+
+ if (!handleSystemEvent(ifitem, evt, generic_data)) {
+ switch (this.state) {
+ case STATE_State1:
+ switch(trigger) {
+ case TRIG_testee__init_action:
+ {
+ chain = CHAIN_TRANS_State1_TO_State2_BY_init_actiontestee;
+ catching_state = STATE_TOP;
+ }
+ break;
+ }
+ break;
+ case STATE_State2:
+ switch(trigger) {
+ case TRIG_testee__s1_entry:
+ {
+ chain = CHAIN_TRANS_State2_TO_State3_BY_s1_entrytestee;
+ catching_state = STATE_TOP;
+ }
+ break;
+ }
+ break;
+ case STATE_State3:
+ switch(trigger) {
+ case TRIG_testee__s1_exit:
+ {
+ chain = CHAIN_TRANS_State3_TO_State4_BY_s1_exittestee;
+ catching_state = STATE_TOP;
+ }
+ break;
+ }
+ break;
+ case STATE_State4:
+ switch(trigger) {
+ case TRIG_testee__s1_m1_s2_action:
+ {
+ chain = CHAIN_TRANS_State4_TO_State5_BY_s1_m1_s2_actiontestee;
+ catching_state = STATE_TOP;
+ }
+ break;
+ }
+ break;
+ case STATE_State5:
+ switch(trigger) {
+ case TRIG_testee__s2_entry:
+ {
+ chain = CHAIN_TRANS_State5_TO_State6_BY_s2_entrytestee;
+ catching_state = STATE_TOP;
+ }
+ break;
+ }
+ break;
+ case STATE_State6:
+ switch(trigger) {
+ case TRIG_testee__s2_m1_s2s1_action:
+ {
+ chain = CHAIN_TRANS_State6_TO_State7_BY_s2_m1_s2s1_actiontestee;
+ catching_state = STATE_TOP;
+ }
+ break;
+ }
+ break;
+ case STATE_State7:
+ switch(trigger) {
+ case TRIG_testee__s2s1_entry:
+ {
+ chain = CHAIN_TRANS_State7_TO_TestPass_BY_s2s1_entrytestee;
+ catching_state = STATE_TOP;
+ }
+ break;
+ }
+ break;
+ case STATE_TestPass:
+ break;
+ }
+ }
+ if (chain != NOT_CAUGHT) {
+ exitTo(this.state, catching_state, is_handler);
+ int next = executeTransitionChain(chain, ifitem, generic_data);
+ next = enterHistory(next, is_handler, skip_entry);
+ setState(next);
+ }
}
//******************************************
diff --git a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/tests/a_HFSM_Tests.java b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/tests/a_HFSM_Tests.java
index 5d51299dc..518f21e34 100644
--- a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/tests/a_HFSM_Tests.java
+++ b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/tests/a_HFSM_Tests.java
@@ -20,7 +20,7 @@ public class a_HFSM_Tests extends ActorClassBase {
//--------------------- services
//--------------------- interface item IDs
-
+
//--------------------- attributes
//--------------------- operations
diff --git a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/tests/p_HFSM.java b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/tests/p_HFSM.java
index 6358a0aa9..17ddad4c2 100644
--- a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/tests/p_HFSM.java
+++ b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/tests/p_HFSM.java
@@ -11,10 +11,7 @@ import org.eclipse.etrice.runtime.java.debugging.DebuggingService;
public class p_HFSM {
// message IDs
- // TODO: separate class for message IDs: class MSG{public static volatile int MSG_MIN = 0; ...} -> better structure
- // error if msgID <= MSG_MIN
- public static final int MSG_MIN = 0;
- //IDs for outgoing messages
+ public static final int MSG_MIN = 0;
public static final int OUT_init_action = 1;
public static final int OUT_s1_entry = 2;
public static final int OUT_s1_exit = 3;
@@ -40,7 +37,6 @@ public class p_HFSM {
public static final int OUT_top_s8_top_action = 23;
public static final int OUT_top_s9_top_action = 24;
public static final int OUT_top_reset_s2_action = 25;
- //IDs for incoming messages
public static final int IN_m1 = 26;
public static final int IN_m2 = 27;
public static final int IN_m3 = 28;
@@ -51,8 +47,7 @@ public class p_HFSM {
public static final int IN_m7 = 33;
public static final int IN_m8 = 34;
public static final int IN_m9 = 35;
- //error if msgID >= MSG_MAX
- public static final int MSG_MAX = 36;
+ public static final int MSG_MAX = 36;
private static String messageStrings[] = {"MIN", "init_action","s1_entry","s1_exit","s2_entry","s2_exit","s3_entry","s3_exit","s4_entry","s4_exit","s2s1_entry","s2s1_exit","s2s2_entry","s2s2_exit","s1_m1_s2_action","s2_m1_s2s1_action","s2s1_m2_s2s2_action","s2s2_m3_action","s2_m4_s4_action","s2_m5_s2_action","s2_m6_s2_action","s2__s3_action","s2_m7_s2_action","top_s8_top_action","top_s9_top_action","top_reset_s2_action", "m1","m2","m3","m4","m5","m6","reset","m7","m8","m9","MAX"};
diff --git a/tests/org.eclipse.etrice.runtime.java.tests/src/org/eclipse/etrice/runtime/java/modelbase/ActorClassBaseTest.java b/tests/org.eclipse.etrice.runtime.java.tests/src/org/eclipse/etrice/runtime/java/modelbase/ActorClassBaseTest.java
index 14f478bf0..6bec2d712 100644
--- a/tests/org.eclipse.etrice.runtime.java.tests/src/org/eclipse/etrice/runtime/java/modelbase/ActorClassBaseTest.java
+++ b/tests/org.eclipse.etrice.runtime.java.tests/src/org/eclipse/etrice/runtime/java/modelbase/ActorClassBaseTest.java
@@ -14,7 +14,6 @@ import org.eclipse.etrice.runtime.java.messaging.Message;
import org.eclipse.etrice.runtime.java.messaging.MessageService;
import org.eclipse.etrice.runtime.java.messaging.RTServices;
import org.eclipse.etrice.runtime.java.modelbase.ActorClassBase;
-import org.eclipse.etrice.runtime.java.modelbase.InterfaceItemBase;
import junit.framework.TestCase;
diff --git a/tests/org.eclipse.etrice.runtime.java.tests/src/org/eclipse/etrice/runtime/java/modelbase/PortBaseTest.java b/tests/org.eclipse.etrice.runtime.java.tests/src/org/eclipse/etrice/runtime/java/modelbase/PortBaseTest.java
index 0c4993802..da792e661 100644
--- a/tests/org.eclipse.etrice.runtime.java.tests/src/org/eclipse/etrice/runtime/java/modelbase/PortBaseTest.java
+++ b/tests/org.eclipse.etrice.runtime.java.tests/src/org/eclipse/etrice/runtime/java/modelbase/PortBaseTest.java
@@ -31,10 +31,7 @@ public class PortBaseTest extends TestCase {
}
@Override
- public void receiveEvent(InterfaceItemBase ifitem, int evt,
- Object data) {
- // TODO Auto-generated method stub
-
+ public void receiveEvent(InterfaceItemBase ifitem, int evt, Object data) {
}
}

Back to the top