Multiple bug fixes

- Arrayutil was not summing correctly
- Added interest to motorsec in order to support old status clients
- core dump because of bad free in devser
- fixed transferring of count time in multicounter
- added stack debugging to sllinux_def
- Modifications to tasdrive to wait for finish of monochromator properly
This commit is contained in:
2014-05-05 13:52:00 +02:00
parent b466a2d427
commit 72f9e59150
8 changed files with 156 additions and 13 deletions

View File

@ -36,11 +36,18 @@ long sumWindow(int *data, int xstart, int xend, int xlength,
}
for(j = ystart; j < yend; j++){
row = data + j*xlength;
for(i = xstart; i < xend; i++){
result += row[i];
/* for(j = ystart; j < yend; j++){ */
/* row = data + j*xlength; */
/* for(i = xstart; i < xend; i++){ */
/* result += row[i]; */
/* } */
/* } */
for(i = xstart; i < xend; i++){
row = data + i*ylength;
for(j = ystart; j < yend; j++){
result += row[j];
}
}
return result;
}

View File

@ -835,7 +835,8 @@ int CountAction(SConnection * pCon, SicsInterp * pSics, void *pData,
{"getpar", 2, {FUPATEXT, FUPAOPT}},
{"getnmon", 0, {0, 0}},
{"state", 0, {0, 0}},
{"error", 0, {0, 0}}
{"error", 0, {0, 0}},
{"countstatus", 0, {0, 0}}
};
char *pMode[] = {
"timer",
@ -852,7 +853,7 @@ int CountAction(SConnection * pCon, SicsInterp * pSics, void *pData,
argtolower(argc, argv);
argx = &argv[1];
iRet =
EvaluateFuPa((pFuncTemplate) & ActionTemplate, 25, argc - 1, argx,
EvaluateFuPa((pFuncTemplate) & ActionTemplate, 26, argc - 1, argx,
&PaRes);
if (iRet < 0) {
snprintf(pBueffel, 255,"%s", PaRes.pError);
@ -961,6 +962,7 @@ int CountAction(SConnection * pCon, SicsInterp * pSics, void *pData,
SCSendOK(pCon);
return 1;
case 11: /* status */
case 25:
self->pCountInt->TransferData(self, pCon);
if (GetCounterMode(self) == ePreset) {
lVal = GetCounterPreset(self);

View File

@ -9,6 +9,7 @@
*
* Mark Koennecke, February 2009
*/
#include <math.h>
#include <time.h>
#include <sics.h>
#include <counter.h>
@ -507,6 +508,41 @@ static int InterestCmd(pSICSOBJ ccmd, SConnection * con,
}
/*--------------------------------------------------------------------------*/
static int CountStatusCmd(pSICSOBJ ccmd, SConnection * con,
Hdb * cmdNode, Hdb * par[], int nPar)
{
float preset, done;
int exponent;
pHdb node, data;
node = GetHipadabaNode(ccmd->objectNode,"preset");
assert(node != NULL);
preset = node->value.v.doubleValue;
node = GetHipadabaNode(ccmd->objectNode,"mode");
assert(node != NULL);
strtolower(node->value.v.text);
if(strcmp(node->value.v.text,"timer") == 0) {
data = GetHipadabaNode(ccmd->objectNode,"time");
assert(data != NULL);
done = data->value.v.doubleValue;
} else {
data = GetHipadabaNode(ccmd->objectNode,"values");
assert(data != NULL);
done = data->value.v.intArray[0];
data = GetHipadabaNode(ccmd->objectNode,"exponent");
assert(data != NULL);
exponent = data->value.v.intValue;
if(exponent != 0){
done /= pow(10,exponent);
}
}
SCPrintf(con,eValue,"%s.CountStatus = %f %f",
ccmd->objectNode->name, preset, done);
return 1;
}
/*--------------------------------------------------------------------------*/
pCounter CreateSecCounter(SConnection *pCon, char *type, char *name, int length)
{
pCounter pRes = NULL;
@ -634,6 +670,7 @@ pCounter CreateSecCounter(SConnection *pCon, char *type, char *name, int length)
child = AddSICSHdbPar(node,"pause", usUser, MakeSICSFunc(PauseCmd));
child = AddSICSHdbPar(node,"continue", usUser, MakeSICSFunc(ContinueCmd));
child = AddSICSHdbPar(node,"interest", usUser, MakeSICSFunc(InterestCmd));
child = AddSICSHdbPar(node,"countstatus", usUser, MakeSICSFunc(CountStatusCmd));
return pRes;
}

View File

@ -333,7 +333,8 @@ static void DevReset(DevSer * devser)
devser->current->kill(devser->current->data);
}
devser->killCurrent = 0;
/* free(devser->current); */
free(devser->current);
devser->current = NULL;
}
}

View File

@ -47,6 +47,7 @@
#define ABS(x) (x < 0 ? -(x) : (x))
/*-------------------------------------------------------------------------*/
static void SecMotorSetError(pMotor self, char *text)
{
@ -655,6 +656,80 @@ static hdbCallbackReturn SecMotorZeroCallback(pHdb node, void *userData,
return hdbContinue;
}
/*--------------------------------------------------------------------------*/
typedef struct {
char *pName;
SConnection *pCon;
float lastValue;
} MotInfo, *pMotInfo;
/*--------------------------------------------------------------------------*/
static void KillInfo(void *pData)
{
pMotInfo self = NULL;
assert(pData);
self = (pMotInfo) pData;
if (self->pName) {
free(self->pName);
}
if (self->pCon != NULL) {
SCDeleteConnection(self->pCon);
}
free(self);
}
/*-------------------------------------------------------------------------*/
static hdbCallbackReturn InterestCallback(pHdb node, void *userData,
pHdbMessage message)
{
pHdbDataMessage mm = NULL;
pMotor self = (pMotor) userData;
float fVal;
hdbValue v;
pMotInfo priv = (pMotInfo)userData;
assert(self != NULL);
mm = GetHdbUpdateMessage(message);
if (mm != NULL) {
v = *mm->v;
if(!SCisConnected(priv->pCon)){
return hdbKill;
}
if(ABS(v.v.doubleValue - priv->lastValue) > .1) {
SCPrintf(priv->pCon,eValue,"%s.position = %f",
priv->pName, v.v.doubleValue);
priv->lastValue = v.v.doubleValue;
}
return hdbContinue;
}
return hdbContinue;
}
/*---------------------------------------------------------------------------*/
static int InterestCmd(pSICSOBJ ccmd, SConnection * con,
Hdb * cmdNode, Hdb * par[], int nPar)
{
pMotInfo priv = NULL;
priv = malloc(sizeof(MotInfo));
if(priv == NULL){
SCWrite(con,"ERROR: out of memory registering interest",eError);
return 0;
}
if(nPar >= 1 && (strcmp(par[0]->value.v.text,"UNKNOWN") != 0)) {
priv->pName = strdup(par[0]->value.v.text);
} else {
priv->pName = strdup(ccmd->objectNode->name);
}
priv->lastValue = .0;
priv->pCon = SCCopyConnection(con);
AppendHipadabaCallback(ccmd->objectNode,
MakeHipadabaCallback(InterestCallback,priv,KillInfo));
SCSendOK(con);
return 1;
}
/*---------------------------------------------------------------------------*/
pMotor SecMotorInit(char *name)
{
@ -793,6 +868,10 @@ pMotor SecMotorInit(char *name)
child = MakeHipadabaNode("error", HIPTEXT, 1);
AddHipadabaChild(node, child, NULL);
child = AddSICSHdbPar(node,"interest", usUser, MakeSICSFunc(InterestCmd));
AddSICSHdbPar(child, "name", usUser, MakeHdbText("UNKNOWN"));
pM->endScriptID = 0;
/* initialise Drivable interface */

View File

@ -134,6 +134,7 @@ static void startMultiCounting(pHdb self, SConnection *pCon)
assert(sID != NULL);
assert(mID != NULL);
strtolower(mode->value.v.text);
if(strcmp(mode->value.v.text,"timer") == 0) {
eMode = eTimer;
} else {
@ -234,12 +235,12 @@ static hdbCallbackReturn MultiSecControllCallback(pHdb node,
/*-------------------------------------------------------------------------------------*/
static int isMultiMasterRunning(pCounter self, SConnection *pCon, int *status)
{
pHdb mID, master, myStatus, control, ccd, stopTime;
pHdb mID, master, myStatus, control, ccd, stopTime, timeNode;
hdbValue v;
long mlID;
void *data;
pICountable pCount;
float controlVal;
float controlVal, tVal;
mID = GetHipadabaNode(self->objectNode,"masterID");
master = GetHipadabaNode(self->objectNode,"master");
@ -247,12 +248,14 @@ static int isMultiMasterRunning(pCounter self, SConnection *pCon, int *status)
control = GetHipadabaNode(self->objectNode,"control");
ccd = GetHipadabaNode(self->objectNode,"ccd");
stopTime = GetHipadabaNode(self->objectNode,"stopTime");
timeNode = GetHipadabaNode(self->objectNode,"time");
assert(mID != NULL);
assert(master != NULL);
assert(myStatus != NULL);
assert(control != NULL);
assert(ccd != NULL);
assert(stopTime != NULL);
assert(timeNode != NULL);
mlID = mID->value.v.intValue;
@ -269,6 +272,8 @@ static int isMultiMasterRunning(pCounter self, SConnection *pCon, int *status)
*status = pCount->CheckCountStatus(data,pCon);
controlVal = GetControlValue((pCounter)data);
UpdateHipadabaPar(control,MakeHdbFloat(controlVal),pCon);
tVal = GetCountTime((pCounter)data,pCon);
UpdateHipadabaPar(timeNode,MakeHdbFloat(tVal),pCon);
SecCounterSetError(self,"None");
switch(*status){
case HWFault:
@ -296,6 +301,8 @@ static int isMultiMasterRunning(pCounter self, SConnection *pCon, int *status)
*status = HWBusy;
UpdateHipadabaPar(myStatus,MakeHdbText("run"),pCon);
UpdateHipadabaPar(stopTime,MakeHdbInt(time(NULL)),pCon);
tVal = GetCountTime((pCounter)data,pCon);
UpdateHipadabaPar(timeNode,MakeHdbFloat(tVal),pCon);
if(ccd->value.v.intValue != 1) {
doCountCommand(self->objectNode,pCon,1011);
}

View File

@ -12,4 +12,4 @@ MFLAGS=-f makefile_linux$(DUMMY)
HDFROOT=/afs/psi.ch/project/sinq/sl6
TCLINC=.
DBG= -g
DBG= -g -fstack-protector-all

View File

@ -352,6 +352,7 @@ static int startMotors(ptasMot self, tasAngles angles,
{
double curve;
int status, silent, stopFixed;
long monoID;
silent = self->math->silent;
stopFixed = self->math->stopFixed;
@ -363,9 +364,9 @@ static int startMotors(ptasMot self, tasAngles angles,
monochromator
*/
status = self->math->mono->SetValue(self->math->monoData,
pCon,angles.monochromator_two_theta);
pCon,angles.monochromator_two_theta);
/*
The call to CheckStatus is necessary because the eiger monochromator may not
The call to CheckStatus is necessary because the eiger monochromator may not
start until then. Deferred until all parameters are known.
*/
self->math->mono->CheckStatus(self->math->monoData,pCon);
@ -374,6 +375,14 @@ static int startMotors(ptasMot self, tasAngles angles,
} else {
AddTaskToGroup(pServ->pTasker, self->math->monoTaskID, self->math->groupID);
}
/* monoID = StartDriveTask(self->math->monoData, pCon,"mono", */
/* angles.monochromator_two_theta); */
/* self->math->mono->CheckStatus(self->math->monoData,pCon); */
/* if(monoID < 0){ */
/* SCWrite(pCon,"ERROR: failed to start monochromator",eLogError); */
/* } else { */
/* AddTaskToGroup(pServ->pTasker,monoID, self->math->groupID); */
/* } */
/*
analyzer
@ -588,7 +597,8 @@ static int checkMotors(ptasMot self, SConnection * pCon)
{
self->math->mustRecalculate = 1;
if(isTaskGroupRunning(pServ->pTasker,self->math->groupID)){
if(isTaskGroupRunning(pServ->pTasker,self->math->groupID) ||
isTaskGroupRunning(pServ->pTasker,self->math->monoTaskID)){
return HWBusy;
} else {
return HWIdle;