progressive patching
This commit is contained in:
@ -35,6 +35,9 @@
|
||||
#include "confvirtmot.h"
|
||||
#include "confvirtmot.i"
|
||||
|
||||
#define BAD_VALUE (-9999.99)
|
||||
extern double DoubleTime(void);
|
||||
|
||||
extern char *stptok(char *s, char *t, int len, char *brk);
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
@ -213,6 +216,7 @@ static long ConfSetValue(void *pData, SConnection * pCon, float newValue)
|
||||
self->targetValue = newValue;
|
||||
self->targetReached = 0;
|
||||
self->posCount = 0;
|
||||
self->last_report_time = 0.0;
|
||||
|
||||
status = startMotorList(self, pCon);
|
||||
if (status != OKOK) {
|
||||
@ -384,12 +388,14 @@ static int ConfCheckStatus(void *pData, SConnection * pCon)
|
||||
InvokeCallBack(self->pCall, MOTDRIVE, &event);
|
||||
}
|
||||
} else if (result == HWBusy) {
|
||||
self->posCount++;
|
||||
if (self->posCount >= 10 /*ObVal(self->ParArray,MOVECOUNT) */ ) {
|
||||
double current_time, skip_time;
|
||||
current_time = DoubleTime();
|
||||
skip_time = 0.500;
|
||||
if (self->last_report_time + skip_time <= current_time) {
|
||||
event.pName = self->name;
|
||||
event.fVal = self->pDriv->GetValue(self, pCon);
|
||||
InvokeCallBack(self->pCall, MOTDRIVE, &event);
|
||||
self->posCount = 0;
|
||||
self->last_report_time = current_time;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
@ -445,7 +451,7 @@ static void checkMotorValues(pConfigurableVirtualMotor self,
|
||||
static float ConfGetValue(void *pData, SConnection * pCon)
|
||||
{
|
||||
pConfigurableVirtualMotor self = (pConfigurableVirtualMotor) pData;
|
||||
float currentValue = -9999.99;
|
||||
float currentValue = BAD_VALUE;
|
||||
|
||||
assert(self != NULL);
|
||||
|
||||
@ -507,6 +513,14 @@ static void KillConfigurableVirtualMotor(void *data)
|
||||
free(self->state);
|
||||
self->state = NULL;
|
||||
}
|
||||
if (self->pCall != NULL) {
|
||||
DeleteCallBackInterface(self->pCall);
|
||||
self->pCall = NULL;
|
||||
}
|
||||
if (self->pDriv != NULL) {
|
||||
free(self->pDriv);
|
||||
self->pDriv = NULL;
|
||||
}
|
||||
free(self);
|
||||
self = NULL;
|
||||
}
|
||||
@ -535,6 +549,7 @@ int MakeConfigurableVirtualMotor(SConnection * pCon, SicsInterp * pSics,
|
||||
|
||||
pNew->name = strdup(argv[1]);
|
||||
pNew->posCount = 0;
|
||||
pNew->last_report_time = 0.0;
|
||||
pNew->pDes = CreateDescriptor("ConfigurableVirtualMotor");
|
||||
pNew->pDriv = CreateDrivableInterface();
|
||||
pNew->motorList = LLDcreate(sizeof(RealMotor));
|
||||
@ -584,7 +599,6 @@ int ConfigurableVirtualMotorAction(SConnection * pCon, SicsInterp * pSics,
|
||||
pConfigurableVirtualMotor self = NULL;
|
||||
char pBueffel[512];
|
||||
float value;
|
||||
int iRet;
|
||||
long lID;
|
||||
pRegisteredInfo pRegInfo = NULL;
|
||||
|
||||
@ -699,10 +713,15 @@ int ConfigurableVirtualMotorAction(SConnection * pCon, SicsInterp * pSics,
|
||||
}
|
||||
pRegInfo->lastValue = value;
|
||||
|
||||
RemoveCallbackCon(self->pCall, pCon);
|
||||
lID = RegisterCallback(self->pCall, MOTDRIVE,
|
||||
InterestCallback, pRegInfo, KillInfo);
|
||||
SCSendOK(pCon);
|
||||
return 1;
|
||||
} else if(strcmp(argv[1],"uninterest") == 0) {
|
||||
RemoveCallbackCon(self->pCall, pCon);
|
||||
SCSendOK(pCon);
|
||||
return 1;
|
||||
} else {
|
||||
snprintf(pBueffel, 5120, "ERROR: subcommand %s to %s unknown",
|
||||
argv[1], argv[0]);
|
||||
|
Reference in New Issue
Block a user