- Added tabledrive: table driven path for MARS

- Initial MARS development
- Upgraded Manager Manual


SKIPPED:
	psi/make_gen
	psi/psi.c
	psi/tabledrive.c
	psi/tabledrive.h
	psi/tabledrive.w
	psi/utils/SerPortServer.c
This commit is contained in:
koennecke
2005-07-22 14:56:18 +00:00
parent d96fb7377d
commit 76abbe1042
39 changed files with 1822 additions and 672 deletions

136
tasub.c
View File

@ -67,6 +67,8 @@ static int tasUBSave(void *pData, char *name, FILE *fd){
saveReflections(self,name,fd);
if(self->tasMode == KICONST){
fprintf(fd,"%s const ki\n",name);
}else if(self->tasMode == ELASTIC){
fprintf(fd,"%s const elastic\n",name);
} else {
fprintf(fd,"%s const kf\n",name);
}
@ -175,11 +177,15 @@ static int readTASAngles(ptasUB self, SConnection *pCon,
/*
Analyzer
*/
status = MotorGetSoftPosition(self->motors[A6],pCon,&val);
if(status == 0){
return status;
if(self->tasMode != ELASTIC){
status = MotorGetSoftPosition(self->motors[A6],pCon,&val);
if(status == 0){
return status;
}
ang->analyzer_two_theta = val;
} else {
ang->analyzer_two_theta = ang->monochromator_two_theta;
}
ang->analyzer_two_theta = val;
/*
crystal
@ -526,7 +532,7 @@ static int addReflection(ptasUB self, SicsInterp *pSics,
SConnection *pCon,
int argc, char *argv[]){
tasReflection r;
int status;
int status, count = 11;
char pBueffel[256];
tasAngles angles;
Tcl_DString list;
@ -560,7 +566,10 @@ static int addReflection(ptasUB self, SicsInterp *pSics,
return 0;
}
if(argc >= 11){
if(self->tasMode == ELASTIC){
count = 10;
}
if(argc >= count){
status = Tcl_GetDouble(InterpGetTcl(pSics),argv[5],&r.angles.a3);
if(status != TCL_OK){
snprintf(pBueffel,255,"ERROR: failed to convert %s to number",argv[5]);
@ -591,14 +600,18 @@ static int addReflection(ptasUB self, SicsInterp *pSics,
SCWrite(pCon,pBueffel,eError);
return 0;
}
r.qe.ki = energyToK(r.qe.ki);
status = Tcl_GetDouble(InterpGetTcl(pSics),argv[10],&r.qe.kf);
if(status != TCL_OK){
snprintf(pBueffel,255,"ERROR: failed to convert %s to number",argv[10]);
SCWrite(pCon,pBueffel,eError);
return 0;
}
r.qe.kf = energyToK(r.qe.kf);
r.qe.ki = energyToK(r.qe.ki);
if(self->tasMode != ELASTIC){
status = Tcl_GetDouble(InterpGetTcl(pSics),argv[10],&r.qe.kf);
if(status != TCL_OK){
snprintf(pBueffel,255,"ERROR: failed to convert %s to number",argv[10]);
SCWrite(pCon,pBueffel,eError);
return 0;
}
r.qe.kf = energyToK(r.qe.kf);
} else {
r.qe.kf = r.qe.ki;
}
} else {
if(argc > 5){
SCWrite(pCon,
@ -612,6 +625,9 @@ static int addReflection(ptasUB self, SicsInterp *pSics,
r.qe.ki = maCalcK(self->machine.monochromator,r.angles.monochromator_two_theta);
r.qe.kf = maCalcK(self->machine.analyzer,r.angles.analyzer_two_theta);
}
if(self->tasMode == ELASTIC){
r.qe.kf = r.qe.ki;
}
if(ABS(r.qe.ki - r.qe.kf) > .01) {
SCWrite(pCon,"WARNING: KI != KF!",eWarning);
}
@ -918,10 +934,18 @@ static int calcRefAngles(ptasUB self, SConnection *pCon,
char pBueffel[256];
int status;
if(argc < 7){
SCWrite(pCon,"ERROR: need Qh, Qk, Ql, EI, EF for calculation",
eError);
return 0;
if(self->tasMode == ELASTIC){
if(argc < 6){
SCWrite(pCon,"ERROR: need Qh, Qk, Ql, EI for calculation",
eError);
return 0;
}
} else {
if(argc < 7){
SCWrite(pCon,"ERROR: need Qh, Qk, Ql, EI, EF for calculation",
eError);
return 0;
}
}
status = Tcl_GetDouble(InterpGetTcl(pSics),argv[2],&q.qh);
if(status != TCL_OK){
@ -947,12 +971,16 @@ static int calcRefAngles(ptasUB self, SConnection *pCon,
SCWrite(pCon,pBueffel,eError);
return 0;
}
status = Tcl_GetDouble(InterpGetTcl(pSics),argv[6],&q.kf);
if(status != TCL_OK){
snprintf(pBueffel,255,"ERROR: failed to convert %s to number",argv[6]);
SCWrite(pCon,pBueffel,eError);
return 0;
}
if(self->tasMode != ELASTIC){
status = Tcl_GetDouble(InterpGetTcl(pSics),argv[6],&q.kf);
if(status != TCL_OK){
snprintf(pBueffel,255,"ERROR: failed to convert %s to number",argv[6]);
SCWrite(pCon,pBueffel,eError);
return 0;
}
} else {
q.kf = q.ki;
}
q.ki = energyToK(q.ki);
q.kf = energyToK(q.kf);
@ -975,11 +1003,18 @@ static int calcRefAngles(ptasUB self, SConnection *pCon,
return 0;
break;
}
snprintf(pBueffel,255," %8.2f %8.2f %8.2f %8.2f %8.2f %8.2f",
angles.monochromator_two_theta,
angles.a3, angles.sample_two_theta,
angles.sgl, angles.sgu,
angles.analyzer_two_theta);
if(self->tasMode != ELASTIC){
snprintf(pBueffel,255," %8.2f %8.2f %8.2f %8.2f %8.2f %8.2f",
angles.monochromator_two_theta,
angles.a3, angles.sample_two_theta,
angles.sgl, angles.sgu,
angles.analyzer_two_theta);
} else {
snprintf(pBueffel,255," %8.2f %8.2f %8.2f %8.2f %8.2f",
angles.monochromator_two_theta,
angles.a3, angles.sample_two_theta,
angles.sgl, angles.sgu);
}
SCWrite(pCon,pBueffel,eValue);
return 1;
}
@ -992,10 +1027,18 @@ static int calcQFromAngles(ptasUB self, SConnection *pCon,
char pBueffel[256];
int status;
if(argc < 8){
SCWrite(pCon,"ERROR: need a2, a3, a4, sgu, sgl, a6 for calculation",
eError);
return 0;
if(self->tasMode != ELASTIC){
if(argc < 8){
SCWrite(pCon,"ERROR: need a2, a3, a4, sgu, sgl, a6 for calculation",
eError);
return 0;
}
} else {
if(argc < 7){
SCWrite(pCon,"ERROR: need a2, a3, a4, sgu, sgl for calculation",
eError);
return 0;
}
}
status = Tcl_GetDouble(InterpGetTcl(pSics),argv[2],
&angles.monochromator_two_theta);
@ -1028,11 +1071,15 @@ static int calcQFromAngles(ptasUB self, SConnection *pCon,
SCWrite(pCon,pBueffel,eError);
return 0;
}
status = Tcl_GetDouble(InterpGetTcl(pSics),argv[7],&angles.analyzer_two_theta);
if(status != TCL_OK){
snprintf(pBueffel,255,"ERROR: failed to convert %s to number",argv[7]);
SCWrite(pCon,pBueffel,eError);
return 0;
if(self->tasMode != ELASTIC){
status = Tcl_GetDouble(InterpGetTcl(pSics),argv[7],&angles.analyzer_two_theta);
if(status != TCL_OK){
snprintf(pBueffel,255,"ERROR: failed to convert %s to number",argv[7]);
SCWrite(pCon,pBueffel,eError);
return 0;
}
} else {
angles.analyzer_two_theta = angles.monochromator_two_theta;
}
status = calcTasQEPosition(&self->machine,angles,&q);
switch(status){
@ -1042,6 +1089,9 @@ static int calcQFromAngles(ptasUB self, SConnection *pCon,
break;
}
if(self->tasMode == ELASTIC){
q.kf = q.ki;
}
snprintf(pBueffel,255,"%8.4f %8.4f %8.4f %8.4f %8.4f",
q.qh,
q.qk,
@ -1265,6 +1315,9 @@ static int tasUpdate(SConnection *pCon, ptasUB self){
SCWrite(pCon,"ERROR: out of memory calculating Q-E variables",eError);
return 0;
}
if(self->tasMode == ELASTIC){
self->current.kf = self->current.ki;
}
self->mustRecalculate = 0;
SCSendOK(pCon);
return 1;
@ -1369,8 +1422,11 @@ int TasUBWrapper(SConnection *pCon,SicsInterp *pSics, void *pData,
self->tasMode = KICONST;
} else if(strcmp(argv[2],"kf") == 0){
self->tasMode = KFCONST;
} else if(strcmp(argv[2],"elastic") == 0){
self->tasMode = ELASTIC;
} else {
SCWrite(pCon,"ERROR: unknown triple axis mode, accepted are ki, kf",
SCWrite(pCon,
"ERROR: unknown triple axis mode, accepted are ki, kf, elastic",
eError);
return 0;
}
@ -1379,6 +1435,8 @@ int TasUBWrapper(SConnection *pCon,SicsInterp *pSics, void *pData,
} else {
if(self->tasMode == KICONST){
snprintf(pBueffel,131,"%s.const = ki",argv[0]);
} else if(self->tasMode == ELASTIC){
snprintf(pBueffel,131,"%s.const = elastic", argv[0]);
} else {
snprintf(pBueffel,131,"%s.const = kf",argv[0]);
}