- Added scan support to new TAS syntax
- First full version of new TAS
This commit is contained in:
88
tasub.c
88
tasub.c
@ -83,6 +83,8 @@ static int tasUBSave(void *pData, char *name, FILE *fd){
|
||||
name,
|
||||
self->target.qh, self->target.qk, self->target.ql, self->target.qm,
|
||||
self->target.ki, self->target.kf);
|
||||
fprintf(fd,"%s setidx %d %d\n",
|
||||
name, self->r1, self->r2);
|
||||
fprintf(fd,"%s update\n", name);
|
||||
return 1;
|
||||
}
|
||||
@ -475,6 +477,8 @@ static void clearReflections(ptasUB self){
|
||||
LLDnodeDelete(self->reflectionList);
|
||||
status = LLDnodePtr2Next(self->reflectionList);
|
||||
}
|
||||
self->r1 = -1;
|
||||
self->r2 = -1;
|
||||
}
|
||||
/*------------------------------------------------------------------*/
|
||||
static void listReflections(ptasUB self, SConnection *pCon){
|
||||
@ -612,7 +616,7 @@ static int addReflection(ptasUB self, SicsInterp *pSics,
|
||||
return 1;
|
||||
}
|
||||
/*-----------------------------------------------------------------*/
|
||||
static int findReflection(int list, int idx, ptasReflection r){
|
||||
int findReflection(int list, int idx, ptasReflection r){
|
||||
int count = 0;
|
||||
int status;
|
||||
|
||||
@ -628,26 +632,29 @@ static int findReflection(int list, int idx, ptasReflection r){
|
||||
return 0;
|
||||
}
|
||||
/*------------------------------------------------------------------*/
|
||||
static void listUB(MATRIX UB, SConnection *pCon){
|
||||
static void listUB(ptasUB self , SConnection *pCon){
|
||||
Tcl_DString list;
|
||||
char pBueffel[255];
|
||||
int i;
|
||||
|
||||
|
||||
Tcl_DStringInit(&list);
|
||||
if(UB == NULL){
|
||||
if(self->machine.UB == NULL){
|
||||
Tcl_DStringAppend(&list,"NO UB",-1);
|
||||
} else {
|
||||
} else {
|
||||
Tcl_DStringAppend(&list,"UB = ", -1);
|
||||
snprintf(pBueffel,255,"%f %f %f\n", UB[0][0],
|
||||
UB[0][1],UB[0][2]);
|
||||
snprintf(pBueffel,255,"%f %f %f\n", self->machine.UB[0][0],
|
||||
self->machine.UB[0][1],self->machine.UB[0][2]);
|
||||
Tcl_DStringAppend(&list,pBueffel,-1);
|
||||
for(i = 1; i < 3; i++){
|
||||
snprintf(pBueffel,255," %f %f %f\n", UB[i][0],
|
||||
UB[i][1],UB[i][2]);
|
||||
snprintf(pBueffel,255," %f %f %f\n", self->machine.UB[i][0],
|
||||
self->machine.UB[i][1],self->machine.UB[i][2]);
|
||||
Tcl_DStringAppend(&list,pBueffel,-1);
|
||||
}
|
||||
}
|
||||
snprintf(pBueffel,255,"UB generated from reflections %d and %d in list\n",
|
||||
self->r1, self->r2);
|
||||
Tcl_DStringAppend(&list,pBueffel,-1);
|
||||
SCWrite(pCon,Tcl_DStringValue(&list),eValue);
|
||||
Tcl_DStringFree(&list);
|
||||
}
|
||||
@ -691,7 +698,7 @@ static void printReflectionDiagnostik(ptasUB self, SConnection *pCon,
|
||||
qe.qh, qe.qk, qe.ql, angles.a3, angles.sample_two_theta,
|
||||
angles.sgu, angles.sgl, qe.ki, qe.kf);
|
||||
Tcl_DStringAppend(&list,line,-1);
|
||||
SCWrite(pCon,Tcl_DStringValue(&list),eValue);
|
||||
SCWrite(pCon,Tcl_DStringValue(&list),eWarning);
|
||||
Tcl_DStringFree(&list);
|
||||
}
|
||||
/*------------------------------------------------------------------*/
|
||||
@ -737,6 +744,7 @@ static int calcUB(ptasUB self, SConnection *pCon, SicsInterp *pSics,
|
||||
SCWrite(pCon,pBueffel,eError);
|
||||
return 0;
|
||||
}
|
||||
self->r1 = idx;
|
||||
status = Tcl_GetInt(InterpGetTcl(pSics),argv[3],&idx);
|
||||
if(status != TCL_OK){
|
||||
snprintf(pBueffel,255,"ERROR: failed to convert %s to number",argv[3]);
|
||||
@ -749,6 +757,7 @@ static int calcUB(ptasUB self, SConnection *pCon, SicsInterp *pSics,
|
||||
SCWrite(pCon,pBueffel,eError);
|
||||
return 0;
|
||||
}
|
||||
self->r2 = idx;
|
||||
|
||||
UB = calcTasUBFromTwoReflections(self->cell,r1,r2,&status);
|
||||
if(UB == NULL){
|
||||
@ -770,7 +779,7 @@ static int calcUB(ptasUB self, SConnection *pCon, SicsInterp *pSics,
|
||||
}
|
||||
self->machine.UB = UB;
|
||||
self->machine.planeNormal = calcPlaneNormal(r1,r2);
|
||||
listUB(UB,pCon);
|
||||
listUB(self,pCon);
|
||||
listDiagnostik(self,pCon);
|
||||
SCparChange(pCon);
|
||||
return 1;
|
||||
@ -943,6 +952,22 @@ static int setUB(SConnection *pCon, SicsInterp *pSics, ptasUB self,
|
||||
return 1;
|
||||
}
|
||||
/*------------------------------------------------------------------*/
|
||||
static int setIDX(SConnection *pCon, SicsInterp *pSics, ptasUB self,
|
||||
int argc, char *argv[]){
|
||||
if(argc < 4) {
|
||||
SCWrite(pCon,"ERROR: not enough arguments to setidx", eError);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(!SCMatchRights(pCon,usMugger)){
|
||||
return 0;
|
||||
}
|
||||
self->r1 = atoi(argv[2]);
|
||||
self->r2 = atoi(argv[3]);
|
||||
SCSendOK(pCon);
|
||||
return 1;
|
||||
}
|
||||
/*------------------------------------------------------------------*/
|
||||
static int setNormal(SConnection *pCon, SicsInterp *pSics, ptasUB self,
|
||||
int argc, char *argv[]){
|
||||
double value;
|
||||
@ -1066,6 +1091,40 @@ static int tasUpdate(SConnection *pCon, ptasUB self){
|
||||
SCSendOK(pCon);
|
||||
return 1;
|
||||
}
|
||||
/*------------------------------------------------------------------*/
|
||||
static int deleteReflection(SConnection *pCon, SicsInterp *pSics,
|
||||
ptasUB self, int argc, char *argv[]){
|
||||
int idx, count = 0, status;
|
||||
char pBueffel[256];
|
||||
|
||||
if(argc < 3){
|
||||
SCWrite(pCon,"ERROR: need number of reflection to delete",eError);
|
||||
return 0;
|
||||
}
|
||||
status = Tcl_GetInt(InterpGetTcl(pSics),argv[2],&idx);
|
||||
if(status != TCL_OK){
|
||||
snprintf(pBueffel,255,"ERROR: failed to convert %s to number",argv[2]);
|
||||
SCWrite(pCon,pBueffel,eError);
|
||||
return 0;
|
||||
}
|
||||
if(idx == self->r1 || idx == self->r2) {
|
||||
SCWrite(pCon,"ERROR: I refuse to delete reflections used for current UB",
|
||||
eError);
|
||||
return 0;
|
||||
}
|
||||
idx--;
|
||||
status = LLDnodePtr2First(self->reflectionList);
|
||||
while(status == 1){
|
||||
if(count == idx){
|
||||
LLDnodeDelete(self->reflectionList);
|
||||
break;
|
||||
}
|
||||
status = LLDnodePtr2Next(self->reflectionList);
|
||||
count++;
|
||||
}
|
||||
SCSendOK(pCon);
|
||||
return 1;
|
||||
}
|
||||
/*-------------------------------------------------------------------*/
|
||||
int TasUBWrapper(SConnection *pCon,SicsInterp *pSics, void *pData,
|
||||
int argc, char *argv[]){
|
||||
@ -1104,7 +1163,7 @@ int TasUBWrapper(SConnection *pCon,SicsInterp *pSics, void *pData,
|
||||
} else if(strcmp(argv[1],"addref") == 0){
|
||||
return addReflection(self,pSics,pCon,argc,argv);
|
||||
} else if(strcmp(argv[1],"listub") == 0){
|
||||
listUB(self->machine.UB,pCon);
|
||||
listUB(self,pCon);
|
||||
return 1;
|
||||
} else if(strcmp(argv[1],"makeub") == 0){
|
||||
return calcUB(self,pCon,pSics,argc,argv);
|
||||
@ -1114,10 +1173,14 @@ int TasUBWrapper(SConnection *pCon,SicsInterp *pSics, void *pData,
|
||||
return setUB(pCon,pSics,self,argc,argv);
|
||||
} else if(strcmp(argv[1],"setnormal") == 0){
|
||||
return setNormal(pCon,pSics,self,argc,argv);
|
||||
} else if(strcmp(argv[1],"setidx") == 0){
|
||||
return setIDX(pCon,pSics,self,argc,argv);
|
||||
} else if(strcmp(argv[1],"settarget") == 0){
|
||||
return setTarget(pCon,pSics,self,argc,argv);
|
||||
} else if(strcmp(argv[1],"update") == 0){
|
||||
return tasUpdate(pCon,self);
|
||||
} else if(strcmp(argv[1],"del") == 0){
|
||||
return deleteReflection(pCon,pSics,self,argc,argv);
|
||||
} else if(strcmp(argv[1],"const") == 0){
|
||||
if(argc > 2){
|
||||
strtolower(argv[2]);
|
||||
@ -1129,7 +1192,8 @@ int TasUBWrapper(SConnection *pCon,SicsInterp *pSics, void *pData,
|
||||
} else if(strcmp(argv[2],"kf") == 0){
|
||||
self->tasMode = KFCONST;
|
||||
} else {
|
||||
SCWrite(pCon,"ERROR: unknown triple axis mode, accepted are ki, kf",eError);
|
||||
SCWrite(pCon,"ERROR: unknown triple axis mode, accepted are ki, kf",
|
||||
eError);
|
||||
return 0;
|
||||
}
|
||||
SCSendOK(pCon);
|
||||
|
Reference in New Issue
Block a user