Stores a number which gets incremented on each `INC` pulse.
When RST pulse, SUM reset to zero.
If STEP is neagtive then Decrease.
counter(step)
@/counter(step)
Stores a number which gets incremented on each `INC` pulse.
When RST pulse, SUM reset to zero.
If STEP is neagtive then Decrease.
STEPnumber
Value to add on each increment. Use a negative value (e.g. -1) to make decrements.
INCpulse
Triggers a single increment.
RSTpulse
Resets the accumulated value to zero.
SUMnumber
The accumulated value.
To use the node in your project you should have the koadrobot/logic 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)
{
Number cnt = getValue<output_SUM>(ctx);
if (isInputDirty<input_RST>(ctx))
{
cnt = 0;
}
else if (isInputDirty<input_INC>(ctx))
{
cnt += getValue<input_STEP>(ctx);
}
emitValue<output_SUM>(ctx, cnt);
}