Added a motor driver which ignores air cushion errors for TRICS (falsely triggered)

This commit is contained in:
2014-10-13 13:38:51 +02:00
parent 07cd8a0215
commit 32e55f2176
3 changed files with 115 additions and 0 deletions

101
el734hp.c
View File

@ -744,3 +744,104 @@ MotorDriver *CreateEL734HPT(SConnection * pCon, int argc, char *argv[])
}
return pDriv;
}
/*======================================================================
A version which ignores the air cushion error for TRICS. Not recommended for
general use!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
But HW cannot be fixed.... as the electronics guys are not there.......
========================================================================*/
static int EL734FixAir(void *pData, int iCode, float fValue)
{
pEL734Driv self = NULL;
int status, msr, i, len = 49;
char pCommand[50], pReply[80];
self = (pEL734Driv) pData;
assert(self);
switch (iCode) {
/*
air cushion error is really OK.....
*/
case BADCUSHION:
return MOTOK;
case BADADR:
case BADCMD:
case BADPAR:
return MOTREDO;
case BADBSY:
EL734Halt(pData);
SicsWait(1);
return MOTREDO;
case TIMEOUT:
for (i = 0; i < 3; i++) {
len = 49;
status = readRS232TillTerm(self->controller, pReply, &len);
if (status == 1) {
return MOTREDO;
}
}
/*
If nothing can be read, the only fixable cause is a network breakdown
Try to fix this. If this does not work: give up
*/
closeRS232(self->controller);
SicsWait(60);
status = initRS232(self->controller);
if (status != 1) {
return MOTFAIL;
} else {
return MOTREDO;
}
break;
case BADUNKNOWN:
if (availableRS232(self->controller)) {
len = 79;
readRS232TillTerm(self->controller, pReply, &len);
return MOTREDO;
}
return MOTFAIL;
break;
case BADLOC:
snprintf(pCommand, 49, "RMT 1\r");
transactEL734(self->controller, pCommand, strlen(pCommand), pReply,
79);
snprintf(pCommand, 49, "ECHO 0\r");
transactEL734(self->controller, pCommand, strlen(pCommand), pReply,
79);
return MOTREDO;
case NOTCONNECTED:
initRS232(self->controller);
return MOTREDO;
case RUNFAULT:
case POSFAULT:
return MOTREDO;
case BADCOUNT:
self->runCount = 0;
self->posCount = 0;
return MOTOK;
case BADSEND:
/*
network problem: try to reopen connection
*/
closeRS232(self->controller);
SicsWait(60);
status = initRS232(self->controller);
if (status != 1) {
return MOTFAIL;
} else {
return MOTREDO;
}
}
return MOTFAIL;
}
/*-------------------------------------------------------------------------*/
MotorDriver *CreateEL734Air(SConnection * pCon, int argc, char *argv[])
{
MotorDriver *pDriv = NULL;
pDriv = CreateEL734HP(pCon, argc, argv);
if (pDriv != NULL) {
pDriv->TryAndFixIt = EL734FixAir;
}
return pDriv;
}