- Changes to amorset to make polarisation analysis work
- Added yet another monitor to POLDI
This commit is contained in:
105
amorset.c
105
amorset.c
@ -73,7 +73,7 @@ static int readMotors(pamorSet self, SConnection * pCon)
|
|||||||
static int calcAmorSettings(pamorSet self, SConnection * pCon)
|
static int calcAmorSettings(pamorSet self, SConnection * pCon)
|
||||||
{
|
{
|
||||||
int readList;
|
int readList;
|
||||||
double val, dist, com = .0, soz, mot;
|
double val, dist, com = .0, soz, mot, sah, sdh, aoz, tmp;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* read motors
|
* 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
|
* slit 5
|
||||||
@ -202,10 +176,56 @@ static int calcAmorSettings(pamorSet self, SConnection * pCon)
|
|||||||
* Analyzer
|
* Analyzer
|
||||||
*/
|
*/
|
||||||
if (self->A.activeFlag == 1) {
|
if (self->A.activeFlag == 1) {
|
||||||
dist = ABS(calcCompPosition(&self->A) - calcCompPosition(&self->S));
|
com = self->targets2t - self->targetm2t + 2 * self->targetath;
|
||||||
val = soz + dist * Tand(com);
|
sah = ABS(calcCompPosition(&self->A) - calcCompPosition(&self->S));
|
||||||
addMotorToList(self->driveList, "aoz", val);
|
aoz = soz + sah * Tand(self->targets2t - self->targetm2t);
|
||||||
addMotorToList(self->driveList, "aom", com + self->targetath);
|
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);
|
LLDdelete(readList);
|
||||||
@ -217,13 +237,14 @@ static int calcAmorSettings(pamorSet self, SConnection * pCon)
|
|||||||
static int updateActualPositions(pamorSet self, SConnection * pCon)
|
static int updateActualPositions(pamorSet self, SConnection * pCon)
|
||||||
{
|
{
|
||||||
int readList, status;
|
int readList, status;
|
||||||
float val, dist, tmp, com;
|
float val, dist, tmp, com, aom, soz, aoz, sah;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* read some motors
|
* read some motors
|
||||||
*/
|
*/
|
||||||
readList = LLDcreate(sizeof(MotControl));
|
readList = LLDcreate(sizeof(MotControl));
|
||||||
addMotorToList(readList, "soz", 125);
|
addMotorToList(readList, "soz", 125);
|
||||||
|
addMotorToList(readList, "aoz", 125);
|
||||||
addMotorToList(readList, "com", 125);
|
addMotorToList(readList, "com", 125);
|
||||||
addMotorToList(readList, "aom", 125);
|
addMotorToList(readList, "aom", 125);
|
||||||
val = self->listDrive->GetValue(&readList, pCon);
|
val = self->listDrive->GetValue(&readList, pCon);
|
||||||
@ -235,6 +256,7 @@ static int updateActualPositions(pamorSet self, SConnection * pCon)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
val = getListMotorPosition(readList, "soz");
|
val = getListMotorPosition(readList, "soz");
|
||||||
|
soz = val;
|
||||||
dist = ABS(calcCompPosition(&self->S) - calcCompPosition(&self->M));
|
dist = ABS(calcCompPosition(&self->S) - calcCompPosition(&self->M));
|
||||||
tmp = val / dist;
|
tmp = val / dist;
|
||||||
if (ABS(tmp) > .0001) {
|
if (ABS(tmp) > .0001) {
|
||||||
@ -242,12 +264,21 @@ static int updateActualPositions(pamorSet self, SConnection * pCon)
|
|||||||
} else {
|
} else {
|
||||||
self->actualm2t = .0;
|
self->actualm2t = .0;
|
||||||
}
|
}
|
||||||
com = getListMotorPosition(readList, "com");
|
if(self->A.activeFlag == 1){
|
||||||
self->actuals2t = com + self->actualm2t;
|
com = getListMotorPosition(readList, "com");
|
||||||
|
aom = getListMotorPosition(readList, "aom");
|
||||||
val = getListMotorPosition(readList, "aom");
|
aoz = getListMotorPosition(readList, "aoz");
|
||||||
self->actualath = val - com;
|
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);
|
LLDdelete(readList);
|
||||||
self->mustRecalculate = 1;
|
self->mustRecalculate = 1;
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -267,7 +267,7 @@ static int ECBGetStatus(struct __COUNTER *self, float *fControl)
|
|||||||
*fControl = (float) count;
|
*fControl = (float) count;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*fControl > self->fPreset) {
|
if (*fControl > self->fPreset + 1.) {
|
||||||
ECBHalt(self);
|
ECBHalt(self);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
@ -526,6 +526,8 @@ static void PoldiUpdate(pPolterdi self, SConnection * pCon)
|
|||||||
NXDputalias(hfil, hdict, "cntime", &fVal);
|
NXDputalias(hfil, hdict, "cntime", &fVal);
|
||||||
lVal = GetMonitor(pCount, 1, pCon);
|
lVal = GetMonitor(pCount, 1, pCon);
|
||||||
NXDputalias(hfil, hdict, "cnmon1", &lVal);
|
NXDputalias(hfil, hdict, "cnmon1", &lVal);
|
||||||
|
lVal = GetMonitor(pCount, 2, pCon);
|
||||||
|
NXDputalias(hfil, hdict, "cnmon2", &lVal);
|
||||||
eMode = GetCounterMode(pCount);
|
eMode = GetCounterMode(pCount);
|
||||||
if (eMode == eTimer) {
|
if (eMode == eTimer) {
|
||||||
strcpy(pBueffel, "timer");
|
strcpy(pBueffel, "timer");
|
||||||
|
7
tdchm.c
7
tdchm.c
@ -261,15 +261,16 @@ static int TDCHalt(pHistDriver self)
|
|||||||
assert(tdc);
|
assert(tdc);
|
||||||
tdc->errorCode = 0;
|
tdc->errorCode = 0;
|
||||||
|
|
||||||
|
if (tdc->counter != NULL) {
|
||||||
|
tdc->counter->pDriv->Halt(tdc->counter->pDriv);
|
||||||
|
}
|
||||||
|
|
||||||
status = disableTdc(tdc);
|
status = disableTdc(tdc);
|
||||||
if (status != 1) {
|
if (status != 1) {
|
||||||
tdc->errorCode = COMMERROR;
|
tdc->errorCode = COMMERROR;
|
||||||
return HWFault;
|
return HWFault;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tdc->counter != NULL) {
|
|
||||||
tdc->counter->pDriv->Halt(tdc->counter->pDriv);
|
|
||||||
}
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user