To use the node in your project you should have the wkov/colony 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
#pragma XOD dirtieness disable
node {
uint8_t prev = 0;
void emitBool(Context ctx, uint8_t opt, bool val) {
switch (opt) {
case 1: emitValue<output_A>(ctx, val); return;
case 2: emitValue<output_B>(ctx, val); return;
case 3: emitValue<output_C>(ctx, val); return;
case 4: emitValue<output_D>(ctx, val); return;
case 5: emitValue<output_E>(ctx, val); return;
}
}
TimeMs getTimeout(Context ctx, uint8_t opt) {
switch (opt) {
case 1: return getValue<input_Ta>(ctx);
case 2: return getValue<input_Tb>(ctx);
case 3: return getValue<input_Tc>(ctx);
case 4: return getValue<input_Td>(ctx);
case 5: return getValue<input_Te>(ctx);
}
}
void evaluate(Context ctx) {
uint8_t next;
if (getValue<input_EN>(ctx)) {
if (prev != 0 && !isTimedOut(ctx)) {
return;
}
next = (prev < 5 ? prev + 1 : 1);
setTimeout(ctx, getTimeout(ctx, next) * 1000);
} else {
clearTimeout(ctx);
next = 0;
}
emitBool(ctx, prev, 0);
emitBool(ctx, next, 1);
emitValue<output_DONE>(ctx, 1);
prev = next;
}
}