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;
|
float targetValue;
|
||||||
int targetReached;
|
int targetReached;
|
||||||
int posCount;
|
int posCount;
|
||||||
|
double last_report_time;
|
||||||
char scriptError[512];
|
char scriptError[512];
|
||||||
int parseOK;
|
int parseOK;
|
||||||
}ConfigurableVirtualMotor, *pConfigurableVirtualMotor;
|
}ConfigurableVirtualMotor, *pConfigurableVirtualMotor;
|
||||||
|
|||||||
@@ -313,13 +313,24 @@ static int ConfCheckStatus(void *pData, SConnection *pCon){
|
|||||||
event.fVal = self->pDriv->GetValue(self,pCon);
|
event.fVal = self->pDriv->GetValue(self,pCon);
|
||||||
InvokeCallBack(self->pCall, MOTDRIVE, &event);
|
InvokeCallBack(self->pCall, MOTDRIVE, &event);
|
||||||
} else if (result == HWBusy) {
|
} 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++;
|
self->posCount++;
|
||||||
if(self->posCount >= 10/*ObVal(self->ParArray,MOVECOUNT)*/)
|
if(self->posCount >= 10/*ObVal(self->ParArray,MOVECOUNT)*/)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
event.pName = self->name;
|
event.pName = self->name;
|
||||||
event.fVal = self->pDriv->GetValue(self,pCon);
|
event.fVal = self->pDriv->GetValue(self,pCon);
|
||||||
InvokeCallBack(self->pCall, MOTDRIVE, &event);
|
InvokeCallBack(self->pCall, MOTDRIVE, &event);
|
||||||
|
#if 1
|
||||||
|
self->last_report_time = current_time;
|
||||||
|
#else
|
||||||
self->posCount = 0;
|
self->posCount = 0;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
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)
|
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++;
|
self->posCount++;
|
||||||
if(self->posCount >= ObVal(self->ParArray,MOVECOUNT))
|
if(self->posCount >= ObVal(self->ParArray,MOVECOUNT))
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
|
MotCallback sCall;
|
||||||
MotorGetSoftPosition(self,pCon,&sCall.fVal);
|
MotorGetSoftPosition(self,pCon,&sCall.fVal);
|
||||||
sCall.pName = self->name;
|
sCall.pName = self->name;
|
||||||
InvokeCallBack(self->pCall, MOTDRIVE, &sCall);
|
InvokeCallBack(self->pCall, MOTDRIVE, &sCall);
|
||||||
|
#if 1
|
||||||
|
self->last_report_time = current_time;
|
||||||
|
#else
|
||||||
self->posCount = 0;
|
self->posCount = 0;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*-----------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------*/
|
||||||
|
|||||||
1
motor.h
1
motor.h
@@ -33,6 +33,7 @@
|
|||||||
int posFaultCount;
|
int posFaultCount;
|
||||||
int stopped;
|
int stopped;
|
||||||
int moving; /* for enabling MOTDRIVE/MOTEND reporting */
|
int moving; /* for enabling MOTDRIVE/MOTEND reporting */
|
||||||
|
double last_report_time;
|
||||||
} Motor;
|
} Motor;
|
||||||
typedef Motor *pMotor;
|
typedef Motor *pMotor;
|
||||||
/*------------------------------------------------------------------------
|
/*------------------------------------------------------------------------
|
||||||
|
|||||||
Reference in New Issue
Block a user