/* Generated with snc from sncProgram.i */ /* Program "sncpac" */ #include #include #include #include #include "epicsTypes.h" #include "seqCom.h" /* Variable declarations */ # line 6 "./../sncpac.stt" static int opState = 0; # line 7 "./../sncpac.stt" static int calibCtrl = 0; # line 8 "./../sncpac.stt" static int wfSelection = 0; # line 9 "./../sncpac.stt" static int cwfSelection = 0; # line 10 "./../sncpac.stt" static int trigMode = 0; # line 11 "./../sncpac.stt" static int loadingWf = 0; # line 12 "./../sncpac.stt" static int loadingCwf = 0; # line 13 "./../sncpac.stt" static int rescaleIbyAmplitude = 0; # line 14 "./../sncpac.stt" static int rescaleQbyAmplitude = 0; # line 15 "./../sncpac.stt" static int loadIRefFromFile = 0; # line 16 "./../sncpac.stt" static int loadQRefFromFile = 0; # line 17 "./../sncpac.stt" static int loadICalRefFromFile = 0; # line 18 "./../sncpac.stt" static int loadQCalRefFromFile = 0; # line 21 "./../sncpac.stt" static int updateOpsIFPGA = 0; # line 22 "./../sncpac.stt" static int updateOpsQFPGA = 0; # line 23 "./../sncpac.stt" static int updateCalIFPGA = 0; # line 24 "./../sncpac.stt" static int updateCalQFPGA = 0; /* C code definitions */ # line 3 "./../sncpac.stt" #include "pacMacros.h" # line 4 "./../sncpac.stt" #include "drvPac.h" /* Program init func */ static void G_prog_init(struct UserVar *pVar) { } /****** Code for state "init" in state set "pac" ******/ /* Entry function for state "init" in state set "pac" */ static void I_pac_init(SS_ID ssId, struct UserVar *pVar) { # line 78 "./../sncpac.stt" printf("sncpac: init\n"); } /* Delay function for state "init" in state set "pac" */ static void D_pac_init(SS_ID ssId, struct UserVar *pVar) { # line 80 "./../sncpac.stt" seq_delayInit(ssId, 0, (1)); } /* Event function for state "init" in state set "pac" */ static seqBool E_pac_init(SS_ID ssId, struct UserVar *pVar, int *pTransNum, int *pNextState) { # line 80 "./../sncpac.stt" if (seq_delay(ssId, 0) && (opState == PAC_STARTING)) { *pNextState = 1; *pTransNum = 0; return TRUE; } return FALSE; } /* Action function for state "init" in state set "pac" */ static void A_pac_init(SS_ID ssId, struct UserVar *pVar, int transNum, int *pNextState) { switch(transNum) { case 0: { # line 81 "./../sncpac.stt" printf("sncpac: operation state set to start-up\n"); } return; } } /****** Code for state "startup" in state set "pac" ******/ /* Entry function for state "startup" in state set "pac" */ static void I_pac_startup(SS_ID ssId, struct UserVar *pVar) { # line 87 "./../sncpac.stt" opState = PAC_STARTING; # line 88 "./../sncpac.stt" seq_pvPut(ssId, 0/*opState*/, 0); # line 89 "./../sncpac.stt" calibCtrl = PAC_CAL_IDLE; # line 90 "./../sncpac.stt" seq_pvPut(ssId, 1/*calibCtrl*/, 0); # line 91 "./../sncpac.stt" printf("sncpac: startup\n"); } /* Delay function for state "startup" in state set "pac" */ static void D_pac_startup(SS_ID ssId, struct UserVar *pVar) { # line 96 "./../sncpac.stt" seq_delayInit(ssId, 0, (1)); # line 101 "./../sncpac.stt" seq_delayInit(ssId, 1, (5)); } /* Event function for state "startup" in state set "pac" */ static seqBool E_pac_startup(SS_ID ssId, struct UserVar *pVar, int *pTransNum, int *pNextState) { # line 96 "./../sncpac.stt" if (seq_delay(ssId, 0) && (seq_efTest(ssId, 1/*changeWfsEvent*/))) { *pNextState = 3; *pTransNum = 0; return TRUE; } # line 101 "./../sncpac.stt" if (seq_delay(ssId, 1)) { *pNextState = 1; *pTransNum = 1; return TRUE; } return FALSE; } /* Action function for state "startup" in state set "pac" */ static void A_pac_startup(SS_ID ssId, struct UserVar *pVar, int transNum, int *pNextState) { switch(transNum) { case 0: { # line 97 "./../sncpac.stt" printf("sncpac: startup detects changeWfsEvent to load initial reference waveforms.\n"); # line 98 "./../sncpac.stt" seq_efClear(ssId, 1/*changeWfsEvent*/); } return; case 1: { # line 102 "./../sncpac.stt" printf("sncpac: startup sequence unable to complete. Select a waveform pair\n"); } return; } } /****** Code for state "running" in state set "pac" ******/ /* Entry function for state "running" in state set "pac" */ static void I_pac_running(SS_ID ssId, struct UserVar *pVar) { # line 110 "./../sncpac.stt" printf("sncpac: running. reloading ops waveforms into FPGA\n"); # line 111 "./../sncpac.stt" updateOpsIFPGA = 1; # line 112 "./../sncpac.stt" seq_pvPut(ssId, 13/*updateOpsIFPGA*/, 0); # line 113 "./../sncpac.stt" updateOpsQFPGA = 1; # line 114 "./../sncpac.stt" seq_pvPut(ssId, 14/*updateOpsQFPGA*/, 0); # line 116 "./../sncpac.stt" printf("sncpac: running. using external trigger mode\n"); # line 117 "./../sncpac.stt" opState = PAC_RUNNING; # line 118 "./../sncpac.stt" seq_pvPut(ssId, 0/*opState*/, 0); # line 119 "./../sncpac.stt" trigMode = PAC_EXT_TRIG_MODE; # line 120 "./../sncpac.stt" seq_pvPut(ssId, 4/*trigMode*/, 0); } /* Delay function for state "running" in state set "pac" */ static void D_pac_running(SS_ID ssId, struct UserVar *pVar) { # line 123 "./../sncpac.stt" seq_delayInit(ssId, 0, (1)); # line 127 "./../sncpac.stt" seq_delayInit(ssId, 1, (1)); } /* Event function for state "running" in state set "pac" */ static seqBool E_pac_running(SS_ID ssId, struct UserVar *pVar, int *pTransNum, int *pNextState) { # line 123 "./../sncpac.stt" if (seq_delay(ssId, 0) && (calibCtrl == PAC_CAL_RQST)) { *pNextState = 4; *pTransNum = 0; return TRUE; } # line 127 "./../sncpac.stt" if (seq_delay(ssId, 1) && (seq_efTest(ssId, 1/*changeWfsEvent*/))) { *pNextState = 3; *pTransNum = 1; return TRUE; } return FALSE; } /* Action function for state "running" in state set "pac" */ static void A_pac_running(SS_ID ssId, struct UserVar *pVar, int transNum, int *pNextState) { switch(transNum) { case 0: { # line 124 "./../sncpac.stt" printf("sncpac: calibration requested\n"); } return; case 1: { # line 128 "./../sncpac.stt" printf("sncpac: running. detects event to change wfs\n"); # line 129 "./../sncpac.stt" seq_efClear(ssId, 1/*changeWfsEvent*/); } return; } } /****** Code for state "changing_wf" in state set "pac" ******/ /* Entry function for state "changing_wf" in state set "pac" */ static void I_pac_changing_wf(SS_ID ssId, struct UserVar *pVar) { # line 136 "./../sncpac.stt" opState = PAC_CHANGING_WFS; # line 137 "./../sncpac.stt" seq_pvPut(ssId, 0/*opState*/, 0); # line 138 "./../sncpac.stt" printf("sncpac: changing to waveforms %d. using internal trigger mode\n", wfSelection); # line 148 "./../sncpac.stt" loadIRefFromFile = 1; # line 149 "./../sncpac.stt" seq_pvPut(ssId, 9/*loadIRefFromFile*/, 0); # line 150 "./../sncpac.stt" loadQRefFromFile = 1; # line 151 "./../sncpac.stt" seq_pvPut(ssId, 10/*loadQRefFromFile*/, 0); # line 152 "./../sncpac.stt" printf("sncpac: forcing processing of I_REF and Q_REF\n"); } /* Delay function for state "changing_wf" in state set "pac" */ static void D_pac_changing_wf(SS_ID ssId, struct UserVar *pVar) { # line 156 "./../sncpac.stt" seq_delayInit(ssId, 0, (.5)); } /* Event function for state "changing_wf" in state set "pac" */ static seqBool E_pac_changing_wf(SS_ID ssId, struct UserVar *pVar, int *pTransNum, int *pNextState) { # line 156 "./../sncpac.stt" if (seq_delay(ssId, 0) && (loadingWf == 0)) { *pNextState = 2; *pTransNum = 0; return TRUE; } return FALSE; } /* Action function for state "changing_wf" in state set "pac" */ static void A_pac_changing_wf(SS_ID ssId, struct UserVar *pVar, int transNum, int *pNextState) { switch(transNum) { case 0: { # line 157 "./../sncpac.stt" printf("sncpac: new wfs loaded. resume running\n"); } return; } } /****** Code for state "calibrating" in state set "pac" ******/ /* Entry function for state "calibrating" in state set "pac" */ static void I_pac_calibrating(SS_ID ssId, struct UserVar *pVar) { # line 163 "./../sncpac.stt" printf("sncpac: calibrating. reloading cal waveforms into FPGA\n"); # line 164 "./../sncpac.stt" updateCalIFPGA = 1; # line 165 "./../sncpac.stt" seq_pvPut(ssId, 15/*updateCalIFPGA*/, 0); # line 166 "./../sncpac.stt" updateCalQFPGA = 1; # line 167 "./../sncpac.stt" seq_pvPut(ssId, 16/*updateCalQFPGA*/, 0); # line 169 "./../sncpac.stt" opState = PAC_CALIBRATING; # line 170 "./../sncpac.stt" seq_pvPut(ssId, 0/*opState*/, 0); # line 171 "./../sncpac.stt" trigMode = PAC_INT_TRIG_MODE; # line 172 "./../sncpac.stt" seq_pvPut(ssId, 4/*trigMode*/, 0); # line 173 "./../sncpac.stt" printf("sncpac: doing calibration. using internal trigger mode\n"); } /* Delay function for state "calibrating" in state set "pac" */ static void D_pac_calibrating(SS_ID ssId, struct UserVar *pVar) { # line 176 "./../sncpac.stt" seq_delayInit(ssId, 0, (1)); # line 180 "./../sncpac.stt" seq_delayInit(ssId, 1, (1)); } /* Event function for state "calibrating" in state set "pac" */ static seqBool E_pac_calibrating(SS_ID ssId, struct UserVar *pVar, int *pTransNum, int *pNextState) { # line 176 "./../sncpac.stt" if (seq_delay(ssId, 0) && (calibCtrl == PAC_CAL_DONE)) { *pNextState = 6; *pTransNum = 0; return TRUE; } # line 180 "./../sncpac.stt" if (seq_delay(ssId, 1) && (seq_efTest(ssId, 2/*changeCwfsEvent*/))) { *pNextState = 5; *pTransNum = 1; return TRUE; } return FALSE; } /* Action function for state "calibrating" in state set "pac" */ static void A_pac_calibrating(SS_ID ssId, struct UserVar *pVar, int transNum, int *pNextState) { switch(transNum) { case 0: { # line 177 "./../sncpac.stt" printf("sncpac: calibration done. resume running...\n"); } return; case 1: { # line 181 "./../sncpac.stt" printf("sncpac: calibrating. detects event to change cwfs\n"); # line 182 "./../sncpac.stt" seq_efClear(ssId, 2/*changeCwfsEvent*/); } return; } } /****** Code for state "changing_cwf" in state set "pac" ******/ /* Entry function for state "changing_cwf" in state set "pac" */ static void I_pac_changing_cwf(SS_ID ssId, struct UserVar *pVar) { # line 189 "./../sncpac.stt" opState = PAC_CHANGING_CWFS; # line 190 "./../sncpac.stt" seq_pvPut(ssId, 0/*opState*/, 0); # line 191 "./../sncpac.stt" printf("sncpac: changing calibration waveforms\n"); # line 192 "./../sncpac.stt" printf("sncpac: changing to %d. using internal trigger mode\n", cwfSelection); # line 193 "./../sncpac.stt" loadICalRefFromFile = 1; # line 194 "./../sncpac.stt" seq_pvPut(ssId, 11/*loadICalRefFromFile*/, 0); # line 195 "./../sncpac.stt" loadQCalRefFromFile = 1; # line 196 "./../sncpac.stt" seq_pvPut(ssId, 12/*loadQCalRefFromFile*/, 0); # line 197 "./../sncpac.stt" printf("sncpac: forcing processing of ICAL_REF and QCAL_REF\n"); } /* Delay function for state "changing_cwf" in state set "pac" */ static void D_pac_changing_cwf(SS_ID ssId, struct UserVar *pVar) { # line 200 "./../sncpac.stt" seq_delayInit(ssId, 0, (.5)); } /* Event function for state "changing_cwf" in state set "pac" */ static seqBool E_pac_changing_cwf(SS_ID ssId, struct UserVar *pVar, int *pTransNum, int *pNextState) { # line 200 "./../sncpac.stt" if (seq_delay(ssId, 0) && (loadingCwf == 0)) { *pNextState = 4; *pTransNum = 0; return TRUE; } return FALSE; } /* Action function for state "changing_cwf" in state set "pac" */ static void A_pac_changing_cwf(SS_ID ssId, struct UserVar *pVar, int transNum, int *pNextState) { switch(transNum) { case 0: { # line 201 "./../sncpac.stt" printf("sncpac: assume new cal wfs finished loading. resume calibrating\n"); } return; } } /****** Code for state "calibration_done" in state set "pac" ******/ /* Entry function for state "calibration_done" in state set "pac" */ static void I_pac_calibration_done(SS_ID ssId, struct UserVar *pVar) { # line 207 "./../sncpac.stt" opState = PAC_CALIBRATION_DONE; # line 208 "./../sncpac.stt" seq_pvPut(ssId, 0/*opState*/, 0); } /* Delay function for state "calibration_done" in state set "pac" */ static void D_pac_calibration_done(SS_ID ssId, struct UserVar *pVar) { # line 210 "./../sncpac.stt" seq_delayInit(ssId, 0, (1)); } /* Event function for state "calibration_done" in state set "pac" */ static seqBool E_pac_calibration_done(SS_ID ssId, struct UserVar *pVar, int *pTransNum, int *pNextState) { # line 210 "./../sncpac.stt" if (seq_delay(ssId, 0)) { *pNextState = 2; *pTransNum = 0; return TRUE; } return FALSE; } /* Action function for state "calibration_done" in state set "pac" */ static void A_pac_calibration_done(SS_ID ssId, struct UserVar *pVar, int transNum, int *pNextState) { switch(transNum) { case 0: { # line 211 "./../sncpac.stt" calibCtrl = PAC_CAL_IDLE; # line 212 "./../sncpac.stt" seq_pvPut(ssId, 1/*calibCtrl*/, 0); } return; } } /************************ Tables ************************/ /* Channel table */ static seqChan G_channels[] = { /* chName, offset, varName, varType, count, eventNum, efId, monitored, queueSize, queueIndex */ {"{PRIM}:{LOCA}:{UNIT}:{PAC}_C_STATE", (size_t)&opState, "opState", "int", 1, 3, 0, 1, 0, 0}, {"{PRIM}:{LOCA}:{UNIT}:{PAC}_C_CALIB", (size_t)&calibCtrl, "calibCtrl", "int", 1, 4, 0, 1, 0, 0}, {"{PRIM}:{LOCA}:{UNIT}:{PAC}_WF", (size_t)&wfSelection, "wfSelection", "int", 1, 5, 1, 1, 0, 0}, {"{PRIM}:{LOCA}:{UNIT}:{PAC}_CWF", (size_t)&cwfSelection, "cwfSelection", "int", 1, 6, 2, 1, 0, 0}, {"{PRIM}:{LOCA}:{UNIT}:{PAC}_TRG_MODE", (size_t)&trigMode, "trigMode", "int", 1, 7, 0, 1, 0, 0}, {"{PRIM}:{LOCA}:{UNIT}:{PAC}_WF.PACT", (size_t)&loadingWf, "loadingWf", "int", 1, 8, 0, 1, 0, 0}, {"{PRIM}:{LOCA}:{UNIT}:{PAC}_CWF.PACT", (size_t)&loadingCwf, "loadingCwf", "int", 1, 9, 0, 1, 0, 0}, {"{PRIM}:{LOCA}:{UNIT}:{PAC}_ICAL.PROC", (size_t)&rescaleIbyAmplitude, "rescaleIbyAmplitude", "int", 1, 10, 0, 1, 0, 0}, {"{PRIM}:{LOCA}:{UNIT}:{PAC}_QCAL.PROC", (size_t)&rescaleQbyAmplitude, "rescaleQbyAmplitude", "int", 1, 11, 0, 1, 0, 0}, {"{PRIM}:{LOCA}:{UNIT}:{PAC}_I_REF.PROC", (size_t)&loadIRefFromFile, "loadIRefFromFile", "int", 1, 12, 0, 1, 0, 0}, {"{PRIM}:{LOCA}:{UNIT}:{PAC}_Q_REF.PROC", (size_t)&loadQRefFromFile, "loadQRefFromFile", "int", 1, 13, 0, 1, 0, 0}, {"{PRIM}:{LOCA}:{UNIT}:{PAC}_ICAL_REF.PROC", (size_t)&loadICalRefFromFile, "loadICalRefFromFile", "int", 1, 14, 0, 1, 0, 0}, {"{PRIM}:{LOCA}:{UNIT}:{PAC}_QCAL_REF.PROC", (size_t)&loadQCalRefFromFile, "loadQCalRefFromFile", "int", 1, 15, 0, 1, 0, 0}, {"{PRIM}:{LOCA}:{UNIT}:{PAC}_I_UP_FP.PROC", (size_t)&updateOpsIFPGA, "updateOpsIFPGA", "int", 1, 16, 0, 1, 0, 0}, {"{PRIM}:{LOCA}:{UNIT}:{PAC}_Q_UP_FP.PROC", (size_t)&updateOpsQFPGA, "updateOpsQFPGA", "int", 1, 17, 0, 1, 0, 0}, {"{PRIM}:{LOCA}:{UNIT}:{PAC}_IC_UP_FP.PROC", (size_t)&updateCalIFPGA, "updateCalIFPGA", "int", 1, 18, 0, 1, 0, 0}, {"{PRIM}:{LOCA}:{UNIT}:{PAC}_QC_UP_FP.PROC", (size_t)&updateCalQFPGA, "updateCalQFPGA", "int", 1, 19, 0, 1, 0, 0} }; /* Event masks for state set "pac" */ static const seqMask EM_pac_init[] = { 0x00000008, }; static const seqMask EM_pac_startup[] = { 0x00000002, }; static const seqMask EM_pac_running[] = { 0x00000012, }; static const seqMask EM_pac_changing_wf[] = { 0x00000100, }; static const seqMask EM_pac_calibrating[] = { 0x00000014, }; static const seqMask EM_pac_changing_cwf[] = { 0x00000200, }; static const seqMask EM_pac_calibration_done[] = { 0x00000000, }; /* State table for state set "pac" */ static seqState G_pac_states[] = { { /* state name */ "init", /* action function */ A_pac_init, /* event function */ E_pac_init, /* delay function */ D_pac_init, /* entry function */ I_pac_init, /* exit function */ 0, /* event mask array */ EM_pac_init, /* state options */ (0) }, { /* state name */ "startup", /* action function */ A_pac_startup, /* event function */ E_pac_startup, /* delay function */ D_pac_startup, /* entry function */ I_pac_startup, /* exit function */ 0, /* event mask array */ EM_pac_startup, /* state options */ (0) }, { /* state name */ "running", /* action function */ A_pac_running, /* event function */ E_pac_running, /* delay function */ D_pac_running, /* entry function */ I_pac_running, /* exit function */ 0, /* event mask array */ EM_pac_running, /* state options */ (0) }, { /* state name */ "changing_wf", /* action function */ A_pac_changing_wf, /* event function */ E_pac_changing_wf, /* delay function */ D_pac_changing_wf, /* entry function */ I_pac_changing_wf, /* exit function */ 0, /* event mask array */ EM_pac_changing_wf, /* state options */ (0) }, { /* state name */ "calibrating", /* action function */ A_pac_calibrating, /* event function */ E_pac_calibrating, /* delay function */ D_pac_calibrating, /* entry function */ I_pac_calibrating, /* exit function */ 0, /* event mask array */ EM_pac_calibrating, /* state options */ (0) }, { /* state name */ "changing_cwf", /* action function */ A_pac_changing_cwf, /* event function */ E_pac_changing_cwf, /* delay function */ D_pac_changing_cwf, /* entry function */ I_pac_changing_cwf, /* exit function */ 0, /* event mask array */ EM_pac_changing_cwf, /* state options */ (0) }, { /* state name */ "calibration_done", /* action function */ A_pac_calibration_done, /* event function */ E_pac_calibration_done, /* delay function */ D_pac_calibration_done, /* entry function */ I_pac_calibration_done, /* exit function */ 0, /* event mask array */ EM_pac_calibration_done, /* state options */ (0) }, }; /* State set table */ static seqSS G_state_sets[] = { { /* state set name */ "pac", /* states */ G_pac_states, /* number of states */ 7, /* number of delays */ 2 }, }; /* Program table (global) */ seqProgram sncpac = { /* magic number */ 2001006, /* program name */ "sncpac", /* channels */ G_channels, /* num. channels */ 17, /* state sets */ G_state_sets, /* num. state sets */ 1, /* user var size */ 0, /* param */ "", /* num. event flags */ 2, /* encoded options */ (0 | OPT_CONN | OPT_NEWEF | OPT_MAIN), /* init func */ G_prog_init, /* entry func */ NULL, /* exit func */ NULL, /* num. queues */ 0 }; #define PROG_NAME sncpac #include "seqMain.c" /* Register sequencer commands and program */ #include "epicsExport.h" static void sncpacRegistrar (void) { seqRegisterSequencerCommands(); seqRegisterSequencerProgram (&sncpac); } epicsExportRegistrar(sncpacRegistrar);