avoid multiple running drive tasks for the same object

This commit is contained in:
2021-10-20 17:06:55 +02:00
parent 61341b52f4
commit f3d95891ad
4 changed files with 20 additions and 0 deletions

View File

@ -279,6 +279,8 @@ int StartDevice(pExeList self, char *name, pObjectDescriptor pDes,
return 0;
}
EndDriveTask(pData); /* BEGIN experimental: stop pending drive task for this objects immediately */
SetDevexecStatus(self,DEVDONE);
if(self->waitID < 0 && level == RUNDRIVE){
self->waitID = GetTaskGroupID(pServ->pTasker);

View File

@ -70,6 +70,7 @@ typedef struct {
#define TOKENRELEASE 303
#define COMLOG 304
#define CRONFUNC 305
#define ENDDRIVETASK 306
#line 131 "event.w"

View File

@ -224,9 +224,23 @@ static void DriveTaskSignal(void *data, int iSignal, void *pSigData)
taskData->pDriv->Halt(taskData->obj);
SCSetInterrupt(taskData->pCon,*interrupt);
}
} else if (iSignal == ENDDRIVETASK) {
if (taskData->obj == pSigData) {
taskData->pDriv = NULL; /* tell DriveTaskFunc to quit */
}
}
}
/*--------------------------------------------------------------------------*/
void EndDriveTask(void *obj) {
/* End a drive task for obj.
Originally in SICS, it was not possible to run an object already running
this was relaxed in SEA, but with the downside, that several drive tasks
for the same object may be running, removed only when the run succeds.
This is called in StartDevice, before creating a new drive task.
*/
TaskSignal(pServ->pTasker, ENDDRIVETASK, obj);
}
/*--------------------------------------------------------------------------*/
static int DriveTaskFunc(void *data)
{
DriveTaskData *taskData = (DriveTaskData *)data;
@ -234,6 +248,7 @@ static int DriveTaskFunc(void *data)
assert(taskData != NULL);
if (!taskData->pDriv) return 0;
status = taskData->pDriv->CheckStatus(taskData->obj,taskData->pCon);
if(status == HWBusy){

View File

@ -48,6 +48,8 @@
float *fPos);
long StartDriveTask(void *self, SConnection *pCon, char *name, float fTarget);
void EndDriveTask(void *data);
/* end a drive task replaced by a new one with the same object*/
#line 438 "interface.w"