/* SNC Version 2.0.11: Sat Mar 20 15:05:13 2010: sncpad.i */ /* Event flags */ /* Program "sncpad" */ #include "seqCom.h" #define NUM_SS 1 #define NUM_CHANNELS 4 #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 FALSE extern struct seqProgram sncpad; /* Variable declarations */ static int opState; static int calibCtrl; static int intrCtrl; static int softTrig; /* Not used (avoids compilation warnings) */ struct UserVar { int dummy; }; /* C code definitions */ # line 21 "../sncpad.st" #include "padMacros.h" # line 22 "../sncpad.st" #include "drvPad.h" /* Entry handler */ static void entry_handler(SS_ID ssId, struct UserVar *pVar) { } /* Code for state "init" in state set "pad" */ /* Entry function for state "init" in state set "pad" */ static void I_pad_init(SS_ID ssId, struct UserVar *pVar) { /* Entry 1: */ # line 40 "../sncpad.st" printf("sncpad: init\n"); } /* Delay function for state "init" in state set "pad" */ static void D_pad_init(SS_ID ssId, struct UserVar *pVar) { # line 44 "../sncpad.st" seq_delayInit(ssId, 0, (1)); } /* Event function for state "init" in state set "pad" */ static long E_pad_init(SS_ID ssId, struct UserVar *pVar, short *pTransNum, short *pNextState) { # line 44 "../sncpad.st" if (seq_delay(ssId, 0)) { *pNextState = 1; *pTransNum = 0; return TRUE; } return FALSE; } /* Action function for state "init" in state set "pad" */ static void A_pad_init(SS_ID ssId, struct UserVar *pVar, short transNum) { switch(transNum) { case 0: { # line 43 "../sncpad.st" printf("sncpad: operation state set to start-up\n"); } return; } } /* Code for state "startup" in state set "pad" */ /* Entry function for state "startup" in state set "pad" */ static void I_pad_startup(SS_ID ssId, struct UserVar *pVar) { /* Entry 1: */ # line 49 "../sncpad.st" opState = PAD_STARTING; # line 50 "../sncpad.st" seq_pvPut(ssId, 0 /* opState */, 0); # line 51 "../sncpad.st" calibCtrl = PAD_CAL_IDLE; # line 52 "../sncpad.st" seq_pvPut(ssId, 1 /* calibCtrl */, 0); # line 53 "../sncpad.st" printf("sncpad: startup\n"); } /* Delay function for state "startup" in state set "pad" */ static void D_pad_startup(SS_ID ssId, struct UserVar *pVar) { # line 57 "../sncpad.st" seq_delayInit(ssId, 0, (5)); } /* Event function for state "startup" in state set "pad" */ static long E_pad_startup(SS_ID ssId, struct UserVar *pVar, short *pTransNum, short *pNextState) { # line 57 "../sncpad.st" if (seq_delay(ssId, 0)) { *pNextState = 2; *pTransNum = 0; return TRUE; } return FALSE; } /* Action function for state "startup" in state set "pad" */ static void A_pad_startup(SS_ID ssId, struct UserVar *pVar, short transNum) { switch(transNum) { case 0: { # line 56 "../sncpad.st" printf("sncpad: startup complete\n"); } return; } } /* Code for state "running" in state set "pad" */ /* Entry function for state "running" in state set "pad" */ static void I_pad_running(SS_ID ssId, struct UserVar *pVar) { /* Entry 1: */ # line 62 "../sncpad.st" opState = PAD_RUNNING; # line 63 "../sncpad.st" seq_pvPut(ssId, 0 /* opState */, 0); # line 64 "../sncpad.st" intrCtrl = 1; # line 65 "../sncpad.st" seq_pvPut(ssId, 2 /* intrCtrl */, 0); # line 66 "../sncpad.st" printf("sncpad: running. interrupts enabled\n"); } /* Delay function for state "running" in state set "pad" */ static void D_pad_running(SS_ID ssId, struct UserVar *pVar) { # line 70 "../sncpad.st" seq_delayInit(ssId, 0, (1)); # line 76 "../sncpad.st" seq_delayInit(ssId, 1, (2)); } /* Event function for state "running" in state set "pad" */ static long E_pad_running(SS_ID ssId, struct UserVar *pVar, short *pTransNum, short *pNextState) { # line 70 "../sncpad.st" if (seq_delay(ssId, 0) && (calibCtrl == PAD_CAL_RQST)) { *pNextState = 3; *pTransNum = 0; return TRUE; } # line 76 "../sncpad.st" if (seq_delay(ssId, 1) && (calibCtrl == PAD_CAL_DONE)) { *pNextState = 3; *pTransNum = 1; return TRUE; } return FALSE; } /* Action function for state "running" in state set "pad" */ static void A_pad_running(SS_ID ssId, struct UserVar *pVar, short transNum) { switch(transNum) { case 0: { # line 69 "../sncpad.st" printf("sncpad: calibration requested\n"); } return; case 1: { # line 73 "../sncpad.st" printf("sncpad: running. ignoring calibration done button press\n"); calibCtrl = PAD_CAL_IDLE; seq_pvPut(ssId, 1 /* calibCtrl */, 0); } return; } } /* Code for state "calibrating" in state set "pad" */ /* Entry function for state "calibrating" in state set "pad" */ static void I_pad_calibrating(SS_ID ssId, struct UserVar *pVar) { /* Entry 1: */ # line 81 "../sncpad.st" opState = PAD_CALIBRATING; # line 82 "../sncpad.st" seq_pvPut(ssId, 0 /* opState */, 0); # line 84 "../sncpad.st" printf("sncpad: calling calibration subroutine\n"); # line 89 "../sncpad.st" padCalibration(); } /* Delay function for state "calibrating" in state set "pad" */ static void D_pad_calibrating(SS_ID ssId, struct UserVar *pVar) { # line 96 "../sncpad.st" seq_delayInit(ssId, 0, (1)); } /* Event function for state "calibrating" in state set "pad" */ static long E_pad_calibrating(SS_ID ssId, struct UserVar *pVar, short *pTransNum, short *pNextState) { # line 96 "../sncpad.st" if (seq_delay(ssId, 0) || (calibCtrl == PAD_CAL_DONE)) { *pNextState = 4; *pTransNum = 0; return TRUE; } return FALSE; } /* Action function for state "calibrating" in state set "pad" */ static void A_pad_calibrating(SS_ID ssId, struct UserVar *pVar, short transNum) { switch(transNum) { case 0: { # line 95 "../sncpad.st" printf("sncpad: calibration done\n"); } return; } } /* Code for state "calibration_done" in state set "pad" */ /* Entry function for state "calibration_done" in state set "pad" */ static void I_pad_calibration_done(SS_ID ssId, struct UserVar *pVar) { /* Entry 1: */ # line 103 "../sncpad.st" opState = PAD_CALIBRATION_DONE; # line 104 "../sncpad.st" seq_pvPut(ssId, 0 /* opState */, 0); } /* Delay function for state "calibration_done" in state set "pad" */ static void D_pad_calibration_done(SS_ID ssId, struct UserVar *pVar) { # line 112 "../sncpad.st" seq_delayInit(ssId, 0, (1)); } /* Event function for state "calibration_done" in state set "pad" */ static long E_pad_calibration_done(SS_ID ssId, struct UserVar *pVar, short *pTransNum, short *pNextState) { # line 112 "../sncpad.st" if (seq_delay(ssId, 0)) { *pNextState = 2; *pTransNum = 0; return TRUE; } return FALSE; } /* Action function for state "calibration_done" in state set "pad" */ static void A_pad_calibration_done(SS_ID ssId, struct UserVar *pVar, short transNum) { switch(transNum) { case 0: { # line 109 "../sncpad.st" calibCtrl = PAD_CAL_IDLE; seq_pvPut(ssId, 1 /* calibCtrl */, 0); printf("sncpad: resume running\n"); } return; } } /* Exit handler */ static void exit_handler(SS_ID ssId, struct UserVar *pVar) { } /************************ Tables ***********************/ /* Database Blocks */ static struct seqChan seqChan[NUM_CHANNELS] = { {"{PRIM}:{LOCA}:{UNIT}:{PAD}_D_STATE", (void *)&opState, "opState", "int", 1, 1, 0, 1, 0, 0, 0}, {"{PRIM}:{LOCA}:{UNIT}:{PAD}_D_CALIB", (void *)&calibCtrl, "calibCtrl", "int", 1, 2, 0, 1, 0, 0, 0}, {"{PRIM}:{LOCA}:{UNIT}:{PAD}_INT_CTRL", (void *)&intrCtrl, "intrCtrl", "int", 1, 3, 0, 1, 0, 0, 0}, {"{PRIM}:{LOCA}:{UNIT}:{PAD}_SOFT_TRG", (void *)&softTrig, "softTrig", "int", 1, 4, 0, 1, 0, 0, 0}, }; /* Event masks for state set pad */ /* Event mask for state init: */ static bitMask EM_pad_init[] = { 0x00000000, }; /* Event mask for state startup: */ static bitMask EM_pad_startup[] = { 0x00000000, }; /* Event mask for state running: */ static bitMask EM_pad_running[] = { 0x00000004, }; /* Event mask for state calibrating: */ static bitMask EM_pad_calibrating[] = { 0x00000004, }; /* Event mask for state calibration_done: */ static bitMask EM_pad_calibration_done[] = { 0x00000000, }; /* State Blocks */ static struct seqState state_pad[] = { /* State "init" */ { /* state name */ "init", /* action function */ (ACTION_FUNC) A_pad_init, /* event function */ (EVENT_FUNC) E_pad_init, /* delay function */ (DELAY_FUNC) D_pad_init, /* entry function */ (ENTRY_FUNC) I_pad_init, /* exit function */ (EXIT_FUNC) 0, /* event mask array */ EM_pad_init, /* state options */ (0)}, /* State "startup" */ { /* state name */ "startup", /* action function */ (ACTION_FUNC) A_pad_startup, /* event function */ (EVENT_FUNC) E_pad_startup, /* delay function */ (DELAY_FUNC) D_pad_startup, /* entry function */ (ENTRY_FUNC) I_pad_startup, /* exit function */ (EXIT_FUNC) 0, /* event mask array */ EM_pad_startup, /* state options */ (0)}, /* State "running" */ { /* state name */ "running", /* action function */ (ACTION_FUNC) A_pad_running, /* event function */ (EVENT_FUNC) E_pad_running, /* delay function */ (DELAY_FUNC) D_pad_running, /* entry function */ (ENTRY_FUNC) I_pad_running, /* exit function */ (EXIT_FUNC) 0, /* event mask array */ EM_pad_running, /* state options */ (0)}, /* State "calibrating" */ { /* state name */ "calibrating", /* action function */ (ACTION_FUNC) A_pad_calibrating, /* event function */ (EVENT_FUNC) E_pad_calibrating, /* delay function */ (DELAY_FUNC) D_pad_calibrating, /* entry function */ (ENTRY_FUNC) I_pad_calibrating, /* exit function */ (EXIT_FUNC) 0, /* event mask array */ EM_pad_calibrating, /* state options */ (0)}, /* State "calibration_done" */ { /* state name */ "calibration_done", /* action function */ (ACTION_FUNC) A_pad_calibration_done, /* event function */ (EVENT_FUNC) E_pad_calibration_done, /* delay function */ (DELAY_FUNC) D_pad_calibration_done, /* entry function */ (ENTRY_FUNC) I_pad_calibration_done, /* exit function */ (EXIT_FUNC) 0, /* event mask array */ EM_pad_calibration_done, /* state options */ (0)}, }; /* State Set Blocks */ static struct seqSS seqSS[NUM_SS] = { /* State set "pad" */ { /* ss name */ "pad", /* ptr to state block */ state_pad, /* number of states */ 5, /* error state */ -1}, }; /* Program parameter list */ static char prog_param[] = ""; /* State Program table (global) */ struct seqProgram sncpad = { /* magic number */ 20000315, /* *name */ "sncpad", /* *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), /* entry handler */ (ENTRY_FUNC) entry_handler, /* exit handler */ (EXIT_FUNC) exit_handler, /* numQueues */ NUM_QUEUES, }; /* Register sequencer commands and program */ void sncpadRegistrar (void) { seqRegisterSequencerCommands(); seqRegisterSequencerProgram (&sncpad); } epicsExportRegistrar(sncpadRegistrar);