Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenrik Rentz-Reichert2019-10-11 15:09:55 +0000
committerGerrit Code Review @ Eclipse.org2019-10-11 15:09:56 +0000
commitad0bc76a408854724e435312d0660d6ba6d9f7e1 (patch)
tree5b80458a1aa2488925db30f1239fbb69ad733601
parent450084d29b75b624d81abf7b2bb3975fa9a77c79 (diff)
parentdc6f84b6d54721849d419d098436f4deb27f9b3b (diff)
downloadorg.eclipse.etrice-ad0bc76a408854724e435312d0660d6ba6d9f7e1.tar.gz
org.eclipse.etrice-ad0bc76a408854724e435312d0660d6ba6d9f7e1.tar.xz
org.eclipse.etrice-ad0bc76a408854724e435312d0660d6ba6d9f7e1.zip
Merge "Bug 551966 - [fsm] allow subgraphs without init transition"
-rw-r--r--plugins/org.eclipse.etrice.core.genmodel.fsm/src/org/eclipse/etrice/core/genmodel/fsm/ExtendedFsmGenBuilder.xtend14
-rw-r--r--tests/org.eclipse.etrice.core.genmodel.fsm.tests/models/HierFSMInitTransition.room55
-rw-r--r--tests/org.eclipse.etrice.core.genmodel.fsm.tests/src/org/eclipse/etrice/core/genmodel/fsm/tests/TestFSMInitTransition.xtend43
3 files changed, 107 insertions, 5 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 a26ee681f..f0aca95f2 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
@@ -20,20 +20,20 @@ import org.eclipse.emf.ecore.EObject
import org.eclipse.emf.ecore.EStructuralFeature
import org.eclipse.etrice.core.fsm.fSM.FSMPackage
import org.eclipse.etrice.core.fsm.fSM.MessageFromIf
+import org.eclipse.etrice.core.fsm.fSM.ModelComponent
import org.eclipse.etrice.core.fsm.fSM.State
import org.eclipse.etrice.core.fsm.fSM.TransitionPoint
import org.eclipse.etrice.core.fsm.fSM.Trigger
import org.eclipse.etrice.core.fsm.fSM.TriggeredTransition
+import org.eclipse.etrice.core.fsm.util.FSMHelpers
import org.eclipse.etrice.core.genmodel.fsm.fsmgen.CommonTrigger
import org.eclipse.etrice.core.genmodel.fsm.fsmgen.FsmGenFactory
+import org.eclipse.etrice.core.genmodel.fsm.fsmgen.Graph
import org.eclipse.etrice.core.genmodel.fsm.fsmgen.GraphContainer
import org.eclipse.etrice.core.genmodel.fsm.fsmgen.Link
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 {
@@ -256,8 +256,12 @@ class ExtendedFsmGenBuilder extends BasicFsmGenBuilder {
// 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);
+ val parentHasHistoryTransitions = parentGraph.links
+ .filter[target==parentState] // parent is target
+ .filter[source!=parentState] // parent is not source (self transition is fine)
+ .empty
+ if (!parentHasHistoryTransitions) {
+ validationError("The state graph has transitions to history in its parent graph (which are no self transitions), thus it must have an initial transition", parentState.stateGraphNode, FSMPackage.Literals.STATE__SUBGRAPH);
}
}
diff --git a/tests/org.eclipse.etrice.core.genmodel.fsm.tests/models/HierFSMInitTransition.room b/tests/org.eclipse.etrice.core.genmodel.fsm.tests/models/HierFSMInitTransition.room
new file mode 100644
index 000000000..7b09e9dad
--- /dev/null
+++ b/tests/org.eclipse.etrice.core.genmodel.fsm.tests/models/HierFSMInitTransition.room
@@ -0,0 +1,55 @@
+/*
+ * Bug 551966 - [fsm] Allow subgraph without init transition
+ */
+RoomModel HierFSMInitTransition {
+
+ ActorClass TestActor {
+ Interface {
+ Port p0: PC
+ }
+ Structure {
+ external Port p0
+ }
+ Behavior {
+ StateMachine {
+ State state0
+
+ State state1 {
+ subgraph {
+ EntryPoint tr0
+ ExitPoint tr1
+ Transition tr2: my tr0 -> state0
+ State state0
+ Transition tr3: state0 -> my tr1 {
+ triggers {
+ <in1: p0>
+ }
+ }
+ }
+ }
+ Transition init0: initial -> state0
+ State state2
+ Transition tr0: state0 -> tr0 of state1 {
+ triggers {
+ <in1: p0>
+ }
+ }
+ Transition tr1: tr1 of state1 -> state2
+ Transition tr2: state1 -> state1 {
+ triggers {
+ <in1: p0>
+ }
+ }
+ }
+ }
+ }
+
+ ProtocolClass PC {
+ incoming {
+ Message in1()
+ Message in2()
+ }
+ outgoing {
+ }
+ }
+}
diff --git a/tests/org.eclipse.etrice.core.genmodel.fsm.tests/src/org/eclipse/etrice/core/genmodel/fsm/tests/TestFSMInitTransition.xtend b/tests/org.eclipse.etrice.core.genmodel.fsm.tests/src/org/eclipse/etrice/core/genmodel/fsm/tests/TestFSMInitTransition.xtend
new file mode 100644
index 000000000..660bbe526
--- /dev/null
+++ b/tests/org.eclipse.etrice.core.genmodel.fsm.tests/src/org/eclipse/etrice/core/genmodel/fsm/tests/TestFSMInitTransition.xtend
@@ -0,0 +1,43 @@
+/*******************************************************************************
+ * Copyright (c) 2010 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 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * CONTRIBUTORS:
+ * Juergen Haug (initial contribution)
+ *
+ *******************************************************************************/
+
+package org.eclipse.etrice.core.genmodel.fsm.tests
+
+import org.eclipse.etrice.core.genmodel.fsm.fsmgen.GraphContainer
+import org.junit.Before
+import org.junit.Test
+
+import static org.junit.Assert.assertFalse
+import static org.junit.Assert.assertNotNull
+
+/**
+ * Bug 551966 - [fsm] Allow subgraph without init transition
+ */
+class TestFSMInitTransition extends FsmGenTestBase {
+
+ GraphContainer gc
+
+ @Before
+ def void setUp() {
+ gc = getGraphContainer("HierFSMInitTransition.room", "TestActor")
+ assertNotNull("graph context was created", gc)
+ }
+
+ @Test
+ def void noErrors() {
+ // there is a check in the ExtendedFsmGenBuilder which is called during setUp
+ assertFalse("logger has no errors", diagnostician.isFailed)
+ }
+
+} \ No newline at end of file

Back to the top