Class Time

  • All Implemented Interfaces:

    
    public final class Time
    
                        
    • Constructor Detail

    • Method Detail

      • applyWhile

         final static <T extends Any> T applyWhile(Boolean event, Function1<Unit, T> f, T null)

        Apply a function while condition is true.

        Parameters:
        event - event
        f - function to be applied
        null - null value
        Returns:

        apply f if event occurs, return null otherwise

      • countDown

         final static Number countDown(Number length)
        Parameters:
        length - count down length
        Returns:

        remaining time

      • cyclicTimer

         final static Boolean cyclicTimer(Number length)

        Cyclic timer.

        Parameters:
        length - timeout
        Returns:

        true if the timeout is expired, false otherwise

      • cyclicTimerWithDecay

         final static Boolean cyclicTimerWithDecay(Number length, Number decay)

        Cyclic timer.

        Parameters:
        length - timeout
        decay - decay rate
        Returns:

        true if the timeout is expired, false otherwise

      • cyclicFunction

         final static <T extends Any> T cyclicFunction(Number length, Function1<Unit, T> f, T null)

        Periodically invoke a function.

        Parameters:
        length - timeout
        f - function to be invoked
        null - default value
        Returns:

        apply f if the timeout is expired, null otherwise

      • cyclicFunctionWithDecay

         final static <T extends Any> T cyclicFunctionWithDecay(Number length, Number decay, Function1<Unit, T> f, T null)

        Periodically invoke a function.

        Parameters:
        length - timeout
        decay - decay rate
        f - function to be invoked
        null - default value
        Returns:

        apply f if the timeout is expired, null otherwise

      • delta

         final static Number delta(Number signal)
        Parameters:
        signal - signal to be monitored
        Returns:

        variation between current and old values

      • evaporation

         final static <T extends Any> <Error class: unknown class> evaporation(Number length, T info, Number decay)

        Evaporation pattern.

        Parameters:
        length - duration
        info - information
        decay - decay rate
      • exponentialBackoffFilter

         final static Number exponentialBackoffFilter(Number signal, Number a)

        Exponential back-off filter.

        Parameters:
        signal - signal to be filtered
        a - alpha value
        Returns:

        filtered signal

      • falseAfterTime

         final static Boolean falseAfterTime(Number timeout)
        Parameters:
        timeout - timeout
        Returns:

        false after timeout, true otherwise

      • isFallingEdge

         final static Boolean isFallingEdge(Boolean signal)
        Parameters:
        signal - binary signal to be monitored
        Returns:

        true if the signal had a falling edge, false otherwise

      • isRecentEvent

         final static Boolean isRecentEvent(Boolean event, Number timeout)
        Parameters:
        event - event
        timeout - timeout
        Returns:

        true if the event occurred before timeout, false otherwise

      • isRisingEdge

         final static Boolean isRisingEdge(Boolean signal)
        Parameters:
        signal - binary signal to be monitored
        Returns:

        true if the signal had a rising edge, false otherwise

      • isSignalStable

         final static <T extends Any> Boolean isSignalStable(T signal, Number time)
        Parameters:
        signal - signal to be monitored
        time - consider the signal stable after this time
        Returns:

        true if the signal does not change for at least time

      • isSignalStableWithDt

         final static <T extends Any> Boolean isSignalStableWithDt(T signal, Number time, Number dt)
        Parameters:
        signal - signal to be monitored
        time - consider the signal stable after this time
        dt - dt
        Returns:

        true if the signal does not change for at least time

      • isValueChanged

         final static <T extends Any> Boolean isValueChanged(T signal)
        Parameters:
        signal - value to be monitored
        Returns:

        whether v has changed given its previous state

      • limitedMemory

         final static <T extends Any> T limitedMemory(T value, T null, Number timeout, Number dt)

        Hold value until a specified timeout.

        TODO: reconsider this function. When do we trigger the recording?

        Parameters:
        value - value to be stored
        null - default value
        timeout - hold the value for this amount of time
        dt - increase the time of this value
        Returns:

        hold value if timeout is not expired, null otherwise

      • trueAfterTime

         final static Boolean trueAfterTime(Number timeout)
        Parameters:
        timeout - timeout
        Returns:

        true after timeout, false otherwise

      • wait

         final static Boolean wait(Number timeout)
        Parameters:
        timeout - count down length
        Returns:

        whether the countdown is expired

      • waitWithDecay

         final static Boolean waitWithDecay(Number timeout, Number dt)
        Parameters:
        timeout - count down length
        dt - decay
        Returns:

        whether the countdown is expired

      • waitAndApply

         final static <T extends Any> T waitAndApply(Number timeout, Function1<Unit, T> f, T null)
        Parameters:
        timeout - timeut
        f - function to be applied
        null - null value
        Returns:

        apply f after x, null otherwise