- Added back calculation from motor positions to Q/E variables into
TAS code. - Fixed communication problems in SerPortServer, mainly with terminator detection. - Added SPS switched motors for TOPSI - Debugged Power-PC histogram memory software for TRICS
This commit is contained in:
240
tasutil.c
240
tasutil.c
@@ -289,7 +289,7 @@ int TASCalc(pTASdata self, SConnection *pCon,
|
||||
if(self->tasPar[LPA]->iVal > 0)
|
||||
lpa = (logical)1;
|
||||
dm = (real)self->tasPar[DM]->fVal;
|
||||
da = (real)self->tasPar[DM]->fVal;
|
||||
da = (real)self->tasPar[DA]->fVal;
|
||||
qm = (real)self->tasPar[QM]->fVal;
|
||||
helm = (real)self->tasPar[HELM]->fVal;
|
||||
f1h = (real)self->tasPar[IF1H]->fVal;
|
||||
@@ -303,7 +303,7 @@ int TASCalc(pTASdata self, SConnection *pCon,
|
||||
|
||||
/*
|
||||
initialize the helmholts currents. This needs work when
|
||||
polarisation anlaysis is really supported.
|
||||
polarisation analysis is really supported.
|
||||
*/
|
||||
for(i = 0; i < 4; i++)
|
||||
{
|
||||
@@ -474,5 +474,239 @@ int TASStart(pTASdata self, SConnection *pCon, SicsInterp *pSics,
|
||||
*/
|
||||
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
/*------------------ from t_update.f converted to t_update.c -----------*/
|
||||
extern int t_update__(real *p_a__, real *p_ih__, real *c_ih__,
|
||||
logical *lpa, real *dm, real *da, integer *isa,
|
||||
real *helm, real *f1h, real *f1v, real *f2h, real *f2v,
|
||||
real *f, real *ei, real *aki, real *ef, real *akf,
|
||||
real *qhkl, real *en, real *hx, real *hy, real *hz,
|
||||
integer *if1, integer *if2, real *qm, integer *ier);
|
||||
/*---------------------------------------------------------------------------
|
||||
TASUpdate calculates the Q/E variables back from the motors A1-A6 and
|
||||
then proceeds to update the energy variables. It also checks if the
|
||||
analyzer monochromator motors match up i.e tth = 2*om.
|
||||
----------------------------------------------------------------------------*/
|
||||
int TASUpdate(pTASdata self, SConnection *pCon)
|
||||
{
|
||||
real sam[16], amot[6], helmCurrent[8], convH[4], dm, da, helm, f1h, f1v;
|
||||
real f, ei, aki, ef, akf, qhkl[3], en, hx, hy, hz, qm, f2v, f2h;
|
||||
logical lpa;
|
||||
integer isa, if1, if2, ier, ifx;
|
||||
pMotor pMot;
|
||||
char pBueffel[132];
|
||||
float fMot, diff;
|
||||
int i, status;
|
||||
|
||||
assert(self);
|
||||
assert(pCon);
|
||||
|
||||
/*
|
||||
The first thing we need to do is to set up the orientation matrix
|
||||
from the sample parameters.
|
||||
*/
|
||||
sam[0] = (real)self->tasPar[AS]->fVal;
|
||||
sam[1] = (real)self->tasPar[BS]->fVal;
|
||||
sam[2] = (real)self->tasPar[CS]->fVal;
|
||||
sam[3] = (real)self->tasPar[AA]->fVal;
|
||||
sam[4] = (real)self->tasPar[BB]->fVal;
|
||||
sam[5] = (real)self->tasPar[CC]->fVal;
|
||||
sam[6] = (real)self->tasPar[AX]->fVal;
|
||||
sam[7] = (real)self->tasPar[AY]->fVal;
|
||||
sam[8] = (real)self->tasPar[AZ]->fVal;
|
||||
sam[9] = (real)self->tasPar[BX]->fVal;
|
||||
sam[10] = (real)self->tasPar[BY]->fVal;
|
||||
sam[11] = (real)self->tasPar[BZ]->fVal;
|
||||
setrlp_(sam,&ier);
|
||||
switch(ier)
|
||||
{
|
||||
case 1:
|
||||
SCWrite(pCon,"ERROR: error on lattice parameters",eError);
|
||||
return 0;
|
||||
break;
|
||||
case 2:
|
||||
SCWrite(pCon,"ERROR: error on lattice angles",eError);
|
||||
return 0;
|
||||
break;
|
||||
case 3:
|
||||
SCWrite(pCon,"ERROR: error on vectors A1, A2",eError);
|
||||
return 0;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
get the motor angles A1-A6
|
||||
*/
|
||||
for(i = 0; i < 6; i++)
|
||||
{
|
||||
pMot = FindMotor(pServ->pSics,tasMotorOrder[i]);
|
||||
if(!pMot)
|
||||
{
|
||||
sprintf(pBueffel,"ERROR: internal: motor %s NOT found",
|
||||
tasMotorOrder[i]);
|
||||
SCWrite(pCon,pBueffel,eError);
|
||||
return 0;
|
||||
}
|
||||
status = MotorGetSoftPosition(pMot,pCon,&fMot);
|
||||
if(status != 1)
|
||||
{
|
||||
sprintf(pBueffel, "ERROR: failed to read motor %s",
|
||||
tasMotorOrder[i]);
|
||||
SCWrite(pCon,pBueffel,eError);
|
||||
return 0;
|
||||
}
|
||||
amot[i] = fMot;
|
||||
}
|
||||
|
||||
/*
|
||||
initialize magnet things to harmless. TODO: update to read properly
|
||||
when installed.
|
||||
*/
|
||||
for(i = 0; i < 4; i++)
|
||||
{
|
||||
helmCurrent[i] = .0;
|
||||
helmCurrent[4+i] = .0;
|
||||
convH[i] = .0;
|
||||
}
|
||||
|
||||
/*
|
||||
collect all the other machine parameters needed for a call to
|
||||
t_update
|
||||
*/
|
||||
if(self->tasPar[LPA]->iVal > 0)
|
||||
lpa = (logical)1;
|
||||
da = (real)self->tasPar[DA]->fVal;
|
||||
dm = (real)self->tasPar[DM]->fVal;
|
||||
isa = (integer)self->tasPar[SA]->iVal;
|
||||
helm = (real)self->tasPar[HELM]->fVal;
|
||||
f1h = (real)self->tasPar[IF1H]->fVal;
|
||||
f1v = (real)self->tasPar[IF1V]->fVal;
|
||||
f2h = (real)self->tasPar[IF2H]->fVal;
|
||||
f2v = (real)self->tasPar[IF2V]->fVal;
|
||||
f = (real)2.072; /* energy unit meV */
|
||||
|
||||
ifx = (integer)self->tasPar[FX]->iVal;
|
||||
|
||||
/*
|
||||
now call t_update to do the calculation
|
||||
*/
|
||||
t_update__(amot, helmCurrent, convH, &lpa, &dm, &da, &isa, &helm,
|
||||
&f1h, &f1v, &f2h, &f2v, &f, &ei, &aki, &ef, &akf,
|
||||
qhkl, &en, &hx, &hy, &hz, &if1, &if2, &qm, &ier);
|
||||
/*
|
||||
!!!!!!!!!!!!! WARNING !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
t_update's function ex_up must be dited manually after conversion
|
||||
to c by f2c. The reason is a different definition of the abs function.
|
||||
The line:
|
||||
arg = (d__1 = *dx * sin(*ax2 / 114.59155902616465, abs(d__1));
|
||||
|
||||
has to be changed to:
|
||||
arg = *dx * sin(*ax2 / 114.59155902616465);
|
||||
if(arg < .0)
|
||||
arg = -arg;
|
||||
|
||||
!!!!!!!!!!!!!!!!!!!!!! WARNING !!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
|
||||
|
||||
/*
|
||||
error messages taken from erreso
|
||||
*/
|
||||
switch(ier)
|
||||
{
|
||||
case 1:
|
||||
SCWrite(pCon,"ERROR: Bad lattice parameters",eError);
|
||||
return 0;
|
||||
break;
|
||||
case 2:
|
||||
SCWrite(pCon,"ERROR: Bad cell angles",eError);
|
||||
return 0;
|
||||
break;
|
||||
case 3:
|
||||
SCWrite(pCon,"ERROR: Bad scattering plane ",eError);
|
||||
return 0;
|
||||
break;
|
||||
case 4:
|
||||
SCWrite(pCon,"ERROR: Bad lattice or lattice plane",eError);
|
||||
return 0;
|
||||
break;
|
||||
case 5:
|
||||
SCWrite(pCon,"ERROR: Q not in scattering plane",eError);
|
||||
return 0;
|
||||
break;
|
||||
case 6:
|
||||
SCWrite(pCon,"ERROR: Q modulus to small",eError);
|
||||
return 0;
|
||||
break;
|
||||
case 7:
|
||||
case 12:
|
||||
SCWrite(pCon,"ERROR: KI, KF, Q triangle cannot close ",eError);
|
||||
return 0;
|
||||
break;
|
||||
case 8:
|
||||
SCWrite(pCon,"ERROR: in KI, KF, check d-spacings",eError);
|
||||
return 0;
|
||||
break;
|
||||
case 9:
|
||||
SCWrite(pCon,"ERROR: KI or KF cannot be obtained",eError);
|
||||
return 0;
|
||||
break;
|
||||
case 10:
|
||||
SCWrite(pCon,"ERROR: KI or KF to small",eError);
|
||||
return 0;
|
||||
break;
|
||||
case 11:
|
||||
SCWrite(pCon,"ERROR: KI or KF cannot be obtained",eError);
|
||||
return 0;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
update all the energy variables
|
||||
*/
|
||||
self->tasPar[EI]->fVal = ei;
|
||||
self->tasPar[KI]->fVal = aki;
|
||||
self->tasPar[EF]->fVal = ef;
|
||||
self->tasPar[KF]->fVal = akf;
|
||||
self->tasPar[QH]->fVal = qhkl[0];
|
||||
self->tasPar[QK]->fVal = qhkl[1];
|
||||
self->tasPar[QL]->fVal = qhkl[2];
|
||||
self->tasPar[EN]->fVal = en;
|
||||
self->tasPar[HX]->fVal = hx;
|
||||
self->tasPar[HY]->fVal = hy;
|
||||
self->tasPar[HZ]->fVal = hz;
|
||||
self->tasPar[QM]->fVal = qm;
|
||||
|
||||
/*
|
||||
now check the analyzer or monochromator angles
|
||||
*/
|
||||
if(ifx == 1)
|
||||
{
|
||||
diff = amot[1]/2 - amot[0];
|
||||
if(diff < .0)
|
||||
diff = -diff;
|
||||
if(diff > .1)
|
||||
{
|
||||
sprintf(pBueffel,"WARNING: A2 = %f is not half of A1 = %f",
|
||||
amot[1], amot[0]);
|
||||
SCWrite(pCon,pBueffel,eWarning);
|
||||
}
|
||||
}
|
||||
else if (ifx == 2)
|
||||
{
|
||||
diff = amot[5]/2 - amot[4];
|
||||
if(diff < .0)
|
||||
diff = -diff;
|
||||
if(diff > .1)
|
||||
{
|
||||
sprintf(pBueffel,"WARNING: A6 = %f is not half of A5 = %f",
|
||||
amot[5], amot[4]);
|
||||
SCWrite(pCon,pBueffel,eWarning);
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user