Class Time
-
- All Implemented Interfaces:
public final class Time
-
-
Method Summary
Modifier and Type Method Description final static <T extends Any> T
applyWhile(Boolean event, Function1<Unit, T> f, T null)
Apply a function while condition is true. final static Number
countDown(Number length)
final static Number
countDownWithDecay(Number length, Number dt)
final static Boolean
cyclicTimer(Number length)
Cyclic timer. final static Boolean
cyclicTimerWithDecay(Number length, Number decay)
Cyclic timer. final static <T extends Any> T
cyclicFunction(Number length, Function1<Unit, T> f, T null)
Periodically invoke a function. final static <T extends Any> T
cyclicFunctionWithDecay(Number length, Number decay, Function1<Unit, T> f, T null)
Periodically invoke a function. final static Number
delta(Number signal)
final static <T extends Any> <Error class: unknown class>
evaporation(Number length, T info, Number decay)
Evaporation pattern. final static Number
exponentialBackoffFilter(Number signal, Number a)
Exponential back-off filter. final static Boolean
falseAfterTime(Number timeout)
final static Boolean
falseAfterTimeWithDt(Number timeout, Number dt)
final static Boolean
isFallingEdge(Boolean signal)
final static Boolean
isRecentEvent(Boolean event, Number timeout)
final static Boolean
isRisingEdge(Boolean signal)
final static <T extends Any> Boolean
isSignalStable(T signal, Number time)
final static <T extends Any> Boolean
isSignalStableWithDt(T signal, Number time, Number dt)
final static <T extends Any> Boolean
isValueChanged(T signal)
final static <T extends Any> T
limitedMemory(T value, T null, Number timeout, Number dt)
Hold value until a specified timeout. final static Unit
T(Object initial, Object zero, Object decay)
final static Boolean
trueAfterTime(Number timeout)
final static Boolean
trueAfterTimeWithDt(Number timeout, Number dt)
final static Boolean
wait(Number timeout)
final static Boolean
waitWithDecay(Number timeout, Number dt)
final static <T extends Any> T
waitAndApply(Number timeout, Function1<Unit, T> f, T null)
-
-
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
- eventf
- function to be appliednull
- 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
-
countDownWithDecay
final static Number countDownWithDecay(Number length, Number dt)
- Parameters:
length
- count down lengthdt
- decay- 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
- timeoutdecay
- 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
- timeoutf
- function to be invokednull
- 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
- timeoutdecay
- decay ratef
- function to be invokednull
- 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
- durationinfo
- informationdecay
- decay rate
-
exponentialBackoffFilter
final static Number exponentialBackoffFilter(Number signal, Number a)
Exponential back-off filter.
- Parameters:
signal
- signal to be filtereda
- alpha value- Returns:
filtered signal
-
falseAfterTime
final static Boolean falseAfterTime(Number timeout)
- Parameters:
timeout
- timeout- Returns:
false after timeout, true otherwise
-
falseAfterTimeWithDt
final static Boolean falseAfterTimeWithDt(Number timeout, Number dt)
- Parameters:
timeout
- timeoutdt
- dt- 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
- eventtimeout
- 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 monitoredtime
- 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 monitoredtime
- consider the signal stable after this timedt
- 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 storednull
- default valuetimeout
- hold the value for this amount of timedt
- 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
-
trueAfterTimeWithDt
final static Boolean trueAfterTimeWithDt(Number timeout, Number dt)
- Parameters:
timeout
- timeoutdt
- dt- 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 lengthdt
- 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
- timeutf
- function to be appliednull
- null value- Returns:
apply f after x, null otherwise
-
-
-
-