Code cleanup.

r2693 | ffr | 2008-09-17 08:40:39 +1000 (Wed, 17 Sep 2008) | 2 lines
This commit is contained in:
Ferdi Franceschini
2008-09-17 08:40:39 +10:00
committed by Douglas Clowes
parent 02015668e2
commit 8b4c571d63

View File

@@ -28,10 +28,10 @@ typedef enum {
char *subcmdName[] = {"act", "args", "status", "debug", NULL}; char *subcmdName[] = {"act", "args", "status", "debug", NULL};
char *validActions[LASTACTION+1] = {"up", "down"}; char *validActions[LASTACTION+1] = {"up", "down"};
/* Each action takes two arguments, an axis label and the jogspeed */ /* Each action takes two arguments, an axis label and the jogspeed */
char *dfltActionSequence[ACTIONS][SEQLEN] = { {"SH%c","JG%c=%d", "BG%c", NULL}, {"SH%c","JG%c=(-1.0)*(%d)", "BG%c", NULL} }; static char *dfltActionSequence[ACTIONS][SEQLEN] = { {"SH%c","JG%c=%d", "BG%c", NULL}, {"SH%c","JG%c=(-1.0)*(%d)", "BG%c", NULL} };
int dfltactArgs[ACTIONS][SEQLEN] = { {1,2,1}, {1,2,1} }; static int dfltactArgs[ACTIONS][SEQLEN] = { {1,2,1}, {1,2,1} };
char *dfltStatusCheck[ACTIONS][SEQLEN] = {{"TS%c", NULL}, {"TS%c", NULL}}; static char *dfltStatusCheck[ACTIONS][SEQLEN] = {{"TS%c", NULL}, {"TS%c", NULL}};
char *dfltDevStatusMsg[] = {"up", "down", "inbetween", "FAULT: Are the limit switches connected?"}; static char *dfltDevStatusMsg[] = {"up", "down", "inbetween", "FAULT: Are the limit switches connected?"};
int numactions = 2; int numactions = 2;
#define NUM_DEVSTATES 4 #define NUM_DEVSTATES 4
// Mask TS reply to get limswitch status // Mask TS reply to get limswitch status
@@ -53,7 +53,7 @@ typedef struct __Action {
char args[256]; char args[256];
char cf_axis; char cf_axis;
int cf_jogspeed; int cf_jogspeed;
int cf_mask[NUM_DEVSTATES]; int cf_devState[NUM_DEVSTATES];
int status; int status;
float fTarget; float fTarget;
int debug; int debug;
@@ -250,7 +250,7 @@ cmd_len = AO_CMDLEN;
} else { } else {
limswi = LIMSWI_MASK & iFlags; limswi = LIMSWI_MASK & iFlags;
for (devStatus = 0; devStatus < NUM_DEVSTATES; devStatus++) { for (devStatus = 0; devStatus < NUM_DEVSTATES; devStatus++) {
if (self->cf_mask[devStatus] == limswi) { if (self->cf_devState[devStatus] == limswi) {
self->devStatusID = devStatus; self->devStatusID = devStatus;
break; break;
} }
@@ -358,15 +358,11 @@ int ActionObjectFactory(SConnection *pCon, SicsInterp *pSics, void *pData, int a
pNew->statusCheck = dfltStatusCheck; pNew->statusCheck = dfltStatusCheck;
pNew->devStatusMsg = dfltDevStatusMsg; pNew->devStatusMsg = dfltDevStatusMsg;
pNew->cf_jogspeed = atoi(argv[3]); pNew->cf_jogspeed = atoi(argv[3]);
pNew->cf_mask[DEVUP] = atoi(argv[4]); pNew->cf_devState[DEVUP] = atoi(argv[4]);
pNew->cf_mask[DEVDOWN] = atoi(argv[5]); pNew->cf_devState[DEVDOWN] = atoi(argv[5]);
pNew->cf_mask[DEVBETWEEN] = 12; // REVSWI | FWDSWI pNew->cf_devState[DEVBETWEEN] = 12; // REVSWI | FWDSWI
pNew->cf_mask[DEVFLT] = 0; // REV & FWD low pNew->cf_devState[DEVFLT] = 0; // REV & FWD low
pNew->cf_axis = argv[6][0]; pNew->cf_axis = argv[6][0];
printf("axis = %c\n", pNew->cf_axis);
printf("jogspeed = %d\n", pNew->cf_jogspeed);
for (i=0; i< NUM_DEVSTATES; i++)
printf("mask[%d] = %d\n",i, pNew->cf_mask[i]);
iRet = AddCommand(pSics, argv[1], AO_Wrapper, AO_Kill, pNew); iRet = AddCommand(pSics, argv[1], AO_Wrapper, AO_Kill, pNew);
if(!iRet) { if(!iRet) {
sprintf(pError,"ERROR: duplicate command %s not created [%d]", argv[1], iRet); sprintf(pError,"ERROR: duplicate command %s not created [%d]", argv[1], iRet);