Search in sources :

Example 1 with TimeEventSpec

use of org.yakindu.sct.model.stext.stext.TimeEventSpec in project statecharts by Yakindu.

the class TimeEventSpecItemProvider method getText.

/**
 * This returns the label text for the adapted class.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public String getText(Object object) {
    TimeEventType labelValue = ((TimeEventSpec) object).getType();
    String label = labelValue == null ? null : labelValue.toString();
    return label == null || label.length() == 0 ? getString("_UI_TimeEventSpec_type") : getString("_UI_TimeEventSpec_type") + " " + label;
}
Also used : TimeEventType(org.yakindu.sct.model.stext.stext.TimeEventType) TimeEventSpec(org.yakindu.sct.model.stext.stext.TimeEventSpec)

Example 2 with TimeEventSpec

use of org.yakindu.sct.model.stext.stext.TimeEventSpec in project statecharts by Yakindu.

the class StextTestFactory method _createTimeEventSpec.

public static TimeEventSpec _createTimeEventSpec(TimeEventType type, Expression value, TimeUnit unit, ReactionTrigger rt) {
    TimeEventSpec timeTrigger = StextFactory.eINSTANCE.createTimeEventSpec();
    timeTrigger.setType(type);
    timeTrigger.setValue(value);
    timeTrigger.setUnit(unit);
    if (rt != null)
        rt.getTriggers().add(timeTrigger);
    return timeTrigger;
}
Also used : TimeEventSpec(org.yakindu.sct.model.stext.stext.TimeEventSpec)

Example 3 with TimeEventSpec

use of org.yakindu.sct.model.stext.stext.TimeEventSpec in project statecharts by Yakindu.

the class SCTResourceTest method testTransitionSerializing.

@Test
public void testTransitionSerializing() throws Exception {
    res.setSerializerEnabled(true);
    Transition transition = createTransition("after 10\n s [true] / 3 * 3");
    res.getContents().add(transition);
    ReactionTrigger trigger = (ReactionTrigger) transition.getTrigger();
    TimeEventSpec timeTrigger = stextFac.createTimeEventSpec();
    timeTrigger.setType(TimeEventType.EVERY);
    timeTrigger.setUnit(TimeUnit.SECOND);
    PrimitiveValueExpression exp = expFac.createPrimitiveValueExpression();
    IntLiteral literal = expFac.createIntLiteral();
    literal.setValue(42);
    exp.setValue(literal);
    timeTrigger.setValue(exp);
    trigger.getTriggers().add(timeTrigger);
    assertEquals("after 10\n s , every 42 s [true] / 3 * 3", transition.getSpecification());
    assertEquals("" + res.getErrors(), 0, res.getErrors().size());
}
Also used : ReactionTrigger(org.yakindu.sct.model.stext.stext.ReactionTrigger) Transition(org.yakindu.sct.model.sgraph.Transition) IntLiteral(org.yakindu.base.expressions.expressions.IntLiteral) TimeEventSpec(org.yakindu.sct.model.stext.stext.TimeEventSpec) PrimitiveValueExpression(org.yakindu.base.expressions.expressions.PrimitiveValueExpression) Test(org.junit.Test)

Aggregations

TimeEventSpec (org.yakindu.sct.model.stext.stext.TimeEventSpec)3 Test (org.junit.Test)1 IntLiteral (org.yakindu.base.expressions.expressions.IntLiteral)1 PrimitiveValueExpression (org.yakindu.base.expressions.expressions.PrimitiveValueExpression)1 Transition (org.yakindu.sct.model.sgraph.Transition)1 ReactionTrigger (org.yakindu.sct.model.stext.stext.ReactionTrigger)1 TimeEventType (org.yakindu.sct.model.stext.stext.TimeEventType)1