Search in sources :

Example 1 with Reaction

use of org.yakindu.sct.model.sgraph.Reaction in project statecharts by Yakindu.

the class StateImpl method getLocalReactions.

/**
 * <!-- begin-user-doc --> <!-- end-user-doc -->
 *
 * @generated NOT
 */
public EList<Reaction> getLocalReactions() {
    EList<Reaction> result = new BasicInternalEList<Reaction>(Reaction.class);
    EList<Scope> scopes = getScopes();
    for (Scope scope : scopes) {
        result.addAll(scope.getReactions());
    }
    return result;
}
Also used : Scope(org.yakindu.sct.model.sgraph.Scope) BasicInternalEList(org.eclipse.emf.ecore.util.BasicInternalEList) Reaction(org.yakindu.sct.model.sgraph.Reaction)

Example 2 with Reaction

use of org.yakindu.sct.model.sgraph.Reaction in project statecharts by Yakindu.

the class RefactoringHelper method getFirstEntryActions.

/**
 * Returns the entry actions of a state. Returns null if no entry block is
 * defined. If multiple entry blocks are defined, only the actions of the first
 * one are returned.
 *
 * @param state
 * @return list of actions of the first entry block defined in the specified
 *         state
 */
public EList<Expression> getFirstEntryActions(State state) {
    EList<Reaction> localReactions = state.getLocalReactions();
    for (Reaction reaction : localReactions) {
        Trigger trigger = reaction.getTrigger();
        if (trigger instanceof ReactionTrigger) {
            ReactionTrigger reactionTrigger = (ReactionTrigger) trigger;
            EList<EventSpec> triggers = reactionTrigger.getTriggers();
            for (EventSpec eventSpec : triggers) {
                if (eventSpec instanceof EntryEvent && reaction.getEffect() instanceof ReactionEffect) {
                    return ((ReactionEffect) reaction.getEffect()).getActions();
                }
            }
        }
    }
    return null;
}
Also used : ReactionTrigger(org.yakindu.sct.model.stext.stext.ReactionTrigger) Trigger(org.yakindu.sct.model.sgraph.Trigger) EventSpec(org.yakindu.sct.model.stext.stext.EventSpec) ReactionTrigger(org.yakindu.sct.model.stext.stext.ReactionTrigger) EntryEvent(org.yakindu.sct.model.stext.stext.EntryEvent) ReactionEffect(org.yakindu.sct.model.stext.stext.ReactionEffect) Reaction(org.yakindu.sct.model.sgraph.Reaction)

Example 3 with Reaction

use of org.yakindu.sct.model.sgraph.Reaction in project statecharts by Yakindu.

the class RefactoringHelper method getFirstExitActions.

/**
 * Returns the exit actions of a state. Returns null if no exit block is
 * defined. If multiple exit blocks are defined, only the actions of the first
 * one are returned.
 *
 * @param state
 * @return list of actions of the first exit block defined in the specified
 *         state
 */
public EList<Expression> getFirstExitActions(State state) {
    EList<Reaction> localReactions = state.getLocalReactions();
    for (Reaction reaction : localReactions) {
        Trigger trigger = reaction.getTrigger();
        if (trigger instanceof ReactionTrigger) {
            ReactionTrigger reactionTrigger = (ReactionTrigger) trigger;
            EList<EventSpec> triggers = reactionTrigger.getTriggers();
            for (EventSpec eventSpec : triggers) {
                if (eventSpec instanceof ExitEvent && reaction.getEffect() instanceof ReactionEffect) {
                    return ((ReactionEffect) reaction.getEffect()).getActions();
                }
            }
        }
    }
    return null;
}
Also used : ReactionTrigger(org.yakindu.sct.model.stext.stext.ReactionTrigger) Trigger(org.yakindu.sct.model.sgraph.Trigger) EventSpec(org.yakindu.sct.model.stext.stext.EventSpec) ReactionTrigger(org.yakindu.sct.model.stext.stext.ReactionTrigger) ReactionEffect(org.yakindu.sct.model.stext.stext.ReactionEffect) Reaction(org.yakindu.sct.model.sgraph.Reaction) ExitEvent(org.yakindu.sct.model.stext.stext.ExitEvent)

Example 4 with Reaction

use of org.yakindu.sct.model.sgraph.Reaction in project statecharts by Yakindu.

the class StextResource method serializeState.

protected void serializeState(State state) {
    if (state.getScopes().size() != 1)
        return;
    Scope scope = state.getScopes().get(0);
    EList<Reaction> reactions = scope.getReactions();
    StringBuilder builder = new StringBuilder();
    for (Reaction reaction : reactions) {
        if (builder.length() > 0)
            builder.append(NEW_LINE);
        builder.append(serializeReaction(reaction));
    }
    state.setSpecification(builder.toString());
}
Also used : Scope(org.yakindu.sct.model.sgraph.Scope) Reaction(org.yakindu.sct.model.sgraph.Reaction) TransitionReaction(org.yakindu.sct.model.stext.stext.TransitionReaction)

Example 5 with Reaction

use of org.yakindu.sct.model.sgraph.Reaction in project statecharts by Yakindu.

the class StatechartImpl method getLocalReactions.

/**
 * <!-- begin-user-doc --> <!-- end-user-doc -->
 *
 * @generated NOT
 */
public EList<Reaction> getLocalReactions() {
    EList<Reaction> result = new BasicInternalEList<Reaction>(Reaction.class);
    EList<Scope> scopes = getScopes();
    for (Scope scope : scopes) {
        result.addAll(scope.getReactions());
    }
    return result;
}
Also used : Scope(org.yakindu.sct.model.sgraph.Scope) BasicInternalEList(org.eclipse.emf.ecore.util.BasicInternalEList) Reaction(org.yakindu.sct.model.sgraph.Reaction)

Aggregations

Reaction (org.yakindu.sct.model.sgraph.Reaction)5 Scope (org.yakindu.sct.model.sgraph.Scope)3 BasicInternalEList (org.eclipse.emf.ecore.util.BasicInternalEList)2 Trigger (org.yakindu.sct.model.sgraph.Trigger)2 EventSpec (org.yakindu.sct.model.stext.stext.EventSpec)2 ReactionEffect (org.yakindu.sct.model.stext.stext.ReactionEffect)2 ReactionTrigger (org.yakindu.sct.model.stext.stext.ReactionTrigger)2 EntryEvent (org.yakindu.sct.model.stext.stext.EntryEvent)1 ExitEvent (org.yakindu.sct.model.stext.stext.ExitEvent)1 TransitionReaction (org.yakindu.sct.model.stext.stext.TransitionReaction)1