Search in sources :

Example 11 with PropertyLookupException

use of org.osate.aadl2.properties.PropertyLookupException in project osate-plugin by sireum.

the class HAMRPropertyProvider method getPlatformsFromElement.

public static List<Platform> getPlatformsFromElement(NamedElement ne) {
    List<Platform> r = new ArrayList<>();
    try {
        Property p = GetProperties.lookupPropertyDefinition(ne, PROP_HAMR__PLATFORM);
        List<? extends PropertyExpression> propertyValues = ne.getPropertyValueList(p);
        for (PropertyExpression pe : propertyValues) {
            String v = ((EnumerationLiteral) ((NamedValue) pe).getNamedValue()).getName();
            r.add(Platform.valueOf(v));
        }
    } catch (PropertyLookupException e) {
    }
    return r;
}
Also used : ArrayList(java.util.ArrayList) PropertyExpression(org.osate.aadl2.PropertyExpression) Property(org.osate.aadl2.Property) EnumerationLiteral(org.osate.aadl2.EnumerationLiteral) PropertyLookupException(org.osate.aadl2.properties.PropertyLookupException)

Example 12 with PropertyLookupException

use of org.osate.aadl2.properties.PropertyLookupException 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 13 with PropertyLookupException

use of org.osate.aadl2.properties.PropertyLookupException in project osate2 by osate.

the class PokProperties method getSlotsAllocation.

public static List<ComponentInstance> getSlotsAllocation(final NamedElement ne) {
    List<ComponentInstance> res;
    res = new ArrayList<ComponentInstance>();
    try {
        Property slotsAllocation = GetProperties.lookupPropertyDefinition(ne, PokProperties._NAME, PokProperties._SLOTS_ALLOCATION);
        List<? extends PropertyExpression> propertyValues = ne.getPropertyValueList(slotsAllocation);
        for (PropertyExpression propertyExpression : propertyValues) {
            InstanceReferenceValue ref = (InstanceReferenceValue) propertyExpression;
            res.add(ref.getReferencedInstanceObject().getComponentInstance());
        }
        return res;
    } catch (PropertyLookupException e) {
        return null;
    }
}
Also used : ComponentInstance(org.osate.aadl2.instance.ComponentInstance) PropertyExpression(org.osate.aadl2.PropertyExpression) InstanceReferenceValue(org.osate.aadl2.instance.InstanceReferenceValue) Property(org.osate.aadl2.Property) PropertyLookupException(org.osate.aadl2.properties.PropertyLookupException)

Example 14 with PropertyLookupException

use of org.osate.aadl2.properties.PropertyLookupException in project osate2 by osate.

the class GetProperties method getSchedulingProtocol.

public static String getSchedulingProtocol(final NamedElement ne) {
    try {
        Property schedulingprotocol = lookupPropertyDefinition(ne, DeploymentProperties._NAME, DeploymentProperties.SCHEDULING_PROTOCOL);
        List<? extends PropertyExpression> propertyValues = ne.getPropertyValueList(schedulingprotocol);
        if (!propertyValues.isEmpty()) {
            return ((EnumerationLiteral) ((NamedValue) propertyValues.iterator().next()).getNamedValue()).getName();
        } else {
            return null;
        }
    } catch (PropertyLookupException e) {
        return null;
    }
}
Also used : BasicProperty(org.osate.aadl2.BasicProperty) Property(org.osate.aadl2.Property) EnumerationLiteral(org.osate.aadl2.EnumerationLiteral) PropertyLookupException(org.osate.aadl2.properties.PropertyLookupException)

Example 15 with PropertyLookupException

use of org.osate.aadl2.properties.PropertyLookupException in project osate2 by osate.

the class GetProperties method getDataEnumerators.

public static List<String> getDataEnumerators(final NamedElement ne) {
    List<String> res;
    res = new ArrayList<String>();
    try {
        Property st = lookupPropertyDefinition(ne, DataModel._NAME, DataModel.Enumerators);
        List<? extends PropertyExpression> propertyValues = ne.getPropertyValueList(st);
        for (PropertyExpression propertyExpression : propertyValues) {
            // System.out.println("pe=" + propertyExpression);
            StringLiteral sl = (StringLiteral) propertyExpression;
            res.add(sl.getValue());
        }
        return res;
    } catch (PropertyLookupException e) {
        return null;
    }
}
Also used : StringLiteral(org.osate.aadl2.StringLiteral) PropertyExpression(org.osate.aadl2.PropertyExpression) BasicProperty(org.osate.aadl2.BasicProperty) Property(org.osate.aadl2.Property) PropertyLookupException(org.osate.aadl2.properties.PropertyLookupException)

Aggregations

PropertyLookupException (org.osate.aadl2.properties.PropertyLookupException)23 PropertyExpression (org.osate.aadl2.PropertyExpression)19 Property (org.osate.aadl2.Property)16 BasicProperty (org.osate.aadl2.BasicProperty)12 EnumerationLiteral (org.osate.aadl2.EnumerationLiteral)8 ArrayList (java.util.ArrayList)6 StringLiteral (org.osate.aadl2.StringLiteral)4 NamedValue (org.osate.aadl2.NamedValue)3 RangeValue (org.osate.aadl2.RangeValue)3 ComponentInstance (org.osate.aadl2.instance.ComponentInstance)3 InstanceReferenceValue (org.osate.aadl2.instance.InstanceReferenceValue)3 IntegerLiteral (org.osate.aadl2.IntegerLiteral)2 ModalPropertyValue (org.osate.aadl2.ModalPropertyValue)2 UnitLiteral (org.osate.aadl2.UnitLiteral)2 PropertyAcc (org.osate.aadl2.properties.PropertyAcc)2 BooleanLiteral (org.osate.aadl2.BooleanLiteral)1 Classifier (org.osate.aadl2.Classifier)1 ComponentClassifier (org.osate.aadl2.ComponentClassifier)1 ComponentType (org.osate.aadl2.ComponentType)1 NumberValue (org.osate.aadl2.NumberValue)1