delay(second)

koadrobot/progress/delay(second)

No description
delay(second)
@/delay(second)
Tsecnumber
Time to delay in seconds
SETpulse
Resets current countdown, starts new countdown
RSTpulse
Resets current countdown, i.e. cancels the delay
delay(second)
Tsec
SET
RST
DONE
ACT
ACTboolean
Outputs true when delay is in progress
DONEpulse
Pulses once the delay is over
To use the node in your project you should have the koadrobot/progress library installed. Use the “File → Add Library” menu item in XOD IDE if you don’t have it yet. See Using libraries for more info.

C++ implementation

struct State {
};

{{ GENERATED_CODE }}

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_Tsec>(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