/* C code for program LHUtrimtest, generated by snc from ../LHUtrimtest.stt */ #include #include #include #include #include "seq_snc.h" # line 35 "../LHUtrimtest.stt" #include # line 37 "../LHUtrimtest.stt" static void outputMessage(char* deviceName, char* message); /* Variable declarations */ struct seqg_vars { # line 40 "../LHUtrimtest.stt" short trimCmd; # line 41 "../LHUtrimtest.stt" short movedSts; # line 42 "../LHUtrimtest.stt" short trimSts; # line 43 "../LHUtrimtest.stt" double moveDes; # line 44 "../LHUtrimtest.stt" short correctCmd; # line 45 "../LHUtrimtest.stt" short correctSts; # line 47 "../LHUtrimtest.stt" double moveValCmd; # line 48 "../LHUtrimtest.stt" short enableCmd; # line 50 "../LHUtrimtest.stt" char *deviceName; # line 52 "../LHUtrimtest.stt" short DEBUG_T; }; /* 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 "trim" in state set "motorTrim" ******/ /* Entry function for state "trim" in state set "motorTrim" */ static void seqg_entry_motorTrim_0_trim(SS_ID seqg_env) { # line 58 "../LHUtrimtest.stt" if (seqg_var->DEBUG_T) # line 58 "../LHUtrimtest.stt" outputMessage(seqg_var->deviceName, "Entering Trim sequence program"); } /* Event function for state "trim" in state set "motorTrim" */ static seqBool seqg_event_motorTrim_0_trim(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 "trim" in state set "motorTrim" */ static void seqg_action_motorTrim_0_trim(SS_ID seqg_env, int seqg_trn, int *seqg_pnst) { switch(seqg_trn) { case 0: { # line 62 "../LHUtrimtest.stt" seqg_var->deviceName = seq_macValueGet(seqg_env, "motor"); } return; } } /****** Code for state "wait" in state set "motorTrim" ******/ /* Entry function for state "wait" in state set "motorTrim" */ static void seqg_entry_motorTrim_0_wait(SS_ID seqg_env) { # line 68 "../LHUtrimtest.stt" if (seqg_var->DEBUG_T) # line 68 "../LHUtrimtest.stt" outputMessage(seqg_var->deviceName, "Entering wait state"); } /* Event function for state "wait" in state set "motorTrim" */ static seqBool seqg_event_motorTrim_0_wait(SS_ID seqg_env, int *seqg_ptrn, int *seqg_pnst) { # line 71 "../LHUtrimtest.stt" if (seqg_var->trimCmd == 1) { *seqg_pnst = 2; *seqg_ptrn = 0; return TRUE; } return FALSE; } /* Action function for state "wait" in state set "motorTrim" */ static void seqg_action_motorTrim_0_wait(SS_ID seqg_env, int seqg_trn, int *seqg_pnst) { switch(seqg_trn) { case 0: { # line 72 "../LHUtrimtest.stt" seqg_var->trimSts = 0; # line 73 "../LHUtrimtest.stt" seq_pvPutTmo(seqg_env, 2/*trimSts*/, SYNC, DEFAULT_TIMEOUT); # line 74 "../LHUtrimtest.stt" if (seqg_var->DEBUG_T) # line 74 "../LHUtrimtest.stt" outputMessage(seqg_var->deviceName, "Trim to begin."); } return; } } /****** Code for state "enable" in state set "motorTrim" ******/ /* Entry function for state "enable" in state set "motorTrim" */ static void seqg_entry_motorTrim_0_enable(SS_ID seqg_env) { # line 80 "../LHUtrimtest.stt" if (seqg_var->DEBUG_T) # line 80 "../LHUtrimtest.stt" outputMessage(seqg_var->deviceName, "Entering enable state"); } /* Event function for state "enable" in state set "motorTrim" */ static seqBool seqg_event_motorTrim_0_enable(SS_ID seqg_env, int *seqg_ptrn, int *seqg_pnst) { if (TRUE) { *seqg_pnst = 3; *seqg_ptrn = 0; return TRUE; } return FALSE; } /* Action function for state "enable" in state set "motorTrim" */ static void seqg_action_motorTrim_0_enable(SS_ID seqg_env, int seqg_trn, int *seqg_pnst) { switch(seqg_trn) { case 0: { # line 84 "../LHUtrimtest.stt" seqg_var->enableCmd = 1; # line 85 "../LHUtrimtest.stt" seq_pvPutTmo(seqg_env, 7/*enableCmd*/, SYNC, DEFAULT_TIMEOUT); # line 86 "../LHUtrimtest.stt" if (seqg_var->DEBUG_T) # line 86 "../LHUtrimtest.stt" outputMessage(seqg_var->deviceName, "Motor enabled"); } return; } } /****** Code for state "startToMove" in state set "motorTrim" ******/ /* Entry function for state "startToMove" in state set "motorTrim" */ static void seqg_entry_motorTrim_0_startToMove(SS_ID seqg_env) { # line 92 "../LHUtrimtest.stt" if (seqg_var->DEBUG_T) # line 92 "../LHUtrimtest.stt" outputMessage(seqg_var->deviceName, "Entering StartToMove state"); } /* Event function for state "startToMove" in state set "motorTrim" */ static seqBool seqg_event_motorTrim_0_startToMove(SS_ID seqg_env, int *seqg_ptrn, int *seqg_pnst) { # line 95 "../LHUtrimtest.stt" if (seqg_var->trimCmd == 0) { *seqg_pnst = 5; *seqg_ptrn = 0; return TRUE; } # line 99 "../LHUtrimtest.stt" if (seq_delay(seqg_env, 1) && (seqg_var->trimCmd == 1)) { *seqg_pnst = 4; *seqg_ptrn = 1; return TRUE; } return FALSE; } /* Action function for state "startToMove" in state set "motorTrim" */ static void seqg_action_motorTrim_0_startToMove(SS_ID seqg_env, int seqg_trn, int *seqg_pnst) { switch(seqg_trn) { case 0: { # line 96 "../LHUtrimtest.stt" if (seqg_var->DEBUG_T) # line 96 "../LHUtrimtest.stt" outputMessage(seqg_var->deviceName, "Trim abort. Heading back to disable"); } return; case 1: { # line 100 "../LHUtrimtest.stt" seqg_var->moveValCmd = seqg_var->moveDes; # line 101 "../LHUtrimtest.stt" seq_pvPutTmo(seqg_env, 6/*moveValCmd*/, SYNC, DEFAULT_TIMEOUT); # line 102 "../LHUtrimtest.stt" if (seqg_var->DEBUG_T) # line 102 "../LHUtrimtest.stt" outputMessage(seqg_var->deviceName, "Motor move requested"); } return; } } /****** Code for state "moving" in state set "motorTrim" ******/ /* Entry function for state "moving" in state set "motorTrim" */ static void seqg_entry_motorTrim_0_moving(SS_ID seqg_env) { # line 108 "../LHUtrimtest.stt" if (seqg_var->DEBUG_T) # line 108 "../LHUtrimtest.stt" outputMessage(seqg_var->deviceName, "Entering moving state"); } /* Event function for state "moving" in state set "motorTrim" */ static seqBool seqg_event_motorTrim_0_moving(SS_ID seqg_env, int *seqg_ptrn, int *seqg_pnst) { # line 111 "../LHUtrimtest.stt" if (seqg_var->trimCmd == 0) { *seqg_pnst = 5; *seqg_ptrn = 0; return TRUE; } # line 115 "../LHUtrimtest.stt" if (seq_delay(seqg_env, 1) && (seqg_var->movedSts == 1)) { *seqg_pnst = 5; *seqg_ptrn = 1; return TRUE; } return FALSE; } /* Action function for state "moving" in state set "motorTrim" */ static void seqg_action_motorTrim_0_moving(SS_ID seqg_env, int seqg_trn, int *seqg_pnst) { switch(seqg_trn) { case 0: { # line 112 "../LHUtrimtest.stt" if (seqg_var->DEBUG_T) # line 112 "../LHUtrimtest.stt" outputMessage(seqg_var->deviceName, "Trim abort. Heading back to disable"); } return; case 1: { } return; } } /****** Code for state "disable" in state set "motorTrim" ******/ /* Entry function for state "disable" in state set "motorTrim" */ static void seqg_entry_motorTrim_0_disable(SS_ID seqg_env) { # line 121 "../LHUtrimtest.stt" if (seqg_var->DEBUG_T) # line 121 "../LHUtrimtest.stt" outputMessage(seqg_var->deviceName, "Entering disable state"); } /* Event function for state "disable" in state set "motorTrim" */ static seqBool seqg_event_motorTrim_0_disable(SS_ID seqg_env, int *seqg_ptrn, int *seqg_pnst) { if (TRUE) { *seqg_pnst = 6; *seqg_ptrn = 0; return TRUE; } return FALSE; } /* Action function for state "disable" in state set "motorTrim" */ static void seqg_action_motorTrim_0_disable(SS_ID seqg_env, int seqg_trn, int *seqg_pnst) { switch(seqg_trn) { case 0: { # line 125 "../LHUtrimtest.stt" seqg_var->enableCmd = 0; # line 126 "../LHUtrimtest.stt" seq_pvPutTmo(seqg_env, 7/*enableCmd*/, SYNC, DEFAULT_TIMEOUT); # line 127 "../LHUtrimtest.stt" seqg_var->trimCmd = 0; # line 128 "../LHUtrimtest.stt" seq_pvPutTmo(seqg_env, 0/*trimCmd*/, SYNC, DEFAULT_TIMEOUT); # line 129 "../LHUtrimtest.stt" if (seqg_var->DEBUG_T) # line 129 "../LHUtrimtest.stt" outputMessage(seqg_var->deviceName, "Motor disabled."); } return; } } /****** Code for state "correct" in state set "motorTrim" ******/ /* Entry function for state "correct" in state set "motorTrim" */ static void seqg_entry_motorTrim_0_correct(SS_ID seqg_env) { # line 135 "../LHUtrimtest.stt" if (seqg_var->DEBUG_T) # line 135 "../LHUtrimtest.stt" outputMessage(seqg_var->deviceName, "Entering correct state"); } /* Event function for state "correct" in state set "motorTrim" */ static seqBool seqg_event_motorTrim_0_correct(SS_ID seqg_env, int *seqg_ptrn, int *seqg_pnst) { # line 138 "../LHUtrimtest.stt" if (seq_delay(seqg_env, 5)) { *seqg_pnst = 1; *seqg_ptrn = 0; return TRUE; } return FALSE; } /* Action function for state "correct" in state set "motorTrim" */ static void seqg_action_motorTrim_0_correct(SS_ID seqg_env, int seqg_trn, int *seqg_pnst) { switch(seqg_trn) { case 0: { # line 139 "../LHUtrimtest.stt" seqg_var->correctSts = 0; # line 140 "../LHUtrimtest.stt" seq_pvPutTmo(seqg_env, 5/*correctSts*/, SYNC, DEFAULT_TIMEOUT); # line 141 "../LHUtrimtest.stt" seqg_var->correctCmd = 1; # line 142 "../LHUtrimtest.stt" seq_pvPutTmo(seqg_env, 4/*correctCmd*/, SYNC, DEFAULT_TIMEOUT); # line 143 "../LHUtrimtest.stt" if (seqg_var->DEBUG_T) # line 143 "../LHUtrimtest.stt" outputMessage(seqg_var->deviceName, "Motor readback corrected"); # line 144 "../LHUtrimtest.stt" seqg_var->correctSts = 1; # line 145 "../LHUtrimtest.stt" seq_pvPutTmo(seqg_env, 5/*correctSts*/, SYNC, DEFAULT_TIMEOUT); # line 146 "../LHUtrimtest.stt" seqg_var->trimSts = 1; # line 147 "../LHUtrimtest.stt" seq_pvPutTmo(seqg_env, 2/*trimSts*/, SYNC, DEFAULT_TIMEOUT); # line 148 "../LHUtrimtest.stt" if (seqg_var->DEBUG_T) # line 148 "../LHUtrimtest.stt" outputMessage(seqg_var->deviceName, "Trim on standby."); } return; } } #undef seqg_var /************************ Tables ************************/ /* Channel table */ static seqChan seqg_chans[] = { /* chName, offset, varName, varType, count, eventNum, efId, monitored, queueSize, queueIndex */ {"{motor}:TRIM", offsetof(struct seqg_vars, trimCmd), "trimCmd", P_SHORT, 1, 1, 0, 1, 0, 0}, {"{motor}:MOTR.DMOV", offsetof(struct seqg_vars, movedSts), "movedSts", P_SHORT, 1, 2, 0, 1, 0, 0}, {"{motor}:TRIMSTS", offsetof(struct seqg_vars, trimSts), "trimSts", P_SHORT, 1, 3, 0, 1, 0, 0}, {"{motordes}", offsetof(struct seqg_vars, moveDes), "moveDes", P_DOUBLE, 1, 4, 0, 1, 0, 0}, {"{motor}:CORRECT", offsetof(struct seqg_vars, correctCmd), "correctCmd", P_SHORT, 1, 5, 0, 1, 0, 0}, {"{motor}:CORRECT_STS", offsetof(struct seqg_vars, correctSts), "correctSts", P_SHORT, 1, 6, 0, 1, 0, 0}, {"{motor}:MOTR.VAL", offsetof(struct seqg_vars, moveValCmd), "moveValCmd", P_DOUBLE, 1, 7, 0, 0, 0, 0}, {"{motor}:MOTR.CNEN", offsetof(struct seqg_vars, enableCmd), "enableCmd", P_SHORT, 1, 8, 0, 0, 0, 0}, {"{motor}:TRIM_DBG", offsetof(struct seqg_vars, DEBUG_T), "DEBUG_T", P_SHORT, 1, 9, 0, 1, 0, 0}, }; /* Event masks for state set "motorTrim" */ static const seqMask seqg_mask_motorTrim_0_trim[] = { 0x00000000, }; static const seqMask seqg_mask_motorTrim_0_wait[] = { 0x00000002, }; static const seqMask seqg_mask_motorTrim_0_enable[] = { 0x00000000, }; static const seqMask seqg_mask_motorTrim_0_startToMove[] = { 0x00000002, }; static const seqMask seqg_mask_motorTrim_0_moving[] = { 0x00000006, }; static const seqMask seqg_mask_motorTrim_0_disable[] = { 0x00000000, }; static const seqMask seqg_mask_motorTrim_0_correct[] = { 0x00000000, }; /* State table for state set "motorTrim" */ static seqState seqg_states_motorTrim[] = { { /* state name */ "trim", /* action function */ seqg_action_motorTrim_0_trim, /* event function */ seqg_event_motorTrim_0_trim, /* entry function */ seqg_entry_motorTrim_0_trim, /* exit function */ 0, /* event mask array */ seqg_mask_motorTrim_0_trim, /* state options */ (0) }, { /* state name */ "wait", /* action function */ seqg_action_motorTrim_0_wait, /* event function */ seqg_event_motorTrim_0_wait, /* entry function */ seqg_entry_motorTrim_0_wait, /* exit function */ 0, /* event mask array */ seqg_mask_motorTrim_0_wait, /* state options */ (0) }, { /* state name */ "enable", /* action function */ seqg_action_motorTrim_0_enable, /* event function */ seqg_event_motorTrim_0_enable, /* entry function */ seqg_entry_motorTrim_0_enable, /* exit function */ 0, /* event mask array */ seqg_mask_motorTrim_0_enable, /* state options */ (0) }, { /* state name */ "startToMove", /* action function */ seqg_action_motorTrim_0_startToMove, /* event function */ seqg_event_motorTrim_0_startToMove, /* entry function */ seqg_entry_motorTrim_0_startToMove, /* exit function */ 0, /* event mask array */ seqg_mask_motorTrim_0_startToMove, /* state options */ (0) }, { /* state name */ "moving", /* action function */ seqg_action_motorTrim_0_moving, /* event function */ seqg_event_motorTrim_0_moving, /* entry function */ seqg_entry_motorTrim_0_moving, /* exit function */ 0, /* event mask array */ seqg_mask_motorTrim_0_moving, /* state options */ (0) }, { /* state name */ "disable", /* action function */ seqg_action_motorTrim_0_disable, /* event function */ seqg_event_motorTrim_0_disable, /* entry function */ seqg_entry_motorTrim_0_disable, /* exit function */ 0, /* event mask array */ seqg_mask_motorTrim_0_disable, /* state options */ (0) }, { /* state name */ "correct", /* action function */ seqg_action_motorTrim_0_correct, /* event function */ seqg_event_motorTrim_0_correct, /* entry function */ seqg_entry_motorTrim_0_correct, /* exit function */ 0, /* event mask array */ seqg_mask_motorTrim_0_correct, /* state options */ (0) }, }; /* State set table */ static seqSS seqg_statesets[] = { { /* state set name */ "motorTrim", /* states */ seqg_states_motorTrim, /* number of states */ 7 }, }; /* Program table (global) */ seqProgram LHUtrimtest = { /* magic number */ 2002004, /* program name */ "LHUtrimtest", /* channels */ seqg_chans, /* num. channels */ 9, /* state sets */ seqg_statesets, /* num. state sets */ 1, /* user var size */ sizeof(struct seqg_vars), /* param */ "", /* num. event flags */ 0, /* encoded options */ (0 | OPT_CONN | OPT_DEBUG | OPT_NEWEF | OPT_REENT), /* init func */ seqg_init, /* entry func */ 0, /* exit func */ 0, /* num. queues */ 0 }; # line 154 "../LHUtrimtest.stt" static void outputMessage(char* deviceName, char* message) { time_t t = time(NULL); struct tm tm = *localtime(&t); printf("%d-%.2d-%.2d %.2d:%.2d:%.2d:(trimMotor) %s - %s\n", \ tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec, \ deviceName, message); return; } /* Register sequencer commands and program */ #include "epicsExport.h" static void LHUtrimtestRegistrar (void) { seqRegisterSequencerCommands(); seqRegisterSequencerProgram (&LHUtrimtest); } epicsExportRegistrar(LHUtrimtestRegistrar);