/* Generated with snc from laserSteering2cam.i */ /* Program "LaserSteering2cam" */ #include #include #include #include #include "epicsTypes.h" #include "seqCom.h" /* Variable declarations */ struct UserVar { # line 37 "../laserSteering2cam.st" double cam_C1_h; # line 40 "../laserSteering2cam.st" double cam_C1_v; # line 43 "../laserSteering2cam.st" double cam_C2_h; # line 46 "../laserSteering2cam.st" double cam_C2_v; # line 49 "../laserSteering2cam.st" double cam_C1_h_ref; # line 52 "../laserSteering2cam.st" double cam_C1_v_ref; # line 55 "../laserSteering2cam.st" double cam_C2_v_ref; # line 58 "../laserSteering2cam.st" double cam_C2_h_ref; # line 61 "../laserSteering2cam.st" double cam_C1_h_err; # line 63 "../laserSteering2cam.st" double cam_C1_h_err_avg; # line 65 "../laserSteering2cam.st" double cam_C1_v_err; # line 67 "../laserSteering2cam.st" double cam_C1_v_err_avg; # line 69 "../laserSteering2cam.st" double cam_C1_dark_img; # line 73 "../laserSteering2cam.st" double cam_C1_stale_img; # line 77 "../laserSteering2cam.st" double cam_C2_h_err; # line 79 "../laserSteering2cam.st" double cam_C2_h_err_avg; # line 81 "../laserSteering2cam.st" double cam_C2_v_err; # line 83 "../laserSteering2cam.st" double cam_C2_v_err_avg; # line 85 "../laserSteering2cam.st" double cam_C2_dark_img; # line 89 "../laserSteering2cam.st" double cam_C2_stale_img; # line 94 "../laserSteering2cam.st" unsigned int loop_fdbk_enbl; # line 98 "../laserSteering2cam.st" unsigned int loop_set_ref; # line 102 "../laserSteering2cam.st" double loop_adj_min; # line 106 "../laserSteering2cam.st" double loop_adj_max; # line 111 "../laserSteering2cam.st" unsigned short feedback_status; # line 116 "../laserSteering2cam.st" unsigned short CHECK_TIMES; # line 121 "../laserSteering2cam.st" double motor_M1_h_adjustment; # line 124 "../laserSteering2cam.st" double motor_M1_h_calc_dest; # line 125 "../laserSteering2cam.st" double motor_M1_h_dest; # line 128 "../laserSteering2cam.st" double motor_M1_h_pos; # line 132 "../laserSteering2cam.st" unsigned int motor_M1_h_moving; # line 136 "../laserSteering2cam.st" double motor_M1_h_dhlm; # line 140 "../laserSteering2cam.st" double motor_M1_h_dllm; # line 145 "../laserSteering2cam.st" double motor_M1_v_adjustment; # line 148 "../laserSteering2cam.st" double motor_M1_v_calc_dest; # line 149 "../laserSteering2cam.st" double motor_M1_v_dest; # line 152 "../laserSteering2cam.st" double motor_M1_v_pos; # line 156 "../laserSteering2cam.st" unsigned int motor_M1_v_moving; # line 160 "../laserSteering2cam.st" double motor_M1_v_dhlm; # line 164 "../laserSteering2cam.st" double motor_M1_v_dllm; # line 169 "../laserSteering2cam.st" double motor_M2_h_adjustment; # line 172 "../laserSteering2cam.st" double motor_M2_h_calc_dest; # line 173 "../laserSteering2cam.st" double motor_M2_h_dest; # line 176 "../laserSteering2cam.st" double motor_M2_h_pos; # line 180 "../laserSteering2cam.st" unsigned int motor_M2_h_moving; # line 184 "../laserSteering2cam.st" double motor_M2_h_dhlm; # line 188 "../laserSteering2cam.st" double motor_M2_h_dllm; # line 193 "../laserSteering2cam.st" double motor_M2_v_adjustment; # line 196 "../laserSteering2cam.st" double motor_M2_v_calc_dest; # line 197 "../laserSteering2cam.st" double motor_M2_v_dest; # line 200 "../laserSteering2cam.st" double motor_M2_v_pos; # line 204 "../laserSteering2cam.st" unsigned int motor_M2_v_moving; # line 208 "../laserSteering2cam.st" double motor_M2_v_dhlm; # line 212 "../laserSteering2cam.st" double motor_M2_v_dllm; # line 217 "../laserSteering2cam.st" char *filename; # line 224 "../laserSteering2cam.st" double var_loopGain; # line 228 "../laserSteering2cam.st" double var_loopDeadband_C1; # line 232 "../laserSteering2cam.st" double var_loopDeadband_C2; # line 236 "../laserSteering2cam.st" unsigned int var_loopReset; # line 240 "../laserSteering2cam.st" unsigned int DEBUG; # line 245 "../laserSteering2cam.st" double var_loopInitPosition_motor_M1_h; # line 246 "../laserSteering2cam.st" double var_loopInitPosition_motor_M1_v; # line 247 "../laserSteering2cam.st" double var_loopInitPosition_motor_M2_h; # line 248 "../laserSteering2cam.st" double var_loopInitPosition_motor_M2_v; # line 250 "../laserSteering2cam.st" int var_internalReset; # line 252 "../laserSteering2cam.st" long tempum1; # line 255 "../laserSteering2cam.st" int loop; # line 256 "../laserSteering2cam.st" int i; # line 257 "../laserSteering2cam.st" int j; # line 258 "../laserSteering2cam.st" int tempum; # line 260 "../laserSteering2cam.st" int dest_in_range; # line 261 "../laserSteering2cam.st" double loop_max_adj; # line 269 "../laserSteering2cam.st" float LOOP_DECPL_MTRX[4][4]; }; /* C code definitions */ # line 15 "../laserSteering2cam.st" #include "string.h" # line 16 "../laserSteering2cam.st" #include "math.h" # line 17 "../laserSteering2cam.st" #include "epicsTime.h" # line 18 "../laserSteering2cam.st" #include "stdio.h" # line 19 "../laserSteering2cam.st" #include "stdlib.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, 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_2cam" ******/ /* Delay function for state "init" in state set "laser_stabilization_2cam" */ static void D_laser_stabilization_2cam_init(SS_ID ssId, struct UserVar *pVar) { } /* Event function for state "init" in state set "laser_stabilization_2cam" */ static seqBool E_laser_stabilization_2cam_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_2cam" */ static void A_laser_stabilization_2cam_init(SS_ID ssId, struct UserVar *pVar, int transNum, int *pNextState) { switch(transNum) { case 0: { # line 283 "../laserSteering2cam.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<4;i++){ for (j=0;j<4;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 304 "../laserSteering2cam.st" pVar->var_loopInitPosition_motor_M1_h = pVar->motor_M1_h_pos; # line 305 "../laserSteering2cam.st" pVar->var_loopInitPosition_motor_M1_v = pVar->motor_M1_v_pos; # line 306 "../laserSteering2cam.st" pVar->var_loopInitPosition_motor_M2_h = pVar->motor_M2_h_pos; # line 307 "../laserSteering2cam.st" pVar->var_loopInitPosition_motor_M2_v = pVar->motor_M2_v_pos; # line 309 "../laserSteering2cam.st" pVar->var_internalReset = 0; # line 311 "../laserSteering2cam.st" if (pVar->DEBUG) # line 314 "../laserSteering2cam.st" printf("initialization: init pos, motor_M1_h = %lf, motor_M1_v = %lf, motor_M2_h = %lf, motor_M2_v = %lf\n", pVar->var_loopInitPosition_motor_M1_h, pVar->var_loopInitPosition_motor_M1_v, pVar->var_loopInitPosition_motor_M2_h, pVar->var_loopInitPosition_motor_M2_v); } return; } } /****** Code for state "idle" in state set "laser_stabilization_2cam" ******/ /* Entry function for state "idle" in state set "laser_stabilization_2cam" */ static void I_laser_stabilization_2cam_idle(SS_ID ssId, struct UserVar *pVar) { # line 325 "../laserSteering2cam.st" if (pVar->DEBUG) # line 325 "../laserSteering2cam.st" printf("idle: entry\n"); # line 327 "../laserSteering2cam.st" if (pVar->loop_set_ref == 1) { # line 328 "../laserSteering2cam.st" seq_pvGet(ssId, 1/*cam_C1_v*/, 0); # line 329 "../laserSteering2cam.st" pVar->cam_C1_v_ref = pVar->cam_C1_v; # line 330 "../laserSteering2cam.st" seq_pvPut(ssId, 5/*cam_C1_v_ref*/, 0); # line 331 "../laserSteering2cam.st" seq_pvGet(ssId, 0/*cam_C1_h*/, 0); # line 332 "../laserSteering2cam.st" pVar->cam_C1_h_ref = pVar->cam_C1_h; # line 333 "../laserSteering2cam.st" seq_pvPut(ssId, 4/*cam_C1_h_ref*/, 0); # line 334 "../laserSteering2cam.st" seq_pvGet(ssId, 3/*cam_C2_v*/, 0); # line 335 "../laserSteering2cam.st" pVar->cam_C2_v_ref = pVar->cam_C2_v; # line 336 "../laserSteering2cam.st" seq_pvPut(ssId, 6/*cam_C2_v_ref*/, 0); # line 337 "../laserSteering2cam.st" seq_pvGet(ssId, 2/*cam_C2_h*/, 0); # line 338 "../laserSteering2cam.st" pVar->cam_C2_h_ref = pVar->cam_C2_h; # line 339 "../laserSteering2cam.st" seq_pvPut(ssId, 7/*cam_C2_h_ref*/, 0); # line 341 "../laserSteering2cam.st" pVar->loop_set_ref = 0; # line 342 "../laserSteering2cam.st" seq_pvPut(ssId, 17/*loop_set_ref*/, 0); } # line 346 "../laserSteering2cam.st" if (pVar->var_loopReset != 0 || !pVar->loop_fdbk_enbl || pVar->var_internalReset) { # line 350 "../laserSteering2cam.st" pVar->var_loopInitPosition_motor_M1_h = pVar->motor_M1_h_pos; # line 351 "../laserSteering2cam.st" pVar->var_loopInitPosition_motor_M1_v = pVar->motor_M1_v_pos; # line 352 "../laserSteering2cam.st" pVar->var_loopInitPosition_motor_M2_h = pVar->motor_M2_h_pos; # line 353 "../laserSteering2cam.st" pVar->var_loopInitPosition_motor_M2_v = pVar->motor_M2_v_pos; # line 355 "../laserSteering2cam.st" pVar->cam_C1_h_err_avg = 0; # line 356 "../laserSteering2cam.st" pVar->cam_C1_v_err_avg = 0; # line 357 "../laserSteering2cam.st" pVar->cam_C2_h_err_avg = 0; # line 358 "../laserSteering2cam.st" pVar->cam_C2_v_err_avg = 0; # line 361 "../laserSteering2cam.st" pVar->var_loopReset = 0; # line 362 "../laserSteering2cam.st" seq_pvPut(ssId, 49/*var_loopReset*/, 0); # line 364 "../laserSteering2cam.st" if (pVar->DEBUG) # line 367 "../laserSteering2cam.st" printf("idle: entry - reset, init pos, motor_M1_h = %lf, motor_M1_v = %lf, motor_M2_h = %lf, motor_M2_v = %lf\n", pVar->var_loopInitPosition_motor_M1_h, pVar->var_loopInitPosition_motor_M1_v, pVar->var_loopInitPosition_motor_M2_h, pVar->var_loopInitPosition_motor_M2_v); } } /* Delay function for state "idle" in state set "laser_stabilization_2cam" */ static void D_laser_stabilization_2cam_idle(SS_ID ssId, struct UserVar *pVar) { # line 372 "../laserSteering2cam.st" seq_delayInit(ssId, 0, ((0.2))); } /* Event function for state "idle" in state set "laser_stabilization_2cam" */ static seqBool E_laser_stabilization_2cam_idle(SS_ID ssId, struct UserVar *pVar, int *pTransNum, int *pNextState) { # line 372 "../laserSteering2cam.st" if (seq_delay(ssId, 0)) { *pNextState = 2; *pTransNum = 0; return TRUE; } return FALSE; } /* Action function for state "idle" in state set "laser_stabilization_2cam" */ static void A_laser_stabilization_2cam_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_2cam" ******/ /* Delay function for state "loop_check_motor" in state set "laser_stabilization_2cam" */ static void D_laser_stabilization_2cam_loop_check_motor(SS_ID ssId, struct UserVar *pVar) { } /* Event function for state "loop_check_motor" in state set "laser_stabilization_2cam" */ static seqBool E_laser_stabilization_2cam_loop_check_motor(SS_ID ssId, struct UserVar *pVar, int *pTransNum, int *pNextState) { # line 384 "../laserSteering2cam.st" if ((!pVar->motor_M1_h_moving) && (!pVar->motor_M1_v_moving) && (!pVar->motor_M2_h_moving) && (!pVar->motor_M2_v_moving)) { *pNextState = 3; *pTransNum = 0; return TRUE; } return FALSE; } /* Action function for state "loop_check_motor" in state set "laser_stabilization_2cam" */ static void A_laser_stabilization_2cam_loop_check_motor(SS_ID ssId, struct UserVar *pVar, int transNum, int *pNextState) { switch(transNum) { case 0: { # line 386 "../laserSteering2cam.st" if (pVar->DEBUG) # line 386 "../laserSteering2cam.st" printf("loop_check_motor\n"); # line 389 "../laserSteering2cam.st" pVar->loop = 0; # line 390 "../laserSteering2cam.st" pVar->cam_C1_h_err_avg = 0; # line 391 "../laserSteering2cam.st" pVar->cam_C1_v_err_avg = 0; # line 392 "../laserSteering2cam.st" pVar->cam_C2_h_err_avg = 0; # line 393 "../laserSteering2cam.st" pVar->cam_C2_v_err_avg = 0; # line 395 "../laserSteering2cam.st" pVar->var_loopInitPosition_motor_M1_h = pVar->motor_M1_h_pos; # line 396 "../laserSteering2cam.st" pVar->var_loopInitPosition_motor_M1_v = pVar->motor_M1_v_pos; # line 397 "../laserSteering2cam.st" pVar->var_loopInitPosition_motor_M2_h = pVar->motor_M2_h_pos; # line 398 "../laserSteering2cam.st" pVar->var_loopInitPosition_motor_M2_v = pVar->motor_M2_v_pos; } return; } } /****** Code for state "loop_check_centroid" in state set "laser_stabilization_2cam" ******/ /* Delay function for state "loop_check_centroid" in state set "laser_stabilization_2cam" */ static void D_laser_stabilization_2cam_loop_check_centroid(SS_ID ssId, struct UserVar *pVar) { } /* Event function for state "loop_check_centroid" in state set "laser_stabilization_2cam" */ static seqBool E_laser_stabilization_2cam_loop_check_centroid(SS_ID ssId, struct UserVar *pVar, int *pTransNum, int *pNextState) { # line 408 "../laserSteering2cam.st" if (pVar->cam_C1_dark_img || pVar->cam_C2_dark_img) { *pNextState = 1; *pTransNum = 0; return TRUE; } # line 415 "../laserSteering2cam.st" if (pVar->cam_C1_stale_img || pVar->cam_C2_stale_img) { *pNextState = 1; *pTransNum = 1; return TRUE; } # line 422 "../laserSteering2cam.st" if (seq_pvGet(ssId, 8/*cam_C1_h_err*/, 0) == pvStatOK && seq_pvGet(ssId, 9/*cam_C1_v_err*/, 0) == pvStatOK && seq_pvGet(ssId, 12/*cam_C2_h_err*/, 0) == pvStatOK && seq_pvGet(ssId, 13/*cam_C2_v_err*/, 0) == pvStatOK) { *pNextState = 4; *pTransNum = 2; return TRUE; } return FALSE; } /* Action function for state "loop_check_centroid" in state set "laser_stabilization_2cam" */ static void A_laser_stabilization_2cam_loop_check_centroid(SS_ID ssId, struct UserVar *pVar, int transNum, int *pNextState) { switch(transNum) { case 0: { # line 411 "../laserSteering2cam.st" pVar->feedback_status = 6; # line 412 "../laserSteering2cam.st" seq_pvPut(ssId, 20/*feedback_status*/, 0); } return; case 1: { # line 418 "../laserSteering2cam.st" pVar->feedback_status = 7; # line 419 "../laserSteering2cam.st" seq_pvPut(ssId, 20/*feedback_status*/, 0); } return; case 2: { # line 424 "../laserSteering2cam.st" pVar->cam_C1_h_err_avg += pVar->cam_C1_h_err; # line 425 "../laserSteering2cam.st" pVar->cam_C1_v_err_avg += pVar->cam_C1_v_err; # line 426 "../laserSteering2cam.st" pVar->cam_C2_h_err_avg += pVar->cam_C2_h_err; # line 427 "../laserSteering2cam.st" pVar->cam_C2_v_err_avg += pVar->cam_C2_v_err; # line 428 "../laserSteering2cam.st" if (pVar->DEBUG) # line 428 "../laserSteering2cam.st" printf("loop_check_centroid: average index %d, %f,%f\n", pVar->loop, pVar->cam_C1_h_err_avg, pVar->cam_C1_h_err); # line 429 "../laserSteering2cam.st" pVar->loop++; } return; } } /****** Code for state "loop_calc_avg" in state set "laser_stabilization_2cam" ******/ /* Delay function for state "loop_calc_avg" in state set "laser_stabilization_2cam" */ static void D_laser_stabilization_2cam_loop_calc_avg(SS_ID ssId, struct UserVar *pVar) { # line 439 "../laserSteering2cam.st" seq_delayInit(ssId, 0, ((0.1))); } /* Event function for state "loop_calc_avg" in state set "laser_stabilization_2cam" */ static seqBool E_laser_stabilization_2cam_loop_calc_avg(SS_ID ssId, struct UserVar *pVar, int *pTransNum, int *pNextState) { # line 439 "../laserSteering2cam.st" if (pVar->loop < pVar->CHECK_TIMES && seq_delay(ssId, 0)) { *pNextState = 3; *pTransNum = 0; return TRUE; } # line 443 "../laserSteering2cam.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_2cam" */ static void A_laser_stabilization_2cam_loop_calc_avg(SS_ID ssId, struct UserVar *pVar, int transNum, int *pNextState) { switch(transNum) { case 0: { } return; case 1: { # line 446 "../laserSteering2cam.st" pVar->cam_C1_h_err_avg = pVar->cam_C1_h_err_avg / pVar->loop; # line 447 "../laserSteering2cam.st" pVar->cam_C1_v_err_avg = pVar->cam_C1_v_err_avg / pVar->loop; # line 448 "../laserSteering2cam.st" pVar->cam_C2_h_err_avg = pVar->cam_C2_h_err_avg / pVar->loop; # line 449 "../laserSteering2cam.st" pVar->cam_C2_v_err_avg = pVar->cam_C2_v_err_avg / pVar->loop; # line 452 "../laserSteering2cam.st" if (fabs(pVar->cam_C1_h_err_avg) < pVar->var_loopDeadband_C1) # line 452 "../laserSteering2cam.st" pVar->cam_C1_h_err_avg = 0.0; # line 453 "../laserSteering2cam.st" if (fabs(pVar->cam_C1_v_err_avg) < pVar->var_loopDeadband_C1) # line 453 "../laserSteering2cam.st" pVar->cam_C1_v_err_avg = 0.0; # line 454 "../laserSteering2cam.st" if (fabs(pVar->cam_C2_h_err_avg) < pVar->var_loopDeadband_C2) # line 454 "../laserSteering2cam.st" pVar->cam_C2_h_err_avg = 0.0; # line 455 "../laserSteering2cam.st" if (fabs(pVar->cam_C2_v_err_avg) < pVar->var_loopDeadband_C2) # line 455 "../laserSteering2cam.st" pVar->cam_C2_v_err_avg = 0.0; # line 458 "../laserSteering2cam.st" pVar->cam_C1_h_err_avg *= pVar->var_loopGain; # line 459 "../laserSteering2cam.st" pVar->cam_C1_v_err_avg *= pVar->var_loopGain; # line 460 "../laserSteering2cam.st" pVar->cam_C2_h_err_avg *= pVar->var_loopGain; # line 461 "../laserSteering2cam.st" pVar->cam_C2_v_err_avg *= pVar->var_loopGain; # line 467 "../laserSteering2cam.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] + pVar->cam_C2_h_err_avg * pVar->LOOP_DECPL_MTRX[0][2] + pVar->cam_C2_v_err_avg * pVar->LOOP_DECPL_MTRX[0][3]; # line 472 "../laserSteering2cam.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] + pVar->cam_C2_h_err_avg * pVar->LOOP_DECPL_MTRX[1][2] + pVar->cam_C2_v_err_avg * pVar->LOOP_DECPL_MTRX[1][3]; # line 477 "../laserSteering2cam.st" pVar->motor_M2_h_adjustment = pVar->cam_C1_h_err_avg * pVar->LOOP_DECPL_MTRX[2][0] + pVar->cam_C1_v_err_avg * pVar->LOOP_DECPL_MTRX[2][1] + pVar->cam_C2_h_err_avg * pVar->LOOP_DECPL_MTRX[2][2] + pVar->cam_C2_v_err_avg * pVar->LOOP_DECPL_MTRX[2][3]; # line 482 "../laserSteering2cam.st" pVar->motor_M2_v_adjustment = pVar->cam_C1_h_err_avg * pVar->LOOP_DECPL_MTRX[3][0] + pVar->cam_C1_v_err_avg * pVar->LOOP_DECPL_MTRX[3][1] + pVar->cam_C2_h_err_avg * pVar->LOOP_DECPL_MTRX[3][2] + pVar->cam_C2_v_err_avg * pVar->LOOP_DECPL_MTRX[3][3]; # line 485 "../laserSteering2cam.st" seq_pvPut(ssId, 22/*motor_M1_h_adjustment*/, 0); # line 486 "../laserSteering2cam.st" seq_pvPut(ssId, 28/*motor_M1_v_adjustment*/, 0); # line 487 "../laserSteering2cam.st" seq_pvPut(ssId, 34/*motor_M2_h_adjustment*/, 0); # line 488 "../laserSteering2cam.st" seq_pvPut(ssId, 40/*motor_M2_v_adjustment*/, 0); # line 491 "../laserSteering2cam.st" pVar->loop_max_adj = 0.0; # line 492 "../laserSteering2cam.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 493 "../laserSteering2cam.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)); # line 494 "../laserSteering2cam.st" pVar->loop_max_adj = (((pVar->loop_max_adj) < (fabs(pVar->motor_M2_h_adjustment))) ? (fabs(pVar->motor_M2_h_adjustment)) : (pVar->loop_max_adj)); # line 495 "../laserSteering2cam.st" pVar->loop_max_adj = (((pVar->loop_max_adj) < (fabs(pVar->motor_M2_v_adjustment))) ? (fabs(pVar->motor_M2_v_adjustment)) : (pVar->loop_max_adj)); # line 497 "../laserSteering2cam.st" if (pVar->DEBUG) { # line 499 "../laserSteering2cam.st" printf("loop_calc_avg:\n"); # line 500 "../laserSteering2cam.st" printf(" average error: c1h = %lf, c1v = %lf, c2h = %lf, c2v = %lf\n", pVar->cam_C1_h_err_avg, pVar->cam_C1_v_err_avg, pVar->cam_C2_h_err_avg, pVar->cam_C2_v_err_avg); # line 501 "../laserSteering2cam.st" printf(" motor adj: motor_M1_h = %lf, motor_M1_v = %lf, motor_M2_h = %lf, motor_M2_v = %lf\n", pVar->motor_M1_h_adjustment, pVar->motor_M1_v_adjustment, pVar->motor_M2_h_adjustment, pVar->motor_M2_v_adjustment); } } return; } } /****** Code for state "loop_calc_dest" in state set "laser_stabilization_2cam" ******/ /* Delay function for state "loop_calc_dest" in state set "laser_stabilization_2cam" */ static void D_laser_stabilization_2cam_loop_calc_dest(SS_ID ssId, struct UserVar *pVar) { } /* Event function for state "loop_calc_dest" in state set "laser_stabilization_2cam" */ static seqBool E_laser_stabilization_2cam_loop_calc_dest(SS_ID ssId, struct UserVar *pVar, int *pTransNum, int *pNextState) { # line 513 "../laserSteering2cam.st" if (!pVar->loop_fdbk_enbl) { *pNextState = 1; *pTransNum = 0; return TRUE; } # line 520 "../laserSteering2cam.st" if (pVar->loop_fdbk_enbl && (pVar->loop_max_adj < pVar->loop_adj_min)) { *pNextState = 1; *pTransNum = 1; return TRUE; } # line 527 "../laserSteering2cam.st" if (pVar->loop_fdbk_enbl && (pVar->loop_max_adj > pVar->loop_adj_max)) { *pNextState = 1; *pTransNum = 2; return TRUE; } # line 536 "../laserSteering2cam.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_2cam" */ static void A_laser_stabilization_2cam_loop_calc_dest(SS_ID ssId, struct UserVar *pVar, int transNum, int *pNextState) { switch(transNum) { case 0: { # line 516 "../laserSteering2cam.st" pVar->feedback_status = 2; # line 517 "../laserSteering2cam.st" seq_pvPut(ssId, 20/*feedback_status*/, 0); } return; case 1: { # line 523 "../laserSteering2cam.st" pVar->feedback_status = 0; # line 524 "../laserSteering2cam.st" seq_pvPut(ssId, 20/*feedback_status*/, 0); } return; case 2: { # line 530 "../laserSteering2cam.st" pVar->feedback_status = 3; # line 531 "../laserSteering2cam.st" seq_pvPut(ssId, 20/*feedback_status*/, 0); # line 533 "../laserSteering2cam.st" pVar->var_internalReset = 1; } return; case 3: { # line 539 "../laserSteering2cam.st" pVar->motor_M1_h_calc_dest = pVar->var_loopInitPosition_motor_M1_h + pVar->motor_M1_h_adjustment; # line 540 "../laserSteering2cam.st" pVar->motor_M1_v_calc_dest = pVar->var_loopInitPosition_motor_M1_v + pVar->motor_M1_v_adjustment; # line 541 "../laserSteering2cam.st" pVar->motor_M2_h_calc_dest = pVar->var_loopInitPosition_motor_M2_h + pVar->motor_M2_h_adjustment; # line 542 "../laserSteering2cam.st" pVar->motor_M2_v_calc_dest = pVar->var_loopInitPosition_motor_M2_v + pVar->motor_M2_v_adjustment; # line 544 "../laserSteering2cam.st" pVar->dest_in_range = 1; # line 545 "../laserSteering2cam.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 545 "../laserSteering2cam.st" pVar->dest_in_range = 0; # line 546 "../laserSteering2cam.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 546 "../laserSteering2cam.st" pVar->dest_in_range = 0; # line 547 "../laserSteering2cam.st" if (pVar->motor_M2_h_calc_dest > pVar->motor_M2_h_dhlm || pVar->motor_M2_h_calc_dest < pVar->motor_M2_h_dllm) # line 547 "../laserSteering2cam.st" pVar->dest_in_range = 0; # line 548 "../laserSteering2cam.st" if (pVar->motor_M2_v_calc_dest > pVar->motor_M2_v_dhlm || pVar->motor_M2_v_calc_dest < pVar->motor_M2_v_dllm) # line 548 "../laserSteering2cam.st" pVar->dest_in_range = 0; # line 550 "../laserSteering2cam.st" if (pVar->DEBUG) # line 551 "../laserSteering2cam.st" printf("loop_calc_dest: new motor des: motor_M1_h = %lf, motor_M1_v = %lf, motor_M2_h = %lf, motor_M2_v = %lf\n", pVar->motor_M1_h_calc_dest, pVar->motor_M1_v_calc_dest, pVar->motor_M2_h_calc_dest, pVar->motor_M2_v_calc_dest); } return; } } /****** Code for state "loop_range_check" in state set "laser_stabilization_2cam" ******/ /* Delay function for state "loop_range_check" in state set "laser_stabilization_2cam" */ static void D_laser_stabilization_2cam_loop_range_check(SS_ID ssId, struct UserVar *pVar) { } /* Event function for state "loop_range_check" in state set "laser_stabilization_2cam" */ static seqBool E_laser_stabilization_2cam_loop_range_check(SS_ID ssId, struct UserVar *pVar, int *pTransNum, int *pNextState) { # line 560 "../laserSteering2cam.st" if (!pVar->dest_in_range) { *pNextState = 1; *pTransNum = 0; return TRUE; } # line 567 "../laserSteering2cam.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_2cam" */ static void A_laser_stabilization_2cam_loop_range_check(SS_ID ssId, struct UserVar *pVar, int transNum, int *pNextState) { switch(transNum) { case 0: { # line 563 "../laserSteering2cam.st" pVar->feedback_status = 4; # line 564 "../laserSteering2cam.st" seq_pvPut(ssId, 20/*feedback_status*/, 0); } return; case 1: { # line 569 "../laserSteering2cam.st" if (pVar->DEBUG) # line 569 "../laserSteering2cam.st" printf("motor_M1_h_calc_dest - in range\n"); } return; } } /****** Code for state "loop_adjust_motors" in state set "laser_stabilization_2cam" ******/ /* Entry function for state "loop_adjust_motors" in state set "laser_stabilization_2cam" */ static void I_laser_stabilization_2cam_loop_adjust_motors(SS_ID ssId, struct UserVar *pVar) { # line 580 "../laserSteering2cam.st" pVar->motor_M1_h_dest = pVar->motor_M1_h_calc_dest; # line 582 "../laserSteering2cam.st" pVar->motor_M1_v_dest = pVar->motor_M1_v_calc_dest; # line 584 "../laserSteering2cam.st" pVar->motor_M2_h_dest = pVar->motor_M2_h_calc_dest; # line 586 "../laserSteering2cam.st" pVar->motor_M2_v_dest = pVar->motor_M2_v_calc_dest; # line 589 "../laserSteering2cam.st" seq_pvPut(ssId, 23/*motor_M1_h_dest*/, 0); # line 590 "../laserSteering2cam.st" seq_pvPut(ssId, 29/*motor_M1_v_dest*/, 0); # line 591 "../laserSteering2cam.st" seq_pvPut(ssId, 35/*motor_M2_h_dest*/, 0); # line 592 "../laserSteering2cam.st" seq_pvPut(ssId, 41/*motor_M2_v_dest*/, 0); # line 595 "../laserSteering2cam.st" pVar->feedback_status = 5; # line 596 "../laserSteering2cam.st" seq_pvPut(ssId, 20/*feedback_status*/, 0); # line 598 "../laserSteering2cam.st" if (pVar->DEBUG) # line 599 "../laserSteering2cam.st" printf("loop_adjust_motors: final motor des: motor_M1_h = %lf, motor_M1_v = %lf, motor_M2_h = %lf, motor_M2_v = %lf\n", pVar->motor_M1_h_dest, pVar->motor_M1_v_dest, pVar->motor_M2_h_dest, pVar->motor_M2_v_dest); } /* Delay function for state "loop_adjust_motors" in state set "laser_stabilization_2cam" */ static void D_laser_stabilization_2cam_loop_adjust_motors(SS_ID ssId, struct UserVar *pVar) { # line 602 "../laserSteering2cam.st" seq_delayInit(ssId, 0, ((0.5))); } /* Event function for state "loop_adjust_motors" in state set "laser_stabilization_2cam" */ static seqBool E_laser_stabilization_2cam_loop_adjust_motors(SS_ID ssId, struct UserVar *pVar, int *pTransNum, int *pNextState) { # line 602 "../laserSteering2cam.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_2cam" */ static void A_laser_stabilization_2cam_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_2cam" ******/ /* Delay function for state "loop_wait_motors" in state set "laser_stabilization_2cam" */ static void D_laser_stabilization_2cam_loop_wait_motors(SS_ID ssId, struct UserVar *pVar) { # line 619 "../laserSteering2cam.st" seq_delayInit(ssId, 0, ((5.0))); } /* Event function for state "loop_wait_motors" in state set "laser_stabilization_2cam" */ static seqBool E_laser_stabilization_2cam_loop_wait_motors(SS_ID ssId, struct UserVar *pVar, int *pTransNum, int *pNextState) { # line 612 "../laserSteering2cam.st" if (!pVar->loop_fdbk_enbl) { *pNextState = 2; *pTransNum = 0; return TRUE; } # line 619 "../laserSteering2cam.st" if (seq_delay(ssId, 0) || ((!pVar->motor_M1_h_moving) && (!pVar->motor_M1_v_moving) && (!pVar->motor_M2_h_moving) && (!pVar->motor_M2_v_moving))) { *pNextState = 9; *pTransNum = 1; return TRUE; } return FALSE; } /* Action function for state "loop_wait_motors" in state set "laser_stabilization_2cam" */ static void A_laser_stabilization_2cam_loop_wait_motors(SS_ID ssId, struct UserVar *pVar, int transNum, int *pNextState) { switch(transNum) { case 0: { # line 615 "../laserSteering2cam.st" pVar->feedback_status = 2; # line 616 "../laserSteering2cam.st" seq_pvPut(ssId, 20/*feedback_status*/, 0); } return; case 1: { # line 621 "../laserSteering2cam.st" if (pVar->DEBUG) # line 621 "../laserSteering2cam.st" printf("loop_wait_motors - waiting\n"); } return; } } /****** Code for state "loop_check_position" in state set "laser_stabilization_2cam" ******/ /* Delay function for state "loop_check_position" in state set "laser_stabilization_2cam" */ static void D_laser_stabilization_2cam_loop_check_position(SS_ID ssId, struct UserVar *pVar) { } /* Event function for state "loop_check_position" in state set "laser_stabilization_2cam" */ static seqBool E_laser_stabilization_2cam_loop_check_position(SS_ID ssId, struct UserVar *pVar, int *pTransNum, int *pNextState) { # line 631 "../laserSteering2cam.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) || (fabs(pVar->motor_M2_h_pos - pVar->motor_M2_h_calc_dest) >= pVar->loop_adj_min) || (fabs(pVar->motor_M2_v_pos - pVar->motor_M2_v_calc_dest) >= pVar->loop_adj_min)) { *pNextState = 1; *pTransNum = 0; return TRUE; } # line 638 "../laserSteering2cam.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) && (fabs(pVar->motor_M2_h_pos - pVar->motor_M2_h_calc_dest) < pVar->loop_adj_min) && (fabs(pVar->motor_M2_v_pos - pVar->motor_M2_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_2cam" */ static void A_laser_stabilization_2cam_loop_check_position(SS_ID ssId, struct UserVar *pVar, int transNum, int *pNextState) { switch(transNum) { case 0: { # line 634 "../laserSteering2cam.st" if (pVar->DEBUG) # line 634 "../laserSteering2cam.st" printf("loop_check_position - position wrong\n"); } return; case 1: { # line 641 "../laserSteering2cam.st" if (pVar->loop_fdbk_enbl) { # line 643 "../laserSteering2cam.st" pVar->feedback_status = 0; # line 644 "../laserSteering2cam.st" seq_pvPut(ssId, 20/*feedback_status*/, 0); } } return; } } /************************ Tables ************************/ /* Channel table */ static seqChan G_channels[] = { /* chName, offset, varName, varType, count, eventNum, efId, monitored, queueSize, queueIndex */ {"{LOOP}:C1_H_ERR.B", offsetof(struct UserVar, cam_C1_h), "cam_C1_h", "double", 1, 1, 0, 0, 0, 0}, {"{LOOP}:C1_V_ERR.B", offsetof(struct UserVar, cam_C1_v), "cam_C1_v", "double", 1, 2, 0, 0, 0, 0}, {"{LOOP}:C2_H_ERR.B", offsetof(struct UserVar, cam_C2_h), "cam_C2_h", "double", 1, 3, 0, 0, 0, 0}, {"{LOOP}:C2_V_ERR.B", offsetof(struct UserVar, cam_C2_v), "cam_C2_v", "double", 1, 4, 0, 0, 0, 0}, {"{LOOP}:C1_H_REF", offsetof(struct UserVar, cam_C1_h_ref), "cam_C1_h_ref", "double", 1, 5, 0, 0, 0, 0}, {"{LOOP}:C1_V_REF", offsetof(struct UserVar, cam_C1_v_ref), "cam_C1_v_ref", "double", 1, 6, 0, 0, 0, 0}, {"{LOOP}:C2_V_REF", offsetof(struct UserVar, cam_C2_v_ref), "cam_C2_v_ref", "double", 1, 7, 0, 0, 0, 0}, {"{LOOP}:C2_H_REF", offsetof(struct UserVar, cam_C2_h_ref), "cam_C2_h_ref", "double", 1, 8, 0, 0, 0, 0}, {"{LOOP}:C1_H_ERR", offsetof(struct UserVar, cam_C1_h_err), "cam_C1_h_err", "double", 1, 9, 0, 0, 0, 0}, {"{LOOP}:C1_V_ERR", offsetof(struct UserVar, cam_C1_v_err), "cam_C1_v_err", "double", 1, 10, 0, 0, 0, 0}, {"{LOOP}:DARKIMG_1", offsetof(struct UserVar, cam_C1_dark_img), "cam_C1_dark_img", "double", 1, 11, 0, 1, 0, 0}, {"{LOOP}:STALEIMG_1", offsetof(struct UserVar, cam_C1_stale_img), "cam_C1_stale_img", "double", 1, 12, 0, 1, 0, 0}, {"{LOOP}:C2_H_ERR", offsetof(struct UserVar, cam_C2_h_err), "cam_C2_h_err", "double", 1, 13, 0, 0, 0, 0}, {"{LOOP}:C2_V_ERR", offsetof(struct UserVar, cam_C2_v_err), "cam_C2_v_err", "double", 1, 14, 0, 0, 0, 0}, {"{LOOP}:DARKIMG_2", offsetof(struct UserVar, cam_C2_dark_img), "cam_C2_dark_img", "double", 1, 15, 0, 1, 0, 0}, {"{LOOP}:STALEIMG_2", offsetof(struct UserVar, cam_C2_stale_img), "cam_C2_stale_img", "double", 1, 16, 0, 1, 0, 0}, {"{LOOP}:POS_FDBK", offsetof(struct UserVar, loop_fdbk_enbl), "loop_fdbk_enbl", "unsigned int", 1, 17, 0, 1, 0, 0}, {"{LOOP}:SET_REF", offsetof(struct UserVar, loop_set_ref), "loop_set_ref", "unsigned int", 1, 18, 0, 1, 0, 0}, {"{LOOP}:POS_FDBK_MIN", offsetof(struct UserVar, loop_adj_min), "loop_adj_min", "double", 1, 19, 0, 1, 0, 0}, {"{LOOP}:POS_FDBK_MAX", offsetof(struct UserVar, loop_adj_max), "loop_adj_max", "double", 1, 20, 0, 1, 0, 0}, {"{LOOP}:POS_FDBK_STS", offsetof(struct UserVar, feedback_status), "feedback_status", "unsigned short", 1, 21, 0, 0, 0, 0}, {"{LOOP}:POS_FDBK_AVGTIME", offsetof(struct UserVar, CHECK_TIMES), "CHECK_TIMES", "unsigned short", 1, 22, 0, 1, 0, 0}, {"{LOOP}:M1_H_ADJ", offsetof(struct UserVar, motor_M1_h_adjustment), "motor_M1_h_adjustment", "double", 1, 23, 0, 0, 0, 0}, {"{M1_H}.VAL", offsetof(struct UserVar, motor_M1_h_dest), "motor_M1_h_dest", "double", 1, 24, 0, 0, 0, 0}, {"{M1_H}.RBV", offsetof(struct UserVar, motor_M1_h_pos), "motor_M1_h_pos", "double", 1, 25, 0, 1, 0, 0}, {"{M1_H}.MOVN", offsetof(struct UserVar, motor_M1_h_moving), "motor_M1_h_moving", "unsigned int", 1, 26, 0, 1, 0, 0}, {"{M1_H}.DHLM", offsetof(struct UserVar, motor_M1_h_dhlm), "motor_M1_h_dhlm", "double", 1, 27, 0, 1, 0, 0}, {"{M1_H}.DLLM", offsetof(struct UserVar, motor_M1_h_dllm), "motor_M1_h_dllm", "double", 1, 28, 0, 1, 0, 0}, {"{LOOP}:M1_V_ADJ", offsetof(struct UserVar, motor_M1_v_adjustment), "motor_M1_v_adjustment", "double", 1, 29, 0, 0, 0, 0}, {"{M1_V}.VAL", offsetof(struct UserVar, motor_M1_v_dest), "motor_M1_v_dest", "double", 1, 30, 0, 0, 0, 0}, {"{M1_V}.RBV", offsetof(struct UserVar, motor_M1_v_pos), "motor_M1_v_pos", "double", 1, 31, 0, 1, 0, 0}, {"{M1_V}.MOVN", offsetof(struct UserVar, motor_M1_v_moving), "motor_M1_v_moving", "unsigned int", 1, 32, 0, 1, 0, 0}, {"{M1_V}.DHLM", offsetof(struct UserVar, motor_M1_v_dhlm), "motor_M1_v_dhlm", "double", 1, 33, 0, 1, 0, 0}, {"{M1_V}.DLLM", offsetof(struct UserVar, motor_M1_v_dllm), "motor_M1_v_dllm", "double", 1, 34, 0, 1, 0, 0}, {"{LOOP}:M2_H_ADJ", offsetof(struct UserVar, motor_M2_h_adjustment), "motor_M2_h_adjustment", "double", 1, 35, 0, 0, 0, 0}, {"{M2_H}.VAL", offsetof(struct UserVar, motor_M2_h_dest), "motor_M2_h_dest", "double", 1, 36, 0, 0, 0, 0}, {"{M2_H}.RBV", offsetof(struct UserVar, motor_M2_h_pos), "motor_M2_h_pos", "double", 1, 37, 0, 1, 0, 0}, {"{M2_H}.MOVN", offsetof(struct UserVar, motor_M2_h_moving), "motor_M2_h_moving", "unsigned int", 1, 38, 0, 1, 0, 0}, {"{M2_H}.DHLM", offsetof(struct UserVar, motor_M2_h_dhlm), "motor_M2_h_dhlm", "double", 1, 39, 0, 1, 0, 0}, {"{M2_H}.DLLM", offsetof(struct UserVar, motor_M2_h_dllm), "motor_M2_h_dllm", "double", 1, 40, 0, 1, 0, 0}, {"{LOOP}:M2_V_ADJ", offsetof(struct UserVar, motor_M2_v_adjustment), "motor_M2_v_adjustment", "double", 1, 41, 0, 0, 0, 0}, {"{M2_V}.VAL", offsetof(struct UserVar, motor_M2_v_dest), "motor_M2_v_dest", "double", 1, 42, 0, 0, 0, 0}, {"{M2_V}.RBV", offsetof(struct UserVar, motor_M2_v_pos), "motor_M2_v_pos", "double", 1, 43, 0, 1, 0, 0}, {"{M2_V}.MOVN", offsetof(struct UserVar, motor_M2_v_moving), "motor_M2_v_moving", "unsigned int", 1, 44, 0, 1, 0, 0}, {"{M2_V}.DHLM", offsetof(struct UserVar, motor_M2_v_dhlm), "motor_M2_v_dhlm", "double", 1, 45, 0, 1, 0, 0}, {"{M2_V}.DLLM", offsetof(struct UserVar, motor_M2_v_dllm), "motor_M2_v_dllm", "double", 1, 46, 0, 1, 0, 0}, {"{LOOP}:GAIN", offsetof(struct UserVar, var_loopGain), "var_loopGain", "double", 1, 47, 0, 1, 0, 0}, {"{LOOP}:DEADBAND_1", offsetof(struct UserVar, var_loopDeadband_C1), "var_loopDeadband_C1", "double", 1, 48, 0, 1, 0, 0}, {"{LOOP}:DEADBAND_2", offsetof(struct UserVar, var_loopDeadband_C2), "var_loopDeadband_C2", "double", 1, 49, 0, 1, 0, 0}, {"{LOOP}:RESET", offsetof(struct UserVar, var_loopReset), "var_loopReset", "unsigned int", 1, 50, 0, 1, 0, 0}, {"{LOOP}:DEBUG", offsetof(struct UserVar, DEBUG), "DEBUG", "unsigned int", 1, 51, 0, 1, 0, 0} }; /* Event masks for state set "laser_stabilization_2cam" */ static const seqMask EM_laser_stabilization_2cam_init[] = { 0x00000000, 0x00000000, }; static const seqMask EM_laser_stabilization_2cam_idle[] = { 0x00000000, 0x00000000, }; static const seqMask EM_laser_stabilization_2cam_loop_check_motor[] = { 0x04000000, 0x00001041, }; static const seqMask EM_laser_stabilization_2cam_loop_check_centroid[] = { 0x0001fe00, 0x00000000, }; static const seqMask EM_laser_stabilization_2cam_loop_calc_avg[] = { 0x00400000, 0x00000000, }; static const seqMask EM_laser_stabilization_2cam_loop_calc_dest[] = { 0x001a0000, 0x00000000, }; static const seqMask EM_laser_stabilization_2cam_loop_range_check[] = { 0x00000000, 0x00000000, }; static const seqMask EM_laser_stabilization_2cam_loop_adjust_motors[] = { 0x00000000, 0x00000000, }; static const seqMask EM_laser_stabilization_2cam_loop_wait_motors[] = { 0x04020000, 0x00001041, }; static const seqMask EM_laser_stabilization_2cam_loop_check_position[] = { 0x82080000, 0x00000820, }; /* State table for state set "laser_stabilization_2cam" */ static seqState G_laser_stabilization_2cam_states[] = { { /* state name */ "init", /* action function */ A_laser_stabilization_2cam_init, /* event function */ E_laser_stabilization_2cam_init, /* delay function */ D_laser_stabilization_2cam_init, /* entry function */ 0, /* exit function */ 0, /* event mask array */ EM_laser_stabilization_2cam_init, /* state options */ (0) }, { /* state name */ "idle", /* action function */ A_laser_stabilization_2cam_idle, /* event function */ E_laser_stabilization_2cam_idle, /* delay function */ D_laser_stabilization_2cam_idle, /* entry function */ I_laser_stabilization_2cam_idle, /* exit function */ 0, /* event mask array */ EM_laser_stabilization_2cam_idle, /* state options */ (0) }, { /* state name */ "loop_check_motor", /* action function */ A_laser_stabilization_2cam_loop_check_motor, /* event function */ E_laser_stabilization_2cam_loop_check_motor, /* delay function */ D_laser_stabilization_2cam_loop_check_motor, /* entry function */ 0, /* exit function */ 0, /* event mask array */ EM_laser_stabilization_2cam_loop_check_motor, /* state options */ (0) }, { /* state name */ "loop_check_centroid", /* action function */ A_laser_stabilization_2cam_loop_check_centroid, /* event function */ E_laser_stabilization_2cam_loop_check_centroid, /* delay function */ D_laser_stabilization_2cam_loop_check_centroid, /* entry function */ 0, /* exit function */ 0, /* event mask array */ EM_laser_stabilization_2cam_loop_check_centroid, /* state options */ (0) }, { /* state name */ "loop_calc_avg", /* action function */ A_laser_stabilization_2cam_loop_calc_avg, /* event function */ E_laser_stabilization_2cam_loop_calc_avg, /* delay function */ D_laser_stabilization_2cam_loop_calc_avg, /* entry function */ 0, /* exit function */ 0, /* event mask array */ EM_laser_stabilization_2cam_loop_calc_avg, /* state options */ (0) }, { /* state name */ "loop_calc_dest", /* action function */ A_laser_stabilization_2cam_loop_calc_dest, /* event function */ E_laser_stabilization_2cam_loop_calc_dest, /* delay function */ D_laser_stabilization_2cam_loop_calc_dest, /* entry function */ 0, /* exit function */ 0, /* event mask array */ EM_laser_stabilization_2cam_loop_calc_dest, /* state options */ (0) }, { /* state name */ "loop_range_check", /* action function */ A_laser_stabilization_2cam_loop_range_check, /* event function */ E_laser_stabilization_2cam_loop_range_check, /* delay function */ D_laser_stabilization_2cam_loop_range_check, /* entry function */ 0, /* exit function */ 0, /* event mask array */ EM_laser_stabilization_2cam_loop_range_check, /* state options */ (0) }, { /* state name */ "loop_adjust_motors", /* action function */ A_laser_stabilization_2cam_loop_adjust_motors, /* event function */ E_laser_stabilization_2cam_loop_adjust_motors, /* delay function */ D_laser_stabilization_2cam_loop_adjust_motors, /* entry function */ I_laser_stabilization_2cam_loop_adjust_motors, /* exit function */ 0, /* event mask array */ EM_laser_stabilization_2cam_loop_adjust_motors, /* state options */ (0) }, { /* state name */ "loop_wait_motors", /* action function */ A_laser_stabilization_2cam_loop_wait_motors, /* event function */ E_laser_stabilization_2cam_loop_wait_motors, /* delay function */ D_laser_stabilization_2cam_loop_wait_motors, /* entry function */ 0, /* exit function */ 0, /* event mask array */ EM_laser_stabilization_2cam_loop_wait_motors, /* state options */ (0) }, { /* state name */ "loop_check_position", /* action function */ A_laser_stabilization_2cam_loop_check_position, /* event function */ E_laser_stabilization_2cam_loop_check_position, /* delay function */ D_laser_stabilization_2cam_loop_check_position, /* entry function */ 0, /* exit function */ 0, /* event mask array */ EM_laser_stabilization_2cam_loop_check_position, /* state options */ (0) }, }; /* State set table */ static seqSS G_state_sets[] = { { /* state set name */ "laser_stabilization_2cam", /* states */ G_laser_stabilization_2cam_states, /* number of states */ 10, /* number of delays */ 1 }, }; /* Program table (global) */ seqProgram LaserSteering2cam = { /* magic number */ 2001006, /* program name */ "LaserSteering2cam", /* channels */ G_channels, /* num. channels */ 51, /* 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 LaserSteering2camRegistrar (void) { seqRegisterSequencerCommands(); seqRegisterSequencerProgram (&LaserSteering2cam); } epicsExportRegistrar(LaserSteering2camRegistrar);