- Added scan support to new TAS syntax

- First full version of new TAS
This commit is contained in:
koennecke
2005-05-18 13:47:46 +00:00
parent 6145b513f8
commit 46492ca9bd
8 changed files with 1265 additions and 18 deletions

View File

@ -6,7 +6,7 @@
Mark Koennecke, November 1996
Made ListObjects moe intelligent: list objects according to interface etc.
Made ListObjects more intelligent: list objects according to interface etc.
Mark Koennecke, December 2003
Copyright:
@ -585,12 +585,14 @@ static void printMatch(SicsInterp *pSics, SConnection *pCon, char *mask)
static void printType(SicsInterp *pSics, SConnection *pCon, char *type)
{
CommandList *pCurrent;
Tcl_DString txt;
char pBueffel[256];
int iNum = 0;
assert(pSics);
assert(pCon);
Tcl_DStringInit(&txt);
pBueffel[0] = '\0';
pCurrent = pSics->pCList;
while(pCurrent)
@ -615,7 +617,7 @@ static void printType(SicsInterp *pSics, SConnection *pCon, char *type)
strcat(pBueffel," ");
strcat(pBueffel,pCurrent->pName);
strcat(pBueffel,"\r\n");
SCWrite(pCon,pBueffel,eStatus);
Tcl_DStringAppend(&txt,pBueffel,-1);
pBueffel[0]='\0';
iNum = 0;
}
@ -626,9 +628,9 @@ static void printType(SicsInterp *pSics, SConnection *pCon, char *type)
/* write final entries */
strcat(pBueffel,"\r\n");
SCWrite(pCon,pBueffel,eStatus);
SCWrite(pCon,Tcl_DStringValue(&txt),eStatus);
Tcl_DStringFree(&txt);
}
/*--------------------------------------------------------------------------*/
int ListObjects(SConnection *pCon, SicsInterp *pSics, void *pData,
int argc, char *argv[])

View File

@ -25,7 +25,7 @@ SOBJ = network.o ifile.o conman.o SCinter.o splitter.o passwd.o \
circular.o maximize.o sicscron.o scanvar.o tasublib.o\
d_sign.o d_mod.o tcldrivable.o stdscan.o diffscan.o\
synchronize.o definealias.o oscillate.o tasdrive.o \
hmcontrol.o userscan.o rs232controller.o lomax.o \
hmcontrol.o userscan.o rs232controller.o lomax.o tasscanub.o \
fourlib.o motreg.o motreglist.o anticollider.o \
s_rnge.o sig_die.o gpibcontroller.o $(NIOBJ) \
hmdata.o nxscript.o tclintimpl.o sicsdata.o

4
ofac.c
View File

@ -111,6 +111,7 @@
#include "hklmot.h"
#include "ubcalc.h"
#include "tasub.h"
#include "tasscanub.h"
/*----------------------- Server options creation -------------------------*/
static int IFServerOption(SConnection *pCon, SicsInterp *pSics, void *pData,
int argc, char *argv[])
@ -300,6 +301,8 @@
MakeUBCalc,NULL,NULL);
AddCommand(pInter,"MakeTasUB",
TasUBFactory,NULL,NULL);
AddCommand(pInter,"MakeTasScan",
TASUBScanFactory,NULL,NULL);
/*
@ -364,6 +367,7 @@
RemoveCommand(pSics,"MakeHKLMot");
RemoveCommand(pSics,"MakeUBCalc");
RemoveCommand(pSics,"MakeTasUB");
RemoveCommand(pSics,"MakeTasScan");
/*
remove site specific installation commands

1135
tasscanub.c Normal file

File diff suppressed because it is too large Load Diff

36
tasscanub.h Normal file
View File

@ -0,0 +1,36 @@
/*----------------------------------------------------------------------
This is the header file for the TAS scan code. It mainly implements
writing of the ILL file format, which the TAS'lers adore.
Mark Koennecke, May 2005, using code from an earlier TASAMAD emulation
core.
------------------------------------------------------------------------*/
#ifndef SICUBSTAS
#define SICSUBTAS
#include <sicsvar.h>
#include "tasub.h"
/* --------------------- data structure -------------------------------*/
#define MAXADD 20
typedef struct {
pObjectDescriptor pDes;
pCounter counter;
pScanData pScan;
ptasUB ub;
int iPOL;
int iIgnore; /* in order to ignore writing scan points again
in polarisation mode;
*/
char out[MAXADD][10];
int addCount;
int iFileNO;
int iFast;
char scanVar[80];
}TASdata, *pTASdata;
/*---------------------- interface ----------------------------------*/
int TASUBScanFactory(SConnection *pCon, SicsInterp *pSics, void *pData,
int argc, char *argv[]);
int TASUBScan(SConnection *pCon, SicsInterp *pSics, void *pData,
int argc, char *argv[]);
#endif

86
tasub.c
View File

@ -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 {
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);

View File

@ -27,6 +27,7 @@
int mustRecalculate;
int mustDrive;
pMotor motors[12];
int r1, r2;
}tasUB, *ptasUB;
@ -46,4 +47,5 @@ int TasUBWrapper(SConnection *pCon,SicsInterp *pSics, void *pData,
int argc, char *argv[]);
int findReflection(int list, int idx, ptasReflection r);
#endif

View File

@ -29,6 +29,7 @@ A data structure:
int mustRecalculate;
int mustDrive;
pMotor motors[12];
int r1, r2;
}tasUB, *ptasUB;
@}
\begin{description}
@ -49,6 +50,8 @@ A data structure:
\item[motors] The TAS motors: A1, A2, MCV (vertical curvature), MCH (horizontal curvature),
A3, A4, SGU, SGL, A5, A6, ACV, ACH. The curvature motors may be NULL at
runtime.
\item[r1,r2] The indexs of the reflections used for calculating the orientation
matrix.
\end{description}
For the virtual motors, there must be a data structure, too:
@ -97,6 +100,7 @@ int TasUBWrapper(SConnection *pCon,SicsInterp *pSics, void *pData,
@<tasubmotdat@>
/*--------------------------------------------------------------------*/
@<tasubint@>
int findReflection(int list, int idx, ptasReflection r);
#endif
@}
@o tasdrive.h @{