/* SNC Version 2.0.11: Fri Oct 26 15:42:45 2007: ../sncPhaseControl.stt */ /* Event flags */ #define mon_flag 1 #define drive_flag 2 #define done_flag 3 #define kly_selector_flag 4 /* Program "RFPhaseControl" */ #include "seqCom.h" #define NUM_SS 4 #define NUM_CHANNELS 71 #define NUM_EVENTS 4 #define NUM_QUEUES 0 #define MAX_STRING_SIZE 40 #define ASYNC_OPT FALSE #define CONN_OPT TRUE #define DEBUG_OPT FALSE #define MAIN_OPT FALSE #define NEWEF_OPT TRUE #define REENT_OPT FALSE extern struct seqProgram RFPhaseControl; /* Variable declarations */ static double pvs[50]; static double s29PV; static double s30PV; static double klys1PV; static double klys2PV; static double data[50]; static double oldData[50]; static char chgFlag[50]; static unsigned int missing_counter; static unsigned int missing_counter_old; static unsigned int missing_rate; static unsigned int event_counter; static unsigned int event_counter_old; static unsigned int event_rate; static unsigned int execution_counter; static unsigned int execution_counter_old; static unsigned int execution_rate; static double pdes_ref; static double pdes_l2; static double phase24_1; static double phase24_2; static double phase_s29; static double phase_s30; static double poc_24_1; static double poc_24_2; static double poc_24_3; static double poc_tcav3_0; static double poc_tcav3_1; static double poc_s29; static double poc_s30; static unsigned int kly_selector; /* Not used (avoids compilation warnings) */ struct UserVar { int dummy; }; /* C code definitions */ # line 12 "../sncPhaseControl.stt" # line 13 "../sncPhaseControl.stt" #include # line 14 "../sncPhaseControl.stt" #include # line 15 "../sncPhaseControl.stt" #define TRUE 1 # line 16 "../sncPhaseControl.stt" #define FLASE 0 # line 17 "../sncPhaseControl.stt" #define M_PI 3.14159265358979323846 /* pi */ # line 18 "../sncPhaseControl.stt" #define DEBUG_ # line 19 "../sncPhaseControl.stt" #define DEBUG_MONPV # line 20 "../sncPhaseControl.stt" #define DEBUG_STATUS_ # line 21 "../sncPhaseControl.stt" #define PERFORM_FEEDBACK # line 21 "../sncPhaseControl.stt" # line 141 "../sncPhaseControl.stt" # line 142 "../sncPhaseControl.stt" # line 143 "../sncPhaseControl.stt" void initData(void) # line 144 "../sncPhaseControl.stt" { # line 145 "../sncPhaseControl.stt" int i; # line 146 "../sncPhaseControl.stt" for(i=0; i<50; i++) { # line 147 "../sncPhaseControl.stt" oldData[i] = 0.; # line 148 "../sncPhaseControl.stt" data[i] = 0.; # line 149 "../sncPhaseControl.stt" chgFlag[i] = 0; # line 150 "../sncPhaseControl.stt" } # line 151 "../sncPhaseControl.stt" missing_counter = 0; # line 152 "../sncPhaseControl.stt" missing_counter_old = 0; # line 153 "../sncPhaseControl.stt" missing_rate = 0; # line 154 "../sncPhaseControl.stt" event_counter = 0; # line 155 "../sncPhaseControl.stt" event_counter_old = 0; # line 156 "../sncPhaseControl.stt" event_rate =0; # line 157 "../sncPhaseControl.stt" execution_counter = 0; # line 158 "../sncPhaseControl.stt" execution_counter_old =0; # line 159 "../sncPhaseControl.stt" execution_rate = 0; # line 160 "../sncPhaseControl.stt" } # line 161 "../sncPhaseControl.stt" # line 162 "../sncPhaseControl.stt" void loadData(void) # line 163 "../sncPhaseControl.stt" { # line 164 "../sncPhaseControl.stt" int i; # line 165 "../sncPhaseControl.stt" # line 166 "../sncPhaseControl.stt" for(i=0;i<50;i++) { # line 167 "../sncPhaseControl.stt" oldData[i] = data[i]; # line 168 "../sncPhaseControl.stt" data[i] = pvs[i]; # line 169 "../sncPhaseControl.stt" if(oldData[i] != data[i]) chgFlag[i] = TRUE; # line 170 "../sncPhaseControl.stt" else chgFlag[i] = FALSE; # line 171 "../sncPhaseControl.stt" } # line 172 "../sncPhaseControl.stt" } # line 173 "../sncPhaseControl.stt" # line 174 "../sncPhaseControl.stt" void set_feedback_klystrons(double phase12, # line 175 "../sncPhaseControl.stt" double eGain, # line 176 "../sncPhaseControl.stt" double stationEnergy, # line 177 "../sncPhaseControl.stt" double *klys1Phase, # line 178 "../sncPhaseControl.stt" double *klys2Phase) # line 179 "../sncPhaseControl.stt" { # line 180 "../sncPhaseControl.stt" double ex, ph; # line 181 "../sncPhaseControl.stt" if(fabs(eGain) > 2.*stationEnergy) { # line 182 "../sncPhaseControl.stt" if(eGain>0.) eGain = 2.*stationEnergy; # line 183 "../sncPhaseControl.stt" else eGain = -2.*stationEnergy; # line 184 "../sncPhaseControl.stt" } # line 185 "../sncPhaseControl.stt" # line 186 "../sncPhaseControl.stt" ex = eGain/stationEnergy/2.; # line 187 "../sncPhaseControl.stt" ph = 180./M_PI * acos(ex); # line 188 "../sncPhaseControl.stt" # line 189 "../sncPhaseControl.stt" *klys1Phase = phase12 + ph; # line 190 "../sncPhaseControl.stt" *klys2Phase = phase12 - ph; # line 191 "../sncPhaseControl.stt" } # line 192 "../sncPhaseControl.stt" # line 193 "../sncPhaseControl.stt" void set_feedback_stations(double phase13, # line 194 "../sncPhaseControl.stt" double eGain, # line 195 "../sncPhaseControl.stt" double stationEnergy1, # line 196 "../sncPhaseControl.stt" double stationEnergy2, # line 197 "../sncPhaseControl.stt" double *s29Phase, # line 198 "../sncPhaseControl.stt" double *s30Phase) # line 199 "../sncPhaseControl.stt" { # line 200 "../sncPhaseControl.stt" double ex, ph; # line 201 "../sncPhaseControl.stt" if(fabs(eGain) > (stationEnergy1+stationEnergy2)) { # line 202 "../sncPhaseControl.stt" if(eGain>0.) eGain = stationEnergy1+stationEnergy2; # line 203 "../sncPhaseControl.stt" else eGain = -1.*(stationEnergy1+stationEnergy2); # line 204 "../sncPhaseControl.stt" } # line 205 "../sncPhaseControl.stt" # line 206 "../sncPhaseControl.stt" ex = eGain/(stationEnergy1+stationEnergy2); # line 207 "../sncPhaseControl.stt" ph = 180./M_PI * acos(ex); # line 208 "../sncPhaseControl.stt" # line 209 "../sncPhaseControl.stt" *s29Phase = phase13 - ph; # line 210 "../sncPhaseControl.stt" *s30Phase = phase13 + ph; # line 211 "../sncPhaseControl.stt" } # line 212 "../sncPhaseControl.stt" # line 212 "../sncPhaseControl.stt" /* Entry handler */ static void entry_handler(SS_ID ssId, struct UserVar *pVar) { } /* Code for state "monSelector" in state set "KlySelectControl" */ /* Delay function for state "monSelector" in state set "KlySelectControl" */ static void D_KlySelectControl_monSelector(SS_ID ssId, struct UserVar *pVar) { # line 219 "../sncPhaseControl.stt" # line 220 "../sncPhaseControl.stt" # line 221 "../sncPhaseControl.stt" } /* Event function for state "monSelector" in state set "KlySelectControl" */ static long E_KlySelectControl_monSelector(SS_ID ssId, struct UserVar *pVar, short *pTransNum, short *pNextState) { # line 219 "../sncPhaseControl.stt" if (kly_selector == 0) { *pNextState = 1; *pTransNum = 0; return TRUE; } # line 220 "../sncPhaseControl.stt" if (kly_selector == 1) { *pNextState = 2; *pTransNum = 1; return TRUE; } # line 221 "../sncPhaseControl.stt" if (kly_selector == 2) { *pNextState = 3; *pTransNum = 2; return TRUE; } return FALSE; } /* Action function for state "monSelector" in state set "KlySelectControl" */ static void A_KlySelectControl_monSelector(SS_ID ssId, struct UserVar *pVar, short transNum) { switch(transNum) { case 0: { } return; case 1: { } return; case 2: { } return; } } /* Code for state "selOneTwo" in state set "KlySelectControl" */ /* Entry function for state "selOneTwo" in state set "KlySelectControl" */ static void I_KlySelectControl_selOneTwo(SS_ID ssId, struct UserVar *pVar) { /* Entry 1: */ # line 227 "../sncPhaseControl.stt" seq_pvAssign(ssId, 0 /* pvs */ + (11), "ACCL:LI24:100:KLY_POC"); seq_pvMonitor(ssId, 0 /* pvs */ + (11)); # line 228 "../sncPhaseControl.stt" seq_pvAssign(ssId, 0 /* pvs */ + (12), "ACCL:LI24:200:KLY_POC"); seq_pvMonitor(ssId, 0 /* pvs */ + (12)); # line 229 "../sncPhaseControl.stt" seq_pvAssign(ssId, 0 /* pvs */ + (13), "ACCL:LI24:300:KLY_POC"); seq_pvMonitor(ssId, 0 /* pvs */ + (13)); # line 231 "../sncPhaseControl.stt" seq_pvAssign(ssId, 52 /* klys1PV */, "ACCL:LI24:100:KLY_PDES"); # line 232 "../sncPhaseControl.stt" seq_pvAssign(ssId, 53 /* klys2PV */, "ACCL:LI24:200:KLY_PDES"); } /* Delay function for state "selOneTwo" in state set "KlySelectControl" */ static void D_KlySelectControl_selOneTwo(SS_ID ssId, struct UserVar *pVar) { # line 236 "../sncPhaseControl.stt" } /* Event function for state "selOneTwo" in state set "KlySelectControl" */ static long E_KlySelectControl_selOneTwo(SS_ID ssId, struct UserVar *pVar, short *pTransNum, short *pNextState) { # line 236 "../sncPhaseControl.stt" if (seq_efTestAndClear(ssId, kly_selector_flag)) { *pNextState = 0; *pTransNum = 0; return TRUE; } return FALSE; } /* Action function for state "selOneTwo" in state set "KlySelectControl" */ static void A_KlySelectControl_selOneTwo(SS_ID ssId, struct UserVar *pVar, short transNum) { switch(transNum) { case 0: { } return; } } /* Code for state "selTwoThree" in state set "KlySelectControl" */ /* Entry function for state "selTwoThree" in state set "KlySelectControl" */ static void I_KlySelectControl_selTwoThree(SS_ID ssId, struct UserVar *pVar) { /* Entry 1: */ # line 242 "../sncPhaseControl.stt" seq_pvAssign(ssId, 0 /* pvs */ + (11), "ACCL:LI24:200:KLY_POC"); seq_pvMonitor(ssId, 0 /* pvs */ + (11)); # line 243 "../sncPhaseControl.stt" seq_pvAssign(ssId, 0 /* pvs */ + (12), "ACCL:LI24:300:KLY_POC"); seq_pvMonitor(ssId, 0 /* pvs */ + (12)); # line 244 "../sncPhaseControl.stt" seq_pvAssign(ssId, 0 /* pvs */ + (13), "ACCL:LI24:100:KLY_POC"); seq_pvMonitor(ssId, 0 /* pvs */ + (13)); # line 246 "../sncPhaseControl.stt" seq_pvAssign(ssId, 52 /* klys1PV */, "ACCL:LI24:200:KLY_PDES"); # line 247 "../sncPhaseControl.stt" seq_pvAssign(ssId, 53 /* klys2PV */, "ACCL:LI24:300:KLY_PDES"); } /* Delay function for state "selTwoThree" in state set "KlySelectControl" */ static void D_KlySelectControl_selTwoThree(SS_ID ssId, struct UserVar *pVar) { # line 251 "../sncPhaseControl.stt" } /* Event function for state "selTwoThree" in state set "KlySelectControl" */ static long E_KlySelectControl_selTwoThree(SS_ID ssId, struct UserVar *pVar, short *pTransNum, short *pNextState) { # line 251 "../sncPhaseControl.stt" if (seq_efTestAndClear(ssId, kly_selector_flag)) { *pNextState = 0; *pTransNum = 0; return TRUE; } return FALSE; } /* Action function for state "selTwoThree" in state set "KlySelectControl" */ static void A_KlySelectControl_selTwoThree(SS_ID ssId, struct UserVar *pVar, short transNum) { switch(transNum) { case 0: { } return; } } /* Code for state "selOneThree" in state set "KlySelectControl" */ /* Entry function for state "selOneThree" in state set "KlySelectControl" */ static void I_KlySelectControl_selOneThree(SS_ID ssId, struct UserVar *pVar) { /* Entry 1: */ # line 257 "../sncPhaseControl.stt" seq_pvAssign(ssId, 0 /* pvs */ + (11), "ACCL:LI24:100:KLY_POC"); seq_pvMonitor(ssId, 0 /* pvs */ + (11)); # line 258 "../sncPhaseControl.stt" seq_pvAssign(ssId, 0 /* pvs */ + (12), "ACCL:LI24:300:KLY_POC"); seq_pvMonitor(ssId, 0 /* pvs */ + (12)); # line 259 "../sncPhaseControl.stt" seq_pvAssign(ssId, 0 /* pvs */ + (13), "ACCL:LI24:200:KLY_POC"); seq_pvMonitor(ssId, 0 /* pvs */ + (13)); # line 261 "../sncPhaseControl.stt" seq_pvAssign(ssId, 52 /* klys1PV */, "ACCL:LI24:100:KLY_PDES"); # line 262 "../sncPhaseControl.stt" seq_pvAssign(ssId, 53 /* klys2PV */, "ACCL:LI24:300:KLY_PDES"); } /* Delay function for state "selOneThree" in state set "KlySelectControl" */ static void D_KlySelectControl_selOneThree(SS_ID ssId, struct UserVar *pVar) { # line 266 "../sncPhaseControl.stt" } /* Event function for state "selOneThree" in state set "KlySelectControl" */ static long E_KlySelectControl_selOneThree(SS_ID ssId, struct UserVar *pVar, short *pTransNum, short *pNextState) { # line 266 "../sncPhaseControl.stt" if (seq_efTestAndClear(ssId, kly_selector_flag)) { *pNextState = 0; *pTransNum = 0; return TRUE; } return FALSE; } /* Action function for state "selOneThree" in state set "KlySelectControl" */ static void A_KlySelectControl_selOneThree(SS_ID ssId, struct UserVar *pVar, short transNum) { switch(transNum) { case 0: { } return; } } /* Code for state "initMon" in state set "MonPhaseControl" */ /* Delay function for state "initMon" in state set "MonPhaseControl" */ static void D_MonPhaseControl_initMon(SS_ID ssId, struct UserVar *pVar) { # line 280 "../sncPhaseControl.stt" } /* Event function for state "initMon" in state set "MonPhaseControl" */ static long E_MonPhaseControl_initMon(SS_ID ssId, struct UserVar *pVar, short *pTransNum, short *pNextState) { # line 280 "../sncPhaseControl.stt" if (1) { *pNextState = 1; *pTransNum = 0; return TRUE; } return FALSE; } /* Action function for state "initMon" in state set "MonPhaseControl" */ static void A_MonPhaseControl_initMon(SS_ID ssId, struct UserVar *pVar, short transNum) { switch(transNum) { case 0: { # line 278 "../sncPhaseControl.stt" initData(); loadData(); loadData(); } return; } } /* Code for state "monPhaseControl" in state set "MonPhaseControl" */ /* Delay function for state "monPhaseControl" in state set "MonPhaseControl" */ static void D_MonPhaseControl_monPhaseControl(SS_ID ssId, struct UserVar *pVar) { # line 288 "../sncPhaseControl.stt" } /* Event function for state "monPhaseControl" in state set "MonPhaseControl" */ static long E_MonPhaseControl_monPhaseControl(SS_ID ssId, struct UserVar *pVar, short *pTransNum, short *pNextState) { # line 288 "../sncPhaseControl.stt" if (seq_efTestAndClear(ssId, mon_flag)) { *pNextState = 2; *pTransNum = 0; return TRUE; } return FALSE; } /* Action function for state "monPhaseControl" in state set "MonPhaseControl" */ static void A_MonPhaseControl_monPhaseControl(SS_ID ssId, struct UserVar *pVar, short transNum) { switch(transNum) { case 0: { # line 286 "../sncPhaseControl.stt" event_counter++; loadData(); # line 287 "../sncPhaseControl.stt" seq_efSet(ssId, drive_flag); } return; } } /* Code for state "waitMon" in state set "MonPhaseControl" */ /* Delay function for state "waitMon" in state set "MonPhaseControl" */ static void D_MonPhaseControl_waitMon(SS_ID ssId, struct UserVar *pVar) { # line 295 "../sncPhaseControl.stt" # line 300 "../sncPhaseControl.stt" } /* Event function for state "waitMon" in state set "MonPhaseControl" */ static long E_MonPhaseControl_waitMon(SS_ID ssId, struct UserVar *pVar, short *pTransNum, short *pNextState) { # line 295 "../sncPhaseControl.stt" if (seq_efTestAndClear(ssId, done_flag)) { *pNextState = 1; *pTransNum = 0; return TRUE; } # line 300 "../sncPhaseControl.stt" if (seq_efTestAndClear(ssId, mon_flag)) { *pNextState = 3; *pTransNum = 1; return TRUE; } return FALSE; } /* Action function for state "waitMon" in state set "MonPhaseControl" */ static void A_MonPhaseControl_waitMon(SS_ID ssId, struct UserVar *pVar, short transNum) { switch(transNum) { case 0: { # line 295 "../sncPhaseControl.stt" execution_counter ++; } return; case 1: { # line 299 "../sncPhaseControl.stt" event_counter ++; missing_counter ++; } return; } } /* Code for state "exceptionPhaseControl" in state set "MonPhaseControl" */ /* Delay function for state "exceptionPhaseControl" in state set "MonPhaseControl" */ static void D_MonPhaseControl_exceptionPhaseControl(SS_ID ssId, struct UserVar *pVar) { # line 310 "../sncPhaseControl.stt" } /* Event function for state "exceptionPhaseControl" in state set "MonPhaseControl" */ static long E_MonPhaseControl_exceptionPhaseControl(SS_ID ssId, struct UserVar *pVar, short *pTransNum, short *pNextState) { # line 310 "../sncPhaseControl.stt" if (1) { *pNextState = 2; *pTransNum = 0; return TRUE; } return FALSE; } /* Action function for state "exceptionPhaseControl" in state set "MonPhaseControl" */ static void A_MonPhaseControl_exceptionPhaseControl(SS_ID ssId, struct UserVar *pVar, short transNum) { switch(transNum) { case 0: { } return; } } /* Code for state "eventRate" in state set "EstEventRate" */ /* Delay function for state "eventRate" in state set "EstEventRate" */ static void D_EstEventRate_eventRate(SS_ID ssId, struct UserVar *pVar) { # line 348 "../sncPhaseControl.stt" seq_delayInit(ssId, 0, (1.)); } /* Event function for state "eventRate" in state set "EstEventRate" */ static long E_EstEventRate_eventRate(SS_ID ssId, struct UserVar *pVar, short *pTransNum, short *pNextState) { # line 348 "../sncPhaseControl.stt" if (seq_delay(ssId, 0)) { *pNextState = 0; *pTransNum = 0; return TRUE; } return FALSE; } /* Action function for state "eventRate" in state set "EstEventRate" */ static void A_EstEventRate_eventRate(SS_ID ssId, struct UserVar *pVar, short transNum) { switch(transNum) { case 0: { # line 320 "../sncPhaseControl.stt" event_rate = event_counter - event_counter_old; event_counter_old = event_counter; missing_rate = missing_counter - missing_counter_old; missing_counter_old = missing_counter; execution_rate = execution_counter - execution_counter_old; execution_counter_old = execution_counter; seq_pvPut(ssId, 55 /* event_rate */, 0); seq_pvPut(ssId, 54 /* missing_rate */, 0); seq_pvPut(ssId, 56 /* execution_rate */, 0); # line 331 "../sncPhaseControl.stt" #ifdef DEBUG_STATUS epicsPrintf("------------------------------------\n"); epicsPrintf("Feedback Event Rate: %ld\n", event_rate); epicsPrintf("Execution Rate: %ld\n", execution_rate); epicsPrintf("Event Missing Rate: %ld\n", missing_rate); epicsPrintf("------------------------------------\n\n"); #endif # line 339 "../sncPhaseControl.stt" { unsigned watchdog = data[0]; watchdog++; data[0] = (double) watchdog; pvs[0] = data[0]; # line 343 "../sncPhaseControl.stt" } seq_pvPut(ssId, 0 /* pvs */ + (0), 0); } return; } } /* Code for state "phaseControl" in state set "phasControl" */ /* Delay function for state "phaseControl" in state set "phasControl" */ static void D_phasControl_phaseControl(SS_ID ssId, struct UserVar *pVar) { # line 801 "../sncPhaseControl.stt" } /* Event function for state "phaseControl" in state set "phasControl" */ static long E_phasControl_phaseControl(SS_ID ssId, struct UserVar *pVar, short *pTransNum, short *pNextState) { # line 801 "../sncPhaseControl.stt" if (seq_efTestAndClear(ssId, drive_flag)) { *pNextState = 1; *pTransNum = 0; return TRUE; } return FALSE; } /* Action function for state "phaseControl" in state set "phasControl" */ static void A_phasControl_phaseControl(SS_ID ssId, struct UserVar *pVar, short transNum) { switch(transNum) { case 0: { # line 374 "../sncPhaseControl.stt" double result = 0.; double mdl_scale = -1./6.; double l2_scale = 1.; double tcav3_scale = 1.; double fb_station_scale = 1.; double S2930_station_scale = 1.; double injector_scale = 1.; double station_energy = 240.; double s21_2856_scale = -1; double requested_fb; double ph24_1_u; double ph24_2_u; double ph24_1; double ph24_2; # line 389 "../sncPhaseControl.stt" double change; double new_phase; double new_l2_phase; double new_tcav3_phase_in; double new_tcav3_phase_out; double s21HH; double s21H; double s21L; double s21LL; # line 399 "../sncPhaseControl.stt" double pchange; double ofchange; double fb_off[5]; # line 403 "../sncPhaseControl.stt" double S29_new; double S30_new; double requested_fb3; double S29_u; double S30_u; double S29; double S30; # line 411 "../sncPhaseControl.stt" int i; double newPhase[10]; # line 449 "../sncPhaseControl.stt" if (chgFlag[1] || chgFlag[2] || chgFlag[22] || chgFlag[23] || chgFlag[43]) { requested_fb = data[2] - data[22] * data[23]; if((int)data[1] && ~(int)data[43]) { set_feedback_klystrons(data[4], requested_fb, station_energy, &ph24_1_u, &ph24_2_u); ph24_1 = ph24_1_u * fb_station_scale; ph24_2 = ph24_2_u * fb_station_scale; /*-----------------------------------------*/ #ifdef PERFORM_FEEDBACK klys1PV = ph24_1; seq_pvPut(ssId, 52 /* klys1PV */, 0); klys2PV = ph24_2; seq_pvPut(ssId, 53 /* klys2PV */, 0); pvs[48] = ph24_1_u; seq_pvPut(ssId, 0 /* pvs */ + (48), 0); pvs[49] = ph24_2_u; seq_pvPut(ssId, 0 /* pvs */ + (49), 0); #endif #ifdef DEBUG_MONPV phase24_1 = ph24_1_u; phase24_2 = ph24_2_u; seq_pvPut(ssId, 59 /* phase24_1 */, 0); seq_pvPut(ssId, 60 /* phase24_2 */, 0); #endif #ifdef DEBUG seq_pvGet(ssId, 52 /* klys1PV */, 0); seq_pvGet(ssId, 53 /* klys2PV */, 0); epicsPrintf("-------------------\n"); epicsPrintf("L2 Amplitude Change\n"); epicsPrintf("-------------------\n"); epicsPrintf("ph24_1(klys1PV): %lf : %lf\n", ph24_1, klys1PV); epicsPrintf("ph24_2(klys2PV): %lf : %lf\n", ph24_2, klys2PV); epicsPrintf("ph24_1_u: %lf : %lf\n", ph24_1_u, pvs[48]); epicsPrintf("ph24_2_u: %lf : %lf\n", ph24_2_u, pvs[49]); epicsPrintf("-------------------\n\n"); #endif } } # line 501 "../sncPhaseControl.stt" if (chgFlag[3]) { change = -1. * (data[3] - oldData[3]); new_phase = data[9] - change * mdl_scale; new_l2_phase = data[10] + change *l2_scale; new_tcav3_phase_in = data[15] + change * tcav3_scale; new_tcav3_phase_out = data[16] + change * tcav3_scale; s21HH = data[17] + change * s21_2856_scale; s21H = data[18] + change * s21_2856_scale; s21L = data[19] + change * s21_2856_scale; s21LL = data[20] + change * s21_2856_scale; /* ----------------------------------------------- */ #ifdef PERFORM_FEEDBACK pvs[9] = new_phase; seq_pvPut(ssId, 0 /* pvs */ + (9), 0); pvs[10] = new_l2_phase; seq_pvPut(ssId, 0 /* pvs */ + (10), 0); pvs[15] = new_tcav3_phase_in; seq_pvPut(ssId, 0 /* pvs */ + (15), 0); pvs[16] = new_tcav3_phase_out; seq_pvPut(ssId, 0 /* pvs */ + (16), 0); pvs[17] = s21HH; seq_pvPut(ssId, 0 /* pvs */ + (17), 0); pvs[18] = s21H; seq_pvPut(ssId, 0 /* pvs */ + (18), 0); pvs[19] = s21L; seq_pvPut(ssId, 0 /* pvs */ + (19), 0); pvs[20] = s21LL; seq_pvPut(ssId, 0 /* pvs */ + (20), 0); #endif #ifdef DEBUG_MONPV pdes_ref = new_phase; pdes_l2 = new_l2_phase; poc_tcav3_0 = new_tcav3_phase_in; poc_tcav3_1 = new_tcav3_phase_out; seq_pvPut(ssId, 57 /* pdes_ref */, 0); seq_pvPut(ssId, 58 /* pdes_l2 */, 0); seq_pvPut(ssId, 66 /* poc_tcav3_0 */, 0); seq_pvPut(ssId, 67 /* poc_tcav3_1 */, 0); #endif #ifdef DEBUG epicsPrintf("---------------------------------------------------------------\n"); epicsPrintf("BC1 Phase Delay, move MDL and L2 phase shifter, fix tacv3 phase\n"); epicsPrintf("---------------------------------------------------------------\n"); epicsPrintf("new_phase: %lf : %lf\n", new_phase, pvs[9]); epicsPrintf("new_l2_phase: %lf : %lf\n", new_l2_phase, pvs[10]); epicsPrintf("new_tcav3_phase_in: %lf : %lf\n", new_tcav3_phase_in, pvs[15]); epicsPrintf("new_tcav3_phase_out: %lf : %lf\n", new_tcav3_phase_out, pvs[16]); epicsPrintf("s21HH: %lf : %lf\n", s21HH, pvs[17]); epicsPrintf("s21H: %lf : %lf\n", s21H, pvs[18]); epicsPrintf("s21L: %lf : %lf\n", s21L, pvs[19]); epicsPrintf("s21LL: %lf : %lf\n", s21LL, pvs[20]); epicsPrintf("---------------------------------------------------------------\n\n"); #endif } # line 614 "../sncPhaseControl.stt" if (chgFlag[4] || chgFlag[5]) { pchange = data[4] - oldData[4]; ofchange = data[5] - oldData[5]; change = pchange + ofchange; new_phase = data[10] + change * l2_scale; s21HH = data[17] + change * s21_2856_scale; s21H = data[18] + change * s21_2856_scale; s21L = data[19] + change * s21_2856_scale; s21LL = data[20] + change * s21_2856_scale; fb_off[1] = data[11] - change * fb_station_scale; fb_off[2] = data[12] - change * fb_station_scale; fb_off[3] = data[13] - change * fb_station_scale; if((pchange != 0.) && (int)data[1] && ~(int)data[43]) { requested_fb = data[2] - data[22] * data[23]; set_feedback_klystrons(data[4], requested_fb, station_energy, &ph24_1_u, &ph24_2_u); ph24_1 = ph24_1_u * fb_station_scale; ph24_2 = ph24_2_u * fb_station_scale; /* ---------------------------------------------- */ #ifdef PERFORM_FEEDBACK pvs[10] = new_phase; seq_pvPut(ssId, 0 /* pvs */ + (10), 0); pvs[11] = fb_off[1]; seq_pvPut(ssId, 0 /* pvs */ + (11), 0); pvs[12] = fb_off[2]; seq_pvPut(ssId, 0 /* pvs */ + (12), 0); pvs[13] = fb_off[3]; seq_pvPut(ssId, 0 /* pvs */ + (13), 0); pvs[17] = s21HH; seq_pvPut(ssId, 0 /* pvs */ + (17), 0); pvs[18] = s21H; seq_pvPut(ssId, 0 /* pvs */ + (18), 0); pvs[19] = s21L; seq_pvPut(ssId, 0 /* pvs */ + (19), 0); pvs[20] = s21LL; seq_pvPut(ssId, 0 /* pvs */ + (20), 0); klys1PV = ph24_1; seq_pvPut(ssId, 52 /* klys1PV */, 0); klys2PV = ph24_2; seq_pvPut(ssId, 53 /* klys2PV */, 0); pvs[48] = ph24_1_u; seq_pvPut(ssId, 0 /* pvs */ + (48), 0); pvs[49] = ph24_2_u; seq_pvPut(ssId, 0 /* pvs */ + (49), 0); #endif #ifdef DEBUG_MONPV pdes_l2 = new_phase; poc_24_1 = fb_off[1]; poc_24_2 = fb_off[2]; poc_24_3 = fb_off[3]; phase24_1 = ph24_1_u; phase24_2 = ph24_2_u; seq_pvPut(ssId, 58 /* pdes_l2 */, 0); seq_pvPut(ssId, 63 /* poc_24_1 */, 0); seq_pvPut(ssId, 64 /* poc_24_2 */, 0); seq_pvPut(ssId, 65 /* poc_24_3 */, 0); seq_pvPut(ssId, 59 /* phase24_1 */, 0); seq_pvPut(ssId, 60 /* phase24_2 */, 0); #endif #ifdef DEBUG seq_pvGet(ssId, 52 /* klys1PV */, 0); seq_pvGet(ssId, 53 /* klys2PV */, 0); epicsPrintf("-------------------------------\n"); epicsPrintf("L2 Phase or phase offset change\n"); epicsPrintf("-------------------------------\n"); epicsPrintf("new_phase: %lf : %lf\n", new_phase, pvs[10]); epicsPrintf("fb_off[1]: %lf : %lf\n", fb_off[1], pvs[11]); epicsPrintf("fb_off[2]: %lf : %lf\n", fb_off[2], pvs[12]); epicsPrintf("fb_off[3]: %lf : %lf\n", fb_off[3], pvs[13]); epicsPrintf("s21HH: %lf : %lf\n", s21HH, pvs[17]); epicsPrintf("s21H: %lf : %lf\n", s21H, pvs[18]); epicsPrintf("s21L: %lf : %lf\n", s21L, pvs[19]); epicsPrintf("s21LL: %lf : %lf\n", s21LL, pvs[20]); epicsPrintf("ph24_1: %lf : %lf\n", ph24_1, klys1PV); epicsPrintf("ph24_2: %lf : %lf\n", ph24_2, klys2PV); epicsPrintf("ph24_1_u: %lf : %lf\n", ph24_1_u, pvs[48]); epicsPrintf("ph24_2_u: %lf : %lf\n", ph24_2_u, pvs[49]); epicsPrintf("-------------------------------\n\n"); #endif } else { #ifdef PERFORM_FEEDBACK pvs[10] = new_phase; seq_pvPut(ssId, 0 /* pvs */ + (10), 0); pvs[11] = fb_off[1]; seq_pvPut(ssId, 0 /* pvs */ + (11), 0); pvs[12] = fb_off[2]; seq_pvPut(ssId, 0 /* pvs */ + (12), 0); pvs[13] = fb_off[3]; seq_pvPut(ssId, 0 /* pvs */ + (13), 0); pvs[17] = s21HH; seq_pvPut(ssId, 0 /* pvs */ + (17), 0); pvs[18] = s21H; seq_pvPut(ssId, 0 /* pvs */ + (18), 0); pvs[19] = s21L; seq_pvPut(ssId, 0 /* pvs */ + (19), 0); pvs[20] = s21LL; seq_pvPut(ssId, 0 /* pvs */ + (20), 0); #endif #ifdef DEBUG_MONPV pdes_l2 = new_phase; poc_24_1 = fb_off[1]; poc_24_2 = fb_off[2]; poc_24_3 = fb_off[3]; seq_pvPut(ssId, 58 /* pdes_l2 */, 0); seq_pvPut(ssId, 63 /* poc_24_1 */, 0); seq_pvPut(ssId, 64 /* poc_24_2 */, 0); seq_pvPut(ssId, 65 /* poc_24_3 */, 0); #endif #ifdef DEBUG epicsPrintf("-------------------------------\n"); epicsPrintf("L2 Phase or phase offset change\n"); epicsPrintf("-------------------------------\n"); epicsPrintf("new_phase: %lf : %lf\n", new_phase, pvs[10]); epicsPrintf("fb_off[1]: %lf : %lf\n", fb_off[1], pvs[11]); epicsPrintf("fb_off[2]: %lf : %lf\n", fb_off[2], pvs[12]); epicsPrintf("fb_off[3]: %lf : %lf\n", fb_off[3], pvs[13]); epicsPrintf("s21HH: %lf : %lf\n", s21HH, pvs[17]); epicsPrintf("s21H: %lf : %lf\n", s21H, pvs[18]); epicsPrintf("s21L: %lf : %lf\n", s21L, pvs[19]); epicsPrintf("s21LL: %lf : %lf\n", s21LL, pvs[20]); epicsPrintf("-------------------------------\n"); #endif } } # line 647 "../sncPhaseControl.stt" if (chgFlag[6]) { change = -1. * (data[6] - oldData[6]); new_phase = data[9] - change *mdl_scale; new_tcav3_phase_in = data[15] + change * tcav3_scale; new_tcav3_phase_out = data[16] + change * tcav3_scale; /* --------------------------------------------------- */ #ifdef PERFORM_FEEDBACK pvs[9] = new_phase; seq_pvPut(ssId, 0 /* pvs */ + (9), 0); pvs[15] = new_tcav3_phase_in; seq_pvPut(ssId, 0 /* pvs */ + (15), 0); pvs[16] = new_tcav3_phase_out; seq_pvPut(ssId, 0 /* pvs */ + (16), 0); #endif #ifdef DEBUG_MONPV pdes_l2 = new_phase; poc_tcav3_0 = new_tcav3_phase_in; poc_tcav3_1 = new_tcav3_phase_out; seq_pvPut(ssId, 58 /* pdes_l2 */, 0); seq_pvPut(ssId, 66 /* poc_tcav3_0 */, 0); seq_pvPut(ssId, 67 /* poc_tcav3_1 */, 0); #endif #ifdef DEBUG epicsPrintf("----------------------\n"); epicsPrintf("Change BC2 phase delay\n"); epicsPrintf("----------------------\n"); epicsPrintf("new_phase: %lf : %lf\n", new_phase, pvs[9]); epicsPrintf("new_tcav3_phase_in: %lf : %lf\n", new_tcav3_phase_in, pvs[15]); epicsPrintf("new_tcav3_phase_out: %lf : %lf\n", new_tcav3_phase_out, pvs[16]); epicsPrintf("----------------------\n\n"); #endif } # line 731 "../sncPhaseControl.stt" if (chgFlag[7] || chgFlag[8]) { pchange = data[7] - oldData[7]; ofchange = data[8] - oldData[8]; change = pchange + ofchange; new_phase = data[9] - change * mdl_scale; S29_new = data[39] - change * S2930_station_scale; S30_new = data[40] - change * S2930_station_scale; if((pchange != 0.) && (int)data[1] && ~(int)data[43]) { requested_fb3 = data[34] - data[35] * data[36]; set_feedback_stations(data[7], requested_fb3, data[37], data[38], &S29_u, &S30_u); S29 = S29_u * S2930_station_scale; S30 = S30_u * S2930_station_scale; /* ------------------------------------------- */ #ifdef PERFORM_FEEDBACK pvs[9] = new_phase; seq_pvPut(ssId, 0 /* pvs */ + (9), 0); pvs[39] = S29_new; seq_pvPut(ssId, 0 /* pvs */ + (39), 0); pvs[40] = S30_new; seq_pvPut(ssId, 0 /* pvs */ + (40), 0); s29PV = S29; seq_pvPut(ssId, 50 /* s29PV */, 0); s30PV = S30; seq_pvPut(ssId, 51 /* s30PV */, 0); pvs[46] = S29_u; seq_pvPut(ssId, 0 /* pvs */ + (46), 0); pvs[47] = S30_u; seq_pvPut(ssId, 0 /* pvs */ + (47), 0); #endif #ifdef DEBUG_MONPV pdes_l2 = new_phase; poc_s29 = S29_new; poc_s30 = S30_new; phase_s29 = S29_u; phase_s30 = S30_u; seq_pvPut(ssId, 58 /* pdes_l2 */, 0); seq_pvPut(ssId, 68 /* poc_s29 */, 0); seq_pvPut(ssId, 69 /* poc_s30 */, 0); seq_pvPut(ssId, 61 /* phase_s29 */, 0); seq_pvPut(ssId, 62 /* phase_s30 */, 0); #endif #ifdef DEBUG seq_pvGet(ssId, 50 /* s29PV */, 0); seq_pvGet(ssId, 51 /* s30PV */, 0); epicsPrintf("-------------------------\n"); epicsPrintf("L3 phase or offset change\n"); epicsPrintf("-------------------------\n"); epicsPrintf("new_phase: %lf : %lf\n", new_phase, pvs[9]); epicsPrintf("S29_new: %lf : %lf\n", S29_new, pvs[39]); epicsPrintf("S30_new: %lf : %lf\n", S30_new, pvs[40]); epicsPrintf("S29: %lf : %lf\n", S29, s29PV); epicsPrintf("S30: %lf : %lf\n", S30, s30PV); epicsPrintf("S29_u: %lf : %lf\n", S29_u, pvs[46]); epicsPrintf("S30_u: %lf : %lf\n", S30_u, pvs[47]); epicsPrintf("-------------------------\n\n"); #endif } else { #ifdef PERFORM_FEEDBACK pvs[9] = new_phase; seq_pvPut(ssId, 0 /* pvs */ + (9), 0); pvs[39] = S29_new; seq_pvPut(ssId, 0 /* pvs */ + (39), 0); pvs[40] = S30_new; seq_pvPut(ssId, 0 /* pvs */ + (40), 0); #endif #ifdef DEBUG_MONPV pdes_l2 = new_phase; phase_s29 = S29_new; phase_s30 = S30_new; seq_pvPut(ssId, 58 /* pdes_l2 */, 0); seq_pvPut(ssId, 61 /* phase_s29 */, 0); seq_pvPut(ssId, 62 /* phase_s30 */, 0); #endif #ifdef DEBUG epicsPrintf("-------------------------\n"); epicsPrintf("L3 phase or offset change\n"); epicsPrintf("-------------------------\n"); epicsPrintf("new_phase: %lf : %lf\n", new_phase, pvs[9]); epicsPrintf("S29_new: %lf : %lf\n", S29_new, pvs[39]); epicsPrintf("S30_new: %lf : %lf\n", S30_new, pvs[40]); epicsPrintf("-------------------------\n\n"); #endif } } # line 758 "../sncPhaseControl.stt" if (chgFlag[24]) { #ifdef DEUG epicsPrintf("---------------------------------\n"); epicsPrintf("Laser Heater chicain phase change\n"); epicsPrintf("---------------------------------\n"); #endif change = data[24] - oldData[24]; for(i=25; i<=33; i++) { newPhase[i-25] = data[i] + change * injector_scale; #ifdef PERFORM_FEEDBACK pvs[i] = newPhase[i - 25]; seq_pvPut(ssId, 0 /* pvs */ + (i), 0); #endif #ifdef DEBUG epicsPrintf("newPhase[%d]: %lf : %lf\n", i - 25, newPhase[i - 25], pvs[i]); #endif } #ifdef DEBUG epicsPrintf("---------------------------------\n\n"); #endif } # line 799 "../sncPhaseControl.stt" if (chgFlag[1] || chgFlag[34] || chgFlag[35] || chgFlag[36] || chgFlag[37] || chgFlag[38] || chgFlag[43]) { requested_fb3 = data[34] - data[35] * data[36]; set_feedback_stations(data[7], requested_fb3, data[37], data[38], &S29_u, &S30_u); S29 = S29_u * S2930_station_scale; S30 = S30_u * S2930_station_scale; /* ------------------------------------ */ #ifdef PERFORM_FEEDBACK s29PV = S29; seq_pvPut(ssId, 50 /* s29PV */, 0); s30PV = S30; seq_pvPut(ssId, 51 /* s30PV */, 0); pvs[46] = S29_u; seq_pvPut(ssId, 0 /* pvs */ + (46), 0); pvs[47] = S30_u; seq_pvPut(ssId, 0 /* pvs */ + (47), 0); #endif #ifdef DEBUG_MONPV phase_s29 = S29_u; phase_s30 = S30_u; seq_pvPut(ssId, 61 /* phase_s29 */, 0); seq_pvPut(ssId, 62 /* phase_s30 */, 0); #endif #ifdef DEBUG seq_pvGet(ssId, 50 /* s29PV */, 0); seq_pvGet(ssId, 51 /* s30PV */, 0); epicsPrintf("-------------------\n"); epicsPrintf("Change in L3 energy\n"); epicsPrintf("-------------------\n"); epicsPrintf("S29 : %lf : %lf\n", S29, s29PV); epicsPrintf("S30 : %lf : %lf\n", S30, s30PV); epicsPrintf("S29_u: %lf : %lf\n", S29_u, pvs[46]); epicsPrintf("S30_u: %lf : %lf\n", S30_u, pvs[47]); epicsPrintf("-------------------\n\n"); #endif } } return; } } /* Code for state "donePhaseControl" in state set "phasControl" */ /* Delay function for state "donePhaseControl" in state set "phasControl" */ static void D_phasControl_donePhaseControl(SS_ID ssId, struct UserVar *pVar) { # line 808 "../sncPhaseControl.stt" } /* Event function for state "donePhaseControl" in state set "phasControl" */ static long E_phasControl_donePhaseControl(SS_ID ssId, struct UserVar *pVar, short *pTransNum, short *pNextState) { # line 808 "../sncPhaseControl.stt" if (1) { *pNextState = 0; *pTransNum = 0; return TRUE; } return FALSE; } /* Action function for state "donePhaseControl" in state set "phasControl" */ static void A_phasControl_donePhaseControl(SS_ID ssId, struct UserVar *pVar, short transNum) { switch(transNum) { case 0: { # line 807 "../sncPhaseControl.stt" seq_efSet(ssId, done_flag); } return; } } /* Exit handler */ static void exit_handler(SS_ID ssId, struct UserVar *pVar) { } /************************ Tables ***********************/ /* Database Blocks */ static struct seqChan seqChan[NUM_CHANNELS] = { {"SIOC:SYS0:ML00:AO057", (void *)&pvs[0], "pvs[0]", "double", 1, 5, 1, 1, 0, 0, 0}, {"SIOC:SYS0:ML00:AO058", (void *)&pvs[1], "pvs[1]", "double", 1, 6, 1, 1, 0, 0, 0}, {"SIOC:SYS0:ML00:AO059", (void *)&pvs[2], "pvs[2]", "double", 1, 7, 1, 1, 0, 0, 0}, {"SIOC:SYS0:ML00:AO060", (void *)&pvs[3], "pvs[3]", "double", 1, 8, 1, 1, 0, 0, 0}, {"SIOC:SYS0:ML00:AO061", (void *)&pvs[4], "pvs[4]", "double", 1, 9, 1, 1, 0, 0, 0}, {"SIOC:SYS0:ML00:AO062", (void *)&pvs[5], "pvs[5]", "double", 1, 10, 1, 1, 0, 0, 0}, {"SIOC:SYS0:ML00:AO063", (void *)&pvs[6], "pvs[6]", "double", 1, 11, 1, 1, 0, 0, 0}, {"SIOC:SYS0:ML00:AO064", (void *)&pvs[7], "pvs[7]", "double", 1, 12, 1, 1, 0, 0, 0}, {"SIOC:SYS0:ML00:AO065", (void *)&pvs[8], "pvs[8]", "double", 1, 13, 1, 1, 0, 0, 0}, {"LLRF:IN20:RH:REF_2_PDES", (void *)&pvs[9], "pvs[9]", "double", 1, 14, 1, 1, 0, 0, 0}, {"LLRF:IN20:RH:L2_PDES", (void *)&pvs[10], "pvs[10]", "double", 1, 15, 1, 1, 0, 0, 0}, {"ACCL:LI24:100:KLY_POC", (void *)&pvs[11], "pvs[11]", "double", 1, 16, 1, 1, 0, 0, 0}, {"ACCL:LI24:300:KLY_POC", (void *)&pvs[12], "pvs[12]", "double", 1, 17, 1, 1, 0, 0, 0}, {"ACCL:LI24:200:KLY_POC", (void *)&pvs[13], "pvs[13]", "double", 1, 18, 1, 1, 0, 0, 0}, {"TCAV:LI24:800:TC3_PDES", (void *)&pvs[14], "pvs[14]", "double", 1, 19, 1, 1, 0, 0, 0}, {"TCAV:LI24:800:TC3_0_POC", (void *)&pvs[15], "pvs[15]", "double", 1, 20, 1, 1, 0, 0, 0}, {"TCAV:LI24:800:TC3_1_POC", (void *)&pvs[16], "pvs[16]", "double", 1, 21, 1, 1, 0, 0, 0}, {"LLRF:IN20:RH:REF_1_S_PA.HIHI", (void *)&pvs[17], "pvs[17]", "double", 1, 22, 1, 1, 0, 0, 0}, {"LLRF:IN20:RH:REF_1_S_PA.HIGH", (void *)&pvs[18], "pvs[18]", "double", 1, 23, 1, 1, 0, 0, 0}, {"LLRF:IN20:RH:REF_1_S_PA.LOW", (void *)&pvs[19], "pvs[19]", "double", 1, 24, 1, 1, 0, 0, 0}, {"LLRF:IN20:RH:REF_1_S_PA.LOLO", (void *)&pvs[20], "pvs[20]", "double", 1, 25, 1, 1, 0, 0, 0}, {"SIOC:SYS0:ML00:AO066", (void *)&pvs[21], "pvs[21]", "double", 1, 26, 1, 1, 0, 0, 0}, {"SIOC:SYS0:ML00:AO278", (void *)&pvs[22], "pvs[22]", "double", 1, 27, 1, 1, 0, 0, 0}, {"SIOC:SYS0:ML00:AO067", (void *)&pvs[23], "pvs[23]", "double", 1, 28, 1, 1, 0, 0, 0}, {"SIOC:SYS0:ML00:AO080", (void *)&pvs[24], "pvs[24]", "double", 1, 29, 1, 1, 0, 0, 0}, {"LASR:IN20:1:LSR_0_POC", (void *)&pvs[25], "pvs[25]", "double", 1, 30, 1, 1, 0, 0, 0}, {"GUN:IN20:1:GN1_0_POC", (void *)&pvs[26], "pvs[26]", "double", 1, 31, 1, 1, 0, 0, 0}, {"GUN:IN20:1:GN1_1_POC", (void *)&pvs[27], "pvs[27]", "double", 1, 32, 1, 1, 0, 0, 0}, {"GUN:IN20:1:GN1_2_POC", (void *)&pvs[28], "pvs[28]", "double", 1, 33, 1, 1, 0, 0, 0}, {"GUN:IN20:1:GN1_3_POC", (void *)&pvs[29], "pvs[29]", "double", 1, 34, 1, 1, 0, 0, 0}, {"ACCL:IN20:300:L0A_0_POC", (void *)&pvs[30], "pvs[30]", "double", 1, 35, 1, 1, 0, 0, 0}, {"ACCL:IN20:300:L0A_1_POC", (void *)&pvs[31], "pvs[31]", "double", 1, 36, 1, 1, 0, 0, 0}, {"ACCL:IN20:400:L0B_2_POC", (void *)&pvs[32], "pvs[32]", "double", 1, 37, 1, 1, 0, 0, 0}, {"ACCL:IN20:400:L0B_3_POC", (void *)&pvs[33], "pvs[33]", "double", 1, 38, 1, 1, 0, 0, 0}, {"SIOC:SYS0:ML00:AO075", (void *)&pvs[34], "pvs[34]", "double", 1, 39, 1, 1, 0, 0, 0}, {"SIOC:SYS0:ML00:AO079", (void *)&pvs[35], "pvs[35]", "double", 1, 40, 1, 1, 0, 0, 0}, {"SIOC:SYS0:ML00:AO279", (void *)&pvs[36], "pvs[36]", "double", 1, 41, 1, 1, 0, 0, 0}, {"SIOC:SYS0:ML00:AO280", (void *)&pvs[37], "pvs[37]", "double", 1, 42, 1, 1, 0, 0, 0}, {"SIOC:SYS0:ML00:AO281", (void *)&pvs[38], "pvs[38]", "double", 1, 43, 1, 1, 0, 0, 0}, {"ACCL:LI29:0:KLY_POC", (void *)&pvs[39], "pvs[39]", "double", 1, 44, 1, 1, 0, 0, 0}, {"ACCL:LI30:0:KLY_POC", (void *)&pvs[40], "pvs[40]", "double", 1, 45, 1, 1, 0, 0, 0}, {"ACCL:LI29:0:KLY_PDES", (void *)&pvs[41], "pvs[41]", "double", 1, 46, 1, 1, 0, 0, 0}, {"ACCL:LI30:0:KLY_PDES", (void *)&pvs[42], "pvs[42]", "double", 1, 47, 1, 1, 0, 0, 0}, {"SIOC:SYS0:ML00:AO017", (void *)&pvs[43], "pvs[43]", "double", 1, 48, 1, 1, 0, 0, 0}, {"SIOC:SYS0:ML00:AO092", (void *)&pvs[44], "pvs[44]", "double", 1, 49, 1, 1, 0, 0, 0}, {"SIOC:SYS0:ML00:AO093", (void *)&pvs[45], "pvs[45]", "double", 1, 50, 1, 1, 0, 0, 0}, {"SIOC:SYS0:ML00:AO094", (void *)&pvs[46], "pvs[46]", "double", 1, 51, 1, 1, 0, 0, 0}, {"SIOC:SYS0:ML00:AO095", (void *)&pvs[47], "pvs[47]", "double", 1, 52, 1, 1, 0, 0, 0}, {"SIOC:SYS0:ML00:AO096", (void *)&pvs[48], "pvs[48]", "double", 1, 53, 1, 1, 0, 0, 0}, {"SIOC:SYS0:ML00:AO097", (void *)&pvs[49], "pvs[49]", "double", 1, 54, 1, 1, 0, 0, 0}, {"ACCL:LI29:0:KLY_PDES", (void *)&s29PV, "s29PV", "double", 1, 55, 0, 0, 0, 0, 0}, {"ACCL:LI30:0:KLY_PDES", (void *)&s30PV, "s30PV", "double", 1, 56, 0, 0, 0, 0, 0}, {"ACCL:LI24:100:KLY_PDES", (void *)&klys1PV, "klys1PV", "double", 1, 57, 0, 0, 0, 0, 0}, {"ACCL:LI24:300:KLY_PDES", (void *)&klys2PV, "klys2PV", "double", 1, 58, 0, 0, 0, 0, 0}, {"{IOC}:MISSING_RATE", (void *)&missing_rate, "missing_rate", "unsigned int", 1, 59, 0, 0, 0, 0, 0}, {"{IOC}:EVENT_RATE", (void *)&event_rate, "event_rate", "unsigned int", 1, 60, 0, 0, 0, 0, 0}, {"{IOC}:EXECUTION_RATE", (void *)&execution_rate, "execution_rate", "unsigned int", 1, 61, 0, 0, 0, 0, 0}, {"{IOC}:PDES:REF", (void *)&pdes_ref, "pdes_ref", "double", 1, 62, 0, 0, 0, 0, 0}, {"{IOC}:PDES:L2", (void *)&pdes_l2, "pdes_l2", "double", 1, 63, 0, 0, 0, 0, 0}, {"{IOC}:PHASE:24_1", (void *)&phase24_1, "phase24_1", "double", 1, 64, 0, 0, 0, 0, 0}, {"{IOC}:PHASE:24_2", (void *)&phase24_2, "phase24_2", "double", 1, 65, 0, 0, 0, 0, 0}, {"{IOC}:PHASE:S29", (void *)&phase_s29, "phase_s29", "double", 1, 66, 0, 0, 0, 0, 0}, {"{IOC}:PHASE:S30", (void *)&phase_s30, "phase_s30", "double", 1, 67, 0, 0, 0, 0, 0}, {"{IOC}:POC:24_1", (void *)&poc_24_1, "poc_24_1", "double", 1, 68, 0, 0, 0, 0, 0}, {"{IOC}:POC:24_2", (void *)&poc_24_2, "poc_24_2", "double", 1, 69, 0, 0, 0, 0, 0}, {"{IOC}:POC:24_3", (void *)&poc_24_3, "poc_24_3", "double", 1, 70, 0, 0, 0, 0, 0}, {"{IOC}:POC:TCAV3_0", (void *)&poc_tcav3_0, "poc_tcav3_0", "double", 1, 71, 0, 0, 0, 0, 0}, {"{IOC}:POC:TCAV3_1", (void *)&poc_tcav3_1, "poc_tcav3_1", "double", 1, 72, 0, 0, 0, 0, 0}, {"{IOC}:POC:S29", (void *)&poc_s29, "poc_s29", "double", 1, 73, 0, 0, 0, 0, 0}, {"{IOC}:POC:S30", (void *)&poc_s30, "poc_s30", "double", 1, 74, 0, 0, 0, 0, 0}, {"{IOC}:KLY_SELECTOR", (void *)&kly_selector, "kly_selector", "unsigned int", 1, 75, 4, 1, 0, 0, 0}, }; /* Event masks for state set KlySelectControl */ /* Event mask for state monSelector: */ static bitMask EM_KlySelectControl_monSelector[] = { 0x00000000, 0x00000000, 0x00000800, }; /* Event mask for state selOneTwo: */ static bitMask EM_KlySelectControl_selOneTwo[] = { 0x00000010, 0x00000000, 0x00000000, }; /* Event mask for state selTwoThree: */ static bitMask EM_KlySelectControl_selTwoThree[] = { 0x00000010, 0x00000000, 0x00000000, }; /* Event mask for state selOneThree: */ static bitMask EM_KlySelectControl_selOneThree[] = { 0x00000010, 0x00000000, 0x00000000, }; /* State Blocks */ static struct seqState state_KlySelectControl[] = { /* State "monSelector" */ { /* state name */ "monSelector", /* action function */ (ACTION_FUNC) A_KlySelectControl_monSelector, /* event function */ (EVENT_FUNC) E_KlySelectControl_monSelector, /* delay function */ (DELAY_FUNC) D_KlySelectControl_monSelector, /* entry function */ (ENTRY_FUNC) 0, /* exit function */ (EXIT_FUNC) 0, /* event mask array */ EM_KlySelectControl_monSelector, /* state options */ (0)}, /* State "selOneTwo" */ { /* state name */ "selOneTwo", /* action function */ (ACTION_FUNC) A_KlySelectControl_selOneTwo, /* event function */ (EVENT_FUNC) E_KlySelectControl_selOneTwo, /* delay function */ (DELAY_FUNC) D_KlySelectControl_selOneTwo, /* entry function */ (ENTRY_FUNC) I_KlySelectControl_selOneTwo, /* exit function */ (EXIT_FUNC) 0, /* event mask array */ EM_KlySelectControl_selOneTwo, /* state options */ (0)}, /* State "selTwoThree" */ { /* state name */ "selTwoThree", /* action function */ (ACTION_FUNC) A_KlySelectControl_selTwoThree, /* event function */ (EVENT_FUNC) E_KlySelectControl_selTwoThree, /* delay function */ (DELAY_FUNC) D_KlySelectControl_selTwoThree, /* entry function */ (ENTRY_FUNC) I_KlySelectControl_selTwoThree, /* exit function */ (EXIT_FUNC) 0, /* event mask array */ EM_KlySelectControl_selTwoThree, /* state options */ (0)}, /* State "selOneThree" */ { /* state name */ "selOneThree", /* action function */ (ACTION_FUNC) A_KlySelectControl_selOneThree, /* event function */ (EVENT_FUNC) E_KlySelectControl_selOneThree, /* delay function */ (DELAY_FUNC) D_KlySelectControl_selOneThree, /* entry function */ (ENTRY_FUNC) I_KlySelectControl_selOneThree, /* exit function */ (EXIT_FUNC) 0, /* event mask array */ EM_KlySelectControl_selOneThree, /* state options */ (0)}, }; /* Event masks for state set MonPhaseControl */ /* Event mask for state initMon: */ static bitMask EM_MonPhaseControl_initMon[] = { 0x00000000, 0x00000000, 0x00000000, }; /* Event mask for state monPhaseControl: */ static bitMask EM_MonPhaseControl_monPhaseControl[] = { 0x00000002, 0x00000000, 0x00000000, }; /* Event mask for state waitMon: */ static bitMask EM_MonPhaseControl_waitMon[] = { 0x0000000a, 0x00000000, 0x00000000, }; /* Event mask for state exceptionPhaseControl: */ static bitMask EM_MonPhaseControl_exceptionPhaseControl[] = { 0x00000000, 0x00000000, 0x00000000, }; /* State Blocks */ static struct seqState state_MonPhaseControl[] = { /* State "initMon" */ { /* state name */ "initMon", /* action function */ (ACTION_FUNC) A_MonPhaseControl_initMon, /* event function */ (EVENT_FUNC) E_MonPhaseControl_initMon, /* delay function */ (DELAY_FUNC) D_MonPhaseControl_initMon, /* entry function */ (ENTRY_FUNC) 0, /* exit function */ (EXIT_FUNC) 0, /* event mask array */ EM_MonPhaseControl_initMon, /* state options */ (0)}, /* State "monPhaseControl" */ { /* state name */ "monPhaseControl", /* action function */ (ACTION_FUNC) A_MonPhaseControl_monPhaseControl, /* event function */ (EVENT_FUNC) E_MonPhaseControl_monPhaseControl, /* delay function */ (DELAY_FUNC) D_MonPhaseControl_monPhaseControl, /* entry function */ (ENTRY_FUNC) 0, /* exit function */ (EXIT_FUNC) 0, /* event mask array */ EM_MonPhaseControl_monPhaseControl, /* state options */ (0)}, /* State "waitMon" */ { /* state name */ "waitMon", /* action function */ (ACTION_FUNC) A_MonPhaseControl_waitMon, /* event function */ (EVENT_FUNC) E_MonPhaseControl_waitMon, /* delay function */ (DELAY_FUNC) D_MonPhaseControl_waitMon, /* entry function */ (ENTRY_FUNC) 0, /* exit function */ (EXIT_FUNC) 0, /* event mask array */ EM_MonPhaseControl_waitMon, /* state options */ (0)}, /* State "exceptionPhaseControl" */ { /* state name */ "exceptionPhaseControl", /* action function */ (ACTION_FUNC) A_MonPhaseControl_exceptionPhaseControl, /* event function */ (EVENT_FUNC) E_MonPhaseControl_exceptionPhaseControl, /* delay function */ (DELAY_FUNC) D_MonPhaseControl_exceptionPhaseControl, /* entry function */ (ENTRY_FUNC) 0, /* exit function */ (EXIT_FUNC) 0, /* event mask array */ EM_MonPhaseControl_exceptionPhaseControl, /* state options */ (0)}, }; /* Event masks for state set EstEventRate */ /* Event mask for state eventRate: */ static bitMask EM_EstEventRate_eventRate[] = { 0x00000000, 0x00000000, 0x00000000, }; /* State Blocks */ static struct seqState state_EstEventRate[] = { /* State "eventRate" */ { /* state name */ "eventRate", /* action function */ (ACTION_FUNC) A_EstEventRate_eventRate, /* event function */ (EVENT_FUNC) E_EstEventRate_eventRate, /* delay function */ (DELAY_FUNC) D_EstEventRate_eventRate, /* entry function */ (ENTRY_FUNC) 0, /* exit function */ (EXIT_FUNC) 0, /* event mask array */ EM_EstEventRate_eventRate, /* state options */ (0)}, }; /* Event masks for state set phasControl */ /* Event mask for state phaseControl: */ static bitMask EM_phasControl_phaseControl[] = { 0x00000004, 0x00000000, 0x00000000, }; /* Event mask for state donePhaseControl: */ static bitMask EM_phasControl_donePhaseControl[] = { 0x00000000, 0x00000000, 0x00000000, }; /* State Blocks */ static struct seqState state_phasControl[] = { /* State "phaseControl" */ { /* state name */ "phaseControl", /* action function */ (ACTION_FUNC) A_phasControl_phaseControl, /* event function */ (EVENT_FUNC) E_phasControl_phaseControl, /* delay function */ (DELAY_FUNC) D_phasControl_phaseControl, /* entry function */ (ENTRY_FUNC) 0, /* exit function */ (EXIT_FUNC) 0, /* event mask array */ EM_phasControl_phaseControl, /* state options */ (0)}, /* State "donePhaseControl" */ { /* state name */ "donePhaseControl", /* action function */ (ACTION_FUNC) A_phasControl_donePhaseControl, /* event function */ (EVENT_FUNC) E_phasControl_donePhaseControl, /* delay function */ (DELAY_FUNC) D_phasControl_donePhaseControl, /* entry function */ (ENTRY_FUNC) 0, /* exit function */ (EXIT_FUNC) 0, /* event mask array */ EM_phasControl_donePhaseControl, /* state options */ (0)}, }; /* State Set Blocks */ static struct seqSS seqSS[NUM_SS] = { /* State set "KlySelectControl" */ { /* ss name */ "KlySelectControl", /* ptr to state block */ state_KlySelectControl, /* number of states */ 4, /* error state */ -1}, /* State set "MonPhaseControl" */ { /* ss name */ "MonPhaseControl", /* ptr to state block */ state_MonPhaseControl, /* number of states */ 4, /* error state */ -1}, /* State set "EstEventRate" */ { /* ss name */ "EstEventRate", /* ptr to state block */ state_EstEventRate, /* number of states */ 1, /* error state */ -1}, /* State set "phasControl" */ { /* ss name */ "phasControl", /* ptr to state block */ state_phasControl, /* number of states */ 2, /* error state */ -1}, }; /* Program parameter list */ static char prog_param[] = ""; /* State Program table (global) */ struct seqProgram RFPhaseControl = { /* magic number */ 20000315, /* *name */ "RFPhaseControl", /* *pChannels */ seqChan, /* numChans */ NUM_CHANNELS, /* *pSS */ seqSS, /* numSS */ NUM_SS, /* user variable size */ 0, /* *pParams */ prog_param, /* numEvents */ NUM_EVENTS, /* encoded options */ (0 | OPT_CONN | OPT_NEWEF), /* entry handler */ (ENTRY_FUNC) entry_handler, /* exit handler */ (EXIT_FUNC) exit_handler, /* numQueues */ NUM_QUEUES, }; /* Register sequencer commands and program */ void RFPhaseControlRegistrar (void) { seqRegisterSequencerCommands(); seqRegisterSequencerProgram (&RFPhaseControl); } epicsExportRegistrar(RFPhaseControlRegistrar);