diff --git a/confvirtmot.i b/confvirtmot.i index d2ea3dec..2aab838c 100644 --- a/confvirtmot.i +++ b/confvirtmot.i @@ -15,6 +15,7 @@ typedef struct __CONFVIRTMOT { float targetValue; int targetReached; int posCount; + double last_report_time; char scriptError[512]; int parseOK; }ConfigurableVirtualMotor, *pConfigurableVirtualMotor; diff --git a/confvirtualmot.c b/confvirtualmot.c index 69f7a000..b42523b6 100644 --- a/confvirtualmot.c +++ b/confvirtualmot.c @@ -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; diff --git a/motor.c b/motor.c index d68aba4a..97ba01ec 100644 --- a/motor.c +++ b/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 } } /*-----------------------------------------------------------------------*/ diff --git a/motor.h b/motor.h index 54266ff5..f86530a4 100644 --- a/motor.h +++ b/motor.h @@ -33,6 +33,7 @@ int posFaultCount; int stopped; int moving; /* for enabling MOTDRIVE/MOTEND reporting */ + double last_report_time; } Motor; typedef Motor *pMotor; /*------------------------------------------------------------------------