- Updated the managers documentation a little
- The crystal settings calculation in hkl now tried to put omega into the limts by calculating a delta omega. - TRICS data files now include HKL and the UB - The scan module has been expanded to support user defined scans which run a script at any scan point. - A small fix to the PSD code in SinqHM_srv_filler
This commit is contained in:
231
faverage.c
231
faverage.c
@@ -10,6 +10,11 @@
|
||||
Updated for additional detector banks
|
||||
|
||||
Mark Koennecke, March 2000
|
||||
|
||||
Added focusraw command for retrieving single detector banks in support
|
||||
of the colour mapping part of the FOCUS status display.
|
||||
|
||||
Mark Koennecke, July 2001
|
||||
---------------------------------------------------------------------------*/
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
@@ -44,78 +49,6 @@
|
||||
DeleteDescriptor(self->pDes);
|
||||
free(self);
|
||||
}
|
||||
/*-------------------------------------------------------------------------*/
|
||||
int MakeFA(SConnection *pCon, SicsInterp *pSics, void *pData,
|
||||
int argc, char *argv[])
|
||||
{
|
||||
pFocusAverager pNew = NULL;
|
||||
CommandList *pCom = NULL;
|
||||
pDummy pDum = NULL;
|
||||
char pBueffel[256];
|
||||
int iRet;
|
||||
|
||||
assert(pCon);
|
||||
assert(pSics);
|
||||
|
||||
/* we need two parameters: the name for the averager and the histogram
|
||||
memory
|
||||
*/
|
||||
if(argc < 3)
|
||||
{
|
||||
SCWrite(pCon,"ERROR: Insufficient number of parameters to MakeFA",
|
||||
eError);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* find histogram memory */
|
||||
pCom = FindCommand(pSics,argv[2]);
|
||||
if(!pCom)
|
||||
{
|
||||
sprintf(pBueffel,"ERROR: histogram memory %s NOT found!", argv[2]);
|
||||
SCWrite(pCon,pBueffel,eError);
|
||||
return 0;
|
||||
}
|
||||
pDum = (pDummy)pCom->pData;
|
||||
if(!pDum)
|
||||
{
|
||||
sprintf(pBueffel,"ERROR: histogram memory %s INVALID!", argv[2]);
|
||||
SCWrite(pCon,pBueffel,eError);
|
||||
return 0;
|
||||
}
|
||||
if(strcmp(pDum->pDescriptor->name,"HistMem") != 0)
|
||||
{
|
||||
sprintf(pBueffel,"ERROR: %s is NO histogram memory object!", argv[2]);
|
||||
SCWrite(pCon,pBueffel,eError);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* we got what we need: set things up */
|
||||
pNew = (pFocusAverager)malloc(sizeof(FocusAverager));
|
||||
if(!pNew)
|
||||
{
|
||||
SCWrite(pCon,"ERROR: out of memory in MakeFA",eError);
|
||||
return 0;
|
||||
}
|
||||
memset(pNew,0,sizeof(FocusAverager));
|
||||
|
||||
pNew->pDes = CreateDescriptor("FocusAverager");
|
||||
if(!pNew->pDes)
|
||||
{
|
||||
SCWrite(pCon,"ERROR: out of memory in MakeFA",eError);
|
||||
return 0;
|
||||
}
|
||||
pNew->pHist = (pHistMem)pDum;
|
||||
|
||||
iRet = AddCommand(pSics,argv[1],FocusAverageDo, KillFA, pNew);
|
||||
if(!iRet)
|
||||
{
|
||||
sprintf(pBueffel,"ERROR: duplicate command %s not created", argv[1]);
|
||||
SCWrite(pCon,pBueffel,eError);
|
||||
KillFA(pNew);
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
/*-------------------------------------------------------------------------*/
|
||||
int FocusAverageDo(SConnection *pCon, SicsInterp *pSics, void *pData,
|
||||
int argc, char *argv[])
|
||||
@@ -278,3 +211,157 @@
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
static int FocusRaw(SConnection *pCon, SicsInterp *pSics, void *pData,
|
||||
int argc, char *argv[])
|
||||
{
|
||||
pFocusAverager self = NULL;
|
||||
int *iData = NULL;
|
||||
int iLength, noTimebin, iRet, i;
|
||||
char pBueffel[256];
|
||||
const float *timeBin;
|
||||
HistInt *hiData = NULL, *hiPtr;
|
||||
int iBank = MIDDLE;
|
||||
|
||||
self = (pFocusAverager)pData;
|
||||
assert(self);
|
||||
assert(pCon);
|
||||
assert(pSics);
|
||||
|
||||
|
||||
/* we need one parameter, the bank to read */
|
||||
if(argc < 2)
|
||||
{
|
||||
SCWrite(pCon,
|
||||
"ERROR: insufficient number of parameters for FocusRaw",
|
||||
eError);
|
||||
return 0;
|
||||
}
|
||||
iRet = Tcl_GetInt(pSics->pTcl,argv[1],&iBank);
|
||||
if(iRet != TCL_OK)
|
||||
{
|
||||
sprintf(pBueffel,"ERROR: cannot convert %d to integer",argv[1]);
|
||||
SCWrite(pCon,pBueffel,eError);
|
||||
return 0;
|
||||
}
|
||||
|
||||
timeBin = GetHistTimeBin(self->pHist,&iLength);
|
||||
assert(timeBin);
|
||||
hiData = GetHistogramPointer(self->pHist,pCon);
|
||||
if(hiData == NULL)
|
||||
{
|
||||
SCWrite(pCon,"ERROR: failed to read histogram memory data",eError);
|
||||
return 0;
|
||||
}
|
||||
setFMDataPointer(hiData, iLength);
|
||||
hiData = getFMBankPointer(iBank);
|
||||
|
||||
/* get histogram length */
|
||||
iLength = getFMdim(iBank);
|
||||
noTimebin = getFMdim(TIMEBIN);
|
||||
/* write dimension info*/
|
||||
sprintf(pBueffel,"focusrawdim = %d = %d", iLength, noTimebin);
|
||||
SCWrite(pCon,pBueffel,eValue);
|
||||
|
||||
/* allocate space */
|
||||
iData = (int *)malloc((iLength*noTimebin+1)*sizeof(int));
|
||||
if(iData == NULL)
|
||||
{
|
||||
SCWrite(pCon,"ERROR: out of memory in FocusRaw",eError);
|
||||
return 0;
|
||||
}
|
||||
memset(iData,0,noTimebin*iLength*sizeof(int));
|
||||
|
||||
/* first int: length of things to come */
|
||||
iData[0] = htonl(iLength*noTimebin);
|
||||
/* network byte order for everything */
|
||||
for(i = 0; i < noTimebin*iLength; i++)
|
||||
{
|
||||
iData[i+1] = htonl(hiData[i]);
|
||||
}
|
||||
/* send away, zipped */
|
||||
SCWriteZipped(pCon,"focusraw",iData,(iLength*noTimebin+1)*sizeof(int));
|
||||
|
||||
free(iData);
|
||||
return 1;
|
||||
}
|
||||
/*-------------------------------------------------------------------------*/
|
||||
int MakeFA(SConnection *pCon, SicsInterp *pSics, void *pData,
|
||||
int argc, char *argv[])
|
||||
{
|
||||
pFocusAverager pNew = NULL;
|
||||
CommandList *pCom = NULL;
|
||||
pDummy pDum = NULL;
|
||||
char pBueffel[256];
|
||||
int iRet;
|
||||
|
||||
assert(pCon);
|
||||
assert(pSics);
|
||||
|
||||
/* we need two parameters: the name for the averager and the histogram
|
||||
memory
|
||||
*/
|
||||
if(argc < 3)
|
||||
{
|
||||
SCWrite(pCon,"ERROR: Insufficient number of parameters to MakeFA",
|
||||
eError);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* find histogram memory */
|
||||
pCom = FindCommand(pSics,argv[2]);
|
||||
if(!pCom)
|
||||
{
|
||||
sprintf(pBueffel,"ERROR: histogram memory %s NOT found!", argv[2]);
|
||||
SCWrite(pCon,pBueffel,eError);
|
||||
return 0;
|
||||
}
|
||||
pDum = (pDummy)pCom->pData;
|
||||
if(!pDum)
|
||||
{
|
||||
sprintf(pBueffel,"ERROR: histogram memory %s INVALID!", argv[2]);
|
||||
SCWrite(pCon,pBueffel,eError);
|
||||
return 0;
|
||||
}
|
||||
if(strcmp(pDum->pDescriptor->name,"HistMem") != 0)
|
||||
{
|
||||
sprintf(pBueffel,"ERROR: %s is NO histogram memory object!", argv[2]);
|
||||
SCWrite(pCon,pBueffel,eError);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* we got what we need: set things up */
|
||||
pNew = (pFocusAverager)malloc(sizeof(FocusAverager));
|
||||
if(!pNew)
|
||||
{
|
||||
SCWrite(pCon,"ERROR: out of memory in MakeFA",eError);
|
||||
return 0;
|
||||
}
|
||||
memset(pNew,0,sizeof(FocusAverager));
|
||||
|
||||
pNew->pDes = CreateDescriptor("FocusAverager");
|
||||
if(!pNew->pDes)
|
||||
{
|
||||
SCWrite(pCon,"ERROR: out of memory in MakeFA",eError);
|
||||
return 0;
|
||||
}
|
||||
pNew->pHist = (pHistMem)pDum;
|
||||
|
||||
iRet = AddCommand(pSics,argv[1],FocusAverageDo, KillFA, pNew);
|
||||
if(!iRet)
|
||||
{
|
||||
sprintf(pBueffel,"ERROR: duplicate command %s not created", argv[1]);
|
||||
SCWrite(pCon,pBueffel,eError);
|
||||
KillFA(pNew);
|
||||
return 0;
|
||||
}
|
||||
iRet = AddCommand(pSics,"focusraw",FocusRaw, NULL, pNew);
|
||||
if(!iRet)
|
||||
{
|
||||
sprintf(pBueffel,"ERROR: duplicate command focusraw not created");
|
||||
SCWrite(pCon,pBueffel,eError);
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user