- 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

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