Search in sources :

Example 1 with CompositeSlot

use of org.yakindu.sct.model.sruntime.CompositeSlot 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 CompositeSlot

use of org.yakindu.sct.model.sruntime.CompositeSlot 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

CompositeSlot (org.yakindu.sct.model.sruntime.CompositeSlot)2 ExecutionEvent (org.yakindu.sct.model.sruntime.ExecutionEvent)2 ExecutionVariable (org.yakindu.sct.model.sruntime.ExecutionVariable)2 StyleRange (org.eclipse.swt.custom.StyleRange)1 ExecutionOperation (org.yakindu.sct.model.sruntime.ExecutionOperation)1 CompositeSlotImpl (org.yakindu.sct.model.sruntime.impl.CompositeSlotImpl)1 ExecutionEventImpl (org.yakindu.sct.model.sruntime.impl.ExecutionEventImpl)1 ExecutionVariableImpl (org.yakindu.sct.model.sruntime.impl.ExecutionVariableImpl)1