/* SNC Version 2.0.11: Fri May 27 10:07:33 2011: ../sncExample.stt */ /* Event flags */ /* Program "sncExample" */ #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 FALSE #define NEWEF_OPT TRUE #define REENT_OPT TRUE extern struct seqProgram sncExample; /* Variable declarations */ struct UserVar { double v; }; /* Entry handler */ static void entry_handler(SS_ID ssId, struct UserVar *pVar) { } /* Code for state "init" in state set "ss1" */ /* Delay function for state "init" in state set "ss1" */ static void D_ss1_init(SS_ID ssId, struct UserVar *pVar) { # line 10 "../sncExample.stt" seq_delayInit(ssId, 0, (10)); } /* Event function for state "init" in state set "ss1" */ static long E_ss1_init(SS_ID ssId, struct UserVar *pVar, short *pTransNum, short *pNextState) { # line 10 "../sncExample.stt" if (seq_delay(ssId, 0)) { *pNextState = 1; *pTransNum = 0; return TRUE; } return FALSE; } /* Action function for state "init" in state set "ss1" */ static void A_ss1_init(SS_ID ssId, struct UserVar *pVar, short transNum) { switch(transNum) { case 0: { # line 9 "../sncExample.stt" printf("sncExample: Startup delay over\n"); } return; } } /* Code for state "low" in state set "ss1" */ /* Delay function for state "low" in state set "ss1" */ static void D_ss1_low(SS_ID ssId, struct UserVar *pVar) { # line 15 "../sncExample.stt" } /* 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 15 "../sncExample.stt" if ((pVar->v) > 5.0) { *pNextState = 2; *pTransNum = 0; 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 14 "../sncExample.stt" printf("sncExample: Changing to high\n"); } 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 20 "../sncExample.stt" } /* 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 20 "../sncExample.stt" if ((pVar->v) <= 5.0) { *pNextState = 1; *pTransNum = 0; 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 19 "../sncExample.stt" printf("sncExample: Changing to low\n"); } return; } } /* Exit handler */ static void exit_handler(SS_ID ssId, struct UserVar *pVar) { } /************************ Tables ***********************/ /* Database Blocks */ static struct seqChan seqChan[NUM_CHANNELS] = { {"{user}:aiExample", (void *)OFFSET(struct UserVar, v), "v", "double", 1, 1, 0, 1, 0, 0, 0}, }; /* Event masks for state set ss1 */ /* Event mask for state init: */ static bitMask EM_ss1_init[] = { 0x00000000, }; /* 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 "init" */ { /* state name */ "init", /* action function */ (ACTION_FUNC) A_ss1_init, /* event function */ (EVENT_FUNC) E_ss1_init, /* delay function */ (DELAY_FUNC) D_ss1_init, /* entry function */ (ENTRY_FUNC) 0, /* exit function */ (EXIT_FUNC) 0, /* event mask array */ EM_ss1_init, /* state options */ (0)}, /* 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) 0, /* 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)}, }; /* State Set Blocks */ static struct seqSS seqSS[NUM_SS] = { /* State set "ss1" */ { /* ss name */ "ss1", /* ptr to state block */ state_ss1, /* number of states */ 3, /* error state */ -1}, }; /* Program parameter list */ static char prog_param[] = ""; /* State Program table (global) */ struct seqProgram sncExample = { /* magic number */ 20000315, /* *name */ "sncExample", /* *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 sncExampleRegistrar (void) { seqRegisterSequencerCommands(); seqRegisterSequencerProgram (&sncExample); } epicsExportRegistrar(sncExampleRegistrar);