Stores a number which gets incremented on each `INC` pulse.
When RST pulse, SUM reset to zero.
If STEP is neagtive then Decrease.
Dont Set outputs differ from zero.
counter(idx)
@/counter(idx)
Stores a number which gets incremented on each `INC` pulse.
When RST pulse, SUM reset to zero.
If STEP is neagtive then Decrease.
Dont Set outputs differ from zero.
STEPnumber
Value to add on each increment. Use a negative value (e.g. -1) to make decrements.
INCpulse
Triggers a single step.
RSTpulse
Resets the counting value to start.
IDXnumber
The counting index value.
SUMnumber
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 sum = getValue<output_SUM>(ctx);
Number idx = getValue<output_IDX>(ctx);
if (isInputDirty<input_RST>(ctx))
{
sum = 0;
idx = 0;
}
else if (isInputDirty<input_INC>(ctx))
{
sum += getValue<input_STEP>(ctx);
idx++;
}
emitValue<output_SUM>(ctx, sum);
emitValue<output_IDX>(ctx, idx);
}