- Added polarisation support for TAS

This commit is contained in:
cvs
2002-04-03 15:32:26 +00:00
parent a5346ddedc
commit 0ce72deb58
17 changed files with 557 additions and 89 deletions

123
tasutil.c
View File

@@ -15,6 +15,10 @@
TAS settings..
Mark Koennecke, November 2000
Polarisation support added.
Mark Koennecke, April 2002
---------------------------------------------------------------------------*/
#include <stdlib.h>
#include <assert.h>
@@ -50,6 +54,21 @@ int isTASMotor(char *val)
}
return -1;
}
/*------------------------------------------------------------------------
return number if val is a current variable, else -1
-----------------------------------------------------------------------*/
int isTASCurrent(char *val){
int test;
test = isTASMotor(val);
if(test < 0){
return test;
}
if(test > 18){
return test;
} else {
return -1;
}
}
/*--------------------------------------------------------------------------
isTASVar finds out if the given string is a TAS variable and returns its
index if this is the case. Else -1 will be returned.
@@ -333,9 +352,9 @@ int TASCalc(pTASdata self, SConnection *pCon,
qhkl[1] = (real)self->tasPar[TQK]->fVal;
qhkl[2] = (real)self->tasPar[TQL]->fVal;
en = (real)self->tasPar[TEN]->fVal;
hx = (real)self->tasPar[HX]->fVal;
hy = (real)self->tasPar[HY]->fVal;
hz = (real)self->tasPar[HZ]->fVal;
hx = (real)self->tasPar[THX]->fVal;
hy = (real)self->tasPar[THY]->fVal;
hz = (real)self->tasPar[THZ]->fVal;
f = (real)2.072; /* energy unit meV */
if1 = (integer)self->tasPar[F1]->iVal;
if2 = (integer)self->tasPar[F2]->iVal;
@@ -343,8 +362,17 @@ int TASCalc(pTASdata self, SConnection *pCon,
{
ldk[i] = (logical)tasMask[i];
}
ldh = (logical)tasMask[8];
ldf = (logical)tasMask[9];
if(if1 > 0 || if2 > 0){
ldf = 1;
} else {
ldf = 0;
}
if(tasMask[9] || tasMask[10] || tasMask[11] ) {
ldh = 1;
} else {
ldh = 0;
}
if(self->tasPar[LPA]->iVal > 0)
lpa = (logical)1;
else
@@ -364,15 +392,15 @@ int TASCalc(pTASdata self, SConnection *pCon,
isa = (integer)self->tasPar[SA]->iVal;
/*
initialize the helmholts currents. This needs work when
polarisation analysis is really supported.
initialize the magnet currents.
*/
for(i = 0; i < 4; i++)
{
helmconv[i] = .0;
currents[i] = .0;
currents[i+4] = .0;
currents[i] = readCurrent(tasMotorOrder[CURMOT+i],pCon);
currents[i+4] = readCurrent(tasMotorOrder[CURMOT + i + 4],pCon);
}
readConversionFactors(self,helmconv);
/*
initalise the motorMasks to 0.
@@ -412,6 +440,9 @@ int TASCalc(pTASdata self, SConnection *pCon,
motorTargets[i] = angles[i];
motorMask[i] = ldra[i];
}
/*
these additional motors are the curvature motors
*/
motorMask[6] = l_RM;
motorTargets[6] = tRM;
motorMask[8] = l_RA;
@@ -420,10 +451,19 @@ int TASCalc(pTASdata self, SConnection *pCon,
{
motorTargets[9+i] = currents[i];
}
for(i = 0; i < 4; i++)
{
motorTargets[17+i] = helmconv[i];
}
if(ldh){
/* currents must be driven */
for( i = 0; i < 4; i++){
motorMask[13+i] = 1;
}
}
if(ldf){
/* currents must be driven */
for( i = 0; i < 4; i++){
motorMask[9+i] = 1;
}
}
self->tasPar[TEI]->fVal = (float)ei;
self->tasPar[TKI]->fVal = (float)aki;
self->tasPar[TEF]->fVal = (float)ef;
@@ -485,9 +525,13 @@ int TASStart(pTASdata self, SConnection *pCon, SicsInterp *pSics,
}
/*
missing: set the magnet currents. In order to do this, I need more
info about the magnets involved and how to address them.
start magnet currents.
*/
for(i = 0; i < 8; i++){
if(motorMask[9+i] == 1){
startCurrent(tasMotorOrder[CURMOT+i],pCon,motorTargets[9+i]);
}
}
return 1;
}
@@ -577,15 +621,15 @@ int TASUpdate(pTASdata self, SConnection *pCon)
}
/*
initialize magnet things to harmless. TODO: update to read properly
when installed.
read magnet currents.
*/
for(i = 0; i < 4; i++)
{
helmCurrent[i] = .0;
helmCurrent[4+i] = .0;
convH[i] = .0;
helmCurrent[i] = readCurrent(tasMotorOrder[CURMOT+i],pCon);
helmCurrent[4+i] = readCurrent(tasMotorOrder[CURMOT+i+4],pCon);
}
readConversionFactors(self,convH);
/*
collect all the other machine parameters needed for a call to
@@ -650,6 +694,9 @@ int TASUpdate(pTASdata self, SConnection *pCon)
self->tasPar[HY]->fVal = hy;
self->tasPar[HZ]->fVal = hz;
self->tasPar[QM]->fVal = qm;
self->tasPar[HX]->fVal = hx;
self->tasPar[HY]->fVal = hy;
self->tasPar[HZ]->fVal = hz;
/*
now check the analyzer or monochromator angles
@@ -678,7 +725,45 @@ int TASUpdate(pTASdata self, SConnection *pCon)
SCWrite(pCon,pBueffel,eWarning);
}
}
return 1;
}
/*-----------------------------------------------------------------------
readCurrent tries to read the value of one of the magnet currents.
All errors are ignored because most of the time currents will not be
present in the system.
-----------------------------------------------------------------------*/
float readCurrent(char *val, SConnection *pCon){
pIDrivable pDriv;
CommandList *pCom;
pDummy pDum;
pCom = FindCommand(pServ->pSics,val);
if(pCom != NULL){
pDriv = GetDrivableInterface(pCom->pData);
if(pDriv != NULL){
return pDriv->GetValue(pCom->pData,pCon);
}
}
return .0;
}
/*-----------------------------------------------------------------------
startCurrent starts driving a current to a new value
All errors are ignored because most of the time currents will not be
present in the system.
-----------------------------------------------------------------------*/
void startCurrent(char *val, SConnection *pCon, float fVal){
StartMotor(pServ->pExecutor,pServ->pSics,pCon,
val,fVal);
}
/*-----------------------------------------------------------------------
readConversionFactors updates the array given as a parameter with the
values of the Gauss->Ampere conversion factors
-------------------------------------------------------------------------*/
void readConversionFactors(pTASdata self,float convH[4]){
convH[0] = self->tasPar[HCONV1]->fVal;
convH[1] = self->tasPar[HCONV2]->fVal;
convH[2] = self->tasPar[HCONV3]->fVal;
convH[3] = self->tasPar[HCONV4]->fVal;
}