/* SNC Version 2.0.11: Tue Apr 10 11:29:17 2012: sncExOpt.i */ /* Event flags */ /* Program "snctest" */ #include "seqCom.h" #define NUM_SS 1 #define NUM_CHANNELS 1 #define NUM_EVENTS 0 #define NUM_QUEUES 0 #define MAX_STRING_SIZE 40 #define ASYNC_OPT FALSE #define CONN_OPT TRUE #define DEBUG_OPT FALSE #define MAIN_OPT TRUE #define NEWEF_OPT TRUE #define REENT_OPT FALSE extern struct seqProgram snctest; /* Main program */ #include #include "epicsThread.h" #include "iocsh.h" int main(int argc,char *argv[]) { char * macro_def; epicsThreadId threadId; int callIocsh = 0; if(argc>1 && strcmp(argv[1],"-s")==0) { callIocsh=1; --argc; ++argv; } macro_def = (argc>1)?argv[1]:NULL; threadId = seq((void *)&snctest, macro_def, 0); if(callIocsh) { seqRegisterSequencerCommands(); iocsh(0); } else { epicsThreadExitMain(); } return(0); } /* Variable declarations */ static float v; /* Not used (avoids compilation warnings) */ struct UserVar { int dummy; }; /* Entry handler */ static void entry_handler(SS_ID ssId, struct UserVar *pVar) { } /* Code for state "low" in state set "ss1" */ /* Entry function for state "low" in state set "ss1" */ static void I_ss1_low(SS_ID ssId, struct UserVar *pVar) { /* Entry 1: */ # line 13 "../sncExOpt.st" printf("Will do this on entry"); # line 14 "../sncExOpt.st" printf("Another thing to do on entry"); } /* Delay function for state "low" in state set "ss1" */ static void D_ss1_low(SS_ID ssId, struct UserVar *pVar) { # line 19 "../sncExOpt.st" # line 23 "../sncExOpt.st" seq_delayInit(ssId, 0, (.1)); } /* Event function for state "low" in state set "ss1" */ static long E_ss1_low(SS_ID ssId, struct UserVar *pVar, short *pTransNum, short *pNextState) { # line 19 "../sncExOpt.st" if (v > 5.0) { *pNextState = 1; *pTransNum = 0; return TRUE; } # line 23 "../sncExOpt.st" if (seq_delay(ssId, 0)) { *pNextState = 0; *pTransNum = 1; return TRUE; } return FALSE; } /* Action function for state "low" in state set "ss1" */ static void A_ss1_low(SS_ID ssId, struct UserVar *pVar, short transNum) { switch(transNum) { case 0: { # line 18 "../sncExOpt.st" printf("now changing to high\n"); } return; case 1: { } return; } } /* Code for state "high" in state set "ss1" */ /* Delay function for state "high" in state set "ss1" */ static void D_ss1_high(SS_ID ssId, struct UserVar *pVar) { # line 31 "../sncExOpt.st" # line 37 "../sncExOpt.st" seq_delayInit(ssId, 0, (.1)); } /* Event function for state "high" in state set "ss1" */ static long E_ss1_high(SS_ID ssId, struct UserVar *pVar, short *pTransNum, short *pNextState) { # line 31 "../sncExOpt.st" if (v <= 5.0) { *pNextState = 0; *pTransNum = 0; return TRUE; } # line 37 "../sncExOpt.st" if (seq_delay(ssId, 0)) { *pNextState = 1; *pTransNum = 1; return TRUE; } return FALSE; } /* Action function for state "high" in state set "ss1" */ static void A_ss1_high(SS_ID ssId, struct UserVar *pVar, short transNum) { switch(transNum) { case 0: { # line 30 "../sncExOpt.st" printf("changing to low\n"); } return; case 1: { } return; } } /* Exit handler */ static void exit_handler(SS_ID ssId, struct UserVar *pVar) { } /************************ Tables ***********************/ /* Database Blocks */ static struct seqChan seqChan[NUM_CHANNELS] = { {"{user}:xxxExample", (void *)&v, "v", "float", 1, 1, 0, 1, 0, 0, 0}, }; /* Event masks for state set ss1 */ /* Event mask for state low: */ static bitMask EM_ss1_low[] = { 0x00000002, }; /* Event mask for state high: */ static bitMask EM_ss1_high[] = { 0x00000002, }; /* State Blocks */ static struct seqState state_ss1[] = { /* State "low" */ { /* state name */ "low", /* action function */ (ACTION_FUNC) A_ss1_low, /* event function */ (EVENT_FUNC) E_ss1_low, /* delay function */ (DELAY_FUNC) D_ss1_low, /* entry function */ (ENTRY_FUNC) I_ss1_low, /* exit function */ (EXIT_FUNC) 0, /* event mask array */ EM_ss1_low, /* state options */ (0)}, /* State "high" */ { /* state name */ "high", /* action function */ (ACTION_FUNC) A_ss1_high, /* event function */ (EVENT_FUNC) E_ss1_high, /* delay function */ (DELAY_FUNC) D_ss1_high, /* entry function */ (ENTRY_FUNC) 0, /* exit function */ (EXIT_FUNC) 0, /* event mask array */ EM_ss1_high, /* state options */ (0 | OPT_NORESETTIMERS)}, }; /* State Set Blocks */ static struct seqSS seqSS[NUM_SS] = { /* State set "ss1" */ { /* ss name */ "ss1", /* ptr to state block */ state_ss1, /* number of states */ 2, /* error state */ -1}, }; /* Program parameter list */ static char prog_param[] = ""; /* State Program table (global) */ struct seqProgram snctest = { /* magic number */ 20000315, /* *name */ "snctest", /* *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 | OPT_MAIN), /* entry handler */ (ENTRY_FUNC) entry_handler, /* exit handler */ (EXIT_FUNC) exit_handler, /* numQueues */ NUM_QUEUES, }; /* Register sequencer commands and program */ void snctestRegistrar (void) { seqRegisterSequencerCommands(); seqRegisterSequencerProgram (&snctest); } epicsExportRegistrar(snctestRegistrar);