Search in sources :

Example 1 with TimeUnits

use of org.osate.aadl2.contrib.aadlproject.TimeUnits 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 TimeUnits

use of org.osate.aadl2.contrib.aadlproject.TimeUnits in project osate2 by osate.

the class TimingProperties method getDeactivateExecutionTime.

public static Optional<IntegerRangeWithUnits<TimeUnits>> getDeactivateExecutionTime(NamedElement lookupContext, Optional<Mode> mode) {
    Property property = getDeactivateExecutionTime_Property(lookupContext);
    try {
        PropertyExpression value = CodeGenUtil.lookupProperty(property, lookupContext, mode);
        PropertyExpression resolved = CodeGenUtil.resolveNamedValue(value, lookupContext, mode);
        return Optional.of(new IntegerRangeWithUnits<>(resolved, TimeUnits.class, lookupContext, mode));
    } catch (PropertyNotPresentException e) {
        return Optional.empty();
    }
}
Also used : TimeUnits(org.osate.aadl2.contrib.aadlproject.TimeUnits) PropertyNotPresentException(org.osate.aadl2.properties.PropertyNotPresentException) PropertyExpression(org.osate.aadl2.PropertyExpression) Property(org.osate.aadl2.Property)

Example 3 with TimeUnits

use of org.osate.aadl2.contrib.aadlproject.TimeUnits in project osate2 by osate.

the class TimingProperties method getFinalizeExecutionTime.

public static Optional<IntegerRangeWithUnits<TimeUnits>> getFinalizeExecutionTime(NamedElement lookupContext, Optional<Mode> mode) {
    Property property = getFinalizeExecutionTime_Property(lookupContext);
    try {
        PropertyExpression value = CodeGenUtil.lookupProperty(property, lookupContext, mode);
        PropertyExpression resolved = CodeGenUtil.resolveNamedValue(value, lookupContext, mode);
        return Optional.of(new IntegerRangeWithUnits<>(resolved, TimeUnits.class, lookupContext, mode));
    } catch (PropertyNotPresentException e) {
        return Optional.empty();
    }
}
Also used : TimeUnits(org.osate.aadl2.contrib.aadlproject.TimeUnits) PropertyNotPresentException(org.osate.aadl2.properties.PropertyNotPresentException) PropertyExpression(org.osate.aadl2.PropertyExpression) Property(org.osate.aadl2.Property)

Example 4 with TimeUnits

use of org.osate.aadl2.contrib.aadlproject.TimeUnits in project osate2 by osate.

the class TimingProperties method getFirstDispatchTime.

public static Optional<IntegerWithUnits<TimeUnits>> getFirstDispatchTime(NamedElement lookupContext, Optional<Mode> mode) {
    Property property = getFirstDispatchTime_Property(lookupContext);
    try {
        PropertyExpression value = CodeGenUtil.lookupProperty(property, lookupContext, mode);
        PropertyExpression resolved = CodeGenUtil.resolveNamedValue(value, lookupContext, mode);
        return Optional.of(new IntegerWithUnits<>(resolved, TimeUnits.class));
    } catch (PropertyNotPresentException e) {
        return Optional.empty();
    }
}
Also used : TimeUnits(org.osate.aadl2.contrib.aadlproject.TimeUnits) PropertyNotPresentException(org.osate.aadl2.properties.PropertyNotPresentException) PropertyExpression(org.osate.aadl2.PropertyExpression) Property(org.osate.aadl2.Property)

Example 5 with TimeUnits

use of org.osate.aadl2.contrib.aadlproject.TimeUnits in project osate2 by osate.

the class TimingProperties method getComputeDeadline.

public static Optional<IntegerWithUnits<TimeUnits>> getComputeDeadline(NamedElement lookupContext, Optional<Mode> mode) {
    Property property = getComputeDeadline_Property(lookupContext);
    try {
        PropertyExpression value = CodeGenUtil.lookupProperty(property, lookupContext, mode);
        PropertyExpression resolved = CodeGenUtil.resolveNamedValue(value, lookupContext, mode);
        return Optional.of(new IntegerWithUnits<>(resolved, TimeUnits.class));
    } catch (PropertyNotPresentException e) {
        return Optional.empty();
    }
}
Also used : TimeUnits(org.osate.aadl2.contrib.aadlproject.TimeUnits) PropertyNotPresentException(org.osate.aadl2.properties.PropertyNotPresentException) PropertyExpression(org.osate.aadl2.PropertyExpression) Property(org.osate.aadl2.Property)

Aggregations

PropertyExpression (org.osate.aadl2.PropertyExpression)41 Property (org.osate.aadl2.Property)40 PropertyNotPresentException (org.osate.aadl2.properties.PropertyNotPresentException)40 TimeUnits (org.osate.aadl2.contrib.aadlproject.TimeUnits)39 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 PropertyConstant (org.osate.aadl2.PropertyConstant)1 FeatureCategory (org.osate.aadl2.instance.FeatureCategory)1 FeatureInstance (org.osate.aadl2.instance.FeatureInstance)1 FlowSpecificationInstance (org.osate.aadl2.instance.FlowSpecificationInstance)1 IntegerWithUnits (org.osate.pluginsupport.properties.IntegerWithUnits)1