timer(second)

koadrobot/progress/timer(second)

No description
timer(second)
@/timer(second)
ENboolean
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.
RSTpulse
Resets the current time value to zero.
UPDpulse
Triggers the time value update.
timer(second)
EN
RST
UPD
Tsec
Tsecnumber
The current time value in seconds.
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
{
    Number lastUpdateTime;
};

{{ GENERATED_CODE }}

void evaluate(Context ctx) 
{
    State* state = getState(ctx);

    Number tsec = transactionTime() / 1000.0;

    if (isInputDirty<input_RST>(ctx))
        emitValue<output_OUT>(ctx, 0);
    else if (getValue<input_EN>(ctx) && isInputDirty<input_UPD>(ctx))
        emitValue<output_Tsec>(ctx, getValue<output_Tsec>(ctx) + (tsec - state->lastUpdateTime)) ;

    state->lastUpdateTime = tsec;
}