Enabled or not. If set to `false` pulses on `UPD` do not change the output value. Effictively that means the timer is paused. Set to `true` again to continue time counting.
Tmsnumber
Tick interval in millisec.
UPDpulse
Triggers the time value update.
TICKpulse
Pulses on each time interval end
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
{
TimeMs nextTrig;
};
{{ GENERATED_CODE }}
void evaluate(Context ctx)
{
State* state = getState(ctx);
TimeMs tNow = transactionTime();
TimeMs dt = getValue<input_Tms>(ctx);
TimeMs tNext = tNow + dt;
auto isEnabled = getValue<input_EN>(ctx);
auto isRstDirty = isInputDirty<input_RST>(ctx);
if (isTimedOut(ctx) && isEnabled && !isRstDirty)
{
emitValue<output_TICK>(ctx, 1);
state->nextTrig = tNext;
setTimeout(ctx, dt);
}
if (isRstDirty || isInputDirty<input_EN>(ctx))
{
// Handle enable/disable/reset
if (dt <= 0 || !isEnabled)
{
// Disable timeout loop on zero IVAL or explicit false on EN
state->nextTrig = 0;
clearTimeout(ctx);
}
else if (state->nextTrig < tNow || state->nextTrig > tNext)
{
// Start timeout from scratch
state->nextTrig = tNext;
setTimeout(ctx, dt);
}
}
}