Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--plugins/org.eclipse.etrice.core.genmodel.fsm/src/org/eclipse/etrice/core/genmodel/fsm/ExtendedFsmGenBuilder.xtend32
-rw-r--r--plugins/org.eclipse.etrice.generator.fsm/src/org/eclipse/etrice/generator/fsm/generic/AbstractStateMachineGenerator.xtend12
-rw-r--r--tests/org.eclipse.etrice.abstractexec.behavior.tests/models/reachability.room2
-rw-r--r--tests/org.eclipse.etrice.abstractexec.behavior.tests/src/org/eclipse/etrice/abstractexec/behavior/tests/TestReachability.java28
-rw-r--r--tests/org.eclipse.etrice.generator.common.tests/build.gradle2
-rw-r--r--tests/org.eclipse.etrice.generator.common.tests/models/Bug541775_NoInitialTransition.room24
6 files changed, 81 insertions, 19 deletions
diff --git a/plugins/org.eclipse.etrice.core.genmodel.fsm/src/org/eclipse/etrice/core/genmodel/fsm/ExtendedFsmGenBuilder.xtend b/plugins/org.eclipse.etrice.core.genmodel.fsm/src/org/eclipse/etrice/core/genmodel/fsm/ExtendedFsmGenBuilder.xtend
index 5dd9c54f9..a26ee681f 100644
--- a/plugins/org.eclipse.etrice.core.genmodel.fsm/src/org/eclipse/etrice/core/genmodel/fsm/ExtendedFsmGenBuilder.xtend
+++ b/plugins/org.eclipse.etrice.core.genmodel.fsm/src/org/eclipse/etrice/core/genmodel/fsm/ExtendedFsmGenBuilder.xtend
@@ -32,6 +32,8 @@ import org.eclipse.etrice.core.genmodel.fsm.fsmgen.Node
import static extension org.eclipse.etrice.core.genmodel.fsm.FsmGenExtensions.*
import org.eclipse.etrice.core.fsm.util.FSMHelpers
+import org.eclipse.etrice.core.fsm.fSM.ModelComponent
+import org.eclipse.etrice.core.genmodel.fsm.fsmgen.Graph
class ExtendedFsmGenBuilder extends BasicFsmGenBuilder {
@@ -49,6 +51,10 @@ class ExtendedFsmGenBuilder extends BasicFsmGenBuilder {
this.validator = if(validator === null) new NullDiagnostician else validator
}
+ override GraphContainer createTransformedModel(ModelComponent mc) {
+ super.createTransformedModel(mc).check(mc)
+ }
+
/**
* computes the available triggers for all leaf states
*/
@@ -229,6 +235,32 @@ class ExtendedFsmGenBuilder extends BasicFsmGenBuilder {
return it
}
+ def protected check(GraphContainer gc, ModelComponent mc) {
+ if (!mc.isAbstract) {
+ gc.eAllContents.toIterable.filter(Graph).forEach[checkInitialTransition(mc)]
+ }
+ return gc
+ }
+
+ def protected checkInitialTransition(Graph graph, ModelComponent mc) {
+ if (graph.initialTransition!==null) {
+ // graph has an initial transition
+ return
+ }
+
+ if (graph.eContainer instanceof GraphContainer) {
+ validationError("Top level state graph must have an initial transition", mc, FSMPackage.Literals.MODEL_COMPONENT__STATE_MACHINE);
+ return;
+ }
+
+ // in the super state graph search for a transition which points to our parent state
+ val parentState = graph.eContainer as Node
+ val parentGraph = parentState.eContainer as Graph
+ if (!parentGraph.links.filter[target==parentState].empty) {
+ validationError("The state graph has transitions to history in its parent graph, thus it must have an initial transition", parentState.stateGraphNode, FSMPackage.Literals.STATE__SUBGRAPH);
+ }
+ }
+
protected def void validationError(String msg, EObject obj, EStructuralFeature feature) {
validationError(msg, obj, feature, IDiagnostician.INSIGNIFICANT_INDEX)
}
diff --git a/plugins/org.eclipse.etrice.generator.fsm/src/org/eclipse/etrice/generator/fsm/generic/AbstractStateMachineGenerator.xtend b/plugins/org.eclipse.etrice.generator.fsm/src/org/eclipse/etrice/generator/fsm/generic/AbstractStateMachineGenerator.xtend
index 2c09bd179..3d77819e6 100644
--- a/plugins/org.eclipse.etrice.generator.fsm/src/org/eclipse/etrice/generator/fsm/generic/AbstractStateMachineGenerator.xtend
+++ b/plugins/org.eclipse.etrice.generator.fsm/src/org/eclipse/etrice/generator/fsm/generic/AbstractStateMachineGenerator.xtend
@@ -405,10 +405,14 @@ abstract class AbstractStateMachineGenerator {
«IF generateImplementation»
«publicIf»void «opScope»executeInitTransition(«selfOnly») {
«var initt = gc.graph.initialTransition»
- int chain__et = «chainIDScope»«initt.genChainId»;
- «stateType» next__et = «opScopePriv»executeTransitionChain(«langExt.selfPointer(true)»chain__et«IF handleEvents», «langExt.nullPointer», «langExt.nullPointer»«ENDIF»);
- next__et = «opScopePriv»enterHistory(«langExt.selfPointer(true)»next__et«IF usesHdlr», «langExt.booleanConstant(false)»«ENDIF»);
- setState(«langExt.selfPointer(true)»next__et);
+ «IF initt===null»
+ /* no initial transition allowed for abstract actor class */
+ «ELSE»
+ int chain__et = «chainIDScope»«initt.genChainId»;
+ «stateType» next__et = «opScopePriv»executeTransitionChain(«langExt.selfPointer(true)»chain__et«IF handleEvents», «langExt.nullPointer», «langExt.nullPointer»«ENDIF»);
+ next__et = «opScopePriv»enterHistory(«langExt.selfPointer(true)»next__et«IF usesHdlr», «langExt.booleanConstant(false)»«ENDIF»);
+ setState(«langExt.selfPointer(true)»next__et);
+ «ENDIF»
}
«ELSE»
void «opScope»executeInitTransition(«selfOnly»);
diff --git a/tests/org.eclipse.etrice.abstractexec.behavior.tests/models/reachability.room b/tests/org.eclipse.etrice.abstractexec.behavior.tests/models/reachability.room
index 33cae1ad3..12c179f65 100644
--- a/tests/org.eclipse.etrice.abstractexec.behavior.tests/models/reachability.room
+++ b/tests/org.eclipse.etrice.abstractexec.behavior.tests/models/reachability.room
@@ -9,7 +9,6 @@ RoomModel Reachability {
ActorRef testee2: Testee_ac
LogicalThread dflt_thread
}
-
ActorClass Testee_Super_ac {
Structure {
Port p: ReachabilityProtocol
@@ -173,6 +172,7 @@ RoomModel Reachability {
<in2: p>
}
}
+ Transition init: initial -> state0_1
ChoicePoint cp0_1
EntryPoint tp0_1
ExitPoint tp1_1
diff --git a/tests/org.eclipse.etrice.abstractexec.behavior.tests/src/org/eclipse/etrice/abstractexec/behavior/tests/TestReachability.java b/tests/org.eclipse.etrice.abstractexec.behavior.tests/src/org/eclipse/etrice/abstractexec/behavior/tests/TestReachability.java
index 83d3da384..22af53082 100644
--- a/tests/org.eclipse.etrice.abstractexec.behavior.tests/src/org/eclipse/etrice/abstractexec/behavior/tests/TestReachability.java
+++ b/tests/org.eclipse.etrice.abstractexec.behavior.tests/src/org/eclipse/etrice/abstractexec/behavior/tests/TestReachability.java
@@ -63,19 +63,21 @@ public class TestReachability extends TestBase {
}
List<AbstractValidationDiagnostic> diagnostics = getIssueCode2diagnostic().get(ReachabilityValidator.DIAG_CODE_UNREACHABLE);
- for (AbstractValidationDiagnostic d : diagnostics) {
- if (d instanceof FeatureBasedDiagnostic) {
- FeatureBasedDiagnostic dx = (FeatureBasedDiagnostic) d;
- StateGraph graph = (StateGraph) dx.getSourceEObject();
- Object feature = graph.eGet(dx.getFeature());
- if (feature instanceof EList) {
- EList<?> list = (EList<?>) feature;
- Object source = list.get(dx.getIndex());
- if (source instanceof StateGraphItem) {
- checkUnreachable((StateGraphItem) source);
- items.remove(source);
- } else
- Assert.fail("unexpected test item:" + source);
+ if (diagnostics!=null) {
+ for (AbstractValidationDiagnostic d : diagnostics) {
+ if (d instanceof FeatureBasedDiagnostic) {
+ FeatureBasedDiagnostic dx = (FeatureBasedDiagnostic) d;
+ StateGraph graph = (StateGraph) dx.getSourceEObject();
+ Object feature = graph.eGet(dx.getFeature());
+ if (feature instanceof EList) {
+ EList<?> list = (EList<?>) feature;
+ Object source = list.get(dx.getIndex());
+ if (source instanceof StateGraphItem) {
+ checkUnreachable((StateGraphItem) source);
+ items.remove(source);
+ } else
+ Assert.fail("unexpected test item:" + source);
+ }
}
}
}
diff --git a/tests/org.eclipse.etrice.generator.common.tests/build.gradle b/tests/org.eclipse.etrice.generator.common.tests/build.gradle
index 8996edebe..69e2ae560 100644
--- a/tests/org.eclipse.etrice.generator.common.tests/build.gradle
+++ b/tests/org.eclipse.etrice.generator.common.tests/build.gradle
@@ -24,7 +24,7 @@ def tests = [
choicePointTestExtended: ['models/ChoicePointTestExtended.room', genericPhysical],
dataDrivenTest: ['models/DataDrivenTest.room', genericPhysical],
/* enumTest: ['models/EnumTest.room', genericPhysical], not supported in c++ */
- compileTest: ['models/CompileTest.room', genericPhysical, 'models/StatemachineInterfaceTest.room', 'models/StatemachineInterfaceInheritedTest.room', 'models/StatemachineInterfaceTest.room', 'models/ContinuationTransitionTest.room'],
+ compileTest: ['models/CompileTest.room', genericPhysical, 'models/StatemachineInterfaceTest.room', 'models/StatemachineInterfaceInheritedTest.room', 'models/StatemachineInterfaceTest.room', 'models/ContinuationTransitionTest.room', 'models/Bug541775_NoInitialTransition.room'],
handlerTest: ['models/HandlerTest.room', genericPhysical],
operationInheritanceTest: ['models/OperationInheritanceTest.room', genericPhysical],
diff --git a/tests/org.eclipse.etrice.generator.common.tests/models/Bug541775_NoInitialTransition.room b/tests/org.eclipse.etrice.generator.common.tests/models/Bug541775_NoInitialTransition.room
new file mode 100644
index 000000000..cdeb83a8d
--- /dev/null
+++ b/tests/org.eclipse.etrice.generator.common.tests/models/Bug541775_NoInitialTransition.room
@@ -0,0 +1,24 @@
+RoomModel Bug541775_NoInitialTransition {
+
+ ProtocolClass PDummy {
+ incoming {
+ Message in1
+ }
+ }
+
+ abstract ActorClass ANoInitialTransition {
+ Structure {
+ Port p1: PDummy
+ }
+ Behavior {
+ StateMachine {
+ handler TransitionPoint tr0
+ Transition tr1: my tr0 -> my tr0 {
+ triggers {
+ <in1: p1>
+ }
+ }
+ }
+ }
+ }
+} \ No newline at end of file

Back to the top