/* C code for program chirpControl, generated by snc from ../chirpControl.st */ #include #include #include #include #include "seq_snc.h" /* Variable declarations */ # line 3 "../chirpControl.st" static short chirpState; # line 7 "../chirpControl.st" static double chirpValue; # line 12 "../chirpControl.st" static double chirpDesired; # line 15 "../chirpControl.st" static short chirpReady; /* Function declarations */ #define seqg_var (*(struct seqg_vars *const *)seqg_env) /* Program init func */ static void seqg_init(PROG_ID seqg_env) { } /****** Code for state "INIT" in state set "chirpCheck" ******/ /* Event function for state "INIT" in state set "chirpCheck" */ static seqBool seqg_event_chirpCheck_0_INIT(SS_ID seqg_env, int *seqg_ptrn, int *seqg_pnst) { if (TRUE) { *seqg_pnst = 1; *seqg_ptrn = 0; return TRUE; } return FALSE; } /* Action function for state "INIT" in state set "chirpCheck" */ static void seqg_action_chirpCheck_0_INIT(SS_ID seqg_env, int seqg_trn, int *seqg_pnst) { switch(seqg_trn) { case 0: { # line 21 "../chirpControl.st" printf("*** INIT chirpCheck ***\n"); # line 22 "../chirpControl.st" seq_pvGetTmo(seqg_env, 1/*chirpValue*/, SYNC, DEFAULT_TIMEOUT); # line 23 "../chirpControl.st" printf("*** INITAL STATE *** %f ***\n", chirpValue); } return; } } /****** Code for state "CHIRP_OFF" in state set "chirpCheck" ******/ /* Event function for state "CHIRP_OFF" in state set "chirpCheck" */ static seqBool seqg_event_chirpCheck_0_CHIRP_OFF(SS_ID seqg_env, int *seqg_ptrn, int *seqg_pnst) { # line 29 "../chirpControl.st" if (chirpState > 0) { *seqg_pnst = 2; *seqg_ptrn = 0; return TRUE; } return FALSE; } /* Action function for state "CHIRP_OFF" in state set "chirpCheck" */ static void seqg_action_chirpCheck_0_CHIRP_OFF(SS_ID seqg_env, int seqg_trn, int *seqg_pnst) { switch(seqg_trn) { case 0: { # line 30 "../chirpControl.st" printf("CHIRP went ON - getting current CHIRP\n"); # line 31 "../chirpControl.st" seq_pvGetTmo(seqg_env, 1/*chirpValue*/, ASYNC, DEFAULT_TIMEOUT); # line 32 "../chirpControl.st" chirpReady = 0; # line 33 "../chirpControl.st" seq_pvPutTmo(seqg_env, 3/*chirpReady*/, ASYNC, DEFAULT_TIMEOUT); } return; } } /****** Code for state "WAIT_CHIRP" in state set "chirpCheck" ******/ /* Event function for state "WAIT_CHIRP" in state set "chirpCheck" */ static seqBool seqg_event_chirpCheck_0_WAIT_CHIRP(SS_ID seqg_env, int *seqg_ptrn, int *seqg_pnst) { # line 38 "../chirpControl.st" if (seq_pvGetComplete(seqg_env, 1/*chirpValue*/) && seq_pvPutComplete(seqg_env, 3/*chirpReady*/, 1, FALSE, NULL)) { *seqg_pnst = 3; *seqg_ptrn = 0; return TRUE; } return FALSE; } /* Action function for state "WAIT_CHIRP" in state set "chirpCheck" */ static void seqg_action_chirpCheck_0_WAIT_CHIRP(SS_ID seqg_env, int seqg_trn, int *seqg_pnst) { switch(seqg_trn) { case 0: { # line 39 "../chirpControl.st" printf("CHIRP went ON - setting CHIRPDES\n"); # line 40 "../chirpControl.st" chirpDesired = chirpValue; # line 41 "../chirpControl.st" seq_pvPutTmo(seqg_env, 2/*chirpDesired*/, SYNC, DEFAULT_TIMEOUT); # line 42 "../chirpControl.st" chirpReady = 1; # line 43 "../chirpControl.st" seq_pvPutTmo(seqg_env, 3/*chirpReady*/, ASYNC, DEFAULT_TIMEOUT); } return; } } /****** Code for state "WAIT_CHIRP_READY" in state set "chirpCheck" ******/ /* Event function for state "WAIT_CHIRP_READY" in state set "chirpCheck" */ static seqBool seqg_event_chirpCheck_0_WAIT_CHIRP_READY(SS_ID seqg_env, int *seqg_ptrn, int *seqg_pnst) { # line 48 "../chirpControl.st" if (seq_pvPutComplete(seqg_env, 3/*chirpReady*/, 1, FALSE, NULL)) { *seqg_pnst = 4; *seqg_ptrn = 0; return TRUE; } return FALSE; } /* Action function for state "WAIT_CHIRP_READY" in state set "chirpCheck" */ static void seqg_action_chirpCheck_0_WAIT_CHIRP_READY(SS_ID seqg_env, int seqg_trn, int *seqg_pnst) { switch(seqg_trn) { case 0: { # line 49 "../chirpControl.st" printf("CHIRPREADY has been set to YES\n"); } return; } } /****** Code for state "CHIRP_ON" in state set "chirpCheck" ******/ /* Event function for state "CHIRP_ON" in state set "chirpCheck" */ static seqBool seqg_event_chirpCheck_0_CHIRP_ON(SS_ID seqg_env, int *seqg_ptrn, int *seqg_pnst) { # line 55 "../chirpControl.st" if (chirpState <= 0) { *seqg_pnst = 5; *seqg_ptrn = 0; return TRUE; } return FALSE; } /* Action function for state "CHIRP_ON" in state set "chirpCheck" */ static void seqg_action_chirpCheck_0_CHIRP_ON(SS_ID seqg_env, int seqg_trn, int *seqg_pnst) { switch(seqg_trn) { case 0: { # line 56 "../chirpControl.st" printf("CHIRP went OFF\n"); } return; } } /****** Code for state "WAIT_CHIRP_NOT_READY" in state set "chirpCheck" ******/ /* Event function for state "WAIT_CHIRP_NOT_READY" in state set "chirpCheck" */ static seqBool seqg_event_chirpCheck_0_WAIT_CHIRP_NOT_READY(SS_ID seqg_env, int *seqg_ptrn, int *seqg_pnst) { # line 61 "../chirpControl.st" if (seq_pvPutComplete(seqg_env, 3/*chirpReady*/, 1, FALSE, NULL)) { *seqg_pnst = 1; *seqg_ptrn = 0; return TRUE; } return FALSE; } /* Action function for state "WAIT_CHIRP_NOT_READY" in state set "chirpCheck" */ static void seqg_action_chirpCheck_0_WAIT_CHIRP_NOT_READY(SS_ID seqg_env, int seqg_trn, int *seqg_pnst) { switch(seqg_trn) { case 0: { # line 62 "../chirpControl.st" chirpReady = 0; # line 63 "../chirpControl.st" seq_pvPutTmo(seqg_env, 3/*chirpReady*/, ASYNC, DEFAULT_TIMEOUT); # line 64 "../chirpControl.st" printf("CHIRPREADY has been set to NO\n"); } return; } } #undef seqg_var /************************ Tables ************************/ /* Channel table */ static seqChan seqg_chans[] = { /* chName, offset, varName, varType, count, eventNum, efId, monitored, queueSize, queueIndex */ {"FBCK:{IOC}:{LOOP}:CHIRPSTATE", (size_t)&chirpState, "chirpState", P_SHORT, 1, 1, 0, 1, 0, 0}, {"FBCK:LI22:1:CHIRP", (size_t)&chirpValue, "chirpValue", P_DOUBLE, 1, 2, 0, 0, 0, 0}, {"FBCK:{IOC}:{LOOP}:CHIRPDES", (size_t)&chirpDesired, "chirpDesired", P_DOUBLE, 1, 3, 0, 0, 0, 0}, {"FBCK:{IOC}:{LOOP}:CHIRPREADY", (size_t)&chirpReady, "chirpReady", P_SHORT, 1, 4, 0, 0, 0, 0}, }; /* Event masks for state set "chirpCheck" */ static const seqMask seqg_mask_chirpCheck_0_INIT[] = { 0x00000000, }; static const seqMask seqg_mask_chirpCheck_0_CHIRP_OFF[] = { 0x00000002, }; static const seqMask seqg_mask_chirpCheck_0_WAIT_CHIRP[] = { 0x00000014, }; static const seqMask seqg_mask_chirpCheck_0_WAIT_CHIRP_READY[] = { 0x00000010, }; static const seqMask seqg_mask_chirpCheck_0_CHIRP_ON[] = { 0x00000002, }; static const seqMask seqg_mask_chirpCheck_0_WAIT_CHIRP_NOT_READY[] = { 0x00000010, }; /* State table for state set "chirpCheck" */ static seqState seqg_states_chirpCheck[] = { { /* state name */ "INIT", /* action function */ seqg_action_chirpCheck_0_INIT, /* event function */ seqg_event_chirpCheck_0_INIT, /* entry function */ 0, /* exit function */ 0, /* event mask array */ seqg_mask_chirpCheck_0_INIT, /* state options */ (0) }, { /* state name */ "CHIRP_OFF", /* action function */ seqg_action_chirpCheck_0_CHIRP_OFF, /* event function */ seqg_event_chirpCheck_0_CHIRP_OFF, /* entry function */ 0, /* exit function */ 0, /* event mask array */ seqg_mask_chirpCheck_0_CHIRP_OFF, /* state options */ (0) }, { /* state name */ "WAIT_CHIRP", /* action function */ seqg_action_chirpCheck_0_WAIT_CHIRP, /* event function */ seqg_event_chirpCheck_0_WAIT_CHIRP, /* entry function */ 0, /* exit function */ 0, /* event mask array */ seqg_mask_chirpCheck_0_WAIT_CHIRP, /* state options */ (0) }, { /* state name */ "WAIT_CHIRP_READY", /* action function */ seqg_action_chirpCheck_0_WAIT_CHIRP_READY, /* event function */ seqg_event_chirpCheck_0_WAIT_CHIRP_READY, /* entry function */ 0, /* exit function */ 0, /* event mask array */ seqg_mask_chirpCheck_0_WAIT_CHIRP_READY, /* state options */ (0) }, { /* state name */ "CHIRP_ON", /* action function */ seqg_action_chirpCheck_0_CHIRP_ON, /* event function */ seqg_event_chirpCheck_0_CHIRP_ON, /* entry function */ 0, /* exit function */ 0, /* event mask array */ seqg_mask_chirpCheck_0_CHIRP_ON, /* state options */ (0) }, { /* state name */ "WAIT_CHIRP_NOT_READY", /* action function */ seqg_action_chirpCheck_0_WAIT_CHIRP_NOT_READY, /* event function */ seqg_event_chirpCheck_0_WAIT_CHIRP_NOT_READY, /* entry function */ 0, /* exit function */ 0, /* event mask array */ seqg_mask_chirpCheck_0_WAIT_CHIRP_NOT_READY, /* state options */ (0) }, }; /* State set table */ static seqSS seqg_statesets[] = { { /* state set name */ "chirpCheck", /* states */ seqg_states_chirpCheck, /* number of states */ 6 }, }; /* Program table (global) */ seqProgram chirpControl = { /* magic number */ 2002004, /* program name */ "chirpControl", /* channels */ seqg_chans, /* num. channels */ 4, /* state sets */ seqg_statesets, /* num. state sets */ 1, /* user var size */ 0, /* param */ "", /* num. event flags */ 0, /* encoded options */ (0 | OPT_CONN | OPT_NEWEF), /* init func */ seqg_init, /* entry func */ 0, /* exit func */ 0, /* num. queues */ 0 }; /* Register sequencer commands and program */ #include "epicsExport.h" static void chirpControlRegistrar (void) { seqRegisterSequencerCommands(); seqRegisterSequencerProgram (&chirpControl); } epicsExportRegistrar(chirpControlRegistrar);