Skip to content
This repository has been archived by the owner on Jan 5, 2021. It is now read-only.

Commit

Permalink
Merge pull request #732 from Yakindu/issue_566_730
Browse files Browse the repository at this point in the history
Fix issues 566 730
  • Loading branch information
terfloth committed Jun 3, 2016
2 parents 74397ed + 01bb0bf commit ff7ce12
Show file tree
Hide file tree
Showing 7 changed files with 131 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ import org.yakindu.sct.model.stext.stext.ReactionTrigger
import org.yakindu.sct.model.stext.stext.RegularEventSpec
import org.yakindu.sct.model.stext.stext.TimeEventSpec
import org.yakindu.base.expressions.expressions.ExpressionsFactory
import java.util.Collection

class BehaviorMapping {

Expand Down Expand Up @@ -603,12 +604,20 @@ class BehaviorMapping {
s.addEnterStepsForTargetsToSequence(targets, seq)
}
} else {
//in the case only sibling regions contain targets the region must be entered using the defaut enter sequence
seq.steps.add(it.enterSequences.defaultSequence.newCall)
// in the case only sibling regions contain targets the region must be entered
// using the defaut enter sequence, if this exists
it.enterSequences.defaultSequence?.newCall?.addTo(seq.steps)
}
}


/** TODO: move... */
def <T> Collection<T> addTo(T it, Collection<T> c) {
c.add(it);
c
}


def dispatch Set<ExecutionNode> allNodes(ExecutionRegion it) {
val allNodes = new HashSet<ExecutionNode>()
allNodes.addAll(nodes)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ import org.yakindu.base.types.Event
}

def Call newCall(Step step) {
// if (step == null) throw new IllegalArgumentException("Attempt to create 'null' call.")
if (step == null) throw new IllegalArgumentException("Attempt to create 'null' call.")
val r = sexecFactory.createCall
r.step = step
r
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,21 @@ public AbstractExecutionFlowSimulationEngine(Statechart statechart) {
protected void runCycle() {
try {
interpreter.runCycle();
} catch (WrappedException ex) {
handleWrappedException(ex);
} catch (Exception e) {
handleException(e);
}
}

private void handleWrappedException(WrappedException ex) {
private void handleException(Exception e) {
if (e instanceof WrappedException) {
WrappedException e1 = (WrappedException)e;
handleException(e1.getCause().getMessage(), e1.getCause());
} else handleException(e.getMessage(), e);
}

private void handleException(String message, Throwable t) {
Status errorStatus = new Status(Status.ERROR, Activator.PLUGIN_ID, ERROR_DURING_SIMULATION,
ex.getCause().getMessage(), ex.getCause());
message, t);
IStatusHandler statusHandler = DebugPlugin.getDefault().getStatusHandler(errorStatus);
try {
statusHandler.handleStatus(errorStatus, getDebugTarget());
Expand Down Expand Up @@ -116,8 +123,8 @@ public void init() {
public void start() {
try {
interpreter.enter();
} catch (WrappedException ex) {
handleWrappedException(ex);
} catch (Exception ex) {
handleException(ex);
}
}

Expand All @@ -130,8 +137,8 @@ public void resume() {
try {
suspended = false;
interpreter.resume();
} catch (WrappedException ex) {
handleWrappedException(ex);
} catch (Exception ex) {
handleException(ex);
}
}

Expand All @@ -145,8 +152,8 @@ public void stepForward() {
interpreter.resume();
interpreter.runCycle();
interpreter.suspend();
} catch (WrappedException ex) {
handleWrappedException(ex);
} catch (Exception ex) {
handleException(ex);
}
}

Expand Down
32 changes: 32 additions & 0 deletions test-plugins/org.yakindu.sct.model.sexec.test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,38 @@
<packaging>eclipse-test-plugin</packaging>
<build>
<plugins>

<plugin>
<artifactId>maven-clean-plugin</artifactId>
<configuration>
<filesets>
<fileset>
<directory>xtend-gen</directory>
<includes>
<include>**</include>
</includes>
<excludes>
<exclude>.gitignore</exclude>
<exclude>.svn/</exclude>
</excludes>
</fileset>
</filesets>
</configuration>
</plugin>

<plugin>
<groupId>org.eclipse.xtend</groupId>
<artifactId>xtend-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>


<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-surefire-plugin</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
ModelSequencerHistoryTest.class,
SelfTransitionTest.class,
StatechartEnterExistActionTest.class,
DefaultNamingServiceTest.class
DefaultNamingServiceTest.class,
NullCallTest.class
})
public class AllTests {

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/**
* Copyright (c) 2016 committers of YAKINDU and others.
* 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:
* committers of YAKINDU - initial API and implementation
*
*/
package org.yakindu.sct.model.sexec.transformation.test

import org.junit.Test
import static org.yakindu.sct.model.sgraph.test.util.SGraphTestFactory.*
import static org.yakindu.sct.model.stext.test.util.StextTestFactory.*
import static org.junit.Assert.*
import org.eclipse.emf.ecore.EObject
import org.yakindu.sct.model.sexec.Call

/**
* This test class tests transformation errors that create calls to null sequences. This covers the issues:
* - #566
*
* @author [email protected]
*/
class NullCallTest extends ModelSequencerTest {


@Test def syncEntryOnReqionsWithoutDefaultSequence() {
val tsc = new SCTTestUtil.MinimalTSC()

val s2 = _createState("S2", tsc.r)

val s2_r1 = _createRegion("r1", s2)
val s2_r1_sync = _createSynchronization(s2_r1)
val s1_t1 = _createTransition(tsc.s1, s2_r1_sync)
val s1_t1_tr = _createReactionTrigger(s1_t1)
_createRegularEventSpec(tsc.e1, s1_t1_tr)
val a = _createState("A", s2_r1)
_createTransition(s2_r1_sync, a)


val s2_r2 = _createRegion("r2", s2)
val b = _createState("B", s2_r2)
_createTransition(s2_r1_sync, b)


val flow = sequencer.transform(tsc.sc);

assertNoNullCalls(flow)

}


def void assertNoNullCalls(EObject e) {
assertFalse (e.eAllContents.filter(Call).exists[ step == null] )
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import org.yakindu.sct.model.sgraph.SGraphFactory;
import org.yakindu.sct.model.sgraph.State;
import org.yakindu.sct.model.sgraph.Statechart;
import org.yakindu.sct.model.sgraph.Synchronization;
import org.yakindu.sct.model.sgraph.Transition;
import org.yakindu.sct.model.sgraph.Vertex;
import org.yakindu.sct.model.sgraph.impl.SGraphFactoryImpl;
Expand Down Expand Up @@ -73,6 +74,13 @@ public static Entry _createEntry(EntryKind kind, String name, Region r) {
return entry;
}

public static Synchronization _createSynchronization(Region r) {
Synchronization sync = SGraphFactory.eINSTANCE.createSynchronization();
if (r != null)
r.getVertices().add(sync);
return sync;
}

public static Transition _createTransition(Vertex source, Vertex target) {
Transition t = SGraphFactory.eINSTANCE.createTransition();
t.setSource(source);
Expand Down

0 comments on commit ff7ce12

Please sign in to comment.