- Changes to amorset to make polarisation analysis work

- Added yet another monitor to POLDI
This commit is contained in:
koennecke
2009-10-30 13:50:49 +00:00
parent b3e425b965
commit 4aca8c9e94
4 changed files with 75 additions and 41 deletions

105
amorset.c
View File

@ -73,7 +73,7 @@ static int readMotors(pamorSet self, SConnection * pCon)
static int calcAmorSettings(pamorSet self, SConnection * pCon)
{
int readList;
double val, dist, com = .0, soz, mot;
double val, dist, com = .0, soz, mot, sah, sdh, aoz, tmp;
/*
* read motors
@ -153,33 +153,7 @@ static int calcAmorSettings(pamorSet self, SConnection * pCon)
}
/*
* detector
*/
com = self->targets2t - self->targetm2t;
if (self->D.activeFlag == 1) {
addMotorToList(self->driveList, "com", com);
dist = ABS(calcCompPosition(&self->D) - calcCompPosition(&self->S));
val = -dist * (Cosd(com) - 1.);
addMotorToList(self->driveList, "cox", val);
val = dist * Sind(com) + soz;
addMotorToList(self->driveList, "coz", val);
}
/*
* slit 4
*/
if (self->D4.activeFlag == 1) {
dist = ABS(calcCompPosition(&self->D4) - calcCompPosition(&self->S));
mot = getListMotorPosition(readList, "d4t");
if (mot < -99999) {
SCWrite(pCon, "WARNING: skipping d4 because of bad read on d4t",
eWarning);
} else {
val = soz + dist * Tand(com) - .5 * mot;
addMotorToList(self->driveList, "d4b", val);
}
}
/*
* slit 5
@ -202,10 +176,56 @@ static int calcAmorSettings(pamorSet self, SConnection * pCon)
* Analyzer
*/
if (self->A.activeFlag == 1) {
dist = ABS(calcCompPosition(&self->A) - calcCompPosition(&self->S));
val = soz + dist * Tand(com);
addMotorToList(self->driveList, "aoz", val);
addMotorToList(self->driveList, "aom", com + self->targetath);
com = self->targets2t - self->targetm2t + 2 * self->targetath;
sah = ABS(calcCompPosition(&self->A) - calcCompPosition(&self->S));
aoz = soz + sah * Tand(self->targets2t - self->targetm2t);
addMotorToList(self->driveList, "aoz", aoz);
addMotorToList(self->driveList, "aom", self->targets2t - self->targetm2t + self->targetath);
/*
* detector, evil analyzer in
*/
if(self->D.activeFlag == 1){
sdh = ABS(calcCompPosition(&self->D) - calcCompPosition(&self->S));
addMotorToList(self->driveList, "com", com);
tmp = soz -aoz;
val = sah - sqrt(sah*sah + tmp*tmp) + (sdh - sqrt(sah*sah + tmp*tmp))*(Cosd(com) -1.);
addMotorToList(self->driveList, "cox", -val);
val = aoz + (sdh -sqrt(sah*sah + tmp*tmp))*Sind(com);
addMotorToList(self->driveList, "coz", val);
}
} else {
/*
* detector, analyzer gone for good
*/
com = self->targets2t - self->targetm2t;
if (self->D.activeFlag == 1) {
addMotorToList(self->driveList, "com", com);
dist = ABS(calcCompPosition(&self->D) - calcCompPosition(&self->S));
val = -dist * (Cosd(com) - 1.);
addMotorToList(self->driveList, "cox", -val);
val = dist * Sind(com) + soz;
addMotorToList(self->driveList, "coz", val);
}
}
/*
* slit 4
*/
if (self->D4.activeFlag == 1) {
dist = ABS(calcCompPosition(&self->D4) - calcCompPosition(&self->S));
mot = getListMotorPosition(readList, "d4t");
if (mot < -99999) {
SCWrite(pCon, "WARNING: skipping d4 because of bad read on d4t",
eWarning);
} else {
if(self->A.activeFlag == 1){
val = soz + dist * Tand(self->targets2t - self->targetm2t) - .5*mot;
} else {
val = soz + dist * Tand(com) - .5 * mot;
}
addMotorToList(self->driveList, "d4b", val);
}
}
LLDdelete(readList);
@ -217,13 +237,14 @@ static int calcAmorSettings(pamorSet self, SConnection * pCon)
static int updateActualPositions(pamorSet self, SConnection * pCon)
{
int readList, status;
float val, dist, tmp, com;
float val, dist, tmp, com, aom, soz, aoz, sah;
/**
* read some motors
*/
readList = LLDcreate(sizeof(MotControl));
addMotorToList(readList, "soz", 125);
addMotorToList(readList, "aoz", 125);
addMotorToList(readList, "com", 125);
addMotorToList(readList, "aom", 125);
val = self->listDrive->GetValue(&readList, pCon);
@ -235,6 +256,7 @@ static int updateActualPositions(pamorSet self, SConnection * pCon)
return 0;
}
val = getListMotorPosition(readList, "soz");
soz = val;
dist = ABS(calcCompPosition(&self->S) - calcCompPosition(&self->M));
tmp = val / dist;
if (ABS(tmp) > .0001) {
@ -242,12 +264,21 @@ static int updateActualPositions(pamorSet self, SConnection * pCon)
} else {
self->actualm2t = .0;
}
com = getListMotorPosition(readList, "com");
self->actuals2t = com + self->actualm2t;
val = getListMotorPosition(readList, "aom");
self->actualath = val - com;
if(self->A.activeFlag == 1){
com = getListMotorPosition(readList, "com");
aom = getListMotorPosition(readList, "aom");
aoz = getListMotorPosition(readList, "aoz");
sah = ABS(calcCompPosition(&self->A) - calcCompPosition(&self->S));
self->actuals2t = Atand((aoz-soz)/sah) + self->actualm2t;
self->actualath = self->actuals2t - self->actualm2t - aom;
} else {
com = getListMotorPosition(readList, "com");
self->actuals2t = com + self->actualm2t;
val = getListMotorPosition(readList, "aom");
self->actualath = val - com;
}
LLDdelete(readList);
self->mustRecalculate = 1;
return 1;