/* Generated with snc from psControl.i */ /* Program "psControl" */ #include #include #include #include #include "epicsTypes.h" #include "seqCom.h" /* Variable declarations */ struct UserVar { # line 37 "../psControl.h" double wait_delay_sofar; # line 40 "../psControl.h" double wait_delay; # line 44 "../psControl.h" int control_setpt; # line 48 "../psControl.h" int norampoff; # line 52 "../psControl.h" int ps_on; # line 56 "../psControl.h" int ps_on_des; # line 59 "../psControl.h" int ps_ramp; # line 63 "../psControl.h" int ps_status; # line 66 "../psControl.h" double ps_curr_setpt; # line 72 "../psControl.h" double ps_curr_des; # line 78 "../psControl.h" int ps_limits_flag; # line 81 "../psControl.h" int ps_didt_select; # line 70 "../psControl.st" int standardize; # line 74 "../psControl.st" int cycle_count; # line 77 "../psControl.st" int max_cycle_count; # line 81 "../psControl.st" double ps_curr_drvh; # line 85 "../psControl.st" double ps_curr_drvl; # line 89 "../psControl.st" double ps_curr_min; # line 93 "../psControl.st" double ps_curr_res; # line 99 "../psControl.st" double ps_didt; # line 103 "../psControl.st" double ps_rampdelay; # line 109 "../psControl.st" char *ps_c; # line 110 "../psControl.st" char *macro_c; # line 111 "../psControl.st" int use_drv; # line 112 "../psControl.st" int use_min; # line 113 "../psControl.st" int pos_pol; # line 114 "../psControl.st" int setpt_change; # line 115 "../psControl.st" int zero_current; # line 116 "../psControl.st" int des_current; # line 117 "../psControl.st" int ramp_current; # line 118 "../psControl.st" int wait_needed; # line 119 "../psControl.st" int ramp_timeout; # line 120 "../psControl.st" int change_count; # line 121 "../psControl.st" int standardizing; # line 122 "../psControl.st" int ramping; # line 123 "../psControl.st" double wait_delay_increment; # line 124 "../psControl.st" double wait_delay_total; # line 125 "../psControl.st" double sw_ramp_delay; # line 126 "../psControl.st" double ps_curr_setpt_new; # line 127 "../psControl.st" double ps_curr_setpt_prev; }; /* C code definitions */ # line 58 "../psControl.st" #include # line 59 "../psControl.st" #include /* 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, }; *pVar = pVarInit; } /****** Code for state "psControl_init" in state set "psControl" ******/ /* Delay function for state "psControl_init" in state set "psControl" */ static void D_psControl_psControl_init(SS_ID ssId, struct UserVar *pVar) { } /* Event function for state "psControl_init" in state set "psControl" */ static seqBool E_psControl_psControl_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 "psControl_init" in state set "psControl" */ static void A_psControl_psControl_init(SS_ID ssId, struct UserVar *pVar, int transNum, int *pNextState) { switch(transNum) { case 0: { # line 138 "../psControl.st" pVar->ps_c = seq_macValueGet(ssId, "ps"); # line 139 "../psControl.st" pVar->macro_c = seq_macValueGet(ssId, "limit"); # line 140 "../psControl.st" pVar->pos_pol = 1; # line 141 "../psControl.st" if (pVar->macro_c && (strncmp(pVar->macro_c, "DRV", 3))) { # line 142 "../psControl.st" pVar->use_drv = 0; } else { # line 144 "../psControl.st" pVar->use_drv = 1; # line 145 "../psControl.st" if (pVar->macro_c && (strncmp(pVar->macro_c, "DRVH", 4))) # line 146 "../psControl.st" pVar->pos_pol = 0; } # line 148 "../psControl.st" pVar->macro_c = seq_macValueGet(ssId, "turnonmin"); # line 149 "../psControl.st" if (pVar->macro_c && (strcmp(pVar->macro_c, "0"))) # line 149 "../psControl.st" pVar->use_min = 1; else # line 150 "../psControl.st" pVar->use_min = 0; # line 151 "../psControl.st" pVar->ps_status = 10; # line 152 "../psControl.st" seq_pvPut(ssId, 7/*ps_status*/, 0); # line 153 "../psControl.st" pVar->cycle_count = 0; # line 154 "../psControl.st" seq_pvPut(ssId, 13/*cycle_count*/, 0); # line 155 "../psControl.st" pVar->wait_delay_sofar = 0; # line 156 "../psControl.st" seq_pvPut(ssId, 0/*wait_delay_sofar*/, 0); # line 157 "../psControl.st" pVar->standardize = 0; # line 158 "../psControl.st" seq_pvPut(ssId, 12/*standardize*/, 0); # line 159 "../psControl.st" pVar->norampoff = 1; # line 160 "../psControl.st" seq_pvPut(ssId, 3/*norampoff*/, 0); # line 161 "../psControl.st" pVar->control_setpt = 0; # line 162 "../psControl.st" seq_pvPut(ssId, 2/*control_setpt*/, 0); # line 163 "../psControl.st" seq_efClear(ssId, 1/*ps_curr_setpt_ef*/); # line 164 "../psControl.st" seq_efClear(ssId, 3/*ps_curr_res_ef*/); # line 165 "../psControl.st" pVar->ps_limits_flag = 0; # line 166 "../psControl.st" seq_pvPut(ssId, 10/*ps_limits_flag*/, 0); # line 167 "../psControl.st" pVar->ps_curr_setpt_prev = pVar->ps_curr_setpt; } return; } } /****** Code for state "psControl_request" in state set "psControl" ******/ /* Entry function for state "psControl_request" in state set "psControl" */ static void I_psControl_psControl_request(SS_ID ssId, struct UserVar *pVar) { # line 178 "../psControl.st" pVar->setpt_change = 0; # line 179 "../psControl.st" pVar->ramping = 0; # line 180 "../psControl.st" pVar->standardizing = 0; # line 181 "../psControl.st" pVar->cycle_count = 0; # line 182 "../psControl.st" pVar->change_count = 0; # line 183 "../psControl.st" pVar->wait_needed = 0; # line 184 "../psControl.st" pVar->ramp_timeout = 0; # line 185 "../psControl.st" pVar->zero_current = 0; # line 186 "../psControl.st" pVar->des_current = 0; # line 187 "../psControl.st" pVar->ramp_current = 0; } /* Delay function for state "psControl_request" in state set "psControl" */ static void D_psControl_psControl_request(SS_ID ssId, struct UserVar *pVar) { } /* Event function for state "psControl_request" in state set "psControl" */ static seqBool E_psControl_psControl_request(SS_ID ssId, struct UserVar *pVar, int *pTransNum, int *pNextState) { # line 192 "../psControl.st" if ((!pVar->ps_on) && (pVar->control_setpt == 2)) { *pNextState = 2; *pTransNum = 0; return TRUE; } # line 207 "../psControl.st" if ((!pVar->ps_on) && ((!pVar->norampoff) || pVar->standardize || seq_efTest(ssId, 1/*ps_curr_setpt_ef*/) || seq_efTest(ssId, 3/*ps_curr_res_ef*/) || ((pVar->control_setpt != 2) && (pVar->control_setpt != 0)))) { *pNextState = 1; *pTransNum = 1; return TRUE; } # line 234 "../psControl.st" if ((pVar->control_setpt < 0) || (pVar->control_setpt > 7)) { *pNextState = 1; *pTransNum = 2; return TRUE; } # line 241 "../psControl.st" if ((!pVar->norampoff) || pVar->standardize || (pVar->control_setpt != 0) || seq_efTest(ssId, 3/*ps_curr_res_ef*/)) { *pNextState = 4; *pTransNum = 3; return TRUE; } # line 286 "../psControl.st" if (seq_efTest(ssId, 1/*ps_curr_setpt_ef*/)) { *pNextState = 7; *pTransNum = 4; return TRUE; } return FALSE; } /* Action function for state "psControl_request" in state set "psControl" */ static void A_psControl_psControl_request(SS_ID ssId, struct UserVar *pVar, int transNum, int *pNextState) { switch(transNum) { case 0: { # line 194 "../psControl.st" epicsPrintf("Ramp on started for %s\n", pVar->ps_c); # line 195 "../psControl.st" seq_pvPut(ssId, 13/*cycle_count*/, 0); # line 196 "../psControl.st" pVar->ps_status = 2; # line 197 "../psControl.st" seq_pvPut(ssId, 7/*ps_status*/, 0); # line 198 "../psControl.st" if (pVar->use_min) # line 198 "../psControl.st" pVar->ps_curr_setpt = pVar->ps_curr_min; else # line 199 "../psControl.st" pVar->ps_curr_setpt = 0.0; # line 200 "../psControl.st" seq_pvPut(ssId, 8/*ps_curr_setpt*/, 0); # line 201 "../psControl.st" pVar->ps_curr_setpt_prev = pVar->ps_curr_setpt; } return; case 1: { # line 213 "../psControl.st" if ((pVar->control_setpt == 5) || (pVar->control_setpt == 1)) { # line 215 "../psControl.st" pVar->ps_curr_setpt = 0.0; # line 216 "../psControl.st" seq_pvPut(ssId, 8/*ps_curr_setpt*/, 0); } # line 218 "../psControl.st" pVar->ps_status = 10; # line 219 "../psControl.st" seq_pvPut(ssId, 7/*ps_status*/, 0); # line 220 "../psControl.st" pVar->norampoff = 1; # line 221 "../psControl.st" seq_pvPut(ssId, 3/*norampoff*/, 0); # line 222 "../psControl.st" pVar->standardize = 0; # line 223 "../psControl.st" seq_pvPut(ssId, 12/*standardize*/, 0); # line 224 "../psControl.st" pVar->control_setpt = 0; # line 225 "../psControl.st" seq_pvPut(ssId, 2/*control_setpt*/, 0); # line 226 "../psControl.st" seq_efClear(ssId, 1/*ps_curr_setpt_ef*/); # line 227 "../psControl.st" seq_efClear(ssId, 3/*ps_curr_res_ef*/); # line 228 "../psControl.st" pVar->ps_curr_setpt_prev = 0.0; } return; case 2: { # line 235 "../psControl.st" pVar->control_setpt = 0; # line 236 "../psControl.st" seq_pvPut(ssId, 2/*control_setpt*/, 0); } return; case 3: { # line 244 "../psControl.st" pVar->ps_limits_flag = 1; # line 245 "../psControl.st" seq_pvPut(ssId, 10/*ps_limits_flag*/, 0); # line 246 "../psControl.st" pVar->ps_curr_setpt_prev = pVar->ps_curr_setpt; # line 247 "../psControl.st" if ((pVar->control_setpt == 4) || pVar->standardize) { # line 248 "../psControl.st" pVar->ps_didt_select = 0; # line 249 "../psControl.st" seq_pvPut(ssId, 11/*ps_didt_select*/, 0); # line 250 "../psControl.st" pVar->zero_current = 1; # line 251 "../psControl.st" pVar->standardize = 1; # line 252 "../psControl.st" seq_pvPut(ssId, 12/*standardize*/, 0); # line 253 "../psControl.st" pVar->control_setpt = 4; # line 254 "../psControl.st" seq_pvPut(ssId, 2/*control_setpt*/, 0); # line 255 "../psControl.st" pVar->standardizing = 1; # line 256 "../psControl.st" epicsPrintf("Standardize started for %s\n", pVar->ps_c); } else # line 258 "../psControl.st" if ((!pVar->norampoff) || (pVar->control_setpt == 1)) { # line 259 "../psControl.st" pVar->ps_didt_select = 0; # line 260 "../psControl.st" seq_pvPut(ssId, 11/*ps_didt_select*/, 0); # line 261 "../psControl.st" pVar->norampoff = 0; # line 262 "../psControl.st" seq_pvPut(ssId, 3/*norampoff*/, 0); # line 263 "../psControl.st" pVar->control_setpt = 1; # line 264 "../psControl.st" seq_pvPut(ssId, 2/*control_setpt*/, 0); # line 265 "../psControl.st" pVar->ramping = 1; # line 266 "../psControl.st" epicsPrintf("Ramp off started for %s\n", pVar->ps_c); } else # line 267 "../psControl.st" if (seq_efTest(ssId, 3/*ps_curr_res_ef*/)) { # line 268 "../psControl.st" seq_efClear(ssId, 3/*ps_curr_res_ef*/); # line 269 "../psControl.st" pVar->control_setpt = 7; # line 270 "../psControl.st" seq_pvPut(ssId, 2/*control_setpt*/, 0); # line 271 "../psControl.st" pVar->ramping = 1; } else # line 272 "../psControl.st" if (pVar->control_setpt == 7) { # line 273 "../psControl.st" seq_pvGet(ssId, 18/*ps_curr_res*/, 0); # line 274 "../psControl.st" pVar->ramping = 1; } else { # line 276 "../psControl.st" pVar->ramping = 1; } # line 278 "../psControl.st" seq_pvPut(ssId, 13/*cycle_count*/, 0); # line 279 "../psControl.st" if (pVar->ps_rampdelay >= 0) { # line 280 "../psControl.st" pVar->ps_ramp = 0; # line 281 "../psControl.st" seq_pvPut(ssId, 6/*ps_ramp*/, 0); } } return; case 4: { # line 288 "../psControl.st" seq_efClear(ssId, 1/*ps_curr_setpt_ef*/); # line 289 "../psControl.st" pVar->setpt_change = 1; # line 290 "../psControl.st" pVar->wait_needed = 1; # line 291 "../psControl.st" pVar->cycle_count = pVar->max_cycle_count + 1; # line 292 "../psControl.st" pVar->ps_limits_flag = 1; # line 293 "../psControl.st" seq_pvPut(ssId, 10/*ps_limits_flag*/, 0); # line 294 "../psControl.st" if (pVar->ps_rampdelay >= 0) { # line 295 "../psControl.st" pVar->ps_ramp = 1; # line 296 "../psControl.st" seq_pvPut(ssId, 6/*ps_ramp*/, 0); # line 297 "../psControl.st" pVar->sw_ramp_delay = 0; } else # line 298 "../psControl.st" if (pVar->ps_curr_setpt != pVar->ps_curr_setpt_prev) { # line 299 "../psControl.st" pVar->sw_ramp_delay = 5.0; } else { # line 301 "../psControl.st" pVar->sw_ramp_delay = 0; } } return; } } /****** Code for state "psControl_on_wait" in state set "psControl" ******/ /* Entry function for state "psControl_on_wait" in state set "psControl" */ static void I_psControl_psControl_on_wait(SS_ID ssId, struct UserVar *pVar) { # line 312 "../psControl.st" pVar->ps_on_des = 1; # line 313 "../psControl.st" seq_pvPut(ssId, 5/*ps_on_des*/, 0); } /* Delay function for state "psControl_on_wait" in state set "psControl" */ static void D_psControl_psControl_on_wait(SS_ID ssId, struct UserVar *pVar) { # line 319 "../psControl.st" seq_delayInit(ssId, 0, (5)); } /* Event function for state "psControl_on_wait" in state set "psControl" */ static seqBool E_psControl_psControl_on_wait(SS_ID ssId, struct UserVar *pVar, int *pTransNum, int *pNextState) { # line 315 "../psControl.st" if (pVar->control_setpt != 2) { *pNextState = 1; *pTransNum = 0; return TRUE; } # line 319 "../psControl.st" if (seq_delay(ssId, 0)) { *pNextState = 3; *pTransNum = 1; return TRUE; } return FALSE; } /* Action function for state "psControl_on_wait" in state set "psControl" */ static void A_psControl_psControl_on_wait(SS_ID ssId, struct UserVar *pVar, int transNum, int *pNextState) { switch(transNum) { case 0: { } return; case 1: { } return; } } /****** Code for state "psControl_on_check" in state set "psControl" ******/ /* Delay function for state "psControl_on_check" in state set "psControl" */ static void D_psControl_psControl_on_check(SS_ID ssId, struct UserVar *pVar) { } /* Event function for state "psControl_on_check" in state set "psControl" */ static seqBool E_psControl_psControl_on_check(SS_ID ssId, struct UserVar *pVar, int *pTransNum, int *pNextState) { # line 329 "../psControl.st" if (pVar->ps_on) { *pNextState = 1; *pTransNum = 0; return TRUE; } # line 335 "../psControl.st" if (pVar->cycle_count > 2) { *pNextState = 1; *pTransNum = 1; return TRUE; } if (TRUE) { *pNextState = 2; *pTransNum = 2; return TRUE; } return FALSE; } /* Action function for state "psControl_on_check" in state set "psControl" */ static void A_psControl_psControl_on_check(SS_ID ssId, struct UserVar *pVar, int transNum, int *pNextState) { switch(transNum) { case 0: { # line 331 "../psControl.st" epicsPrintf("PS on - setting to des for %s\n", pVar->ps_c); } return; case 1: { # line 337 "../psControl.st" epicsPrintf("Supply off - Ramp on aborted for %s\n", pVar->ps_c); # line 338 "../psControl.st" pVar->ps_status = 4; # line 339 "../psControl.st" seq_pvPut(ssId, 7/*ps_status*/, 0); # line 340 "../psControl.st" pVar->control_setpt = 0; # line 341 "../psControl.st" seq_pvPut(ssId, 2/*control_setpt*/, 0); } return; case 2: { # line 347 "../psControl.st" pVar->cycle_count++; # line 348 "../psControl.st" seq_pvPut(ssId, 13/*cycle_count*/, 0); } return; } } /****** Code for state "psControl_ramp_wait" in state set "psControl" ******/ /* Entry function for state "psControl_ramp_wait" in state set "psControl" */ static void I_psControl_psControl_ramp_wait(SS_ID ssId, struct UserVar *pVar) { # line 359 "../psControl.st" if (pVar->ps_ramp && (!pVar->setpt_change)) { # line 360 "../psControl.st" pVar->ps_status = 1; # line 361 "../psControl.st" seq_pvPut(ssId, 7/*ps_status*/, 0); } # line 367 "../psControl.st" if ((pVar->ps_rampdelay >= 0) && pVar->ps_ramp) { # line 368 "../psControl.st" if ((pVar->ps_rampdelay >= 0.02) && (!pVar->setpt_change) && (pVar->ps_curr_setpt_new != pVar->ps_curr_setpt)) { # line 370 "../psControl.st" pVar->sw_ramp_delay = 0; } else { # line 376 "../psControl.st" if (pVar->ps_didt > 0) { # line 378 "../psControl.st" pVar->sw_ramp_delay = (pVar->ps_curr_setpt - pVar->ps_curr_setpt_prev) / pVar->ps_didt; # line 379 "../psControl.st" if (pVar->sw_ramp_delay < 0.0) # line 379 "../psControl.st" pVar->sw_ramp_delay *= -1; } else { # line 381 "../psControl.st" pVar->sw_ramp_delay = pVar->ps_rampdelay; } } } else { # line 385 "../psControl.st" pVar->sw_ramp_delay = 30.0; } } /* Delay function for state "psControl_ramp_wait" in state set "psControl" */ static void D_psControl_psControl_ramp_wait(SS_ID ssId, struct UserVar *pVar) { # line 396 "../psControl.st" seq_delayInit(ssId, 0, (pVar->sw_ramp_delay)); # line 423 "../psControl.st" seq_delayInit(ssId, 1, (30.0)); } /* Event function for state "psControl_ramp_wait" in state set "psControl" */ static seqBool E_psControl_psControl_ramp_wait(SS_ID ssId, struct UserVar *pVar, int *pTransNum, int *pNextState) { # line 388 "../psControl.st" if (!pVar->ps_on) { *pNextState = 8; *pTransNum = 0; return TRUE; } # line 392 "../psControl.st" if (!pVar->ps_ramp) { *pNextState = 5; *pTransNum = 1; return TRUE; } # line 396 "../psControl.st" if ((pVar->ps_rampdelay >= 0) && seq_delay(ssId, 0)) { *pNextState = 4; *pTransNum = 2; return TRUE; } # line 423 "../psControl.st" if (seq_delay(ssId, 1)) { *pNextState = 8; *pTransNum = 3; return TRUE; } return FALSE; } /* Action function for state "psControl_ramp_wait" in state set "psControl" */ static void A_psControl_psControl_ramp_wait(SS_ID ssId, struct UserVar *pVar, int transNum, int *pNextState) { switch(transNum) { case 0: { } return; case 1: { } return; case 2: { # line 402 "../psControl.st" if ((!pVar->setpt_change) && (pVar->ps_rampdelay >= 0.02) && (pVar->ps_curr_setpt != pVar->ps_curr_setpt_new)) { # line 404 "../psControl.st" pVar->sw_ramp_delay = pVar->ps_rampdelay; # line 405 "../psControl.st" if (pVar->ps_didt <= 0) { # line 406 "../psControl.st" pVar->ps_curr_setpt = pVar->ps_curr_setpt_new; } else # line 407 "../psControl.st" if (pVar->ps_curr_setpt_new > pVar->ps_curr_setpt) { # line 408 "../psControl.st" pVar->ps_curr_setpt += pVar->ps_didt * pVar->ps_rampdelay; # line 409 "../psControl.st" if (pVar->ps_curr_setpt >= pVar->ps_curr_setpt_new) # line 410 "../psControl.st" pVar->ps_curr_setpt = pVar->ps_curr_setpt_new; } else { # line 412 "../psControl.st" pVar->ps_curr_setpt -= pVar->ps_didt * pVar->ps_rampdelay; # line 413 "../psControl.st" if (pVar->ps_curr_setpt <= pVar->ps_curr_setpt_new) # line 414 "../psControl.st" pVar->ps_curr_setpt = pVar->ps_curr_setpt_new; } # line 416 "../psControl.st" seq_pvPut(ssId, 8/*ps_curr_setpt*/, 0); } else { # line 418 "../psControl.st" pVar->ps_ramp = 0; # line 419 "../psControl.st" seq_pvPut(ssId, 6/*ps_ramp*/, 0); } } return; case 3: { # line 425 "../psControl.st" pVar->ramp_timeout = 1; # line 426 "../psControl.st" seq_efClear(ssId, 1/*ps_curr_setpt_ef*/); } return; } } /****** Code for state "psControl_wait" in state set "psControl" ******/ /* Entry function for state "psControl_wait" in state set "psControl" */ static void I_psControl_psControl_wait(SS_ID ssId, struct UserVar *pVar) { # line 439 "../psControl.st" pVar->wait_delay_increment = 1.0; # line 440 "../psControl.st" pVar->wait_delay_sofar = 0; # line 441 "../psControl.st" seq_pvPut(ssId, 0/*wait_delay_sofar*/, 0); # line 442 "../psControl.st" pVar->wait_delay_total = pVar->wait_delay; # line 443 "../psControl.st" seq_efClear(ssId, 1/*ps_curr_setpt_ef*/); } /* Delay function for state "psControl_wait" in state set "psControl" */ static void D_psControl_psControl_wait(SS_ID ssId, struct UserVar *pVar) { # line 469 "../psControl.st" seq_delayInit(ssId, 0, (pVar->wait_delay_increment)); } /* Event function for state "psControl_wait" in state set "psControl" */ static seqBool E_psControl_psControl_wait(SS_ID ssId, struct UserVar *pVar, int *pTransNum, int *pNextState) { # line 449 "../psControl.st" if ((!pVar->ps_on) || (pVar->standardizing && ((!pVar->standardize) || (!pVar->norampoff) || (pVar->control_setpt != 4))) || (pVar->setpt_change && (pVar->standardize || (!pVar->norampoff) || (pVar->control_setpt != 0))) || ((pVar->cycle_count > pVar->max_cycle_count) && ((pVar->wait_delay_sofar >= pVar->wait_delay_total) || (pVar->control_setpt == 1)))) { *pNextState = 8; *pTransNum = 0; return TRUE; } # line 456 "../psControl.st" if (pVar->ps_ramp) { *pNextState = 4; *pTransNum = 1; return TRUE; } # line 464 "../psControl.st" if ((!pVar->wait_needed) || ((pVar->cycle_count <= pVar->max_cycle_count) && (pVar->wait_delay_sofar >= pVar->wait_delay))) { *pNextState = 6; *pTransNum = 2; return TRUE; } # line 469 "../psControl.st" if (seq_delay(ssId, 0)) { *pNextState = 5; *pTransNum = 3; return TRUE; } return FALSE; } /* Action function for state "psControl_wait" in state set "psControl" */ static void A_psControl_psControl_wait(SS_ID ssId, struct UserVar *pVar, int transNum, int *pNextState) { switch(transNum) { case 0: { } return; case 1: { # line 458 "../psControl.st" if (pVar->ps_rampdelay >= 0) { # line 459 "../psControl.st" pVar->ps_ramp = 0; # line 460 "../psControl.st" seq_pvPut(ssId, 6/*ps_ramp*/, 0); } } return; case 2: { } return; case 3: { # line 471 "../psControl.st" if (!pVar->setpt_change) { # line 472 "../psControl.st" pVar->ps_status = 2; # line 473 "../psControl.st" seq_pvPut(ssId, 7/*ps_status*/, 0); } # line 475 "../psControl.st" pVar->wait_delay_sofar += pVar->wait_delay_increment; # line 476 "../psControl.st" seq_pvPut(ssId, 0/*wait_delay_sofar*/, 0); # line 477 "../psControl.st" pVar->wait_delay_increment = pVar->wait_delay_total - pVar->wait_delay_sofar; # line 478 "../psControl.st" if (pVar->wait_delay_increment > 1.0) # line 479 "../psControl.st" pVar->wait_delay_increment = 1.0; } return; } } /****** Code for state "psControl_set_current" in state set "psControl" ******/ /* Delay function for state "psControl_set_current" in state set "psControl" */ static void D_psControl_psControl_set_current(SS_ID ssId, struct UserVar *pVar) { } /* Event function for state "psControl_set_current" in state set "psControl" */ static seqBool E_psControl_psControl_set_current(SS_ID ssId, struct UserVar *pVar, int *pTransNum, int *pNextState) { if (TRUE) { *pNextState = 7; *pTransNum = 0; return TRUE; } return FALSE; } /* Action function for state "psControl_set_current" in state set "psControl" */ static void A_psControl_psControl_set_current(SS_ID ssId, struct UserVar *pVar, int transNum, int *pNextState) { switch(transNum) { case 0: { # line 489 "../psControl.st" pVar->wait_needed = 1; # line 490 "../psControl.st" pVar->ps_curr_setpt_prev = pVar->ps_curr_setpt; # line 491 "../psControl.st" if (pVar->ramping) { # line 493 "../psControl.st" pVar->cycle_count = pVar->max_cycle_count + 1; # line 494 "../psControl.st" if ((pVar->control_setpt == 3) || (pVar->control_setpt == 2)) { # line 496 "../psControl.st" pVar->ps_curr_setpt = pVar->ps_curr_des; # line 497 "../psControl.st" pVar->des_current = 1; } else # line 498 "../psControl.st" if (pVar->control_setpt == 6) { # line 499 "../psControl.st" pVar->ps_curr_setpt = pVar->ps_curr_min; # line 500 "../psControl.st" pVar->ramp_current = 1; } else # line 501 "../psControl.st" if (pVar->control_setpt == 7) { # line 502 "../psControl.st" pVar->ps_curr_setpt = pVar->ps_curr_res; # line 503 "../psControl.st" pVar->ramp_current = 1; } else { # line 505 "../psControl.st" pVar->ps_curr_setpt = 0.0; # line 506 "../psControl.st" pVar->zero_current = 1; } } else # line 509 "../psControl.st" if (pVar->cycle_count < pVar->max_cycle_count) { # line 511 "../psControl.st" pVar->change_count++; # line 512 "../psControl.st" pVar->cycle_count = pVar->change_count / 2; # line 513 "../psControl.st" seq_pvPut(ssId, 13/*cycle_count*/, 0); # line 514 "../psControl.st" pVar->zero_current = pVar->zero_current ? 0 : 1; # line 515 "../psControl.st" if (pVar->zero_current) # line 515 "../psControl.st" pVar->ps_curr_setpt = pVar->ps_curr_min; else # line 516 "../psControl.st" if (pVar->use_drv || ((pVar->ps_curr_des < 0.1) && (pVar->ps_curr_des > -0.1))) # line 519 "../psControl.st" if (pVar->pos_pol) # line 519 "../psControl.st" pVar->ps_curr_setpt = pVar->ps_curr_drvh; else # line 520 "../psControl.st" pVar->ps_curr_setpt = pVar->ps_curr_drvl; else # line 521 "../psControl.st" pVar->ps_curr_setpt = pVar->ps_curr_des; } else { # line 525 "../psControl.st" pVar->cycle_count = pVar->max_cycle_count + 1; # line 526 "../psControl.st" pVar->ps_curr_setpt = pVar->ps_curr_des; } # line 528 "../psControl.st" pVar->ps_curr_setpt_new = pVar->ps_curr_setpt; # line 529 "../psControl.st" if (pVar->ps_rampdelay >= 0) { # line 530 "../psControl.st" pVar->ps_ramp = 1; # line 531 "../psControl.st" seq_pvPut(ssId, 6/*ps_ramp*/, 0); # line 532 "../psControl.st" pVar->sw_ramp_delay = 0; } else # line 533 "../psControl.st" if (pVar->ps_curr_setpt != pVar->ps_curr_setpt_prev) { # line 534 "../psControl.st" pVar->sw_ramp_delay = 5.0; } else { # line 536 "../psControl.st" pVar->sw_ramp_delay = 0; } # line 538 "../psControl.st" if ((pVar->ps_rampdelay < 0.02) || (pVar->ps_didt <= 0)) { # line 539 "../psControl.st" seq_pvPut(ssId, 8/*ps_curr_setpt*/, 0); } else { # line 541 "../psControl.st" pVar->ps_curr_setpt = pVar->ps_curr_setpt_prev; } } return; } } /****** Code for state "psControl_ramp_start" in state set "psControl" ******/ /* Delay function for state "psControl_ramp_start" in state set "psControl" */ static void D_psControl_psControl_ramp_start(SS_ID ssId, struct UserVar *pVar) { # line 554 "../psControl.st" seq_delayInit(ssId, 0, (pVar->sw_ramp_delay)); } /* Event function for state "psControl_ramp_start" in state set "psControl" */ static seqBool E_psControl_psControl_ramp_start(SS_ID ssId, struct UserVar *pVar, int *pTransNum, int *pNextState) { # line 550 "../psControl.st" if (!pVar->ps_on) { *pNextState = 8; *pTransNum = 0; return TRUE; } # line 554 "../psControl.st" if (pVar->ps_ramp || seq_delay(ssId, 0)) { *pNextState = 4; *pTransNum = 1; return TRUE; } return FALSE; } /* Action function for state "psControl_ramp_start" in state set "psControl" */ static void A_psControl_psControl_ramp_start(SS_ID ssId, struct UserVar *pVar, int transNum, int *pNextState) { switch(transNum) { case 0: { } return; case 1: { } return; } } /****** Code for state "psControl_done" in state set "psControl" ******/ /* Delay function for state "psControl_done" in state set "psControl" */ static void D_psControl_psControl_done(SS_ID ssId, struct UserVar *pVar) { } /* Event function for state "psControl_done" in state set "psControl" */ static seqBool E_psControl_psControl_done(SS_ID ssId, struct UserVar *pVar, int *pTransNum, int *pNextState) { if (TRUE) { *pNextState = 1; *pTransNum = 0; return TRUE; } return FALSE; } /* Action function for state "psControl_done" in state set "psControl" */ static void A_psControl_psControl_done(SS_ID ssId, struct UserVar *pVar, int transNum, int *pNextState) { switch(transNum) { case 0: { # line 566 "../psControl.st" pVar->ps_status = 10; # line 567 "../psControl.st" if (pVar->standardizing) { # line 568 "../psControl.st" if (!pVar->ps_on) { # line 569 "../psControl.st" epicsPrintf("Supply off - Standardize aborted for %s\n", pVar->ps_c); # line 570 "../psControl.st" pVar->ps_status = 4; } else # line 572 "../psControl.st" if ((!pVar->standardize) || (!pVar->norampoff) || (pVar->control_setpt != 4)) { # line 574 "../psControl.st" epicsPrintf("Standardize aborted by user for %s\n", pVar->ps_c); # line 575 "../psControl.st" pVar->ps_status = 3; } else # line 577 "../psControl.st" if (pVar->ramp_timeout) { # line 578 "../psControl.st" epicsPrintf("Ramp timeout - Standardize aborted for %s\n", pVar->ps_c); # line 579 "../psControl.st" pVar->ps_status = 5; } else { # line 582 "../psControl.st" epicsPrintf("Standardize completed for %s\n", pVar->ps_c); } # line 584 "../psControl.st" pVar->standardize = 0; # line 585 "../psControl.st" seq_pvPut(ssId, 12/*standardize*/, 0); # line 586 "../psControl.st" if (pVar->control_setpt == 4) { # line 587 "../psControl.st" pVar->control_setpt = 0; # line 588 "../psControl.st" seq_pvPut(ssId, 2/*control_setpt*/, 0); } # line 590 "../psControl.st" if (pVar->ps_status != 10) { # line 591 "../psControl.st" if (pVar->ps_curr_setpt != 0.0) { # line 592 "../psControl.st" pVar->ps_curr_setpt = 0.0; # line 593 "../psControl.st" seq_pvPut(ssId, 8/*ps_curr_setpt*/, 0); # line 594 "../psControl.st" seq_efSet(ssId, 1/*ps_curr_setpt_ef*/); } } } else # line 597 "../psControl.st" if (pVar->zero_current || pVar->ramp_timeout || (!pVar->ps_on)) { # line 598 "../psControl.st" if ((!pVar->norampoff) || (pVar->control_setpt == 1)) { # line 599 "../psControl.st" epicsPrintf("PS ramped to zero - setting PS off for %s\n", pVar->ps_c); # line 600 "../psControl.st" seq_efClear(ssId, 1/*ps_curr_setpt_ef*/); # line 601 "../psControl.st" pVar->norampoff = 1; # line 602 "../psControl.st" seq_pvPut(ssId, 3/*norampoff*/, 0); # line 603 "../psControl.st" pVar->ps_on_des = 0; # line 604 "../psControl.st" seq_pvPut(ssId, 5/*ps_on_des*/, 0); } # line 606 "../psControl.st" if (pVar->ramp_timeout || (!pVar->ps_on) || (pVar->control_setpt == 1) || (pVar->control_setpt == 5)) { # line 609 "../psControl.st" pVar->control_setpt = 0; # line 610 "../psControl.st" seq_pvPut(ssId, 2/*control_setpt*/, 0); } } else # line 612 "../psControl.st" if ((!pVar->setpt_change) && ((pVar->des_current && ((pVar->control_setpt == 2) || (pVar->control_setpt == 3))) || (pVar->ramp_current && ((pVar->control_setpt == 6) || (pVar->control_setpt == 7))))) { # line 619 "../psControl.st" pVar->control_setpt = 0; # line 620 "../psControl.st" seq_pvPut(ssId, 2/*control_setpt*/, 0); } # line 622 "../psControl.st" seq_pvPut(ssId, 7/*ps_status*/, 0); # line 623 "../psControl.st" if (!seq_efTest(ssId, 1/*ps_curr_setpt_ef*/) || (!pVar->ps_on)) { # line 624 "../psControl.st" pVar->ps_limits_flag = 0; # line 625 "../psControl.st" seq_pvPut(ssId, 10/*ps_limits_flag*/, 0); } # line 627 "../psControl.st" if ((pVar->ps_rampdelay >= 0) && pVar->ps_ramp) { # line 628 "../psControl.st" pVar->ps_ramp = 0; # line 629 "../psControl.st" seq_pvPut(ssId, 6/*ps_ramp*/, 0); } # line 631 "../psControl.st" pVar->ps_curr_setpt_prev = pVar->ps_curr_setpt; } return; } } /* Program exit func */ static void G_prog_exit(SS_ID ssId, struct UserVar *pVar) { } /************************ Tables ************************/ /* Channel table */ static seqChan G_channels[] = { /* chName, offset, varName, varType, count, eventNum, efId, monitored, queueSize, queueIndex */ {"{ps}:ControlDelay", offsetof(struct UserVar, wait_delay_sofar), "wait_delay_sofar", "double", 1, 4, 0, 0, 0, 0}, {"{ps}:ControlDelayMax", offsetof(struct UserVar, wait_delay), "wait_delay", "double", 1, 5, 0, 1, 0, 0}, {"{ps}:Control", offsetof(struct UserVar, control_setpt), "control_setpt", "int", 1, 6, 0, 1, 0, 0}, {"{ps}:Ramp", offsetof(struct UserVar, norampoff), "norampoff", "int", 1, 7, 0, 1, 0, 0}, {"{ps}:State", offsetof(struct UserVar, ps_on), "ps_on", "int", 1, 8, 0, 1, 0, 0}, {"{ps}:StateSetpt", offsetof(struct UserVar, ps_on_des), "ps_on_des", "int", 1, 9, 0, 0, 0, 0}, {"{ps}:RampStatus", offsetof(struct UserVar, ps_ramp), "ps_ramp", "int", 1, 10, 0, 1, 0, 0}, {"{ps}:ControlStatus", offsetof(struct UserVar, ps_status), "ps_status", "int", 1, 11, 0, 0, 0, 0}, {"{ps}:{vi}Setpt", offsetof(struct UserVar, ps_curr_setpt), "ps_curr_setpt", "double", 1, 12, 1, 1, 0, 0}, {"{ps}:{vi}SetptDes", offsetof(struct UserVar, ps_curr_des), "ps_curr_des", "double", 1, 13, 2, 1, 0, 0}, {"{ps}:WarnDelta.F", offsetof(struct UserVar, ps_limits_flag), "ps_limits_flag", "int", 1, 14, 0, 0, 0, 0}, {"{ps}:{vi}D{vis}DtSelect", offsetof(struct UserVar, ps_didt_select), "ps_didt_select", "int", 1, 15, 0, 0, 0, 0}, {"{ps}:Standardize", offsetof(struct UserVar, standardize), "standardize", "int", 1, 16, 0, 1, 0, 0}, {"{ps}:StandardizeNumCycle", offsetof(struct UserVar, cycle_count), "cycle_count", "int", 1, 17, 0, 0, 0, 0}, {"{ps}:StandardizeNumCycleMax", offsetof(struct UserVar, max_cycle_count), "max_cycle_count", "int", 1, 18, 0, 1, 0, 0}, {"{ps}:{vi}Setpt.DRVH", offsetof(struct UserVar, ps_curr_drvh), "ps_curr_drvh", "double", 1, 19, 0, 1, 0, 0}, {"{ps}:{vi}Setpt.DRVL", offsetof(struct UserVar, ps_curr_drvl), "ps_curr_drvl", "double", 1, 20, 0, 1, 0, 0}, {"{ps}:{vi}SetptMin", offsetof(struct UserVar, ps_curr_min), "ps_curr_min", "double", 1, 21, 0, 1, 0, 0}, {"{ps}:{vi}SetptConf", offsetof(struct UserVar, ps_curr_res), "ps_curr_res", "double", 1, 22, 3, 1, 0, 0}, {"{ps}:{vi}D{vis}Dt", offsetof(struct UserVar, ps_didt), "ps_didt", "double", 1, 23, 0, 1, 0, 0}, {"{ps}:RampStepDelay", offsetof(struct UserVar, ps_rampdelay), "ps_rampdelay", "double", 1, 24, 0, 1, 0, 0} }; /* Event masks for state set "psControl" */ static const seqMask EM_psControl_psControl_init[] = { 0x00000000, }; static const seqMask EM_psControl_psControl_request[] = { 0x000101ca, }; static const seqMask EM_psControl_psControl_on_wait[] = { 0x00000040, }; static const seqMask EM_psControl_psControl_on_check[] = { 0x00020100, }; static const seqMask EM_psControl_psControl_ramp_wait[] = { 0x01000500, }; static const seqMask EM_psControl_psControl_wait[] = { 0x000705f0, }; static const seqMask EM_psControl_psControl_set_current[] = { 0x00000000, }; static const seqMask EM_psControl_psControl_ramp_start[] = { 0x00000500, }; static const seqMask EM_psControl_psControl_done[] = { 0x00000000, }; /* State table for state set "psControl" */ static seqState G_psControl_states[] = { { /* state name */ "psControl_init", /* action function */ A_psControl_psControl_init, /* event function */ E_psControl_psControl_init, /* delay function */ D_psControl_psControl_init, /* entry function */ 0, /* exit function */ 0, /* event mask array */ EM_psControl_psControl_init, /* state options */ (0) }, { /* state name */ "psControl_request", /* action function */ A_psControl_psControl_request, /* event function */ E_psControl_psControl_request, /* delay function */ D_psControl_psControl_request, /* entry function */ I_psControl_psControl_request, /* exit function */ 0, /* event mask array */ EM_psControl_psControl_request, /* state options */ (0) }, { /* state name */ "psControl_on_wait", /* action function */ A_psControl_psControl_on_wait, /* event function */ E_psControl_psControl_on_wait, /* delay function */ D_psControl_psControl_on_wait, /* entry function */ I_psControl_psControl_on_wait, /* exit function */ 0, /* event mask array */ EM_psControl_psControl_on_wait, /* state options */ (0) }, { /* state name */ "psControl_on_check", /* action function */ A_psControl_psControl_on_check, /* event function */ E_psControl_psControl_on_check, /* delay function */ D_psControl_psControl_on_check, /* entry function */ 0, /* exit function */ 0, /* event mask array */ EM_psControl_psControl_on_check, /* state options */ (0) }, { /* state name */ "psControl_ramp_wait", /* action function */ A_psControl_psControl_ramp_wait, /* event function */ E_psControl_psControl_ramp_wait, /* delay function */ D_psControl_psControl_ramp_wait, /* entry function */ I_psControl_psControl_ramp_wait, /* exit function */ 0, /* event mask array */ EM_psControl_psControl_ramp_wait, /* state options */ (0) }, { /* state name */ "psControl_wait", /* action function */ A_psControl_psControl_wait, /* event function */ E_psControl_psControl_wait, /* delay function */ D_psControl_psControl_wait, /* entry function */ I_psControl_psControl_wait, /* exit function */ 0, /* event mask array */ EM_psControl_psControl_wait, /* state options */ (0) }, { /* state name */ "psControl_set_current", /* action function */ A_psControl_psControl_set_current, /* event function */ E_psControl_psControl_set_current, /* delay function */ D_psControl_psControl_set_current, /* entry function */ 0, /* exit function */ 0, /* event mask array */ EM_psControl_psControl_set_current, /* state options */ (0) }, { /* state name */ "psControl_ramp_start", /* action function */ A_psControl_psControl_ramp_start, /* event function */ E_psControl_psControl_ramp_start, /* delay function */ D_psControl_psControl_ramp_start, /* entry function */ 0, /* exit function */ 0, /* event mask array */ EM_psControl_psControl_ramp_start, /* state options */ (0) }, { /* state name */ "psControl_done", /* action function */ A_psControl_psControl_done, /* event function */ E_psControl_psControl_done, /* delay function */ D_psControl_psControl_done, /* entry function */ 0, /* exit function */ 0, /* event mask array */ EM_psControl_psControl_done, /* state options */ (0) }, }; /* State set table */ static seqSS G_state_sets[] = { { /* state set name */ "psControl", /* states */ G_psControl_states, /* number of states */ 9, /* number of delays */ 2 }, }; /* Program table (global) */ seqProgram psControl = { /* magic number */ 2001006, /* program name */ "psControl", /* channels */ G_channels, /* num. channels */ 21, /* state sets */ G_state_sets, /* num. state sets */ 1, /* user var size */ sizeof(struct UserVar), /* param */ "ps=00G-QD1,limit=DRVH,vi=Curr,vis=I,turnonmin=0", /* num. event flags */ 3, /* encoded options */ (0 | OPT_CONN | OPT_NEWEF | OPT_REENT), /* init func */ G_prog_init, /* entry func */ NULL, /* exit func */ G_prog_exit, /* num. queues */ 0 }; /* Register sequencer commands and program */ #include "epicsExport.h" static void psControlRegistrar (void) { seqRegisterSequencerCommands(); seqRegisterSequencerProgram (&psControl); } epicsExportRegistrar(psControlRegistrar);