org.eclipse.app4mc.amalthea.model

Class AmaltheaServices



  • public class AmaltheaServices
    extends Object
    This class provides static methods that implement operations of the Amalthea EMF model.

    The methods are called from several generated model objects.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      static List<TimeUnit> TIME_UNIT_LIST  
    • Method Summary

      All Methods 
      Modifier and Type Method Description
      static @NonNull Time addTime​(@NonNull Time t1, @NonNull Time t2)  
      static @NonNull Time adjustTimeUnit​(@NonNull Time time)
      This method takes a time (in value and unit) and adjusts the TimeUnit so that the value is as small as possible, without losing precision e.g. 1000us is converted to 1ms
      static int compareDataRates​(@NonNull DataRate r1, @NonNull DataRate r2)
      This method is used to compare DataRate objects on the basis of their values (obtained in bit per second after applying the conversion based on DataRateUnit)
      static int compareTimes​(@NonNull Time t1, @NonNull Time t2)
      This method is used to compare Time objects on the basis of their values (obtained in pico seconds after applying the conversion based on TimeUnit)
      static BigInteger convertToBit​(@NonNull DataSize size)  
      static BigInteger convertToBitPerSecond​(@NonNull DataRate rate)  
      static BigDecimal convertToHertz​(@NonNull Frequency frequency)  
      static BigDecimal convertToMicroVolt​(@NonNull Voltage voltage)  
      static BigInteger convertToPicoSeconds​(@NonNull Time time)
      This method is used to convert the value of Time/TimeObject element's value to BigInteger in Pico Seconds
      static BigDecimal convertToSeconds​(double time, @NonNull TimeUnit timeUnit)
      This method is used to convert a time with associated time unit to BigDecimal in seconds
      static BigDecimal convertToSeconds​(@NonNull Time time)
      This method is used to convert the value of Time/TimeObject element's value to BigDecimal in seconds
      static double divideTime​(@NonNull Time t1, @NonNull Time t2)
      Divides t1 by t2
      static EList<HwModule> getAllModules​(@NonNull HwStructure struct)  
      static double getAverageOfBetaDistribution​(@NonNull Number inputA, @NonNull Number inputB, double alpha, double beta)  
      static Time getAverageOfBetaDistribution​(@NonNull Time a, @NonNull Time b, double alpha, double beta)  
      static double getAverageOfTruncatedNormalDistribution​(@Nullable Number inputA, @Nullable Number inputB, double mean, double sd)
      Computes the average (mean) of the truncated normal distribution
      static @NonNull Time getAverageOfTruncatedNormalDistribution​(@Nullable Time a, @Nullable Time b, @NonNull Time mean, @NonNull Time sd)
      Computes the average (mean) of the truncated normal distribution
      static <T extends EObject>
      T
      getContainerOfType​(@NonNull EObject object, @NonNull Class<T> type)  
      static EList<HwPort> getInnerPorts​(@NonNull HwStructure struct)  
      static EList<QualifiedPort> getInnerPorts​(@NonNull ISystem system)  
      static @NonNull Time multiply​(@NonNull Time t1, double value)  
      static @NonNull Time multiply​(@NonNull Time t1, long value)  
      static @NonNull Time subtractTime​(@NonNull Time t1, @NonNull Time t2)  
      • Methods inherited from class Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • TIME_UNIT_LIST

        public static final List<TimeUnit> TIME_UNIT_LIST
    • Method Detail

      • getContainerOfType

        public static <T extends EObject> T getContainerOfType​(@NonNull EObject object,
                                                               @NonNull Class<T> type)
      • convertToBit

        public static BigInteger convertToBit​(@NonNull DataSize size)
      • convertToBitPerSecond

        public static BigInteger convertToBitPerSecond​(@NonNull DataRate rate)
      • convertToPicoSeconds

        public static BigInteger convertToPicoSeconds​(@NonNull Time time)
        This method is used to convert the value of Time/TimeObject element's value to BigInteger in Pico Seconds
        Parameters:
        time - Time object
        Returns:
        value BigInteger in Pico Seconds
      • convertToSeconds

        public static BigDecimal convertToSeconds​(double time,
                                                  @NonNull TimeUnit timeUnit)
        This method is used to convert a time with associated time unit to BigDecimal in seconds
        Parameters:
        time - time as double
        timeUnit - the time unit
        Returns:
        value BigDecimal in seconds
      • convertToSeconds

        public static BigDecimal convertToSeconds​(@NonNull Time time)
        This method is used to convert the value of Time/TimeObject element's value to BigDecimal in seconds
        Parameters:
        time - Time object
        Returns:
        value BigDecimal in seconds
      • convertToHertz

        public static BigDecimal convertToHertz​(@NonNull Frequency frequency)
      • convertToMicroVolt

        public static BigDecimal convertToMicroVolt​(@NonNull Voltage voltage)
      • compareDataRates

        public static int compareDataRates​(@NonNull DataRate r1,
                                           @NonNull DataRate r2)
        This method is used to compare DataRate objects on the basis of their values (obtained in bit per second after applying the conversion based on DataRateUnit)
        Parameters:
        r1 - DataRate object
        r2 - DataRate object
        Returns:
        -1 ,0 or 1
      • compareTimes

        public static int compareTimes​(@NonNull Time t1,
                                       @NonNull Time t2)
        This method is used to compare Time objects on the basis of their values (obtained in pico seconds after applying the conversion based on TimeUnit)
        Parameters:
        t1 - Time object
        t2 - Time object
        Returns:
        -1 ,0 or 1
      • adjustTimeUnit

        public static @NonNull Time adjustTimeUnit​(@NonNull Time time)
        This method takes a time (in value and unit) and adjusts the TimeUnit so that the value is as small as possible, without losing precision e.g. 1000us is converted to 1ms
        Parameters:
        time -
        Returns:
        new Time with adjusted value and unit
      • addTime

        public static @NonNull Time addTime​(@NonNull Time t1,
                                   @NonNull Time t2)
      • subtractTime

        public static @NonNull Time subtractTime​(@NonNull Time t1,
                                        @NonNull Time t2)
      • divideTime

        public static double divideTime​(@NonNull Time t1,
                                        @NonNull Time t2)
        Divides t1 by t2

        In case of t2 == 0 the limit t2 -> 0 is used

        Parameters:
        t1 -
        t2 -
        Returns:
        t1 / t2
      • multiply

        public static @NonNull Time multiply​(@NonNull Time t1,
                                    long value)
      • multiply

        public static @NonNull Time multiply​(@NonNull Time t1,
                                    double value)
      • getAverageOfTruncatedNormalDistribution

        public static @NonNull Time getAverageOfTruncatedNormalDistribution​(@Nullable Time a,
                                                                   @Nullable Time b,
                                                                   @NonNull Time mean,
                                                                   @NonNull Time sd)
        Computes the average (mean) of the truncated normal distribution

        See Truncated normal distribution (Wikipedia)

        Parameters:
        a - lower bound (null = not truncated from below)
        b - upper bound (null = not truncated from above)
        mean - mean or expectation of the (unlimited) distribution
        sd - standard deviation
        Returns:
        Average of the truncated distribution
      • getAverageOfTruncatedNormalDistribution

        public static double getAverageOfTruncatedNormalDistribution​(@Nullable Number inputA,
                                                                     @Nullable Number inputB,
                                                                     double mean,
                                                                     double sd)
        Computes the average (mean) of the truncated normal distribution

        See Truncated normal distribution (Wikipedia)

        Parameters:
        inputA - lower bound (null = not truncated from below)
        inputB - upper bound (null = not truncated from above)
        mean - mean or expectation of the (unlimited) distribution
        sd - standard deviation
        Returns:
        Average of the truncated distribution
      • getAverageOfBetaDistribution

        public static Time getAverageOfBetaDistribution​(@NonNull Time a,
                                                        @NonNull Time b,
                                                        double alpha,
                                                        double beta)
      • getAverageOfBetaDistribution

        public static Double getAverageOfBetaDistribution​(@NonNull Number inputA,
                                                          @NonNull Number inputB,
                                                          double alpha,
                                                          double beta)
      • getInnerPorts

        public static EList<QualifiedPort> getInnerPorts​(@NonNull ISystem system)
      • getInnerPorts

        public static EList<HwPort> getInnerPorts​(@NonNull HwStructure struct)
      • getAllModules

        public static EList<HwModule> getAllModules​(@NonNull HwStructure struct)