Search in sources :

Example 16 with NamedValue

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

the class PropertyUtils method getContainedSimplePropertyValue.

/**
 * get a property association from the properties section of the containing classifier if the context.
 * This method has been designed to work with end points of connections, i.e., consisting of a target and a context.
 * The context must be a NamedElement in its containing classifier, i.e., a feature, feature group, subcomponent.
 * The property holder is assumed to be contained in the context object, e.g., a feature in afeature group or a data subcomponent in a port, or feature in a subcomponent.
 * The association must match the property definition.
 * if the context is null then the containing classifier of the target is used and the path must be one or no path.
 * The applies to clause of the property association must be of size 2 if the context is set and point to the context and then the property holder.
 * The property value of the property association is assumed not to be modal.
 * @param context NamedElement whose containing classifier's properties section is searched for the desired property
 * @param target NamedElement the model element to which the property is applied to via the applies to clause
 * @param pd Property the property definition
 * @return
 */
public static PropertyExpression getContainedSimplePropertyValue(final NamedElement context, final NamedElement target, final Property pd) {
    if (context == null) {
        return target.getNonModalPropertyValue(pd);
    }
    Classifier cl = AadlUtil.getContainingClassifier(context);
    EList<PropertyAssociation> props = cl.getAllPropertyAssociations();
    for (PropertyAssociation propertyAssociation : props) {
        if (propertyAssociation.getProperty().equals(pd)) {
            // we found a property with the corect type
            // now we need to check whether the applies to points to the holder
            EList<ContainedNamedElement> appliestos = propertyAssociation.getAppliesTos();
            for (ContainedNamedElement containedNamedElement : appliestos) {
                EList<ContainmentPathElement> cpes = containedNamedElement.getContainmentPathElements();
                if (cpes.size() == 2) {
                    NamedElement pathcxt = cpes.get(0).getNamedElement();
                    NamedElement pathelement = cpes.get(1).getNamedElement();
                    if (context.equals(pathcxt) && target.equals(pathelement)) {
                        EList<ModalPropertyValue> vallist = propertyAssociation.getOwnedValues();
                        if (!vallist.isEmpty()) {
                            ModalPropertyValue elem = vallist.get(0);
                            PropertyExpression res = elem.getOwnedValue();
                            if (res instanceof NamedValue) {
                                AbstractNamedValue nv = ((NamedValue) res).getNamedValue();
                                if (nv instanceof Property) {
                                    res = target.getNonModalPropertyValue((Property) nv);
                                } else if (nv instanceof PropertyConstant) {
                                    res = ((PropertyConstant) nv).getConstantValue();
                                }
                            }
                            return res;
                        }
                    }
                }
            }
        }
    }
    return null;
}
Also used : ModalPropertyValue(org.osate.aadl2.ModalPropertyValue) PropertyAssociation(org.osate.aadl2.PropertyAssociation) BasicPropertyAssociation(org.osate.aadl2.BasicPropertyAssociation) ContainmentPathElement(org.osate.aadl2.ContainmentPathElement) AbstractNamedValue(org.osate.aadl2.AbstractNamedValue) NamedValue(org.osate.aadl2.NamedValue) AbstractNamedValue(org.osate.aadl2.AbstractNamedValue) Classifier(org.osate.aadl2.Classifier) PropertyConstant(org.osate.aadl2.PropertyConstant) PropertyExpression(org.osate.aadl2.PropertyExpression) ContainedNamedElement(org.osate.aadl2.ContainedNamedElement) ContainedNamedElement(org.osate.aadl2.ContainedNamedElement) NamedElement(org.osate.aadl2.NamedElement) Property(org.osate.aadl2.Property)

Example 17 with NamedValue

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

the class DeclarativePackageImpl method initializePackageContents.

/**
 * Complete the initialization of the package and its meta-model.  This
 * method is guarded to have no affect on any invocation but its first.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public void initializePackageContents() {
    if (isInitialized)
        return;
    isInitialized = true;
    // Initialize package
    setName(eNAME);
    setNsPrefix(eNS_PREFIX);
    setNsURI(eNS_URI);
    // Obtain other dependent packages
    AadlBaPackage theAadlBaPackage = (AadlBaPackage) EPackage.Registry.INSTANCE.getEPackage(AadlBaPackage.eNS_URI);
    Aadl2Package theAadl2Package = (Aadl2Package) EPackage.Registry.INSTANCE.getEPackage(Aadl2Package.eNS_URI);
    // Create type parameters
    // Set bounds for type parameters
    // Add supertypes to classes
    arrayableIdentifierEClass.getESuperTypes().add(this.getIdentifier());
    commActionEClass.getESuperTypes().add(theAadlBaPackage.getCommunicationAction());
    commActionEClass.getESuperTypes().add(this.getDeclarativeBehaviorElement());
    declarativeArrayDimensionEClass.getESuperTypes().add(theAadl2Package.getArrayDimension());
    declarativeArrayDimensionEClass.getESuperTypes().add(this.getDeclarativeBehaviorElement());
    declarativeBehaviorElementEClass.getESuperTypes().add(theAadlBaPackage.getBehaviorElement());
    declarativeBehaviorTransitionEClass.getESuperTypes().add(theAadlBaPackage.getBehaviorTransition());
    declarativeBehaviorTransitionEClass.getESuperTypes().add(this.getDeclarativeBehaviorElement());
    declarativePropertyNameEClass.getESuperTypes().add(this.getDeclarativeBehaviorElement());
    declarativePropertyReferenceEClass.getESuperTypes().add(this.getDeclarativeBehaviorElement());
    declarativePropertyReferenceEClass.getESuperTypes().add(theAadlBaPackage.getIntegerValueConstant());
    declarativePropertyReferenceEClass.getESuperTypes().add(theAadlBaPackage.getValueConstant());
    declarativeTimeEClass.getESuperTypes().add(theAadlBaPackage.getBehaviorTime());
    declarativeTimeEClass.getESuperTypes().add(theAadlBaPackage.getCompletionRelativeTimeout());
    declarativeTimeEClass.getESuperTypes().add(this.getDeclarativeBehaviorElement());
    identifierEClass.getESuperTypes().add(theAadlBaPackage.getBehaviorState());
    identifierEClass.getESuperTypes().add(this.getDeclarativeBehaviorElement());
    namedValueEClass.getESuperTypes().add(theAadlBaPackage.getIntegerValueVariable());
    namedValueEClass.getESuperTypes().add(theAadlBaPackage.getValueVariable());
    namedValueEClass.getESuperTypes().add(this.getDeclarativeBehaviorElement());
    qualifiedNamedElementEClass.getESuperTypes().add(theAadl2Package.getDataClassifier());
    qualifiedNamedElementEClass.getESuperTypes().add(theAadl2Package.getClassifier());
    qualifiedNamedElementEClass.getESuperTypes().add(this.getDeclarativeBehaviorElement());
    qualifiedNamedElementEClass.getESuperTypes().add(theAadlBaPackage.getValueConstant());
    qualifiedNamedElementEClass.getESuperTypes().add(theAadlBaPackage.getIntegerValueConstant());
    qualifiedNamedElementEClass.getESuperTypes().add(theAadl2Package.getProcessorClassifier());
    qualifiedNamedElementEClass.getESuperTypes().add(theAadl2Package.getProperty());
    qualifiedNamedElementEClass.getESuperTypes().add(theAadl2Package.getUnitLiteral());
    referenceEClass.getESuperTypes().add(theAadlBaPackage.getActualPortHolder());
    referenceEClass.getESuperTypes().add(this.getDeclarativeBehaviorElement());
    referenceEClass.getESuperTypes().add(theAadlBaPackage.getIntegerValueVariable());
    referenceEClass.getESuperTypes().add(theAadlBaPackage.getValueVariable());
    referenceEClass.getESuperTypes().add(theAadlBaPackage.getElementValues());
    referenceEClass.getESuperTypes().add(theAadlBaPackage.getTarget());
    referenceEClass.getESuperTypes().add(theAadlBaPackage.getDispatchTriggerCondition());
    referenceEClass.getESuperTypes().add(theAadlBaPackage.getDispatchTrigger());
    referenceEClass.getESuperTypes().add(theAadlBaPackage.getModeSwitchTrigger());
    referenceEClass.getESuperTypes().add(theAadl2Package.getContainmentPathElement());
    declarativePropertyAssociationEClass.getESuperTypes().add(this.getDeclarativeBehaviorElement());
    declarativeListValueEClass.getESuperTypes().add(theAadl2Package.getListValue());
    declarativeListValueEClass.getESuperTypes().add(this.getDeclarativePropertyExpression());
    declarativePropertyExpressionEClass.getESuperTypes().add(theAadl2Package.getPropertyExpression());
    declarativeStringLiteralEClass.getESuperTypes().add(theAadlBaPackage.getBehaviorStringLiteral());
    declarativeStringLiteralEClass.getESuperTypes().add(this.getDeclarativePropertyExpression());
    declarativeIntegerLiteralEClass.getESuperTypes().add(theAadlBaPackage.getBehaviorIntegerLiteral());
    declarativeIntegerLiteralEClass.getESuperTypes().add(this.getDeclarativePropertyExpression());
    declarativeRealLiteralEClass.getESuperTypes().add(theAadlBaPackage.getBehaviorRealLiteral());
    declarativeRealLiteralEClass.getESuperTypes().add(this.getDeclarativePropertyExpression());
    declarativeRecordValueEClass.getESuperTypes().add(theAadl2Package.getRecordValue());
    declarativeRecordValueEClass.getESuperTypes().add(this.getDeclarativePropertyExpression());
    declarativeBasicPropertyAssociationEClass.getESuperTypes().add(theAadl2Package.getBasicPropertyAssociation());
    declarativeBooleanLiteralEClass.getESuperTypes().add(theAadlBaPackage.getBehaviorBooleanLiteral());
    declarativeBooleanLiteralEClass.getESuperTypes().add(this.getDeclarativePropertyExpression());
    declarativeRangeValueEClass.getESuperTypes().add(theAadl2Package.getRangeValue());
    declarativeRangeValueEClass.getESuperTypes().add(this.getDeclarativePropertyExpression());
    declarativeReferenceValueEClass.getESuperTypes().add(this.getDeclarativePropertyExpression());
    declarativeClassifierValueEClass.getESuperTypes().add(this.getDeclarativePropertyExpression());
    // Initialize classes and features; add operations and parameters
    initEClass(arrayableIdentifierEClass, ArrayableIdentifier.class, "ArrayableIdentifier", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
    initEReference(getArrayableIdentifier_ArrayIndexes(), theAadlBaPackage.getIntegerValue(), null, "arrayIndexes", null, 0, -1, ArrayableIdentifier.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
    initEClass(commActionEClass, CommAction.class, "CommAction", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
    initEReference(getCommAction_Parameters(), theAadlBaPackage.getParameterLabel(), null, "parameters", null, 0, -1, CommAction.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
    initEAttribute(getCommAction_PortFreeze(), theAadlBaPackage.getBoolean(), "portFreeze", "false", 0, 1, CommAction.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
    initEAttribute(getCommAction_PortDequeue(), theAadlBaPackage.getBoolean(), "portDequeue", "false", 0, 1, CommAction.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
    initEAttribute(getCommAction_Lock(), theAadlBaPackage.getBoolean(), "lock", "false", 0, 1, CommAction.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
    initEAttribute(getCommAction_Unlock(), theAadlBaPackage.getBoolean(), "unlock", "false", 0, 1, CommAction.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
    initEReference(getCommAction_Target(), theAadlBaPackage.getTarget(), null, "target", null, 0, 1, CommAction.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
    initEReference(getCommAction_QualifiedName(), this.getQualifiedNamedElement(), null, "qualifiedName", null, 0, 1, CommAction.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
    initEReference(getCommAction_Reference(), this.getReference(), null, "reference", null, 0, 1, CommAction.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
    initEClass(declarativeArrayDimensionEClass, DeclarativeArrayDimension.class, "DeclarativeArrayDimension", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
    initEReference(getDeclarativeArrayDimension_Dimension(), theAadlBaPackage.getIntegerValueConstant(), null, "dimension", null, 1, 1, DeclarativeArrayDimension.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
    initEClass(declarativeBehaviorElementEClass, DeclarativeBehaviorElement.class, "DeclarativeBehaviorElement", IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
    initEReference(getDeclarativeBehaviorElement_OsateRef(), theAadl2Package.getElement(), null, "osateRef", null, 0, 1, DeclarativeBehaviorElement.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, !IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
    initEReference(getDeclarativeBehaviorElement_BaRef(), theAadlBaPackage.getBehaviorElement(), null, "baRef", null, 0, 1, DeclarativeBehaviorElement.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, !IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
    initEClass(declarativeBehaviorTransitionEClass, DeclarativeBehaviorTransition.class, "DeclarativeBehaviorTransition", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
    initEReference(getDeclarativeBehaviorTransition_SrcStates(), this.getIdentifier(), null, "srcStates", null, 1, -1, DeclarativeBehaviorTransition.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
    initEReference(getDeclarativeBehaviorTransition_DestState(), this.getIdentifier(), null, "destState", null, 1, 1, DeclarativeBehaviorTransition.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
    initEClass(declarativePropertyNameEClass, DeclarativePropertyName.class, "DeclarativePropertyName", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
    initEReference(getDeclarativePropertyName_PropertyName(), this.getIdentifier(), null, "propertyName", null, 1, 1, DeclarativePropertyName.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
    initEReference(getDeclarativePropertyName_Field(), theAadlBaPackage.getPropertyNameField(), null, "field", null, 0, 1, DeclarativePropertyName.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
    initEReference(getDeclarativePropertyName_Indexes(), theAadlBaPackage.getIntegerValue(), null, "indexes", null, 0, -1, DeclarativePropertyName.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
    initEClass(declarativePropertyReferenceEClass, DeclarativePropertyReference.class, "DeclarativePropertyReference", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
    initEReference(getDeclarativePropertyReference_QualifiedName(), this.getQualifiedNamedElement(), null, "qualifiedName", null, 0, 1, DeclarativePropertyReference.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
    initEReference(getDeclarativePropertyReference_Reference(), this.getReference(), null, "reference", null, 0, 1, DeclarativePropertyReference.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
    initEReference(getDeclarativePropertyReference_PropertyNames(), this.getDeclarativePropertyName(), null, "propertyNames", null, 1, -1, DeclarativePropertyReference.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
    initEAttribute(getDeclarativePropertyReference_PropertySet(), theAadlBaPackage.getBoolean(), "propertySet", "false", 0, 1, DeclarativePropertyReference.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
    initEClass(declarativeTimeEClass, DeclarativeTime.class, "DeclarativeTime", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
    initEReference(getDeclarativeTime_UnitId(), this.getIdentifier(), null, "unitId", null, 1, 1, DeclarativeTime.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
    initEClass(identifierEClass, Identifier.class, "Identifier", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
    initEAttribute(getIdentifier_Id(), theAadlBaPackage.getString(), "id", null, 1, 1, Identifier.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
    initEClass(namedValueEClass, NamedValue.class, "NamedValue", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
    initEReference(getNamedValue_Reference(), this.getReference(), null, "reference", null, 1, 1, NamedValue.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
    initEAttribute(getNamedValue_Dequeue(), theAadlBaPackage.getBoolean(), "dequeue", "false", 0, 1, NamedValue.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
    initEAttribute(getNamedValue_Fresh(), theAadlBaPackage.getBoolean(), "fresh", "false", 0, 1, NamedValue.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
    initEAttribute(getNamedValue_Count(), theAadlBaPackage.getBoolean(), "count", "false", 0, 1, NamedValue.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
    initEClass(qualifiedNamedElementEClass, QualifiedNamedElement.class, "QualifiedNamedElement", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
    initEReference(getQualifiedNamedElement_BaNamespace(), this.getIdentifier(), null, "baNamespace", null, 0, 1, QualifiedNamedElement.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
    initEReference(getQualifiedNamedElement_BaName(), this.getIdentifier(), null, "baName", null, 1, 1, QualifiedNamedElement.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
    initEClass(referenceEClass, Reference.class, "Reference", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
    initEReference(getReference_Ids(), this.getArrayableIdentifier(), null, "ids", null, 1, -1, Reference.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
    initEClass(declarativePropertyAssociationEClass, DeclarativePropertyAssociation.class, "DeclarativePropertyAssociation", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
    initEReference(getDeclarativePropertyAssociation_Property(), this.getQualifiedNamedElement(), null, "property", null, 1, 1, DeclarativePropertyAssociation.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
    initEReference(getDeclarativePropertyAssociation_OwnedValue(), this.getDeclarativePropertyExpression(), null, "ownedValue", null, 1, 1, DeclarativePropertyAssociation.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
    initEClass(declarativeListValueEClass, DeclarativeListValue.class, "DeclarativeListValue", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
    initEClass(declarativePropertyExpressionEClass, DeclarativePropertyExpression.class, "DeclarativePropertyExpression", IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
    initEClass(declarativeStringLiteralEClass, DeclarativeStringLiteral.class, "DeclarativeStringLiteral", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
    initEClass(declarativeIntegerLiteralEClass, DeclarativeIntegerLiteral.class, "DeclarativeIntegerLiteral", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
    initEClass(declarativeRealLiteralEClass, DeclarativeRealLiteral.class, "DeclarativeRealLiteral", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
    initEClass(declarativeRecordValueEClass, DeclarativeRecordValue.class, "DeclarativeRecordValue", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
    initEClass(declarativeBasicPropertyAssociationEClass, DeclarativeBasicPropertyAssociation.class, "DeclarativeBasicPropertyAssociation", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
    initEAttribute(getDeclarativeBasicPropertyAssociation_BasicPropertyName(), theAadl2Package.getString(), "basicPropertyName", null, 1, 1, DeclarativeBasicPropertyAssociation.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
    initEClass(declarativeBooleanLiteralEClass, DeclarativeBooleanLiteral.class, "DeclarativeBooleanLiteral", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
    initEClass(declarativeRangeValueEClass, DeclarativeRangeValue.class, "DeclarativeRangeValue", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
    initEClass(declarativeReferenceValueEClass, DeclarativeReferenceValue.class, "DeclarativeReferenceValue", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
    initEReference(getDeclarativeReferenceValue_Ref(), this.getReference(), null, "ref", null, 1, 1, DeclarativeReferenceValue.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
    initEClass(declarativeClassifierValueEClass, DeclarativeClassifierValue.class, "DeclarativeClassifierValue", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
    initEReference(getDeclarativeClassifierValue_Classifier(), this.getQualifiedNamedElement(), null, "classifier", null, 1, 1, DeclarativeClassifierValue.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
    initEClass(declarativeBehaviorAnnexEClass, DeclarativeBehaviorAnnex.class, "DeclarativeBehaviorAnnex", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
    initEReference(getDeclarativeBehaviorAnnex_DeclarativeBehaviorElements(), this.getDeclarativeBehaviorElement(), null, "declarativeBehaviorElements", null, 0, -1, DeclarativeBehaviorAnnex.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
    // Create resource
    createResource(eNS_URI);
}
Also used : AadlBaPackage(org.osate.ba.aadlba.AadlBaPackage) Aadl2Package(org.osate.aadl2.Aadl2Package)

Example 18 with NamedValue

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

the class AadlBaUtils method getDataRepresentation.

/**
 * Returns the last data representation from the property stack of the given data
 * classifier or DataRepresentation.UNKNOWN if Data_Model::Data_Representation
 * property is not set or if the data classifier represents a data structure.
 *
 * @param c the given data classifier
 * @return the data representation or DataRepresentation.UNKNOWN
 */
public static DataRepresentation getDataRepresentation(DataClassifier c) {
    DataRepresentation result = null;
    if (c == null) {
        result = DataRepresentation.UNKNOWN;
    } else {
        EList<PropertyExpression> l = PropertyUtils.findPropertyExpression(c, DataModelProperties.DATA_REPRESENTATION);
        if (l.size() > 0) {
            // Fetches the last enumeration value from the inheritance stack of
            // properties.
            NamedValue nv = (NamedValue) l.get(l.size() - 1);
            String tmp = ((EnumerationLiteral) nv.getNamedValue()).getName();
            result = DataRepresentation.getByName(tmp);
            if (result == null) {
                result = DataRepresentation.UNKNOWN;
            }
        } else {
            result = DataRepresentation.UNKNOWN;
        }
    }
    return result;
}
Also used : DataRepresentation(org.osate.ba.aadlba.DataRepresentation) PropertyExpression(org.osate.aadl2.PropertyExpression) NamedValue(org.osate.aadl2.NamedValue) AadlString(org.osate.aadl2.AadlString) EnumerationLiteral(org.osate.aadl2.EnumerationLiteral)

Example 19 with NamedValue

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

the class PropertyUtils method getEnumValue.

/**
 * Extract enumeration value from a specified property. May return null.
 *
 * @param i
 *            component instance.
 * @param propertyName
 *            property name.
 * @return property value.
 *             enumeration.
 */
public static String getEnumValue(NamedElement i, String propertyName) {
    PropertyAssociation pa = findPropertyAssociation(propertyName, i);
    if (pa != null) {
        Property p = pa.getProperty();
        if (p.getName().equalsIgnoreCase(propertyName)) {
            List<ModalPropertyValue> values = pa.getOwnedValues();
            if (values.size() == 1) {
                ModalPropertyValue v = values.get(0);
                PropertyExpression expr = v.getOwnedValue();
                if (expr instanceof EnumerationLiteral) {
                    return ((EnumerationLiteral) expr).getName();
                } else if (expr instanceof NamedValue) {
                    NamedValue nv = (NamedValue) expr;
                    if (nv.getNamedValue() instanceof EnumerationLiteral) {
                        EnumerationLiteral el = (EnumerationLiteral) nv.getNamedValue();
                        return el.getName();
                    }
                }
            }
        }
    }
    // try on a refined NamedElement
    if (i instanceof RefinableElement) {
        RefinableElement re = (RefinableElement) i;
        if (re.getRefinedElement() != null) {
            return getEnumValue(re.getRefinedElement(), propertyName);
        }
    }
    return null;
}
Also used : ModalPropertyValue(org.osate.aadl2.ModalPropertyValue) PropertyAssociation(org.osate.aadl2.PropertyAssociation) BasicPropertyAssociation(org.osate.aadl2.BasicPropertyAssociation) PropertyExpression(org.osate.aadl2.PropertyExpression) NamedValue(org.osate.aadl2.NamedValue) AbstractNamedValue(org.osate.aadl2.AbstractNamedValue) RefinableElement(org.osate.aadl2.RefinableElement) BasicProperty(org.osate.aadl2.BasicProperty) Property(org.osate.aadl2.Property) EnumerationLiteral(org.osate.aadl2.EnumerationLiteral)

Example 20 with NamedValue

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

the class InstantiateModel method interpretConnectionPatterns.

private boolean interpretConnectionPatterns(ConnectionInstance conni, boolean isOpposite, List<PropertyExpression> patterns, int offset, List<Integer> srcSizes, int srcOffset, List<Integer> dstSizes, int dstOffset, List<Long> srcIndices, List<Long> dstIndices) {
    boolean result = true;
    if (patterns != null ? offset >= patterns.size() : srcOffset == srcSizes.size() && dstOffset == dstSizes.size()) {
        createNewConnection(conni, srcIndices, dstIndices);
        return result;
    }
    String patternName = "One_to_One";
    if (patterns == null) {
        // default one-to-one pattern
        if (!conni.isComplete()) {
            // outgoing or incoming only
            InstanceObject io = conni.getSource();
            if (io instanceof FeatureInstance && io.getContainingComponentInstance() instanceof SystemInstance) {
                if (srcSizes.isEmpty()) {
                    patternName = isOpposite ? "All_to_One" : "One_To_All";
                }
            } else {
                if (dstSizes.isEmpty()) {
                    patternName = isOpposite ? "One_To_All" : "All_to_One";
                }
            }
        }
    } else {
        NamedValue nv = (NamedValue) patterns.get(offset);
        EnumerationLiteral pattern = (EnumerationLiteral) nv.getNamedValue();
        patternName = pattern.getName();
    }
    if (!isOpposite && !patternName.equalsIgnoreCase("One_To_All") && (srcOffset >= srcSizes.size())) {
        errManager.error(conni, "Too few indices for connection source for " + conni.getFullName());
        return false;
    }
    if (!isOpposite && !patternName.equalsIgnoreCase("All_To_One") && (dstOffset >= dstSizes.size())) {
        errManager.error(conni, "Too few indices for connection destination for " + conni.getFullName());
        return false;
    }
    if (isOpposite && !patternName.equalsIgnoreCase("One_To_All") && (dstOffset >= dstSizes.size())) {
        // verbose exception message
        errManager.error(conni, "Too few indices for connection source for " + conni.getFullName());
        return false;
    }
    if (isOpposite && !patternName.equalsIgnoreCase("All_To_One") && (srcOffset >= srcSizes.size())) {
        errManager.error(conni, "Too few indices for connection destination for " + conni.getFullName());
        return false;
    }
    if (patternName.equalsIgnoreCase("All_To_All")) {
        for (long i = 1; i <= srcSizes.get(srcOffset); i++) {
            srcIndices.add(i);
            for (long j = 1; j <= dstSizes.get(dstOffset); j++) {
                dstIndices.add(j);
                result &= interpretConnectionPatterns(conni, isOpposite, patterns, offset + 1, srcSizes, srcOffset + 1, dstSizes, dstOffset + 1, srcIndices, dstIndices);
                dstIndices.remove(dstOffset);
            }
            srcIndices.remove(srcOffset);
        }
    } else if ((!isOpposite && patternName.equalsIgnoreCase("One_To_All")) || (isOpposite && patternName.equalsIgnoreCase("All_To_One"))) {
        for (long j = 1; j <= dstSizes.get(dstOffset); j++) {
            dstIndices.add(j);
            result &= interpretConnectionPatterns(conni, isOpposite, patterns, offset + 1, srcSizes, srcOffset, dstSizes, dstOffset + 1, srcIndices, dstIndices);
            dstIndices.remove(dstOffset);
        }
    } else if ((!isOpposite && patternName.equalsIgnoreCase("All_To_One")) || (isOpposite && patternName.equalsIgnoreCase("One_To_All"))) {
        for (long i = 1; i <= srcSizes.get(srcOffset); i++) {
            srcIndices.add(i);
            result &= interpretConnectionPatterns(conni, isOpposite, patterns, offset + 1, srcSizes, srcOffset + 1, dstSizes, dstOffset, srcIndices, dstIndices);
            srcIndices.remove(srcOffset);
        }
    } else {
        if (!srcSizes.get(srcOffset).equals(dstSizes.get(dstOffset))) {
            // verbose exception message
            errManager.error(conni, "Array size mismatch (" + patternName + ") on connection " + conni.getFullName() + " in " + conni.getContainingComponentInstance().getFullName() + ": " + srcSizes.get(srcOffset) + // ("+conni.getSource().getFullName()+")
            " at source " + "and " + dstSizes.get(dstOffset) + // ("+conni.getSource().getFullName()+")."
            " at destination.");
            return false;
        } else {
            if (patternName.equalsIgnoreCase("One_To_One")) {
                for (long i = 1; i <= srcSizes.get(srcOffset); i++) {
                    srcIndices.add(i);
                    dstIndices.add(i);
                    result &= interpretConnectionPatterns(conni, isOpposite, patterns, offset + 1, srcSizes, srcOffset + 1, dstSizes, dstOffset + 1, srcIndices, dstIndices);
                    srcIndices.remove(srcOffset);
                    dstIndices.remove(dstOffset);
                }
            } else if (patternName.equalsIgnoreCase("Next")) {
                for (long i = 1; i <= srcSizes.get(srcOffset) - 1; i++) {
                    srcIndices.add(i);
                    dstIndices.add(i + 1);
                    result &= interpretConnectionPatterns(conni, isOpposite, patterns, offset + 1, srcSizes, srcOffset + 1, dstSizes, dstOffset + 1, srcIndices, dstIndices);
                    dstIndices.remove(dstOffset);
                    srcIndices.remove(srcOffset);
                }
            } else if (patternName.equalsIgnoreCase("Previous")) {
                for (long i = 2; i <= srcSizes.get(srcOffset); i++) {
                    srcIndices.add(i);
                    dstIndices.add(i - 1);
                    result &= interpretConnectionPatterns(conni, isOpposite, patterns, offset + 1, srcSizes, srcOffset + 1, dstSizes, dstOffset + 1, srcIndices, dstIndices);
                    dstIndices.remove(dstOffset);
                    srcIndices.remove(srcOffset);
                }
            } else if (patternName.equalsIgnoreCase("Cyclic_Next")) {
                for (long i = 1; i <= srcSizes.get(srcOffset); i++) {
                    srcIndices.add(i);
                    dstIndices.add(i == srcSizes.get(srcOffset) ? 1 : i + 1);
                    result &= interpretConnectionPatterns(conni, isOpposite, patterns, offset + 1, srcSizes, srcOffset + 1, dstSizes, dstOffset + 1, srcIndices, dstIndices);
                    dstIndices.remove(dstOffset);
                    srcIndices.remove(srcOffset);
                }
            } else if (patternName.equalsIgnoreCase("Cyclic_Previous")) {
                for (long i = 1; i <= srcSizes.get(srcOffset); i++) {
                    srcIndices.add(i);
                    dstIndices.add(i == 1 ? srcSizes.get(srcOffset) : i - 1);
                    result &= interpretConnectionPatterns(conni, isOpposite, patterns, offset + 1, srcSizes, srcOffset + 1, dstSizes, dstOffset + 1, srcIndices, dstIndices);
                    dstIndices.remove(dstOffset);
                    srcIndices.remove(srcOffset);
                }
            } else if (patternName.equalsIgnoreCase("Next_Next")) {
                for (long i = 1; i <= srcSizes.get(srcOffset) - 2; i++) {
                    srcIndices.add(i);
                    dstIndices.add(i + 2);
                    result &= interpretConnectionPatterns(conni, isOpposite, patterns, offset + 1, srcSizes, srcOffset + 1, dstSizes, dstOffset + 1, srcIndices, dstIndices);
                    dstIndices.remove(dstOffset);
                    srcIndices.remove(srcOffset);
                }
            } else if (patternName.equalsIgnoreCase("Previous_Previous")) {
                for (long i = 3; i <= srcSizes.get(srcOffset); i++) {
                    srcIndices.add(i);
                    dstIndices.add(i - 2);
                    result &= interpretConnectionPatterns(conni, isOpposite, patterns, offset + 1, srcSizes, srcOffset + 1, dstSizes, dstOffset + 1, srcIndices, dstIndices);
                    dstIndices.remove(dstOffset);
                    srcIndices.remove(srcOffset);
                }
            } else if (patternName.equalsIgnoreCase("Cyclic_Next_Next")) {
                for (long i = 1; i <= srcSizes.get(srcOffset); i++) {
                    srcIndices.add(i);
                    dstIndices.add(i == srcSizes.get(srcOffset) ? 2 : (i == srcSizes.get(srcOffset) - 1 ? 1 : i + 1));
                    result &= interpretConnectionPatterns(conni, isOpposite, patterns, offset + 1, srcSizes, srcOffset + 1, dstSizes, dstOffset + 1, srcIndices, dstIndices);
                    dstIndices.remove(dstOffset);
                    srcIndices.remove(srcOffset);
                }
            } else if (patternName.equalsIgnoreCase("Cyclic_Previous_Previous")) {
                for (long i = 1; i <= srcSizes.get(srcOffset); i++) {
                    srcIndices.add(i);
                    dstIndices.add(i == 2 ? srcSizes.get(srcOffset) : (i == 1 ? srcSizes.get(srcOffset) - 1 : i - 1));
                    result &= interpretConnectionPatterns(conni, isOpposite, patterns, offset + 1, srcSizes, srcOffset + 1, dstSizes, dstOffset + 1, srcIndices, dstIndices);
                    dstIndices.remove(dstOffset);
                    srcIndices.remove(srcOffset);
                }
            } else if (patternName.equalsIgnoreCase("Even_To_Even")) {
                for (long i = 2; i <= srcSizes.get(srcOffset); i = i + 2) {
                    srcIndices.add(i);
                    dstIndices.add(i);
                    result &= interpretConnectionPatterns(conni, isOpposite, patterns, offset + 1, srcSizes, srcOffset + 1, dstSizes, dstOffset + 1, srcIndices, dstIndices);
                    dstIndices.remove(dstOffset);
                    srcIndices.remove(srcOffset);
                }
            } else if (patternName.equalsIgnoreCase("Odd_To_Odd")) {
                for (long i = 1; i <= srcSizes.get(srcOffset); i = i + 2) {
                    srcIndices.add(i);
                    dstIndices.add(i);
                    result &= interpretConnectionPatterns(conni, isOpposite, patterns, offset + 1, srcSizes, srcOffset + 1, dstSizes, dstOffset + 1, srcIndices, dstIndices);
                    dstIndices.remove(dstOffset);
                    srcIndices.remove(srcOffset);
                }
            }
        }
    }
    return result;
}
Also used : InstanceObject(org.osate.aadl2.instance.InstanceObject) FeatureInstance(org.osate.aadl2.instance.FeatureInstance) SystemInstance(org.osate.aadl2.instance.SystemInstance) NamedValue(org.osate.aadl2.NamedValue) EnumerationLiteral(org.osate.aadl2.EnumerationLiteral)

Aggregations

NamedValue (org.osate.aadl2.NamedValue)41 EnumerationLiteral (org.osate.aadl2.EnumerationLiteral)29 Property (org.osate.aadl2.Property)27 PropertyExpression (org.osate.aadl2.PropertyExpression)24 AbstractNamedValue (org.osate.aadl2.AbstractNamedValue)20 PropertyAssociation (org.osate.aadl2.PropertyAssociation)18 BasicPropertyAssociation (org.osate.aadl2.BasicPropertyAssociation)15 ContainmentPathElement (org.osate.aadl2.ContainmentPathElement)15 ListValue (org.osate.aadl2.ListValue)15 StringLiteral (org.osate.aadl2.StringLiteral)15 BasicProperty (org.osate.aadl2.BasicProperty)13 ContainedNamedElement (org.osate.aadl2.ContainedNamedElement)13 IntegerLiteral (org.osate.aadl2.IntegerLiteral)12 BooleanLiteral (org.osate.aadl2.BooleanLiteral)11 ClassifierValue (org.osate.aadl2.ClassifierValue)11 ModalPropertyValue (org.osate.aadl2.ModalPropertyValue)11 NamedElement (org.osate.aadl2.NamedElement)11 RangeValue (org.osate.aadl2.RangeValue)11 RealLiteral (org.osate.aadl2.RealLiteral)11 RecordValue (org.osate.aadl2.RecordValue)11