- Added an edge function to peakcenter for NARZISS

- Fixed ei interrupt bug in tasdrive.c
- Made eiger A2 driving work
- Added force start facility to devexec for POLDI HV


SKIPPED:
	psi/eigera2.c
	psi/polterwrite.c
This commit is contained in:
koennecke
2011-12-19 12:24:58 +00:00
parent a207ebf46d
commit 14f257c2ab
14 changed files with 361 additions and 43 deletions

View File

@ -72,8 +72,10 @@ static int readTASMotAngles(ptasUB self, SConnection * pCon,
}
ang->monochromator_two_theta = val;
if (ABS(val / 2. - theta) > .1) {
SCWrite(pCon, "WARNING: theta monochromator not half of two theta",
eWarning);
if(DevExecLevelRunning(pServ->pExecutor,RUNRUN) != 1) {
SCWrite(pCon, "WARNING: theta monochromator not half of two theta",
eWarning);
}
}
/*
@ -90,7 +92,7 @@ static int readTASMotAngles(ptasUB self, SConnection * pCon,
return status;
}
ang->analyzer_two_theta = val;
if (ABS(val / 2. - theta) > .1) {
if (ABS(val / 2. - theta) > .1 && DevExecLevelRunning(pServ->pExecutor,RUNRUN) != 1) {
SCWrite(pCon, "WARNING: theta analyzer not half of two theta",
eWarning);
}
@ -236,7 +238,7 @@ static void writeMotPos(SConnection * pCon, int silent, char *name,
if (silent != 1) {
snprintf(pBueffel, 131, "Driving %5s from %8.3f to %8.3f",
name, val, target);
SCWrite(pCon, pBueffel, eWarning);
SCWrite(pCon, pBueffel, eLog);
}
}
@ -258,6 +260,7 @@ static int startTASMotor(pMotor mot, SConnection * pCon, char *name,
char buffer[132];
pIDrivable pDriv = NULL;
pDummy dum = NULL;
pDynString mes = NULL;
dum = (pDummy)mot;
if(strcmp(dum->pDescriptor->name,"Motor") == 0){
@ -272,8 +275,11 @@ static int startTASMotor(pMotor mot, SConnection * pCon, char *name,
mot->stopped = 0;
if (ABS(val - target) > MOTPREC) {
pDriv = GetDrivableInterface(mot);
SCStartBuffering(pCon);
status = pDriv->SetValue(mot, pCon, (float) target);
mes = SCEndBuffering(pCon);
if (status != OKOK) {
SCPrintf(pCon,eLogError, GetCharArray(mes));
return status;
}
}
@ -310,7 +316,8 @@ static int startMotors(ptasMot self, tasAngles angles,
status = startTASMotor(self->math->motors[MCV], pCon, "mcv",
curve, silent);
if (status != OKOK) {
return status;
SCWrite(pCon,"WARNING: monochromator vertical curvature motor failed to start", eWarning);
SCSetInterrupt(pCon,eContinue);
}
}
@ -319,8 +326,9 @@ static int startMotors(ptasMot self, tasAngles angles,
angles.monochromator_two_theta);
status = startTASMotor(self->math->motors[MCH], pCon, "mch",
curve, silent);
if (status != OKOK) {
return status;
if (status != OKOK) {
SCWrite(pCon,"WARNING: monochromator horizontal curvature motor failed to start", eWarning);
SCSetInterrupt(pCon,eContinue);
}
}
@ -346,7 +354,8 @@ static int startMotors(ptasMot self, tasAngles angles,
status = startTASMotor(self->math->motors[ACV], pCon, "acv",
curve, silent);
if (status != OKOK) {
return status;
SCWrite(pCon,"WARNING: analyzer vertical curvature motor failed to start", eWarning);
SCSetInterrupt(pCon,eContinue);
}
}
if (self->math->motors[ACH] != NULL) {
@ -355,7 +364,8 @@ static int startMotors(ptasMot self, tasAngles angles,
status = startTASMotor(self->math->motors[ACH], pCon, "ach",
curve, silent);
if (status != OKOK) {
return status;
SCWrite(pCon,"WARNING: analyzer horizontal curvature motor failed to start", eWarning);
SCSetInterrupt(pCon,eContinue);
}
}
}
@ -450,7 +460,6 @@ static int checkQMotorLimits(ptasMot self, SConnection * pCon,
}
return retVal;
}
/*-----------------------------------------------------------------------------*/
static int calculateAndDrive(ptasMot self, SConnection * pCon)
{
@ -461,31 +470,33 @@ static int calculateAndDrive(ptasMot self, SConnection * pCon)
if (self->math->ubValid == 0) {
SCWrite(pCon, "WARNING: UB matrix invalid", eWarning);
}
status = calcAllTasAngles(&self->math->machine, self->math->target,
&angles);
self->math->mustDrive = 0;
switch (status) {
case ENERGYTOBIG:
SCWrite(pCon, "ERROR: desired energy to big", eError);
return HWFault;
break;
SCWrite(pCon, "ERROR: desired energy to big", eError);
return HWFault;
break;
case UBNOMEMORY:
SCWrite(pCon, "ERROR: out of memory calculating angles", eError);
driveQ = 0;
break;
SCWrite(pCon, "ERROR: out of memory calculating angles", eError);
driveQ = 0;
break;
case BADRMATRIX:
SCWrite(pCon, "ERROR: bad crystallographic parameters or bad UB",
eError);
driveQ = 0;
break;
SCWrite(pCon, "ERROR: bad crystallographic parameters or bad UB",
eError);
driveQ = 0;
break;
case BADUBORQ:
SCWrite(pCon, "ERROR: bad UB matrix or bad Q-vector", eError);
driveQ = 0;
break;
SCWrite(pCon, "ERROR: bad UB matrix or bad Q-vector", eError);
driveQ = 0;
break;
case TRIANGLENOTCLOSED:
SCWrite(pCon, "ERROR: cannot close scattering triangle", eError);
driveQ = 0;
break;
SCWrite(pCon, "ERROR: cannot close scattering triangle", eError);
driveQ = 0;
break;
}
/**
* check out of plane condition and permission
@ -523,8 +534,8 @@ static int calculateAndDrive(ptasMot self, SConnection * pCon)
/*-----------------------------------------------------------------------------*/
static int checkMotors(ptasMot self, SConnection * pCon)
{
int i, status, length = 12;
int mask[12];
int i, status, length = 12, count;
int mask[12], busy[12];
pIDrivable pDrivInt = NULL;
self->math->mustRecalculate = 1;
@ -532,8 +543,10 @@ static int checkMotors(ptasMot self, SConnection * pCon)
length = 8;
}
memset(mask, 0, 12 * sizeof(int));
memset(busy, 0, 12 * sizeof(int));
for (i = 0; i < length; i++) {
mask[i] = 1;
busy[i] = 1;
}
if (self->math->outOfPlaneAllowed == 0) {
mask[SGU] = 0;
@ -541,15 +554,26 @@ static int checkMotors(ptasMot self, SConnection * pCon)
}
for (i = 0; i < 12; i++) {
if (self->math->motors[i] != NULL && mask[i] != 0) {
pDrivInt = GetDrivableInterface(self->math->motors[i]);
status = pDrivInt->CheckStatus(self->math->motors[i], pCon);
if (status != HWIdle && status != OKOK) {
return status;
}
if(self->math->motors[i] == NULL){
busy[i] = 0;
} else {
if(mask[i] != 0) {
pDrivInt = GetDrivableInterface(self->math->motors[i]);
status = pDrivInt->CheckStatus(self->math->motors[i], pCon);
if(status == HWIdle || status == OKOK || status == HWFault || status == HWPosFault){
busy[i] = 0;
}
}
}
}
return HWIdle;
for(i = 0, count = 0; i < 12; i++){
count += busy[i];
}
if(count == 0) {
return HWIdle;
} else {
return HWBusy;
}
}
/*------------------------------------------------------------------------------*/