use of org.yakindu.sct.model.sexec.ExecutionState in project statecharts by Yakindu.
the class TraceStateExitedImpl method setState.
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setState(ExecutionState newState) {
ExecutionState oldState = state;
state = newState;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, SexecPackage.TRACE_STATE_EXITED__STATE, oldState, state));
}
use of org.yakindu.sct.model.sexec.ExecutionState in project statecharts by Yakindu.
the class TraceStateEnteredImpl method setState.
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setState(ExecutionState newState) {
ExecutionState oldState = state;
state = newState;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, SexecPackage.TRACE_STATE_ENTERED__STATE, oldState, state));
}
use of org.yakindu.sct.model.sexec.ExecutionState in project statecharts by Yakindu.
the class ModelSequencerHistoryTest method testFlowName.
@SuppressWarnings("unused")
@Test
public void testFlowName() {
Statechart sc = _createStatechart("sc");
{
InterfaceScope s_scope = _createInterfaceScope("Interface", sc);
VariableDefinition v1 = _createVariableDefinition("v1", TYPE_INTEGER, s_scope);
Region r = _createRegion("r", sc);
{
Entry r_entry = _createEntry(EntryKind.INITIAL, null, r);
State s1 = _createState("s1", r);
State s2 = _createState("s2", r);
{
Region r2 = _createRegion("r2", s2);
{
Entry r2_entry1 = _createEntry(EntryKind.SHALLOW_HISTORY, null, r2);
Entry r2_entry2 = _createEntry(EntryKind.INITIAL, "Unused_Backup", r2);
State s3 = _createState("s3", r2);
State s4 = _createState("s4", r2);
_createTransition(r2_entry1, s3);
_createTransition(r2_entry2, s4);
_createTransition(s1, r2_entry1);
}
}
_createTransition(s1, s2);
Transition _t = _createTransition(s1, s2);
_createTransition(r_entry, s1);
}
}
ExecutionFlow flow = sequencer.transform(sc);
ExecutionState _s1 = flow.getStates().get(0);
assertEquals("sc.r.s1", _s1.getName());
ExecutionState _s2 = flow.getStates().get(1);
assertEquals("sc.r.s2", _s2.getName());
ExecutionState _s3 = flow.getStates().get(2);
assertEquals("sc.r.s2.r2.s3", _s3.getName());
ExecutionState _s4 = flow.getStates().get(3);
assertEquals("sc.r.s2.r2.s4", _s4.getName());
ExecutionNode r2_history_entry = flow.getNodes().get(1);
EList<Reaction> _t1 = _s1.getReactions();
Sequence reactSequence_history = flow.getNodes().get(1).getReactSequence();
HistoryEntry historyStep = (HistoryEntry) reactSequence_history.getSteps().get(0);
assertFalse(historyStep.isDeep());
assertCall(firstStep(firstStep(historyStep.getInitialStep())), _s3.getEnterSequences().get(0));
Reaction reaction_history = _t1.get(0);
assertCall(assertedSequence(reaction_history.getEffect()), 1, reactSequence_history);
Sequence reactSequence_initial = flow.getNodes().get(2).getReactSequence();
assertCall(((Sequence) firstStep(firstStep(reactSequence_initial))), 0, _s4.getEnterSequences().get(0));
Reaction reaction = _t1.get(1);
assertCall(assertedSequence(reaction.getEffect()), 1, _s2.getEnterSequences().get(0));
assertCall(_s3.getSuperScope().getEnterSequences().get(0), 0, r2_history_entry.getReactSequence());
Step saveStep = _s3.getEnterSequences().get(0).getSteps().get(1);
assertTrue(saveStep.eClass().toString(), saveStep instanceof SaveHistory);
saveStep = _s4.getEnterSequences().get(0).getSteps().get(1);
assertTrue(saveStep.eClass().toString(), saveStep instanceof SaveHistory);
}
use of org.yakindu.sct.model.sexec.ExecutionState in project statecharts by Yakindu.
the class ModelSequencerStateTest method testStateCycle_WithLocalReactionsOnly.
/**
* The cycle sequence of a state that only consists of local reactions
* includes sequential processing of the local reactions.
*/
@SuppressWarnings("unused")
@Test
public void testStateCycle_WithLocalReactionsOnly() {
MinimalTSC tsc = new MinimalTSC();
VariableDefinition v1 = _createVariableDefinition("v1", TYPE_INTEGER, tsc.s_scope);
// the first local reaction conforms to "e1 / x=42;"
LocalReaction lr1 = _createLocalReaction(tsc.s1, null);
_createRegularEventSpec(tsc.e1, (ReactionTrigger) lr1.getTrigger());
ReactionEffect lr1_eff = _createReactionEffect(lr1);
AssignmentExpression assign1 = _createVariableAssignment(v1, AssignmentOperator.ASSIGN, _createValue(42), lr1_eff);
// the secont local reaction conforms to "e1 [x==42] / x=0;"
LocalReaction lr2 = _createLocalReaction(tsc.s1, null);
_createRegularEventSpec(tsc.e1, (ReactionTrigger) lr2.getTrigger());
LogicalRelationExpression lr2_equals = ExpressionsFactory.eINSTANCE.createLogicalRelationExpression();
lr2_equals.setOperator(RelationalOperator.EQUALS);
ElementReferenceExpression lr2_varRef = ExpressionsFactory.eINSTANCE.createElementReferenceExpression();
lr2_varRef.setReference(v1);
PrimitiveValueExpression lr2_value = _createValue(42);
lr2_equals.setLeftOperand(lr2_varRef);
lr2_equals.setRightOperand(lr2_value);
((ReactionTrigger) lr2.getTrigger()).setGuard(createGuardExpression(lr2_equals));
ReactionEffect lr2_eff = _createReactionEffect(lr2);
AssignmentExpression assign2 = _createVariableAssignment(v1, AssignmentOperator.ASSIGN, _createValue(0), lr2_eff);
// the third local reaction conforms to: "[x==0] / x=1;"
LocalReaction lr3 = _createLocalReaction(tsc.s1, null);
LogicalRelationExpression lr3_equals = ExpressionsFactory.eINSTANCE.createLogicalRelationExpression();
lr3_equals.setOperator(RelationalOperator.EQUALS);
ElementReferenceExpression lr3_varRef = ExpressionsFactory.eINSTANCE.createElementReferenceExpression();
lr3_varRef.setReference(v1);
PrimitiveValueExpression lr3_value = _createValue(0);
lr3_equals.setLeftOperand(lr3_varRef);
lr3_equals.setRightOperand(lr3_value);
((ReactionTrigger) lr3.getTrigger()).setGuard(createGuardExpression(lr3_equals));
ReactionEffect lr3_eff = _createReactionEffect(lr3);
AssignmentExpression assign3 = _createVariableAssignment(v1, AssignmentOperator.ASSIGN, _createValue(1), lr3_eff);
ExecutionFlow flow = sequencer.transform(tsc.sc);
// test state with one outgoing transition
ExecutionState s1 = flow.getStates().get(0);
assertEquals(tsc.s1.getName(), s1.getSimpleName());
assertEquals(3, s1.getReactions().size());
assertNotNull(s1.getReactSequence());
Step step = s1.getReactSequence().getSteps().get(0);
Sequence _seq = assertedSequence(assertedSequence(assertedSequence(assertedSequence(assertedSequence(step).getSteps().get(0)).getSteps().get(0)).getSteps().get(0)).getSteps().get(0));
assertEquals(3, _seq.getSteps().size());
// check first local reaction
If _lr1 = (If) _seq.getSteps().get(0);
assertClass(ElementReferenceExpression.class, _lr1.getCheck().getCondition());
assertSame(s1.getReactions().get(0).getCheck().getCondition(), _lr1.getCheck().getCondition());
Call _lr1_eff_call = (Call) _lr1.getThenStep();
assertSame(s1.getReactions().get(0).getEffect(), _lr1_eff_call.getStep());
// check second local reaction
If _lr2 = (If) _seq.getSteps().get(1);
assertClass(LogicalAndExpression.class, _lr2.getCheck().getCondition());
assertSame(s1.getReactions().get(1).getCheck().getCondition(), _lr2.getCheck().getCondition());
Call _lr2_eff_call = (Call) _lr2.getThenStep();
assertSame(s1.getReactions().get(1).getEffect(), _lr2_eff_call.getStep());
// check the third local reaction
If _lr3 = (If) _seq.getSteps().get(2);
assertClass(LogicalRelationExpression.class, _lr3.getCheck().getCondition());
assertSame(s1.getReactions().get(2).getCheck().getCondition(), _lr3.getCheck().getCondition());
Call _lr3_eff_call = (Call) _lr3.getThenStep();
assertSame(s1.getReactions().get(2).getEffect(), _lr3_eff_call.getStep());
}
use of org.yakindu.sct.model.sexec.ExecutionState in project statecharts by Yakindu.
the class ModelSequencerStateTest method testLeafStateExitSequence.
/**
* A leaf state must have a exit sequence. This exit sequence consists of an
* exit action call and a state exit step.
*/
@Test
public void testLeafStateExitSequence() {
Statechart sc = _createStatechart("cs");
Scope scope = _createInterfaceScope("interface", sc);
VariableDefinition v1 = _createVariableDefinition("v1", TYPE_INTEGER, scope);
Region r = _createRegion("r", sc);
State s1 = _createState("s1", r);
LocalReaction entryAction = _createExitAction(s1);
_createVariableAssignment(v1, AssignmentOperator.ASSIGN, _createValue(42), (ReactionEffect) entryAction.getEffect());
ExecutionFlow flow = sequencer.transform(sc);
ExecutionState _s1 = flow.getStates().get(0);
assertEquals(s1.getName(), _s1.getSimpleName());
assertNotNull(_s1.getExitAction());
assertNotNull(_s1.getExitSequence());
assertEquals(2, _s1.getExitSequence().getSteps().size());
assertClass(ExitState.class, _s1.getExitSequence().getSteps().get(0));
assertCall(_s1.getExitSequence(), 1, _s1.getExitAction());
}
Aggregations