- added third monitor to AMOR

- prepared monitor writing for SANS
- created a separate powder diffractometer simulation
- updated histogram memory code to read SANS gummi monitor packets
- updated histogram memory to read third single detector = TOF-monitor
This commit is contained in:
cvs
2002-10-02 15:01:45 +00:00
parent dfc8c8e28c
commit f514cf51e9
13 changed files with 253 additions and 56 deletions

View File

@@ -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 */

View File

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

View File

@@ -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.

View File

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

View File

@@ -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 (