Fixed a minor memory leak in count and drive task handling

Reformatted multicountser to become clearer
Minor fixes
Added more tracing output to sort the SANSLI problem
This commit is contained in:
2014-10-13 13:36:37 +02:00
parent 8ea20b87f4
commit b319461531
8 changed files with 155 additions and 135 deletions

View File

@ -543,6 +543,7 @@ void DeleteInterp(SicsInterp * self)
call KillSicsUnknown instead to clean up all memory properly. M.Z., Apr 05 call KillSicsUnknown instead to clean up all memory properly. M.Z., Apr 05
*/ */
Tcl_DeleteInterp(pTcl);
KillSicsUnknown(); KillSicsUnknown();
} }

3
cone.c
View File

@ -171,7 +171,6 @@ static long ConeSetValue(void *pData, SConnection * pCon, float fVal)
*/ */
SICSHdbGetPar(obj, pCon, "target", &v); SICSHdbGetPar(obj, pCon, "target", &v);
target.h = v.v.floatArray[0]; target.h = v.v.floatArray[0];
target.k = v.v.floatArray[1];
target.l = v.v.floatArray[2]; target.l = v.v.floatArray[2];
SICSHdbGetPar(obj, pCon, "qscale", &v); SICSHdbGetPar(obj, pCon, "qscale", &v);
/* /*
@ -198,7 +197,7 @@ static long ConeSetValue(void *pData, SConnection * pCon, float fVal)
mat_free(csToPsi); mat_free(csToPsi);
if (status != 1) { if (status != 1) {
SCWrite(pCon, "ERROR: cannot get cone vector into scattering position", SCWrite(pCon, "ERROR: cannot get cone vector into scattering position",
eError); eLogError);
SCSetInterrupt(pCon, eAbortOperation); SCSetInterrupt(pCon, eAbortOperation);
return 0; return 0;
} }

View File

@ -188,6 +188,7 @@ pExeList CreateExeList(pTaskMan pTask)
pRes->pCall = CreateCallBackInterface(); pRes->pCall = CreateCallBackInterface();
pRes->lastRun = time(NULL); pRes->lastRun = time(NULL);
pRes->pDes->GetInterface = DevexecInterface; pRes->pDes->GetInterface = DevexecInterface;
pRes->instStatus = eEager;
return pRes; return pRes;
} }

View File

@ -126,6 +126,9 @@ static int HMCStatus(void *pData, SConnection * pCon)
assert(self); assert(self);
if(self->checkSlaves == 0) { if(self->checkSlaves == 0) {
/*
check master
*/
status = self->slaves[0]->CheckCountStatus(self->slaveData[0], pCon); status = self->slaves[0]->CheckCountStatus(self->slaveData[0], pCon);
/* /*
Warning: this assumes that slaves 1 - MAXSLAVE are histogram memories. Warning: this assumes that slaves 1 - MAXSLAVE are histogram memories.
@ -194,7 +197,7 @@ static int HMCBoaStatus(void *pData, SConnection * pCon)
HMCHalt(self); HMCHalt(self);
ReleaseCountLock(self->pCount); ReleaseCountLock(self->pCount);
self->checkSlaves = 0; self->checkSlaves = 0;
for(j = 0; j < 100; j++){ for(j = 0; j < 200; j++){
SicsWait(1); SicsWait(1);
status = self->slaves[i]->CheckCountStatus(self->slaveData[i], pCon); status = self->slaves[i]->CheckCountStatus(self->slaveData[i], pCon);
if(status == HWIdle || status == HWFault) { if(status == HWIdle || status == HWFault) {

View File

@ -196,6 +196,7 @@ static void KillDriveTaskData(void *data)
if(taskData->pCon != NULL){ if(taskData->pCon != NULL){
SCDeleteConnection(taskData->pCon); SCDeleteConnection(taskData->pCon);
} }
free(taskData);
} }
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
static void DriveTaskSignal(void *data, int iSignal, void *pSigData) static void DriveTaskSignal(void *data, int iSignal, void *pSigData)
@ -240,6 +241,7 @@ static int DriveTaskFunc(void *data)
} else { } else {
ExeInterest(pServ->pExecutor,taskData->name, "finished with problem"); ExeInterest(pServ->pExecutor,taskData->name, "finished with problem");
} }
traceSys("drive","DriveTask %s finished with state %d", taskData->name,status);
return 0; return 0;
} }
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/
@ -338,6 +340,7 @@ static void KillCountTaskData(void *data)
if(taskData->pCon != NULL){ if(taskData->pCon != NULL){
SCDeleteConnection(taskData->pCon); SCDeleteConnection(taskData->pCon);
} }
free(taskData);
} }
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
static void CountTaskSignal(void *data, int iSignal, void *pSigData) static void CountTaskSignal(void *data, int iSignal, void *pSigData)
@ -389,6 +392,7 @@ static int CountTaskFunc(void *data)
} else { } else {
ExeInterest(pServ->pExecutor,taskData->name, "finished with problem"); ExeInterest(pServ->pExecutor,taskData->name, "finished with problem");
} }
traceSys("count","CountTask %s finished with state %d", taskData->name,status);
return 0; return 0;
} }
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/

View File

@ -239,7 +239,7 @@ static hdbCallbackReturn MultiSecControllCallback(pHdb node,
return hdbContinue; return hdbContinue;
} }
/*--------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------2-*/
static int MultiSecTransfer(void *pData, SConnection * pCon) static int MultiSecTransfer(void *pData, SConnection * pCon)
{ {
int i, retVal = OKOK, tclStatus; int i, retVal = OKOK, tclStatus;
@ -253,6 +253,7 @@ static int MultiSecTransfer(void *pData, SConnection * pCon)
transfer = GetHipadabaNode(pCount->objectNode,"transfer"); transfer = GetHipadabaNode(pCount->objectNode,"transfer");
if(transfer != NULL){ if(transfer != NULL){
myCon = SCCopyConnection(pCon); myCon = SCCopyConnection(pCon);
SCsetMacro(myCon,1);
MacroPush(myCon); MacroPush(myCon);
tclStatus = Tcl_Eval(InterpGetTcl(pServ->pSics), transfer->value.v.text); tclStatus = Tcl_Eval(InterpGetTcl(pServ->pSics), transfer->value.v.text);
if (tclStatus != TCL_OK) { if (tclStatus != TCL_OK) {
@ -269,8 +270,8 @@ static int MultiSecTransfer(void *pData, SConnection * pCon)
return retVal; return retVal;
} }
/*-------------------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------------------*/
static int isMultiMasterRunning(pCounter self, SConnection *pCon, int *status) static int isMultiMasterRunning(pCounter self, SConnection *pCon, int *status)
{ {
pHdb mID, master, myStatus, control, ccd, stopTime, timeNode; pHdb mID, master, myStatus, control, ccd, stopTime, timeNode;
hdbValue v; hdbValue v;
long mlID; long mlID;
@ -357,10 +358,10 @@ static int isMultiMasterRunning(pCounter self, SConnection *pCon, int *status)
} }
} }
return 1; return 1;
} }
/*-------------------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------------------*/
static int areSlavesRunning(pCounter self, SConnection *pCon, int *status) static int areSlavesRunning(pCounter self, SConnection *pCon, int *status)
{ {
pHdb slaveID, myStatus, stopTime, ccd; pHdb slaveID, myStatus, stopTime, ccd;
int i; int i;
@ -390,19 +391,18 @@ static int areSlavesRunning(pCounter self, SConnection *pCon, int *status)
} }
SCWrite(pCon,"ERROR: failed to stop overrun CCD",eLogError); SCWrite(pCon,"ERROR: failed to stop overrun CCD",eLogError);
*status = HWFault; *status = HWFault;
return 0;
} else { } else {
*status = HWBusy; *status = HWBusy;
UpdateHipadabaPar(myStatus,MakeHdbText("run"),pCon); UpdateHipadabaPar(myStatus,MakeHdbText("run"),pCon);
return 1; return 1;
} }
} else { } else {
*status = HWIdle; *status = HWIdle;
UpdateHipadabaPar(myStatus,MakeHdbText("idle"),pCon); UpdateHipadabaPar(myStatus,MakeHdbText("idle"),pCon);
return 0; return 0;
} }
return 1; return 1;
} }
/*------------------------------------------------------------------------------------*/ /*------------------------------------------------------------------------------------*/
static void multiEndCounting(pCounter self, SConnection *pCon) static void multiEndCounting(pCounter self, SConnection *pCon)
{ {

View File

@ -235,6 +235,7 @@ static int handleFileOperations(SConnection * pCon, pNXScript self,
SCWrite(pCon, buffer, eError); SCWrite(pCon, buffer, eError);
return -1; return -1;
} }
traceIO("datafile", "Opening %s", argv[2]);
SCSendOK(pCon); SCSendOK(pCon);
return 1; return 1;
} }
@ -1499,7 +1500,7 @@ static int SPutPadding(void *message, void *userData)
{ {
pPutMessage self = (pPutMessage)message; pPutMessage self = (pPutMessage)message;
char *pPtr = NULL, *pEnd = NULL; char *pPtr = NULL, *pEnd = NULL;
unsigned int len, i; unsigned int len = 0, i;
if(self->v.dataType == HIPTEXT && strstr(self->v.v.text,"@len") != NULL){ if(self->v.dataType == HIPTEXT && strstr(self->v.v.text,"@len") != NULL){
pPtr = strchr(self->v.v.text,'='); pPtr = strchr(self->v.v.text,'=');
@ -1509,11 +1510,11 @@ static int SPutPadding(void *message, void *userData)
*pEnd = '\0'; *pEnd = '\0';
len = atoi(pPtr); len = atoi(pPtr);
} }
pPtr = malloc((len+5)*sizeof(char)); pPtr = malloc((len+7)*sizeof(char));
if(pPtr != NULL){ if(pPtr != NULL){
memset(pPtr,0,len*sizeof(char)); memset(pPtr,0,len*sizeof(char));
strncpy(pPtr,pEnd+1,len); strncpy(pPtr,pEnd+1,len);
for(i = strlen(pPtr); i < len-1; i++){ for(i = strlen(pPtr); i < len-2; i++){
pPtr[i] = ' '; pPtr[i] = ' ';
} }
pPtr[len-1] = '!'; pPtr[len-1] = '!';
@ -1550,7 +1551,11 @@ static int SPutDim(void *message, void *userData)
self->dim[0] = self->v.arrayLength; self->dim[0] = self->v.arrayLength;
break; break;
case HIPTEXT: case HIPTEXT:
if(self->v.v.text != NULL){
self->dim[0] = strlen(self->v.v.text)+1; self->dim[0] = strlen(self->v.v.text)+1;
} else {
self->dim[0] = 1;
}
break; break;
default: default:
snprintf(self->error, sizeof(self->error),"invalid data type %d", snprintf(self->error, sizeof(self->error),"invalid data type %d",

View File

@ -8,6 +8,13 @@
* copyright: see file COPYRIGHT * copyright: see file COPYRIGHT
* *
* Mark Koennecke, February 2013 * Mark Koennecke, February 2013
*
* TODO: this may need a refactoring towards a monochromator object with its
* own parameters and such. Eiger would have benefitted from this. This here
* just implements a drivable interface on top of the tasub parameters. As EIGER
* is now working; this has gone low priority.
*
* Mark Koennecke, September 2014
*/ */
#include <sics.h> #include <sics.h>
#include "tasmono.h" #include "tasmono.h"