Search in sources :

Example 1 with TransmissionTime

use of org.osate.aadl2.contrib.communication.TransmissionTime in project osate2 by osate.

the class FlowLatencyAnalysisSwitch method getTimeToTransferData.

private static RealRange getTimeToTransferData(final NamedElement bus, double datasizeinbyte) {
    final Optional<TransmissionTime> tt_o = org.osate.aadl2.contrib.communication.CommunicationProperties.getTransmissionTime(bus);
    if (tt_o.isPresent()) {
        final TransmissionTime tt = tt_o.get();
        final RealRange fixedRange = PropertyUtils.scaleRange(tt.getFixed(), TimeUnits.MS).orElse(RealRange.ZEROED);
        final RealRange perByteRange = PropertyUtils.scaleRange(tt.getPerbyte(), TimeUnits.MS).orElse(RealRange.ZEROED);
        final double min = fixedRange.getMinimum() + (datasizeinbyte * perByteRange.getMinimum());
        final double max = fixedRange.getMaximum() + (datasizeinbyte * perByteRange.getMaximum());
        return new RealRange(min, max);
    } else {
        return new RealRange(0.0, 0.0);
    }
}
Also used : RealRange(org.osate.pluginsupport.properties.RealRange) TransmissionTime(org.osate.aadl2.contrib.communication.TransmissionTime)

Example 2 with TransmissionTime

use of org.osate.aadl2.contrib.communication.TransmissionTime in project osate2 by osate.

the class CommunicationProperties method getTransmissionTime.

public static Optional<TransmissionTime> getTransmissionTime(NamedElement lookupContext, Optional<Mode> mode) {
    Property property = getTransmissionTime_Property(lookupContext);
    try {
        PropertyExpression value = CodeGenUtil.lookupProperty(property, lookupContext, mode);
        PropertyExpression resolved = CodeGenUtil.resolveNamedValue(value, lookupContext, mode);
        return Optional.of(new TransmissionTime(resolved, lookupContext, mode));
    } 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

Property (org.osate.aadl2.Property)1 PropertyExpression (org.osate.aadl2.PropertyExpression)1 TransmissionTime (org.osate.aadl2.contrib.communication.TransmissionTime)1 PropertyNotPresentException (org.osate.aadl2.properties.PropertyNotPresentException)1 RealRange (org.osate.pluginsupport.properties.RealRange)1