Search in sources :

Example 6 with SubcomponentType

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

the class SubcomponentImpl method getSubcomponentType.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated NOT
 */
public SubcomponentType getSubcomponentType() {
    SubcomponentType subcomponentType = basicGetSubcomponentType();
    subcomponentType = subcomponentType != null && ((EObject) subcomponentType).eIsProxy() ? (SubcomponentType) eResolveProxy((InternalEObject) subcomponentType) : subcomponentType;
    return subcomponentType == null || subcomponentType.eIsProxy() ? null : subcomponentType;
}
Also used : SubcomponentType(org.osate.aadl2.SubcomponentType) InternalEObject(org.eclipse.emf.ecore.InternalEObject)

Example 7 with SubcomponentType

use of org.osate.aadl2.SubcomponentType 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)

Example 8 with SubcomponentType

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

the class AadlSubcomponentUtil method getAllSubcomponentType.

// Helper Methods
private static SubcomponentType getAllSubcomponentType(Subcomponent sc) {
    SubcomponentType scType;
    do {
        scType = sc.getSubcomponentType();
        sc = sc.getRefined();
    } while (sc != null && scType == null);
    return scType;
}
Also used : SubcomponentType(org.osate.aadl2.SubcomponentType) AbstractSubcomponentType(org.osate.aadl2.AbstractSubcomponentType) SubprogramGroupSubcomponentType(org.osate.aadl2.SubprogramGroupSubcomponentType) SystemSubcomponentType(org.osate.aadl2.SystemSubcomponentType) MemorySubcomponentType(org.osate.aadl2.MemorySubcomponentType) ProcessSubcomponentType(org.osate.aadl2.ProcessSubcomponentType) SubprogramSubcomponentType(org.osate.aadl2.SubprogramSubcomponentType) DeviceSubcomponentType(org.osate.aadl2.DeviceSubcomponentType) ProcessorSubcomponentType(org.osate.aadl2.ProcessorSubcomponentType) ThreadSubcomponentType(org.osate.aadl2.ThreadSubcomponentType) VirtualBusSubcomponentType(org.osate.aadl2.VirtualBusSubcomponentType) BusSubcomponentType(org.osate.aadl2.BusSubcomponentType) DataSubcomponentType(org.osate.aadl2.DataSubcomponentType) ThreadGroupSubcomponentType(org.osate.aadl2.ThreadGroupSubcomponentType) VirtualProcessorSubcomponentType(org.osate.aadl2.VirtualProcessorSubcomponentType)

Example 9 with SubcomponentType

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

the class AadlSubcomponentUtil method getSubcomponentTypeDescription.

/**
 * Returns null if it is unable to build a non-empty string.
 * @param sc
 * @return
 */
public static String getSubcomponentTypeDescription(final Subcomponent sc, final BusinessObjectContext scBoc) {
    // Get top level component implementation.
    NamedElement implRoot = null;
    for (BusinessObjectContext tmpBoc = scBoc.getParent(); tmpBoc != null; tmpBoc = tmpBoc.getParent()) {
        if (tmpBoc.getBusinessObject() instanceof ComponentImplementation) {
            implRoot = ((ComponentImplementation) tmpBoc.getBusinessObject()).getElementRoot();
        }
    }
    String retVal = "";
    final SubcomponentType scType = getAllSubcomponentType(sc);
    if (scType != null) {
        retVal += scType.getElementRoot() == implRoot ? scType.getName() : scType.getQualifiedName();
    }
    // Add text for each of the implementation references (for arrays)
    final List<ComponentImplementationReference> implRefs = getArrayComponentImplementationReferences(sc);
    if (implRefs.size() != 0) {
        retVal += "\n(";
        for (int i = 0; i < implRefs.size(); i++) {
            final ComponentImplementationReference ref = implRefs.get(i);
            if (ref.getImplementation() != null) {
                if (ref.getImplementation().eIsProxy()) {
                    retVal += "<unresolved>";
                } else {
                    retVal += ref.getImplementation().getElementRoot() == implRoot ? ref.getImplementation().getName() : ref.getImplementation().getQualifiedName();
                }
            }
            if (i == (implRefs.size() - 1)) {
                retVal += ")";
            } else {
                retVal += ",\n";
            }
        }
    }
    return retVal.length() == 0 ? null : retVal;
}
Also used : ComponentImplementation(org.osate.aadl2.ComponentImplementation) ComponentImplementationReference(org.osate.aadl2.ComponentImplementationReference) SubcomponentType(org.osate.aadl2.SubcomponentType) AbstractSubcomponentType(org.osate.aadl2.AbstractSubcomponentType) SubprogramGroupSubcomponentType(org.osate.aadl2.SubprogramGroupSubcomponentType) SystemSubcomponentType(org.osate.aadl2.SystemSubcomponentType) MemorySubcomponentType(org.osate.aadl2.MemorySubcomponentType) ProcessSubcomponentType(org.osate.aadl2.ProcessSubcomponentType) SubprogramSubcomponentType(org.osate.aadl2.SubprogramSubcomponentType) DeviceSubcomponentType(org.osate.aadl2.DeviceSubcomponentType) ProcessorSubcomponentType(org.osate.aadl2.ProcessorSubcomponentType) ThreadSubcomponentType(org.osate.aadl2.ThreadSubcomponentType) VirtualBusSubcomponentType(org.osate.aadl2.VirtualBusSubcomponentType) BusSubcomponentType(org.osate.aadl2.BusSubcomponentType) DataSubcomponentType(org.osate.aadl2.DataSubcomponentType) ThreadGroupSubcomponentType(org.osate.aadl2.ThreadGroupSubcomponentType) VirtualProcessorSubcomponentType(org.osate.aadl2.VirtualProcessorSubcomponentType) NamedElement(org.osate.aadl2.NamedElement) BusinessObjectContext(org.osate.ge.BusinessObjectContext)

Example 10 with SubcomponentType

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

the class SubcomponentPrototypeBindingsModel method flush.

@Override
public void flush() {
    // Get any subcomponent. Will be used to resolve selected classifier
    final Subcomponent currentSc = getBusinessObjectSelection().boStream(Subcomponent.class).findFirst().orElse(null);
    if (currentSc == null) {
        throw new RuntimeException("Unable to retrieve subcomponent");
    }
    // Get the actual object.
    final NamedElementOrDescription classifier = getClassifier(null);
    EObject classifierValue = classifier == null ? null : classifier.getResolvedValue(getResourceSet());
    if (classifierValue != null && !(classifierValue instanceof SubcomponentType)) {
        throw new RuntimeException("Unexpected value: " + classifierValue);
    }
    final SubcomponentType newSubcomponentType = (SubcomponentType) classifierValue;
    getBusinessObjectSelection().modify(Subcomponent.class, sc -> {
        // Set subcomponent type
        AadlSubcomponentUtil.setClassifier(sc, newSubcomponentType);
        // Update prototype bindings
        sc.getOwnedPrototypeBindings().clear();
        createNewBindings(null, newSubcomponentType, sc, sc.getOwnedPrototypeBindings());
    });
}
Also used : Subcomponent(org.osate.aadl2.Subcomponent) EObject(org.eclipse.emf.ecore.EObject) SubcomponentType(org.osate.aadl2.SubcomponentType)

Aggregations

SubcomponentType (org.osate.aadl2.SubcomponentType)10 SubprogramGroupSubcomponentType (org.osate.aadl2.SubprogramGroupSubcomponentType)4 EObject (org.eclipse.emf.ecore.EObject)3 AbstractSubcomponentType (org.osate.aadl2.AbstractSubcomponentType)3 BusSubcomponentType (org.osate.aadl2.BusSubcomponentType)3 ComponentClassifier (org.osate.aadl2.ComponentClassifier)3 ComponentPrototypeActual (org.osate.aadl2.ComponentPrototypeActual)3 MemorySubcomponentType (org.osate.aadl2.MemorySubcomponentType)3 ProcessorSubcomponentType (org.osate.aadl2.ProcessorSubcomponentType)3 Subcomponent (org.osate.aadl2.Subcomponent)3 ThreadSubcomponentType (org.osate.aadl2.ThreadSubcomponentType)3 VirtualBusSubcomponentType (org.osate.aadl2.VirtualBusSubcomponentType)3 VirtualProcessorSubcomponentType (org.osate.aadl2.VirtualProcessorSubcomponentType)3 ComponentImplementation (org.osate.aadl2.ComponentImplementation)2 ComponentImplementationReference (org.osate.aadl2.ComponentImplementationReference)2 ComponentPrototype (org.osate.aadl2.ComponentPrototype)2 ComponentPrototypeBinding (org.osate.aadl2.ComponentPrototypeBinding)2 DataPrototype (org.osate.aadl2.DataPrototype)2 DataSubcomponentType (org.osate.aadl2.DataSubcomponentType)2 DeviceSubcomponentType (org.osate.aadl2.DeviceSubcomponentType)2