/* Generated with snc from laserSteering1cam.i */ /* Program "LaserSteering1cam" */ #include #include #include #include #include "epicsTypes.h" #include "seqCom.h" /* Variable declarations */ struct UserVar { # line 36 "../laserSteering1cam.st" unsigned int loop_fdbk_enbl; # line 40 "../laserSteering1cam.st" unsigned short feedback_status; # line 43 "../laserSteering1cam.st" unsigned int loop_set_ref; # line 47 "../laserSteering1cam.st" double loop_adj_min; # line 51 "../laserSteering1cam.st" double loop_adj_max; # line 55 "../laserSteering1cam.st" unsigned short CHECK_TIMES; # line 59 "../laserSteering1cam.st" double motor_M1_v_adjustment; # line 62 "../laserSteering1cam.st" double motor_M1_h_adjustment; # line 66 "../laserSteering1cam.st" double cam_C1_h; # line 69 "../laserSteering1cam.st" double cam_C1_v; # line 72 "../laserSteering1cam.st" double cam_C1_h_ref; # line 75 "../laserSteering1cam.st" double cam_C1_v_ref; # line 78 "../laserSteering1cam.st" double cam_C1_h_err; # line 80 "../laserSteering1cam.st" double cam_C1_h_err_avg; # line 82 "../laserSteering1cam.st" double cam_C1_v_err; # line 84 "../laserSteering1cam.st" double cam_C1_v_err_avg; # line 86 "../laserSteering1cam.st" double cam_C1_dark_img; # line 90 "../laserSteering1cam.st" double cam_C1_stale_img; # line 95 "../laserSteering1cam.st" double motor_M1_h_calc_dest; # line 96 "../laserSteering1cam.st" double motor_M1_h_dest; # line 99 "../laserSteering1cam.st" double motor_M1_h_pos; # line 103 "../laserSteering1cam.st" unsigned int motor_M1_h_moving; # line 107 "../laserSteering1cam.st" double motor_M1_h_dhlm; # line 111 "../laserSteering1cam.st" double motor_M1_h_dllm; # line 115 "../laserSteering1cam.st" double motor_M1_h_rdbd; # line 120 "../laserSteering1cam.st" double motor_M1_v_calc_dest; # line 121 "../laserSteering1cam.st" double motor_M1_v_dest; # line 124 "../laserSteering1cam.st" double motor_M1_v_pos; # line 128 "../laserSteering1cam.st" unsigned int motor_M1_v_moving; # line 132 "../laserSteering1cam.st" double motor_M1_v_dhlm; # line 136 "../laserSteering1cam.st" double motor_M1_v_dllm; # line 140 "../laserSteering1cam.st" double motor_M1_v_rdbd; # line 145 "../laserSteering1cam.st" char *filename; # line 147 "../laserSteering1cam.st" int var_internalReset; # line 149 "../laserSteering1cam.st" double var_loopGain; # line 153 "../laserSteering1cam.st" double var_loopDeadband_C1; # line 157 "../laserSteering1cam.st" double var_loopInitPosition_motor_M1_h; # line 158 "../laserSteering1cam.st" double var_loopInitPosition_motor_M1_v; # line 161 "../laserSteering1cam.st" int loop; # line 162 "../laserSteering1cam.st" int i; # line 163 "../laserSteering1cam.st" int j; # line 164 "../laserSteering1cam.st" int tempum; # line 166 "../laserSteering1cam.st" int dest_in_range; # line 167 "../laserSteering1cam.st" double loop_max_adj; # line 173 "../laserSteering1cam.st" float LOOP_DECPL_MTRX[2][2]; }; /* C code definitions */ # line 15 "../laserSteering1cam.st" #include "string.h" # line 16 "../laserSteering1cam.st" #include "math.h" # line 17 "../laserSteering1cam.st" #include "epicsTime.h" /* Program init func */ static void G_prog_init(struct UserVar *pVar) { static struct UserVar pVarInit = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, {{0,0},{0,0}}, }; *pVar = pVarInit; } /****** Code for state "init" in state set "laser_stabilization_1cam" ******/ /* Delay function for state "init" in state set "laser_stabilization_1cam" */ static void D_laser_stabilization_1cam_init(SS_ID ssId, struct UserVar *pVar) { } /* Event function for state "init" in state set "laser_stabilization_1cam" */ static seqBool E_laser_stabilization_1cam_init(SS_ID ssId, struct UserVar *pVar, int *pTransNum, int *pNextState) { if (TRUE) { *pNextState = 1; *pTransNum = 0; return TRUE; } return FALSE; } /* Action function for state "init" in state set "laser_stabilization_1cam" */ static void A_laser_stabilization_1cam_init(SS_ID ssId, struct UserVar *pVar, int transNum, int *pNextState) { switch(transNum) { case 0: { # line 188 "../laserSteering1cam.st" pVar->filename = seq_macValueGet(ssId, "FILENAME"); FILE *file; int i,j; float val; file = fopen(pVar->filename, "r"); if (file == 0) { printf("Can not open response matrix file %s\n",pVar->filename);} else { for (i=0;i<2;i++) { for (j=0;j<2;j++) { fscanf(file,"%f",&val); pVar->LOOP_DECPL_MTRX[i][j]=val; printf("LOOP_DECPL_MTRX[%d][%d]=%f\n",i,j,pVar->LOOP_DECPL_MTRX[i][j]); } } fclose(file); } # line 211 "../laserSteering1cam.st" pVar->var_internalReset = 0; } return; } } /****** Code for state "idle" in state set "laser_stabilization_1cam" ******/ /* Entry function for state "idle" in state set "laser_stabilization_1cam" */ static void I_laser_stabilization_1cam_idle(SS_ID ssId, struct UserVar *pVar) { # line 225 "../laserSteering1cam.st" if (pVar->loop_set_ref == 1) { # line 227 "../laserSteering1cam.st" seq_pvGet(ssId, 9/*cam_C1_v*/, 0); # line 228 "../laserSteering1cam.st" pVar->cam_C1_v_ref = pVar->cam_C1_v; # line 229 "../laserSteering1cam.st" seq_pvPut(ssId, 11/*cam_C1_v_ref*/, 0); # line 230 "../laserSteering1cam.st" seq_pvGet(ssId, 8/*cam_C1_h*/, 0); # line 231 "../laserSteering1cam.st" pVar->cam_C1_h_ref = pVar->cam_C1_h; # line 232 "../laserSteering1cam.st" seq_pvPut(ssId, 10/*cam_C1_h_ref*/, 0); # line 234 "../laserSteering1cam.st" pVar->loop_set_ref = 0; # line 235 "../laserSteering1cam.st" seq_pvPut(ssId, 2/*loop_set_ref*/, 0); } } /* Delay function for state "idle" in state set "laser_stabilization_1cam" */ static void D_laser_stabilization_1cam_idle(SS_ID ssId, struct UserVar *pVar) { # line 240 "../laserSteering1cam.st" seq_delayInit(ssId, 0, ((0.2))); } /* Event function for state "idle" in state set "laser_stabilization_1cam" */ static seqBool E_laser_stabilization_1cam_idle(SS_ID ssId, struct UserVar *pVar, int *pTransNum, int *pNextState) { # line 240 "../laserSteering1cam.st" if (seq_delay(ssId, 0)) { *pNextState = 2; *pTransNum = 0; return TRUE; } return FALSE; } /* Action function for state "idle" in state set "laser_stabilization_1cam" */ static void A_laser_stabilization_1cam_idle(SS_ID ssId, struct UserVar *pVar, int transNum, int *pNextState) { switch(transNum) { case 0: { } return; } } /****** Code for state "loop_check_motor" in state set "laser_stabilization_1cam" ******/ /* Delay function for state "loop_check_motor" in state set "laser_stabilization_1cam" */ static void D_laser_stabilization_1cam_loop_check_motor(SS_ID ssId, struct UserVar *pVar) { } /* Event function for state "loop_check_motor" in state set "laser_stabilization_1cam" */ static seqBool E_laser_stabilization_1cam_loop_check_motor(SS_ID ssId, struct UserVar *pVar, int *pTransNum, int *pNextState) { # line 248 "../laserSteering1cam.st" if ((!pVar->motor_M1_h_moving) && (!pVar->motor_M1_v_moving)) { *pNextState = 3; *pTransNum = 0; return TRUE; } return FALSE; } /* Action function for state "loop_check_motor" in state set "laser_stabilization_1cam" */ static void A_laser_stabilization_1cam_loop_check_motor(SS_ID ssId, struct UserVar *pVar, int transNum, int *pNextState) { switch(transNum) { case 0: { # line 250 "../laserSteering1cam.st" pVar->loop = 0; # line 251 "../laserSteering1cam.st" pVar->cam_C1_h_err_avg = 0; # line 252 "../laserSteering1cam.st" pVar->cam_C1_v_err_avg = 0; # line 255 "../laserSteering1cam.st" pVar->motor_M1_h_calc_dest = pVar->motor_M1_h_pos; # line 256 "../laserSteering1cam.st" pVar->motor_M1_v_calc_dest = pVar->motor_M1_v_pos; } return; } } /****** Code for state "loop_check_centroid" in state set "laser_stabilization_1cam" ******/ /* Delay function for state "loop_check_centroid" in state set "laser_stabilization_1cam" */ static void D_laser_stabilization_1cam_loop_check_centroid(SS_ID ssId, struct UserVar *pVar) { } /* Event function for state "loop_check_centroid" in state set "laser_stabilization_1cam" */ static seqBool E_laser_stabilization_1cam_loop_check_centroid(SS_ID ssId, struct UserVar *pVar, int *pTransNum, int *pNextState) { # line 264 "../laserSteering1cam.st" if (pVar->cam_C1_dark_img) { *pNextState = 1; *pTransNum = 0; return TRUE; } # line 270 "../laserSteering1cam.st" if (pVar->cam_C1_stale_img) { *pNextState = 1; *pTransNum = 1; return TRUE; } # line 276 "../laserSteering1cam.st" if (seq_pvGet(ssId, 12/*cam_C1_h_err*/, 0) != pvStatOK || seq_pvGet(ssId, 13/*cam_C1_v_err*/, 0) != pvStatOK) { *pNextState = 1; *pTransNum = 2; return TRUE; } # line 282 "../laserSteering1cam.st" if (seq_pvGet(ssId, 12/*cam_C1_h_err*/, 0) == pvStatOK && seq_pvGet(ssId, 13/*cam_C1_v_err*/, 0) == pvStatOK) { *pNextState = 4; *pTransNum = 3; return TRUE; } return FALSE; } /* Action function for state "loop_check_centroid" in state set "laser_stabilization_1cam" */ static void A_laser_stabilization_1cam_loop_check_centroid(SS_ID ssId, struct UserVar *pVar, int transNum, int *pNextState) { switch(transNum) { case 0: { # line 266 "../laserSteering1cam.st" pVar->feedback_status = 6; # line 267 "../laserSteering1cam.st" seq_pvPut(ssId, 1/*feedback_status*/, 0); } return; case 1: { # line 272 "../laserSteering1cam.st" pVar->feedback_status = 7; # line 273 "../laserSteering1cam.st" seq_pvPut(ssId, 1/*feedback_status*/, 0); } return; case 2: { # line 278 "../laserSteering1cam.st" pVar->feedback_status = 1; # line 279 "../laserSteering1cam.st" seq_pvPut(ssId, 1/*feedback_status*/, 0); } return; case 3: { # line 284 "../laserSteering1cam.st" pVar->cam_C1_h_err_avg += pVar->cam_C1_h_err; # line 285 "../laserSteering1cam.st" pVar->cam_C1_v_err_avg += pVar->cam_C1_v_err; # line 286 "../laserSteering1cam.st" pVar->loop++; } return; } } /****** Code for state "loop_calc_avg" in state set "laser_stabilization_1cam" ******/ /* Delay function for state "loop_calc_avg" in state set "laser_stabilization_1cam" */ static void D_laser_stabilization_1cam_loop_calc_avg(SS_ID ssId, struct UserVar *pVar) { # line 292 "../laserSteering1cam.st" seq_delayInit(ssId, 0, ((0.1))); } /* Event function for state "loop_calc_avg" in state set "laser_stabilization_1cam" */ static seqBool E_laser_stabilization_1cam_loop_calc_avg(SS_ID ssId, struct UserVar *pVar, int *pTransNum, int *pNextState) { # line 292 "../laserSteering1cam.st" if (pVar->loop < pVar->CHECK_TIMES && seq_delay(ssId, 0)) { *pNextState = 3; *pTransNum = 0; return TRUE; } # line 296 "../laserSteering1cam.st" if (pVar->loop >= pVar->CHECK_TIMES) { *pNextState = 5; *pTransNum = 1; return TRUE; } return FALSE; } /* Action function for state "loop_calc_avg" in state set "laser_stabilization_1cam" */ static void A_laser_stabilization_1cam_loop_calc_avg(SS_ID ssId, struct UserVar *pVar, int transNum, int *pNextState) { switch(transNum) { case 0: { } return; case 1: { # line 299 "../laserSteering1cam.st" pVar->cam_C1_h_err_avg = pVar->cam_C1_h_err_avg / pVar->loop; # line 300 "../laserSteering1cam.st" pVar->cam_C1_v_err_avg = pVar->cam_C1_v_err_avg / pVar->loop; # line 303 "../laserSteering1cam.st" if (fabs(pVar->cam_C1_h_err_avg) < pVar->var_loopDeadband_C1) # line 303 "../laserSteering1cam.st" pVar->cam_C1_h_err_avg = 0.0; # line 304 "../laserSteering1cam.st" if (fabs(pVar->cam_C1_v_err_avg) < pVar->var_loopDeadband_C1) # line 304 "../laserSteering1cam.st" pVar->cam_C1_v_err_avg = 0.0; # line 307 "../laserSteering1cam.st" pVar->cam_C1_h_err_avg *= pVar->var_loopGain; # line 308 "../laserSteering1cam.st" pVar->cam_C1_v_err_avg *= pVar->var_loopGain; # line 311 "../laserSteering1cam.st" pVar->motor_M1_h_adjustment = pVar->cam_C1_h_err_avg * pVar->LOOP_DECPL_MTRX[0][0] + pVar->cam_C1_v_err_avg * pVar->LOOP_DECPL_MTRX[0][1]; # line 314 "../laserSteering1cam.st" pVar->motor_M1_v_adjustment = pVar->cam_C1_h_err_avg * pVar->LOOP_DECPL_MTRX[1][0] + pVar->cam_C1_v_err_avg * pVar->LOOP_DECPL_MTRX[1][1]; # line 317 "../laserSteering1cam.st" seq_pvPut(ssId, 7/*motor_M1_h_adjustment*/, 0); # line 318 "../laserSteering1cam.st" seq_pvPut(ssId, 6/*motor_M1_v_adjustment*/, 0); # line 321 "../laserSteering1cam.st" pVar->loop_max_adj = 0.0; # line 322 "../laserSteering1cam.st" pVar->loop_max_adj = (((pVar->loop_max_adj) < (fabs(pVar->motor_M1_h_adjustment))) ? (fabs(pVar->motor_M1_h_adjustment)) : (pVar->loop_max_adj)); # line 323 "../laserSteering1cam.st" pVar->loop_max_adj = (((pVar->loop_max_adj) < (fabs(pVar->motor_M1_v_adjustment))) ? (fabs(pVar->motor_M1_v_adjustment)) : (pVar->loop_max_adj)); } return; } } /****** Code for state "loop_calc_dest" in state set "laser_stabilization_1cam" ******/ /* Delay function for state "loop_calc_dest" in state set "laser_stabilization_1cam" */ static void D_laser_stabilization_1cam_loop_calc_dest(SS_ID ssId, struct UserVar *pVar) { } /* Event function for state "loop_calc_dest" in state set "laser_stabilization_1cam" */ static seqBool E_laser_stabilization_1cam_loop_calc_dest(SS_ID ssId, struct UserVar *pVar, int *pTransNum, int *pNextState) { # line 330 "../laserSteering1cam.st" if (!pVar->loop_fdbk_enbl) { *pNextState = 1; *pTransNum = 0; return TRUE; } # line 336 "../laserSteering1cam.st" if (pVar->loop_fdbk_enbl && (pVar->loop_max_adj < pVar->loop_adj_min)) { *pNextState = 1; *pTransNum = 1; return TRUE; } # line 343 "../laserSteering1cam.st" if (pVar->loop_fdbk_enbl && (pVar->loop_max_adj > pVar->loop_adj_max)) { *pNextState = 1; *pTransNum = 2; return TRUE; } # line 349 "../laserSteering1cam.st" if (pVar->loop_fdbk_enbl && pVar->loop_max_adj >= pVar->loop_adj_min && pVar->loop_max_adj <= pVar->loop_adj_max) { *pNextState = 6; *pTransNum = 3; return TRUE; } return FALSE; } /* Action function for state "loop_calc_dest" in state set "laser_stabilization_1cam" */ static void A_laser_stabilization_1cam_loop_calc_dest(SS_ID ssId, struct UserVar *pVar, int transNum, int *pNextState) { switch(transNum) { case 0: { # line 332 "../laserSteering1cam.st" pVar->feedback_status = 2; # line 333 "../laserSteering1cam.st" seq_pvPut(ssId, 1/*feedback_status*/, 0); } return; case 1: { # line 339 "../laserSteering1cam.st" pVar->feedback_status = 0; # line 340 "../laserSteering1cam.st" seq_pvPut(ssId, 1/*feedback_status*/, 0); } return; case 2: { # line 345 "../laserSteering1cam.st" pVar->feedback_status = 3; # line 346 "../laserSteering1cam.st" seq_pvPut(ssId, 1/*feedback_status*/, 0); } return; case 3: { # line 351 "../laserSteering1cam.st" pVar->motor_M1_h_calc_dest += pVar->motor_M1_h_adjustment; # line 352 "../laserSteering1cam.st" pVar->motor_M1_v_calc_dest += pVar->motor_M1_v_adjustment; # line 354 "../laserSteering1cam.st" pVar->dest_in_range = 1; # line 355 "../laserSteering1cam.st" if (pVar->motor_M1_h_calc_dest > pVar->motor_M1_h_dhlm || pVar->motor_M1_h_calc_dest < pVar->motor_M1_h_dllm) # line 355 "../laserSteering1cam.st" pVar->dest_in_range = 0; # line 356 "../laserSteering1cam.st" if (pVar->motor_M1_v_calc_dest > pVar->motor_M1_v_dhlm || pVar->motor_M1_v_calc_dest < pVar->motor_M1_v_dllm) # line 356 "../laserSteering1cam.st" pVar->dest_in_range = 0; } return; } } /****** Code for state "loop_range_check" in state set "laser_stabilization_1cam" ******/ /* Delay function for state "loop_range_check" in state set "laser_stabilization_1cam" */ static void D_laser_stabilization_1cam_loop_range_check(SS_ID ssId, struct UserVar *pVar) { } /* Event function for state "loop_range_check" in state set "laser_stabilization_1cam" */ static seqBool E_laser_stabilization_1cam_loop_range_check(SS_ID ssId, struct UserVar *pVar, int *pTransNum, int *pNextState) { # line 362 "../laserSteering1cam.st" if (!pVar->dest_in_range) { *pNextState = 1; *pTransNum = 0; return TRUE; } # line 368 "../laserSteering1cam.st" if (pVar->dest_in_range) { *pNextState = 7; *pTransNum = 1; return TRUE; } return FALSE; } /* Action function for state "loop_range_check" in state set "laser_stabilization_1cam" */ static void A_laser_stabilization_1cam_loop_range_check(SS_ID ssId, struct UserVar *pVar, int transNum, int *pNextState) { switch(transNum) { case 0: { # line 364 "../laserSteering1cam.st" pVar->feedback_status = 4; # line 365 "../laserSteering1cam.st" seq_pvPut(ssId, 1/*feedback_status*/, 0); } return; case 1: { } return; } } /****** Code for state "loop_adjust_motors" in state set "laser_stabilization_1cam" ******/ /* Entry function for state "loop_adjust_motors" in state set "laser_stabilization_1cam" */ static void I_laser_stabilization_1cam_loop_adjust_motors(SS_ID ssId, struct UserVar *pVar) { # line 377 "../laserSteering1cam.st" pVar->motor_M1_h_dest = pVar->motor_M1_h_calc_dest; # line 378 "../laserSteering1cam.st" seq_pvPut(ssId, 16/*motor_M1_h_dest*/, 0); # line 380 "../laserSteering1cam.st" pVar->motor_M1_v_dest = pVar->motor_M1_v_calc_dest; # line 381 "../laserSteering1cam.st" seq_pvPut(ssId, 22/*motor_M1_v_dest*/, 0); # line 383 "../laserSteering1cam.st" pVar->feedback_status = 5; # line 384 "../laserSteering1cam.st" seq_pvPut(ssId, 1/*feedback_status*/, 0); } /* Delay function for state "loop_adjust_motors" in state set "laser_stabilization_1cam" */ static void D_laser_stabilization_1cam_loop_adjust_motors(SS_ID ssId, struct UserVar *pVar) { # line 387 "../laserSteering1cam.st" seq_delayInit(ssId, 0, ((0.5))); } /* Event function for state "loop_adjust_motors" in state set "laser_stabilization_1cam" */ static seqBool E_laser_stabilization_1cam_loop_adjust_motors(SS_ID ssId, struct UserVar *pVar, int *pTransNum, int *pNextState) { # line 387 "../laserSteering1cam.st" if (seq_delay(ssId, 0)) { *pNextState = 8; *pTransNum = 0; return TRUE; } return FALSE; } /* Action function for state "loop_adjust_motors" in state set "laser_stabilization_1cam" */ static void A_laser_stabilization_1cam_loop_adjust_motors(SS_ID ssId, struct UserVar *pVar, int transNum, int *pNextState) { switch(transNum) { case 0: { } return; } } /****** Code for state "loop_wait_motors" in state set "laser_stabilization_1cam" ******/ /* Delay function for state "loop_wait_motors" in state set "laser_stabilization_1cam" */ static void D_laser_stabilization_1cam_loop_wait_motors(SS_ID ssId, struct UserVar *pVar) { # line 400 "../laserSteering1cam.st" seq_delayInit(ssId, 0, ((5.0))); } /* Event function for state "loop_wait_motors" in state set "laser_stabilization_1cam" */ static seqBool E_laser_stabilization_1cam_loop_wait_motors(SS_ID ssId, struct UserVar *pVar, int *pTransNum, int *pNextState) { # line 394 "../laserSteering1cam.st" if (!pVar->loop_fdbk_enbl) { *pNextState = 1; *pTransNum = 0; return TRUE; } # line 400 "../laserSteering1cam.st" if (seq_delay(ssId, 0) || ((!pVar->motor_M1_h_moving) && (!pVar->motor_M1_v_moving))) { *pNextState = 9; *pTransNum = 1; return TRUE; } return FALSE; } /* Action function for state "loop_wait_motors" in state set "laser_stabilization_1cam" */ static void A_laser_stabilization_1cam_loop_wait_motors(SS_ID ssId, struct UserVar *pVar, int transNum, int *pNextState) { switch(transNum) { case 0: { # line 396 "../laserSteering1cam.st" pVar->feedback_status = 2; # line 397 "../laserSteering1cam.st" seq_pvPut(ssId, 1/*feedback_status*/, 0); } return; case 1: { } return; } } /****** Code for state "loop_check_position" in state set "laser_stabilization_1cam" ******/ /* Delay function for state "loop_check_position" in state set "laser_stabilization_1cam" */ static void D_laser_stabilization_1cam_loop_check_position(SS_ID ssId, struct UserVar *pVar) { } /* Event function for state "loop_check_position" in state set "laser_stabilization_1cam" */ static seqBool E_laser_stabilization_1cam_loop_check_position(SS_ID ssId, struct UserVar *pVar, int *pTransNum, int *pNextState) { # line 407 "../laserSteering1cam.st" if ((fabs(pVar->motor_M1_h_pos - pVar->motor_M1_h_calc_dest) >= pVar->loop_adj_min) || (fabs(pVar->motor_M1_v_pos - pVar->motor_M1_v_calc_dest) >= pVar->loop_adj_min)) { *pNextState = 1; *pTransNum = 0; return TRUE; } # line 411 "../laserSteering1cam.st" if ((fabs(pVar->motor_M1_h_pos - pVar->motor_M1_h_calc_dest) < pVar->loop_adj_min) && (fabs(pVar->motor_M1_v_pos - pVar->motor_M1_v_calc_dest) < pVar->loop_adj_min)) { *pNextState = 1; *pTransNum = 1; return TRUE; } return FALSE; } /* Action function for state "loop_check_position" in state set "laser_stabilization_1cam" */ static void A_laser_stabilization_1cam_loop_check_position(SS_ID ssId, struct UserVar *pVar, int transNum, int *pNextState) { switch(transNum) { case 0: { } return; case 1: { # line 413 "../laserSteering1cam.st" pVar->feedback_status = 0; # line 414 "../laserSteering1cam.st" seq_pvPut(ssId, 1/*feedback_status*/, 0); } return; } } /************************ Tables ************************/ /* Channel table */ static seqChan G_channels[] = { /* chName, offset, varName, varType, count, eventNum, efId, monitored, queueSize, queueIndex */ {"{LOOP}:POS_FDBK", offsetof(struct UserVar, loop_fdbk_enbl), "loop_fdbk_enbl", "unsigned int", 1, 1, 0, 1, 0, 0}, {"{LOOP}:POS_FDBK_STS", offsetof(struct UserVar, feedback_status), "feedback_status", "unsigned short", 1, 2, 0, 0, 0, 0}, {"{LOOP}:SET_REF", offsetof(struct UserVar, loop_set_ref), "loop_set_ref", "unsigned int", 1, 3, 0, 1, 0, 0}, {"{LOOP}:POS_FDBK_MIN", offsetof(struct UserVar, loop_adj_min), "loop_adj_min", "double", 1, 4, 0, 1, 0, 0}, {"{LOOP}:POS_FDBK_MAX", offsetof(struct UserVar, loop_adj_max), "loop_adj_max", "double", 1, 5, 0, 1, 0, 0}, {"{LOOP}:POS_FDBK_AVGTIME", offsetof(struct UserVar, CHECK_TIMES), "CHECK_TIMES", "unsigned short", 1, 6, 0, 1, 0, 0}, {"{LOOP}:M1_V_ADJ", offsetof(struct UserVar, motor_M1_v_adjustment), "motor_M1_v_adjustment", "double", 1, 7, 0, 0, 0, 0}, {"{LOOP}:M1_H_ADJ", offsetof(struct UserVar, motor_M1_h_adjustment), "motor_M1_h_adjustment", "double", 1, 8, 0, 0, 0, 0}, {"{LOOP}:C1_H_ERR.B", offsetof(struct UserVar, cam_C1_h), "cam_C1_h", "double", 1, 9, 0, 0, 0, 0}, {"{LOOP}:C1_V_ERR.B", offsetof(struct UserVar, cam_C1_v), "cam_C1_v", "double", 1, 10, 0, 0, 0, 0}, {"{LOOP}:C1_H_REF", offsetof(struct UserVar, cam_C1_h_ref), "cam_C1_h_ref", "double", 1, 11, 0, 0, 0, 0}, {"{LOOP}:C1_V_REF", offsetof(struct UserVar, cam_C1_v_ref), "cam_C1_v_ref", "double", 1, 12, 0, 0, 0, 0}, {"{LOOP}:C1_H_ERR", offsetof(struct UserVar, cam_C1_h_err), "cam_C1_h_err", "double", 1, 13, 0, 0, 0, 0}, {"{LOOP}:C1_V_ERR", offsetof(struct UserVar, cam_C1_v_err), "cam_C1_v_err", "double", 1, 14, 0, 0, 0, 0}, {"{LOOP}:DARKIMG_1", offsetof(struct UserVar, cam_C1_dark_img), "cam_C1_dark_img", "double", 1, 15, 0, 1, 0, 0}, {"{LOOP}:STALEIMG_1", offsetof(struct UserVar, cam_C1_stale_img), "cam_C1_stale_img", "double", 1, 16, 0, 1, 0, 0}, {"{M1_H}.VAL", offsetof(struct UserVar, motor_M1_h_dest), "motor_M1_h_dest", "double", 1, 17, 0, 0, 0, 0}, {"{M1_H}.RBV", offsetof(struct UserVar, motor_M1_h_pos), "motor_M1_h_pos", "double", 1, 18, 0, 1, 0, 0}, {"{M1_H}.MOVN", offsetof(struct UserVar, motor_M1_h_moving), "motor_M1_h_moving", "unsigned int", 1, 19, 0, 1, 0, 0}, {"{M1_H}.DHLM", offsetof(struct UserVar, motor_M1_h_dhlm), "motor_M1_h_dhlm", "double", 1, 20, 0, 1, 0, 0}, {"{M1_H}.DLLM", offsetof(struct UserVar, motor_M1_h_dllm), "motor_M1_h_dllm", "double", 1, 21, 0, 1, 0, 0}, {"{M1_H}.RDBD", offsetof(struct UserVar, motor_M1_h_rdbd), "motor_M1_h_rdbd", "double", 1, 22, 0, 1, 0, 0}, {"{M1_V}.VAL", offsetof(struct UserVar, motor_M1_v_dest), "motor_M1_v_dest", "double", 1, 23, 0, 0, 0, 0}, {"{M1_V}.RBV", offsetof(struct UserVar, motor_M1_v_pos), "motor_M1_v_pos", "double", 1, 24, 0, 1, 0, 0}, {"{M1_V}.MOVN", offsetof(struct UserVar, motor_M1_v_moving), "motor_M1_v_moving", "unsigned int", 1, 25, 0, 1, 0, 0}, {"{M1_V}.DHLM", offsetof(struct UserVar, motor_M1_v_dhlm), "motor_M1_v_dhlm", "double", 1, 26, 0, 1, 0, 0}, {"{M1_V}.DLLM", offsetof(struct UserVar, motor_M1_v_dllm), "motor_M1_v_dllm", "double", 1, 27, 0, 1, 0, 0}, {"{M1_V}.RDBD", offsetof(struct UserVar, motor_M1_v_rdbd), "motor_M1_v_rdbd", "double", 1, 28, 0, 1, 0, 0}, {"{LOOP}:GAIN", offsetof(struct UserVar, var_loopGain), "var_loopGain", "double", 1, 29, 0, 1, 0, 0}, {"{LOOP}:DEADBAND_1", offsetof(struct UserVar, var_loopDeadband_C1), "var_loopDeadband_C1", "double", 1, 30, 0, 1, 0, 0} }; /* Event masks for state set "laser_stabilization_1cam" */ static const seqMask EM_laser_stabilization_1cam_init[] = { 0x00000000, }; static const seqMask EM_laser_stabilization_1cam_idle[] = { 0x00000000, }; static const seqMask EM_laser_stabilization_1cam_loop_check_motor[] = { 0x02080000, }; static const seqMask EM_laser_stabilization_1cam_loop_check_centroid[] = { 0x0001e000, }; static const seqMask EM_laser_stabilization_1cam_loop_calc_avg[] = { 0x00000040, }; static const seqMask EM_laser_stabilization_1cam_loop_calc_dest[] = { 0x00000032, }; static const seqMask EM_laser_stabilization_1cam_loop_range_check[] = { 0x00000000, }; static const seqMask EM_laser_stabilization_1cam_loop_adjust_motors[] = { 0x00000000, }; static const seqMask EM_laser_stabilization_1cam_loop_wait_motors[] = { 0x02080002, }; static const seqMask EM_laser_stabilization_1cam_loop_check_position[] = { 0x01040010, }; /* State table for state set "laser_stabilization_1cam" */ static seqState G_laser_stabilization_1cam_states[] = { { /* state name */ "init", /* action function */ A_laser_stabilization_1cam_init, /* event function */ E_laser_stabilization_1cam_init, /* delay function */ D_laser_stabilization_1cam_init, /* entry function */ 0, /* exit function */ 0, /* event mask array */ EM_laser_stabilization_1cam_init, /* state options */ (0) }, { /* state name */ "idle", /* action function */ A_laser_stabilization_1cam_idle, /* event function */ E_laser_stabilization_1cam_idle, /* delay function */ D_laser_stabilization_1cam_idle, /* entry function */ I_laser_stabilization_1cam_idle, /* exit function */ 0, /* event mask array */ EM_laser_stabilization_1cam_idle, /* state options */ (0) }, { /* state name */ "loop_check_motor", /* action function */ A_laser_stabilization_1cam_loop_check_motor, /* event function */ E_laser_stabilization_1cam_loop_check_motor, /* delay function */ D_laser_stabilization_1cam_loop_check_motor, /* entry function */ 0, /* exit function */ 0, /* event mask array */ EM_laser_stabilization_1cam_loop_check_motor, /* state options */ (0) }, { /* state name */ "loop_check_centroid", /* action function */ A_laser_stabilization_1cam_loop_check_centroid, /* event function */ E_laser_stabilization_1cam_loop_check_centroid, /* delay function */ D_laser_stabilization_1cam_loop_check_centroid, /* entry function */ 0, /* exit function */ 0, /* event mask array */ EM_laser_stabilization_1cam_loop_check_centroid, /* state options */ (0) }, { /* state name */ "loop_calc_avg", /* action function */ A_laser_stabilization_1cam_loop_calc_avg, /* event function */ E_laser_stabilization_1cam_loop_calc_avg, /* delay function */ D_laser_stabilization_1cam_loop_calc_avg, /* entry function */ 0, /* exit function */ 0, /* event mask array */ EM_laser_stabilization_1cam_loop_calc_avg, /* state options */ (0) }, { /* state name */ "loop_calc_dest", /* action function */ A_laser_stabilization_1cam_loop_calc_dest, /* event function */ E_laser_stabilization_1cam_loop_calc_dest, /* delay function */ D_laser_stabilization_1cam_loop_calc_dest, /* entry function */ 0, /* exit function */ 0, /* event mask array */ EM_laser_stabilization_1cam_loop_calc_dest, /* state options */ (0) }, { /* state name */ "loop_range_check", /* action function */ A_laser_stabilization_1cam_loop_range_check, /* event function */ E_laser_stabilization_1cam_loop_range_check, /* delay function */ D_laser_stabilization_1cam_loop_range_check, /* entry function */ 0, /* exit function */ 0, /* event mask array */ EM_laser_stabilization_1cam_loop_range_check, /* state options */ (0) }, { /* state name */ "loop_adjust_motors", /* action function */ A_laser_stabilization_1cam_loop_adjust_motors, /* event function */ E_laser_stabilization_1cam_loop_adjust_motors, /* delay function */ D_laser_stabilization_1cam_loop_adjust_motors, /* entry function */ I_laser_stabilization_1cam_loop_adjust_motors, /* exit function */ 0, /* event mask array */ EM_laser_stabilization_1cam_loop_adjust_motors, /* state options */ (0) }, { /* state name */ "loop_wait_motors", /* action function */ A_laser_stabilization_1cam_loop_wait_motors, /* event function */ E_laser_stabilization_1cam_loop_wait_motors, /* delay function */ D_laser_stabilization_1cam_loop_wait_motors, /* entry function */ 0, /* exit function */ 0, /* event mask array */ EM_laser_stabilization_1cam_loop_wait_motors, /* state options */ (0) }, { /* state name */ "loop_check_position", /* action function */ A_laser_stabilization_1cam_loop_check_position, /* event function */ E_laser_stabilization_1cam_loop_check_position, /* delay function */ D_laser_stabilization_1cam_loop_check_position, /* entry function */ 0, /* exit function */ 0, /* event mask array */ EM_laser_stabilization_1cam_loop_check_position, /* state options */ (0) }, }; /* State set table */ static seqSS G_state_sets[] = { { /* state set name */ "laser_stabilization_1cam", /* states */ G_laser_stabilization_1cam_states, /* number of states */ 10, /* number of delays */ 1 }, }; /* Program table (global) */ seqProgram LaserSteering1cam = { /* magic number */ 2001006, /* program name */ "LaserSteering1cam", /* channels */ G_channels, /* num. channels */ 30, /* state sets */ G_state_sets, /* num. state sets */ 1, /* user var size */ sizeof(struct UserVar), /* param */ "stack=200000", /* num. event flags */ 0, /* encoded options */ (0 | OPT_CONN | OPT_DEBUG | OPT_NEWEF | OPT_REENT), /* init func */ G_prog_init, /* entry func */ NULL, /* exit func */ NULL, /* num. queues */ 0 }; /* Register sequencer commands and program */ #include "epicsExport.h" static void LaserSteering1camRegistrar (void) { seqRegisterSequencerCommands(); seqRegisterSequencerProgram (&LaserSteering1cam); } epicsExportRegistrar(LaserSteering1camRegistrar);