progressive patching
This commit is contained in:
@ -174,8 +174,8 @@ static void KillAdapter(void *pData)
|
|||||||
if (self->pInt)
|
if (self->pInt)
|
||||||
free(self->pInt);
|
free(self->pInt);
|
||||||
|
|
||||||
if (self->pParName);
|
if (self->pParName)
|
||||||
free(self->pParName);
|
free(self->pParName);
|
||||||
|
|
||||||
free(self);
|
free(self);
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,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;
|
||||||
|
@ -35,6 +35,9 @@
|
|||||||
#include "confvirtmot.h"
|
#include "confvirtmot.h"
|
||||||
#include "confvirtmot.i"
|
#include "confvirtmot.i"
|
||||||
|
|
||||||
|
#define BAD_VALUE (-9999.99)
|
||||||
|
extern double DoubleTime(void);
|
||||||
|
|
||||||
extern char *stptok(char *s, char *t, int len, char *brk);
|
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->targetValue = newValue;
|
||||||
self->targetReached = 0;
|
self->targetReached = 0;
|
||||||
self->posCount = 0;
|
self->posCount = 0;
|
||||||
|
self->last_report_time = 0.0;
|
||||||
|
|
||||||
status = startMotorList(self, pCon);
|
status = startMotorList(self, pCon);
|
||||||
if (status != OKOK) {
|
if (status != OKOK) {
|
||||||
@ -384,12 +388,14 @@ static int ConfCheckStatus(void *pData, SConnection * pCon)
|
|||||||
InvokeCallBack(self->pCall, MOTDRIVE, &event);
|
InvokeCallBack(self->pCall, MOTDRIVE, &event);
|
||||||
}
|
}
|
||||||
} else if (result == HWBusy) {
|
} else if (result == HWBusy) {
|
||||||
self->posCount++;
|
double current_time, skip_time;
|
||||||
if (self->posCount >= 10 /*ObVal(self->ParArray,MOVECOUNT) */ ) {
|
current_time = DoubleTime();
|
||||||
|
skip_time = 0.500;
|
||||||
|
if (self->last_report_time + skip_time <= current_time) {
|
||||||
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);
|
||||||
self->posCount = 0;
|
self->last_report_time = current_time;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
@ -445,7 +451,7 @@ static void checkMotorValues(pConfigurableVirtualMotor self,
|
|||||||
static float ConfGetValue(void *pData, SConnection * pCon)
|
static float ConfGetValue(void *pData, SConnection * pCon)
|
||||||
{
|
{
|
||||||
pConfigurableVirtualMotor self = (pConfigurableVirtualMotor) pData;
|
pConfigurableVirtualMotor self = (pConfigurableVirtualMotor) pData;
|
||||||
float currentValue = -9999.99;
|
float currentValue = BAD_VALUE;
|
||||||
|
|
||||||
assert(self != NULL);
|
assert(self != NULL);
|
||||||
|
|
||||||
@ -507,6 +513,14 @@ static void KillConfigurableVirtualMotor(void *data)
|
|||||||
free(self->state);
|
free(self->state);
|
||||||
self->state = NULL;
|
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);
|
free(self);
|
||||||
self = NULL;
|
self = NULL;
|
||||||
}
|
}
|
||||||
@ -535,6 +549,7 @@ int MakeConfigurableVirtualMotor(SConnection * pCon, SicsInterp * pSics,
|
|||||||
|
|
||||||
pNew->name = strdup(argv[1]);
|
pNew->name = strdup(argv[1]);
|
||||||
pNew->posCount = 0;
|
pNew->posCount = 0;
|
||||||
|
pNew->last_report_time = 0.0;
|
||||||
pNew->pDes = CreateDescriptor("ConfigurableVirtualMotor");
|
pNew->pDes = CreateDescriptor("ConfigurableVirtualMotor");
|
||||||
pNew->pDriv = CreateDrivableInterface();
|
pNew->pDriv = CreateDrivableInterface();
|
||||||
pNew->motorList = LLDcreate(sizeof(RealMotor));
|
pNew->motorList = LLDcreate(sizeof(RealMotor));
|
||||||
@ -584,7 +599,6 @@ int ConfigurableVirtualMotorAction(SConnection * pCon, SicsInterp * pSics,
|
|||||||
pConfigurableVirtualMotor self = NULL;
|
pConfigurableVirtualMotor self = NULL;
|
||||||
char pBueffel[512];
|
char pBueffel[512];
|
||||||
float value;
|
float value;
|
||||||
int iRet;
|
|
||||||
long lID;
|
long lID;
|
||||||
pRegisteredInfo pRegInfo = NULL;
|
pRegisteredInfo pRegInfo = NULL;
|
||||||
|
|
||||||
@ -699,10 +713,15 @@ int ConfigurableVirtualMotorAction(SConnection * pCon, SicsInterp * pSics,
|
|||||||
}
|
}
|
||||||
pRegInfo->lastValue = value;
|
pRegInfo->lastValue = value;
|
||||||
|
|
||||||
|
RemoveCallbackCon(self->pCall, pCon);
|
||||||
lID = RegisterCallback(self->pCall, MOTDRIVE,
|
lID = RegisterCallback(self->pCall, MOTDRIVE,
|
||||||
InterestCallback, pRegInfo, KillInfo);
|
InterestCallback, pRegInfo, KillInfo);
|
||||||
SCSendOK(pCon);
|
SCSendOK(pCon);
|
||||||
return 1;
|
return 1;
|
||||||
|
} else if(strcmp(argv[1],"uninterest") == 0) {
|
||||||
|
RemoveCallbackCon(self->pCall, pCon);
|
||||||
|
SCSendOK(pCon);
|
||||||
|
return 1;
|
||||||
} else {
|
} else {
|
||||||
snprintf(pBueffel, 5120, "ERROR: subcommand %s to %s unknown",
|
snprintf(pBueffel, 5120, "ERROR: subcommand %s to %s unknown",
|
||||||
argv[1], argv[0]);
|
argv[1], argv[0]);
|
||||||
|
@ -22,6 +22,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;
|
||||||
|
7
conman.c
7
conman.c
@ -622,7 +622,7 @@ int SCPrintf(SConnection * self, int iOut, char *fmt, ...)
|
|||||||
va_list ap;
|
va_list ap;
|
||||||
char buf[256];
|
char buf[256];
|
||||||
char *dyn;
|
char *dyn;
|
||||||
int l;
|
unsigned int l;
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
@ -765,7 +765,10 @@ int SCNormalWrite(SConnection * self, char *buffer, int iOut)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* log it for any case */
|
/* log it for any case */
|
||||||
SICSLogWrite(buffer, iOut);
|
if (!(iOut == eInternal
|
||||||
|
|| (buffer[0] == 'O' && buffer[1] == 'K'
|
||||||
|
&& (buffer[2] == '\0' || buffer[2] == '\r' || buffer[2] == '\n'))))
|
||||||
|
SICSLogWrite(buffer, iOut);
|
||||||
|
|
||||||
testAndWriteCommandLog(self, buffer, iOut);
|
testAndWriteCommandLog(self, buffer, iOut);
|
||||||
|
|
||||||
|
16
costa.c
16
costa.c
@ -108,10 +108,6 @@ int CostaTop(pCosta self, char *pCommand)
|
|||||||
|
|
||||||
assert(self);
|
assert(self);
|
||||||
|
|
||||||
/* check for lock */
|
|
||||||
if (self->iLock) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
/* check Size */
|
/* check Size */
|
||||||
if (self->iCount >= self->iMaxSize) {
|
if (self->iCount >= self->iMaxSize) {
|
||||||
return 0;
|
return 0;
|
||||||
@ -138,11 +134,6 @@ int CostaBottom(pCosta self, char *pCommand)
|
|||||||
int iRet, iRes = 1;
|
int iRet, iRes = 1;
|
||||||
assert(self);
|
assert(self);
|
||||||
|
|
||||||
/* check for lock */
|
|
||||||
if (self->iLock) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* do not want 0 commands */
|
/* do not want 0 commands */
|
||||||
if (strlen(pCommand) < 1) {
|
if (strlen(pCommand) < 1) {
|
||||||
return 1;
|
return 1;
|
||||||
@ -187,3 +178,10 @@ void CostaUnlock(pCosta self)
|
|||||||
{
|
{
|
||||||
self->iLock = 0;
|
self->iLock = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*--------------------------------------------------------------------------*/
|
||||||
|
int CostaLocked(pCosta self)
|
||||||
|
{
|
||||||
|
return self->iLock;
|
||||||
|
}
|
||||||
|
|
||||||
|
1
costa.h
1
costa.h
@ -25,5 +25,6 @@ int CostaPop(pCosta self, char **pPtr);
|
|||||||
/*----------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------*/
|
||||||
void CostaLock(pCosta self);
|
void CostaLock(pCosta self);
|
||||||
void CostaUnlock(pCosta self);
|
void CostaUnlock(pCosta self);
|
||||||
|
int CostaLocked(pCosta self);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -61,6 +61,7 @@ pCounterDriver CreateCounterDriver(char *name, char *type)
|
|||||||
pRes->fPreset = 1000.;
|
pRes->fPreset = 1000.;
|
||||||
pRes->fTime = 0.;
|
pRes->fTime = 0.;
|
||||||
pRes->iNoOfMonitors = 0;
|
pRes->iNoOfMonitors = 0;
|
||||||
|
pRes->iControlMonitor = 0;
|
||||||
pRes->iPause = 0;
|
pRes->iPause = 0;
|
||||||
pRes->Start = NULL;
|
pRes->Start = NULL;
|
||||||
pRes->GetStatus = NULL;
|
pRes->GetStatus = NULL;
|
||||||
|
@ -42,6 +42,7 @@ typedef struct __COUNTER {
|
|||||||
float fLastCurrent;
|
float fLastCurrent;
|
||||||
float fTime;
|
float fTime;
|
||||||
int iNoOfMonitors;
|
int iNoOfMonitors;
|
||||||
|
int iControlMonitor;
|
||||||
long lCounts[MAXCOUNT];
|
long lCounts[MAXCOUNT];
|
||||||
int iPause;
|
int iPause;
|
||||||
int iErrorCode;
|
int iErrorCode;
|
||||||
|
Reference in New Issue
Block a user