Search in sources :

Example 6 with BusSubcomponent

use of org.osate.aadl2.BusSubcomponent in project VERDICT by ge-high-assurance.

the class Aadl2Vdm method getStrRepofExpr.

/**
 * @author Paul Meng
 * The calling function should know the size of the return array
 */
String[] getStrRepofExpr(PropertyExpression expr) {
    String[] values = new String[4];
    if (expr instanceof BooleanLiteralImpl) {
        BooleanLiteralImpl bool = ((BooleanLiteralImpl) expr);
        // values[0] = bool.getValue()?"1":"0";
        values[0] = bool.getValue() ? "true" : "false";
    } else if (expr instanceof IntegerLiteralImpl) {
        IntegerLiteralImpl intVal = ((IntegerLiteralImpl) expr);
        values[0] = String.valueOf((int) intVal.getValue());
    } else if (expr instanceof NamedValueImpl) {
        NamedValueImpl namedValue = ((NamedValueImpl) expr);
        if (namedValue.getNamedValue() instanceof EnumerationLiteralImpl) {
            EnumerationLiteralImpl enu = ((EnumerationLiteralImpl) namedValue.getNamedValue());
            values[0] = enu.getName();
        } else {
            throw new RuntimeException("Unsupported property value: " + namedValue.getNamedValue());
        }
    } else if (expr instanceof ListValueImpl) {
        ListValueImpl listValue = (ListValueImpl) expr;
        if (listValue.getOwnedListElements().size() == 1) {
            values = getStrRepofExpr(listValue.getOwnedListElements().get(0));
        } else {
            throw new RuntimeException("Unexpected!");
        }
    } else if (expr instanceof ReferenceValueImpl) {
        // We only consider the value of expr is a bus expression here.
        ReferenceValueImpl refValue = (ReferenceValueImpl) expr;
        if (refValue.getContainmentPathElements().size() == 1) {
            ContainmentPathElement element = refValue.getContainmentPathElements().get(0);
            NamedElement namedElement = element.getNamedElement();
            if (namedElement instanceof BusSubcomponent) {
                ComponentImplementation impl = ((BusSubcomponent) namedElement).getContainingComponentImpl();
                String compTypeName = impl.getTypeName();
                values[0] = compTypeName;
                values[1] = impl.getName();
                values[2] = "";
                values[3] = namedElement.getName();
            } else {
                throw new RuntimeException("Unexpected!");
            }
        } else if (refValue.getContainmentPathElements().size() == 2) {
            // This is to deal with the expression "subcomponent . bus"
            ContainmentPathElement elementZero = refValue.getContainmentPathElements().get(0);
            ContainmentPathElement elementOne = refValue.getContainmentPathElements().get(1);
            NamedElement namedElementZero = elementZero.getNamedElement();
            NamedElement namedElementOne = elementOne.getNamedElement();
            if (namedElementZero instanceof SystemSubcomponent) {
                ComponentImplementation impl = ((SystemSubcomponent) namedElementZero).getComponentImplementation();
                values[0] = impl.getTypeName();
                values[1] = impl.getName();
                values[2] = namedElementZero.getName();
                values[3] = namedElementOne.getName();
            } else {
                throw new RuntimeException("Unexpected!");
            }
        } else {
            throw new RuntimeException("Unexpected number of property values: " + refValue.getContainmentPathElements().size());
        }
    } else if (expr instanceof StringLiteralImpl) {
        StringLiteralImpl strVal = ((StringLiteralImpl) expr);
        values[0] = strVal.getValue();
    } else {
        throw new RuntimeException("Unsupported property value: " + expr);
    }
    return values;
}
Also used : ComponentImplementation(org.osate.aadl2.ComponentImplementation) StringLiteralImpl(org.osate.aadl2.impl.StringLiteralImpl) NamedValueImpl(org.osate.aadl2.impl.NamedValueImpl) ContainmentPathElement(org.osate.aadl2.ContainmentPathElement) BusSubcomponent(org.osate.aadl2.BusSubcomponent) BooleanLiteralImpl(org.osate.aadl2.impl.BooleanLiteralImpl) ReferenceValueImpl(org.osate.aadl2.impl.ReferenceValueImpl) EnumerationLiteralImpl(org.osate.aadl2.impl.EnumerationLiteralImpl) SystemSubcomponent(org.osate.aadl2.SystemSubcomponent) IntegerLiteralImpl(org.osate.aadl2.impl.IntegerLiteralImpl) ListValueImpl(org.osate.aadl2.impl.ListValueImpl) ContainedNamedElement(org.osate.aadl2.ContainedNamedElement) NamedElement(org.osate.aadl2.NamedElement)

Example 7 with BusSubcomponent

use of org.osate.aadl2.BusSubcomponent in project VERDICT by ge-high-assurance.

the class Aadl2CsvTranslator method getStrRepofExpr.

/**
 * The calling function should know the size of the return array
 */
String[] getStrRepofExpr(PropertyExpression expr) {
    String[] values = new String[4];
    if (expr instanceof BooleanLiteralImpl) {
        BooleanLiteralImpl bool = ((BooleanLiteralImpl) expr);
        values[0] = bool.getValue() ? "1" : "0";
    } else if (expr instanceof IntegerLiteralImpl) {
        IntegerLiteralImpl intVal = ((IntegerLiteralImpl) expr);
        values[0] = String.valueOf((int) intVal.getValue());
    } else if (expr instanceof NamedValueImpl) {
        NamedValueImpl namedValue = ((NamedValueImpl) expr);
        if (namedValue.getNamedValue() instanceof EnumerationLiteralImpl) {
            EnumerationLiteralImpl enu = ((EnumerationLiteralImpl) namedValue.getNamedValue());
            values[0] = enu.getName();
        } else {
            throw new RuntimeException("Unsupported property value: " + namedValue.getNamedValue());
        }
    } else if (expr instanceof ListValueImpl) {
        ListValueImpl listValue = (ListValueImpl) expr;
        if (listValue.getOwnedListElements().size() == 1) {
            values = getStrRepofExpr(listValue.getOwnedListElements().get(0));
        } else {
            throw new RuntimeException("Unexpected!");
        }
    } else if (expr instanceof ReferenceValueImpl) {
        // We only consider the value of expr is a bus expression here.
        ReferenceValueImpl refValue = (ReferenceValueImpl) expr;
        if (refValue.getContainmentPathElements().size() == 1) {
            ContainmentPathElement element = refValue.getContainmentPathElements().get(0);
            NamedElement namedElement = element.getNamedElement();
            if (namedElement instanceof BusSubcomponent) {
                ComponentImplementation impl = ((BusSubcomponent) namedElement).getContainingComponentImpl();
                String compTypeName = impl.getTypeName();
                values[0] = compTypeName;
                values[1] = impl.getName();
                values[2] = "";
                values[3] = namedElement.getName();
            } else {
                throw new RuntimeException("Unexpected!");
            }
        } else if (refValue.getContainmentPathElements().size() == 2) {
            // This is to deal with the expression "subcomponent . bus"
            ContainmentPathElement elementZero = refValue.getContainmentPathElements().get(0);
            ContainmentPathElement elementOne = refValue.getContainmentPathElements().get(1);
            NamedElement namedElementZero = elementZero.getNamedElement();
            NamedElement namedElementOne = elementOne.getNamedElement();
            if (namedElementZero instanceof SystemSubcomponent) {
                ComponentImplementation impl = ((SystemSubcomponent) namedElementZero).getComponentImplementation();
                values[0] = impl.getTypeName();
                values[1] = impl.getName();
                values[2] = namedElementZero.getName();
                values[3] = namedElementOne.getName();
            } else {
                throw new RuntimeException("Unexpected!");
            }
        } else {
            throw new RuntimeException("Unexpected number of property values: " + refValue.getContainmentPathElements().size());
        }
    } else if (expr instanceof StringLiteralImpl) {
        StringLiteralImpl strVal = ((StringLiteralImpl) expr);
        values[0] = strVal.getValue();
    } else {
        throw new RuntimeException("Unsupported property value: " + expr);
    }
    return values;
}
Also used : ComponentImplementation(org.osate.aadl2.ComponentImplementation) StringLiteralImpl(org.osate.aadl2.impl.StringLiteralImpl) NamedValueImpl(org.osate.aadl2.impl.NamedValueImpl) ContainmentPathElement(org.osate.aadl2.ContainmentPathElement) BusSubcomponent(org.osate.aadl2.BusSubcomponent) BooleanLiteralImpl(org.osate.aadl2.impl.BooleanLiteralImpl) ReferenceValueImpl(org.osate.aadl2.impl.ReferenceValueImpl) EnumerationLiteralImpl(org.osate.aadl2.impl.EnumerationLiteralImpl) SystemSubcomponent(org.osate.aadl2.SystemSubcomponent) IntegerLiteralImpl(org.osate.aadl2.impl.IntegerLiteralImpl) ListValueImpl(org.osate.aadl2.impl.ListValueImpl) ContainedNamedElement(org.osate.aadl2.ContainedNamedElement) NamedElement(org.osate.aadl2.NamedElement)

Example 8 with BusSubcomponent

use of org.osate.aadl2.BusSubcomponent in project osate2 by osate.

the class DeviceImplementationImpl method createOwnedBusSubcomponent.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public BusSubcomponent createOwnedBusSubcomponent() {
    BusSubcomponent newOwnedBusSubcomponent = (BusSubcomponent) create(Aadl2Package.eINSTANCE.getBusSubcomponent());
    getOwnedBusSubcomponents().add(newOwnedBusSubcomponent);
    return newOwnedBusSubcomponent;
}
Also used : BusSubcomponent(org.osate.aadl2.BusSubcomponent) VirtualBusSubcomponent(org.osate.aadl2.VirtualBusSubcomponent)

Example 9 with BusSubcomponent

use of org.osate.aadl2.BusSubcomponent in project osate2 by osate.

the class SystemImplementationImpl method createOwnedBusSubcomponent.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public BusSubcomponent createOwnedBusSubcomponent() {
    BusSubcomponent newOwnedBusSubcomponent = (BusSubcomponent) create(Aadl2Package.eINSTANCE.getBusSubcomponent());
    getOwnedBusSubcomponents().add(newOwnedBusSubcomponent);
    return newOwnedBusSubcomponent;
}
Also used : BusSubcomponent(org.osate.aadl2.BusSubcomponent) VirtualBusSubcomponent(org.osate.aadl2.VirtualBusSubcomponent)

Example 10 with BusSubcomponent

use of org.osate.aadl2.BusSubcomponent in project osate2 by osate.

the class AadlSubcomponentUtil method setClassifier.

public static void setClassifier(final Subcomponent sc, final SubcomponentType selectedSubcomponentType) {
    // Import as necessary
    if (selectedSubcomponentType != null) {
        // Import its package if necessary
        final AadlPackage pkg = (AadlPackage) sc.getElementRoot();
        if (selectedSubcomponentType instanceof ComponentClassifier && selectedSubcomponentType.getNamespace() != null && pkg != null) {
            final PackageSection section = pkg.getPublicSection();
            final AadlPackage selectedClassifierPkg = (AadlPackage) selectedSubcomponentType.getNamespace().getOwner();
            if (selectedClassifierPkg != null && pkg != selectedClassifierPkg) {
                AadlImportsUtil.addImportIfNeeded(section, selectedClassifierPkg);
            }
        }
    }
    if (sc instanceof SystemSubcomponent) {
        ((SystemSubcomponent) sc).setSystemSubcomponentType((SystemSubcomponentType) selectedSubcomponentType);
    } else if (sc instanceof AbstractSubcomponent) {
        ((AbstractSubcomponent) sc).setAbstractSubcomponentType((AbstractSubcomponentType) selectedSubcomponentType);
    } else if (sc instanceof ThreadGroupSubcomponent) {
        ((ThreadGroupSubcomponent) sc).setThreadGroupSubcomponentType((ThreadGroupSubcomponentType) selectedSubcomponentType);
    } else if (sc instanceof ThreadSubcomponent) {
        ((ThreadSubcomponent) sc).setThreadSubcomponentType((ThreadSubcomponentType) selectedSubcomponentType);
    } else if (sc instanceof SubprogramSubcomponent) {
        ((SubprogramSubcomponent) sc).setSubprogramSubcomponentType((SubprogramSubcomponentType) selectedSubcomponentType);
    } else if (sc instanceof SubprogramGroupSubcomponent) {
        ((SubprogramGroupSubcomponent) sc).setSubprogramGroupSubcomponentType((SubprogramGroupSubcomponentType) selectedSubcomponentType);
    } else if (sc instanceof DataSubcomponent) {
        ((DataSubcomponent) sc).setDataSubcomponentType((DataSubcomponentType) selectedSubcomponentType);
    } else if (sc instanceof VirtualBusSubcomponent) {
        ((VirtualBusSubcomponent) sc).setVirtualBusSubcomponentType((VirtualBusSubcomponentType) selectedSubcomponentType);
    } else if (sc instanceof VirtualProcessorSubcomponent) {
        ((VirtualProcessorSubcomponent) sc).setVirtualProcessorSubcomponentType((VirtualProcessorSubcomponentType) selectedSubcomponentType);
    } else if (sc instanceof BusSubcomponent) {
        ((BusSubcomponent) sc).setBusSubcomponentType((BusSubcomponentType) selectedSubcomponentType);
    } else if (sc instanceof ProcessSubcomponent) {
        ((ProcessSubcomponent) sc).setProcessSubcomponentType((ProcessSubcomponentType) selectedSubcomponentType);
    } else if (sc instanceof ProcessorSubcomponent) {
        ((ProcessorSubcomponent) sc).setProcessorSubcomponentType((ProcessorSubcomponentType) selectedSubcomponentType);
    } else if (sc instanceof DeviceSubcomponent) {
        ((DeviceSubcomponent) sc).setDeviceSubcomponentType((DeviceSubcomponentType) selectedSubcomponentType);
    } else if (sc instanceof MemorySubcomponent) {
        ((MemorySubcomponent) sc).setMemorySubcomponentType((MemorySubcomponentType) selectedSubcomponentType);
    } else {
        throw new RuntimeException("Unexpected type: " + sc.getClass().getName());
    }
}
Also used : ComponentClassifier(org.osate.aadl2.ComponentClassifier) ThreadSubcomponentType(org.osate.aadl2.ThreadSubcomponentType) PackageSection(org.osate.aadl2.PackageSection) AbstractSubcomponent(org.osate.aadl2.AbstractSubcomponent) ProcessorSubcomponentType(org.osate.aadl2.ProcessorSubcomponentType) VirtualProcessorSubcomponentType(org.osate.aadl2.VirtualProcessorSubcomponentType) SubprogramGroupSubcomponent(org.osate.aadl2.SubprogramGroupSubcomponent) AbstractSubcomponentType(org.osate.aadl2.AbstractSubcomponentType) VirtualBusSubcomponentType(org.osate.aadl2.VirtualBusSubcomponentType) BusSubcomponentType(org.osate.aadl2.BusSubcomponentType) DeviceSubcomponent(org.osate.aadl2.DeviceSubcomponent) MemorySubcomponentType(org.osate.aadl2.MemorySubcomponentType) ThreadGroupSubcomponent(org.osate.aadl2.ThreadGroupSubcomponent) SubprogramGroupSubcomponentType(org.osate.aadl2.SubprogramGroupSubcomponentType) ProcessorSubcomponent(org.osate.aadl2.ProcessorSubcomponent) VirtualProcessorSubcomponent(org.osate.aadl2.VirtualProcessorSubcomponent) MemorySubcomponent(org.osate.aadl2.MemorySubcomponent) SubprogramSubcomponent(org.osate.aadl2.SubprogramSubcomponent) VirtualBusSubcomponentType(org.osate.aadl2.VirtualBusSubcomponentType) AadlPackage(org.osate.aadl2.AadlPackage) VirtualBusSubcomponent(org.osate.aadl2.VirtualBusSubcomponent) VirtualProcessorSubcomponent(org.osate.aadl2.VirtualProcessorSubcomponent) BusSubcomponent(org.osate.aadl2.BusSubcomponent) VirtualBusSubcomponent(org.osate.aadl2.VirtualBusSubcomponent) ThreadSubcomponent(org.osate.aadl2.ThreadSubcomponent) SystemSubcomponent(org.osate.aadl2.SystemSubcomponent) ProcessSubcomponent(org.osate.aadl2.ProcessSubcomponent) DataSubcomponent(org.osate.aadl2.DataSubcomponent)

Aggregations

BusSubcomponent (org.osate.aadl2.BusSubcomponent)10 VirtualBusSubcomponent (org.osate.aadl2.VirtualBusSubcomponent)6 SystemSubcomponent (org.osate.aadl2.SystemSubcomponent)5 ContainedNamedElement (org.osate.aadl2.ContainedNamedElement)4 ContainmentPathElement (org.osate.aadl2.ContainmentPathElement)4 AbstractSubcomponent (org.osate.aadl2.AbstractSubcomponent)3 DataSubcomponent (org.osate.aadl2.DataSubcomponent)3 DeviceSubcomponent (org.osate.aadl2.DeviceSubcomponent)3 MemorySubcomponent (org.osate.aadl2.MemorySubcomponent)3 ProcessSubcomponent (org.osate.aadl2.ProcessSubcomponent)3 SubprogramSubcomponent (org.osate.aadl2.SubprogramSubcomponent)3 ThreadGroupSubcomponent (org.osate.aadl2.ThreadGroupSubcomponent)3 ThreadSubcomponent (org.osate.aadl2.ThreadSubcomponent)3 VirtualProcessorSubcomponent (org.osate.aadl2.VirtualProcessorSubcomponent)3 AadlPackage (org.osate.aadl2.AadlPackage)2 BusAccess (org.osate.aadl2.BusAccess)2 ComponentImplementation (org.osate.aadl2.ComponentImplementation)2 DataAccess (org.osate.aadl2.DataAccess)2 DataPort (org.osate.aadl2.DataPort)2 EventDataPort (org.osate.aadl2.EventDataPort)2