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;
}
}
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();
}
}
Aggregations