Add uninterest to Virtual Motors and externalize CheckMotiMatch in motor.c

r3548 | dcl | 2012-05-18 14:05:11 +1000 (Fri, 18 May 2012) | 1 line
This commit is contained in:
Douglas Clowes
2012-05-18 14:05:11 +10:00
parent 585b67ca5a
commit 32d8224dd7
2 changed files with 9 additions and 1 deletions

View File

@@ -22,6 +22,7 @@
#define BAD_VALUE (-9999.99) #define BAD_VALUE (-9999.99)
extern char *stptok(char *s, char *t, int len, char *brk); extern char *stptok(char *s, char *t, int len, char *brk);
extern int CheckMotiMatch(const void* context, const void* pUserData);
/*--------------------------------------------------------------------------- /*---------------------------------------------------------------------------
An internal data structure which holds information required to control An internal data structure which holds information required to control
@@ -571,10 +572,17 @@ int ConfigurableVirtualMotorAction(SConnection *pCon, SicsInterp *pSics,
} }
pRegInfo->lastValue = value; pRegInfo->lastValue = value;
RemoveCallback3(self->pCall, InterestCallback, CheckMotiMatch, pCon); /* only this one */
lID = RegisterCallback(self->pCall, SCGetContext(pCon),MOTDRIVE, InterestCallback, pRegInfo, KillInfo); lID = RegisterCallback(self->pCall, SCGetContext(pCon),MOTDRIVE, InterestCallback, pRegInfo, KillInfo);
SCRegister(pCon,pSics, self->pCall,lID); SCRegister(pCon,pSics, self->pCall,lID);
SCSendOK(pCon); SCSendOK(pCon);
return 1; return 1;
}
else if(strcmp(argv[1],"uninterest") == 0)
{
RemoveCallback3(self->pCall, InterestCallback, CheckMotiMatch, 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]);

View File

@@ -1190,7 +1190,7 @@ extern MotorDriver *MakePiPiezo(Tcl_Interp *pTcl, char *pArray);
return iRet; return iRet;
} }
static int CheckMotiMatch(const void* context, const void* pUserData) int CheckMotiMatch(const void* context, const void* pUserData)
{ {
pMotInfo pMoti = (pMotInfo) pUserData; pMotInfo pMoti = (pMotInfo) pUserData;
SConnection *pCon = (SConnection*) context; SConnection *pCon = (SConnection*) context;