bool32.rising increment trigger
bool32 retfirst
bool32 restart
int32 output
int32.hradio numstage
int32 p0
int32 p1
int32 p2
int32 p3
int32 p4
int32 p5
int32 p6
int32 p7
bool32.tgl retfirst
bool32.tgl restart
int ntrig;
int count;
int scount;
int pval;
int vdir;
int cstep[8];
count = -1;
ntrig = 0;
scount = 0;
pval = 0;
vdir = 1;
cstep[0] = param_p0;
cstep[1] = param_p1;
cstep[2] = param_p2;
cstep[3] = param_p3;
cstep[4] = param_p4;
cstep[5] = param_p5;
cstep[6] = param_p6;
cstep[7] = param_p7;
if (param_restart > 0 || inlet_restart > 0) {
count = -1;
ntrig = 0;
scount = 0;
pval = 0;
vdir = 1;
}
if (scount >= cstep[pval]) {
if (param_numstage <= pval) {
if (param_retfirst > 0 || inlet_retfirst > 0) {
count = -1;
vdir = -1;
}
pval = 0;
} else {
pval = pval + 1;
}
scount = 0;
vdir = vdir * -1;
}
if ((inlet_inc > 0) && ntrig == 0) {
if (vdir == 1)
count = count + 1;
if (vdir == -1)
count = count - 1;
if (count < 0)
count = 15;
if (count > 15)
count = 0;
scount = scount + 1;
ntrig = 1;
}
if (inlet_inc < 1)
ntrig = 0;
outlet_o = count;