Search in sources :

Example 6 with PropertyExpression

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

the class AgreeTypeSystem method getArraySize.

private static long getArraySize(ArrayDimension arrayDimension) {
    ArraySize arraySize = arrayDimension.getSize();
    long size = arraySize.getSize();
    if (size == 0) {
        ArraySizeProperty arraySizeProperty = arraySize.getSizeProperty();
        if (arraySizeProperty instanceof PropertyConstant) {
            PropertyExpression pe = ((PropertyConstant) arraySizeProperty).getConstantValue();
            size = intFromPropExp(pe).orElse((long) -1);
        }
    }
    assert size > 0;
    return size;
}
Also used : ArraySize(org.osate.aadl2.ArraySize) PropertyExpression(org.osate.aadl2.PropertyExpression) PropertyConstant(org.osate.aadl2.PropertyConstant) ArraySizeProperty(org.osate.aadl2.ArraySizeProperty)

Example 7 with PropertyExpression

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

the class AgreeAADLPropertyUtils method getPropertyList.

public static List<PropertyExpression> getPropertyList(NamedElement namedEl, String property) {
    List<PropertyExpression> els = new ArrayList<>();
    Property prop = Aadl2GlobalScopeUtil.get(namedEl, Aadl2Package.eINSTANCE.getProperty(), property);
    ListValue listExpr = (ListValue) PropertyUtils.getSimplePropertyListValue(namedEl, prop);
    for (PropertyExpression propExpr : listExpr.getOwnedListElements()) {
        els.add(propExpr);
    }
    return els;
}
Also used : ListValue(org.osate.aadl2.ListValue) ArrayList(java.util.ArrayList) PropertyExpression(org.osate.aadl2.PropertyExpression) Property(org.osate.aadl2.Property)

Example 8 with PropertyExpression

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

the class AgreeTypeSystem method hasBooleanDataRepresentation.

public static boolean hasBooleanDataRepresentation(Classifier classifier) {
    boolean result = false;
    EList<PropertyAssociation> propertyAssociations = classifier.getAllPropertyAssociations();
    for (PropertyAssociation propertyAssociation : propertyAssociations) {
        Property property = propertyAssociation.getProperty();
        try {
            PropertyExpression propertyExpr = classifier.getSimplePropertyValue(property);
            if ("Data_Model::Data_Representation".equals(property.getQualifiedName()) && propertyExpr instanceof NamedValue) {
                AbstractNamedValue abstractNamedValue = ((NamedValue) propertyExpr).getNamedValue();
                if (abstractNamedValue instanceof EnumerationLiteral && "Boolean".equals(((EnumerationLiteral) abstractNamedValue).getName())) {
                    result = true;
                }
            }
        } catch (Exception e) {
            continue;
        }
    }
    return result;
}
Also used : PropertyAssociation(org.osate.aadl2.PropertyAssociation) AbstractNamedValue(org.osate.aadl2.AbstractNamedValue) PropertyExpression(org.osate.aadl2.PropertyExpression) AbstractNamedValue(org.osate.aadl2.AbstractNamedValue) NamedValue(org.osate.aadl2.NamedValue) ArraySizeProperty(org.osate.aadl2.ArraySizeProperty) Property(org.osate.aadl2.Property) EnumerationLiteral(org.osate.aadl2.EnumerationLiteral)

Example 9 with PropertyExpression

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

the class Arinc653 method getDal.

public static Optional<SupportedDalType> getDal(NamedElement lookupContext, Optional<Mode> mode) {
    Property property = getDal_Property(lookupContext);
    try {
        PropertyExpression value = CodeGenUtil.lookupProperty(property, lookupContext, mode);
        PropertyExpression resolved = CodeGenUtil.resolveNamedValue(value, lookupContext, mode);
        return Optional.of(SupportedDalType.valueOf(resolved));
    } catch (PropertyNotPresentException e) {
        return Optional.empty();
    }
}
Also used : PropertyNotPresentException(org.osate.aadl2.properties.PropertyNotPresentException) PropertyExpression(org.osate.aadl2.PropertyExpression) Property(org.osate.aadl2.Property)

Example 10 with PropertyExpression

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

the class CodeGenerationProperties method getParameterUsage.

public static Optional<ParameterUsage> getParameterUsage(NamedElement lookupContext, Optional<Mode> mode) {
    Property property = getParameterUsage_Property(lookupContext);
    try {
        PropertyExpression value = CodeGenUtil.lookupProperty(property, lookupContext, mode);
        PropertyExpression resolved = CodeGenUtil.resolveNamedValue(value, lookupContext, mode);
        return Optional.of(ParameterUsage.valueOf(resolved));
    } catch (PropertyNotPresentException e) {
        return Optional.empty();
    }
}
Also used : PropertyNotPresentException(org.osate.aadl2.properties.PropertyNotPresentException) PropertyExpression(org.osate.aadl2.PropertyExpression) Property(org.osate.aadl2.Property)

Aggregations

PropertyExpression (org.osate.aadl2.PropertyExpression)405 Property (org.osate.aadl2.Property)300 PropertyNotPresentException (org.osate.aadl2.properties.PropertyNotPresentException)246 ListValue (org.osate.aadl2.ListValue)89 BasicProperty (org.osate.aadl2.BasicProperty)51 PropertyAssociation (org.osate.aadl2.PropertyAssociation)41 TimeUnits (org.osate.aadl2.contrib.aadlproject.TimeUnits)40 PropertyLookupException (org.osate.aadl2.properties.PropertyLookupException)36 BasicPropertyAssociation (org.osate.aadl2.BasicPropertyAssociation)34 IntegerLiteral (org.osate.aadl2.IntegerLiteral)33 InstanceReferenceValue (org.osate.aadl2.instance.InstanceReferenceValue)32 ModalPropertyValue (org.osate.aadl2.ModalPropertyValue)31 ArrayList (java.util.ArrayList)29 EnumerationLiteral (org.osate.aadl2.EnumerationLiteral)28 NamedElement (org.osate.aadl2.NamedElement)27 NamedValue (org.osate.aadl2.NamedValue)27 PropertyConstant (org.osate.aadl2.PropertyConstant)27 ClassifierValue (org.osate.aadl2.ClassifierValue)26 StringLiteral (org.osate.aadl2.StringLiteral)26 ENotificationImpl (org.eclipse.emf.ecore.impl.ENotificationImpl)23