From bde19bb973846d18c88bd4f187188ea4d3f0a977 Mon Sep 17 00:00:00 2001 From: cvs Date: Fri, 19 Jul 2002 15:09:21 +0000 Subject: [PATCH] - Fixes to HM code for AMOR TOF - A couple of TAS fixes - o2t was fixed to work with any drivable - FOCUS was mended to include beam monitor in data file --- Makefile | 3 +- amorstat.c | 95 ++++++++++++++++-- amortest.tcl | 15 +-- counter.c | 2 +- danu.dat | 2 +- focus.dic | 4 +- fowrite.c | 2 + histmem.c | 3 +- hkl.c | 93 +++++++++++++++--- hkl.i | 1 + hkl.tex | 3 + hkl.w | 3 + macro.c | 16 ++- motor.c | 4 +- network.c | 4 + nserver.c | 12 ++- nxamor.c | 35 ++++++- nxdata.c | 48 ++++----- o2t.c | 24 +++-- sicsstatus.tcl | 186 +++++++++++++++-------------------- sinqhm/FOCUS_srv_main.c | 30 +++--- sinqhm/SinqHM_srv_filler.c | 15 ++- sinqhm/SinqHM_srv_main.c | 2 +- sinqhm/SinqHM_srv_routines.c | 6 +- sinqhm/bld | 1 + sinqhmdriv.c | 30 ++++-- status.c | 36 ++++++- status.h | 13 ++- synchronize.c | 23 ++++- tascom.tcl | 23 +++-- tasdrive.c | 2 +- tasscan.c | 42 +++++--- tasu.h | 2 +- tasutil.c | 32 ++++-- tcl/scancom.tcl | 4 +- tecs/tecs.c | 15 ++- test.tcl | 20 ++++ token.h | 2 +- 38 files changed, 604 insertions(+), 249 deletions(-) diff --git a/Makefile b/Makefile index ce812bc2..a66eda37 100644 --- a/Makefile +++ b/Makefile @@ -72,7 +72,8 @@ CFLAGS = -I$(HDFROOT)/include -Ihardsup -DHDF4 -DHDF5 -I. -std1 \ # -std1 -warnprotos -c LIBS = -L$(HDFROOT)/lib -Lhardsup -lhlib -Lmatrix -lmatrix -Ltecs \ -ltecsl -ltcl8.0 -lfor $(HDFROOT)/lib/libhdf5.a \ - -lmfhdf -ldf $(HDFROOT)/lib/libjpeg.a -lz -lm -ll -lc + $(HDFROOT)/lib/libmfhdf.a $(HDFROOT)/lib/libdf.a \ + $(HDFROOT)/lib/libjpeg.a -lz -lm -ll -lc #------- for cygnus #HDFROOT=../HDF411 diff --git a/amorstat.c b/amorstat.c index daa504f3..139a45ea 100644 --- a/amorstat.c +++ b/amorstat.c @@ -61,7 +61,7 @@ iTime[0] = htonl(iLength); for(i = 0 ; i < iLength; i++) { - iTime[i+1] = htonl((int)(fTime[i]*65536.)); + iTime[i+1] = htonl((int)((fTime[i]/10.)*65536.)); } /* send new time binning to all clients */ SCWrite(pCon,"TOFClear",eError); @@ -499,6 +499,7 @@ int *iImage = NULL, *iPtr; pSINQHM pHist; SinqHMDriv *pTata; + int iMax = -999999; /* get size of our problem */ GetHistDim(self->pHM,iDim,&i3); @@ -537,8 +538,16 @@ */ for(i = 2; i < length; i++) { + /* + if(iImage[i] > iMax){ + iMax = iImage[i]; + } + */ iImage[i] = htonl(iImage[i]); } + /* + printf("Collpased maximum: %d\n",iMax); + */ if(status != 1) { SCWrite(pCon,"ERROR: histogram memory refused to Collapse",eError); @@ -562,10 +571,74 @@ /* send image */ SCWriteUUencoded(pCon,"arrow_image",iImage, - (iDim[0]*iDim[1]+2)*sizeof(int)); + ((iDim[0]*iDim[1])+2)*sizeof(int)); free(iImage); return 1; } +/*----------------------------------------------------------------- + SendSingleTOF sends single detector data for TOF mode +*/ + + static int SendSingleTOF(pAmorStat self, SConnection *pCon) + { + HistInt *lData = NULL; + int i, i2, i3, iDim[MAXDIM], iIdx, iSum, status, length; + pSINQHM pHist; + SinqHMDriv *pTata; + int iMax = -999999; + const float *timebin; + HistInt *iData = NULL; + + /* get size of our problem */ + GetHistDim(self->pHM,iDim,&i3); + assert(i3 == 3); + + /* allocate some data */ + timebin = GetHistTimeBin(self->pHM, &i3); + length = 1 + 2*i3; + iData = (HistInt *)malloc(length*sizeof(HistInt)); + if(iData == NULL){ + SCWrite(pCon,"ERROR: failed to allocate memory in SendSingleTOF", + eError); + return 0; + } + memset(iData,0,length*sizeof(int)); + + /* first number is the length of each single histogram */ + iData[0] = htonl(i3); + + + if(isSINQHMDriv(self->pHM->pDriv)) + { + GetHistogramDirect(self->pHM,pCon,0,iDim[0]*iDim[1]*iDim[2], + 2*iDim[2],&iData[1],2*iDim[2]*sizeof(HistInt)); + for(i = 1; i < length; i++) + { + iData[i] = htonl(iData[i]); + } + } + else + { + /* + we are in simulation and just create some random numbers + */ + for(i = 1; i < length; i++) + { + iData[i] = htonl(random()); + } + } + + /* + send, with a little trick to do two histograms. + */ + SCWriteUUencoded(pCon,"SING1",iData, + (iDim[2]+1)*sizeof(int)); + iData[iDim[2]] = htonl(iDim[2]); + SCWriteUUencoded(pCon,"SING2",&iData[iDim[2]], + (iDim[2]+1)*sizeof(int)); + free(iData); + return 1; + } /*------------------------------------------------------------------- SubSample sums histogram data in the area defined by the rectangle x1,y1 x2, y2. Summing is along the time axis. @@ -585,10 +658,16 @@ assert(i3 == 3); /* check limits */ - if(x2 < x1) - x2 = x1 + 1; - if(y2 < y1) - y2 = y1 + 1; + if(x2 < x1){ + i = x1; + x1 = x2; + x2 = i +1; + } + if(y2 < y1){ + i = y1; + y1 = y2; + y2 = i + 1; + } iLimit = 0; if( x1 > iDim[0]) @@ -797,6 +876,10 @@ SCSendOK(pCon); return iRet; } + else if(strcmp(argv[1],"singletof") == 0) + { + return SendSingleTOF(self,pCon); + } else if(strcmp(argv[1],"sendloaded") == 0) { SendLoadedData(self,pCon); diff --git a/amortest.tcl b/amortest.tcl index 5baa2ad4..600c3b0e 100644 --- a/amortest.tcl +++ b/amortest.tcl @@ -1,3 +1,4 @@ +# # -------------------------------------------------------------------------- # Initialization script for a simulated AMOR instrument # @@ -187,16 +188,16 @@ ClientPut "Motors initialized" #======================== histogram memory #MakeHM hm SinqHM MakeHM hm SIM -hm configure HistMode PSD hm configure OverFlowMode Ceil +hm configure HistMode PSD hm configure Rank 1 hm configure dim0 256 -hm configure dim1 128 -hm configure xfac 16 -hm configure yfac 16 +hm configure dim1 256 +hm configure xfac 10 +hm configure yfac 10 hm configure xoff 128 -hm configure yoff 64 -hm configure Length 32768 +hm configure yoff 128 +hm configure Length 65536 hm configure BinWidth 4 hm preset 100. hm CountMode Timer @@ -204,7 +205,7 @@ hm configure HMComputer psds03.psi.ch hm configure HMPort 2400 hm configure Counter counter hm configure init 0 -hm genbin 0. 33 512 +hm genbin 0. 33 5 hm init ClientPut "Histogram Memory Initialized" diff --git a/counter.c b/counter.c index 6486551e..24f8ed9e 100644 --- a/counter.c +++ b/counter.c @@ -273,7 +273,7 @@ } else { - sprintf(pBueffel,"%s SetMode Preset\n",name); + sprintf(pBueffel,"%s SetMode Monitor\n",name); } fputs(pBueffel,fd); diff --git a/danu.dat b/danu.dat index 72983f35..f126a7a8 100644 --- a/danu.dat +++ b/danu.dat @@ -1,3 +1,3 @@ - 212 + 226 NEVER, EVER modify or delete this file You'll risk eternal damnation and a reincarnation as a cockroach!|n \ No newline at end of file diff --git a/focus.dic b/focus.dic index 89e44651..e6c4d254 100644 --- a/focus.dic +++ b/focus.dic @@ -73,6 +73,8 @@ cnmon1=/entry1,NXentry/FOCUS,NXinstrument/counter,NXmonitor/SDS monitor \ -type DFNT_INT32 -attr {units,counts} cnmon2=/entry1,NXentry/FOCUS,NXinstrument/counter,NXmonitor/SDS beam_monitor \ -type DFNT_INT32 -attr {units,counts} +cnmon3=/entry1,NXentry/FOCUS,NXinstrument/counter,NXmonitor/SDS proton_beam_monitor \ + -type DFNT_INT32 -attr {units,counts} #-------------- detector bank dname=/entry1,NXentry/FOCUS,NXinstrument/$(bank),NXdetector/SDS type \ -type DFNT_CHAR -rank 1 -dim {132} @@ -81,7 +83,7 @@ dtheta=/entry1,NXentry/FOCUS,NXinstrument/$(bank),NXdetector/SDS theta \ dtime=/entry1,NXentry/FOCUS,NXinstrument/$(bank),NXdetector/SDS time_binning \ -rank 1 -dim {$(timebin)} -attr {axis,2} -attr {units,us} dcounts=/entry1,NXentry/FOCUS,NXinstrument/$(bank),NXdetector/SDS counts \ - -type DFNT_INT32 -rank 2 -LZW -dim {$(noofdetectors),$(timebin)} \ + -type DFNT_INT32 -LZW -rank 2 -dim {$(noofdetectors),$(timebin)} \ -attr {signal,1} dsums=/entry1,NXentry/FOCUS,NXinstrument/$(bank),NXdetector/SDS summed_counts \ -rank 1 -dim {$(noofdetectors)} -type DFNT_INT32 diff --git a/fowrite.c b/fowrite.c index 79cda84e..aa591415 100644 --- a/fowrite.c +++ b/fowrite.c @@ -423,6 +423,8 @@ NXDputalias(pFile,pDict,"cnmon1",&lVal); lVal = GetHistMonitor(self->pHist,0,pCon); NXDputalias(pFile,pDict,"cnmon2",&lVal); + lVal = GetHistMonitor(self->pHist,4,pCon); + NXDputalias(pFile,pDict,"cnmon3",&lVal); /* histogram with three detector banks */ diff --git a/histmem.c b/histmem.c index 23164f48..9e6ecf94 100644 --- a/histmem.c +++ b/histmem.c @@ -1462,7 +1462,8 @@ /* check user rights */ if(!SCMatchRights(pCon,self->iAccess)) { - SCWrite(pCon,"ERROR: you are not priviledged for attempted operation",eError); + SCWrite(pCon, + "ERROR: you are not priviledged for attempted operation",eError); return 0; } diff --git a/hkl.c b/hkl.c index 89b19ad4..56b72aaf 100644 --- a/hkl.c +++ b/hkl.c @@ -13,6 +13,11 @@ Updated to use fourlib. Mark Koennecke, December 2001 + + Introduced HM mode in order to cope with with the fact that TRICS has + three detectors. + + Mark Koennecke, May 2002 -----------------------------------------------------------------------------*/ #include #include @@ -47,6 +52,7 @@ name, self->fUB[0], self->fUB[1], self->fUB[2], self->fUB[3], self->fUB[4], self->fUB[5], self->fUB[6], self->fUB[7], self->fUB[8]); + fprintf(fd,"%s hm %d\n",name, self->iHM); return 1; } @@ -86,6 +92,7 @@ pNew->fLambda = 1.38; pNew->iManual = 1; pNew->iQuad = 1; + pNew->iHM = 0; pNew->fUB[0] = 1.; pNew->fUB[4] = 1.; pNew->fUB[8] = 1.; @@ -369,19 +376,49 @@ return 1; } /*-----------------------------------------------------------------------*/ +static int checkTheta(pHKL self, double *stt){ + char pError[132]; + int iTest; + float fHard; + + iTest = MotorCheckBoundary(self->pTheta,(float)*stt, &fHard,pError,131); + if(!iTest) + { + /* + check if it is on the other detectors + */ + if(self->iHM){ + iTest = MotorCheckBoundary(self->pTheta,(float)*stt-45., + &fHard,pError,131); + if(iTest){ + *stt -= 45.; + } else { + iTest = MotorCheckBoundary(self->pTheta,(float)*stt-90., + &fHard,pError,131); + if(iTest) { + *stt -= 90.; + } + } + } + if(!iTest){ + return -1; + } + } + return 1; +} +/*-----------------------------------------------------------------------*/ static int checkBisecting(pHKL self, - double stt, double om, double chi, double phi) + double *stt, double om, double chi, double phi) { int iTest; float fHard, fLimit; char pError[132]; /* check two theta */ - iTest = MotorCheckBoundary(self->pTheta,(float)stt, &fHard,pError,131); - if(!iTest) - { + iTest = checkTheta(self, stt); + if(!iTest){ return -1; - } + } /* for omega check against the limits +- SCANBORDER in order to allow for a omega scan @@ -409,7 +446,7 @@ static int checkBisecting(pHKL self, return 0; } /*-----------------------------------------------------------------------*/ -static int checkNormalBeam(double om, double gamma, double nu, +static int checkNormalBeam(double om, double *gamma, double nu, float fSet[4], SConnection *pCon, pHKL self) { int iTest; @@ -418,11 +455,11 @@ static int checkNormalBeam(double om, double gamma, double nu, /* check omega, gamma and nu */ iTest = MotorCheckBoundary(self->pOmega,(float)om, &fHard,pError,131); - iTest += MotorCheckBoundary(self->pTheta,(float)gamma, &fHard,pError,131); + iTest += checkTheta(self,gamma); iTest += MotorCheckBoundary(self->pNu,(float)nu, &fHard,pError,131); if(iTest == 3) /* none of them burns */ { - fSet[0] = (float)gamma; + fSet[0] = (float)*gamma; fSet[1] = (float)om; fSet[2] = (float)nu; return 1; @@ -433,7 +470,7 @@ static int checkNormalBeam(double om, double gamma, double nu, tryOmegaTweak tries to calculate a psi angle in order to put an offending omega back into range. -----------------------------------------------------------------------*/ -static int tryOmegaTweak(pHKL self, MATRIX z1, double stt, double *om, +static int tryOmegaTweak(pHKL self, MATRIX z1, double *stt, double *om, double *chi, double *phi){ int status; float fLower, fUpper, omTarget, omOffset; @@ -478,7 +515,7 @@ static int tryOmegaTweak(pHKL self, MATRIX z1, double stt, double *om, return 0; } - if(checkBisecting(self,dumstt,offom,offchi,offphi)){ + if(checkBisecting(self,&dumstt,offom,offchi,offphi)){ *om = offom; *chi = offchi; *phi = offphi; @@ -529,7 +566,7 @@ static int calculateBisecting(MATRIX z1, pHKL self, SConnection *pCon, phi = circlify(phi); if(iRetry > 1) { - if(tryOmegaTweak(self,z1,stt,&om,&chi,&phi)){ + if(tryOmegaTweak(self,z1,&stt,&om,&chi,&phi)){ fSet[0] = (float)stt; fSet[1] = (float)om; fSet[2] = (float)circlify(chi); @@ -554,7 +591,7 @@ static int calculateBisecting(MATRIX z1, pHKL self, SConnection *pCon, rotatePsi(om,chi,phi,psi,&ompsi,&chipsi,&phipsi); chipsi = circlify(chipsi); phipsi = circlify(phipsi); - test = checkBisecting(self,stt,ompsi,chipsi,phipsi); + test = checkBisecting(self,&stt,ompsi,chipsi,phipsi); if(test == 1) { fSet[0] = (float)stt; @@ -643,7 +680,7 @@ static int calculateNormalBeam(MATRIX z1, pHKL self, SConnection *pCon, if(bisToNormalBeam(stt,ompsi,chipsi,phipsi, &om, &gamma, &nu)) { - if(checkNormalBeam(om, gamma, nu,fSet,pCon,self)) + if(checkNormalBeam(om, &gamma, nu,fSet,pCon,self)) { return 1; } @@ -708,7 +745,7 @@ static int calculateNormalBeamOmega(MATRIX z1, pHKL self, if(bisToNormalBeam(stt,ompsi,chi,phi, &om, &gamma, &nu)) { - if(checkNormalBeam(om, gamma, nu,fSet,pCon,self)) + if(checkNormalBeam(om, &gamma, nu,fSet,pCon,self)) { return 1; } @@ -1212,8 +1249,9 @@ ente: strtolower(argv[1]); if(strcmp(argv[1],"list") == 0 ) { - sprintf(pBueffel,"lambda = %f Normal Beam = %d Quadrant = %d", - self->fLambda, self->iNOR, self->iQuad); + sprintf(pBueffel, + "lambda = %f Normal Beam = %d Quadrant = %d HM = %d", + self->fLambda, self->iNOR, self->iQuad,self->iHM); SCWrite(pCon,pBueffel,eValue); sprintf(pBueffel,"UB = { %f %f %f", self->fUB[0], self->fUB[1],self->fUB[2]); @@ -1356,6 +1394,29 @@ ente: SCSendOK(pCon); return 1; } +/*------------- HM mode */ + else if(strcmp(argv[1],"hm") == 0) + { + if(argc < 3) + { + sprintf(pBueffel,"%s.hm = %d", argv[0],self->iHM); + SCWrite(pCon,pBueffel,eValue); + return 1; + } + if(!SCMatchRights(pCon,usUser)) + { + return 0; + } + if(!isNumeric(argv[2])) + { + sprintf(pBueffel,"ERROR: %s was not recognized as a number", argv[2]); + SCWrite(pCon,pBueffel,eError); + return 0; + } + self->iHM = atoi(argv[2]); + SCSendOK(pCon); + return 1; + } /*------------- normal beam */ else if(strcmp(argv[1],"nb") == 0) { diff --git a/hkl.i b/hkl.i index 56ef03da..25ae78c0 100644 --- a/hkl.i +++ b/hkl.i @@ -16,6 +16,7 @@ double fLastHKL[5]; int iNOR; int iQuad; + int iHM; pMotor pTheta; pMotor pOmega; pMotor pChi; diff --git a/hkl.tex b/hkl.tex index f34f82d9..936f563c 100644 --- a/hkl.tex +++ b/hkl.tex @@ -24,6 +24,7 @@ $\langle$hkldat {\footnotesize ?}$\rangle\equiv$ \mbox{}\verb@ double fLastHKL[5];@\\ \mbox{}\verb@ int iNOR;@\\ \mbox{}\verb@ int iQuad;@\\ +\mbox{}\verb@ int iHM;@\\ \mbox{}\verb@ pMotor pTheta;@\\ \mbox{}\verb@ pMotor pOmega;@\\ \mbox{}\verb@ pMotor pChi;@\\ @@ -51,6 +52,8 @@ The fields are more or less self explaining: or is updated automatically from a wavelength variable. \item[fLastHKL] the HKL of the last reflection calculated. \item[iNor] a flag for normal beam calculation mode. +\item[iHM] a flag for histogram memory mode. In this mode two theta +limits are checked alos for detector 2 and 3. \item[pTheta] The two theta motor. All motor are needed for boundary checking. \item[pOmega] The omega axis motor. diff --git a/hkl.w b/hkl.w index e26baff2..a87ab57f 100644 --- a/hkl.w +++ b/hkl.w @@ -19,6 +19,7 @@ The object uses the following object data structure: double fLastHKL[5]; int iNOR; int iQuad; + int iHM; pMotor pTheta; pMotor pOmega; pMotor pChi; @@ -39,6 +40,8 @@ The fields are more or less self explaining: or is updated automatically from a wavelength variable. \item[fLastHKL] the HKL of the last reflection calculated. \item[iNor] a flag for normal beam calculation mode. +\item[iHM] a flag for histogram memory mode. In this mode two theta +limits are checked alos for detector 2 and 3. \item[pTheta] The two theta motor. All motor are needed for boundary checking. \item[pOmega] The omega axis motor. diff --git a/macro.c b/macro.c index 692e6b3e..bb1a9c3b 100644 --- a/macro.c +++ b/macro.c @@ -182,10 +182,17 @@ extern Tcl_Interp *InterpGetTcl(SicsInterp *pSics); SCsetMacro(pCon,1); iRet = pCommand->OFunc(pCon,pSinter,pCommand->pData,margc, myarg); SCsetMacro(pCon,iMacro); - - free(pSics->lastUnknown[pSics->iStack]); - pSics->lastUnknown[pSics->iStack] = NULL; - + + /* + lastUnkown gets deeply stacked with each SICS command exec'd. + This is not reflected in code. However, lastUnknown has already + done its job here, so it is safe to do it the way it is done + */ + if(pSics->lastUnknown[pSics->iStack] != NULL) + { + free(pSics->lastUnknown[pSics->iStack]); + pSics->lastUnknown[pSics->iStack] = NULL; + } /* finish */ if(iRet) @@ -375,6 +382,7 @@ extern Tcl_Interp *InterpGetTcl(SicsInterp *pSics); { sprintf(pBueffel," Failed to open file -> %s <- ",argv[1]); SCWrite(pCon,pBueffel,eError); + /* SCSetInterrupt(pCon,eAbortBatch); */ return 0; } diff --git a/motor.c b/motor.c index d4448952..0e9a5026 100644 --- a/motor.c +++ b/motor.c @@ -159,6 +159,8 @@ self= (pMotor)pData; fprintf(fd,"# Motor %s\n",name); + sprintf(pBueffel,"%s sign %f\n",name,ObVal(self->ParArray,SIGN)); + fputs(pBueffel,fd); sprintf(pBueffel,"%s SoftZero %f\n",name,ObVal(self->ParArray,SZERO)); fputs(pBueffel,fd); sprintf(pBueffel,"%s SoftLowerLim %f\n",name,ObVal(self->ParArray,SLOW)); @@ -167,8 +169,6 @@ fputs(pBueffel,fd); sprintf(pBueffel,"%s Fixed %f\n",name,ObVal(self->ParArray,FIX)); fputs(pBueffel,fd); - sprintf(pBueffel,"%s sign %f\n",name,ObVal(self->ParArray,SIGN)); - fputs(pBueffel,fd); sprintf(pBueffel,"%s InterruptMode %f\n",name,ObVal(self->ParArray,INT)); fputs(pBueffel,fd); sprintf(pBueffel,"%s AccessCode %f\n",name,ObVal(self->ParArray,USRIGHTS)); diff --git a/network.c b/network.c index 92f65761..d386a546 100644 --- a/network.c +++ b/network.c @@ -361,6 +361,10 @@ CreateSocketAdress( if(iRet != lLen) { printf("Incomplete send: %d to %d\n ",iRet,lLen); + if(iRet < 0) + { + printf("System error: %s\n",strerror(errno)); + } return 0; } else diff --git a/nserver.c b/nserver.c index 7be0659a..67b0b10d 100644 --- a/nserver.c +++ b/nserver.c @@ -457,6 +457,11 @@ return 0; } + if(pServ->simMode) + { + return 1; + } + eOld = GetStatus(); SetStatus(eUserWait); tNow = time(NULL); @@ -481,7 +486,12 @@ pTaskMan pTasker = NULL; time_t tNow; long lID; - + + if(pServ->simMode) + { + return 1; + } + pTasker = GetTasker(); tNow = time(NULL); sWait.tFinish = tNow + lTime; diff --git a/nxamor.c b/nxamor.c index e69e99b2..178acde7 100644 --- a/nxamor.c +++ b/nxamor.c @@ -48,6 +48,13 @@ */ pAmor2T pAmor = NULL; +/* + if to save psd data in TOF mode or not. This is in order to save time + when measureing TOF with a single detector only. +*/ + +static int psdSave = 1; + /*------------------------------------------------------------------------*/ static void WriteDiaphragm(NXhandle hfil, NXdict hdict, int i, SConnection *pCon) @@ -611,8 +618,11 @@ static int WriteTOFDetector(char *name, pHistMem pHM, int *iDim, } else { - WriteTOFDetector("spinup",pHM, iDim,hfil,hdict,pCon); - + if(psdSave){ + WriteTOFDetector("spinup",pHM, iDim,hfil,hdict,pCon); + } else { + SCWrite(pCon,"PSD writing supressed!",eWarning); + } /* now get and write single detectors */ @@ -651,8 +661,27 @@ static int WriteTOFDetector(char *name, pHistMem pHM, int *iDim, int argc, char *argv[]) { char pBueffel[512], *pFile = NULL; - int iRet; + int iRet, iFlag; + /* + if arguments, check for psdsave + */ + if(argc > 1){ + strtolower(argv[1]); + if(strcmp(argv[1],"psdsave") == 0){ + if(argc > 2){ + psdSave = atof(argv[2]); + SCSendOK(pCon); + return 1; + } else { + sprintf(pBueffel,"storeamor.psdSave = %d",psdSave); + SCWrite(pCon,pBueffel,eValue); + return 1; + } + } + } + + pFile = SNXMakeFileName(pSics,pCon); sprintf(pBueffel,"Writing file %s .....",pFile); SCWrite(pCon,pBueffel,eWarning); diff --git a/nxdata.c b/nxdata.c index a4934b10..e02c2d68 100644 --- a/nxdata.c +++ b/nxdata.c @@ -195,7 +195,7 @@ if(pVar) { iStat = NXputattr(pFile,"instrument",pVar->text, - strlen(pVar->text)+1,DFNT_INT8); + strlen(pVar->text)+1,NX_CHAR); if(iStat == NX_ERROR) { SCWrite(pCon,"ERROR: writing instrument attribute to Nexus file",eError); @@ -444,7 +444,7 @@ SCWrite(pCon,pBueffel,eError); return 0; } - return SNputdata1att(hfil,dataname, DFNT_FLOAT32,1,&fVal,"Units",units); + return SNputdata1att(hfil,dataname, NX_FLOAT32,1,&fVal,"Units",units); } #ifdef NONINTF extern float nintf(float f); @@ -518,14 +518,14 @@ if(pMot) { iStat = MotorGetSoftPosition(pMot,pCon,&fStart); - iStat = SNputdata1att(Nfil,"kollimator1",DFNT_FLOAT32,1, + iStat = SNputdata1att(Nfil,"kollimator1",NX_FLOAT32,1, &fStart,"Units","degrees"); } pMot = FindMotor(pSics,"CEX2"); if(pMot) { iStat = MotorGetSoftPosition(pMot,pCon,&fStart); - iStat = SNputdata1att(Nfil,"kollimator2",DFNT_FLOAT32,1, + iStat = SNputdata1att(Nfil,"kollimator2",NX_FLOAT32,1, &fStart,"Units","degrees"); } NXclosegroup(Nfil); /* leave kollimator */ @@ -543,7 +543,7 @@ if(pVar) { VarGetFloat(pVar,&fVal); - SNputdata1att(Nfil,"lambda",DFNT_FLOAT32,1,&fVal, + SNputdata1att(Nfil,"lambda",NX_FLOAT32,1,&fVal, "Units","Angstroem"); NXopendata(Nfil,"lambda"); NXgetdataID(Nfil,&lWave); @@ -600,7 +600,7 @@ pPell = (pSelVar)pCom->pData; assert(iHasType(pPell,"SicsSelVar")); fVal = GetSelValue(pPell,pCon); - iStat = SNputdata1(Nfil,"lambda",DFNT_FLOAT32,1,&fVal); + iStat = SNputdata1(Nfil,"lambda",NX_FLOAT32,1,&fVal); if(!iStat) { return 0; @@ -613,11 +613,11 @@ if(iStat) /* skip if not readable, error has been reported lower down */ { - SNputdata1att(Nfil,"theta",DFNT_FLOAT32,1,&fTh, + SNputdata1att(Nfil,"theta",NX_FLOAT32,1,&fTh, "Units","degrees"); - SNputdata1att(Nfil,"two_theta",DFNT_FLOAT32, 1,&f2Th, + SNputdata1att(Nfil,"two_theta",NX_FLOAT32, 1,&f2Th, "Units","degrees"); - SNputdata1att(Nfil,"curvature",DFNT_FLOAT32, 1,&fB1, + SNputdata1att(Nfil,"curvature",NX_FLOAT32, 1,&fB1, "Units","mm"); } /* more monochromatic motors */ @@ -667,12 +667,12 @@ fVal = GetHistPreset(pHist); if(eCount == eTimer) { - iStat = SNputdata1(Nfil,"Preset",DFNT_FLOAT32,1, &fVal); + iStat = SNputdata1(Nfil,"Preset",NX_FLOAT32,1, &fVal); } else { fVal = nintf(fVal); - iStat = SNputdata1(Nfil,"Preset",DFNT_FLOAT32,1, &fVal); + iStat = SNputdata1(Nfil,"Preset",NX_FLOAT32,1, &fVal); } if(!iStat) { @@ -690,11 +690,11 @@ { return 0; } - iStat = SNputdata1(Nfil,"Monitor",DFNT_INT32,1, &iVal); + iStat = SNputdata1(Nfil,"Monitor",NX_INT32,1, &iVal); iVal = GetHistMonitor(pHist, 0, pCon); - SNputdata1(Nfil,"beam_monitor",DFNT_INT32,1, &iVal); + SNputdata1(Nfil,"beam_monitor",NX_INT32,1, &iVal); iVal = GetHistMonitor(pHist, 4, pCon); - SNputdata1(Nfil,"proton_monitor",DFNT_INT32,1, &iVal); + SNputdata1(Nfil,"proton_monitor",NX_INT32,1, &iVal); NXopendata(Nfil,"Monitor"); NXgetdataID(Nfil,&lMoni); NXclosedata(Nfil); @@ -707,7 +707,7 @@ return 0; } fVal = pVar->fVal; - iStat = SNputdata1(Nfil,"Step",DFNT_FLOAT32,1, &fVal); + iStat = SNputdata1(Nfil,"Step",NX_FLOAT32,1, &fVal); if(!iStat) { return 0; @@ -727,7 +727,7 @@ { return 0; } - iStat = SNputdata1(Nfil,"no_of_steps",DFNT_INT32,1, &iVal); + iStat = SNputdata1(Nfil,"no_of_steps",NX_INT32,1, &iVal); if(iStat < 1) { return 0; @@ -747,7 +747,7 @@ { return 0; } - iStat = SNputdata1(Nfil,"Counts",DFNT_INT32,iVal, lData); + iStat = SNputdata1(Nfil,"Counts",NX_INT32,iVal, lData); if(!iStat) { return 0; @@ -763,7 +763,7 @@ pMot = FindMotor(pSics,"a4"); assert(pMot); iStat = MotorGetSoftPosition(pMot,pCon,&fStart); - iStat = SNputdata1att(Nfil,"two_theta_start",DFNT_FLOAT32,1, + iStat = SNputdata1att(Nfil,"two_theta_start",NX_FLOAT32,1, &fStart,"Units","degrees"); if(!iStat) { @@ -772,7 +772,7 @@ /* create 2Theta array and store it */ fTheta = NULL; - fTheta = (float32 *)malloc(iVal*sizeof(DFNT_FLOAT32)); + fTheta = (float *)malloc(iVal*sizeof(NX_FLOAT32)); if(!fTheta) { return 0; @@ -781,7 +781,7 @@ { fTheta[i] = fStart + i*fVal; } - iStat = SNputdata1att(Nfil,"two_theta",DFNT_FLOAT32,iVal, + iStat = SNputdata1att(Nfil,"two_theta",NX_FLOAT32,iVal, fTheta,"Units","degrees"); if(!iStat) { @@ -819,7 +819,7 @@ pVar = FindVariable(pSics,"sample_mur"); if(pVar) { - SNputdata1att(Nfil,"sample_mur",DFNT_FLOAT32, 1,&pVar->fVal, + SNputdata1att(Nfil,"sample_mur",NX_FLOAT32, 1,&pVar->fVal, "Units","???"); } /* write sample environment here */ @@ -834,9 +834,9 @@ if(pLog) { VarlogGetMean(pLog,&fMean,&fStdDev); - SNputdata1att(Nfil,"temperature_mean",DFNT_FLOAT32, 1,&fMean, + SNputdata1att(Nfil,"temperature_mean",NX_FLOAT32, 1,&fMean, "Units","K"); - SNputdata1att(Nfil,"temperature_stddev",DFNT_FLOAT32, 1, + SNputdata1att(Nfil,"temperature_stddev",NX_FLOAT32, 1, &fStdDev,"Units","K"); } fVal = pDrive->GetValue(pCom->pData,pCon); @@ -845,7 +845,7 @@ { VarGetFloat((pSicsVariable)pDum,&fVal); } - SNputdata1att(Nfil,"sample_temperature",DFNT_FLOAT32, 1,&fVal, + SNputdata1att(Nfil,"sample_temperature",NX_FLOAT32, 1,&fVal, "Units","K"); } NXclosegroup(Nfil); /* sample Vgroup */ diff --git a/o2t.c b/o2t.c index 9bd33133..d00e2ae3 100644 --- a/o2t.c +++ b/o2t.c @@ -8,6 +8,8 @@ Mark Koennecke, February 1997 revised: Mark Koennecke, June 1997 + + revised to work with all drivables: Mark Koennecke, July 2002 Copyright: @@ -45,14 +47,13 @@ #include "fortify.h" #include "sics.h" #include "fupa.h" -#include "motor.h" #include "o2t.h" typedef struct __SicsO2T { pObjectDescriptor pDes; pIDrivable pDrivInt; - pMotor pOmega; - pMotor pTheta; + pDummy pOmega; + pDummy pTheta; } SicsO2T; /*---------------------------------------------------------------------------*/ @@ -191,6 +192,9 @@ pSicsO2T MakeO2T(char *omega, char *theta, SicsInterp *pSics) { pSicsO2T self = NULL; + CommandList *pCom = NULL; + pIDrivable pDriv = NULL; + pDummy pDum = NULL; /* allocate memory */ self = (pSicsO2T)malloc(sizeof(SicsO2T)); @@ -205,9 +209,17 @@ return NULL; } - /* get motors */ - self->pOmega = FindMotor(pSics,omega); - self->pTheta = FindMotor(pSics,theta); + /* get and check drivabels */ + pCom = FindCommand(pSics,omega); + pDum = pCom->pData; + if(GetDrivableInterface(pDum) != NULL){ + self->pOmega = pDum; + } + pCom = FindCommand(pSics,theta); + pDum = pCom->pData; + if(GetDrivableInterface(pDum) != NULL){ + self->pTheta = pDum; + } if( (self->pOmega == NULL) || (self->pTheta == NULL) ) { DeleteDescriptor(self->pDes); diff --git a/sicsstatus.tcl b/sicsstatus.tcl index f23530f6..9d303acc 100644 --- a/sicsstatus.tcl +++ b/sicsstatus.tcl @@ -1,74 +1,48 @@ -yfactor 1.420000 -yfactor setAccess 1 -xfactor 0.715000 -xfactor setAccess 1 -ps.listfile peaksearch.dat -ps.listfile setAccess 2 -ps.scansteps 24 -ps.scansteps setAccess 2 -ps.scanpreset 1000000.000000 -ps.scanpreset setAccess 2 -ps.preset 1000.000000 -ps.preset setAccess 2 -ps.countmode monitor -ps.countmode setAccess 2 -ps.cogcontour 0.200000 -ps.cogcontour setAccess 2 -ps.cogwindow 60 -ps.cogwindow setAccess 2 -ps.window 7 -ps.window setAccess 2 -ps.steepness 3 -ps.steepness setAccess 2 -ps.threshold 30 -ps.threshold setAccess 2 -ps.sttstep 3.000000 -ps.sttstep setAccess 2 -ps.sttend 70.000000 -ps.sttend setAccess 2 -ps.sttstart 5.000000 -ps.sttstart setAccess 2 -ps.omstep 3.000000 -ps.omstep setAccess 2 -ps.omend 30.000000 -ps.omend setAccess 2 -ps.omstart 0.000000 -ps.omstart setAccess 2 -ps.chistep 12.000000 -ps.chistep setAccess 2 -ps.chiend 180.000000 -ps.chiend setAccess 2 -ps.chistart 0.000000 -ps.chistart setAccess 2 -ps.phistep 3.000000 -ps.phistep setAccess 2 -ps.phiend 180.000000 -ps.phiend setAccess 2 -ps.phistart 0.000000 -ps.phistart setAccess 2 -hm3 CountMode timer -hm3 preset 3600.000000 +a5l.length 80.000000 +flightpathlength 0.000000 +flightpathlength setAccess 1 +flightpath 0.000000 +flightpath setAccess 1 +delay 2500.000000 +delay setAccess 1 +hm CountMode timer +hm preset 100.000000 +hm genbin 120.000000 35.000000 512 +hm init +datafile focus-1001848.hdf +datafile setAccess 3 hm2 CountMode timer hm2 preset 3600.000000 hm1 CountMode timer hm1 preset 3600.000000 +dbfile UNKNOWN +dbfile setAccess 2 +# Motor th +th sign 1.000000 +th SoftZero 0.000000 +th SoftLowerLim 4.000000 +th SoftUpperLim 113.000000 +th Fixed -1.000000 +th InterruptMode 0.000000 +th AccessCode 2.000000 #Crystallographic Settings hkl lambda 1.179000 hkl setub -0.017880 -0.074923 0.028280 -0.007008 -0.036800 -0.057747 0.160912 -0.009928 0.000627 -detdist3 0.000000 -detdist3 setAccess 1 +hkl hm 0 +det3dist 300.000000 +det3dist setAccess 1 det3zeroy 128.000000 det3zeroy setAccess 1 det3zerox 128.000000 det3zerox setAccess 1 -detdist2 0.000000 -detdist2 setAccess 1 +det2dist 300.000000 +det2dist setAccess 1 det2zeroy 128.000000 det2zeroy setAccess 1 det2zerox 128.000000 det2zerox setAccess 1 -detdist1 0.000000 -detdist1 setAccess 1 +det1dist 300.000000 +det1dist setAccess 1 det1zeroy 128.000000 det1zeroy setAccess 1 det1zerox 128.000000 @@ -78,103 +52,105 @@ mono2theta setAccess 1 monodescription unknownit crystal monodescription setAccess 1 # Motor om +om sign 1.000000 om SoftZero 0.000000 om SoftLowerLim -73.000000 om SoftUpperLim 134.000000 om Fixed -1.000000 -om sign 1.000000 om InterruptMode 0.000000 om AccessCode 2.000000 # Motor stt +stt sign 1.000000 stt SoftZero 0.000000 stt SoftLowerLim 4.000000 stt SoftUpperLim 113.000000 stt Fixed -1.000000 -stt sign 1.000000 stt InterruptMode 0.000000 stt AccessCode 2.000000 # Motor ch +ch sign 1.000000 ch SoftZero 0.000000 ch SoftLowerLim 0.000000 ch SoftUpperLim 212.000000 ch Fixed -1.000000 -ch sign 1.000000 ch InterruptMode 0.000000 ch AccessCode 1.000000 # Motor ph +ph sign 1.000000 ph SoftZero 0.000000 ph SoftLowerLim -360.000000 ph SoftUpperLim 360.000000 ph Fixed -1.000000 -ph sign 1.000000 ph InterruptMode 0.000000 ph AccessCode 2.000000 # Motor dg3 +dg3 sign 1.000000 dg3 SoftZero 0.000000 dg3 SoftLowerLim -10.000000 dg3 SoftUpperLim 40.000000 dg3 Fixed -1.000000 -dg3 sign 1.000000 dg3 InterruptMode 0.000000 dg3 AccessCode 2.000000 # Motor dg2 +dg2 sign 1.000000 dg2 SoftZero 0.000000 dg2 SoftLowerLim -10.000000 dg2 SoftUpperLim 40.000000 dg2 Fixed -1.000000 -dg2 sign 1.000000 dg2 InterruptMode 0.000000 dg2 AccessCode 2.000000 # Motor dg1 +dg1 sign 1.000000 dg1 SoftZero 0.000000 dg1 SoftLowerLim -10.000000 dg1 SoftUpperLim 40.000000 dg1 Fixed -1.000000 -dg1 sign 1.000000 dg1 InterruptMode 0.000000 dg1 AccessCode 2.000000 # Motor muca +muca sign 1.000000 muca SoftZero 0.000000 muca SoftLowerLim 30.000000 muca SoftUpperLim 36.000000 muca Fixed -1.000000 -muca sign 1.000000 muca InterruptMode 0.000000 muca AccessCode 2.000000 # Motor phi +phi sign 1.000000 phi SoftZero 0.000000 phi SoftLowerLim -360.000000 phi SoftUpperLim 360.000000 phi Fixed -1.000000 -phi sign 1.000000 phi InterruptMode 0.000000 phi AccessCode 2.000000 # Motor chi +chi sign 1.000000 chi SoftZero 0.000000 chi SoftLowerLim 0.000000 chi SoftUpperLim 212.000000 chi Fixed -1.000000 -chi sign 1.000000 chi InterruptMode 0.000000 chi AccessCode 1.000000 # Motor omega +omega sign 1.000000 omega SoftZero 0.000000 omega SoftLowerLim -73.000000 omega SoftUpperLim 134.000000 omega Fixed -1.000000 -omega sign 1.000000 omega InterruptMode 0.000000 omega AccessCode 2.000000 # Motor twotheta +twotheta sign 1.000000 twotheta SoftZero 0.000000 twotheta SoftLowerLim 4.000000 twotheta SoftUpperLim 113.000000 twotheta Fixed -1.000000 -twotheta sign 1.000000 twotheta InterruptMode 0.000000 twotheta AccessCode 2.000000 lastscancommand cscan a4 10. .1 10 5 lastscancommand setAccess 2 +banana CountMode timer +banana preset 100.000000 sample_mur 0.000000 sample_mur setAccess 2 email UNKNOWN @@ -189,274 +165,276 @@ adress setAccess 2 counter SetPreset 1.000000 counter SetMode Timer # Motor som +som sign 1.000000 som SoftZero 0.000000 som SoftLowerLim -360.000000 som SoftUpperLim 360.000000 som Fixed -1.000000 -som sign 1.000000 som InterruptMode 0.000000 -som AccessCode 0.000000 +som AccessCode 2.000000 # Motor sax +sax sign 1.000000 sax SoftZero 0.000000 sax SoftLowerLim -30.000000 sax SoftUpperLim 30.000000 sax Fixed -1.000000 -sax sign 1.000000 sax InterruptMode 0.000000 sax AccessCode 2.000000 # Motor tilt +tilt sign 1.000000 tilt SoftZero 0.000000 tilt SoftLowerLim -15.000000 tilt SoftUpperLim 15.000000 tilt Fixed -1.000000 -tilt sign 1.000000 tilt InterruptMode 0.000000 tilt AccessCode 0.000000 # Motor detectorrotation +detectorrotation sign 1.000000 detectorrotation SoftZero 0.000000 detectorrotation SoftLowerLim -20.000000 detectorrotation SoftUpperLim 20.000000 detectorrotation Fixed -1.000000 -detectorrotation sign 1.000000 detectorrotation InterruptMode 0.000000 detectorrotation AccessCode 2.000000 # Motor detectory +detectory sign 1.000000 detectory SoftZero 0.000000 detectory SoftLowerLim -20.000000 detectory SoftUpperLim 20.000000 detectory Fixed -1.000000 -detectory sign 1.000000 detectory InterruptMode 0.000000 detectory AccessCode 2.000000 # Motor detectorx +detectorx sign 1.000000 detectorx SoftZero 0.000000 detectorx SoftLowerLim -20.000000 detectorx SoftUpperLim 20.000000 detectorx Fixed -1.000000 -detectorx sign 1.000000 detectorx InterruptMode 0.000000 detectorx AccessCode 2.000000 # Motor beamstopy +beamstopy sign 1.000000 beamstopy SoftZero 0.000000 beamstopy SoftLowerLim -20.000000 beamstopy SoftUpperLim 20.000000 beamstopy Fixed -1.000000 -beamstopy sign 1.000000 beamstopy InterruptMode 0.000000 beamstopy AccessCode 2.000000 # Motor beamstopx +beamstopx sign 1.000000 beamstopx SoftZero 0.000000 beamstopx SoftLowerLim -20.000000 beamstopx SoftUpperLim 20.000000 beamstopx Fixed -1.000000 -beamstopx sign 1.000000 beamstopx InterruptMode 0.000000 beamstopx AccessCode 2.000000 # Motor d2t +d2t sign 1.000000 d2t SoftZero 0.000000 d2t SoftLowerLim -20.000000 d2t SoftUpperLim 20.000000 d2t Fixed -1.000000 -d2t sign 1.000000 d2t InterruptMode 0.000000 d2t AccessCode 2.000000 # Motor d2l +d2l sign 1.000000 d2l SoftZero 0.000000 d2l SoftLowerLim -20.000000 d2l SoftUpperLim 20.000000 d2l Fixed -1.000000 -d2l sign 1.000000 d2l InterruptMode 0.000000 d2l AccessCode 2.000000 # Motor d2r +d2r sign 1.000000 d2r SoftZero 0.000000 d2r SoftLowerLim -20.000000 d2r SoftUpperLim 20.000000 d2r Fixed -1.000000 -d2r sign 1.000000 d2r InterruptMode 0.000000 d2r AccessCode 2.000000 # Motor d1t +d1t sign 1.000000 d1t SoftZero 0.000000 d1t SoftLowerLim -20.000000 d1t SoftUpperLim 20.000000 d1t Fixed -1.000000 -d1t sign 1.000000 d1t InterruptMode 0.000000 d1t AccessCode 2.000000 # Motor d1l +d1l sign 1.000000 d1l SoftZero 0.000000 d1l SoftLowerLim -20.000000 d1l SoftUpperLim 20.000000 d1l Fixed -1.000000 -d1l sign 1.000000 d1l InterruptMode 0.000000 d1l AccessCode 2.000000 # Motor d1r +d1r sign 1.000000 d1r SoftZero 0.000000 d1r SoftLowerLim -20.000000 d1r SoftUpperLim 20.000000 d1r Fixed -1.000000 -d1r sign 1.000000 d1r InterruptMode 0.000000 d1r AccessCode 2.000000 # Motor monochi +monochi sign 1.000000 monochi SoftZero 0.000000 monochi SoftLowerLim -30.000000 monochi SoftUpperLim 30.000000 monochi Fixed -1.000000 -monochi sign 1.000000 monochi InterruptMode 0.000000 monochi AccessCode 2.000000 # Motor monophi +monophi sign 1.000000 monophi SoftZero 0.000000 monophi SoftLowerLim -30.000000 monophi SoftUpperLim 30.000000 monophi Fixed -1.000000 -monophi sign 1.000000 monophi InterruptMode 0.000000 monophi AccessCode 2.000000 # Motor monoy +monoy sign 1.000000 monoy SoftZero 0.000000 monoy SoftLowerLim -30.000000 monoy SoftUpperLim 30.000000 monoy Fixed -1.000000 -monoy sign 1.000000 monoy InterruptMode 0.000000 monoy AccessCode 2.000000 # Motor monox +monox sign 1.000000 monox SoftZero 0.000000 monox SoftLowerLim -30.000000 monox SoftUpperLim 30.000000 monox Fixed -1.000000 -monox sign 1.000000 monox InterruptMode 0.000000 monox AccessCode 2.000000 # Motor tasse +tasse sign 1.000000 tasse SoftZero 0.000000 tasse SoftLowerLim -130.000000 tasse SoftUpperLim 130.000000 tasse Fixed -1.000000 -tasse sign 1.000000 tasse InterruptMode 0.000000 tasse AccessCode 2.000000 # Motor sdm +sdm sign 1.000000 sdm SoftZero 0.000000 sdm SoftLowerLim -5.000000 sdm SoftUpperLim 50.000000 sdm Fixed -1.000000 -sdm sign 1.000000 sdm InterruptMode 0.000000 sdm AccessCode 2.000000 # Motor sgu +sgu sign 1.000000 sgu SoftZero 0.000000 sgu SoftLowerLim -20.000000 sgu SoftUpperLim 20.000000 sgu Fixed -1.000000 -sgu sign 1.000000 sgu InterruptMode 0.000000 sgu AccessCode 2.000000 # Motor sgl +sgl sign 1.000000 sgl SoftZero 0.000000 sgl SoftLowerLim -20.000000 sgl SoftUpperLim 20.000000 sgl Fixed -1.000000 -sgl sign 1.000000 sgl InterruptMode 0.000000 sgl AccessCode 2.000000 # Motor mgu +mgu sign 1.000000 mgu SoftZero 0.000000 mgu SoftLowerLim -50.000000 mgu SoftUpperLim 50.000000 mgu Fixed -1.000000 -mgu sign 1.000000 mgu InterruptMode 0.000000 mgu AccessCode 2.000000 # Motor stu +stu sign 1.000000 stu SoftZero 0.000000 stu SoftLowerLim -30.000000 stu SoftUpperLim 30.000000 stu Fixed -1.000000 -stu sign 1.000000 stu InterruptMode 0.000000 stu AccessCode 2.000000 # Motor stl +stl sign 1.000000 stl SoftZero 0.000000 stl SoftLowerLim -30.000000 stl SoftUpperLim 30.000000 stl Fixed -1.000000 -stl sign 1.000000 stl InterruptMode 0.000000 stl AccessCode 2.000000 # Motor mtu +mtu sign 1.000000 mtu SoftZero 0.000000 mtu SoftLowerLim -30.000000 mtu SoftUpperLim 30.000000 mtu Fixed -1.000000 -mtu sign 1.000000 mtu InterruptMode 0.000000 mtu AccessCode 2.000000 # Motor mtl +mtl sign 1.000000 mtl SoftZero 0.000000 mtl SoftLowerLim -30.000000 mtl SoftUpperLim 30.000000 mtl Fixed -1.000000 -mtl sign 1.000000 mtl InterruptMode 0.000000 mtl AccessCode 2.000000 # Motor a6 +a6 sign 1.000000 a6 SoftZero 0.000000 a6 SoftLowerLim -30.000000 a6 SoftUpperLim 30.000000 a6 Fixed -1.000000 -a6 sign 1.000000 a6 InterruptMode 0.000000 a6 AccessCode 2.000000 # Motor a5 +a5 sign 1.000000 a5 SoftZero 0.000000 a5 SoftLowerLim -30.000000 a5 SoftUpperLim 30.000000 a5 Fixed -1.000000 -a5 sign 1.000000 a5 InterruptMode 0.000000 a5 AccessCode 2.000000 # Motor a4 +a4 sign 1.000000 a4 SoftZero 0.000000 a4 SoftLowerLim -130.000000 a4 SoftUpperLim 130.000000 a4 Fixed -1.000000 -a4 sign 1.000000 a4 InterruptMode 0.000000 a4 AccessCode 2.000000 # Motor a3 +a3 sign 1.000000 a3 SoftZero 0.000000 a3 SoftLowerLim -360.000000 a3 SoftUpperLim 360.000000 a3 Fixed -1.000000 -a3 sign 1.000000 a3 InterruptMode 0.000000 -a3 AccessCode 0.000000 +a3 AccessCode 2.000000 # Motor a2 +a2 sign 1.000000 a2 SoftZero 0.000000 a2 SoftLowerLim -73.000000 a2 SoftUpperLim 137.000000 a2 Fixed -1.000000 -a2 sign 1.000000 a2 InterruptMode 0.000000 a2 AccessCode 2.000000 # Motor a1 +a1 sign 1.000000 a1 SoftZero 0.000000 a1 SoftLowerLim 15.000000 a1 SoftUpperLim 120.000000 a1 Fixed -1.000000 -a1 sign 1.000000 a1 InterruptMode 0.000000 a1 AccessCode 2.000000 +batchroot /data/koenneck/src/sics +batchroot setAccess 2 user Uwe Filges user setAccess 2 sample D20 30K SNP Okt 2001 GS sample setAccess 2 title snp gs apd 30K title setAccess 2 -starttime 2002-04-23 10:49:18 +starttime 2002-04-23 10:49:18 starttime setAccess 2 diff --git a/sinqhm/FOCUS_srv_main.c b/sinqhm/FOCUS_srv_main.c index d16b91bd..e8136dce 100755 --- a/sinqhm/FOCUS_srv_main.c +++ b/sinqhm/FOCUS_srv_main.c @@ -14,7 +14,8 @@ ** ** Author . . . . . . . . . . : D. Maden ** Date of creation . . . . . . : Mar 2000 -** +** Well, start a motor. But not a3 in powder mode in order to + ** Updates: ** 1A01 7-Mar-2000 DM Initial version. **--------------------------------------------------------------------------- @@ -101,8 +102,11 @@ #include "SinqHM_def.h" #include "FOCUS_gbl.h" +#define READBUFSIZE 66560 extern char *vxWorksVersion; /* Version string of vxWorks */ extern char *creationDate; /* Creation Date string of vxWorks */ + static uchar readBuffer[READBUFSIZE]; + /* **============================================================================= ** Local routines. @@ -1593,7 +1597,7 @@ uint bins_to_go, lastbin; struct req_buff_struct my_rqst; struct rply_buff_struct my_rply; - uchar *buff_pntr, *last_byte, *nxt; + uchar *buff_pntr, *last_byte, *nxt; uchar buff[pkt_size]; register union { @@ -1661,23 +1665,12 @@ /***************************************************************/ /* ** The args are OK. - ** Reserve some space for buffering the histogram data. + ** Set up fixed buffer to do transfer */ my_pntr.base = NULL; - i = memFindMax (); /* Get size of biggest free memory block */ - if (i > (my_nbins * FS_bpb)) { /* If there's room to hold everything, - ** try to get it */ - bins_in_buff = my_nbins; - my_pntr.base = malloc (bins_in_buff * FS_bpb); - if (my_pntr.base == NULL) { - bins_in_buff = my_nbins/2; /* A fall-back position! */ - my_pntr.base = malloc (bins_in_buff * FS_bpb); - } - }else { - i = (i * 3)/4; /* there's not room to hold everything, so get less! */ - bins_in_buff = (i + FS_bpb - 1)/FS_bpb; - my_pntr.base = malloc (bins_in_buff * FS_bpb); - } + my_pntr.base = readBuffer; + bins_in_buff = READBUFSIZE/FS_bpb; + if (my_pntr.base == NULL ) { if (FS_dbg_lev0) printf ( "\n%s -- SQHM_READ: no buffer space available!\n", @@ -1708,6 +1701,7 @@ nbins_to_send = my_nbins; bytes_in_buff = 0; nxt = (char *) my_pntr.base; + while (nbins_to_send > 0) { /* Read some histogram data into buffer */ lastbin = nxtbin_to_send + bins_in_buff; @@ -1743,7 +1737,7 @@ nxtbin_to_send += bins_to_go; nbins_to_send -= bins_to_go; } - free (my_pntr.base); + /* ** Read-out complete so let DAQ continue. */ diff --git a/sinqhm/SinqHM_srv_filler.c b/sinqhm/SinqHM_srv_filler.c index 514aef4d..237f9d6b 100755 --- a/sinqhm/SinqHM_srv_filler.c +++ b/sinqhm/SinqHM_srv_filler.c @@ -950,8 +950,10 @@ } /* We have a valid single detector packet. + Subtract one form the number because Urs Greuter starts + counting at 1, and ANSI-C at 0 */ - edNum = edData.ui2[1]; + edNum = edData.ui2[1] - 1; if(edNum < 0 || edNum >= MAX_PSD_ED){ printf("Got invalid detector number %d\n",edNum); continue; @@ -999,7 +1001,13 @@ /* calculate histogram position to update */ - dataPos = (psdYSize*psdXSize + edNum)*Tof_edges[0]->n_bins + middl; + dataPos = (psdYSize*psdXSize)*Tof_edges[0]->n_bins + + edNum*Tof_edges[0]->n_bins + middl - 1; + + if(Dbg_lev1){ + printf("dataPos = %d\n", dataPos); + } + /* UD must come but the UD bit is not defined...... if ((Hm_mode_UD != 0) && @@ -1358,3 +1366,6 @@ exit (KER__SUCCESS); } /*======================================= End of SinqHM_srv_filler.c ========*/ + + + diff --git a/sinqhm/SinqHM_srv_main.c b/sinqhm/SinqHM_srv_main.c index 2091f73c..7ec8799b 100755 --- a/sinqhm/SinqHM_srv_main.c +++ b/sinqhm/SinqHM_srv_main.c @@ -151,7 +151,7 @@ Dbg_mask = 0; Dbg_lev0 = 0; - Dbg_lev1 = 0; + Dbg_lev1 = 1; Dbg_lev2 = 0; Dbg_lev3 = 0; Cfgn_done = 0; /* Force a configuration before we can do anything. */ diff --git a/sinqhm/SinqHM_srv_routines.c b/sinqhm/SinqHM_srv_routines.c index 86e4d0a6..5367dcae 100755 --- a/sinqhm/SinqHM_srv_routines.c +++ b/sinqhm/SinqHM_srv_routines.c @@ -1322,6 +1322,7 @@ psdYSize = ntohs(my_rqst->u.cnfg.u.psd.ySize); printf("\txSize = %4d, ySize = %4d\n", psdXSize, psdYSize); + N_hists = psdXSize*psdYSize+MAX_PSD_ED; Tof_dts_soll = ntohl (my_rqst->u.cnfg.u.psd.preset_delay); /* The ** required "Delay-Time-to-Start" */ @@ -1368,6 +1369,7 @@ edge_arr_pntr = &my_rqst->u.cnfg.u.psd.edge_0; for (i = 0; i < N_tof_edges; i++) { n_bins = ntohl (edge_arr_pntr->n_bins); + N_bins = n_bins; flag = ntohl (edge_arr_pntr->flag); edge_0 = ntohl (edge_arr_pntr->edges[0]); edge_1 = ntohl (edge_arr_pntr->edges[1]); @@ -1567,7 +1569,8 @@ Total_bytes += ((n_cntrs + MAX_PSD_ED) * n_bins * bytes_per_bin); if (i == 0) { /* Use the first counter bank to define some .. */ - N_hists = n_cntrs; /* .. globals since we expect there usually to .. */ + N_hists = n_cntrs+MAX_PSD_ED; + /* .. globals since we expect there usually to .. */ /* .. be only 1 counter bank. */ N_bins = n_bins; Lo_cntr = first; @@ -1591,6 +1594,7 @@ }else { Hist_base_addr = NULL; } + printf("Successfully allocated %d bytes\n", Total_bytes); if (Hist_base_addr == NULL) { printf ("\007do_SQHM__PSD_alloc:\n" " Unable to reserve %d bytes of memory!\n" diff --git a/sinqhm/bld b/sinqhm/bld index 88dd24a7..265640e1 100755 --- a/sinqhm/bld +++ b/sinqhm/bld @@ -82,6 +82,7 @@ mv bld bld.save rcp -p "${src}bld" ./bld rcp -p "${src}bld2" ./bld2 + rcp -p "${src}bld604" ./bld604 exit #----------------------------------------------------------------------------- startup: diff --git a/sinqhmdriv.c b/sinqhmdriv.c index 631122f0..0bc4ebc9 100644 --- a/sinqhmdriv.c +++ b/sinqhmdriv.c @@ -353,7 +353,7 @@ { SinqHMDriv *pInternal; pICountable pCountInt = NULL; - int status, iMode; + int status, iMode, nHist; char pError[132]; assert(self); @@ -369,9 +369,20 @@ pInternal->pCounter->pDriv->fPreset = self->fCountPreset; } - /* first zero the HM */ - status = SINQHMZero(pInternal->pMaster,-1,0,self->iRank*self->iLength); + if(self->eHistMode == ePSD && self->iTimeChan > 2){ + /* + this is special for AMOR and should be replaced by -1, -1, -1 + logic ASAP + */ + nHist = (self->iDims[0]*self->iDims[1] + 2) *self->iTimeChan; + status = SINQHMZero(pInternal->pMaster,-1,-1,-1); + }else{ + status = SINQHMZero(pInternal->pMaster,-1,0,self->iRank*self->iLength); + } + /* + status = SINQHMZero(pInternal->pMaster,-1,-1,-1); + */ if(status < 0) { pInternal->iLastHMError = status; @@ -897,7 +908,7 @@ SinqHMDriv *pInternal; char pError[132]; HistInt *plData = NULL; - int i, status; + int i, status, nHist; assert(self); assert(self->pPriv); @@ -905,7 +916,12 @@ pInternal = self->pPriv; /* get memory */ - plData = (HistInt *)malloc(self->iRank*self->iLength*sizeof(HistInt)); + if(self->eHistMode == ePSD && self->iTimeChan > 2){ + nHist = self->iDims[0]*self->iDims[1]*self->iTimeChan; + } else { + nHist = self->iRank*self->iLength; + } + plData = (HistInt *)malloc(nHist*sizeof(HistInt)); if(!plData) { PrintHMError("Out of memory in SinqHMDriv",pCon); @@ -913,12 +929,12 @@ } /* initialise */ - for(i = 0; i < self->iRank*self->iLength; i++) + for(i = 0; i < nHist; i++) { plData[i] = iVal; } - status = SQSetHistogram(self,pCon, -1,0,self->iRank*self->iLength, plData); + status = SQSetHistogram(self,pCon, -1,0,nHist, plData); free(plData); return status; } diff --git a/status.c b/status.c index ef354248..5a411c6c 100644 --- a/status.c +++ b/status.c @@ -81,6 +81,7 @@ NULL }; static pICallBack pCall = NULL; + static int fixed = 0; /*-------------------------------------------------------------------------*/ void KillStatus(void *pData) { @@ -89,15 +90,40 @@ DeleteCallBackInterface(pCall); } } -/*--------------------------------------------------------------------------*/ +/*--------------------------------------------------------------------------*/ void SetStatus(Status eNew) { - if(eCode == eNew) + if(!fixed) { - return; + if(eCode == eNew) + { + return; + } + eCode = eNew; + InvokeCallBack(pCall,VALUECHANGE,NULL); } - eCode = eNew; - InvokeCallBack(pCall,VALUECHANGE,NULL); + } +/*----------------------------------------------------------------------*/ + void SetStatusFixed(Status eNew) + { + if(eCode == eNew) + { + return; + } + eCode = eNew; + InvokeCallBack(pCall,VALUECHANGE,NULL); + fixed = 1; + } +/*----------------------------------------------------------------------*/ + void ClearFixedStatus(Status eNew) + { + if(eCode == eNew) + { + return; + } + eCode = eNew; + InvokeCallBack(pCall,VALUECHANGE,NULL); + fixed = 0; } /*-------------------------------------------------------------------------*/ Status GetStatus(void) diff --git a/status.h b/status.h index 61c27b58..c789ae15 100644 --- a/status.h +++ b/status.h @@ -27,9 +27,20 @@ void SetStatus(Status eNew); int SetStatusFromText(char *text); void KillStatus(void *pData); - +/** + * set a status and disallow any further changes to the status. This serves + * in order to prevent massive message flows to the client from status + * changes while processing synchronisation files + */ + void SetStatusFixed(Status eNew); +/** + * clear a fixed status again, status will be updated again. + */ + void ClearFixedStatus(Status eNew); + Status GetStatus(void); void GetStatusText(char *buf, int iBufLen); + int UserStatus(SConnection *pCon, SicsInterp *pSics, void *pData, int argc, char *argv[]); int ResetStatus(SConnection *pCon, SicsInterp *pSics, void *pData, diff --git a/synchronize.c b/synchronize.c index 53d82c12..0515559a 100644 --- a/synchronize.c +++ b/synchronize.c @@ -5,11 +5,17 @@ SICS server. Mark Koennecke, March 2001 + + Use internal connection. + Mark Koennecke, July 2002 + */ #include "sics.h" #include "network.h" +#include "status.h" #include "synchronize.h" + /*----------------------------------------------------------------------- Some file statics which hold the connection parameters ------------------------------------------------------------------------*/ @@ -137,6 +143,7 @@ int Synchronize(SConnection *pCon, SicsInterp *pSics, void *pData, char pBueffel[1024]; char pRead[80]; int test,i; + SConnection *internalCon = NULL; /* check for connection @@ -156,6 +163,7 @@ int Synchronize(SConnection *pCon, SicsInterp *pSics, void *pData, /* first tell the remote server to backup */ + SetStatusFixed(eBatch); strcpy(pBueffel,"transact backup\n"); test = NETWrite(connection,pBueffel,strlen(pBueffel)); if(test != 1) @@ -165,6 +173,7 @@ int Synchronize(SConnection *pCon, SicsInterp *pSics, void *pData, connection = NULL; SCWrite(pCon,"ERROR: Failed to contact sync server",eError); SCWrite(pCon,"Try again in order to reconnect before giving up",eWarning); + ClearFixedStatus(eEager); return 0; } /* @@ -182,6 +191,7 @@ int Synchronize(SConnection *pCon, SicsInterp *pSics, void *pData, SCWrite(pCon,"ERROR: Failed to contact sync server",eError); SCWrite(pCon, "Try again in order to reconnect before giving up",eWarning); + ClearFixedStatus(eEager); return 0; } else @@ -208,7 +218,18 @@ int Synchronize(SConnection *pCon, SicsInterp *pSics, void *pData, /* now read the backup file and we are done */ - test = InterpExecute(pSics,pCon,"restore"); + internalCon = SCCreateDummyConnection(pSics); + if(internalCon == NULL) + { + SCWrite(pCon,"ERROR: out of memory in sync", + eError); + ClearFixedStatus(eEager); + return 0; + + } + test = InterpExecute(pSics,internalCon,"restore"); + SCDeleteConnection(internalCon); + ClearFixedStatus(eEager); if(test != 1) { SCWrite(pCon,"ERROR: Failed to read sync information",eError); diff --git a/tascom.tcl b/tascom.tcl index bedcc396..e4ade56f 100644 --- a/tascom.tcl +++ b/tascom.tcl @@ -77,6 +77,15 @@ proc tasSplit {text} { return [lindex $list 1] } +#---------------------------------------------------------------------- +# put an angle into 360 +proc circlify {val} { + set p $val + while {$p > 360.0} { + set p [expr $p - 360.] + } + return $p +} #------------------------------------------------------------------------- # motor zero points are handled differently in SICS and MAD: # - MAD zero's are of opposite sign to SICS @@ -102,8 +111,8 @@ proc madZero args { set high [tasSplit [$mot softupperlim]] set displacement [expr $val - $zero] $mot softzero $val - $mot softupperlim [expr $high + $displacement] - $mot softlowerlim [expr $low + $displacement] + $mot softupperlim [expr $high - $displacement] + $mot softlowerlim [expr $low - $displacement] } } @@ -574,7 +583,7 @@ proc fz args { } #-------------------------------------------------------------------------- -# pr (int) values of variables +# pr(int) values of variables proc pr args { global tasmap @@ -582,7 +591,8 @@ proc pr args { set line [string tolower $line] set pos 0 set token [varToken $line $pos] - while { [string compare $token END] != 0 } { + while { [string compare $token END] != 0 && \ + [string compare $token end] != 0 } { #-------- check for mapped values first if { [info exists tasmap($token)] == 1 } { set val [tasSplit [eval $tasmap($token)]] @@ -907,10 +917,10 @@ proc sz args { set mot [varToken $line $pos] set val [varToken $line $pos] if { [lsearch $tasmot $mot] < 0 } { - error [format "ERROR: %s is no motor %s" $mot $usage] + error [format "ERROR: %s is no motor\n %s" $mot $usage] } if { [string compare [SICStype $val] NUM ] != 0 } { - error [format "ERROR: expected number, got %s %s" $val $usage] + error [format "ERROR: expected number, got %s \n%s" $val $usage] } #-------- output, output, output......... append output [format "Values : Lo(hard) Lo(soft) Posn%s" \ @@ -945,7 +955,6 @@ proc sz args { $loh $los $pos $targ $his $hih $zero] return $output } - #--------------------------------------------------------------------------- # switches and the sw command diff --git a/tasdrive.c b/tasdrive.c index 0a738d4c..35d91a8b 100644 --- a/tasdrive.c +++ b/tasdrive.c @@ -266,7 +266,7 @@ int TASDrive(SConnection *pCon, SicsInterp *pSics, void *pData, { if(tasTargetMask[9+i]) { - oldPos = readCurrent(tasMotorOrder[CURMOT+i], pCon); + oldPos = readDrivable(tasMotorOrder[CURMOT+i], pCon); sprintf(pBueffel,"Driving %s from %f to %f",tasMotorOrder[CURMOT+i], oldPos, tasTargets[9+i]); SCWrite(pCon,pBueffel,eWarning); diff --git a/tasscan.c b/tasscan.c index c40180c4..71cf2dc3 100644 --- a/tasscan.c +++ b/tasscan.c @@ -20,6 +20,7 @@ #include #include #include +#include #include "fortify.h" #include "sics.h" #include "sicsvar.h" @@ -241,7 +242,7 @@ static int TASHeader(pScanData self) iCount = 0; for(i = MAXMOT-8; i < MAXMOT;i++) { - fVal = readCurrent(tasMotorOrder[i],self->pCon); + fVal = readDrivable(tasMotorOrder[i],self->pCon); strcpy(pWork2,tasMotorOrder[i]); strtoupper(pWork2); fprintf(self->fd,"%-8s=%8.4f, ",pWork2,fVal); @@ -429,7 +430,7 @@ static int TASScanPoint(pScanData self, int iPoint) float fVal; pMotor pMot = NULL; long m1, m2, m3, cnts; - char pBueffel[1024], pWork[80]; + char pBueffel[1024], pWork[80], pError[132]; /* after polarisation analysis, this has to be ignored as it is called @@ -507,14 +508,14 @@ static int TASScanPoint(pScanData self, int iPoint) */ for(i = 0; i < pTAS->addCount; i++) { + fVal = -999.99; if(pTAS->addType[i] == 1) /* motor */ { - pMot = FindMotor(self->pSics,tasMotorOrder[pTAS->addOutput[i]]); - if(pMot) - { - status = MotorGetSoftPosition(pMot,self->pCon,&fVal); - if(!status) - fVal = -9999.77; + fVal = readDrivable(tasMotorOrder[pTAS->addOutput[i]],self->pCon); + if(fVal < -990.){ + sprintf(pError,"WARNING: problem reading %s", + tasMotorOrder[pTAS->addOutput[i]]); + SCWrite(self->pCon, pError,eWarning); } } else @@ -539,6 +540,20 @@ static int TASScanPoint(pScanData self, int iPoint) return 1; } +/*----------------------------------------------------------------------- + disables a3 driving in powder mode. In powder mode a3 is fixed. This + supresses the error message issued otherwise. + ------------------------------------------------------------------------*/ +static void fixPowder(unsigned char tasTargetMask[20]){ + char *pPtr = NULL; + + pPtr = Tcl_GetVar(pServ->pSics->pTcl,"powder",TCL_GLOBAL_ONLY); + if(pPtr){ + if(strstr(pPtr,"1") != NULL){ + tasTargetMask[2] = 0; + } + } +} /*------------------------------------------------------------------------ TASScanDrive starts all the motors necessary to drive to a new scan position. It thereby takes care of the TAS calculation if necessary. @@ -588,7 +603,9 @@ static int TASScanDrive(pScanData self, int iPoint) } else { - /* here there is a motor */ + /* + This is a motor, start it. + */ StartMotor(pServ->pExecutor,self->pSics, self->pCon, pVar->Name, pVar->fStart + iPoint * pVar->fStep); /* @@ -614,6 +631,7 @@ static int TASScanDrive(pScanData self, int iPoint) ignored here on purpose. There is a slight chance that other points in the scan fit the bill. */ + fixPowder(tasTargetMask); TASStart(pTAS,self->pCon, self->pSics,tasTargets,tasTargetMask); } @@ -1434,12 +1452,12 @@ int TASScan(SConnection *pCon, SicsInterp *pSics, void *pData, pTAS->tasPar[TIT]->text, pTAS->tasPar[USR]->text, pTAS->tasPar[QH]->fVal - (pTAS->pScan->iNP/2)*pTAS->tasPar[DQH]->fVal, - pTAS->tasPar[QL]->fVal - (pTAS->pScan->iNP/2)*pTAS->tasPar[DQL]->fVal, - pTAS->tasPar[QK]->fVal - (pTAS->pScan->iNP/2)*pTAS->tasPar[DQK]->fVal, + pTAS->tasPar[QK]->fVal - (pTAS->pScan->iNP/2)*pTAS->tasPar[DQL]->fVal, + pTAS->tasPar[QL]->fVal - (pTAS->pScan->iNP/2)*pTAS->tasPar[DQK]->fVal, pTAS->tasPar[EN]->fVal - (pTAS->pScan->iNP/2)*pTAS->tasPar[DEN]->fVal, pTAS->tasPar[DQH]->fVal, - pTAS->tasPar[DQL]->fVal, pTAS->tasPar[DQK]->fVal, + pTAS->tasPar[DQL]->fVal, pTAS->tasPar[DEN]->fVal); SCWrite(pCon,pLine,eWarning); if(iTas > 0) diff --git a/tasu.h b/tasu.h index 44e2eec2..bc95ce99 100644 --- a/tasu.h +++ b/tasu.h @@ -35,7 +35,7 @@ int isTASVar(char *val); int isTASEnergy(char *val); void prepare2Parse(char *line); int tasNumeric(char *pText); -float readCurrent(char *val, SConnection *pCon); +float readDrivable(char *val, SConnection *pCon); void startCurrent(char *val, SConnection *pCon, float fVal); void readConversionFactors(pTASdata self,float convH[4]); diff --git a/tasutil.c b/tasutil.c index c746a656..8e7e00fa 100644 --- a/tasutil.c +++ b/tasutil.c @@ -397,8 +397,8 @@ int TASCalc(pTASdata self, SConnection *pCon, for(i = 0; i < 4; i++) { helmconv[i] = .0; - currents[i] = readCurrent(tasMotorOrder[CURMOT+i],pCon); - currents[i+4] = readCurrent(tasMotorOrder[CURMOT + i + 4],pCon); + currents[i] = readDrivable(tasMotorOrder[CURMOT+i],pCon); + currents[i+4] = readDrivable(tasMotorOrder[CURMOT + i + 4],pCon); } readConversionFactors(self,helmconv); @@ -626,8 +626,8 @@ int TASUpdate(pTASdata self, SConnection *pCon) for(i = 0; i < 4; i++) { convH[i] = .0; - helmCurrent[i] = readCurrent(tasMotorOrder[CURMOT+i],pCon); - helmCurrent[4+i] = readCurrent(tasMotorOrder[CURMOT+i+4],pCon); + helmCurrent[i] = readDrivable(tasMotorOrder[CURMOT+i],pCon); + helmCurrent[4+i] = readDrivable(tasMotorOrder[CURMOT+i+4],pCon); } readConversionFactors(self,convH); @@ -729,15 +729,29 @@ int TASUpdate(pTASdata self, SConnection *pCon) return 1; } /*----------------------------------------------------------------------- - readCurrent tries to read the value of one of the magnet currents. + readDrivable tries to read the value of one of the magnet currents. All errors are ignored because most of the time currents will not be present in the system. -----------------------------------------------------------------------*/ -float readCurrent(char *val, SConnection *pCon){ +float readDrivable(char *val, SConnection *pCon){ pIDrivable pDriv; CommandList *pCom; pDummy pDum; + pMotor pMot = NULL; + float fVal; + /* + if motor: read motor + */ + pMot = FindMotor(pServ->pSics,val); + if(pMot != NULL){ + MotorGetSoftPosition(pMot,pCon,&fVal); + return fVal; + } + + /* + else: read general drivable + */ pCom = FindCommand(pServ->pSics,val); if(pCom != NULL){ pDriv = GetDrivableInterface(pCom->pData); @@ -745,7 +759,7 @@ float readCurrent(char *val, SConnection *pCon){ return pDriv->GetValue(pCom->pData,pCon); } } - return .0; + return -999.99; } /*----------------------------------------------------------------------- startCurrent starts driving a current to a new value @@ -767,3 +781,7 @@ void readConversionFactors(pTASdata self,float convH[4]){ convH[2] = self->tasPar[HCONV3]->fVal; convH[3] = self->tasPar[HCONV4]->fVal; } + + + + diff --git a/tcl/scancom.tcl b/tcl/scancom.tcl index 953eef6f..f4919172 100644 --- a/tcl/scancom.tcl +++ b/tcl/scancom.tcl @@ -312,7 +312,7 @@ object_class ScanCommand { #********************** initialisation of module commands to SICS ********** set ret [catch {scan list} msg] -if {$ret != 0} { +#if {$ret != 0} { object_new ScanCommand scan Publish scan Spy VarMake lastscancommand Text User @@ -323,7 +323,7 @@ if {$ret != 0} { Publish sftime Spy Publish scaninfo Spy Publish wwwsics Spy -} +#} #************************************************************************* diff --git a/tecs/tecs.c b/tecs/tecs.c index 6236a2c3..39b7d03d 100644 --- a/tecs/tecs.c +++ b/tecs/tecs.c @@ -531,7 +531,7 @@ int PrepInput(char *label) { sensD.alarm=0; } loop=1; - resist=10; + resist=25; str_copy(heUnits, "%"); i=sscanf(t, "%12s%n", nam, &l); @@ -1108,6 +1108,9 @@ void CalcMaxPower(void) { } } +#define ABS(x) (x < 0 ? -(x) : (x)) + + int SetMaxPower(void) { int i, j; float pa, pr, pw, dif, p; @@ -1121,13 +1124,17 @@ int SetMaxPower(void) { CalcMaxPower(); } logfileOut(LOG_MAIN, "maxPower changed from %g to %g\n", p0, maxPower); - ERR_P(LscCmd(ser, "CDISP 1:[loop],[resist],1;MOUT [loop]:0;CMODE [loop]:1")); + ERR_P(LscCmd(ser, "CDISP 1:[loop],25000,1;MOUT [loop]:0;CMODE [loop]:1")); if (slope<0) slope=-slope; if (slope!=0 && slope<0.1) slope=0.1; fbuf=tLimit/CtlScale(); if (loop==1) { - prop=sqrt(p0/scalPower)*prop; - ERR_P(LscCmd(ser, "CLIMIT 1:[fbuf],[slope],0,[iAmp],[iRange];PID [loop],[prop]")); + if(ABS(p0) > .0 && ABS(scalPower) > .0){ + prop=sqrt(p0/scalPower)*prop; + } else { + prop = 10.; + } + ERR_P(LscCmd(ser, "CLIMIT 1:[fbuf],[slope],0,2.0,[iRange];PID [loop],[prop]")); } else { ERR_P(LscCmd(ser, "CLIMIT 2:[fbuf],[slope],0")); } diff --git a/test.tcl b/test.tcl index 97f65b51..10c1270b 100644 --- a/test.tcl +++ b/test.tcl @@ -106,6 +106,8 @@ VarMake sampledist Float Mugger sampledist 496. sampledist lock +VarMake batchroot Text User + #-------------------------------------------------------------------------- # D E V I C E S : M O T O R S @@ -474,5 +476,23 @@ MakeLin2Ang a5l a5 source tcl/wwwpar.tcl source bef.tcl +source batch.tcl +Publish batchrun User + + #------- test of RS232Controller #MakeRS232Controller hugo psts213 3004 + +#-------------------------- batch run issue +VarMake BatchRoot Text User +BatchRoot /data/koenneck/src/sics +Publish batchrun User + +proc SplitReply { text } { + set l [split $text =] + return [lindex $l 1] +} + +proc batchrun file { + fileeval [string trim [SplitReply [BatchRoot]]/$file] +} diff --git a/token.h b/token.h index 6dcff35d..a31b3817 100644 --- a/token.h +++ b/token.h @@ -5,7 +5,7 @@ This is the header file for the SICS token management functions. It implements the token command. - Mark Koenencke, January 1998 + Mark Koennecke, January 1998 copyright: see copyright.h