/* SNC Version 2.0.11: Fri May 27 10:07:33 2011: ../sncPauFcomPush.stt */ /* Event flags */ #define ev_data0 1 #define ev_data1 2 #define ev_data2 3 #define ev_data3 4 /* Program "sncPauFcomPush" */ #include "seqCom.h" #define NUM_SS 1 #define NUM_CHANNELS 5 #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 TRUE extern struct seqProgram sncPauFcomPush; /* Variable declarations */ struct UserVar { int i; unsigned long userData[4]; char *muxName; char *fcomName; int feedback_mode; double static_data[4]; }; /* C code definitions */ # line 5 "../sncPauFcomPush.stt" # line 6 "../sncPauFcomPush.stt" #define FBCK_OFF 0 # line 7 "../sncPauFcomPush.stt" #define FBCK_ON 1 # line 7 "../sncPauFcomPush.stt" # line 12 "../sncPauFcomPush.stt" # line 13 "../sncPauFcomPush.stt" #include # line 14 "../sncPauFcomPush.stt" #include # line 15 "../sncPauFcomPush.stt" #include # line 16 "../sncPauFcomPush.stt" #include # line 17 "../sncPauFcomPush.stt" # line 18 "../sncPauFcomPush.stt" typedef struct { # line 19 "../sncPauFcomPush.stt" char fcomPVName[40]; # line 20 "../sncPauFcomPush.stt" FcomID fcomId; # line 21 "../sncPauFcomPush.stt" FcomBlob *pBlob; # line 22 "../sncPauFcomPush.stt" int status; # line 23 "../sncPauFcomPush.stt" double pushVal; # line 24 "../sncPauFcomPush.stt" unsigned succCnt; # line 25 "../sncPauFcomPush.stt" unsigned failCnt; # line 26 "../sncPauFcomPush.stt" } usrData_ts; # line 27 "../sncPauFcomPush.stt" # line 28 "../sncPauFcomPush.stt" # line 29 "../sncPauFcomPush.stt" static usrData_ts * usrAllocate(char *mux_name) # line 30 "../sncPauFcomPush.stt" { # line 31 "../sncPauFcomPush.stt" usrData_ts *pUsr = (usrData_ts*) mallocMustSucceed(sizeof(usrData_ts), mux_name); # line 32 "../sncPauFcomPush.stt" FcomBlob *pBlob = (FcomBlob *) mallocMustSucceed(sizeof(FcomBlob), mux_name); # line 33 "../sncPauFcomPush.stt" # line 34 "../sncPauFcomPush.stt" if(pUsr && pBlob) { # line 35 "../sncPauFcomPush.stt" pUsr->pBlob = pBlob; # line 36 "../sncPauFcomPush.stt" return pUsr; # line 37 "../sncPauFcomPush.stt" } # line 38 "../sncPauFcomPush.stt" else return (usrData_ts *)NULL; # line 39 "../sncPauFcomPush.stt" } # line 40 "../sncPauFcomPush.stt" # line 41 "../sncPauFcomPush.stt" static unsigned long initFcom(char *mux_name, int slot) # line 42 "../sncPauFcomPush.stt" { # line 43 "../sncPauFcomPush.stt" if(!mux_name) return 0; # line 44 "../sncPauFcomPush.stt" # line 45 "../sncPauFcomPush.stt" usrData_ts *p = usrAllocate(mux_name); # line 46 "../sncPauFcomPush.stt" # line 47 "../sncPauFcomPush.stt" if(!p) return 0; # line 48 "../sncPauFcomPush.stt" # line 49 "../sncPauFcomPush.stt" p->status = 0; # line 50 "../sncPauFcomPush.stt" p->pushVal = 0.; # line 51 "../sncPauFcomPush.stt" p->succCnt = 0; # line 52 "../sncPauFcomPush.stt" p->failCnt = 0; # line 53 "../sncPauFcomPush.stt" # line 54 "../sncPauFcomPush.stt" makeFcomPVNamewithSlotNumber(mux_name, p->fcomPVName, slot); # line 55 "../sncPauFcomPush.stt" p->fcomId = fcomLCLSPV2FcomID(p->fcomPVName); # line 56 "../sncPauFcomPush.stt" # line 57 "../sncPauFcomPush.stt" # line 58 "../sncPauFcomPush.stt" if(!p->fcomId) return 0; # line 59 "../sncPauFcomPush.stt" else return (unsigned long) p; # line 60 "../sncPauFcomPush.stt" } # line 61 "../sncPauFcomPush.stt" # line 62 "../sncPauFcomPush.stt" # line 63 "../sncPauFcomPush.stt" static void reportFcom(char *mux_name, unsigned long usrData) # line 64 "../sncPauFcomPush.stt" { # line 65 "../sncPauFcomPush.stt" if(!usrData) return; # line 66 "../sncPauFcomPush.stt" # line 67 "../sncPauFcomPush.stt" usrData_ts *p = (usrData_ts*) usrData; # line 68 "../sncPauFcomPush.stt" # line 69 "../sncPauFcomPush.stt" epicsPrintf("\tsncPauFcomPush: mux (%s), fcomPV (%s), fcomID (0x%8x), pUsr (%8p), pBlob (%8p)\n", # line 70 "../sncPauFcomPush.stt" mux_name, p->fcomPVName, (unsigned int) p->fcomId, p, p->pBlob); # line 71 "../sncPauFcomPush.stt" # line 72 "../sncPauFcomPush.stt" } # line 73 "../sncPauFcomPush.stt" # line 74 "../sncPauFcomPush.stt" # line 75 "../sncPauFcomPush.stt" static int pushFcom(unsigned long usrData, double value) # line 76 "../sncPauFcomPush.stt" { # line 77 "../sncPauFcomPush.stt" if(!usrData) return -1; # line 78 "../sncPauFcomPush.stt" # line 79 "../sncPauFcomPush.stt" usrData_ts *pUsr = (usrData_ts *) usrData; # line 80 "../sncPauFcomPush.stt" FcomBlob *pBlob = pUsr->pBlob; # line 81 "../sncPauFcomPush.stt" # line 82 "../sncPauFcomPush.stt" epicsTimeStamp timestamp; # line 83 "../sncPauFcomPush.stt" # line 84 "../sncPauFcomPush.stt" pUsr->pushVal = value; # line 85 "../sncPauFcomPush.stt" # line 86 "../sncPauFcomPush.stt" epicsTimeGetCurrent(×tamp); # line 87 "../sncPauFcomPush.stt" # line 88 "../sncPauFcomPush.stt" pBlob->fc_vers = FCOM_PROTO_VERSION; # line 89 "../sncPauFcomPush.stt" pBlob->fc_tsHi = timestamp.secPastEpoch; # line 90 "../sncPauFcomPush.stt" pBlob->fc_tsLo = timestamp.nsec; # line 91 "../sncPauFcomPush.stt" pBlob->fc_stat = 0; # line 92 "../sncPauFcomPush.stt" pBlob->fc_type = FCOM_EL_DOUBLE; # line 93 "../sncPauFcomPush.stt" pBlob->fc_nelm = 1; # line 94 "../sncPauFcomPush.stt" pBlob->fc_idnt = pUsr->fcomId; # line 95 "../sncPauFcomPush.stt" pBlob->fc_dbl = &pUsr->pushVal; # line 96 "../sncPauFcomPush.stt" # line 97 "../sncPauFcomPush.stt" pUsr->status = fcomPutBlob(pBlob); # line 98 "../sncPauFcomPush.stt" # line 99 "../sncPauFcomPush.stt" # line 100 "../sncPauFcomPush.stt" if(!pUsr->status) pUsr->succCnt++; # line 101 "../sncPauFcomPush.stt" else pUsr->failCnt++; # line 102 "../sncPauFcomPush.stt" # line 103 "../sncPauFcomPush.stt" return pUsr->status; # line 104 "../sncPauFcomPush.stt" } # line 105 "../sncPauFcomPush.stt" # line 106 "../sncPauFcomPush.stt" # line 106 "../sncPauFcomPush.stt" /* Entry handler */ static void entry_handler(SS_ID ssId, struct UserVar *pVar) { } /* Code for state "init" in state set "fcomPush" */ /* Entry function for state "init" in state set "fcomPush" */ static void I_fcomPush_init(SS_ID ssId, struct UserVar *pVar) { /* Entry 1: */ # line 140 "../sncPauFcomPush.stt" (pVar->muxName) = seq_macValueGet(ssId, "MUX_NAME"); # line 141 "../sncPauFcomPush.stt" (pVar->fcomName) = seq_macValueGet(ssId, "FCOM_NAME"); # line 142 "../sncPauFcomPush.stt" if ((pVar->fcomName)) (pVar->muxName) = (pVar->fcomName); # line 146 "../sncPauFcomPush.stt" for ((pVar->i) = 0; (pVar->i) < 4; (pVar->i)++) { (pVar->userData)[(pVar->i)] = initFcom((pVar->muxName), (pVar->i)); } } /* Exit function for state "init" in state set "fcomPush" */ static void O_fcomPush_init(SS_ID ssId, struct UserVar *pVar) { /* Exit 1: */ # line 155 "../sncPauFcomPush.stt" for ((pVar->i) = 0; (pVar->i) < 4; (pVar->i)++) { reportFcom((pVar->muxName), (pVar->userData)[(pVar->i)]); } } /* Delay function for state "init" in state set "fcomPush" */ static void D_fcomPush_init(SS_ID ssId, struct UserVar *pVar) { # line 150 "../sncPauFcomPush.stt" seq_delayInit(ssId, 0, (1.)); } /* Event function for state "init" in state set "fcomPush" */ static long E_fcomPush_init(SS_ID ssId, struct UserVar *pVar, short *pTransNum, short *pNextState) { # line 150 "../sncPauFcomPush.stt" if (seq_delay(ssId, 0)) { *pNextState = 1; *pTransNum = 0; return TRUE; } return FALSE; } /* Action function for state "init" in state set "fcomPush" */ static void A_fcomPush_init(SS_ID ssId, struct UserVar *pVar, short transNum) { switch(transNum) { case 0: { } return; } } /* Code for state "deactivate" in state set "fcomPush" */ /* Delay function for state "deactivate" in state set "fcomPush" */ static void D_fcomPush_deactivate(SS_ID ssId, struct UserVar *pVar) { # line 160 "../sncPauFcomPush.stt" } /* Event function for state "deactivate" in state set "fcomPush" */ static long E_fcomPush_deactivate(SS_ID ssId, struct UserVar *pVar, short *pTransNum, short *pNextState) { # line 160 "../sncPauFcomPush.stt" if (!(pVar->feedback_mode)) { *pNextState = 2; *pTransNum = 0; return TRUE; } return FALSE; } /* Action function for state "deactivate" in state set "fcomPush" */ static void A_fcomPush_deactivate(SS_ID ssId, struct UserVar *pVar, short transNum) { switch(transNum) { case 0: { } return; } } /* Code for state "activate" in state set "fcomPush" */ /* Delay function for state "activate" in state set "fcomPush" */ static void D_fcomPush_activate(SS_ID ssId, struct UserVar *pVar) { # line 166 "../sncPauFcomPush.stt" # line 172 "../sncPauFcomPush.stt" # line 176 "../sncPauFcomPush.stt" # line 180 "../sncPauFcomPush.stt" # line 184 "../sncPauFcomPush.stt" } /* Event function for state "activate" in state set "fcomPush" */ static long E_fcomPush_activate(SS_ID ssId, struct UserVar *pVar, short *pTransNum, short *pNextState) { # line 166 "../sncPauFcomPush.stt" if ((pVar->feedback_mode)) { *pNextState = 1; *pTransNum = 0; return TRUE; } # line 172 "../sncPauFcomPush.stt" if (seq_efTestAndClear(ssId, ev_data0)) { *pNextState = 2; *pTransNum = 1; return TRUE; } # line 176 "../sncPauFcomPush.stt" if (seq_efTestAndClear(ssId, ev_data1)) { *pNextState = 2; *pTransNum = 2; return TRUE; } # line 180 "../sncPauFcomPush.stt" if (seq_efTestAndClear(ssId, ev_data2)) { *pNextState = 2; *pTransNum = 3; return TRUE; } # line 184 "../sncPauFcomPush.stt" if (seq_efTestAndClear(ssId, ev_data3)) { *pNextState = 2; *pTransNum = 4; return TRUE; } return FALSE; } /* Action function for state "activate" in state set "fcomPush" */ static void A_fcomPush_activate(SS_ID ssId, struct UserVar *pVar, short transNum) { switch(transNum) { case 0: { } return; case 1: { # line 171 "../sncPauFcomPush.stt" pushFcom((pVar->userData)[0], (pVar->static_data)[0]); } return; case 2: { # line 175 "../sncPauFcomPush.stt" pushFcom((pVar->userData)[1], (pVar->static_data)[1]); } return; case 3: { # line 179 "../sncPauFcomPush.stt" pushFcom((pVar->userData)[2], (pVar->static_data)[2]); } return; case 4: { # line 183 "../sncPauFcomPush.stt" pushFcom((pVar->userData)[3], (pVar->static_data)[3]); } return; } } /* Exit handler */ static void exit_handler(SS_ID ssId, struct UserVar *pVar) { } /************************ Tables ***********************/ /* Database Blocks */ static struct seqChan seqChan[NUM_CHANNELS] = { {"{MUX_NAME}:FBCK", (void *)OFFSET(struct UserVar, feedback_mode), "feedback_mode", "int", 1, 5, 0, 1, 0, 0, 0}, {"{MUX_NAME}:SETDATA_0", (void *)OFFSET(struct UserVar, static_data[0]), "static_data[0]", "double", 1, 6, 1, 1, 0, 0, 0}, {"{MUX_NAME}:SETDATA_1", (void *)OFFSET(struct UserVar, static_data[1]), "static_data[1]", "double", 1, 7, 2, 1, 0, 0, 0}, {"{MUX_NAME}:SETDATA_2", (void *)OFFSET(struct UserVar, static_data[2]), "static_data[2]", "double", 1, 8, 3, 1, 0, 0, 0}, {"{MUX_NAME}:SETDATA_3", (void *)OFFSET(struct UserVar, static_data[3]), "static_data[3]", "double", 1, 9, 4, 1, 0, 0, 0}, }; /* Event masks for state set fcomPush */ /* Event mask for state init: */ static bitMask EM_fcomPush_init[] = { 0x00000000, }; /* Event mask for state deactivate: */ static bitMask EM_fcomPush_deactivate[] = { 0x00000020, }; /* Event mask for state activate: */ static bitMask EM_fcomPush_activate[] = { 0x0000003e, }; /* State Blocks */ static struct seqState state_fcomPush[] = { /* State "init" */ { /* state name */ "init", /* action function */ (ACTION_FUNC) A_fcomPush_init, /* event function */ (EVENT_FUNC) E_fcomPush_init, /* delay function */ (DELAY_FUNC) D_fcomPush_init, /* entry function */ (ENTRY_FUNC) I_fcomPush_init, /* exit function */ (EXIT_FUNC) O_fcomPush_init, /* event mask array */ EM_fcomPush_init, /* state options */ (0)}, /* State "deactivate" */ { /* state name */ "deactivate", /* action function */ (ACTION_FUNC) A_fcomPush_deactivate, /* event function */ (EVENT_FUNC) E_fcomPush_deactivate, /* delay function */ (DELAY_FUNC) D_fcomPush_deactivate, /* entry function */ (ENTRY_FUNC) 0, /* exit function */ (EXIT_FUNC) 0, /* event mask array */ EM_fcomPush_deactivate, /* state options */ (0)}, /* State "activate" */ { /* state name */ "activate", /* action function */ (ACTION_FUNC) A_fcomPush_activate, /* event function */ (EVENT_FUNC) E_fcomPush_activate, /* delay function */ (DELAY_FUNC) D_fcomPush_activate, /* entry function */ (ENTRY_FUNC) 0, /* exit function */ (EXIT_FUNC) 0, /* event mask array */ EM_fcomPush_activate, /* state options */ (0)}, }; /* State Set Blocks */ static struct seqSS seqSS[NUM_SS] = { /* State set "fcomPush" */ { /* ss name */ "fcomPush", /* ptr to state block */ state_fcomPush, /* number of states */ 3, /* error state */ -1}, }; /* Program parameter list */ static char prog_param[] = ""; /* State Program table (global) */ struct seqProgram sncPauFcomPush = { /* magic number */ 20000315, /* *name */ "sncPauFcomPush", /* *pChannels */ seqChan, /* numChans */ NUM_CHANNELS, /* *pSS */ seqSS, /* numSS */ NUM_SS, /* user variable size */ sizeof(struct UserVar), /* *pParams */ prog_param, /* numEvents */ NUM_EVENTS, /* encoded options */ (0 | OPT_CONN | OPT_NEWEF | OPT_REENT), /* entry handler */ (ENTRY_FUNC) entry_handler, /* exit handler */ (EXIT_FUNC) exit_handler, /* numQueues */ NUM_QUEUES, }; /* Register sequencer commands and program */ void sncPauFcomPushRegistrar (void) { seqRegisterSequencerCommands(); seqRegisterSequencerProgram (&sncPauFcomPush); } epicsExportRegistrar(sncPauFcomPushRegistrar);