Search in sources :

Example 1 with IntegerRangeWithUnits

use of org.osate.pluginsupport.properties.IntegerRangeWithUnits in project osate2 by osate.

the class FlowLatencyAnalysisSwitch method getTimeInMilliSec2.

private RealRange getTimeInMilliSec2(final FlowElementInstance fei, final ComponentInstance ci, final boolean isPeriodic, final Function<NamedElement, Optional<IntegerRangeWithUnits<TimeUnits>>> getExecTime) {
    /*
		 * If the flow element is a component instance or if the thread is periodic, we use the thread's
		 * computation time. Otherwise we try to use the compute execution time from the flow's input feature.
		 */
    if (!(isPeriodic || fei == ci)) {
        // the flow element is a FlowSpecificationInstance (It is not periodic or a component instance)
        final FlowSpecificationInstance fsi = (FlowSpecificationInstance) fei;
        final FlowEnd allInEnd = fsi.getFlowSpecification().getAllInEnd();
        if (allInEnd != null) {
            // we have an input feature
            FeatureInstance fi = null;
            if (allInEnd.getContext() instanceof FeatureGroup) {
                final FeatureInstance fgi = ci.findFeatureInstance((FeatureGroup) allInEnd.getContext());
                fi = fgi.findFeatureInstance(allInEnd.getFeature());
            } else {
                fi = ci.findFeatureInstance(allInEnd.getFeature());
            }
            final FeatureCategory featureCategory = fi.getCategory();
            if (featureCategory == FeatureCategory.EVENT_PORT || featureCategory == FeatureCategory.EVENT_DATA_PORT) {
                final Optional<IntegerRangeWithUnits<TimeUnits>> fromFeature = getExecTime.apply(fi);
                if (fromFeature.isPresent()) {
                    return AnalysisUtils.scaleTimeRange(PropertyUtils.scaleRange(fromFeature.get(), TimeUnits.MS), fi);
                }
            // otherwise fall through and get from component
            }
        // otherwise fall through and get from component
        }
    }
    final ComponentCategory componentCategory = ci.getCategory();
    if (componentCategory == ComponentCategory.THREAD || componentCategory == ComponentCategory.DEVICE || componentCategory == ComponentCategory.SUBPROGRAM || componentCategory == ComponentCategory.ABSTRACT) {
        return AnalysisUtils.scaleTimeRange(PropertyUtils.scaleRange(getExecTime.apply(ci), TimeUnits.MS).orElse(RealRange.ZEROED), ci);
    } else {
        return RealRange.ZEROED;
    }
}
Also used : FeatureGroup(org.osate.aadl2.FeatureGroup) FeatureInstance(org.osate.aadl2.instance.FeatureInstance) IntegerRangeWithUnits(org.osate.pluginsupport.properties.IntegerRangeWithUnits) FlowSpecificationInstance(org.osate.aadl2.instance.FlowSpecificationInstance) ComponentCategory(org.osate.aadl2.ComponentCategory) FeatureCategory(org.osate.aadl2.instance.FeatureCategory) FlowEnd(org.osate.aadl2.FlowEnd)

Example 2 with IntegerRangeWithUnits

use of org.osate.pluginsupport.properties.IntegerRangeWithUnits in project osate2 by osate.

the class DeploymentProperties method getAllowedPeriod.

public static Optional<List<IntegerRangeWithUnits<TimeUnits>>> getAllowedPeriod(NamedElement lookupContext, Optional<Mode> mode) {
    Property property = getAllowedPeriod_Property(lookupContext);
    try {
        PropertyExpression value = CodeGenUtil.lookupProperty(property, lookupContext, mode);
        PropertyExpression resolved = CodeGenUtil.resolveNamedValue(value, lookupContext, mode);
        return Optional.of(((ListValue) resolved).getOwnedListElements().stream().map(element1 -> {
            PropertyExpression resolved1 = CodeGenUtil.resolveNamedValue(element1, lookupContext, mode);
            return new IntegerRangeWithUnits<>(resolved1, TimeUnits.class, lookupContext, mode);
        }).collect(Collectors.toList()));
    } catch (PropertyNotPresentException e) {
        return Optional.empty();
    }
}
Also used : PropertyNotPresentException(org.osate.aadl2.properties.PropertyNotPresentException) ListValue(org.osate.aadl2.ListValue) PropertyExpression(org.osate.aadl2.PropertyExpression) IntegerRangeWithUnits(org.osate.pluginsupport.properties.IntegerRangeWithUnits) Property(org.osate.aadl2.Property)

Aggregations

IntegerRangeWithUnits (org.osate.pluginsupport.properties.IntegerRangeWithUnits)2 ComponentCategory (org.osate.aadl2.ComponentCategory)1 FeatureGroup (org.osate.aadl2.FeatureGroup)1 FlowEnd (org.osate.aadl2.FlowEnd)1 ListValue (org.osate.aadl2.ListValue)1 Property (org.osate.aadl2.Property)1 PropertyExpression (org.osate.aadl2.PropertyExpression)1 FeatureCategory (org.osate.aadl2.instance.FeatureCategory)1 FeatureInstance (org.osate.aadl2.instance.FeatureInstance)1 FlowSpecificationInstance (org.osate.aadl2.instance.FlowSpecificationInstance)1 PropertyNotPresentException (org.osate.aadl2.properties.PropertyNotPresentException)1