- Fixed a crash coming from velo.c

- Improved saving of reflection lists
- The other changes are mostly whitespace
This commit is contained in:
koennecke
2009-10-30 13:49:37 +00:00
parent cb0e4ea434
commit 2e873e3059
13 changed files with 79 additions and 14 deletions

View File

@ -1069,18 +1069,27 @@ int SicsIdle(SConnection * pCon, SicsInterp * pSics, void *pData,
/*-------------------------------------------------------------------------- /*--------------------------------------------------------------------------
Usage: Usage:
Success Success [level]
*/ */
int Success(SConnection * pCon, SicsInterp * pSics, void *pData, int Success(SConnection * pCon, SicsInterp * pSics, void *pData,
int argc, char *argv[]) int argc, char *argv[])
{ {
int iRet; int iRet, level;
Status eOld; Status eOld;
pExeList self = (pExeList)pData; pExeList self = (pExeList)pData;
eOld = GetStatus(); eOld = GetStatus();
SetStatus(eRunning); SetStatus(eRunning);
while(DevExecLevelRunning(self, RUNRUN)){
if(argc > 1){
if(strcmp(argv[1],"RUNDRIVE") == 0){
level = RUNDRIVE;
}
} else {
level = RUNRUN;
}
while(DevExecLevelRunning(self, level)){
TaskYield(self->pTask); TaskYield(self->pTask);
} }
iRet = self->iStatus; iRet = self->iStatus;

View File

@ -165,6 +165,7 @@ static int ECBGetStatus(struct __COUNTER *self, float *fControl)
This can happen after a stop This can happen after a stop
*/ */
if (pPriv->state == IDLE) { if (pPriv->state == IDLE) {
ECBTransfer(self);
return HWIdle; return HWIdle;
} }
@ -210,6 +211,7 @@ static int ECBGetStatus(struct __COUNTER *self, float *fControl)
} }
if (out.d == 0 && pPriv->state == COUNT) { if (out.d == 0 && pPriv->state == COUNT) {
result = HWIdle; result = HWIdle;
ECBTransfer(self);
pPriv->state = IDLE; pPriv->state = IDLE;
} else { } else {
result = HWBusy; result = HWBusy;
@ -228,11 +230,12 @@ static int ECBGetStatus(struct __COUNTER *self, float *fControl)
readScaler(pPriv, scaler, &count); readScaler(pPriv, scaler, &count);
/* /*
ignore errors on this one ignore errors on this one
*/ */
*fControl = (float) count; *fControl = (float) count;
return result; return result;
} }exit
/*=====================================================================*/ /*=====================================================================*/
static int clearScalers(pECBCounter self) static int clearScalers(pECBCounter self)

View File

@ -13,5 +13,6 @@
pSICSOBJ MakeHdbTable(char *name, char *hdbclass); pSICSOBJ MakeHdbTable(char *name, char *hdbclass);
int ReadTableTemplate(pSICSOBJ self, SConnection *con); int ReadTableTemplate(pSICSOBJ self, SConnection *con);
int HdbTableFactory(SConnection *pCon, SicsInterp *pSics, void *pData, int argc, char *argv[]); int HdbTableFactory(SConnection *pCon, SicsInterp *pSics, void *pData, int argc, char *argv[]);
int SaveHdbTable(void *data, char *name, FILE * fd);
#endif /*HDBTABLE_H_*/ #endif /*HDBTABLE_H_*/

View File

@ -328,9 +328,10 @@ static int HistCountStatus(void *pData, SConnection * pCon)
return HWBusy; return HWBusy;
} }
} }
if (eCt == HWBusy) if (eCt == HWBusy){
updateHMData(self->pDriv->data); updateHMData(self->pDriv->data);
}
if (eCt == HWIdle) { if (eCt == HWIdle) {
/* force an update of local histogram data with next /* force an update of local histogram data with next
GetHistogram GetHistogram

2
hkl.c
View File

@ -393,7 +393,7 @@ int hklInRange(void *data, double fSet[4], int mask[4])
violation we first try to calculate a delta omega which puts omega violation we first try to calculate a delta omega which puts omega
into the right range. This is a fix because the omega movement is quite into the right range. This is a fix because the omega movement is quite
often restricted due to the cryogenic garbage around the sample. often restricted due to the cryogenic garbage around the sample.
*/ -------------------------------------------------------------------------*/
int CalculateSettings(pHKL self, float fHKL[3], float fPsi, int iHamil, int CalculateSettings(pHKL self, float fHKL[3], float fPsi, int iHamil,
float fSet[4], SConnection * pCon) float fSet[4], SConnection * pCon)
{ {

View File

@ -180,8 +180,10 @@ int GetCountLock(pICountable self, SConnection * pCon)
{ {
if (self->running == 1) { if (self->running == 1) {
SCWrite(pCon, "ERROR: someone else is already counting!", eError); SCWrite(pCon, "ERROR: someone else is already counting!", eError);
/* printf("Countlock denied\n"); */
return 0; return 0;
} else { } else {
/* printf("Countlock aquired\n");*/
self->running = 1; self->running = 1;
return 1; return 1;
} }
@ -190,6 +192,7 @@ int GetCountLock(pICountable self, SConnection * pCon)
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/
void ReleaseCountLock(pICountable self) void ReleaseCountLock(pICountable self)
{ {
/* printf("Countlock released\n"); */
self->running = 0; self->running = 0;
} }

View File

@ -6,6 +6,10 @@
* copyright: see file COPYRIGHT * copyright: see file COPYRIGHT
* *
* Mark Koennecke, July 2008 * Mark Koennecke, July 2008
*
* Fixed saving of anglesheader status
*
* Mark Koennecke, September 2009
*/ */
#include <stdlib.h> #include <stdlib.h>
#include <assert.h> #include <assert.h>
@ -26,6 +30,18 @@ typedef struct {
int angCount; int angCount;
int count; int count;
} RLPriv, *pRLPriv; } RLPriv, *pRLPriv;
/*-----------------------------------------------------------------------*/
int SaveRefList(void *data, char *name, FILE * fd)
{
pHdb node = NULL;
pSICSOBJ self = (pSICSOBJ)data;
node = GetHipadabaNode(self->objectNode,"anglesheader");
fprintf(fd,"%s anglesheader %s\n", name, node->value.v.text);
SaveHdbTable(data,name,fd);
return 1;
}
/*---------------------------------------------------------------------- /*----------------------------------------------------------------------
* The point of the code below and the callback is to update the * The point of the code below and the callback is to update the
* configuration counts whenever the corresponding parameters * configuration counts whenever the corresponding parameters
@ -449,7 +465,8 @@ pSICSOBJ CreateReflectionList(SConnection * pCon, SicsInterp * pSics,
SCWrite(pCon, "ERROR: failed to create reflection list", eError); SCWrite(pCon, "ERROR: failed to create reflection list", eError);
return 0; return 0;
} }
pNew->pDes->SaveStatus = SaveRefList;
AddSICSHdbPar(pNew->objectNode, "names", usUser, MakeSICSFunc(NamesCmd)); AddSICSHdbPar(pNew->objectNode, "names", usUser, MakeSICSFunc(NamesCmd));
cmd = cmd =

View File

@ -186,6 +186,10 @@ static int StatCmd(pSICSOBJ self, SConnection *pCon, pHdb commandNode,
return 0; return 0;
} }
data = GetHistogramPointer(hm,pCon); data = GetHistogramPointer(hm,pCon);
if(data == NULL){
SCPrintf(pCon,eError,"ERROR: failed to get data for hm %s", par[0]->value.v.text);
return 0;
}
max = -9999; max = -9999;
min = 99999.99; min = 99999.99;
length = dim[0]*dim[1]; length = dim[0]*dim[1];

2
scan.c
View File

@ -575,7 +575,7 @@ static int ScanLoop(pScanData self)
} }
if (!iRet) { if (!iRet) {
SCWrite(self->pCon, SCWrite(self->pCon,
"WARNING: skipped scan point after count failure", eLog); "WARNING: skipped scan point after count failure", eLog);
continue; continue;
} }

View File

@ -9,6 +9,8 @@
copyright: see file COPYRIGHT copyright: see file COPYRIGHT
Mark Koennecke, June 2003 Mark Koennecke, June 2003
added addto. Mark Koennecke, August 2009
----------------------------------------------------------------------*/ ----------------------------------------------------------------------*/
#include <stdio.h> #include <stdio.h>
#include <assert.h> #include <assert.h>
@ -424,6 +426,7 @@ static int divideSicsData(pSICSData self, SicsInterp * pSics,
return 1; return 1;
} }
/*------------------------------------------------------------------*/ /*------------------------------------------------------------------*/
static int scaleSicsData(pSICSData self, SicsInterp * pSics, static int scaleSicsData(pSICSData self, SicsInterp * pSics,
SConnection * pCon, float scale) SConnection * pCon, float scale)
@ -442,6 +445,24 @@ static int scaleSicsData(pSICSData self, SicsInterp * pSics,
} }
return 1; return 1;
} }
/*------------------------------------------------------------------*/
static int addToSicsData(pSICSData self, SicsInterp * pSics,
SConnection *pCon, float val)
{
int i;
float div;
for (i = 0; i < self->dataUsed; i++) {
div = getDataPos(self, i);
div += val;
if (self->dataType[i] == INTTYPE) {
self->data[i] = (int) fabsf(div);
} else {
memcpy(&self->data[i], &div, sizeof(float));
}
}
return 1;
}
/*-------------------------------------------------------------------*/ /*-------------------------------------------------------------------*/
static int copyScanCounts(pSICSData self, int argc, char *argv[], static int copyScanCounts(pSICSData self, int argc, char *argv[],
@ -938,7 +959,7 @@ int SICSDataAction(SConnection * pCon, SicsInterp * pSics, void *pData,
pSICSData self = NULL; pSICSData self = NULL;
char pBueffel[132]; char pBueffel[132];
int pos; int pos;
float scale; float scale, val;
self = (pSICSData) pData; self = (pSICSData) pData;
assert(self); assert(self);
@ -992,6 +1013,12 @@ int SICSDataAction(SConnection * pCon, SicsInterp * pSics, void *pData,
return 0; return 0;
} }
return scaleSicsData(self, pSics, pCon, atof(argv[2])); return scaleSicsData(self, pSics, pCon, atof(argv[2]));
} else if (strcmp(argv[1], "addto") == 0) {
if (argc < 3) {
SCWrite(pCon, "ERROR: need a value to add", eError);
return 0;
}
return addToSicsData(self, pSics, pCon, atof(argv[2]));
} else if (strcmp(argv[1], "copydata") == 0) { } else if (strcmp(argv[1], "copydata") == 0) {
return copyData(self, pSics, pCon, argc, argv); return copyData(self, pSics, pCon, argc, argv);
} else if (strcmp(argv[1], "putint") == 0) { } else if (strcmp(argv[1], "putint") == 0) {

View File

@ -543,8 +543,7 @@ int VarWrapper(SConnection * pCon, SicsInterp * pInterp, void *pData,
return iRet; return iRet;
} else { } else {
/* now, only a new value is still possible */ /* now, only a new value is still possible */
eStat = GetStatus(); if (DevExecLevelRunning(pServ->pExecutor, RUNDRIVE)) {
if ((eStat != eEager) && (eStat != eBatch)) {
SCWrite(pCon, SCWrite(pCon,
"You cannot set variables while a scan is running", eError); "You cannot set variables while a scan is running", eError);
DeleteTokenList(pList); DeleteTokenList(pList);

View File

@ -85,6 +85,7 @@ static int calculateNBSettings(pSingleDiff self,
if (status != 1) { if (status != 1) {
return 0; return 0;
} }
if(om > 180.){ if(om > 180.){
om -= 360; om -= 360;
} else if (om < -180.){ } else if (om < -180.){

2
velo.c
View File

@ -919,7 +919,7 @@ int VelSelAction(SConnection * pCon, SicsInterp * pSics, void *pData,
int argc, char *argv[]) int argc, char *argv[])
{ {
pVelSel self = NULL; pVelSel self = NULL;
char pCommand[512], pBueffel[256]; char pCommand[512], pBueffel[512];
char *pPtr = NULL; char *pPtr = NULL;
float fTilt, fRot, fVal; float fTilt, fRot, fVal;
int iDrive = 0; int iDrive = 0;