diff --git a/amor.dic b/amor.dic index 23229545..7f31282e 100644 --- a/amor.dic +++ b/amor.dic @@ -204,6 +204,8 @@ singledown=/entry1,NXentry/reflectometer,NXinstrument/single,NXdetector/SDS \ singletime=/entry1,NXentry/reflectometer,NXinstrument/single,NXdetector/SDS \ time_binning -type DFNT_FLOAT32 -rank 1 -dim {$(timebin)} \ -attr {axis,2} +singletofmon=/entry1,NXentry/reflectometer,NXinstrument/single,NXdetector/SDS \ + tof_monitor -type DFNT_INT32 -rank 1 -dim {$(timebin)} #------------ detector: scan mode scanroot=/entry1,NXentry/reflectometer,NXinstrument/scan,NXdetector/SDS sdetx=/entry1,NXentry/reflectometer,NXinstrument/scan,NXdetector/SDS x \ diff --git a/danu.dat b/danu.dat index 51d3e2e7..b6dc33d2 100644 --- a/danu.dat +++ b/danu.dat @@ -1,3 +1,3 @@ - 233 + 239 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/nxamor.c b/nxamor.c index 57f97733..9b5f83e7 100644 --- a/nxamor.c +++ b/nxamor.c @@ -9,6 +9,7 @@ Mark Koennecke, September 1999 Updated, Mark Koennecke, August 2001 + Updated to store TOF-monitor, Mark Koennecke, September 2002 --------------------------------------------------------------------------*/ #include @@ -624,11 +625,12 @@ static int WriteTOFDetector(char *name, pHistMem pHM, int *iDim, } else { SCWrite(pCon,"PSD writing supressed!",eWarning); } +#define MAXSINGLE 3 /* now get and write single detectors */ iLength = iDim[0]*iDim[1]*iDim[2]; - lData = (HistInt *)malloc(2*iDim[2]*sizeof(HistInt)); + lData = (HistInt *)malloc(MAXSINGLE*iDim[2]*sizeof(HistInt)); if(!lData) { SCWrite(pCon,"ERROR: out of memory while writing single detectors", @@ -636,12 +638,18 @@ static int WriteTOFDetector(char *name, pHistMem pHM, int *iDim, } else { - memset(lData,0,2*iDim[2]*sizeof(HistInt)); - GetHistogramDirect(pHM,pCon,0,iLength,2*iDim[2], - lData, 2*iDim[2]*sizeof(HistInt)); + memset(lData,0,MAXSINGLE*iDim[2]*sizeof(HistInt)); + GetHistogramDirect(pHM,pCon,0,iLength,MAXSINGLE*iDim[2], + lData, MAXSINGLE*iDim[2]*sizeof(HistInt)); NXDputalias(hfil,hdict,"singleup",lData); NXDaliaslink(hfil,hdict,"singledana","singleup"); NXDaliaslink(hfil,hdict,"singledana","singletime"); + /* + the TOF monitor + */ + NXDputalias(hfil,hdict,"singletofmon",lData+2*iDim[2]); + NXDaliaslink(hfil,hdict,"dana","singletofmon"); + NXDaliaslink(hfil,hdict,"singledana","singletofmon"); } } diff --git a/nxsans.c b/nxsans.c index 64fac775..e6f5b0af 100644 --- a/nxsans.c +++ b/nxsans.c @@ -8,7 +8,10 @@ Updated to support the larger detector resolution and possible TOF and stroboscopic modes, Mark Koennecke, February 2001 - + + Added additional monitors for stroboscopic gummi mode, + Mark Koennecke, September 2002 + Copyright: Labor fuer Neutronenstreuung @@ -66,6 +69,7 @@ #define HISTNAME "banana" #define SAMPLETABLE "sampletable" +static int gummiFlag = 0; /* a flag indicating stroboscopic, or gummi mode */ /*-----------------------------------------------------------------------*/ static void SNError(void *pData, char *text) @@ -106,7 +110,7 @@ /* store global attributes */ iStat = NXputattr(pFile,"file_name",filename, - strlen(filename)+1,DFNT_INT8); + strlen(filename)+1,NX_CHAR); if(iStat == NX_ERROR) { SCWrite(pCon,"ERROR: writing file_name attribute to Nexus file",eError); @@ -118,7 +122,7 @@ /* write creation time */ SNXFormatTime(pBueffel,512); iStat = NXputattr(pFile,"file_time",pBueffel, - strlen(pBueffel)+1,DFNT_INT8); + strlen(pBueffel)+1,NX_CHAR); if(iStat == NX_ERROR) { SCWrite(pCon,"ERROR: writing date attribute to Nexus file",eError); @@ -127,7 +131,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); @@ -138,7 +142,7 @@ if(pVar) { iStat = NXputattr(pFile,"owner",pVar->text, - strlen(pVar->text)+1,DFNT_INT8); + strlen(pVar->text)+1,NX_CHAR); if(iStat == NX_ERROR) { SCWrite(pCon,"ERROR: writing owner attribute to Nexus file",eError); @@ -150,7 +154,7 @@ if(pVar) { iStat = NXputattr(pFile,"owner_adress",pVar->text, - strlen(pVar->text)+1,DFNT_INT8); + strlen(pVar->text)+1,NX_CHAR); if(iStat == NX_ERROR) { SCWrite(pCon,"ERROR: writing owner_adress attribute to Nexus file",eError); @@ -161,7 +165,7 @@ if(pVar) { iStat = NXputattr(pFile,"owner_telephone_number",pVar->text, - strlen(pVar->text)+1,DFNT_INT8); + strlen(pVar->text)+1,NX_CHAR); if(iStat == NX_ERROR) { SCWrite(pCon,"ERROR: writing owner_telephone_number attribute to Nexus file",eError); @@ -172,7 +176,7 @@ if(pVar) { iStat = NXputattr(pFile,"owner_fax_number",pVar->text, - strlen(pVar->text)+1,DFNT_INT8); + strlen(pVar->text)+1,NX_CHAR); if(iStat == NX_ERROR) { SCWrite(pCon,"ERROR: writing owner_fax_number attribute to Nexus file",eError); @@ -183,7 +187,7 @@ if(pVar) { iStat = NXputattr(pFile,"owner_email",pVar->text, - strlen(pVar->text)+1,DFNT_INT8); + strlen(pVar->text)+1,NX_CHAR); if(iStat == NX_ERROR) { SCWrite(pCon,"ERROR: writing owner_email attribute to Nexus file",eError); @@ -598,6 +602,7 @@ } NXDputalias(Nfil,pDict,"ddcounts",lData); free(lData); + /* write x and y axis */ for(i = 0; i < iDim[0]; i++) { @@ -609,6 +614,7 @@ iAxis[i] = i; } NXDputalias(Nfil,pDict,"ddcy",iAxis); + /* write time binning if appropriate */ if(nDim == 3) { @@ -616,6 +622,31 @@ NXDputalias(Nfil,pDict,"ddtb",(void *)fTime); } + /* + write gummi monitors when apropriate + */ + if(nDim == 3 && gummiFlag != 0) + { + histSize = 3*iDim[2]; + lData = (HistInt *)malloc(histSize*sizeof(HistInt)); + if(lData == NULL) + { + SCWrite(pCon,"WARNING: failed to allocate memory for monitors", + eWarning); + } else { + memset(lData,0,histSize*sizeof(HistInt)); + GetHistogram(self,pCon,0,iDim[0]*iDim[1]*iDim[2],histSize, + lData,histSize*sizeof(HistInt)); + NXDputalias(Nfil,pDict,"gummimon1",lData); + NXDputalias(Nfil,pDict,"gummimon2",lData+iDim[2]); + NXDputalias(Nfil,pDict,"gummimon3",lData+2*iDim[2]); + free(lData); + } + } + + /* + write detector temperature. It is a hot one............ + */ if(pSiem) { iRet = SPSGetADC(pSiem,1,&iVal); @@ -637,7 +668,7 @@ NXDaliaslink(Nfil,pDict,"dan","ddtb"); } - /* send quieck message for autoamtic copying*/ + /* send quieck message for automatic copying*/ i = 131; iVal = NX_CHAR; NXgetattr(Nfil,"file_name",pBueffel,&i,&iVal); @@ -704,12 +735,33 @@ char *argv[]) { + char pBueffel[80]; pDictStruct self = NULL; self = (pDictStruct)pData; + assert(self); assert(pCon); assert(pSics); - + + if(argc > 1){ + strtolower(argv[1]); + if(strcmp(argv[1],"gummi") == 0){ + if(argc > 2){ + if(!SCMatchRights(pCon,usMugger)){ + return 0; + } + gummiFlag = atoi(argv[2]); + SCSendOK(pCon); + return 1; + } else + { + sprintf(pBueffel,"%s.gummi = %d",argv[0], gummiFlag); + SCWrite(pCon,pBueffel,eValue); + return 1; + } + } + } + return SNMakeSANS(pCon,pSics,self->pDict); } /*--------------------------------------------------------------------------*/ diff --git a/sans.tcl b/sans.tcl index c950469c..b4a856f6 100644 --- a/sans.tcl +++ b/sans.tcl @@ -82,8 +82,8 @@ SicsDataPrefix lock VarMake SicsDataPostFix Text Mugger SicsDataPostFix ".hdf" SicsDataPostFix lock -MakeDataNumber SicsDataNumber $root/data/DataNumber -InitSANS $root/data/sansdict.dic +MakeDataNumber SicsDataNumber $root/data/2001/DataNumber +InitSANS $root/sansdict.dic #-------------------------------------------------------------------------- diff --git a/sansdict.dic b/sansdict.dic index e2757ed3..cec0eeb4 100644 --- a/sansdict.dic +++ b/sansdict.dic @@ -88,6 +88,15 @@ ddtb = /entry1,NXentry/SANS,NXinstrument/detector,NXdetector/SDS tof_or_gummi \ -attr {units,uSecOrStroboscopicDimension} ddtemp = /entry1,NXentry/SANS,NXinstrument/detector,NXdetector/SDS \ temperature +gummimon1 = /entry1,NXentry/SANS,NXinstrument/detector,NXdetector/SDS \ + gummi_monitor1 -rank 1 -dim {$(timedim)} \ + -attr {units,counts} +gummimon2 = /entry1,NXentry/SANS,NXinstrument/detector,NXdetector/SDS \ + gummi_monitor1 -rank 1 -dim {$(timedim)} \ + -attr {units,counts} +gummimon3 = /entry1,NXentry/SANS,NXinstrument/detector,NXdetector/SDS \ + gummi_monitor1 -rank 1 -dim {$(timedim)} \ + -attr {units,counts} #--------Sample san = /entry1,NXentry/sample,NXsample/SDS name -type DFNT_CHAR -rank 1 \ -dim {256} diff --git a/sicsstatus.tcl b/sicsstatus.tcl index 79513302..e484f928 100644 --- a/sicsstatus.tcl +++ b/sicsstatus.tcl @@ -1,48 +1,77 @@ -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 +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 10.000000 hm2 CountMode timer hm2 preset 10.000000 +banana CountMode timer +banana preset 10.000000 hm1 CountMode timer hm1 preset 10.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 hkl hm 0 -det3dist 300.000000 -det3dist setAccess 1 +detdist3 0.000000 +detdist3 setAccess 1 det3zeroy 128.000000 det3zeroy setAccess 1 det3zerox 128.000000 det3zerox setAccess 1 -det2dist 300.000000 -det2dist setAccess 1 +detdist2 0.000000 +detdist2 setAccess 1 det2zeroy 128.000000 det2zeroy setAccess 1 det2zerox 128.000000 det2zerox setAccess 1 -det1dist 300.000000 -det1dist setAccess 1 +detdist1 0.000000 +detdist1 setAccess 1 det1zeroy 128.000000 det1zeroy setAccess 1 det1zerox 128.000000 @@ -149,8 +178,6 @@ twotheta InterruptMode 0.000000 twotheta AccessCode 2.000000 lastscancommand cscan a4 10. .1 10 5 lastscancommand setAccess 2 -banana CountMode timer -banana preset 20.000000 sample_mur 0.000000 sample_mur setAccess 2 email UNKNOWN @@ -428,8 +455,6 @@ a1 SoftUpperLim 120.000000 a1 Fixed -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 diff --git a/sinqhm/SinqHM_def.h b/sinqhm/SinqHM_def.h index 96dea131..20f8a164 100755 --- a/sinqhm/SinqHM_def.h +++ b/sinqhm/SinqHM_def.h @@ -21,10 +21,10 @@ */ #define PORT_BASE 2400 /* The Internet Port for Server Requests */ #define MAX_CLIENTS 8 /* The maximum number of active clients */ -#define MAX_TOF_CNTR 1024 /* The maximum number of individual counters .. +#define MAX_TOF_CNTR 32768 /* The maximum number of individual counters .. ** which can be handled in TOF mode */ #define MAX_PSD_CNTR 1048576 /* maximum number of PSD elements */ -#define MAX_PSD_ED 2 /* maximum number of additional +#define MAX_PSD_ED 3 /* maximum number of additional single detectors at AMOR */ #define MAX_TOF_NBINS 32768 /* The maximum number of bins in a TOF histog */ @@ -220,6 +220,8 @@ #define LWL_TOF_C8 (0x08000000) /* TOF-Mode 8 chan dgrm hdr */ #define LWL_TOF_C9 (0x09000000) /* TOF-Mode 9 chan dgrm hdr */ +#define LWL_GUMMI_MON (0x14000000) /* GUMMI-Mode Monitor datagram */ + #define LWL_PSD_TSI 0x0E000000 /* PSD-Mode TSI datagram */ #define LWL_PSD_DATA 0x12000000 /* PSD-mode data datagram */ #define LWL_PSD_ED 0x03000000 /* PSD-mode single detector datagram */ diff --git a/sinqhm/SinqHM_gbl.h b/sinqhm/SinqHM_gbl.h index 80f06314..d5cce36d 100755 --- a/sinqhm/SinqHM_gbl.h +++ b/sinqhm/SinqHM_gbl.h @@ -296,6 +296,9 @@ uint hdr); void process_no_coinc_tsi ( uint hdr); + void process_gummi_monitor( + uint hdr); + int rply_status_send ( int skt, struct rply_buff_struct *rply_bf); diff --git a/sinqhm/SinqHM_srv_filler.c b/sinqhm/SinqHM_srv_filler.c index 237f9d6b..71c92f6a 100755 --- a/sinqhm/SinqHM_srv_filler.c +++ b/sinqhm/SinqHM_srv_filler.c @@ -681,6 +681,11 @@ ** type TSI header. The packet has 10 bytes ** altogether. Process it. */ + }else if ((lwl_hdr.ui4 & LWL_HDR_TYPE_MASK) == LWL_GUMMI_MON) { + /* + process a SANS gummi mode monitor datagram + */ + process_gummi_monitor(lwl_hdr.ui4); }else { /* Anything else gets flushed */ lwl_Packet_Read (lwl_hdr.ui4, my_buff); } @@ -950,14 +955,16 @@ } /* We have a valid single detector packet. - Subtract one form the number because Urs Greuter starts + Subtract one from the number because Urs Greuter starts counting at 1, and ANSI-C at 0 */ edNum = edData.ui2[1] - 1; + /* if(edNum < 0 || edNum >= MAX_PSD_ED){ printf("Got invalid detector number %d\n",edNum); continue; } + */ /* Extract time stamp and match to the appropriate time bin. diff --git a/sinqhm/SinqHM_srv_main.c b/sinqhm/SinqHM_srv_main.c index 7ec8799b..722b6be8 100755 --- a/sinqhm/SinqHM_srv_main.c +++ b/sinqhm/SinqHM_srv_main.c @@ -261,8 +261,12 @@ Lwl_hdr_daq_mask = LWL_HDR_NRL_MASK; Lwl_hdr_daq_soll = 0; }else if (strcmp (INST, "FOCUS") == 0) { + /* Lwl_hdr_daq_mask = LWL_HDR_NRL_MASK | LWL_HDR_SYNC2_MASK; Lwl_hdr_daq_soll = 0; + */ + Lwl_hdr_daq_mask = 0x00f00000; + Lwl_hdr_daq_soll = 0x00200000; printf ("%s: Instrument = \"%s\"\n", Tsk_name[0], "FOCUS"); }else if (strcmp (INST, "HRPT") == 0) { printf ("%s: Instrument = \"%s\"\n", Tsk_name[0], "HRPT"); diff --git a/sinqhm/SinqHM_srv_routines.c b/sinqhm/SinqHM_srv_routines.c index 5367dcae..5f40307b 100755 --- a/sinqhm/SinqHM_srv_routines.c +++ b/sinqhm/SinqHM_srv_routines.c @@ -3545,6 +3545,89 @@ lwl_data.ui2[1] = words[2]; Num_bad_events = lwl_data.ui4; } +/*-------------------------------------------------------------------------- + process_gummi_monitor processes special monitor datagrams as emitted by + SANS. In gummi mode a sample environment is cycled and data continously + collected during various steps of the cycle. Naturally, monitor values are + needed at each step in order to be able to scale the data measured + appropriatetly. The monitors are sent in a special datagram consisting of. + 7 packets. The first is the header and handed down as a function + call parameter. This header also holds the gummi cycle number to which this + monitor belongs. The following six packets are the monitor values, separate + as low byte, high byte. + + The monitors are then stored into the last three counters of the first + detector (and only) detector bank. The looser is supposed to give three + additional detectors additional to the normal ones. + + Look at this again when one of the following conditions is violated: + - More then one detector bank. + + --------------------------------------------------------------------------*/ +void process_gummi_monitor(uint hdr){ + uint gummiBin, readbuf[6], mon[3]; + int i, imon; + struct tof_histog *my_tof_descr; + + union { + uint ui4; + usint ui2[2]; + uchar ui1[4]; + } lwl_data, monitor; + + /* + collect those monitor values + */ + for(imon = 0; imon < 6; imon++){ + readbuf[imon] = LWL_FIFO_EMPTY; + for (i=0; i<1000; i++) { + readbuf[imon] = *Lwl_fifo; + if (readbuf[imon] != LWL_FIFO_EMPTY) break; + taskDelay (0); /* But wait if FIFO is slow! */ + } + if(readbuf[imon] == LWL_FIFO_EMPTY){ + printf("Timeout reading monitor %d in SANS GUMMI mode\n", imon); + return; + } + } + // put them together again + for(imon = 0; imon < 3; imon++){ + lwl_data.ui4 = readbuf[imon*2]; + monitor.ui2[0] = lwl_data.ui2[1]; + lwl_data.ui4 = readbuf[imon*2+1]; + monitor.ui2[1] = lwl_data.ui2[1]; + mon[imon] = monitor.ui4; + } + + gummiBin = hdr & LWL_HDR_TS_MASK; + if(gummiBin < 0 || gummiBin >= N_bins){ + printf("Invalid gummiBin %d detected \n", gummiBin); + return; + } + + if(Dbg_lev1){ + printf(" Gummi monitors: %d, %d, %d registered for gummi bin %d\n", + mon[0],mon[1],mon[2],gummiBin); + } + + for(imon = 0; imon < 3; imon++){ + my_tof_descr=Tof_descr[N_hists-3+imon]; + /* + printf(" detector %d receives %d\n", N_hists-3+imon, mon[imon]); + */ + switch (my_tof_descr->bytes_per_bin) { + case 1: + my_tof_descr->u.b_bin_data[gummiBin] += mon[imon]; + break; + case 2: + my_tof_descr->u.w_bin_data[gummiBin] += mon[imon]; + break; + default: + my_tof_descr->u.l_bin_data[gummiBin] += mon[imon]; + break; + } + } +} /* **--------------------------------------------------------------------------*/ void process_psd_tsi ( diff --git a/sinqhmdriv.c b/sinqhmdriv.c index 0bc4ebc9..d60a641e 100644 --- a/sinqhmdriv.c +++ b/sinqhmdriv.c @@ -170,7 +170,8 @@ /* in any case let us propagate the state of affairs to SINQHM */ - SINQHMSetPar(pInternal->pMaster,self->iRank, self->iLength, self->iBinWidth); + SINQHMSetPar(pInternal->pMaster,self->iRank, self->iLength, + self->iBinWidth); /* actual configuration. On first call, check for flag INIt in @@ -207,7 +208,8 @@ if( (self->iBinWidth != 1) && (self->iBinWidth != 2) && (self->iBinWidth != 4)) { - PrintHMError("Unsuported BinWidth specified, 1,2,4 are permissable",pCon); + PrintHMError("Unsuported BinWidth specified, 1,2,4 are permissable", +pCon); return 0; }