Change movecount to millisecond rather than loop count because of faster loop count on newere hardware/software
r3611 | dcl | 2012-06-19 14:01:09 +1000 (Tue, 19 Jun 2012) | 1 line
This commit is contained in:
@@ -15,6 +15,7 @@ typedef struct __CONFVIRTMOT {
|
||||
float targetValue;
|
||||
int targetReached;
|
||||
int posCount;
|
||||
double last_report_time;
|
||||
char scriptError[512];
|
||||
int parseOK;
|
||||
}ConfigurableVirtualMotor, *pConfigurableVirtualMotor;
|
||||
|
||||
@@ -313,13 +313,24 @@ static int ConfCheckStatus(void *pData, SConnection *pCon){
|
||||
event.fVal = self->pDriv->GetValue(self,pCon);
|
||||
InvokeCallBack(self->pCall, MOTDRIVE, &event);
|
||||
} else if (result == HWBusy) {
|
||||
#if 1
|
||||
double current_time, skip_time, DoubleTime(void);
|
||||
current_time = DoubleTime();
|
||||
skip_time = 0.500;
|
||||
if (self->last_report_time + skip_time >= current_time)
|
||||
#else
|
||||
self->posCount++;
|
||||
if(self->posCount >= 10/*ObVal(self->ParArray,MOVECOUNT)*/)
|
||||
#endif
|
||||
{
|
||||
event.pName = self->name;
|
||||
event.fVal = self->pDriv->GetValue(self,pCon);
|
||||
InvokeCallBack(self->pCall, MOTDRIVE, &event);
|
||||
#if 1
|
||||
self->last_report_time = current_time;
|
||||
#else
|
||||
self->posCount = 0;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
||||
14
motor.c
14
motor.c
@@ -368,15 +368,25 @@ static int evaluateStatus(pMotor self, SConnection *pCon)
|
||||
/*---------------------------------------------------------------------*/
|
||||
static void handleMoveCallback(pMotor self, SConnection *pCon)
|
||||
{
|
||||
MotCallback sCall;
|
||||
|
||||
#if 1
|
||||
double current_time, skip_time, DoubleTime(void);
|
||||
current_time = DoubleTime();
|
||||
skip_time = 0.001 * ObVal(self->ParArray,MOVECOUNT);
|
||||
if(self->last_report_time + skip_time >= current_time)
|
||||
#else
|
||||
self->posCount++;
|
||||
if(self->posCount >= ObVal(self->ParArray,MOVECOUNT))
|
||||
#endif
|
||||
{
|
||||
MotCallback sCall;
|
||||
MotorGetSoftPosition(self,pCon,&sCall.fVal);
|
||||
sCall.pName = self->name;
|
||||
InvokeCallBack(self->pCall, MOTDRIVE, &sCall);
|
||||
#if 1
|
||||
self->last_report_time = current_time;
|
||||
#else
|
||||
self->posCount = 0;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------------------*/
|
||||
|
||||
Reference in New Issue
Block a user