Search in sources :

Example 11 with PropertyConstant

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

the class PropertiesLinkingService method findPropertyConstant.

/**
 * find property constant based on property constant name.
 * The name is qualified with the property set name, or if unqualified is assumed to be a predeclared property constant
 * The context object can be any model object, typically the object that is the context of the reference such as a property definition
 * @param context Element an AADL model element
 * @param name property type name possibly qualified with the property set name
 * @return PropertyConstant the property type or null
 */
public PropertyConstant findPropertyConstant(EObject context, String name) {
    // look for property constant in property set
    EReference reference = Aadl2Package.eINSTANCE.getNamedValue_NamedValue();
    EObject e = findPropertySetElement(context, reference, name);
    if (e != null && e instanceof PropertyConstant) {
        return (PropertyConstant) e;
    }
    return null;
}
Also used : EObject(org.eclipse.emf.ecore.EObject) EReference(org.eclipse.emf.ecore.EReference) PropertyConstant(org.osate.aadl2.PropertyConstant)

Example 12 with PropertyConstant

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

the class PropertySetImpl method createOwnedPropertyConstant.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public PropertyConstant createOwnedPropertyConstant() {
    PropertyConstant newOwnedPropertyConstant = (PropertyConstant) create(Aadl2Package.eINSTANCE.getPropertyConstant());
    getOwnedPropertyConstants().add(newOwnedPropertyConstant);
    return newOwnedPropertyConstant;
}
Also used : PropertyConstant(org.osate.aadl2.PropertyConstant)

Example 13 with PropertyConstant

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

the class BehaviorPropertyConstantImpl method setProperty.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public void setProperty(PropertyConstant newProperty) {
    PropertyConstant oldProperty = property;
    property = newProperty;
    if (eNotificationRequired())
        eNotify(new ENotificationImpl(this, Notification.SET, AadlBaPackage.BEHAVIOR_PROPERTY_CONSTANT__PROPERTY, oldProperty, property));
}
Also used : ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl) BehaviorPropertyConstant(org.osate.ba.aadlba.BehaviorPropertyConstant) PropertyConstant(org.osate.aadl2.PropertyConstant)

Example 14 with PropertyConstant

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

the class AdaLikeDataTypeChecker method checkDefinition.

@Override
public TypeHolder checkDefinition(BehaviorElement e, Enumerator operator, TypeHolder operand1, TypeHolder operand2) {
    // Operator ** has special consistency checking.
    if (operator != BinaryNumericOperator.MULTIPLY_MULTIPLY && !conformsTo(operand1, operand2, true)) {
        reportErrorConsystency(e, operator, operand1, operand2);
        return null;
    }
    if (operator instanceof LogicalOperator) {
        if (operand1.getDataRep() == DataRepresentation.BOOLEAN) {
            return getTopLevelTypeWithoutConsistencyChecking(operand1, operand1);
        } else {
            reportErrorBinaryOperator(e, operator, operand1);
            return null;
        }
    } else if (operator instanceof RelationalOperator) {
        RelationalOperator rop = (RelationalOperator) operator;
        DataRepresentation[] expectedTypes = null;
        // Operators = and != are defined for all coherent types.
        if (rop == RelationalOperator.EQUAL || rop == RelationalOperator.NOT_EQUAL) {
            return new TypeHolder(DataRepresentation.BOOLEAN, null);
        }
        expectedTypes = _alphaNumTypes;
        if (Aadl2Utils.contains(operand1.getDataRep(), expectedTypes)) {
            return new TypeHolder(DataRepresentation.BOOLEAN, null);
        } else {
            reportErrorBinaryOperator(e, operator, operand1);
            return null;
        }
    } else if (operator instanceof BinaryAddingOperator) {
        if (Aadl2Utils.contains(operand1.getDataRep(), _numTypes)) {
            return getTopLevelTypeWithoutConsistencyChecking(operand1, operand2);
        } else {
            reportErrorBinaryOperator(e, operator, operand1);
            return null;
        }
    } else if (operator instanceof MultiplyingOperator) {
        MultiplyingOperator op = (MultiplyingOperator) operator;
        switch(op) {
            case MULTIPLY:
            case DIVIDE:
                {
                    if (Aadl2Utils.contains(operand1.getDataRep(), _numTypes)) {
                        return getTopLevelTypeWithoutConsistencyChecking(operand1, operand2);
                    } else {
                        reportErrorBinaryOperator(e, operator, operand1);
                        return null;
                    }
                }
            case MOD:
            case REM:
                {
                    if (operand1.getDataRep() == DataRepresentation.INTEGER) {
                        return getTopLevelTypeWithoutConsistencyChecking(operand1, operand2);
                    } else {
                        reportErrorBinaryOperator(e, operator, operand1);
                        return null;
                    }
                }
            default:
                return null;
        }
    } else if (operator instanceof BinaryNumericOperator) {
        // Checks operands consistency:
        if (Aadl2Utils.contains(operand1.getDataRep(), _numTypesWithoutFixed)) {
            boolean reportError = false;
            if (operand2.getDataRep() == DataRepresentation.INTEGER) {
                // Datatyped operand case : checks if operand2 is a natural.
                if (operand2.getKlass() != null) {
                    EList<org.osate.aadl2.PropertyExpression> l = PropertyUtils.findPropertyExpression(operand2.getKlass(), DataModelProperties.INTEGER_RANGE);
                    if (l.size() > 0) {
                        RangeValue rv = (RangeValue) l.get(l.size() - 1);
                        if (rv.getMinimumValue().getScaledValue() < 0) {
                            reportError = true;
                        }
                    } else {
                        reportError = true;
                    }
                } else // constant data case : checks if the constant value is not
                // negative.
                {
                    if (e instanceof Factor) {
                        Value val = ((Factor) e).getSecondValue();
                        // PropertyConstants and warns PropertyValues.
                        if (val instanceof BehaviorPropertyConstant) {
                            BehaviorPropertyConstant bpc = (BehaviorPropertyConstant) val;
                            org.osate.aadl2.PropertyConstant pc = bpc.getProperty();
                            org.osate.aadl2.IntegerLiteral intLit = (org.osate.aadl2.IntegerLiteral) pc.getConstantValue();
                            if (intLit.getValue() < 0) {
                                reportError = true;
                            }
                        } else if (val instanceof PropertyReference) // PropertyValue case : its value can only be evaluated at
                        // runtime so raises a warning.
                        {
                            _errManager.warning(e, "Cannot evaluate if the exponent" + " is a natural");
                        }
                    }
                }
            } else {
                reportError = true;
            }
            if (reportError) {
                _errManager.error(e, "exponent must be of type natural, found " + operand2.toString());
                return null;
            } else {
                return operand1;
            }
        } else {
            reportErrorConsystency(e, operator, operand1, operand2);
            return null;
        }
    } else {
        String errorMsg = "operator : " + operator.getName() + " is not supported.";
        System.err.println(errorMsg);
        throw new UnsupportedOperationException(errorMsg);
    }
}
Also used : RelationalOperator(org.osate.ba.aadlba.RelationalOperator) LogicalOperator(org.osate.ba.aadlba.LogicalOperator) RangeValue(org.osate.aadl2.RangeValue) PropertyReference(org.osate.ba.aadlba.PropertyReference) BehaviorPropertyConstant(org.osate.ba.aadlba.BehaviorPropertyConstant) Factor(org.osate.ba.aadlba.Factor) BinaryAddingOperator(org.osate.ba.aadlba.BinaryAddingOperator) RangeValue(org.osate.aadl2.RangeValue) Value(org.osate.ba.aadlba.Value) MultiplyingOperator(org.osate.ba.aadlba.MultiplyingOperator) BinaryNumericOperator(org.osate.ba.aadlba.BinaryNumericOperator)

Example 15 with PropertyConstant

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

the class AadlProject method getMaxQueueSize.

public static long getMaxQueueSize(EObject lookupContext) {
    PropertyConstant constant = getMaxQueueSize_PropertyConstant(lookupContext);
    PropertyExpression resolved = CodeGenUtil.resolveNamedValue(constant.getConstantValue());
    return ((IntegerLiteral) resolved).getValue();
}
Also used : PropertyExpression(org.osate.aadl2.PropertyExpression) PropertyConstant(org.osate.aadl2.PropertyConstant) IntegerLiteral(org.osate.aadl2.IntegerLiteral)

Aggregations

PropertyConstant (org.osate.aadl2.PropertyConstant)40 PropertyExpression (org.osate.aadl2.PropertyExpression)27 IntegerLiteral (org.osate.aadl2.IntegerLiteral)18 Property (org.osate.aadl2.Property)14 Classifier (org.osate.aadl2.Classifier)12 ClassifierValue (org.osate.aadl2.ClassifierValue)12 ListValue (org.osate.aadl2.ListValue)12 NamedValue (org.osate.aadl2.NamedValue)10 NamedElement (org.osate.aadl2.NamedElement)9 List (java.util.List)8 EObject (org.eclipse.emf.ecore.EObject)8 IntegerWithUnits (org.osate.pluginsupport.properties.IntegerWithUnits)7 AbstractNamedValue (org.osate.aadl2.AbstractNamedValue)6 ContainedNamedElement (org.osate.aadl2.ContainedNamedElement)6 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