diff --git a/commandlog.c b/commandlog.c index 4135c737..7f60b573 100644 --- a/commandlog.c +++ b/commandlog.c @@ -162,7 +162,7 @@ for(i = 0; i < iNum; i++) { pPtr = (char *)getCircular(pTail); - if(pCon->pSock) + if(pCon->pSock && pPtr != NULL) { TelnetWrite(pCon->pSock, pPtr); } diff --git a/conman.c b/conman.c index 0017aa27..5fef5ebb 100644 --- a/conman.c +++ b/conman.c @@ -545,6 +545,13 @@ extern pServer pServ; { return 0; } + /* + Do not die if no data + */ + if(pBuffer == NULL) + { + return 0; + } return self->write(self,pBuffer,iOut); } /*-------------------------------------------------------------------------*/ diff --git a/drive.c b/drive.c index 21fd206a..37739af5 100644 --- a/drive.c +++ b/drive.c @@ -6,7 +6,6 @@ Mark Koennecke, December 1996 - Copyright: Labor fuer Neutronenstreuung Paul Scherrer Institut diff --git a/hklscan.c b/hklscan.c index 4a2c7c4b..ffa12325 100644 --- a/hklscan.c +++ b/hklscan.c @@ -198,7 +198,7 @@ /* print HKL */ for(i2 = 0; i2 < 3; i2++) { - sprintf(pItem,"%-8.4f",pHaSca->fStart[i2] + i * pHaSca->fStep[i2]); + sprintf(pItem," %-8.4f",pHaSca->fStart[i2] + i * pHaSca->fStep[i2]); strcat(pLine,pItem); } /* print chi, ph, om */ @@ -208,7 +208,7 @@ pVar = (pVarEntry)pPtr; if(pVar) { - sprintf(pItem,"%-7.2f",pVar->fData[i]); + sprintf(pItem," %-7.2f",pVar->fData[i]); strcat(pLine,pItem); } } @@ -217,9 +217,9 @@ pData = (pCountEntry)pPtr; if(pData) { - sprintf(pItem,"%-13ld",pData->lCount); + sprintf(pItem," %-13ld",pData->lCount); strcat(pLine,pItem); - sprintf(pItem,"%-12ld",pData->Monitors[0]); + sprintf(pItem," %-12ld",pData->Monitors[0]); strcat(pLine,pItem); } fprintf(self->fd,"%s\n",pLine); diff --git a/macro.c b/macro.c index 9641091c..aa6f88b5 100644 --- a/macro.c +++ b/macro.c @@ -864,10 +864,15 @@ int TransactAction(SConnection *pCon, SicsInterp *pSics, void *pData, int argc, char *argv[]) { - char pCommand[1024]; + char pCommand[1024], pStart[1024]; int iRet; Arg2Text(argc-1,&argv[1],pCommand,1023); + strtolower(argv[0]); + if(strcmp(argv[0],"fulltransact") == 0){ + snprintf(pStart,1024,"TRANSACTIONSTART %s",pCommand); + SCWrite(pCon,pStart,eError); + } iRet = InterpExecute(pSics,pCon,pCommand); SicsWait(1); SCWrite(pCon,"TRANSACTIONFINISHED",eError); diff --git a/motor.c b/motor.c index 9e1f7a92..27f5838f 100644 --- a/motor.c +++ b/motor.c @@ -75,6 +75,7 @@ #define SIGN 10 #define ECOUNT 11 #define POSCOUNT 12 +#define IGNOREFAULT 13 /*------------------------------------------------------------------------ a tiny structure used in CallBack work */ @@ -223,7 +224,17 @@ static int evaluateStatus(pMotor self, SConnection *pCon) SCWrite(pCon,pBueffel, eWarning); MotorInterrupt(pCon,ObVal(self->ParArray,INT)); self->retryCount = 0; - return HWPosFault; + /* + suppress HWPosFaults when ignore flag set + */ + if(ObVal(self->ParArray,IGNOREFAULT) > 0) + { + return HWIdle; + } + else + { + return HWPosFault; + } } self->retryCount = 0; return HWIdle; @@ -273,12 +284,26 @@ static int evaluateStatus(pMotor self, SConnection *pCon) } else if(iRet == MOTREDO) { + /* + abort if to many positioning faults + */ self->posFaultCount++; if(self->posFaultCount >= 4) { self->posFaultCount = 0; self->retryCount = 0; - return HWPosFault; + /* + do not do pass on positioning fault errors when the + appropriate flag has been set + */ + if(ObVal(self->ParArray,IGNOREFAULT) > 0) + { + return HWIdle; + } + else + { + return HWPosFault; + } } self->pDriver->RunTo(self->pDriver,self->fTarget); return HWBusy; @@ -328,147 +353,6 @@ static void handleMoveCallback(pMotor self, SConnection *pCon) } return status; } -/*-------------------------------------------------------------------------- - Refactor - --------------------------------------------------------------------------*/ - static int MotorStatus2(void *sulf, SConnection *pCon) - { - float fHard; - pMotor self; - int iRet,i, iCode; - char pError[132]; - char pBueffel[256]; - static int iPosFault = 0, iRetry = 0; - MotCallback sCall; - - - assert(sulf); - - self = (pMotor)sulf; - - iRet = self->pDriver->GetStatus(self->pDriver); - fHard = MotorGetValue((void *)self,pCon); - if(fHard < -9999990) - { - self->pDriver->GetError(self->pDriver,&iCode, pError,131); - iRet = self->pDriver->TryAndFixIt(self->pDriver,iCode, self->fTarget); - if(iRet == MOTFAIL) - { - sprintf(pBueffel,"WARNING: %s on %s",pError,self->name); - SCWrite(pCon,pBueffel,eError); - MotorInterrupt(pCon,ObVal(self->ParArray,INT)); - iRetry = 0; - return HWFault; - } - else if(iRet == MOTREDO) - { - iRetry++; - if(iRetry >= 3) - { - iRetry = 0; - return HWFault; - } - } - else - { - iRetry = 0; - return HWBusy; - } - } - - /* invoke callback */ - sCall.fVal = fHard; - sCall.pName = self->name; - InvokeCallBack(self->pCall, MOTDRIVE, &sCall); - - /* motor thinks he is done */ - if( (iRet == OKOK) || (iRet == HWIdle)) - { - MotorGetSoftPosition(self,pCon,&sCall.fVal); - InvokeCallBack(self->pCall, MOTEND, &sCall); - self->fPosition = fHard; - if(absf(fHard - self->fTarget) > ObVal(self->ParArray,PREC)) - { - sprintf(pBueffel,"WARNING: %s off position by %f", - self->name, absf(fHard - self->fTarget)); - SCWrite(pCon,pBueffel, eWarning); - MotorInterrupt(pCon,ObVal(self->ParArray,INT)); - iRetry = 0; - return HWPosFault; - } - iRetry = 0; - return HWIdle; - } - /* motor suggests a fault */ - else if(iRet == HWFault) - { - self->pDriver->GetError(self->pDriver,&iCode, pError,131); - iRet = self->pDriver->TryAndFixIt(self->pDriver,iCode, self->fTarget); - if(iRet == MOTFAIL) - { - sprintf(pBueffel,"ERROR: %s on %s",pError,self->name); - SCWrite(pCon,pBueffel,eError); - MotorInterrupt(pCon,ObVal(self->ParArray,INT)); - iRetry = 0; - return HWFault; - } - else if(iRet == MOTREDO) - { - self->pDriver->RunTo(self->pDriver,self->fTarget); - iRetry++; - if(iRetry >= 3) - { - iRetry = 0; - return HWFault; - } - return HWBusy; - } - else - { - iRetry = 0; - return HWBusy; - } - } - /* a positioning fault */ - else if(iRet == HWPosFault) - { - self->pDriver->GetError(self->pDriver,&iCode, pError,131); - iRet = self->pDriver->TryAndFixIt(self->pDriver,iCode, self->fTarget); - if(iRet == MOTFAIL) - { - sprintf(pBueffel,"ERROR: %s on %s",pError,self->name); - SCWrite(pCon,pBueffel,eError); - MotorInterrupt(pCon,ObVal(self->ParArray,INT)); - iRetry = 0; - return HWFault; - } - else if(iRet == MOTREDO) - { - iPosFault++; - if(iPosFault == 2) - { - iPosFault = 0; - iRetry = 0; - return HWPosFault; - } - self->pDriver->RunTo(self->pDriver,self->fTarget); - return HWBusy; - } - else - { - return HWBusy; - } - } - else if(iRet == HWWarn) - { - self->pDriver->GetError(self->pDriver,&iCode,pError,131); - sprintf(pBueffel,"WARNING: %s on %s",pError,self->name); - SCWrite(pCon,pBueffel,eStatus); - return HWIdle; - } - iRetry = 0; - return iRet; - } /*---------------------------------------------------------------------------*/ pMotor MotorInit(char *drivername, char *name, MotorDriver *pDriv) { pMotor pM = NULL; @@ -486,7 +370,7 @@ static void handleMoveCallback(pMotor self, SConnection *pCon) /* create and initialize parameters */ - pM->ParArray = ObParCreate(13); + pM->ParArray = ObParCreate(14); if(!pM->ParArray) { free(pM); @@ -505,6 +389,7 @@ static void handleMoveCallback(pMotor self, SConnection *pCon) ObParInit(pM->ParArray,SIGN,"sign",1.0,usMugger); ObParInit(pM->ParArray,ECOUNT,"failafter",3.0,usMugger); ObParInit(pM->ParArray,POSCOUNT,"poscount",20.0,usMugger); + ObParInit(pM->ParArray,IGNOREFAULT,"ignorefault",0.0,usMugger); pDriv->GetPosition(pDriv,&(pM->fPosition)); pM->fTarget = pM->fPosition; pM->endScriptID = 0; @@ -813,6 +698,15 @@ extern void KillPiPiezo(void *pData); return 0; } + /* check if the bad motor flag is set */ + if((int)ObVal(self->ParArray,IGNOREFAULT) > 0) + { + snprintf(pBueffel,511,"WARNING: motor %s is unreliable", + self->name); + SCWrite(pCon,pBueffel,eWarning); + self->pDrivInt->iErrorCount = 0; + } + /* check our error count and interrupt if to much */ iCode = (int)ObVal(self->ParArray,ECOUNT); if(self->pDrivInt->iErrorCount > iCode) diff --git a/ofac.c b/ofac.c index 0d334d4f..85eada8e 100644 --- a/ofac.c +++ b/ofac.c @@ -196,6 +196,7 @@ AddCommand(pInter,"ClientPut",ClientPut,NULL,NULL); AddCommand(pInter,"broadcast",Broadcast,NULL,NULL); AddCommand(pInter,"transact",TransactAction,NULL,NULL); + AddCommand(pInter,"fulltransact",TransactAction,NULL,NULL); AddCommand(pInter,"sicsprompt", SicsPrompt,NULL,NULL); AddCommand(pInter,"Publish",TclPublish,NULL,NULL); AddCommand(pInter,"GetLog", LogCapture,NULL,NULL); diff --git a/scan.c b/scan.c index 0769858e..6f88432e 100644 --- a/scan.c +++ b/scan.c @@ -1235,6 +1235,7 @@ int StoreScanCounts(pScanData self, char *data) case eContinue: break; case eAbortOperation: + SCSetInterrupt(self->pCon,eContinue); continue; break; case eAbortScan: