- Fixed a bug fix with Fixed motor in TAS code

- Made AMOR write HDF-5 data in chunks
- Added  driver for a PSI-DSP magnet controller as used at SLS
- Added code for directly accessing RS232 controllers connected to a
  terminal server, thereby bypassing the SerPortServer
- A rounding problem in the PSD histogram memory was resolved.
This commit is contained in:
cvs
2001-10-25 13:57:59 +00:00
parent 22688ac0fc
commit 3c916c9a7d
32 changed files with 2247 additions and 758 deletions

View File

@@ -60,6 +60,7 @@
*/
#define HM2OFF "hm2off"
#define HM3OFF "hm3off"
#define HM1OFF "hm1off"
/*
name of hkl object holding crystallographic information
@@ -77,8 +78,10 @@ name of hkl object holding crystallographic information
int iFirst;
int iFrameNum;
pICallBack pCall;
float hm2Off, hm3Off;
float hm2Off, hm3Off, hm1off;
pHKL pCrystal;
int iHDF5;
pCounter pCount;
} NexTrics;
/* event type */
@@ -116,17 +119,24 @@ name of hkl object holding crystallographic information
DeleteNexTrics(pNew);
return NULL;
}
if(strstr(pDict,"5") != NULL)
{
pNew->iHDF5 = 1;
}
pNew->pFileRoot = strdup(pRoot);
pNew->pDanu = pNum;
/* find things in interpreter */
pCom = FindCommand(pSics,HM1);
if(!pCom)
if(pCom)
{
DeleteNexTrics(pNew);
return NULL;
pNew->pHistogram1 = (pHistMem)pCom->pData;
}
pNew->pHistogram1 = (pHistMem)pCom->pData;
else
{
pNew->pHistogram1 = NULL;
}
pCom = FindCommand(pSics,HM2);
if(pCom)
{
@@ -154,9 +164,27 @@ name of hkl object holding crystallographic information
{
pNew->pCrystal = NULL;
}
pCom = FindCommand(pSics,"counter");
if(pCom)
{
pNew->pCount = (pCounter)pCom->pData;
}
else
{
pNew->pCrystal = NULL;
}
pNew->iFirst = 1;
pNew->iFrameNum = 0;
pVar = FindVariable(pSics,HM1OFF);
if(pVar)
{
pNew->hm1off = pVar->fVal;
}
else
{
pNew->hm1off = 0;
}
pVar = FindVariable(pSics,HM2OFF);
if(pVar)
{
@@ -164,7 +192,7 @@ name of hkl object holding crystallographic information
}
else
{
pNew->hm2Off = -45.;
pNew->hm2Off = +45.;
}
pVar = FindVariable(pSics,HM3OFF);
if(pVar)
@@ -173,9 +201,10 @@ name of hkl object holding crystallographic information
}
else
{
pNew->hm3Off = 45.;
pNew->hm3Off = 90.;
}
return pNew;
}
/*-------------------------------------------------------------------------*/
@@ -313,7 +342,30 @@ name of hkl object holding crystallographic information
}
/* write counting parameters */
eMode = GetHistCountMode(self->pHistogram1);
if(self->pHistogram1 != NULL)
{
eMode = GetHistCountMode(self->pHistogram1);
fVal = GetHistPreset(self->pHistogram1);
lVal = GetHistMonitor(self->pHistogram1,1,pCon);
}
if(self->pHistogram2 != NULL)
{
eMode = GetHistCountMode(self->pHistogram2);
fVal = GetHistPreset(self->pHistogram2);
lVal = GetHistMonitor(self->pHistogram2,1,pCon);
}
if(self->pHistogram3 != NULL)
{
eMode = GetHistCountMode(self->pHistogram3);
fVal = GetHistPreset(self->pHistogram3);
lVal = GetHistMonitor(self->pHistogram3,1,pCon);
}
if(self->pCount != NULL)
{
eMode = GetCounterMode(self->pCount);
fVal = GetCounterPreset(self->pCount);
lVal = GetMonitor(self->pCount,1,pCon);
}
if(eMode == eTimer)
{
strcpy(pBueffel,"Timer");
@@ -323,36 +375,37 @@ name of hkl object holding crystallographic information
strcpy(pBueffel,"Monitor");
}
NXDputalias(hfil,self->pDict,"framemode",pBueffel);
fVal = GetHistPreset(self->pHistogram1);
NXDputalias(hfil,self->pDict,"framepreset",&fVal);
lVal = GetHistMonitor(self->pHistogram1,1,pCon);
iVal = (int32)lVal;
NXDputalias(hfil,self->pDict,"framemonitor",&iVal);
/* write detector1 histogram */
strcpy(pBueffel,"detector1");
NXDupdate(self->pDict,"dnumber",pBueffel);
SNXSPutMotor(pServ->pSics,pCon,hfil,self->pDict,
"frametilt","DG1");
GetHistogram(self->pHistogram1,pCon,0,0,DET1X*DET1Y,lData,
DET1X*DET1Y*sizeof(HistInt));
/*
NXDputalias(hfil,self->pDict,"framecounts",lData);
*/
NXDopenalias(hfil,self->pDict,"framecounts");
NXputdata(hfil,lData);
NXsetdimname(hfil,0,"frame_x");
NXsetdimname(hfil,1,"frame_y");
NXclosedata(hfil);
if(self->pHistogram1 != NULL)
{
strcpy(pBueffel,"detector1");
NXDupdate(self->pDict,"dnumber",pBueffel);
SNXSPutMotor(pServ->pSics,pCon,hfil,self->pDict,
"frametilt","DG1");
GetHistogram(self->pHistogram1,pCon,0,0,DET1X*DET1Y,lData,
DET1X*DET1Y*sizeof(HistInt));
NXDputalias(hfil,self->pDict,"framecounts",lData);
fVal = fTTheta;
NXDputalias(hfil,self->pDict,"frame2theta",&fVal);
/*
NXDopenalias(hfil,self->pDict,"framecounts");
NXputdata(hfil,lData);
NXsetdimname(hfil,0,"frame_x");
NXsetdimname(hfil,1,"frame_y");
*/
NXclosedata(hfil);
/* the NXdata links */
NXDaliaslink(hfil,self->pDict,"frame","detectorx");
NXDaliaslink(hfil,self->pDict,"frame","detectory");
NXDaliaslink(hfil,self->pDict,"frame","framecounts");
fVal = fTTheta + self->hm1off;
NXDputalias(hfil,self->pDict,"frame2theta",&fVal);
/* the NXdata links */
NXDaliaslink(hfil,self->pDict,"frame","detectorx");
NXDaliaslink(hfil,self->pDict,"frame","detectory");
NXDaliaslink(hfil,self->pDict,"frame","framecounts");
}
/*
do detector 2 histogram
*/
@@ -364,13 +417,14 @@ name of hkl object holding crystallographic information
"frametilt","DG2");
GetHistogram(self->pHistogram2,pCon,0,0,DET2X*DET2Y,lData,
DET2X*DET2Y*sizeof(HistInt));
/*
NXDputalias(hfil,self->pDict,"framecounts",lData);
*/
/* code for reducing object number in HDF-4
NXDopenalias(hfil,self->pDict,"framecounts");
NXputdata(hfil,lData);
NXsetdimname(hfil,0,"frame_x");
NXsetdimname(hfil,1,"frame_y");
*/
NXclosedata(hfil);
fVal = fTTheta + self->hm2Off;
@@ -393,13 +447,15 @@ name of hkl object holding crystallographic information
GetHistogram(self->pHistogram2,pCon,0,0,DET3X*DET3Y,lData,
DET3X*DET3Y*sizeof(HistInt));
/*
NXDputalias(hfil,self->pDict,"framecounts",lData);
*/
/* code for reducing object numbers in HDF-4
NXDopenalias(hfil,self->pDict,"framecounts");
NXputdata(hfil,lData);
NXsetdimname(hfil,0,"frame_x");
NXsetdimname(hfil,1,"frame_y");
*/
NXclosedata(hfil);
fVal = fTTheta + self->hm3Off;
@@ -555,91 +611,93 @@ name of hkl object holding crystallographic information
first set detector variables in dictionary
This is the first detector.
*/
strcpy(pBueffel,"detector1");
NXDupdate(self->pDict,"dnumber",pBueffel);
sprintf(pBueffel,"%d",DET1X);
NXDupdate(self->pDict,"framedim1",pBueffel);
sprintf(pBueffel,"%d",DET1Y);
NXDupdate(self->pDict,"framedim2",pBueffel);
strcpy(pBueffel,DET1DESC);
iRet = NXDputalias(hfil,self->pDict,"ddescription",pBueffel);
if(iRet != NX_OK)
if(self->pHistogram1 != NULL)
{
SCWrite(pCon,"ERROR: failed to write detector1 description",eError);
strcpy(pBueffel,"detector1");
NXDupdate(self->pDict,"dnumber",pBueffel);
sprintf(pBueffel,"%d",DET1X);
NXDupdate(self->pDict,"framedim1",pBueffel);
sprintf(pBueffel,"%d",DET1Y);
NXDupdate(self->pDict,"framedim2",pBueffel);
strcpy(pBueffel,DET1DESC);
iRet = NXDputalias(hfil,self->pDict,"ddescription",pBueffel);
if(iRet != NX_OK)
{
SCWrite(pCon,"ERROR: failed to write detector1 description",eError);
}
for(i = 0; i < DET1X; i++)
{
fPix[i] = i * DET1XS;
}
iRet = NXDputalias(hfil,self->pDict,"detectorx",fPix);
if(iRet != NX_OK)
{
SCWrite(pCon,"ERROR: failed to write detector1 x-axis description",eError);
}
for(i = 0; i < DET1Y; i++)
{
fPix[i] = i * DET1YS;
}
iRet = NXDputalias(hfil,self->pDict,"detectory",fPix);
if(iRet != NX_OK)
{
SCWrite(pCon,"ERROR: failed to write detector1 y-axis description",eError);
}
pVar = NULL;
pVar = FindVariable(pServ->pSics,"det1zerox");
if(pVar)
{
fVal = pVar->fVal;
}
else
{
SCWrite(pCon,"ERROR: Variable detector x zero point not found ",eError);
fVal = -2188.99;
}
iRet = NXDputalias(hfil,self->pDict,"detzerox",&fVal);
if(iRet != NX_OK)
{
SCWrite(pCon,"ERROR: failed to write detecor x zero point",eError);
}
pVar = NULL;
pVar = FindVariable(pServ->pSics,"det1zeroy");
if(pVar)
{
fVal = pVar->fVal;
}
else
{
SCWrite(pCon,"ERROR: Variable detector y zero point not found ",eError);
fVal = -2188.99;
}
iRet = NXDputalias(hfil,self->pDict,"detzeroy",&fVal);
if(iRet != NX_OK)
{
SCWrite(pCon,"ERROR: failed to write detecor y zero point",eError);
}
pVar = NULL;
pVar = FindVariable(pServ->pSics,"det1dist");
if(pVar)
{
fVal = pVar->fVal;
}
else
{
SCWrite(pCon,"ERROR: Variable detector distance not found ",eError);
fVal = -2188.99;
}
iRet = NXDputalias(hfil,self->pDict,"detdist",&fVal);
if(iRet != NX_OK)
{
SCWrite(pCon,"ERROR: failed to write detecor y zero point",eError);
}
iRet = 1;
iRet = NXDputalias(hfil,self->pDict,"detvalid",&iRet);
if(iRet != NX_OK)
{
SCWrite(pCon,"ERROR: failed to write frame validity",eError);
}
}
for(i = 0; i < DET1X; i++)
{
fPix[i] = i * DET1XS;
}
iRet = NXDputalias(hfil,self->pDict,"detectorx",fPix);
if(iRet != NX_OK)
{
SCWrite(pCon,"ERROR: failed to write detector1 x-axis description",eError);
}
for(i = 0; i < DET1Y; i++)
{
fPix[i] = i * DET1YS;
}
iRet = NXDputalias(hfil,self->pDict,"detectory",fPix);
if(iRet != NX_OK)
{
SCWrite(pCon,"ERROR: failed to write detector1 y-axis description",eError);
}
pVar = NULL;
pVar = FindVariable(pServ->pSics,"det1zerox");
if(pVar)
{
fVal = pVar->fVal;
}
else
{
SCWrite(pCon,"ERROR: Variable detector x zero point not found ",eError);
fVal = -2188.99;
}
iRet = NXDputalias(hfil,self->pDict,"detzerox",&fVal);
if(iRet != NX_OK)
{
SCWrite(pCon,"ERROR: failed to write detecor x zero point",eError);
}
pVar = NULL;
pVar = FindVariable(pServ->pSics,"det1zeroy");
if(pVar)
{
fVal = pVar->fVal;
}
else
{
SCWrite(pCon,"ERROR: Variable detector y zero point not found ",eError);
fVal = -2188.99;
}
iRet = NXDputalias(hfil,self->pDict,"detzeroy",&fVal);
if(iRet != NX_OK)
{
SCWrite(pCon,"ERROR: failed to write detecor y zero point",eError);
}
pVar = NULL;
pVar = FindVariable(pServ->pSics,"det1dist");
if(pVar)
{
fVal = pVar->fVal;
}
else
{
SCWrite(pCon,"ERROR: Variable detector distance not found ",eError);
fVal = -2188.99;
}
iRet = NXDputalias(hfil,self->pDict,"detdist",&fVal);
if(iRet != NX_OK)
{
SCWrite(pCon,"ERROR: failed to write detecor y zero point",eError);
}
iRet = 1;
iRet = NXDputalias(hfil,self->pDict,"detvalid",&iRet);
if(iRet != NX_OK)
{
SCWrite(pCon,"ERROR: failed to write frame validity",eError);
}
/*
second frame, but only if present
*/
@@ -969,45 +1027,48 @@ name of hkl object holding crystallographic information
links in detector group
detector 1
*/
strcpy(pBueffel,"detector1");
NXDupdate(self->pDict,"dnumber",pBueffel);
iRet = NXDaliaslink(hfil,self->pDict,"det1","ddescription");
if(iRet != NX_OK)
if(self->pHistogram1 != NULL)
{
SCWrite(pCon,"WARNING: cannot link against detector description",eWarning);
strcpy(pBueffel,"detector1");
NXDupdate(self->pDict,"dnumber",pBueffel);
iRet = NXDaliaslink(hfil,self->pDict,"det1","ddescription");
if(iRet != NX_OK)
{
SCWrite(pCon,"WARNING: cannot link against detector description",eWarning);
}
iRet = NXDaliaslink(hfil,self->pDict,"det1","detectorx");
if(iRet != NX_OK)
{
SCWrite(pCon,"WARNING: cannot link against detector x-axis",eWarning);
}
iRet = NXDaliaslink(hfil,self->pDict,"det1","detectory");
if(iRet != NX_OK)
{
SCWrite(pCon,"WARNING: cannot link against detector y-axis",eWarning);
}
iRet = NXDaliaslink(hfil,self->pDict,"det1","detzerox");
if(iRet != NX_OK)
{
SCWrite(pCon,"WARNING: cannot link against detector x zero ",eWarning);
}
iRet = NXDaliaslink(hfil,self->pDict,"det1","detzeroy");
if(iRet != NX_OK)
{
SCWrite(pCon,"WARNING: cannot link against detector y zero",eWarning);
}
iRet = NXDaliaslink(hfil,self->pDict,"det1","detdist");
if(iRet != NX_OK)
{
SCWrite(pCon,"WARNING: cannot link against detector distance",
eWarning);
}
iRet = 1;
iRet = NXDputalias(hfil,self->pDict,"detvalid",&iRet);
if(iRet != NX_OK)
{
SCWrite(pCon,"ERROR: failed to write frame validity",eError);
}
}
iRet = NXDaliaslink(hfil,self->pDict,"det1","detectorx");
if(iRet != NX_OK)
{
SCWrite(pCon,"WARNING: cannot link against detector x-axis",eWarning);
}
iRet = NXDaliaslink(hfil,self->pDict,"det1","detectory");
if(iRet != NX_OK)
{
SCWrite(pCon,"WARNING: cannot link against detector y-axis",eWarning);
}
iRet = NXDaliaslink(hfil,self->pDict,"det1","detzerox");
if(iRet != NX_OK)
{
SCWrite(pCon,"WARNING: cannot link against detector x zero ",eWarning);
}
iRet = NXDaliaslink(hfil,self->pDict,"det1","detzeroy");
if(iRet != NX_OK)
{
SCWrite(pCon,"WARNING: cannot link against detector y zero",eWarning);
}
iRet = NXDaliaslink(hfil,self->pDict,"det1","detdist");
if(iRet != NX_OK)
{
SCWrite(pCon,"WARNING: cannot link against detector distance",eWarning);
}
iRet = 1;
iRet = NXDputalias(hfil,self->pDict,"detvalid",&iRet);
if(iRet != NX_OK)
{
SCWrite(pCon,"ERROR: failed to write frame validity",eError);
}
/*
links in detector group, detector 2
*/
@@ -1158,7 +1219,14 @@ name of hkl object holding crystallographic information
iRet = IncrementDataNumber(self->pDanu,&iYear);
sprintf(pBueffel,"%s/trics%5.5d%4.4d.hdf",self->pFileRoot,iRet, iYear);
self->pCurrentFile = strdup(pBueffel);
iRet = NXopen(self->pCurrentFile,NXACC_CREATE,&hfil);
if(self->iHDF5)
{
iRet = NXopen(self->pCurrentFile,NXACC_CREATE5,&hfil);
}
else
{
iRet = NXopen(self->pCurrentFile,NXACC_CREATE,&hfil);
}
if(iRet != NX_OK)
{
sprintf(pBueffel,"ERROR: cannot open %s",self->pCurrentFile);