/* C code for program femto, generated by snc from ../femto.st */ #include #include #include #include #include "seq_snc.h" # line 22 "../femto.st" #include # line 23 "../femto.st" #include # line 30 "../femto.st" static const EF_ID t0_mon = 1; # line 31 "../femto.st" static const EF_ID t1_mon = 2; # line 32 "../femto.st" static const EF_ID t2_mon = 3; # line 33 "../femto.st" static const EF_ID tx_mon = 4; # line 35 "../femto.st" static const EF_ID gainidx_mon = 5; # line 36 "../femto.st" static const EF_ID debug_flag_mon = 6; # line 42 "../femto.st" static int powers[] = {5,6,7,8,9,10,11,0,3,4,5,6,7,8,9,0}; /* Variable declarations */ struct seqg_vars { # line 30 "../femto.st" int t0; # line 31 "../femto.st" int t1; # line 32 "../femto.st" int t2; # line 33 "../femto.st" int tx; # line 34 "../femto.st" double gain; # line 35 "../femto.st" int gainidx; # line 36 "../femto.st" int debug_flag; # line 38 "../femto.st" int curgain; # line 39 "../femto.st" char msg[256]; # line 40 "../femto.st" char *SNLtaskName; }; /* Function declarations */ #define seqg_var (*(struct seqg_vars *const *)seqg_env) /* Program init func */ static void seqg_init(PROG_ID seqg_env) { } /****** Code for state "init" in state set "femto" ******/ /* Event function for state "init" in state set "femto" */ static seqBool seqg_event_femto_0_init(SS_ID seqg_env, int *seqg_ptrn, int *seqg_pnst) { if (TRUE) { *seqg_pnst = 2; *seqg_ptrn = 0; return TRUE; } return FALSE; } /* Action function for state "init" in state set "femto" */ static void seqg_action_femto_0_init(SS_ID seqg_env, int seqg_trn, int *seqg_pnst) { switch(seqg_trn) { case 0: { # line 51 "../femto.st" seqg_var->SNLtaskName = seq_macValueGet(seqg_env, "name"); # line 53 "../femto.st" seq_pvGetTmo(seqg_env, 0/*t0*/, SYNC, DEFAULT_TIMEOUT); # line 54 "../femto.st" seq_pvGetTmo(seqg_env, 1/*t1*/, SYNC, DEFAULT_TIMEOUT); # line 55 "../femto.st" seq_pvGetTmo(seqg_env, 2/*t2*/, SYNC, DEFAULT_TIMEOUT); # line 56 "../femto.st" seq_pvGetTmo(seqg_env, 3/*tx*/, SYNC, DEFAULT_TIMEOUT); # line 58 "../femto.st" if ((seqg_var->tx + seqg_var->t2 + seqg_var->t1 + seqg_var->t0) == 0) { # line 60 "../femto.st" seqg_var->gainidx = 8; # line 61 "../femto.st" if (seqg_var->debug_flag >= 2) { # line 61 "../femto.st" printf("<%s,%d,%s,%d> ", "../femto.st", 61, seqg_var->SNLtaskName, 2); # line 61 "../femto.st" ; # line 61 "../femto.st" printf("%s\n", "gainidx = default (1e3 since all bits were OFF)"); # line 61 "../femto.st" epicsThreadSleep(0.01); } # line 61 "../femto.st" ; } else { # line 65 "../femto.st" seqg_var->gainidx = (seqg_var->tx << 3) | (seqg_var->t2 << 2) | (seqg_var->t1 << 1) | seqg_var->t0; # line 66 "../femto.st" sprintf(seqg_var->msg, "gainidx = %d", seqg_var->gainidx); # line 67 "../femto.st" if (seqg_var->debug_flag >= 2) { # line 67 "../femto.st" printf("<%s,%d,%s,%d> ", "../femto.st", 67, seqg_var->SNLtaskName, 2); # line 67 "../femto.st" ; # line 67 "../femto.st" printf("%s\n", seqg_var->msg); # line 67 "../femto.st" epicsThreadSleep(0.01); } # line 67 "../femto.st" ; } # line 70 "../femto.st" if (seqg_var->gainidx >= 15 || seqg_var->gainidx == 7) { # line 72 "../femto.st" seqg_var->gainidx = 6; # line 73 "../femto.st" if (seqg_var->debug_flag >= 4) { # line 73 "../femto.st" printf("<%s,%d,%s,%d> ", "../femto.st", 73, seqg_var->SNLtaskName, 4); # line 73 "../femto.st" ; # line 73 "../femto.st" printf("%s\n", "resetting gain to 1e11"); # line 73 "../femto.st" epicsThreadSleep(0.01); } # line 73 "../femto.st" ; } # line 76 "../femto.st" seqg_var->curgain = -1; { # line 77 "../femto.st" seqg_var->gainidx = (seqg_var->gainidx); # line 77 "../femto.st" seq_pvPutTmo(seqg_env, 5/*gainidx*/, SYNC, DEFAULT_TIMEOUT); } # line 77 "../femto.st" ; { # line 78 "../femto.st" seqg_var->gain = (pow(10, powers[seqg_var->gainidx])); # line 78 "../femto.st" seq_pvPutTmo(seqg_env, 4/*gain*/, SYNC, DEFAULT_TIMEOUT); } # line 78 "../femto.st" ; # line 79 "../femto.st" sprintf(seqg_var->msg, "gainidx = %d", seqg_var->gainidx); # line 80 "../femto.st" if (seqg_var->debug_flag >= 2) { # line 80 "../femto.st" printf("<%s,%d,%s,%d> ", "../femto.st", 80, seqg_var->SNLtaskName, 2); # line 80 "../femto.st" ; # line 80 "../femto.st" printf("%s\n", seqg_var->msg); # line 80 "../femto.st" epicsThreadSleep(0.01); } # line 80 "../femto.st" ; # line 82 "../femto.st" seq_efClear(seqg_env, t0_mon); # line 83 "../femto.st" seq_efClear(seqg_env, t1_mon); # line 84 "../femto.st" seq_efClear(seqg_env, t2_mon); # line 85 "../femto.st" seq_efClear(seqg_env, tx_mon); # line 86 "../femto.st" seq_efClear(seqg_env, gainidx_mon); # line 87 "../femto.st" seq_efClear(seqg_env, debug_flag_mon); # line 89 "../femto.st" if (seqg_var->debug_flag >= 2) { # line 89 "../femto.st" printf("<%s,%d,%s,%d> ", "../femto.st", 89, seqg_var->SNLtaskName, 2); # line 89 "../femto.st" ; # line 89 "../femto.st" printf("%s\n", "init complete"); # line 89 "../femto.st" epicsThreadSleep(0.01); } # line 89 "../femto.st" ; } return; } } /****** Code for state "updateGain" in state set "femto" ******/ /* Event function for state "updateGain" in state set "femto" */ static seqBool seqg_event_femto_0_updateGain(SS_ID seqg_env, int *seqg_ptrn, int *seqg_pnst) { if (TRUE) { *seqg_pnst = 3; *seqg_ptrn = 0; return TRUE; } return FALSE; } /* Action function for state "updateGain" in state set "femto" */ static void seqg_action_femto_0_updateGain(SS_ID seqg_env, int seqg_trn, int *seqg_pnst) { switch(seqg_trn) { case 0: { # line 98 "../femto.st" seqg_var->gainidx = (seqg_var->tx << 3) | (seqg_var->t2 << 2) | (seqg_var->t1 << 1) | seqg_var->t0; # line 99 "../femto.st" sprintf(seqg_var->msg, "gainidx = %d", seqg_var->gainidx); # line 100 "../femto.st" if (seqg_var->debug_flag >= 2) { # line 100 "../femto.st" printf("<%s,%d,%s,%d> ", "../femto.st", 100, seqg_var->SNLtaskName, 2); # line 100 "../femto.st" ; # line 100 "../femto.st" printf("%s\n", seqg_var->msg); # line 100 "../femto.st" epicsThreadSleep(0.01); } # line 100 "../femto.st" ; # line 102 "../femto.st" if (seqg_var->gainidx >= 15 || seqg_var->gainidx == 7) { # line 104 "../femto.st" seqg_var->gainidx = 6; # line 105 "../femto.st" if (seqg_var->debug_flag >= 4) { # line 105 "../femto.st" printf("<%s,%d,%s,%d> ", "../femto.st", 105, seqg_var->SNLtaskName, 4); # line 105 "../femto.st" ; # line 105 "../femto.st" printf("%s\n", "resetting gain to 1e11"); # line 105 "../femto.st" epicsThreadSleep(0.01); } # line 105 "../femto.st" ; } # line 108 "../femto.st" seqg_var->curgain = seqg_var->gainidx; { # line 109 "../femto.st" seqg_var->gainidx = (seqg_var->gainidx); # line 109 "../femto.st" seq_pvPutTmo(seqg_env, 5/*gainidx*/, SYNC, DEFAULT_TIMEOUT); } # line 109 "../femto.st" ; { # line 110 "../femto.st" seqg_var->gain = (pow(10, powers[seqg_var->gainidx])); # line 110 "../femto.st" seq_pvPutTmo(seqg_env, 4/*gain*/, SYNC, DEFAULT_TIMEOUT); } # line 110 "../femto.st" ; # line 111 "../femto.st" sprintf(seqg_var->msg, "gainidx = %d", seqg_var->gainidx); # line 112 "../femto.st" if (seqg_var->debug_flag >= 2) { # line 112 "../femto.st" printf("<%s,%d,%s,%d> ", "../femto.st", 112, seqg_var->SNLtaskName, 2); # line 112 "../femto.st" ; # line 112 "../femto.st" printf("%s\n", seqg_var->msg); # line 112 "../femto.st" epicsThreadSleep(0.01); } # line 112 "../femto.st" ; } return; } } /****** Code for state "changeGain" in state set "femto" ******/ /* Event function for state "changeGain" in state set "femto" */ static seqBool seqg_event_femto_0_changeGain(SS_ID seqg_env, int *seqg_ptrn, int *seqg_pnst) { # line 120 "../femto.st" if (seqg_var->curgain == seqg_var->gainidx) { *seqg_pnst = 3; *seqg_ptrn = 0; return TRUE; } # line 125 "../femto.st" if (seqg_var->gainidx < 0) { *seqg_pnst = 3; *seqg_ptrn = 1; return TRUE; } # line 133 "../femto.st" if (seqg_var->gainidx > 15) { *seqg_pnst = 3; *seqg_ptrn = 2; return TRUE; } # line 141 "../femto.st" if (seqg_var->gainidx == 7 || seqg_var->gainidx == 15) { *seqg_pnst = 3; *seqg_ptrn = 3; return TRUE; } if (TRUE) { *seqg_pnst = 3; *seqg_ptrn = 4; return TRUE; } return FALSE; } /* Action function for state "changeGain" in state set "femto" */ static void seqg_action_femto_0_changeGain(SS_ID seqg_env, int seqg_trn, int *seqg_pnst) { switch(seqg_trn) { case 0: { # line 122 "../femto.st" if (seqg_var->debug_flag >= 2) { # line 122 "../femto.st" printf("<%s,%d,%s,%d> ", "../femto.st", 122, seqg_var->SNLtaskName, 2); # line 122 "../femto.st" ; # line 122 "../femto.st" printf("%s\n", "No gain change required"); # line 122 "../femto.st" epicsThreadSleep(0.01); } # line 122 "../femto.st" ; } return; case 1: { { # line 127 "../femto.st" seqg_var->gainidx = (seqg_var->curgain); # line 127 "../femto.st" seq_pvPutTmo(seqg_env, 5/*gainidx*/, SYNC, DEFAULT_TIMEOUT); } # line 127 "../femto.st" ; { # line 128 "../femto.st" seqg_var->gain = (pow(10, powers[seqg_var->curgain])); # line 128 "../femto.st" seq_pvPutTmo(seqg_env, 4/*gain*/, SYNC, DEFAULT_TIMEOUT); } # line 128 "../femto.st" ; # line 129 "../femto.st" sprintf(seqg_var->msg, "Requested gain (%d) too low!", seqg_var->gainidx); # line 130 "../femto.st" if (seqg_var->debug_flag >= 2) { # line 130 "../femto.st" printf("<%s,%d,%s,%d> ", "../femto.st", 130, seqg_var->SNLtaskName, 2); # line 130 "../femto.st" ; # line 130 "../femto.st" printf("%s\n", seqg_var->msg); # line 130 "../femto.st" epicsThreadSleep(0.01); } # line 130 "../femto.st" ; } return; case 2: { { # line 135 "../femto.st" seqg_var->gainidx = (seqg_var->curgain); # line 135 "../femto.st" seq_pvPutTmo(seqg_env, 5/*gainidx*/, SYNC, DEFAULT_TIMEOUT); } # line 135 "../femto.st" ; { # line 136 "../femto.st" seqg_var->gain = (pow(10, powers[seqg_var->curgain])); # line 136 "../femto.st" seq_pvPutTmo(seqg_env, 4/*gain*/, SYNC, DEFAULT_TIMEOUT); } # line 136 "../femto.st" ; # line 137 "../femto.st" sprintf(seqg_var->msg, "Requested gain (%d) too high!", seqg_var->gainidx); # line 138 "../femto.st" if (seqg_var->debug_flag >= 2) { # line 138 "../femto.st" printf("<%s,%d,%s,%d> ", "../femto.st", 138, seqg_var->SNLtaskName, 2); # line 138 "../femto.st" ; # line 138 "../femto.st" printf("%s\n", seqg_var->msg); # line 138 "../femto.st" epicsThreadSleep(0.01); } # line 138 "../femto.st" ; } return; case 3: { { # line 143 "../femto.st" seqg_var->gainidx = (seqg_var->curgain); # line 143 "../femto.st" seq_pvPutTmo(seqg_env, 5/*gainidx*/, SYNC, DEFAULT_TIMEOUT); } # line 143 "../femto.st" ; { # line 144 "../femto.st" seqg_var->gain = (pow(10, powers[seqg_var->curgain])); # line 144 "../femto.st" seq_pvPutTmo(seqg_env, 4/*gain*/, SYNC, DEFAULT_TIMEOUT); } # line 144 "../femto.st" ; # line 145 "../femto.st" sprintf(seqg_var->msg, "Requested gain (%d) invalid!", seqg_var->gainidx); # line 146 "../femto.st" if (seqg_var->debug_flag >= 2) { # line 146 "../femto.st" printf("<%s,%d,%s,%d> ", "../femto.st", 146, seqg_var->SNLtaskName, 2); # line 146 "../femto.st" ; # line 146 "../femto.st" printf("%s\n", seqg_var->msg); # line 146 "../femto.st" epicsThreadSleep(0.01); } # line 146 "../femto.st" ; } return; case 4: { # line 151 "../femto.st" sprintf(seqg_var->msg, "gain %d selected", seqg_var->gainidx); # line 152 "../femto.st" if (seqg_var->debug_flag >= 2) { # line 152 "../femto.st" printf("<%s,%d,%s,%d> ", "../femto.st", 152, seqg_var->SNLtaskName, 2); # line 152 "../femto.st" ; # line 152 "../femto.st" printf("%s\n", seqg_var->msg); # line 152 "../femto.st" epicsThreadSleep(0.01); } # line 152 "../femto.st" ; # line 155 "../femto.st" if (seqg_var->gainidx == 0) { { # line 157 "../femto.st" seqg_var->t0 = (0); # line 157 "../femto.st" seq_pvPutTmo(seqg_env, 0/*t0*/, SYNC, DEFAULT_TIMEOUT); } # line 157 "../femto.st" ; { # line 158 "../femto.st" seqg_var->t1 = (0); # line 158 "../femto.st" seq_pvPutTmo(seqg_env, 1/*t1*/, SYNC, DEFAULT_TIMEOUT); } # line 158 "../femto.st" ; { # line 159 "../femto.st" seqg_var->t2 = (0); # line 159 "../femto.st" seq_pvPutTmo(seqg_env, 2/*t2*/, SYNC, DEFAULT_TIMEOUT); } # line 159 "../femto.st" ; { # line 160 "../femto.st" seqg_var->tx = (0); # line 160 "../femto.st" seq_pvPutTmo(seqg_env, 3/*tx*/, SYNC, DEFAULT_TIMEOUT); } # line 160 "../femto.st" ; } # line 164 "../femto.st" if (seqg_var->gainidx == 1) { { # line 166 "../femto.st" seqg_var->t0 = (1); # line 166 "../femto.st" seq_pvPutTmo(seqg_env, 0/*t0*/, SYNC, DEFAULT_TIMEOUT); } # line 166 "../femto.st" ; { # line 167 "../femto.st" seqg_var->t1 = (0); # line 167 "../femto.st" seq_pvPutTmo(seqg_env, 1/*t1*/, SYNC, DEFAULT_TIMEOUT); } # line 167 "../femto.st" ; { # line 168 "../femto.st" seqg_var->t2 = (0); # line 168 "../femto.st" seq_pvPutTmo(seqg_env, 2/*t2*/, SYNC, DEFAULT_TIMEOUT); } # line 168 "../femto.st" ; { # line 169 "../femto.st" seqg_var->tx = (0); # line 169 "../femto.st" seq_pvPutTmo(seqg_env, 3/*tx*/, SYNC, DEFAULT_TIMEOUT); } # line 169 "../femto.st" ; } # line 173 "../femto.st" if (seqg_var->gainidx == 2) { { # line 175 "../femto.st" seqg_var->t0 = (0); # line 175 "../femto.st" seq_pvPutTmo(seqg_env, 0/*t0*/, SYNC, DEFAULT_TIMEOUT); } # line 175 "../femto.st" ; { # line 176 "../femto.st" seqg_var->t1 = (1); # line 176 "../femto.st" seq_pvPutTmo(seqg_env, 1/*t1*/, SYNC, DEFAULT_TIMEOUT); } # line 176 "../femto.st" ; { # line 177 "../femto.st" seqg_var->t2 = (0); # line 177 "../femto.st" seq_pvPutTmo(seqg_env, 2/*t2*/, SYNC, DEFAULT_TIMEOUT); } # line 177 "../femto.st" ; { # line 178 "../femto.st" seqg_var->tx = (0); # line 178 "../femto.st" seq_pvPutTmo(seqg_env, 3/*tx*/, SYNC, DEFAULT_TIMEOUT); } # line 178 "../femto.st" ; } # line 182 "../femto.st" if (seqg_var->gainidx == 3) { { # line 184 "../femto.st" seqg_var->t0 = (1); # line 184 "../femto.st" seq_pvPutTmo(seqg_env, 0/*t0*/, SYNC, DEFAULT_TIMEOUT); } # line 184 "../femto.st" ; { # line 185 "../femto.st" seqg_var->t1 = (1); # line 185 "../femto.st" seq_pvPutTmo(seqg_env, 1/*t1*/, SYNC, DEFAULT_TIMEOUT); } # line 185 "../femto.st" ; { # line 186 "../femto.st" seqg_var->t2 = (0); # line 186 "../femto.st" seq_pvPutTmo(seqg_env, 2/*t2*/, SYNC, DEFAULT_TIMEOUT); } # line 186 "../femto.st" ; { # line 187 "../femto.st" seqg_var->tx = (0); # line 187 "../femto.st" seq_pvPutTmo(seqg_env, 3/*tx*/, SYNC, DEFAULT_TIMEOUT); } # line 187 "../femto.st" ; } # line 191 "../femto.st" if (seqg_var->gainidx == 4) { { # line 193 "../femto.st" seqg_var->t0 = (0); # line 193 "../femto.st" seq_pvPutTmo(seqg_env, 0/*t0*/, SYNC, DEFAULT_TIMEOUT); } # line 193 "../femto.st" ; { # line 194 "../femto.st" seqg_var->t1 = (0); # line 194 "../femto.st" seq_pvPutTmo(seqg_env, 1/*t1*/, SYNC, DEFAULT_TIMEOUT); } # line 194 "../femto.st" ; { # line 195 "../femto.st" seqg_var->t2 = (1); # line 195 "../femto.st" seq_pvPutTmo(seqg_env, 2/*t2*/, SYNC, DEFAULT_TIMEOUT); } # line 195 "../femto.st" ; { # line 196 "../femto.st" seqg_var->tx = (0); # line 196 "../femto.st" seq_pvPutTmo(seqg_env, 3/*tx*/, SYNC, DEFAULT_TIMEOUT); } # line 196 "../femto.st" ; } # line 200 "../femto.st" if (seqg_var->gainidx == 5) { { # line 202 "../femto.st" seqg_var->t0 = (1); # line 202 "../femto.st" seq_pvPutTmo(seqg_env, 0/*t0*/, SYNC, DEFAULT_TIMEOUT); } # line 202 "../femto.st" ; { # line 203 "../femto.st" seqg_var->t1 = (0); # line 203 "../femto.st" seq_pvPutTmo(seqg_env, 1/*t1*/, SYNC, DEFAULT_TIMEOUT); } # line 203 "../femto.st" ; { # line 204 "../femto.st" seqg_var->t2 = (1); # line 204 "../femto.st" seq_pvPutTmo(seqg_env, 2/*t2*/, SYNC, DEFAULT_TIMEOUT); } # line 204 "../femto.st" ; { # line 205 "../femto.st" seqg_var->tx = (0); # line 205 "../femto.st" seq_pvPutTmo(seqg_env, 3/*tx*/, SYNC, DEFAULT_TIMEOUT); } # line 205 "../femto.st" ; } # line 209 "../femto.st" if (seqg_var->gainidx == 6) { { # line 211 "../femto.st" seqg_var->t0 = (0); # line 211 "../femto.st" seq_pvPutTmo(seqg_env, 0/*t0*/, SYNC, DEFAULT_TIMEOUT); } # line 211 "../femto.st" ; { # line 212 "../femto.st" seqg_var->t1 = (1); # line 212 "../femto.st" seq_pvPutTmo(seqg_env, 1/*t1*/, SYNC, DEFAULT_TIMEOUT); } # line 212 "../femto.st" ; { # line 213 "../femto.st" seqg_var->t2 = (1); # line 213 "../femto.st" seq_pvPutTmo(seqg_env, 2/*t2*/, SYNC, DEFAULT_TIMEOUT); } # line 213 "../femto.st" ; { # line 214 "../femto.st" seqg_var->tx = (0); # line 214 "../femto.st" seq_pvPutTmo(seqg_env, 3/*tx*/, SYNC, DEFAULT_TIMEOUT); } # line 214 "../femto.st" ; } # line 218 "../femto.st" if (seqg_var->gainidx == 8) { { # line 220 "../femto.st" seqg_var->t0 = (0); # line 220 "../femto.st" seq_pvPutTmo(seqg_env, 0/*t0*/, SYNC, DEFAULT_TIMEOUT); } # line 220 "../femto.st" ; { # line 221 "../femto.st" seqg_var->t1 = (0); # line 221 "../femto.st" seq_pvPutTmo(seqg_env, 1/*t1*/, SYNC, DEFAULT_TIMEOUT); } # line 221 "../femto.st" ; { # line 222 "../femto.st" seqg_var->t2 = (0); # line 222 "../femto.st" seq_pvPutTmo(seqg_env, 2/*t2*/, SYNC, DEFAULT_TIMEOUT); } # line 222 "../femto.st" ; { # line 223 "../femto.st" seqg_var->tx = (1); # line 223 "../femto.st" seq_pvPutTmo(seqg_env, 3/*tx*/, SYNC, DEFAULT_TIMEOUT); } # line 223 "../femto.st" ; } # line 227 "../femto.st" if (seqg_var->gainidx == 9) { { # line 229 "../femto.st" seqg_var->t0 = (1); # line 229 "../femto.st" seq_pvPutTmo(seqg_env, 0/*t0*/, SYNC, DEFAULT_TIMEOUT); } # line 229 "../femto.st" ; { # line 230 "../femto.st" seqg_var->t1 = (0); # line 230 "../femto.st" seq_pvPutTmo(seqg_env, 1/*t1*/, SYNC, DEFAULT_TIMEOUT); } # line 230 "../femto.st" ; { # line 231 "../femto.st" seqg_var->t2 = (0); # line 231 "../femto.st" seq_pvPutTmo(seqg_env, 2/*t2*/, SYNC, DEFAULT_TIMEOUT); } # line 231 "../femto.st" ; { # line 232 "../femto.st" seqg_var->tx = (1); # line 232 "../femto.st" seq_pvPutTmo(seqg_env, 3/*tx*/, SYNC, DEFAULT_TIMEOUT); } # line 232 "../femto.st" ; } # line 236 "../femto.st" if (seqg_var->gainidx == 10) { { # line 238 "../femto.st" seqg_var->t0 = (0); # line 238 "../femto.st" seq_pvPutTmo(seqg_env, 0/*t0*/, SYNC, DEFAULT_TIMEOUT); } # line 238 "../femto.st" ; { # line 239 "../femto.st" seqg_var->t1 = (1); # line 239 "../femto.st" seq_pvPutTmo(seqg_env, 1/*t1*/, SYNC, DEFAULT_TIMEOUT); } # line 239 "../femto.st" ; { # line 240 "../femto.st" seqg_var->t2 = (0); # line 240 "../femto.st" seq_pvPutTmo(seqg_env, 2/*t2*/, SYNC, DEFAULT_TIMEOUT); } # line 240 "../femto.st" ; { # line 241 "../femto.st" seqg_var->tx = (1); # line 241 "../femto.st" seq_pvPutTmo(seqg_env, 3/*tx*/, SYNC, DEFAULT_TIMEOUT); } # line 241 "../femto.st" ; } # line 245 "../femto.st" if (seqg_var->gainidx == 11) { { # line 247 "../femto.st" seqg_var->t0 = (1); # line 247 "../femto.st" seq_pvPutTmo(seqg_env, 0/*t0*/, SYNC, DEFAULT_TIMEOUT); } # line 247 "../femto.st" ; { # line 248 "../femto.st" seqg_var->t1 = (1); # line 248 "../femto.st" seq_pvPutTmo(seqg_env, 1/*t1*/, SYNC, DEFAULT_TIMEOUT); } # line 248 "../femto.st" ; { # line 249 "../femto.st" seqg_var->t2 = (0); # line 249 "../femto.st" seq_pvPutTmo(seqg_env, 2/*t2*/, SYNC, DEFAULT_TIMEOUT); } # line 249 "../femto.st" ; { # line 250 "../femto.st" seqg_var->tx = (1); # line 250 "../femto.st" seq_pvPutTmo(seqg_env, 3/*tx*/, SYNC, DEFAULT_TIMEOUT); } # line 250 "../femto.st" ; } # line 254 "../femto.st" if (seqg_var->gainidx == 12) { { # line 256 "../femto.st" seqg_var->t0 = (0); # line 256 "../femto.st" seq_pvPutTmo(seqg_env, 0/*t0*/, SYNC, DEFAULT_TIMEOUT); } # line 256 "../femto.st" ; { # line 257 "../femto.st" seqg_var->t1 = (0); # line 257 "../femto.st" seq_pvPutTmo(seqg_env, 1/*t1*/, SYNC, DEFAULT_TIMEOUT); } # line 257 "../femto.st" ; { # line 258 "../femto.st" seqg_var->t2 = (1); # line 258 "../femto.st" seq_pvPutTmo(seqg_env, 2/*t2*/, SYNC, DEFAULT_TIMEOUT); } # line 258 "../femto.st" ; { # line 259 "../femto.st" seqg_var->tx = (1); # line 259 "../femto.st" seq_pvPutTmo(seqg_env, 3/*tx*/, SYNC, DEFAULT_TIMEOUT); } # line 259 "../femto.st" ; } # line 263 "../femto.st" if (seqg_var->gainidx == 13) { { # line 265 "../femto.st" seqg_var->t0 = (1); # line 265 "../femto.st" seq_pvPutTmo(seqg_env, 0/*t0*/, SYNC, DEFAULT_TIMEOUT); } # line 265 "../femto.st" ; { # line 266 "../femto.st" seqg_var->t1 = (0); # line 266 "../femto.st" seq_pvPutTmo(seqg_env, 1/*t1*/, SYNC, DEFAULT_TIMEOUT); } # line 266 "../femto.st" ; { # line 267 "../femto.st" seqg_var->t2 = (1); # line 267 "../femto.st" seq_pvPutTmo(seqg_env, 2/*t2*/, SYNC, DEFAULT_TIMEOUT); } # line 267 "../femto.st" ; { # line 268 "../femto.st" seqg_var->tx = (1); # line 268 "../femto.st" seq_pvPutTmo(seqg_env, 3/*tx*/, SYNC, DEFAULT_TIMEOUT); } # line 268 "../femto.st" ; } # line 272 "../femto.st" if (seqg_var->gainidx == 14) { { # line 274 "../femto.st" seqg_var->t0 = (0); # line 274 "../femto.st" seq_pvPutTmo(seqg_env, 0/*t0*/, SYNC, DEFAULT_TIMEOUT); } # line 274 "../femto.st" ; { # line 275 "../femto.st" seqg_var->t1 = (1); # line 275 "../femto.st" seq_pvPutTmo(seqg_env, 1/*t1*/, SYNC, DEFAULT_TIMEOUT); } # line 275 "../femto.st" ; { # line 276 "../femto.st" seqg_var->t2 = (1); # line 276 "../femto.st" seq_pvPutTmo(seqg_env, 2/*t2*/, SYNC, DEFAULT_TIMEOUT); } # line 276 "../femto.st" ; { # line 277 "../femto.st" seqg_var->tx = (1); # line 277 "../femto.st" seq_pvPutTmo(seqg_env, 3/*tx*/, SYNC, DEFAULT_TIMEOUT); } # line 277 "../femto.st" ; } # line 280 "../femto.st" seqg_var->curgain = seqg_var->gainidx; { # line 281 "../femto.st" seqg_var->gain = (pow(10, powers[seqg_var->gainidx])); # line 281 "../femto.st" seq_pvPutTmo(seqg_env, 4/*gain*/, SYNC, DEFAULT_TIMEOUT); } # line 281 "../femto.st" ; # line 283 "../femto.st" seq_efClear(seqg_env, t0_mon); # line 284 "../femto.st" seq_efClear(seqg_env, t1_mon); # line 285 "../femto.st" seq_efClear(seqg_env, t2_mon); # line 286 "../femto.st" seq_efClear(seqg_env, tx_mon); # line 287 "../femto.st" seq_efClear(seqg_env, gainidx_mon); } return; } } /****** Code for state "idle" in state set "femto" ******/ /* Event function for state "idle" in state set "femto" */ static seqBool seqg_event_femto_0_idle(SS_ID seqg_env, int *seqg_ptrn, int *seqg_pnst) { # line 295 "../femto.st" if (seq_efTestAndClear(seqg_env, debug_flag_mon)) { *seqg_pnst = 3; *seqg_ptrn = 0; return TRUE; } # line 302 "../femto.st" if (seq_efTestAndClear(seqg_env, tx_mon) || seq_efTestAndClear(seqg_env, t2_mon) || seq_efTestAndClear(seqg_env, t1_mon) || seq_efTestAndClear(seqg_env, t0_mon)) { *seqg_pnst = 1; *seqg_ptrn = 1; return TRUE; } # line 308 "../femto.st" if (seq_efTestAndClear(seqg_env, gainidx_mon)) { *seqg_pnst = 2; *seqg_ptrn = 2; return TRUE; } # line 313 "../femto.st" if (seq_delay(seqg_env, .1)) { *seqg_pnst = 3; *seqg_ptrn = 3; return TRUE; } return FALSE; } /* Action function for state "idle" in state set "femto" */ static void seqg_action_femto_0_idle(SS_ID seqg_env, int seqg_trn, int *seqg_pnst) { switch(seqg_trn) { case 0: { # line 297 "../femto.st" sprintf(seqg_var->msg, "Debug level changed to %d", seqg_var->debug_flag); # line 298 "../femto.st" if (seqg_var->debug_flag >= 1) { # line 298 "../femto.st" printf("<%s,%d,%s,%d> ", "../femto.st", 298, seqg_var->SNLtaskName, 1); # line 298 "../femto.st" ; # line 298 "../femto.st" printf("%s\n", seqg_var->msg); # line 298 "../femto.st" epicsThreadSleep(0.01); } # line 298 "../femto.st" ; } return; case 1: { # line 305 "../femto.st" if (seqg_var->debug_flag >= 2) { # line 305 "../femto.st" printf("<%s,%d,%s,%d> ", "../femto.st", 305, seqg_var->SNLtaskName, 2); # line 305 "../femto.st" ; # line 305 "../femto.st" printf("%s\n", "bits changed, updating"); # line 305 "../femto.st" epicsThreadSleep(0.01); } # line 305 "../femto.st" ; } return; case 2: { # line 310 "../femto.st" if (seqg_var->debug_flag >= 2) { # line 310 "../femto.st" printf("<%s,%d,%s,%d> ", "../femto.st", 310, seqg_var->SNLtaskName, 2); # line 310 "../femto.st" ; # line 310 "../femto.st" printf("%s\n", "gain change"); # line 310 "../femto.st" epicsThreadSleep(0.01); } # line 310 "../femto.st" ; } return; case 3: { } return; } } #undef seqg_var /************************ Tables ************************/ /* Channel table */ static seqChan seqg_chans[] = { /* chName, offset, varName, varType, count, eventNum, efId, monitored, queueSize, queueIndex */ {"{G1}", offsetof(struct seqg_vars, t0), "t0", P_INT, 1, 7, 1, 1, 0, 0}, {"{G2}", offsetof(struct seqg_vars, t1), "t1", P_INT, 1, 8, 2, 1, 0, 0}, {"{G3}", offsetof(struct seqg_vars, t2), "t2", P_INT, 1, 9, 3, 1, 0, 0}, {"{NO}", offsetof(struct seqg_vars, tx), "tx", P_INT, 1, 10, 4, 1, 0, 0}, {"{P}{H}{F}gain", offsetof(struct seqg_vars, gain), "gain", P_DOUBLE, 1, 11, 0, 0, 0, 0}, {"{P}{H}{F}gainidx", offsetof(struct seqg_vars, gainidx), "gainidx", P_INT, 1, 12, 5, 1, 0, 0}, {"{P}{H}{F}debug", offsetof(struct seqg_vars, debug_flag), "debug_flag", P_INT, 1, 13, 6, 1, 0, 0}, }; /* Event masks for state set "femto" */ static const seqMask seqg_mask_femto_0_init[] = { 0x00000000, }; static const seqMask seqg_mask_femto_0_updateGain[] = { 0x00000000, }; static const seqMask seqg_mask_femto_0_changeGain[] = { 0x00001000, }; static const seqMask seqg_mask_femto_0_idle[] = { 0x0000007e, }; /* State table for state set "femto" */ static seqState seqg_states_femto[] = { { /* state name */ "init", /* action function */ seqg_action_femto_0_init, /* event function */ seqg_event_femto_0_init, /* entry function */ 0, /* exit function */ 0, /* event mask array */ seqg_mask_femto_0_init, /* state options */ (0) }, { /* state name */ "updateGain", /* action function */ seqg_action_femto_0_updateGain, /* event function */ seqg_event_femto_0_updateGain, /* entry function */ 0, /* exit function */ 0, /* event mask array */ seqg_mask_femto_0_updateGain, /* state options */ (0) }, { /* state name */ "changeGain", /* action function */ seqg_action_femto_0_changeGain, /* event function */ seqg_event_femto_0_changeGain, /* entry function */ 0, /* exit function */ 0, /* event mask array */ seqg_mask_femto_0_changeGain, /* state options */ (0) }, { /* state name */ "idle", /* action function */ seqg_action_femto_0_idle, /* event function */ seqg_event_femto_0_idle, /* entry function */ 0, /* exit function */ 0, /* event mask array */ seqg_mask_femto_0_idle, /* state options */ (0) }, }; /* State set table */ static seqSS seqg_statesets[] = { { /* state set name */ "femto", /* states */ seqg_states_femto, /* number of states */ 4 }, }; /* Program table (global) */ seqProgram femto = { /* magic number */ 2002004, /* program name */ "femto", /* channels */ seqg_chans, /* num. channels */ 7, /* state sets */ seqg_statesets, /* num. state sets */ 1, /* user var size */ sizeof(struct seqg_vars), /* param */ "name=femto,P=,H=,F=,G1=,G2=,G3=,NO=", /* num. event flags */ 6, /* encoded options */ (0 | OPT_DEBUG | OPT_NEWEF | OPT_REENT), /* init func */ seqg_init, /* entry func */ 0, /* exit func */ 0, /* num. queues */ 0 }; /* Register sequencer commands and program */ #include "epicsExport.h" static void femtoRegistrar (void) { seqRegisterSequencerCommands(); seqRegisterSequencerProgram (&femto); } epicsExportRegistrar(femtoRegistrar);