- Added scaling to sicsdata

- Fixed fixed motor driving in tasdrive
- Fixed stdscan to behnave nicely when various things are missing
- Fixed a bug in multicounter
This commit is contained in:
koennecke
2007-04-26 14:33:36 +00:00
parent 82be2f1f85
commit 6c71e32f4b
6 changed files with 190 additions and 230 deletions

View File

@ -217,11 +217,33 @@ static float getMotorValue(pMotor mot, SConnection *pCon){
MotorGetSoftPosition(mot,pCon,&val);
return val;
}
}
/*--------------------------------------------------------------------------*/
static int startTASMotor(pMotor mot, SConnection *pCon, char *name,
double target, int silent){
float val, fixed;
int status = OKOK;
char buffer[132];
val = getMotorValue(mot,pCon);
MotorGetPar(mot,"fixed",&fixed);
if(ABS(fixed - 1.0) < .1) {
snprintf(buffer,131,"WARNING: %s is FIXED", name);
SCWrite(pCon,buffer,eWarning);
return OKOK;
}
if(ABS(val - target) > MOTPREC){
status = mot->pDrivInt->SetValue(mot,pCon,(float)target);
if(status != OKOK){
return status;
}
}
writeMotPos(pCon,silent,name,val, target);
return status;
}
/*---------------------------------------------------------------------------*/
static int startMotors(ptasMot self, tasAngles angles,
SConnection *pCon, int driveQ, int driveTilt){
float val;
double curve;
int status, silent;
@ -229,115 +251,71 @@ static int startMotors(ptasMot self, tasAngles angles,
/*
monochromator
*/
val = getMotorValue(self->math->motors[A1],pCon);
if(ABS(val - angles.monochromator_two_theta/2.) > MOTPREC){
status = self->math->motors[A1]->pDrivInt->SetValue(self->math->motors[A1],
pCon,
angles.monochromator_two_theta/2.);
if(status != OKOK){
return status;
}
status = startTASMotor(self->math->motors[A1],pCon, "a1",
angles.monochromator_two_theta/2.,silent);
if(status != OKOK){
return status;
}
writeMotPos(pCon,silent,"a1",val, angles.monochromator_two_theta/2.);
val = getMotorValue(self->math->motors[A2],pCon);
if(ABS(val - angles.monochromator_two_theta) > MOTPREC){
status = self->math->motors[A2]->pDrivInt->SetValue(self->math->motors[A2],
pCon,
angles.monochromator_two_theta);
if(status != OKOK){
return status;
}
status = startTASMotor(self->math->motors[A2],pCon, "a2",
angles.monochromator_two_theta,silent);
if(status != OKOK){
return status;
}
writeMotPos(pCon,silent,"a2",val, angles.monochromator_two_theta);
if(self->math->motors[MCV] != NULL){
curve = maCalcVerticalCurvature(self->math->machine.monochromator,
angles.monochromator_two_theta);
val = getMotorValue(self->math->motors[MCV],pCon);
if(ABS(val - curve) > MOTPREC){
status = self->math->motors[MCV]->pDrivInt->SetValue(self->math->motors[MCV],
pCon,
curve);
if(status != OKOK){
return status;
}
status = startTASMotor(self->math->motors[MCV],pCon, "mcv",
curve,silent);
if(status != OKOK){
return status;
}
writeMotPos(pCon,silent,"mcv",val, curve);
}
}
if(self->math->motors[MCH] != NULL){
curve = maCalcHorizontalCurvature(self->math->machine.monochromator,
angles.monochromator_two_theta);
val = getMotorValue(self->math->motors[MCH],pCon);
if(ABS(val - curve) > MOTPREC){
status = self->math->motors[MCH]->pDrivInt->SetValue(self->math->motors[MCH],
pCon,
curve);
if(status != OKOK){
return status;
}
angles.monochromator_two_theta);
status = startTASMotor(self->math->motors[MCH],pCon, "mch",
curve,silent);
if(status != OKOK){
return status;
}
writeMotPos(pCon,silent,"mch",val, curve);
}
/*
analyzer
*/
if(self->math->tasMode != ELASTIC){
val = getMotorValue(self->math->motors[A5],pCon);
if(ABS(val - angles.analyzer_two_theta/2.) > MOTPREC){
status = self->math->motors[A5]->pDrivInt->SetValue(self->math->motors[A5],
pCon,
angles.analyzer_two_theta/2.);
if(status != OKOK){
return status;
}
}
writeMotPos(pCon,silent,self->math->motors[A5]->name,
val, angles.analyzer_two_theta/2.);
val = getMotorValue(self->math->motors[A6],pCon);
if(ABS(val - angles.analyzer_two_theta) > MOTPREC){
status = self->math->motors[A6]->pDrivInt->SetValue(self->math->motors[A6],
pCon,
angles.analyzer_two_theta);
if(status != OKOK){
return status;
}
}
writeMotPos(pCon,silent,"a6",val, angles.analyzer_two_theta);
status = startTASMotor(self->math->motors[A5],pCon, "a5",
angles.analyzer_two_theta/2.0,silent);
if(status != OKOK){
return status;
}
status = startTASMotor(self->math->motors[A6],pCon, "a6",
angles.analyzer_two_theta,silent);
if(status != OKOK){
return status;
}
if(self->math->motors[ACV] != NULL){
curve = maCalcVerticalCurvature(self->math->machine.analyzer,
angles.analyzer_two_theta);
val = getMotorValue(self->math->motors[ACV],pCon);
if(ABS(val - curve) > MOTPREC){
status = self->math->motors[ACV]->pDrivInt->SetValue(self->math->motors[ACV],
pCon,
curve);
if(status != OKOK){
return status;
}
}
writeMotPos(pCon,silent,"acv",val, curve);
}
status = startTASMotor(self->math->motors[ACV],pCon, "acv",
curve,silent);
if(status != OKOK){
return status;
}
}
if(self->math->motors[ACH] != NULL){
curve = maCalcHorizontalCurvature(self->math->machine.analyzer,
angles.analyzer_two_theta);
val = getMotorValue(self->math->motors[ACH],pCon);
if(ABS(val - curve) > MOTPREC){
status = self->math->motors[ACH]->pDrivInt->SetValue(self->math->motors[ACH],
pCon,
curve);
if(status != OKOK){
return status;
}
}
writeMotPos(pCon,silent,"ach",val, curve);
}
status = startTASMotor(self->math->motors[ACH],pCon, "ach",
curve,silent);
if(status != OKOK){
return status;
}
}
}
if(driveQ == 0){
@ -347,50 +325,28 @@ static int startMotors(ptasMot self, tasAngles angles,
/*
crystal
*/
val = getMotorValue(self->math->motors[A3],pCon);
if(ABS(val - angles.a3) > MOTPREC){
status = self->math->motors[A3]->pDrivInt->SetValue(self->math->motors[A3],
pCon,
angles.a3);
if(status != OKOK){
return status;
}
status = startTASMotor(self->math->motors[A3],pCon, "a3",
angles.a3,silent);
if(status != OKOK){
return status;
}
writeMotPos(pCon,silent,"a3",val, angles.a3);
val = getMotorValue(self->math->motors[A4],pCon);
if(ABS(val - angles.sample_two_theta) > MOTPREC){
status = self->math->motors[A4]->pDrivInt->SetValue(self->math->motors[A4],
pCon,
angles.sample_two_theta);
if(status != OKOK){
return status;
}
status = startTASMotor(self->math->motors[A4],pCon, "a4",
angles.sample_two_theta,silent);
if(status != OKOK){
return status;
}
writeMotPos(pCon,silent,"a4",val, angles.sample_two_theta);
if(driveTilt == 1){
val = getMotorValue(self->math->motors[SGL],pCon);
if(ABS(val - angles.sgl) > MOTPREC){
status = self->math->motors[SGL]->pDrivInt->SetValue(self->math->motors[SGL],
pCon,
angles.sgl);
if(status != OKOK){
return status;
}
}
writeMotPos(pCon,silent,"sgl",val, angles.sgl);
val = getMotorValue(self->math->motors[SGU],pCon);
if(ABS(val - angles.sgu) > MOTPREC){
status = self->math->motors[SGU]->pDrivInt->SetValue(self->math->motors[SGU],
pCon,
angles.sgu);
if(status != OKOK){
return status;
}
}
writeMotPos(pCon,silent,"sgu",val, angles.sgu);
status = startTASMotor(self->math->motors[SGL],pCon, "sgl",
angles.sgl,silent);
if(status != OKOK){
return status;
}
status = startTASMotor(self->math->motors[SGU],pCon, "sgu",
angles.sgu,silent);
if(status != OKOK){
return status;
}
}
self->math->mustDrive = 0;
return OKOK;
@ -401,17 +357,21 @@ static int checkQMotorLimits(ptasMot self, SConnection *pCon,
int status, retVal = 1;
char error[131];
char pBueffel[256];
float val;
status = self->math->motors[A3]->pDrivInt->CheckLimits(self->math->motors[A3],
angles.a3,
error,
131);
if(status != 1) {
retVal = 0;
snprintf(pBueffel,256,"ERROR: limit violation an a3: %s", error);
SCWrite(pCon,pBueffel,eError);
MotorGetPar(self->math->motors[A3],"fixed",&val);
if((int)val != 1){
status = self->math->motors[A3]->pDrivInt->CheckLimits(self->math->motors[A3],
angles.a3,
error,
131);
if(status != 1) {
retVal = 0;
snprintf(pBueffel,256,"ERROR: limit violation an a3: %s", error);
SCWrite(pCon,pBueffel,eError);
}
}
status = self->math->motors[A4]->pDrivInt->CheckLimits(self->math->motors[A4],
angles.sample_two_theta,
error,
@ -550,117 +510,86 @@ static int startQMMotors(ptasMot self, tasAngles angles,
SConnection *pCon){
float val;
double curve;
int status;
int status, silent;
silent = self->math->silent;
/*
monochromator
*/
val = self->math->motors[A1]->pDrivInt->GetValue(self->math->motors[A1],pCon);
if(ABS(val - angles.monochromator_two_theta/2.) > MOTPREC){
status = self->math->motors[A1]->pDrivInt->SetValue(self->math->motors[A1],
pCon,
angles.monochromator_two_theta/2.);
if(status != OKOK){
return status;
}
status = startTASMotor(self->math->motors[A1],pCon, "a1",
angles.monochromator_two_theta/2.,silent);
if(status != OKOK){
return status;
}
val = self->math->motors[A2]->pDrivInt->GetValue(self->math->motors[A2],pCon);
if(ABS(val - angles.monochromator_two_theta) > MOTPREC){
status = self->math->motors[A2]->pDrivInt->SetValue(self->math->motors[A2],
pCon,
angles.monochromator_two_theta);
if(status != OKOK){
return status;
}
status = startTASMotor(self->math->motors[A2],pCon, "a2",
angles.monochromator_two_theta,silent);
if(status != OKOK){
return status;
}
if(self->math->motors[MCV] != NULL){
curve = maCalcVerticalCurvature(self->math->machine.monochromator,
angles.monochromator_two_theta);
val = self->math->motors[MCV]->pDrivInt->GetValue(self->math->motors[MCV],pCon);
if(ABS(val - curve) > MOTPREC){
status = self->math->motors[MCV]->pDrivInt->SetValue(self->math->motors[MCV],
pCon,
curve);
if(status != OKOK){
return status;
}
angles.monochromator_two_theta);
status = startTASMotor(self->math->motors[MCV],pCon, "mcv",
curve,silent);
if(status != OKOK){
return status;
}
}
if(self->math->motors[MCH] != NULL){
curve = maCalcHorizontalCurvature(self->math->machine.monochromator,
angles.monochromator_two_theta);
val = self->math->motors[MCH]->pDrivInt->GetValue(self->math->motors[MCH],pCon);
if(ABS(val - curve) > MOTPREC){
status = self->math->motors[MCH]->pDrivInt->SetValue(self->math->motors[MCH],
pCon,
curve);
if(status != OKOK){
return status;
}
angles.monochromator_two_theta);
status = startTASMotor(self->math->motors[MCH],pCon, "mch",
curve,silent);
if(status != OKOK){
return status;
}
}
/*
analyzer
*/
val = self->math->motors[A5]->pDrivInt->GetValue(self->math->motors[A5],pCon);
if(ABS(val - angles.analyzer_two_theta/2.) > MOTPREC){
status = self->math->motors[A5]->pDrivInt->SetValue(self->math->motors[A5],
pCon,
angles.analyzer_two_theta/2.);
status = startTASMotor(self->math->motors[A5],pCon, "a5",
angles.analyzer_two_theta/2.0,silent);
if(status != OKOK){
return status;
return status;
}
}
val = self->math->motors[A6]->pDrivInt->GetValue(self->math->motors[A6],pCon);
if(ABS(val - angles.analyzer_two_theta) > MOTPREC){
status = self->math->motors[A6]->pDrivInt->SetValue(self->math->motors[A6],
pCon,
angles.analyzer_two_theta);
status = startTASMotor(self->math->motors[A6],pCon, "a6",
angles.analyzer_two_theta,silent);
if(status != OKOK){
return status;
return status;
}
}
if(self->math->motors[ACV] != NULL){
curve = maCalcVerticalCurvature(self->math->machine.analyzer,
angles.analyzer_two_theta);
val = self->math->motors[ACV]->pDrivInt->GetValue(self->math->motors[ACV],pCon);
if(ABS(val - curve) > MOTPREC){
status = self->math->motors[ACV]->pDrivInt->SetValue(self->math->motors[ACV],
pCon,
curve);
if(status != OKOK){
return status;
}
if(self->math->motors[ACV] != NULL){
curve = maCalcVerticalCurvature(self->math->machine.analyzer,
angles.analyzer_two_theta);
status = startTASMotor(self->math->motors[ACV],pCon, "acv",
curve,silent);
if(status != OKOK){
return status;
}
}
}
if(self->math->motors[ACH] != NULL){
curve = maCalcHorizontalCurvature(self->math->machine.analyzer,
angles.analyzer_two_theta);
val = self->math->motors[ACH]->pDrivInt->GetValue(self->math->motors[ACH],pCon);
if(ABS(val - curve) > MOTPREC){
status = self->math->motors[ACH]->pDrivInt->SetValue(self->math->motors[ACH],
pCon,
curve);
if(status != OKOK){
return status;
}
if(self->math->motors[ACH] != NULL){
curve = maCalcHorizontalCurvature(self->math->machine.analyzer,
angles.analyzer_two_theta);
status = startTASMotor(self->math->motors[ACH],pCon, "ach",
curve,silent);
if(status != OKOK){
return status;
}
}
}
/*
crystal
*/
val = self->math->motors[A4]->pDrivInt->GetValue(self->math->motors[A4],pCon);
if(ABS(val - angles.sample_two_theta) > MOTPREC){
status = self->math->motors[A4]->pDrivInt->SetValue(self->math->motors[A4],
pCon,
angles.sample_two_theta);
if(status != OKOK){
return status;
}
status = startTASMotor(self->math->motors[A4],pCon, "a4",
angles.sample_two_theta,silent);
if(status != OKOK){
return status;
}
self->math->mustDrive = 0;
return OKOK;
}