/* Generated with snc from ../timeout.stt */ /* Program "timeout" */ #include #include #include #include #include "epicsTypes.h" #include "seqCom.h" /* Variable declarations */ # line 19 "../timeout.stt" static short inMotion = 0; # line 20 "../timeout.stt" static short setMode = 0; # line 21 "../timeout.stt" static double dialVal = 0; # line 22 "../timeout.stt" static double val = 0; # line 23 "../timeout.stt" static double offset = 0; # line 24 "../timeout.stt" static short stop = 0; # line 25 "../timeout.stt" static short closedLoop = 0; # line 26 "../timeout.stt" static short lLimit = 0; # line 27 "../timeout.stt" static short hLimit = 0; # line 29 "../timeout.stt" static double homePos = 0; # line 31 "../timeout.stt" static short timeoutEn = 0; # line 32 "../timeout.stt" static double pidOffset = 0; # line 33 "../timeout.stt" static double timeOut = 0; # line 34 "../timeout.stt" static double longTimeOut = 0; # line 35 "../timeout.stt" static short retract = 0; # line 37 "../timeout.stt" static double tempVal = 0; /* Program init func */ static void G_prog_init(struct UserVar *pVar) { } /****** Code for state "init" in state set "tim" ******/ /* Entry function for state "init" in state set "tim" */ static void I_tim_init(SS_ID ssId, struct UserVar *pVar) { # line 45 "../timeout.stt" printf("Timeout program\n"); } /* Delay function for state "init" in state set "tim" */ static void D_tim_init(SS_ID ssId, struct UserVar *pVar) { # line 48 "../timeout.stt" seq_delayInit(ssId, 0, (5)); # line 50 "../timeout.stt" seq_delayInit(ssId, 1, (5)); } /* Event function for state "init" in state set "tim" */ static seqBool E_tim_init(SS_ID ssId, struct UserVar *pVar, int *pTransNum, int *pNextState) { # line 48 "../timeout.stt" if (seq_delay(ssId, 0) && timeoutEn) { *pNextState = 2; *pTransNum = 0; return TRUE; } # line 50 "../timeout.stt" if (seq_delay(ssId, 1) && !timeoutEn) { *pNextState = 1; *pTransNum = 1; return TRUE; } return FALSE; } /* Action function for state "init" in state set "tim" */ static void A_tim_init(SS_ID ssId, struct UserVar *pVar, int transNum, int *pNextState) { switch(transNum) { case 0: { } return; case 1: { } return; } } /****** Code for state "disabled" in state set "tim" ******/ /* Entry function for state "disabled" in state set "tim" */ static void I_tim_disabled(SS_ID ssId, struct UserVar *pVar) { # line 57 "../timeout.stt" printf("Timeout disabled\n"); } /* Delay function for state "disabled" in state set "tim" */ static void D_tim_disabled(SS_ID ssId, struct UserVar *pVar) { } /* Event function for state "disabled" in state set "tim" */ static seqBool E_tim_disabled(SS_ID ssId, struct UserVar *pVar, int *pTransNum, int *pNextState) { # line 59 "../timeout.stt" if (timeoutEn) { *pNextState = 2; *pTransNum = 0; return TRUE; } # line 61 "../timeout.stt" if (retract == 1) { *pNextState = 2; *pTransNum = 1; return TRUE; } return FALSE; } /* Action function for state "disabled" in state set "tim" */ static void A_tim_disabled(SS_ID ssId, struct UserVar *pVar, int transNum, int *pNextState) { switch(transNum) { case 0: { } return; case 1: { # line 62 "../timeout.stt" val = homePos; # line 63 "../timeout.stt" seq_pvPut(ssId, 3/*val*/, 0); } return; } } /****** Code for state "wait" in state set "tim" ******/ /* Entry function for state "wait" in state set "tim" */ static void I_tim_wait(SS_ID ssId, struct UserVar *pVar) { # line 70 "../timeout.stt" printf("STATE wait \n"); } /* Delay function for state "wait" in state set "tim" */ static void D_tim_wait(SS_ID ssId, struct UserVar *pVar) { } /* Event function for state "wait" in state set "tim" */ static seqBool E_tim_wait(SS_ID ssId, struct UserVar *pVar, int *pTransNum, int *pNextState) { # line 72 "../timeout.stt" if (closedLoop == 0) { *pNextState = 6; *pTransNum = 0; return TRUE; } # line 75 "../timeout.stt" if ((val == homePos || lLimit == 1) && inMotion == 0) { *pNextState = 3; *pTransNum = 1; return TRUE; } # line 78 "../timeout.stt" if (inMotion == 0) { *pNextState = 4; *pTransNum = 2; return TRUE; } return FALSE; } /* Action function for state "wait" in state set "tim" */ static void A_tim_wait(SS_ID ssId, struct UserVar *pVar, int transNum, int *pNextState) { switch(transNum) { case 0: { } return; case 1: { } return; case 2: { } return; } } /****** Code for state "timeOut" in state set "tim" ******/ /* Entry function for state "timeOut" in state set "tim" */ static void I_tim_timeOut(SS_ID ssId, struct UserVar *pVar) { # line 89 "../timeout.stt" printf("STATE timeout \n"); } /* Delay function for state "timeOut" in state set "tim" */ static void D_tim_timeOut(SS_ID ssId, struct UserVar *pVar) { # line 110 "../timeout.stt" seq_delayInit(ssId, 0, (timeOut)); } /* Event function for state "timeOut" in state set "tim" */ static seqBool E_tim_timeOut(SS_ID ssId, struct UserVar *pVar, int *pTransNum, int *pNextState) { # line 91 "../timeout.stt" if (inMotion) { *pNextState = 2; *pTransNum = 0; return TRUE; } # line 94 "../timeout.stt" if (closedLoop == 0) { *pNextState = 6; *pTransNum = 1; return TRUE; } # line 97 "../timeout.stt" if (retract == 1 && (val == homePos || lLimit == 1)) { *pNextState = 5; *pTransNum = 2; return TRUE; } # line 102 "../timeout.stt" if (retract == 1) { *pNextState = 2; *pTransNum = 3; return TRUE; } # line 107 "../timeout.stt" if (!timeoutEn) { *pNextState = 1; *pTransNum = 4; return TRUE; } # line 110 "../timeout.stt" if (seq_delay(ssId, 0)) { *pNextState = 5; *pTransNum = 5; return TRUE; } return FALSE; } /* Action function for state "timeOut" in state set "tim" */ static void A_tim_timeOut(SS_ID ssId, struct UserVar *pVar, int transNum, int *pNextState) { switch(transNum) { case 0: { } return; case 1: { } return; case 2: { # line 98 "../timeout.stt" retract = 0; # line 99 "../timeout.stt" seq_pvPut(ssId, 14/*retract*/, 0); } return; case 3: { # line 103 "../timeout.stt" val = homePos; # line 104 "../timeout.stt" seq_pvPut(ssId, 3/*val*/, 0); } return; case 4: { } return; case 5: { } return; } } /****** Code for state "longTimeOut" in state set "tim" ******/ /* Entry function for state "longTimeOut" in state set "tim" */ static void I_tim_longTimeOut(SS_ID ssId, struct UserVar *pVar) { # line 121 "../timeout.stt" printf("STATE long timeout \n"); } /* Delay function for state "longTimeOut" in state set "tim" */ static void D_tim_longTimeOut(SS_ID ssId, struct UserVar *pVar) { # line 132 "../timeout.stt" seq_delayInit(ssId, 0, (longTimeOut)); } /* Event function for state "longTimeOut" in state set "tim" */ static seqBool E_tim_longTimeOut(SS_ID ssId, struct UserVar *pVar, int *pTransNum, int *pNextState) { # line 123 "../timeout.stt" if (inMotion) { *pNextState = 2; *pTransNum = 0; return TRUE; } # line 126 "../timeout.stt" if (closedLoop == 0) { *pNextState = 6; *pTransNum = 1; return TRUE; } # line 129 "../timeout.stt" if (!timeoutEn) { *pNextState = 1; *pTransNum = 2; return TRUE; } # line 132 "../timeout.stt" if (seq_delay(ssId, 0)) { *pNextState = 2; *pTransNum = 3; return TRUE; } # line 137 "../timeout.stt" if (retract == 1) { *pNextState = 2; *pTransNum = 4; return TRUE; } return FALSE; } /* Action function for state "longTimeOut" in state set "tim" */ static void A_tim_longTimeOut(SS_ID ssId, struct UserVar *pVar, int transNum, int *pNextState) { switch(transNum) { case 0: { } return; case 1: { } return; case 2: { } return; case 3: { # line 133 "../timeout.stt" val = homePos; # line 134 "../timeout.stt" seq_pvPut(ssId, 3/*val*/, 0); } return; case 4: { # line 138 "../timeout.stt" val = homePos; # line 139 "../timeout.stt" seq_pvPut(ssId, 3/*val*/, 0); } return; } } /****** Code for state "turnOff" in state set "tim" ******/ /* Delay function for state "turnOff" in state set "tim" */ static void D_tim_turnOff(SS_ID ssId, struct UserVar *pVar) { } /* Event function for state "turnOff" in state set "tim" */ static seqBool E_tim_turnOff(SS_ID ssId, struct UserVar *pVar, int *pTransNum, int *pNextState) { if (TRUE) { *pNextState = 6; *pTransNum = 0; return TRUE; } return FALSE; } /* Action function for state "turnOff" in state set "tim" */ static void A_tim_turnOff(SS_ID ssId, struct UserVar *pVar, int transNum, int *pNextState) { switch(transNum) { case 0: { # line 147 "../timeout.stt" printf("STATE turnOff \n"); # line 149 "../timeout.stt" closedLoop = 0; # line 150 "../timeout.stt" seq_pvPut(ssId, 6/*closedLoop*/, 0); } return; } } /****** Code for state "motorOff" in state set "tim" ******/ /* Entry function for state "motorOff" in state set "tim" */ static void I_tim_motorOff(SS_ID ssId, struct UserVar *pVar) { # line 157 "../timeout.stt" printf("STATE motorOff \n"); # line 158 "../timeout.stt" tempVal = val; } /* Delay function for state "motorOff" in state set "tim" */ static void D_tim_motorOff(SS_ID ssId, struct UserVar *pVar) { } /* Event function for state "motorOff" in state set "tim" */ static seqBool E_tim_motorOff(SS_ID ssId, struct UserVar *pVar, int *pTransNum, int *pNextState) { # line 162 "../timeout.stt" if (!timeoutEn) { *pNextState = 1; *pTransNum = 0; return TRUE; } # line 165 "../timeout.stt" if (val != tempVal) { *pNextState = 2; *pTransNum = 1; return TRUE; } # line 187 "../timeout.stt" if (closedLoop == 1) { *pNextState = 2; *pTransNum = 2; return TRUE; } return FALSE; } /* Action function for state "motorOff" in state set "tim" */ static void A_tim_motorOff(SS_ID ssId, struct UserVar *pVar, int transNum, int *pNextState) { switch(transNum) { case 0: { } return; case 1: { # line 167 "../timeout.stt" tempVal = val; # line 168 "../timeout.stt" printf("Val is %f\n", tempVal); # line 170 "../timeout.stt" stop = 1; # line 171 "../timeout.stt" seq_pvPut(ssId, 5/*stop*/, SYNC); # line 179 "../timeout.stt" closedLoop = 1; # line 180 "../timeout.stt" seq_pvPut(ssId, 6/*closedLoop*/, 0); # line 183 "../timeout.stt" val = tempVal; # line 184 "../timeout.stt" seq_pvPut(ssId, 3/*val*/, 0); } return; case 2: { } return; } } /************************ Tables ************************/ /* Channel table */ static seqChan G_channels[] = { /* chName, offset, varName, varType, count, eventNum, efId, monitored, queueSize, queueIndex */ {"{motor}:MOTR.MOVN", (size_t)&inMotion, "inMotion", "short", 1, 1, 0, 1, 0, 0}, {"{motor}:MOTR.SET", (size_t)&setMode, "setMode", "short", 1, 2, 0, 0, 0, 0}, {"{motor}:MOTR.DVAL", (size_t)&dialVal, "dialVal", "double", 1, 3, 0, 0, 0, 0}, {"{motor}:MOTR.VAL", (size_t)&val, "val", "double", 1, 4, 0, 1, 0, 0}, {"{motor}:MOTR.OFF", (size_t)&offset, "offset", "double", 1, 5, 0, 1, 0, 0}, {"{motor}:MOTR.STOP", (size_t)&stop, "stop", "short", 1, 6, 0, 0, 0, 0}, {"{motor}:MOTR.CNEN", (size_t)&closedLoop, "closedLoop", "short", 1, 7, 0, 1, 0, 0}, {"{motor}:MOTR.LLS", (size_t)&lLimit, "lLimit", "short", 1, 8, 0, 1, 0, 0}, {"{motor}:MOTR.HLS", (size_t)&hLimit, "hLimit", "short", 1, 9, 0, 1, 0, 0}, {"{motor}:MOTR_HOMPOS", (size_t)&homePos, "homePos", "double", 1, 10, 0, 1, 0, 0}, {"{motor}:MOTR_TIMEOUTEN", (size_t)&timeoutEn, "timeoutEn", "short", 1, 11, 0, 1, 0, 0}, {"{motor}:MOTR_PIDOFF", (size_t)&pidOffset, "pidOffset", "double", 1, 12, 0, 0, 0, 0}, {"{motor}:MOTR_TIMEOUT", (size_t)&timeOut, "timeOut", "double", 1, 13, 0, 1, 0, 0}, {"{motor}:MOTR_LTIMEOUT", (size_t)&longTimeOut, "longTimeOut", "double", 1, 14, 0, 1, 0, 0}, {"{motor}:MOTR_RETRACT", (size_t)&retract, "retract", "short", 1, 15, 0, 1, 0, 0} }; /* Event masks for state set "tim" */ static const seqMask EM_tim_init[] = { 0x00000800, }; static const seqMask EM_tim_disabled[] = { 0x00008800, }; static const seqMask EM_tim_wait[] = { 0x00000592, }; static const seqMask EM_tim_timeOut[] = { 0x0000ad92, }; static const seqMask EM_tim_longTimeOut[] = { 0x0000c882, }; static const seqMask EM_tim_turnOff[] = { 0x00000000, }; static const seqMask EM_tim_motorOff[] = { 0x00000890, }; /* State table for state set "tim" */ static seqState G_tim_states[] = { { /* state name */ "init", /* action function */ A_tim_init, /* event function */ E_tim_init, /* delay function */ D_tim_init, /* entry function */ I_tim_init, /* exit function */ 0, /* event mask array */ EM_tim_init, /* state options */ (0) }, { /* state name */ "disabled", /* action function */ A_tim_disabled, /* event function */ E_tim_disabled, /* delay function */ D_tim_disabled, /* entry function */ I_tim_disabled, /* exit function */ 0, /* event mask array */ EM_tim_disabled, /* state options */ (0) }, { /* state name */ "wait", /* action function */ A_tim_wait, /* event function */ E_tim_wait, /* delay function */ D_tim_wait, /* entry function */ I_tim_wait, /* exit function */ 0, /* event mask array */ EM_tim_wait, /* state options */ (0) }, { /* state name */ "timeOut", /* action function */ A_tim_timeOut, /* event function */ E_tim_timeOut, /* delay function */ D_tim_timeOut, /* entry function */ I_tim_timeOut, /* exit function */ 0, /* event mask array */ EM_tim_timeOut, /* state options */ (0) }, { /* state name */ "longTimeOut", /* action function */ A_tim_longTimeOut, /* event function */ E_tim_longTimeOut, /* delay function */ D_tim_longTimeOut, /* entry function */ I_tim_longTimeOut, /* exit function */ 0, /* event mask array */ EM_tim_longTimeOut, /* state options */ (0) }, { /* state name */ "turnOff", /* action function */ A_tim_turnOff, /* event function */ E_tim_turnOff, /* delay function */ D_tim_turnOff, /* entry function */ 0, /* exit function */ 0, /* event mask array */ EM_tim_turnOff, /* state options */ (0) }, { /* state name */ "motorOff", /* action function */ A_tim_motorOff, /* event function */ E_tim_motorOff, /* delay function */ D_tim_motorOff, /* entry function */ I_tim_motorOff, /* exit function */ 0, /* event mask array */ EM_tim_motorOff, /* state options */ (0) }, }; /* State set table */ static seqSS G_state_sets[] = { { /* state set name */ "tim", /* states */ G_tim_states, /* number of states */ 7, /* number of delays */ 2 }, }; /* Program table (global) */ seqProgram timeout = { /* magic number */ 2001006, /* program name */ "timeout", /* channels */ G_channels, /* num. channels */ 15, /* state sets */ G_state_sets, /* num. state sets */ 1, /* user var size */ 0, /* param */ "", /* num. event flags */ 0, /* encoded options */ (0 | OPT_CONN | OPT_NEWEF), /* init func */ G_prog_init, /* entry func */ NULL, /* exit func */ NULL, /* num. queues */ 0 }; /* Register sequencer commands and program */ #include "epicsExport.h" static void timeoutRegistrar (void) { seqRegisterSequencerCommands(); seqRegisterSequencerProgram (&timeout); } epicsExportRegistrar(timeoutRegistrar);