node {
TimeMs nextTrig;
int8_t count;
void evaluate(Context ctx) {
TimeMs tNow = transactionTime();
auto ival = 0.0015;
if (ival < 0) ival = 0;
TimeMs dt = ival * 1000;
TimeMs tNext = tNow + dt;
if (isTimedOut(ctx)){
if(getValue<input_ACT>(ctx)){
emitValue<output_TICK>(ctx, 1);
}
if (count >= 4){
count = 0;
}else{
if(count == 0){
emitValue<output_VAL>(ctx, getValue<input_D1>(ctx));
emitValue<output_DIG>(ctx, count);
emitValue<output_MPLX>(ctx, count);
}
if(count == 1){
emitValue<output_VAL>(ctx, getValue<input_D2>(ctx));
emitValue<output_DIG>(ctx, count);
emitValue<output_MPLX>(ctx, count);
}
if(count == 2){
emitValue<output_VAL>(ctx, getValue<input_D3>(ctx));
emitValue<output_DIG>(ctx, count);
emitValue<output_MPLX>(ctx, count);
}
if(count == 3){
emitValue<output_VAL>(ctx, getValue<input_D4>(ctx));
emitValue<output_DIG>(ctx, count);
emitValue<output_MPLX>(ctx, count);
}
count ++;
}
nextTrig = tNext;
setTimeout(ctx, dt);
}
if (nextTrig < tNow || nextTrig > tNext) {
nextTrig = tNext;
setTimeout(ctx, dt);
}
}
}