- Changes to amorset to make polarisation analysis work
- Added yet another monitor to POLDI
This commit is contained in:
103
amorset.c
103
amorset.c
@ -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,11 +264,20 @@ static int updateActualPositions(pamorSet self, SConnection * pCon)
|
||||
} else {
|
||||
self->actualm2t = .0;
|
||||
}
|
||||
com = getListMotorPosition(readList, "com");
|
||||
self->actuals2t = com + self->actualm2t;
|
||||
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;
|
||||
val = getListMotorPosition(readList, "aom");
|
||||
self->actualath = val - com;
|
||||
}
|
||||
|
||||
LLDdelete(readList);
|
||||
self->mustRecalculate = 1;
|
||||
|
@ -267,7 +267,7 @@ static int ECBGetStatus(struct __COUNTER *self, float *fControl)
|
||||
*fControl = (float) count;
|
||||
}
|
||||
|
||||
if (*fControl > self->fPreset) {
|
||||
if (*fControl > self->fPreset + 1.) {
|
||||
ECBHalt(self);
|
||||
}
|
||||
return result;
|
||||
|
@ -526,6 +526,8 @@ static void PoldiUpdate(pPolterdi self, SConnection * pCon)
|
||||
NXDputalias(hfil, hdict, "cntime", &fVal);
|
||||
lVal = GetMonitor(pCount, 1, pCon);
|
||||
NXDputalias(hfil, hdict, "cnmon1", &lVal);
|
||||
lVal = GetMonitor(pCount, 2, pCon);
|
||||
NXDputalias(hfil, hdict, "cnmon2", &lVal);
|
||||
eMode = GetCounterMode(pCount);
|
||||
if (eMode == eTimer) {
|
||||
strcpy(pBueffel, "timer");
|
||||
|
7
tdchm.c
7
tdchm.c
@ -261,15 +261,16 @@ static int TDCHalt(pHistDriver self)
|
||||
assert(tdc);
|
||||
tdc->errorCode = 0;
|
||||
|
||||
if (tdc->counter != NULL) {
|
||||
tdc->counter->pDriv->Halt(tdc->counter->pDriv);
|
||||
}
|
||||
|
||||
status = disableTdc(tdc);
|
||||
if (status != 1) {
|
||||
tdc->errorCode = COMMERROR;
|
||||
return HWFault;
|
||||
}
|
||||
|
||||
if (tdc->counter != NULL) {
|
||||
tdc->counter->pDriv->Halt(tdc->counter->pDriv);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user