Search in sources :

Example 61 with ComponentClassifier

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

the class InstantiateModel method instantiateSubcomponent.

protected void instantiateSubcomponent(final ComponentInstance parent, final ModalElement mm, final Subcomponent sub, Stack<Long> indexStack, int index) throws InterruptedException {
    final ComponentInstance newInstance = InstanceFactory.eINSTANCE.createComponentInstance();
    final ComponentClassifier cc;
    final InstantiatedClassifier ic;
    newInstance.setSubcomponent(sub);
    // Issue 961: Set the category for real later (below); set it here now in case something goes wrong
    newInstance.setCategory(sub.getCategory());
    newInstance.setName(sub.getName());
    newInstance.getIndices().addAll(indexStack);
    newInstance.getIndices().add(Long.valueOf(index));
    parent.getComponentInstances().add(newInstance);
    ic = getInstantiatedClassifier(newInstance);
    if (ic == null) {
        cc = null;
    } else {
        cc = (ComponentClassifier) ic.getClassifier();
    }
    if (cc == null) {
        errManager.warning(newInstance, "Instantiated subcomponent doesn't have a component classifier");
    } else {
        // if (cc instanceof ComponentType) {
        // if (sub instanceof SystemSubcomponent || sub instanceof ProcessSubcomponent
        // || sub instanceof ThreadGroupSubcomponent) {
        // errManager.warning(newInstance, "Instantiated subcomponent has a component type only");
        // }
        // }
        newInstance.setClassifier(cc);
        /*
			 * From Issue 961:
			 *
			 * I think the category can be determined as follows:
			 *
			 * If the classifier is not abstract then use its category (and maybe check that the subcomponent either has the same category or is abstract).
			 * If the classifier is abstract then use the category from the subcomponent.
			 *
			 * Only if both are abstract the component instance should be abstract.
			 * If both are not abstract then they must have the same category. If the categories are different, validation should already have reported an
			 * error, and we don't instantiate models with errors. It can't hurt if the instantiator checks again, though.
			 */
        final ComponentCategory classifierCategory = cc.getCategory();
        final ComponentCategory subcomponentCategory = sub.getCategory();
        if (classifierCategory != ComponentCategory.ABSTRACT) {
            newInstance.setCategory(cc.getCategory());
            if (subcomponentCategory != ComponentCategory.ABSTRACT && subcomponentCategory != classifierCategory) {
                errManager.warning(newInstance, "Subcomponent's category and its classifier's category do not match");
            }
        } else {
            newInstance.setCategory(subcomponentCategory);
        }
    }
    for (Mode mode : mm.getAllInModes()) {
        if (monitor.isCanceled()) {
            throw new InterruptedException();
        }
        ModeInstance mi = parent.findModeInstance(mode);
        if (mi != null) {
            newInstance.getInModes().add(mi);
        }
    }
    populateComponentInstance(newInstance, index);
}
Also used : ComponentClassifier(org.osate.aadl2.ComponentClassifier) ModeInstance(org.osate.aadl2.instance.ModeInstance) InstantiatedClassifier(org.osate.aadl2.instance.util.InstanceUtil.InstantiatedClassifier) Mode(org.osate.aadl2.Mode) SystemOperationMode(org.osate.aadl2.instance.SystemOperationMode) ComponentInstance(org.osate.aadl2.instance.ComponentInstance) ComponentCategory(org.osate.aadl2.ComponentCategory)

Example 62 with ComponentClassifier

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

the class ComponentInstanceImpl method setClassifier.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public void setClassifier(ComponentClassifier newClassifier) {
    ComponentClassifier oldClassifier = classifier;
    classifier = newClassifier;
    if (eNotificationRequired()) {
        eNotify(new ENotificationImpl(this, Notification.SET, InstancePackage.COMPONENT_INSTANCE__CLASSIFIER, oldClassifier, classifier));
    }
}
Also used : ComponentClassifier(org.osate.aadl2.ComponentClassifier) ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl)

Example 63 with ComponentClassifier

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

the class ComponentInstanceImpl method acceptsProperty.

public boolean acceptsProperty(Property property) {
    ComponentClassifier cc = getComponentClassifier();
    Subcomponent sub = getSubcomponent();
    if (getCategory().equals(ComponentCategory.ABSTRACT)) {
        return true;
    }
    for (PropertyOwner propOwner : property.getAppliesTos()) {
        if (propOwner instanceof MetaclassReference) {
            MetaclassReference metaRef = (MetaclassReference) propOwner;
            if (metaRef.getMetaclassNames().get(0).equals("all")) {
                return true;
            } else {
                EClass appliesTo = metaRef.getMetaclass();
                if (appliesTo == null) {
                    return false;
                }
                if (cc != null && appliesTo.isSuperTypeOf(cc.eClass()) || sub != null && appliesTo.isSuperTypeOf(sub.eClass())) {
                    return true;
                }
            }
        }
    }
    return (cc == null) ? false : cc.checkAppliesToClassifier(property);
}
Also used : ComponentClassifier(org.osate.aadl2.ComponentClassifier) PropertyOwner(org.osate.aadl2.PropertyOwner) EClass(org.eclipse.emf.ecore.EClass) Subcomponent(org.osate.aadl2.Subcomponent) MetaclassReference(org.osate.aadl2.MetaclassReference)

Example 64 with ComponentClassifier

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

the class GetProperties method getProvidedVirtualBusClass.

public static List<ComponentClassifier> getProvidedVirtualBusClass(final NamedElement io) {
    Property providedVirtualBusClass;
    ArrayList<ComponentClassifier> components;
    providedVirtualBusClass = lookupPropertyDefinition(io, DeploymentProperties._NAME, DeploymentProperties.PROVIDED_VIRTUAL_BUS_CLASS);
    components = new ArrayList<>();
    List<? extends PropertyExpression> propertyValues;
    try {
        propertyValues = io.getPropertyValueList(providedVirtualBusClass);
    } catch (Exception e) {
        return components;
    }
    for (PropertyExpression propertyExpression : propertyValues) {
        components.add((ComponentClassifier) ((ClassifierValue) propertyExpression).getClassifier());
    }
    return components;
}
Also used : ComponentClassifier(org.osate.aadl2.ComponentClassifier) ClassifierValue(org.osate.aadl2.ClassifierValue) PropertyExpression(org.osate.aadl2.PropertyExpression) BasicProperty(org.osate.aadl2.BasicProperty) Property(org.osate.aadl2.Property) PropertyLookupException(org.osate.aadl2.properties.PropertyLookupException) PropertyNotPresentException(org.osate.aadl2.properties.PropertyNotPresentException)

Example 65 with ComponentClassifier

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

the class GetProperties method getRequiredVirtualBusClass.

/**
 * Get the virtual bus required for a connection, virtual bus, port, etc.
 *
 * @param io
 *            - the component which has the property
 * @return - the list of virtual bus classifier
 */
public static List<ComponentClassifier> getRequiredVirtualBusClass(final NamedElement io) {
    Property requiredVirtualBusClass;
    ArrayList<ComponentClassifier> components;
    requiredVirtualBusClass = lookupPropertyDefinition(io, DeploymentProperties._NAME, DeploymentProperties.REQUIRED_VIRTUAL_BUS_CLASS);
    components = new ArrayList<ComponentClassifier>();
    List<? extends PropertyExpression> propertyValues;
    try {
        propertyValues = io.getPropertyValueList(requiredVirtualBusClass);
    } catch (Exception e) {
        return components;
    }
    for (PropertyExpression propertyExpression : propertyValues) {
        components.add((ComponentClassifier) ((ClassifierValue) propertyExpression).getClassifier());
    }
    return components;
}
Also used : ComponentClassifier(org.osate.aadl2.ComponentClassifier) ClassifierValue(org.osate.aadl2.ClassifierValue) PropertyExpression(org.osate.aadl2.PropertyExpression) BasicProperty(org.osate.aadl2.BasicProperty) Property(org.osate.aadl2.Property) PropertyLookupException(org.osate.aadl2.properties.PropertyLookupException) PropertyNotPresentException(org.osate.aadl2.properties.PropertyNotPresentException)

Aggregations

ComponentClassifier (org.osate.aadl2.ComponentClassifier)76 Subcomponent (org.osate.aadl2.Subcomponent)26 Classifier (org.osate.aadl2.Classifier)22 EObject (org.eclipse.emf.ecore.EObject)19 NamedElement (org.osate.aadl2.NamedElement)19 ComponentImplementation (org.osate.aadl2.ComponentImplementation)16 ArrayList (java.util.ArrayList)15 ComponentInstance (org.osate.aadl2.instance.ComponentInstance)14 AadlPackage (org.osate.aadl2.AadlPackage)13 FeatureGroupType (org.osate.aadl2.FeatureGroupType)12 List (java.util.List)11 ComponentPrototype (org.osate.aadl2.ComponentPrototype)11 Element (org.osate.aadl2.Element)11 ComponentType (org.osate.aadl2.ComponentType)10 Feature (org.osate.aadl2.Feature)9 Mode (org.osate.aadl2.Mode)8 BusinessObjectContext (org.osate.ge.BusinessObjectContext)8 Collectors (java.util.stream.Collectors)7 ENotificationImpl (org.eclipse.emf.ecore.impl.ENotificationImpl)7 ComponentCategory (org.osate.aadl2.ComponentCategory)7