Search in sources :

Example 41 with PropertyConstant

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

the class ValidateConnectionsSwitch method classifiersFoundInSupportedTypeConversionsProperty.

// XXX How can I avoid duplicating this method for the instance and the declarative models?
private boolean classifiersFoundInSupportedTypeConversionsProperty(ConnectionInstance connection, Classifier source, Classifier destination) {
    PropertyConstant conversionsPropertyConstant = GetProperties.lookupPropertyConstant(connection, AadlProject.SUPPORTED_TYPE_CONVERSIONS);
    if (conversionsPropertyConstant == null) {
        return false;
    }
    PropertyExpression constantValue = conversionsPropertyConstant.getConstantValue();
    if (!(constantValue instanceof ListValue)) {
        return false;
    }
    for (PropertyExpression classifierPair : ((ListValue) constantValue).getOwnedListElements()) {
        if (classifierPair instanceof ListValue) {
            EList<PropertyExpression> innerListElements = ((ListValue) classifierPair).getOwnedListElements();
            if (innerListElements.size() == 2 && innerListElements.get(0) instanceof ClassifierValue && innerListElements.get(1) instanceof ClassifierValue) {
                Classifier firstPairElement = ((ClassifierValue) innerListElements.get(0)).getClassifier();
                Classifier secondPairElement = ((ClassifierValue) innerListElements.get(1)).getClassifier();
                if (firstPairElement == source && secondPairElement == destination) {
                    return true;
                }
            }
        }
    }
    return false;
}
Also used : ClassifierValue(org.osate.aadl2.ClassifierValue) ListValue(org.osate.aadl2.ListValue) PropertyExpression(org.osate.aadl2.PropertyExpression) InstantiatedClassifier(org.osate.aadl2.instance.util.InstanceUtil.InstantiatedClassifier) Classifier(org.osate.aadl2.Classifier) PropertyConstant(org.osate.aadl2.PropertyConstant)

Example 42 with PropertyConstant

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

the class ErrorCodeValueImpl method setConstant.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public void setConstant(PropertyConstant newConstant) {
    PropertyConstant oldConstant = constant;
    constant = newConstant;
    if (eNotificationRequired())
        eNotify(new ENotificationImpl(this, Notification.SET, ErrorModelPackage.ERROR_CODE_VALUE__CONSTANT, oldConstant, constant));
}
Also used : ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl) PropertyConstant(org.osate.aadl2.PropertyConstant)

Example 43 with PropertyConstant

use of org.osate.aadl2.PropertyConstant in project AGREE by loonwerks.

the class AgreeTypeSystem method inferPropExp.

private static TypeDef inferPropExp(PropertyExpression pe) {
    if (pe instanceof IntegerLiteral) {
        return Prim.IntTypeDef;
    } else if (pe instanceof RealLiteral) {
        return Prim.RealTypeDef;
    } else if (pe instanceof NamedValue) {
        NamedValue nv = (NamedValue) pe;
        AbstractNamedValue anv = nv.getNamedValue();
        if (anv instanceof PropertyConstant) {
            return inferPropExp(((PropertyConstant) anv).getConstantValue());
        }
    }
    return Prim.ErrorTypeDef;
}
Also used : RealLiteral(org.osate.aadl2.RealLiteral) AbstractNamedValue(org.osate.aadl2.AbstractNamedValue) AbstractNamedValue(org.osate.aadl2.AbstractNamedValue) NamedValue(org.osate.aadl2.NamedValue) IntegerLiteral(org.osate.aadl2.IntegerLiteral) PropertyConstant(org.osate.aadl2.PropertyConstant)

Example 44 with PropertyConstant

use of org.osate.aadl2.PropertyConstant in project AGREE by loonwerks.

the class AgreeValidator method checkGetPropertyExpr.

@Check(CheckType.FAST)
public void checkGetPropertyExpr(GetPropertyExpr getPropExpr) {
    ComponentRef componentRef = getPropExpr.getComponentRef();
    NamedElement prop = getPropExpr.getProp();
    if (!(prop instanceof Property || prop instanceof PropertyConstant)) {
        error(getPropExpr.getProp(), "Expected AADL property or property constant");
    }
    if (prop instanceof Property) {
        NamedElement element = namedElementFromComponentRef(componentRef);
        final boolean applies = element.acceptsProperty((Property) prop);
        if (!applies) {
            error("Property " + ((Property) prop).getQualifiedName() + " does not apply to " + element.getQualifiedName() + ".", getPropExpr, AgreePackage.Literals.GET_PROPERTY_EXPR__PROP);
        }
    }
}
Also used : ComponentRef(com.rockwellcollins.atc.agree.agree.ComponentRef) NamedElement(org.osate.aadl2.NamedElement) Property(org.osate.aadl2.Property) PropertyConstant(org.osate.aadl2.PropertyConstant) Check(org.eclipse.xtext.validation.Check)

Aggregations

PropertyConstant (org.osate.aadl2.PropertyConstant)39 PropertyExpression (org.osate.aadl2.PropertyExpression)26 IntegerLiteral (org.osate.aadl2.IntegerLiteral)18 Property (org.osate.aadl2.Property)13 Classifier (org.osate.aadl2.Classifier)11 ClassifierValue (org.osate.aadl2.ClassifierValue)11 ListValue (org.osate.aadl2.ListValue)11 NamedElement (org.osate.aadl2.NamedElement)9 NamedValue (org.osate.aadl2.NamedValue)9 EObject (org.eclipse.emf.ecore.EObject)8 List (java.util.List)7 IntegerWithUnits (org.osate.pluginsupport.properties.IntegerWithUnits)7 ContainedNamedElement (org.osate.aadl2.ContainedNamedElement)6 AbstractNamedValue (org.osate.aadl2.AbstractNamedValue)5 ArraySize (org.osate.aadl2.ArraySize)5 BasicPropertyAssociation (org.osate.aadl2.BasicPropertyAssociation)5 ContainmentPathElement (org.osate.aadl2.ContainmentPathElement)5 PropertyType (org.osate.aadl2.PropertyType)5 Aadl2Package (org.osate.aadl2.Aadl2Package)4 ArrayDimension (org.osate.aadl2.ArrayDimension)4