Search in sources :

Example 1 with ExecutionVariable

use of org.yakindu.sct.model.sruntime.ExecutionVariable in project statecharts by Yakindu.

the class STextInterpreterTest method initContext.

private void initContext() {
    // "event abc operation foo() var intVar : integer var boolVar : boolean
    // var realVar : real
    ExecutionVariable intVar = new ExecutionVariableImpl();
    intVar.setName("intVar");
    intVar.setFqName("intVar");
    intVar.setType(typeSystem.getType(GenericTypeSystem.INTEGER));
    intVar.setValue(0);
    context.getSlots().add(intVar);
    ExecutionVariable boolVar = new ExecutionVariableImpl();
    boolVar.setName("boolVar");
    boolVar.setFqName("boolVar");
    boolVar.setType(typeSystem.getType(GenericTypeSystem.BOOLEAN));
    boolVar.setValue(false);
    context.getSlots().add(boolVar);
    ExecutionVariable realVar = new ExecutionVariableImpl();
    realVar.setName("realVar");
    realVar.setFqName("realVar");
    realVar.setType(typeSystem.getType(GenericTypeSystem.REAL));
    realVar.setValue(0.0f);
    context.getSlots().add(realVar);
    ExecutionVariable stringVar = new ExecutionVariableImpl();
    stringVar.setName("stringVar");
    stringVar.setFqName("stringVar");
    stringVar.setType(typeSystem.getType(GenericTypeSystem.STRING));
    stringVar.setValue("");
    context.getSlots().add(stringVar);
    ExecutionEvent event = new ExecutionEventImpl();
    event.setName("abc");
    event.setFqName("abc");
    event.setType(typeSystem.getType(GenericTypeSystem.INTEGER));
    context.getSlots().add(event);
    ExecutionVariable enumVar = new ExecutionVariableImpl();
    enumVar.setName("enumVar");
    enumVar.setFqName("enumVar");
    enumVar.setType(typeSystem.getType(GenericTypeSystem.INTEGER));
    context.getSlots().add(enumVar);
    CompositeSlot cpVar = new CompositeSlotImpl();
    cpVar.setName("cpVar");
    cpVar.setFqName("cpVar");
    ExecutionVariable featureVar = new ExecutionVariableImpl();
    featureVar.setName("x");
    featureVar.setFqName("cpVar.x");
    featureVar.setType(typeSystem.getType(GenericTypeSystem.INTEGER));
    featureVar.setValue(0);
    cpVar.getSlots().add(featureVar);
    context.getSlots().add(cpVar);
}
Also used : ExecutionVariableImpl(org.yakindu.sct.model.sruntime.impl.ExecutionVariableImpl) ExecutionEventImpl(org.yakindu.sct.model.sruntime.impl.ExecutionEventImpl) ExecutionEvent(org.yakindu.sct.model.sruntime.ExecutionEvent) CompositeSlot(org.yakindu.sct.model.sruntime.CompositeSlot) CompositeSlotImpl(org.yakindu.sct.model.sruntime.impl.CompositeSlotImpl) ExecutionVariable(org.yakindu.sct.model.sruntime.ExecutionVariable)

Example 2 with ExecutionVariable

use of org.yakindu.sct.model.sruntime.ExecutionVariable in project statecharts by Yakindu.

the class AbstractExecutionFlowTest method assertVarValue.

// -> Assertion methods...
protected void assertVarValue(String variableName, Object value) {
    ExecutionVariable variable = context().getVariable(variableName);
    assertNotNull("Variable '" + variableName + "' is not defined", variable);
    assertEquals(value, variable.getValue());
}
Also used : ExecutionVariable(org.yakindu.sct.model.sruntime.ExecutionVariable)

Example 3 with ExecutionVariable

use of org.yakindu.sct.model.sruntime.ExecutionVariable in project statecharts by Yakindu.

the class FeatureParameterValueImpl method getExecutionContext.

/**
 * <!-- begin-user-doc --> <!-- end-user-doc -->
 *
 * @generated NOT
 */
protected ExecutionContext getExecutionContext() {
    if (!(EcoreUtil.getRootContainer(this) instanceof GeneratorModel)) {
        return new ExecutionContextImpl();
    }
    ExecutionContext context = new ExecutionContextImpl();
    GeneratorModel generatorModel = (GeneratorModel) EcoreUtil.getRootContainer(this);
    EList<PropertyDefinition> properties = generatorModel.getProperties();
    for (PropertyDefinition propertyDefinition : properties) {
        ExecutionVariable variable = SRuntimeFactory.eINSTANCE.createExecutionVariable();
        variable.setName(propertyDefinition.getName());
        variable.setFqName(propertyDefinition.getName());
        variable.setType(propertyDefinition.getType());
        variable.setValue(interpreter.evaluate(propertyDefinition.getInitialValue(), context));
        context.getSlots().add(variable);
    }
    return context;
}
Also used : ExecutionContext(org.yakindu.sct.model.sruntime.ExecutionContext) ExecutionContextImpl(org.yakindu.sct.model.sruntime.impl.ExecutionContextImpl) GeneratorModel(org.yakindu.sct.model.sgen.GeneratorModel) PropertyDefinition(org.yakindu.sct.model.sgen.PropertyDefinition) ExecutionVariable(org.yakindu.sct.model.sruntime.ExecutionVariable)

Example 4 with ExecutionVariable

use of org.yakindu.sct.model.sruntime.ExecutionVariable in project statecharts by Yakindu.

the class ExecutionContextLabelProvider method updateNameCell.

private void updateNameCell(ViewerCell cell) {
    Object element = cell.getElement();
    if (element instanceof ExecutionEvent) {
        ExecutionEvent event = (ExecutionEvent) element;
        cell.setText(event.getName());
        StyleRange style1 = new StyleRange();
        style1.start = 0;
        style1.length = event.getName().length();
        style1.underline = true;
        style1.foreground = ColorConstants.lightBlue;
        cell.setText(event.getName());
        cell.setStyleRanges(new StyleRange[] { style1 });
        if (event.isRaised()) {
            cell.setImage(SimulationImages.EVENT_ENABLED.image());
        } else if (event.getName().contains("time_event")) {
            cell.setImage(SimulationImages.TIMEEVENT.image());
        } else {
            cell.setImage(SimulationImages.EVENT_DISABLED.image());
        }
    } else if (element instanceof ExecutionOperation) {
        ExecutionVariable variable = (ExecutionVariable) element;
        cell.setText(variable.getName());
        cell.setImage(SimulationImages.OPERATION.image());
    } else if (element instanceof ExecutionVariable) {
        ExecutionVariable variable = (ExecutionVariable) element;
        cell.setText(variable.getName());
        if (((ExecutionVariable) element).isWritable())
            cell.setImage(SimulationImages.VARIABLE.image());
        else
            cell.setImage(SimulationImages.VARIABLE_LOCK.image());
    } else if (element instanceof CompositeSlot) {
        cell.setText(((CompositeSlot) element).getName());
        cell.setImage(SimulationImages.SCOPE.image());
    }
}
Also used : ExecutionEvent(org.yakindu.sct.model.sruntime.ExecutionEvent) StyleRange(org.eclipse.swt.custom.StyleRange) CompositeSlot(org.yakindu.sct.model.sruntime.CompositeSlot) ExecutionOperation(org.yakindu.sct.model.sruntime.ExecutionOperation) ExecutionVariable(org.yakindu.sct.model.sruntime.ExecutionVariable)

Aggregations

ExecutionVariable (org.yakindu.sct.model.sruntime.ExecutionVariable)4 CompositeSlot (org.yakindu.sct.model.sruntime.CompositeSlot)2 ExecutionEvent (org.yakindu.sct.model.sruntime.ExecutionEvent)2 StyleRange (org.eclipse.swt.custom.StyleRange)1 GeneratorModel (org.yakindu.sct.model.sgen.GeneratorModel)1 PropertyDefinition (org.yakindu.sct.model.sgen.PropertyDefinition)1 ExecutionContext (org.yakindu.sct.model.sruntime.ExecutionContext)1 ExecutionOperation (org.yakindu.sct.model.sruntime.ExecutionOperation)1 CompositeSlotImpl (org.yakindu.sct.model.sruntime.impl.CompositeSlotImpl)1 ExecutionContextImpl (org.yakindu.sct.model.sruntime.impl.ExecutionContextImpl)1 ExecutionEventImpl (org.yakindu.sct.model.sruntime.impl.ExecutionEventImpl)1 ExecutionVariableImpl (org.yakindu.sct.model.sruntime.impl.ExecutionVariableImpl)1