PSI sics-cvs-psi-2008-10-02
This commit is contained in:
50
motor.c
50
motor.c
@@ -76,13 +76,6 @@
|
||||
#define IGNOREFAULT 10
|
||||
#define MOVECOUNT 11
|
||||
|
||||
/*------------------------------------------------------------------------
|
||||
a tiny structure used in CallBack work
|
||||
*/
|
||||
typedef struct {
|
||||
float fVal;
|
||||
char *pName;
|
||||
} MotCallback;
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
static void *MotorGetInterface(void *pData, int iID)
|
||||
@@ -142,7 +135,7 @@
|
||||
float fVal = 0.;
|
||||
|
||||
assert(pData);
|
||||
iRet = MotorGetHardPosition((pMotor)pData,pCon,&fVal);
|
||||
iRet = MotorGetSoftPosition((pMotor)pData,pCon,&fVal);
|
||||
if(iRet != OKOK)
|
||||
{
|
||||
fVal = -9999999.99;
|
||||
@@ -178,8 +171,10 @@
|
||||
fputs(pBueffel,fd);
|
||||
sprintf(pBueffel,"%s AccessCode %f\n",name,ObVal(self->ParArray,USRIGHTS));
|
||||
fputs(pBueffel,fd);
|
||||
sprintf(pBueffel,"%s poscount %f\n",name,
|
||||
ObVal(self->ParArray,POSCOUNT));
|
||||
sprintf(pBueffel,"%s failafter %f\n",name,ObVal(self->ParArray,ECOUNT));
|
||||
fputs(pBueffel,fd);
|
||||
sprintf(pBueffel,"%s maxretry %f\n",name,ObVal(self->ParArray,POSCOUNT));
|
||||
fputs(pBueffel,fd);
|
||||
sprintf(pBueffel,"%s movecount %f\n",name,
|
||||
ObVal(self->ParArray,MOVECOUNT));
|
||||
fputs(pBueffel,fd);
|
||||
@@ -262,6 +257,8 @@ static void finishDriving(pMotor self, SConnection *pCon)
|
||||
MotCallback sCall;
|
||||
MotorGetSoftPosition(self,pCon,&sCall.fVal);
|
||||
sCall.pName = self->name;
|
||||
self->fPosition = sCall.fVal;
|
||||
self->fPosition = sCall.fVal;
|
||||
InvokeCallBack(self->pCall, MOTDRIVE, &sCall); /* send also very last position */
|
||||
InvokeCallBack(self->pCall, MOTEND, &sCall);
|
||||
}
|
||||
@@ -336,7 +333,7 @@ static int evaluateStatus(pMotor self, SConnection *pCon)
|
||||
newStatus = checkPosition(self,pCon);
|
||||
if(newStatus != HWBusy)
|
||||
{
|
||||
finishDriving(self,pCon);
|
||||
finishDriving(self,pCon);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -357,6 +354,7 @@ static int evaluateStatus(pMotor self, SConnection *pCon)
|
||||
}
|
||||
if(newStatus == HWFault)
|
||||
{
|
||||
finishDriving(self,pCon);
|
||||
MotorInterrupt(pCon,ObVal(self->ParArray,INT));
|
||||
self->retryCount = 0;
|
||||
}
|
||||
@@ -416,7 +414,7 @@ static void handleMoveCallback(pMotor self, SConnection *pCon)
|
||||
|
||||
|
||||
/* create and initialize parameters */
|
||||
pM->ParArray = ObParCreate(12);
|
||||
pM->ParArray = ObParCreate(MOTOBPARLENGTH);
|
||||
if(!pM->ParArray)
|
||||
{
|
||||
free(pM);
|
||||
@@ -492,6 +490,8 @@ extern void KillPiPiezo(void *pData);
|
||||
|
||||
pM = (pMotor)self;
|
||||
|
||||
/* MotorHalt(pM); */
|
||||
|
||||
if(pM->name)
|
||||
free(pM->name);
|
||||
|
||||
@@ -604,6 +604,7 @@ extern void KillPiPiezo(void *pData);
|
||||
if(iRet == 1)
|
||||
{
|
||||
SCparChange(pCon);
|
||||
InvokeCallBack(self->pCall,HDBVAL,self);
|
||||
return iRet;
|
||||
}
|
||||
}
|
||||
@@ -629,6 +630,7 @@ extern void KillPiPiezo(void *pData);
|
||||
fLimit -= fChange;
|
||||
ObParSet(self->ParArray,self->name,"softlowerlim",fLimit,pCon);
|
||||
SCparChange(pCon);
|
||||
InvokeCallBack(self->pCall,HDBVAL,self);
|
||||
|
||||
return 1;
|
||||
}
|
||||
@@ -650,6 +652,7 @@ extern void KillPiPiezo(void *pData);
|
||||
ObParInit(self->ParArray,SZERO,"softzero",ZEROINACTIVE,usUser);
|
||||
}
|
||||
}
|
||||
InvokeCallBack(self->pCall,HDBVAL,self);
|
||||
SCparChange(pCon);
|
||||
|
||||
return iRet;
|
||||
@@ -745,10 +748,11 @@ extern void KillPiPiezo(void *pData);
|
||||
}
|
||||
|
||||
/* check boundaries first */
|
||||
iRet = MotorCheckBoundary(self,fNew,&fHard,pBueffel,511);
|
||||
iRet = MotorCheckBoundary(self,fNew,&fHard,pError,131);
|
||||
if(!iRet)
|
||||
{
|
||||
SCWrite(pCon,pBueffel,eStatus);
|
||||
snprintf(pBueffel,511,"ERROR: %s",pError);
|
||||
SCWrite(pCon,pBueffel,eError);
|
||||
SCSetInterrupt(pCon,eAbortOperation);
|
||||
return 0;
|
||||
}
|
||||
@@ -782,6 +786,7 @@ extern void KillPiPiezo(void *pData);
|
||||
self->retryCount = 0;
|
||||
self->stopped = 0;
|
||||
self->fTarget = fHard;
|
||||
InvokeCallBack(self->pCall,HDBVAL,self);
|
||||
self->posCount = 0;
|
||||
iRet = self->pDriver->RunTo(self->pDriver,fHard);
|
||||
if(iRet != OKOK)
|
||||
@@ -1022,7 +1027,22 @@ extern MotorDriver *MakePiPiezo(Tcl_Interp *pTcl, char *pArray);
|
||||
SCWrite(pCon,pBueffel,eError);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
} else if(strcmp(argv[2],"regress") == 0)
|
||||
{
|
||||
pDriver = RGMakeMotorDriver();
|
||||
if(!pDriver)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
/* create the motor */
|
||||
pNew = MotorInit("regress",argv[1],pDriver);
|
||||
if(!pNew)
|
||||
{
|
||||
sprintf(pBueffel,"Failure to create motor %s",argv[1]);
|
||||
SCWrite(pCon,pBueffel,eError);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
site = getSite();
|
||||
|
||||
Reference in New Issue
Block a user