Search in sources :

Example 41 with ComponentClassifier

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

the class FlowLatencyUtil method getContributorType.

public static String getContributorType(EObject relatedElement) {
    if (relatedElement instanceof ComponentInstance) {
        ComponentInstance relatedComponentInstance = (ComponentInstance) relatedElement;
        if (relatedComponentInstance.getCategory() == ComponentCategory.VIRTUAL_BUS) {
            return "protocol";
        }
        if (relatedComponentInstance.getCategory() == ComponentCategory.VIRTUAL_PROCESSOR) {
            return "partition";
        }
        return relatedComponentInstance.getCategory().getName();
    }
    if (relatedElement instanceof VirtualBus) {
        return "protocol";
    }
    if (relatedElement instanceof ComponentClassifier) {
        ComponentType relatedComponentType = (ComponentType) relatedElement;
        return relatedComponentType.getCategory().getName();
    }
    if (relatedElement instanceof ConnectionInstance) {
        final ConnectionKind connectionKind = ((ConnectionInstance) relatedElement).getKind();
        Timing connectionType;
        try {
            connectionType = connectionKind == ConnectionKind.PORT_CONNECTION ? CommunicationProperties.getTiming((ConnectionInstance) relatedElement).orElse(Timing.SAMPLED) : Timing.SAMPLED;
        } catch (final PropertyLookupException e) {
            // Property association semantics for FEATURE connections are missing
            connectionType = Timing.SAMPLED;
        }
        if (connectionType == Timing.DELAYED) {
            return "delayed connection";
        }
        if (connectionType == Timing.IMMEDIATE) {
            return "immediate connection";
        }
        if (connectionType == Timing.SAMPLED) {
            return "connection";
        }
        return "connection";
    }
    return "component";
}
Also used : ConnectionInstance(org.osate.aadl2.instance.ConnectionInstance) ComponentClassifier(org.osate.aadl2.ComponentClassifier) ComponentType(org.osate.aadl2.ComponentType) VirtualBus(org.osate.aadl2.VirtualBus) ComponentInstance(org.osate.aadl2.instance.ComponentInstance) ConnectionKind(org.osate.aadl2.instance.ConnectionKind) Timing(org.osate.aadl2.contrib.communication.Timing) PropertyLookupException(org.osate.aadl2.properties.PropertyLookupException)

Example 42 with ComponentClassifier

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

the class LatencyContributorComponent method getContributorType.

@Override
protected String getContributorType() {
    ComponentInstance relatedComponentInstance;
    ComponentType relatedComponentType;
    if (relatedElement instanceof ComponentInstance) {
        relatedComponentInstance = (ComponentInstance) relatedElement;
        if (relatedComponentInstance.getCategory() == ComponentCategory.VIRTUAL_BUS) {
            return "protocol";
        }
        if (relatedComponentInstance.getCategory() == ComponentCategory.VIRTUAL_PROCESSOR) {
            return "partition";
        }
        return relatedComponentInstance.getCategory().getName();
    }
    if (relatedElement instanceof VirtualBus) {
        return "protocol";
    }
    if (relatedElement instanceof ComponentClassifier) {
        relatedComponentType = (ComponentType) relatedElement;
        return relatedComponentType.getCategory().getName();
    }
    return "component";
}
Also used : ComponentClassifier(org.osate.aadl2.ComponentClassifier) ComponentType(org.osate.aadl2.ComponentType) VirtualBus(org.osate.aadl2.VirtualBus) ComponentInstance(org.osate.aadl2.instance.ComponentInstance)

Example 43 with ComponentClassifier

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

the class AadlBaUtils method getDataClassifier.

/**
 * Returns the DataClassifier of the element binded to the given
 * Value object. A target instance can be given to this method as
 * Target instance can be cast into ValueVariable reference.
 * <BR><BR>
 *  Notes: <BR><BR>
 *  <BR>_ ValueVariable : {@link #getClassifier(Element, Classifier)}
 *                                 to see the restrictions.
 *  <BR>_ ValueConstant : Property constant and property reference are not supported:
 *  returns {@code null}.
 *  <BR><BR>
 *
 * @param v the given Value object
 * @param parentContainer only for AADLBA declarative objects which have no
 * parent set, yet
 * @return the binded component's DataClassifier object or {@code null} for
 * the ValueConstant objects and for the Abstract components objects.
 * @exception UnsupportedOperationException for unsupported binded
 * object types.
 */
public static DataClassifier getDataClassifier(Value v, ComponentClassifier parentContainer) {
    Classifier result = null;
    if (v instanceof ValueVariable) {
        // Either ElementHolder or DataComponentReference object.
        Element el = null;
        if (v instanceof ElementHolder) {
            el = ((ElementHolder) v).getElement();
        } else // DataComponentReference case.
        {
            DataComponentReference dcr = (DataComponentReference) v;
            DataHolder lastElement = dcr.getData().get(dcr.getData().size() - 1);
            el = lastElement.getElement();
        }
        if (parentContainer == null) {
            parentContainer = (ComponentClassifier) v.getContainingClassifier();
        }
        result = getClassifier(el, parentContainer);
    } else // Property constant and property reference are not supported.
    {
        result = null;
    }
    if (result instanceof DataClassifier) {
        return (DataClassifier) result;
    } else // Abstract components case.
    {
        return null;
    }
}
Also used : ValueVariable(org.osate.ba.aadlba.ValueVariable) DataHolder(org.osate.ba.aadlba.DataHolder) StructUnionElement(org.osate.ba.aadlba.StructUnionElement) BehaviorNamedElement(org.osate.ba.aadlba.BehaviorNamedElement) NamedElement(org.osate.aadl2.NamedElement) ArrayableElement(org.osate.aadl2.ArrayableElement) Element(org.osate.aadl2.Element) BehaviorElement(org.osate.ba.aadlba.BehaviorElement) IndexableElement(org.osate.ba.aadlba.IndexableElement) ElementHolder(org.osate.ba.aadlba.ElementHolder) PropertyElementHolder(org.osate.ba.aadlba.PropertyElementHolder) SubprogramClassifier(org.osate.aadl2.SubprogramClassifier) ComponentClassifier(org.osate.aadl2.ComponentClassifier) Classifier(org.osate.aadl2.Classifier) ProcessClassifier(org.osate.aadl2.ProcessClassifier) DataClassifier(org.osate.aadl2.DataClassifier) ProcessorClassifier(org.osate.aadl2.ProcessorClassifier) DataClassifier(org.osate.aadl2.DataClassifier) DataComponentReference(org.osate.ba.aadlba.DataComponentReference)

Example 44 with ComponentClassifier

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

the class AadlBaUtils method getDataRepresentation.

/**
 * Returns the data representation of the given ValueVariable object
 * or DataRepresentation.UNKNOWN if Data_Model::Data_Representation
 * property is not set or if the ValueVariable object represents a data
 * structure.
 *
 * @param v the given ValueVariable object
 * @return the data representation or DataRepresentation.UNKNOWN
 */
public static DataRepresentation getDataRepresentation(ValueVariable v) {
    if (v instanceof PortCountValue) {
        return DataRepresentation.INTEGER;
    } else if (v instanceof PortFreshValue) {
        return DataRepresentation.BOOLEAN;
    } else {
        // Either ElementHolder or DataComponentReference object.
        Element el = null;
        if (v instanceof ElementHolder) {
            if (v instanceof PrototypeHolder) {
                PrototypeHolder ph = (PrototypeHolder) v;
                if (ph.getPrototypeBinding() != null) {
                    el = ph.getPrototypeBinding();
                } else {
                    el = ph.getPrototype();
                }
            } else {
                el = ((ElementHolder) v).getElement();
            }
        } else // DataComponentReference case.
        {
            DataComponentReference dcr = (DataComponentReference) v;
            DataHolder lastElement = dcr.getData().get(dcr.getData().size() - 1);
            el = lastElement.getElement();
        }
        if (el instanceof Abstract) {
            return DataRepresentation.UNKNOWN;
        } else if (el instanceof Feature) {
            Classifier c = ((Feature) el).getClassifier();
            if (c instanceof DataClassifier) {
                return getDataRepresentation((DataClassifier) c);
            } else {
                return DataRepresentation.UNKNOWN;
            }
        } else if (el instanceof DataSubcomponent) {
            final DataSubcomponent subcompo = (DataSubcomponent) el;
            final Classifier classifier = subcompo.getClassifier();
            // fixes 2401: Avoid crashing the editor when subcomponent is not resolved
            if (classifier == null || classifier.eIsProxy()) {
                return DataRepresentation.UNKNOWN;
            }
            return getDataRepresentation((DataClassifier) ((DataSubcomponent) el).getClassifier());
        } else if (el instanceof BehaviorVariable) {
            // Behavior case.
            return getDataRepresentation((BehaviorVariable) el);
        } else {
            // Prototype cases.
            Classifier klass;
            ComponentClassifier baParentComponent = (ComponentClassifier) v.getContainingClassifier();
            klass = AadlBaUtils.getClassifier(el, baParentComponent);
            return getDataRepresentation((DataClassifier) klass);
        }
    }
}
Also used : ComponentClassifier(org.osate.aadl2.ComponentClassifier) BehaviorVariable(org.osate.ba.aadlba.BehaviorVariable) Abstract(org.osate.aadl2.Abstract) StructUnionElement(org.osate.ba.aadlba.StructUnionElement) BehaviorNamedElement(org.osate.ba.aadlba.BehaviorNamedElement) NamedElement(org.osate.aadl2.NamedElement) ArrayableElement(org.osate.aadl2.ArrayableElement) Element(org.osate.aadl2.Element) BehaviorElement(org.osate.ba.aadlba.BehaviorElement) IndexableElement(org.osate.ba.aadlba.IndexableElement) ElementHolder(org.osate.ba.aadlba.ElementHolder) PropertyElementHolder(org.osate.ba.aadlba.PropertyElementHolder) PortFreshValue(org.osate.ba.aadlba.PortFreshValue) SubprogramClassifier(org.osate.aadl2.SubprogramClassifier) ComponentClassifier(org.osate.aadl2.ComponentClassifier) Classifier(org.osate.aadl2.Classifier) ProcessClassifier(org.osate.aadl2.ProcessClassifier) DataClassifier(org.osate.aadl2.DataClassifier) ProcessorClassifier(org.osate.aadl2.ProcessorClassifier) DataClassifier(org.osate.aadl2.DataClassifier) DataComponentReference(org.osate.ba.aadlba.DataComponentReference) Feature(org.osate.aadl2.Feature) AbstractFeature(org.osate.aadl2.AbstractFeature) DirectedFeature(org.osate.aadl2.DirectedFeature) PortCountValue(org.osate.ba.aadlba.PortCountValue) DataHolder(org.osate.ba.aadlba.DataHolder) DataSubcomponent(org.osate.aadl2.DataSubcomponent) PrototypeHolder(org.osate.ba.aadlba.PrototypeHolder) DataAccessPrototypeHolder(org.osate.ba.aadlba.DataAccessPrototypeHolder) FeaturePrototypeHolder(org.osate.ba.aadlba.FeaturePrototypeHolder)

Example 45 with ComponentClassifier

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

the class InstanceValidation method checkForReferenceProcessor.

protected void checkForReferenceProcessor(Element obj) {
    if (obj instanceof ComponentInstance) {
        ComponentInstance ci = (ComponentInstance) obj;
        double et = GetProperties.getMaximumComputeExecutionTimeinSec(ci);
        if (et != 0) {
            ComponentClassifier refproc = GetProperties.getReferenceProcessor(ci);
            if (refproc == null) {
                isOK = false;
                handler.error(ci, "Thread instance " + ci.getComponentInstancePath() + " has execution time, but no Reference_Processor. Please this property.");
            }
        }
    }
}
Also used : ComponentClassifier(org.osate.aadl2.ComponentClassifier) ComponentInstance(org.osate.aadl2.instance.ComponentInstance)

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