- added backwards calculation of hkl from four circle angles. This
required inclusion of a matrix package. - modified counter error handling to send a Stop when the _BAD_BUSY error is received. - added an environment interface to the general controller stuff in choco.* Also added setting a parameter directly at the controller object. - Added a driver for the ETH High Temperature Furnace to be used at SANS.
This commit is contained in:
80
hkl.c
80
hkl.c
@ -18,6 +18,7 @@
|
||||
#include "motor.h"
|
||||
#include "selector.h"
|
||||
#include "selvar.h"
|
||||
#include "matrix/matrix.h"
|
||||
#include "hkl.h"
|
||||
#include "hkl.i"
|
||||
/*-------------------------------------------------------------------------*/
|
||||
@ -79,6 +80,7 @@
|
||||
pNew->fUB[0] = 1.;
|
||||
pNew->fUB[4] = 1.;
|
||||
pNew->fUB[8] = 1.;
|
||||
pNew->UBinv = NULL;
|
||||
|
||||
return pNew;
|
||||
}
|
||||
@ -306,6 +308,7 @@
|
||||
int SetUB(pHKL self, float fUB[9])
|
||||
{
|
||||
int i;
|
||||
MATRIX m;
|
||||
|
||||
assert(self);
|
||||
|
||||
@ -313,6 +316,21 @@
|
||||
{
|
||||
self->fUB[i] = fUB[i];
|
||||
}
|
||||
/* invert UB matrix for use in backwards calculation */
|
||||
if(self->UBinv != NULL)
|
||||
{
|
||||
mat_free(self->UBinv);
|
||||
}
|
||||
m = mat_creat(3,3,ZERO_MATRIX);
|
||||
for(i = 0; i < 3; i++)
|
||||
{
|
||||
m[0][i] = self->fUB[i];
|
||||
m[1][i] = self->fUB[3+i];
|
||||
m[2][i] = self->fUB[6+i];
|
||||
}
|
||||
self->UBinv = mat_inv(m);
|
||||
mat_free(m);
|
||||
|
||||
return 1;
|
||||
}
|
||||
/*-------------------------------------------------------------------------*/
|
||||
@ -1183,6 +1201,42 @@ ente:
|
||||
|
||||
return iResult;
|
||||
}
|
||||
/*-------------------------------------------------------------------------
|
||||
For the conversion from angles to HKL.
|
||||
-------------------------------------------------------------------------*/
|
||||
static int angle2HKL(pHKL self ,double tth, double om,
|
||||
double chi, double phi, float fHKL[3])
|
||||
{
|
||||
double dTh, dOm, dChi, dPhi, dHM;
|
||||
MATRIX res, rez;
|
||||
int i;
|
||||
|
||||
/* conversion to radians */
|
||||
dTh = tth/(2*RD);
|
||||
dOm = (om - tth/2.)/RD;
|
||||
dChi = chi/RD;
|
||||
dPhi = phi/RD;
|
||||
dHM = 2* sin(dTh)/self->fLambda;
|
||||
|
||||
/* angles to XYZ, stolen from DIFRAC code in PRPXYZ */
|
||||
res = mat_creat(3,1,ZERO_MATRIX);
|
||||
res[0][0] = dHM*(cos(dChi)*cos(dPhi)*cos(dOm) -
|
||||
sin(dPhi)*sin(dOm));
|
||||
res[1][0] = dHM*(cos(dChi)*sin(dPhi)*cos(dOm) +
|
||||
cos(dPhi)*sin(dOm));
|
||||
res[2][0] = dHM*sin(dChi)*cos(dOm);
|
||||
|
||||
/* multiply with UBinv in order to yield HKL */
|
||||
rez = mat_mul(self->UBinv,res);
|
||||
for(i = 0; i < 3; i++)
|
||||
{
|
||||
fHKL[i] = rez[i][0];
|
||||
}
|
||||
mat_free(res);
|
||||
mat_free(rez);
|
||||
|
||||
return 1;
|
||||
}
|
||||
/*--------------------------------------------------------------------------*/
|
||||
int isNumeric(char *pText)
|
||||
{
|
||||
@ -1312,10 +1366,28 @@ ente:
|
||||
/*----------- current */
|
||||
else if(strcmp(argv[1],"current") == 0)
|
||||
{
|
||||
sprintf(pBueffel,"Last HKL: %8.4f %8.4f %8.4f ",
|
||||
self->fLastHKL[0], self->fLastHKL[1],self->fLastHKL[2]);
|
||||
SCWrite(pCon,pBueffel,eValue);
|
||||
return 1;
|
||||
if(self->iNOR)
|
||||
{
|
||||
sprintf(pBueffel,"Last HKL: %8.4f %8.4f %8.4f ",
|
||||
self->fLastHKL[0], self->fLastHKL[1],self->fLastHKL[2]);
|
||||
SCWrite(pCon,pBueffel,eValue);
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* do a serious calculation based on angles */
|
||||
iRet = GetCurrentPosition(self,pCon,fSet);
|
||||
if(iRet == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
angle2HKL(self,(double)fSet[0],(double)fSet[1],
|
||||
(double)fSet[2],(double)fSet[3],fHKL);
|
||||
sprintf(pBueffel,"Current HKL: %8.4f %8.4f %8.4f ",
|
||||
fHKL[0], fHKL[1],fHKL[2]);
|
||||
SCWrite(pCon,pBueffel,eValue);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
/*------------- lambda */
|
||||
else if(strcmp(argv[1],"lambda") == 0)
|
||||
|
Reference in New Issue
Block a user