delay

xod/core/delay

Delays triggering of an incoming pulse by specified time
delay
@/delay
Delays triggering of an incoming pulse by specified time
Tnumber
Time to delay in seconds
SETpulse
Resets current countdown, starts new countdown
RSTpulse
Resets current countdown, i.e. cancels the delay
delay
DONE
ACT
T
SET
RST
ACTboolean
Outputs true when delay is in progress
DONEpulse
Pulses once the delay is over

C++ implementation

node {
    void evaluate(Context ctx) {
        if (isInputDirty<input_RST>(ctx)) {
            clearTimeout(ctx);
            emitValue<output_ACT>(ctx, false);
        } else if (isInputDirty<input_SET>(ctx)) {
            TimeMs dt = getValue<input_T>(ctx) * 1000;
            setTimeout(ctx, dt);
            emitValue<output_ACT>(ctx, true);
        } else if (isTimedOut(ctx)) {
            emitValue<output_DONE>(ctx, true);
            emitValue<output_ACT>(ctx, false);
        }
    }
}

Tabular tests

__time(ms)TSETRSTDONEACT
00.5no-pulseno-pulseno-pulsefalse
10000.5pulseno-pulseno-pulsetrue
15000.5no-pulseno-pulseno-pulsetrue
15010.5no-pulseno-pulsepulsefalse
20000.5pulsepulseno-pulsefalse
25000.5pulseno-pulseno-pulsetrue
26002no-pulseno-pulseno-pulsetrue
27002no-pulsepulseno-pulsefalse
30012no-pulseno-pulseno-pulsefalse