{ user procedures and utility related} { types for wfd readout } type bit32 = packed array [0..31] of boolean; bit16 = packed array [0..15] of boolean; bit8 = packed array [0..7] of boolean; ptr = ^integer; cpointer = packed record case integer of 0:( int: [pos(32)] integer); 1:( lwptr: [pos(32)] ^integer); 2:( wptr: [pos(32)] ^bit16); 3:( b: [pos(32)] ^bit32); end; int_pointer = packed record case boolean of true:( int: [pos(32)] integer); false:( pnt: [pos(32)] ^integer) end; erp_ch_type1 = [word] packed record case boolean of true:( TDC: [pos(0)] 0..4095; ch: [pos(12)] 0..3; modlow: [pos(14)] 0..3); false:( word: word16); end; erp_ch_type2 = [word] packed record case boolean of true:( TDC: [pos(0)] 0..4095; modhi: [pos(12)] 0..7; notused: [pos(15)] boolean); false:( word: word16); end; var save_evt_word,save_eqp_word,save_noqindex,save_start_window : integer; save_cam_error_flag, save_error_flag : boolean; save_current_equipment : integer; save_buffer : data_fle; save_mask_read : large_integer; save_vec_p : ^vector(max_size4); wait_flag : boolean := false; {flag to signal if the wait procedure (user3 has been called} { Variabili utilizzate nella procedura CAEN TRIP RECOVERY} esone_first : boolean := true; ten : array [0..2,0..40] of word16; {memorizza quante volte il canale e' andato in trip} m_n_ch : array [0..40] of word16;{memorizza il canale} { Variables used in wfd_patreg } eq30 : cpointer; { cspam readout } erp_wfd_index : array[1..106] of integer := (-1,-1,-1,-1, 0, 1, 0, 1, 2, 3, 2, 3, 2, 3, 2, 3, 4, 5, 4, 5, 4, 5, 4, 5, 6, 7, 6, 7, 6, 7, 6, 7, 8, 9, 8, 9, 8, 9, 8,-1,10,11,10,11,10,11,10,-1, 12,13,12,13,12,13,12,-1,14,15,14,15,14,15,14,15, 16,17,16,17,16,17,16,17,18,19,18,19,18,19,18,19, 0, 1, 0, 1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1,-1,-1); procedure save_list_data(orig_data:^anytype); {this procedure can be used in a multi process camac environnement { to save camac_list variables FR sept 1989} var k,status : integer; data_pointer:^data_fle; begin save_evt_word := evt_word; save_eqp_word := eqp_word; save_noqindex := noqindex; save_start_window := start_window; save_cam_error_flag := cam_error_flag; save_error_flag := error_flag; save_mask_read::byte_data(8) := equip_mask_read::byte_data(8); save_current_equipment:=current_equipment; data_pointer := orig_data; save_buffer.header := data_pointer^.header; save_vec_p::integer := evt_buffer[id]::integer; for k:=1 to (evt_word div 2 +1) do save_buffer.i4[k] := save_vec_p^[k] ; { unlock semaphores ecc} reset_header(id); unlock_mutex(data_blk[id].empty); { resume(camac_run,status:=status); { resume(alarm_in_subprocess,status:=status); { eln$camac_long_write(lg_s_mask,lamgrader_csr,trigger_sel_bit); { eln$camac_long_write(lg_s_mask,lamgrader_csr,alarm_sel_bit); {} unlock_area(lock_camac_area,lock_camac_pointer^.lock_camac); end; procedure restore_list_data(orig_data:^anytype); var k,status : integer; data_pointer:^data_fle; begin { lock semaphores ecc} { suspend(camac_run,status:=status); { suspend(alarm_in_subprocess,status:=status); { { eln$camac_long_write(lg_c_mask,lamgrader_csr,trigger_sel_bit); { eln$camac_long_write(lg_c_mask,lamgrader_csr,alarm_sel_bit); {} evt_word := save_evt_word; eqp_word := save_eqp_word; noqindex := save_noqindex; start_window := save_start_window; cam_error_flag := save_cam_error_flag; error_flag := save_error_flag; current_equipment:=save_current_equipment; equip_mask_read::byte_data(8):= save_mask_read::byte_data(8); data_pointer := orig_data; data_pointer^.header := save_buffer.header; save_vec_p::integer := evt_buffer[id]::integer; for k:=1 to (evt_word div 2 +1) do save_vec_p^[k] := save_buffer.i4[k]; end; procedure user_procedure_1; { wait 3 seconds } var dt : large_integer; begin dt := time_value('0000 00:00:03.0'); wait_any(time:=dt); end; procedure user_procedure_2; var dt : large_integer; begin dt := time_value('0000 00:00:00.02'); { to be used for IMB cal} wait_any(time:=dt); end; procedure user_procedure_3; { wait 2 sec without stop acq to be used inside monitors eqp} var dt : large_integer; begin wait_flag:=true; save_list_data(data[id]); dt := time_value('0000 00:00:02.0'); wait_any(time:=dt); {the following two lines are been removed from the restore procedure {before at high rate a few events was corrupted; FR nov 12 1989} {} lock_area(lock_camac_area,lock_camac_pointer^.lock_camac); lock_mutex(data_blk[id].empty); restore_list_data(data[id]); wait_flag:=false; end; procedure user_procedure_4; { this procedure active the vme readout} begin vme_list[id] := true; end; procedure user_procedure_5; begin end; procedure user_procedure_6; begin end; procedure user_procedure_7; { CAEN TRIP RECOVERY} const max=2; { numero max di canali che possono andare in trip } ch_caen=39; { numero dei canali in un crate caen } type { Case of per i bits che formano la parola di Protection Bits } c_bit=[word] packed record case boolean of true: (p_on :[pos(0)] boolean; { Power On } pass_en:[pos(1)] boolean; { Password Enable } key_en :[pos(2)] boolean; { Keyboard Enable } clear :[pos(3)] boolean); { Clear allarm } false:(full :word16); end; { case of per i bits che formano la parola dello Status bits} bit=[word] packed record case boolean of true: (Off :[pos(0)] boolean; { Canale Off } Trip :[pos(1)] boolean; { Canale in Trip } On :[pos(2)] boolean; { Canale On } OVV :[pos(3)] boolean; { Canale in Over-Voltage } UVV :[pos(4)] boolean; { Canale in Undr-Voltage } OVC :[pos(5)] boolean; { Canale in Over-Current } RPU :[pos(6)] boolean; { Rump_Up } RPD :[pos(7)] boolean); { Rump_Down } false:(full : word16); end; var p:bit; c_alarm: c_bit; exta,exta1,k,icam:integer; a_caen,s_caen : word16; { Sottoindirizzi Caen } bit_8_15,bit_0:word16; { bits per la scrittura e lettura } { sullo Status Bits } crt:word16; p_bit,t_n_ch:word16; { targhet per il protection Bits e per i canali } i,w,m,n_ch,z,x:integer; tvar,time: large_integer; q:boolean; f_w ,f_wr,f_r:word16; b_caen:word16:=caen_branch; c_caen:word16 := caen_crate; n_caen:word16:=caen_station; begin for x:=0 to ch_caen do m_n_ch[x]:=0; f_w:=16;f_wr:=17;f_r:=0; begin if (alarm_contents.single[1]=TRUE) then { Assegnazione Numero al } begin { Crate Caen} crt:=2*microvax_number-1;i:=0; end else if (alarm_contents.single[4]=TRUE) then begin crt:=2*microvax_number;i:=1; end; if (alarm_contents.single[6]=TRUE) then begin crt:=2*microvax_number +1;i:=1; end; {else {if (alarm_contents.single[ ]=TRUE) then {mettere indirizzo alarm_conten ts} { begin { crt:=microvax_number+6;i:=2; { end;} {Indirizzamento dell'interfaccia camac C 139} bit_8_15:=65280; a_caen:=7;s_caen:=0;p.full:=a_caen; cdreg(exta,b_caen,c_caen,n_caen,a_caen); cdreg(exta1,b_caen,c_caen,n_caen,s_caen); {routine di ricerca piano in trip} begin n_ch:=0;x:=0;z:=0;m:=0; repeat; t_n_ch:=n_ch+256*crt; cssa(f_wr,exta1,t_n_ch,q); wait_any(time:=-1000000); cssa(f_wr,exta,bit_8_15,q); wait_any(time:=-1000000); cssa(f_r,exta,p.full,q); wait_any(time:=-1000000); if p.trip=true then begin ten[i,x]:=ten[i,x]+1; { mettere lock mutex} lock_mutex(write_mutex); writeln(' **** Caen crate ',crt:3,' channel ',n_ch:2,' in trip', ' # of trips ',ten[i,x]:3); unlock_mutex(write_mutex); { now write some informations in the data buffer for each channel in trip} eqp_word := eqp_word+1; evt_word:= evt_word+1; data[id]^.buffer[evt_word]:=crt; { Caen crate number} eqp_word := eqp_word+1; evt_word:= evt_word+1; data[id]^.buffer[evt_word]:=n_ch; { channel in trip } eqp_word := eqp_word+1; evt_word:= evt_word+1; data[id]^.buffer[evt_word]:=ten[i,x]; { number of trips } m_n_ch[x]:=n_ch+1; lock_mutex(write_mutex); writeln(m_n_ch[x]); unlock_mutex(write_mutex); m:=m+1; end; N_CH:=N_CH+1;X:=X+1;Z:=Z+1; until z=ch_caen; end; {routine del clear degli allarmi} begin p_bit:=70+256*crt;c_alarm.full:=p_bit; cssa(f_wr,exta1,p_bit,q); wait_any(time:=-1000000); cssa(f_r,exta1,c_alarm.full,q); wait_any(time:=-1000000); cssa(f_wr,exta1,p_bit,q); wait_any(time:=-1000000); c_alarm.clear:=true; wait_any(time:=-1000000); cssa(f_w,exta1,c_alarm.full,q); wait_any(time:=-1000000); end; { controllo di quanti canali sono in trip} if m > max then begin lock_mutex(write_mutex); writeln('**** more than ',max:3,'channel in trip - no trip recover'); unlock_mutex(write_mutex); end else BEGIN { controllo di quante volte e' andato il canale in trip} begin W:=0;x:=0; repeat; if ten[i,x] >3 then begin n_ch:=m_n_ch[x]-1; lock_mutex(write_mutex); writeln('**** ch (',n_ch:2,') tripped > 3 times - no trip recover', ' call Streamer experts'); unlock_mutex(write_mutex); w:=ten[i,x]; X:=X+1; end ELSE x:=x+1; until x=ch_caen; end; { routine di accensione dei canali in trip} x:=0; repeat; begin if (m_n_ch[x] <>0) and (ten[i,x] <=3) then begin m_n_ch[x]:=m_n_ch[x]-1; lock_mutex(write_mutex); writeln(m_n_ch[x]); unlock_mutex(write_mutex); bit_0:=1; t_n_ch:=m_n_ch[x]+256*crt; cssa(f_wr,exta1,t_n_ch,q); wait_any(time:=-1000000); cssa(f_w,exta,bit_0,q); wait_any(time:=-1000000); cssa(f_wr,exta,bit_8_15,q); wait_any(time:=-1000000); cssa(f_r,exta,p.full,q); wait_any(time:=-1000000); x:=x+1; end else x:=x+1; end; until x=ch_caen; end; end; end; procedure user_procedure_8; { Caen Trip Recovery } { azzeramento delle variabili che controllano il numero dei canali in trip e il numero di volte che un canale va in trip} var x,i: integer; begin { commentato perche' non serve con il sistema VME { if esone_first then begin { i:=3; { cdset(x,i); {initialize esone routines} { esone_first :=false; { end; } for i:=0 to 2 do begin for x:=0 to 40 do ten[i,x]:=0; m_n_ch[x]:=0; end; end; procedure user_procedure_9; begin end; procedure user_procedure_10; begin end; { } { Forward definition of routines used in cspam WFD_PATREG calls } { The actual routines are after the wfd_patreg routine } { } procedure cspam_BC(wptr : cpointer; cdat : bit8; offset : integer); FORWARD; procedure cspam_WE(wptr : cpointer; cdat : bit8; offset : integer); FORWARD; procedure cspam_T(wptr : cpointer; cdat : bit8; offset : integer); FORWARD; procedure cspam_NS(wptr : cpointer; cdat : bit8; offset : integer); FORWARD; { -------------------------------------------------------------------- } { This user procedure corresponds to the WFD_PATREG camaclist command. } { It is used to set a software pattern register to control selective } { readout of WFD channels. The syntax is: } { WFD_PATREG supermodule, id, subid } { where "id" is by convention the equipment number and "subid" is the } { word within the equipment that is to be decoded. } { ETK Aug 1994 } { } { Cspam/fmt decoding for equip 30 added. The "subid" is a 3 digit code} { = xyz where x="microvax#" yz="pair of sm #'s in trigger" } { Ex. subid=223 -> microvax 2 readout of CSPAM23 or FMT23 } { In the camac list, do WFD_PATREG with sm=lowest supermodule# in } { that microvax that is part of the trigger. Ex: subid=223 -> sm=3 } { but subid=123 -> sm=2 } { SPECIAL CASE: subid=0 stores the equipment 30 pointer to data } { call this at the very beginning of equip 30 readout, before any data} { is read. All the other stuff should be done AFTER eq30 readout } { HIPT SUBIDS: same as cspam/fmt but * 10 (Ex: 1120)... } { } { CEL 11 Apr 95 } { -------------------------------------------------------------------- } procedure wfd_patreg(wfd_spr : ^integer; id : integer; subid : integer; pat : ^integer); const longwords = 4; words = 2; bytes = 1; max_erp_hits = 80; var indx : integer; word,i : integer; p : cpointer; wptr0 : cpointer; wptr1 : cpointer; cdat : array [0..10] of bit8; dum_ptr : int_pointer; dum_wrd : word16; erp_ptr : int_pointer; wrd1_ptr : int_pointer; wrd2_ptr : int_pointer; word_count : integer; hit_buf : array [1..max_ERP_hits] of integer; hit_count : integer; erp_wrd1 : erp_ch_type1; erp_wrd2 : erp_ch_type2; erp_module : integer; erp_channel : integer; begin case id of 0: case subid of { id = 0 is assigned to direct manipulation of the register } 0: begin { 0 is reserved for WRITE, which is handled elsewhere } end; 1: begin { Count bits and write result to data stream } { This is handled elsewhere } end; 2: begin { Mask specified bits (OR) } indx := FIND_FIRST_BIT_SET(pat^::bit32); while indx < 32 do begin wfd_spr^::bit32[indx] := true; indx := FIND_FIRST_BIT_SET(pat^::bit32,indx+1); end; end; 3: begin { Mask specified bits off (AND) } indx := FIND_FIRST_BIT_CLEAR(pat^::bit32); while indx < 32 do begin wfd_spr^::bit32[indx] := false; indx := FIND_FIRST_BIT_CLEAR(pat^::bit32,indx+1); end; end; 4: begin { Clear bits, ignoring word-1 passed from data buffer } wfd_spr^ := 0; end; 5: begin { Set bit pattern exactly } wfd_spr^ := pat^; end; end; 14: case subid of { id = 14 is assigned to the LIP trigger } 1: begin { subid = 1 handles the 1st pair of 16-bit patterns } wfd_spr^::bit32[16] := wfd_spr^::bit32[16] or pat^::bit32[0] or pat^::bit32[2] or pat^::bit32[4] or pat^::bit32[6]; wfd_spr^::bit32[17] := wfd_spr^::bit32[17] or pat^::bit32[1] or pat^::bit32[3] or pat^::bit32[5] or pat^::bit32[7]; wfd_spr^::bit32[18] := wfd_spr^::bit32[18] or pat^::bit32[8] or pat^::bit32[10] or pat^::bit32[12] or pat^::bit32[14]; wfd_spr^::bit32[19] := wfd_spr^::bit32[19] or pat^::bit32[9] or pat^::bit32[11] or pat^::bit32[13] or pat^::bit32[15]; wfd_spr^::bit32[4] := wfd_spr^::bit32[4] or pat^::bit32[16] or pat^::bit32[18] or pat^::bit32[20] or pat^::bit32[22]; wfd_spr^::bit32[5] := wfd_spr^::bit32[5] or pat^::bit32[17] or pat^::bit32[19] or pat^::bit32[21] or pat^::bit32[23]; wfd_spr^::bit32[6] := wfd_spr^::bit32[6] or pat^::bit32[24] or pat^::bit32[26] or pat^::bit32[28] or pat^::bit32[30]; wfd_spr^::bit32[7] := wfd_spr^::bit32[7] or pat^::bit32[25] or pat^::bit32[27] or pat^::bit32[29] or pat^::bit32[31]; end; 2: begin { subid = 2 handles the 2nd pair of 16-bit patterns } wfd_spr^::bit32[0] := wfd_spr^::bit32[0] or pat^::bit32[0] or pat^::bit32[2] or pat^::bit32[4] or pat^::bit32[6]; wfd_spr^::bit32[1] := wfd_spr^::bit32[1] or pat^::bit32[1] or pat^::bit32[3] or pat^::bit32[5] or pat^::bit32[7]; wfd_spr^::bit32[2] := wfd_spr^::bit32[2] or pat^::bit32[8] or pat^::bit32[10] or pat^::bit32[12] or pat^::bit32[14]; wfd_spr^::bit32[3] := wfd_spr^::bit32[3] or pat^::bit32[9] or pat^::bit32[11] or pat^::bit32[13] or pat^::bit32[15]; wfd_spr^::bit32[10] := wfd_spr^::bit32[10] or pat^::bit32[16] or pat^::bit32[18] or pat^::bit32[20] or pat^::bit32[22]; wfd_spr^::bit32[11] := wfd_spr^::bit32[11] or pat^::bit32[17] or pat^::bit32[19] or pat^::bit32[21]; wfd_spr^::bit32[14] := wfd_spr^::bit32[14] or pat^::bit32[24] or pat^::bit32[26] or pat^::bit32[28] or pat^::bit32[30]; wfd_spr^::bit32[15] := wfd_spr^::bit32[15] or pat^::bit32[25] or pat^::bit32[27] or pat^::bit32[29]; end; 3: begin { subid = 3 handles the 5th 16-bit pattern } { It is unusual in that we have to check the lower bits only } { The lower bits have already been checked by subid = 2 } wfd_spr^::bit32[8] := wfd_spr^::bit32[8] or pat^::bit32[0] or pat^::bit32[2] or pat^::bit32[4] or pat^::bit32[6]; wfd_spr^::bit32[9] := wfd_spr^::bit32[9] or pat^::bit32[1] or pat^::bit32[3] or pat^::bit32[5]; wfd_spr^::bit32[12] := wfd_spr^::bit32[12] or pat^::bit32[8] or pat^::bit32[10] or pat^::bit32[12] or pat^::bit32[14]; wfd_spr^::bit32[13] := wfd_spr^::bit32[13] or pat^::bit32[9] or pat^::bit32[11] or pat^::bit32[13]; end; end; 20,22,25: begin { id = 20,22,35 is used for even (EQUIP 20) (EQUIP 22) SM's and the N/S face ERP crates (EQUIP 25). here is the plan - we start by decoding the channel number by unpacking from the last two words in the event. Then, we must find the correspondence between this channel number and the wfd channel. Then we decrement the event pointer by 10, and go again. Here is the tricky part: to know when to end, we compare number words we've seen with the contents of the pointer location. At the end, the pointer will sit on the word count, and the two will agree. we don't allow more than 80 hits, to avoid infinite loops } erp_ptr.pnt:= pat; { put on 16 bit word boundary} erp_ptr.int := erp_ptr.int + 2; { set initial condition to make sure we do loop once} word_count:=0; hit_count := 0; { first a little pointer arithmetic} wrd1_ptr.int := erp_ptr.int; wrd2_ptr.int := erp_ptr.int-2; erp_wrd1.word:=wrd1_ptr.pnt^; erp_wrd2.word:=wrd2_ptr.pnt^; while (erp_wrd1.word <> word_count) AND (hit_count< Max_erp_hits) do begin erp_module := 4 * erp_wrd2.modhi + erp_wrd1.modlow; erp_channel := 4 * erp_module + erp_wrd1.ch + 1; { decrement pointer by 2* hit length ( 20 bytes) and increment counters } word_count:= word_count + 10; hit_count := hit_count + 1; hit_buf[hit_count]:=erp_channel; erp_ptr.int := erp_ptr.int - 20; wrd1_ptr.int := erp_ptr.int; wrd2_ptr.int := erp_ptr.int-2; erp_wrd1.word:=wrd1_ptr.pnt^; erp_wrd2.word:=wrd2_ptr.pnt^ end; { B/C/T/E/W/N/S planes handled here: } if (subid=0) OR (hit_count>1) then begin for i:= 1 to hit_count do begin { here we must find the WFD index for a given ERP channel} erp_channel:=hit_buf[i]; indx:=-1; if (erp_channel>0) AND (erp_channel<106) then indx := erp_wfd_index[erp_channel] ; { set the wfd hit register bit on} if (indx>-1) AND (indx < 23) then if (id = 25) then wfd_spr^::bit32[indx+20] := true else wfd_spr^::bit32[indx] := true; end; end; end; 27: case subid of { id = 27 is assigned to the CIT latch } 1: begin { subid = 1 handles the 1st pair of 16-bit patterns } { and it only checks the trigger bits (not activity) } wfd_spr^::bit32[0] := wfd_spr^::bit32[0] or pat^::bit32[0] or pat^::bit32[2] or pat^::bit32[4] or pat^::bit32[6]; wfd_spr^::bit32[1] := wfd_spr^::bit32[1] or pat^::bit32[1] or pat^::bit32[3] or pat^::bit32[5] or pat^::bit32[7]; wfd_spr^::bit32[2] := wfd_spr^::bit32[2] or pat^::bit32[16] or pat^::bit32[18] or pat^::bit32[20] or pat^::bit32[22]; wfd_spr^::bit32[3] := wfd_spr^::bit32[3] or pat^::bit32[17] or pat^::bit32[19] or pat^::bit32[21] or pat^::bit32[23]; end; 2: begin { subid = 2 handles the 2nd pair of 16-bit patterns } { and it only checks the trigger bits (not activity) } wfd_spr^::bit32[4] := wfd_spr^::bit32[4] or pat^::bit32[0] or pat^::bit32[2] or pat^::bit32[4] or pat^::bit32[6]; wfd_spr^::bit32[5] := wfd_spr^::bit32[5] or pat^::bit32[1] or pat^::bit32[3] or pat^::bit32[5] or pat^::bit32[7]; wfd_spr^::bit32[6] := wfd_spr^::bit32[6] or pat^::bit32[16] or pat^::bit32[18] or pat^::bit32[20] or pat^::bit32[22]; wfd_spr^::bit32[7] := wfd_spr^::bit32[7] or pat^::bit32[17] or pat^::bit32[19] or pat^::bit32[21] or pat^::bit32[23]; end; 3: begin { subid = 3 handles the 3rd pair of 16-bit patterns } { and it only checks the trigger bits (not activity) } { note that currently, bit-7 and bit-23 are unused } wfd_spr^::bit32[8] := wfd_spr^::bit32[8] or pat^::bit32[0] or pat^::bit32[2] or pat^::bit32[4] or pat^::bit32[6]; wfd_spr^::bit32[9] := wfd_spr^::bit32[9] or pat^::bit32[1] or pat^::bit32[3] or pat^::bit32[5]; wfd_spr^::bit32[10] := wfd_spr^::bit32[10] or pat^::bit32[16] or pat^::bit32[18] or pat^::bit32[20] or pat^::bit32[22]; wfd_spr^::bit32[11] := wfd_spr^::bit32[11] or pat^::bit32[17] or pat^::bit32[19] or pat^::bit32[21]; end; end; 30: {cspam/hipt/fmt} begin if (subid <> 0) then {make coincidence bits, uvax wfd ptrs} begin wptr0.lwptr := wfd_spr; wptr1.int := wptr0.int + longwords; p.int := eq30.int; for word:=0 to 10 do begin for i:=0 to 7 do cdat[word][i] := p.wptr^[2*i] and p.wptr^[2*i+1]; p.int := p.int + words; end; end; case subid of 0: {store pointer to equip data...at begin equip} begin eq30.lwptr := pat; eq30.int := eq30.int + longwords; end; 112: {uV1 csp12...call with sm=1 or 7} begin cspam_NS(wptr0,cdat[5],1); {1N} cspam_BC(wptr0,cdat[6],0); {1BC} cspam_BC(wptr1,cdat[6],2); {2BC} cspam_WE(wptr0,cdat[7],0); {1WE} cspam_WE(wptr1,cdat[7],2); {2WE} cspam_T(wptr0,cdat[8],0); {1T} cspam_T(wptr1,cdat[8],2); {2T} end; 123, {uV1 csp23...call with sm=2 or 8} 223: {uV2 csp23...call with sm=3 or 9} begin cspam_BC(wptr0,cdat[0],0); {2BC or 3BC} cspam_WE(wptr0,cdat[1],0); {2WE or 3WE} cspam_T(wptr0,cdat[2],0); {2T or 3T} end; 234: {uV2 csp34...call with sm=1 or 7} begin cspam_BC(wptr0,cdat[0],0); {3BC} cspam_BC(wptr1,cdat[0],2); {4BC} cspam_WE(wptr0,cdat[1],0); {3WE} cspam_WE(wptr1,cdat[1],2); {4WE cspam_T(wptr0,cdat[2],0); {3T} cspam_T(wptr1,cdat[2],2); {4T} end; 245: {uV2 csp45...call with sm=4 or 10} begin cspam_BC(wptr0,cdat[0],2); {4BC} cspam_WE(wptr0,cdat[1],2); {4WE} cspam_T(wptr0,cdat[2],2); {4T} end; 345: {uV3 csp45...call with sm=5 or 11} begin cspam_BC(wptr0,cdat[8],0); {5BC} cspam_WE(wptr0,cdat[9],0); {5WE} cspam_T(wptr0,cdat[10],0); {5T} end; 356: {uV3 csp56...call with sm=5 or 11} begin cspam_NS(wptr1,cdat[5],1); {6S} cspam_BC(wptr0,cdat[0],0); {5BC} cspam_BC(wptr1,cdat[0],2); {6BC} cspam_WE(wptr0,cdat[1],0); {5WE} cspam_WE(wptr1,cdat[1],2); {6WE} cspam_T(wptr0,cdat[2],0); {5T} cspam_T(wptr1,cdat[2],2); {6T} end; 1120: {uV1 hip12...call with sm=1 or 7} begin cspam_NS(wptr0,cdat[5],5); {1N-H} cspam_T(wptr0,cdat[8],4); {1T-H} cspam_T(wptr1,cdat[8],6); {2T-H} cspam_BC(wptr0,cdat[9],0); {1BC-H} cspam_BC(wptr1,cdat[9],2); {2BC-H} cspam_WE(wptr0,cdat[10],0); {1WE-H} cspam_WE(wptr1,cdat[10],2); {2WE-H} end; 1230, {uV1 hip23...call with sm=2 or 8} 2230: {uV2 hip23...call with sm=3 or 9} begin cspam_T(wptr0,cdat[2],4); {2T-H} cspam_BC(wptr0,cdat[3],0); {2BC-H} cspam_WE(wptr0,cdat[4],0); {2WE-H} end; 2340: {uV2 hip34...call with sm=3 or 9} begin cspam_T(wptr0,cdat[2],4); {3T-H} cspam_T(wptr1,cdat[2],6); {4T-H} cspam_BC(wptr0,cdat[3],0); {3BC-H} cspam_BC(wptr1,cdat[3],2); {4BC-H} cspam_WE(wptr0,cdat[4],0); {3WE-H} cspam_WE(wptr1,cdat[4],2); {4BC-H} end; 2450: {uV2 hip45...call with sm=4 or 10} begin cspam_T(wptr0,cdat[2],6); {4T-H} cspam_BC(wptr0,cdat[3],2); {4BC-H} cspam_WE(wptr0,cdat[4],2); {4WE-H} end; 3450: {uV3 hip45...call with sm=5 or 11} begin cspam_BC(wptr0,cdat[6],0); {5BC-H} cspam_WE(wptr0,cdat[7],0); {5WE-H} cspam_T(wptr0,cdat[10],4); {5T-H} end; 3560: {uV3 hip56...call with sm=5 or 11} begin cspam_T(wptr0,cdat[2],4); {5T-H} cspam_T(wptr1,cdat[2],6); {6T-H} cspam_BC(wptr0,cdat[3],0); {5BC-H} cspam_BC(wptr1,cdat[3],2); {6BC-H} cspam_WE(wptr0,cdat[4],0); {5WE-H} cspam_WE(wptr1,cdat[4],2); {6WE-H} cspam_NS(wptr1,cdat[5],5); {6S-H} end; end; {of subid case} end; {of eq30} end; {of id case} end; { The following 4 procedures are to make CSPAM/FMT/HIPT readout easier } { Their parameters are defined in the FORWARD definitions above. } { They set bits in the WFD pattern register for particular planes, based} { On bits set in the cspam/fmt/hipt equipment 30 data } { They are called with a pointer to the WFD longword to be set, the 8 } { bits of cspam coincidence bits to use, and an offset to the first bit} { of the cspam coincidence bits to use....there are separate routines for} { BC planes, WE planes, the T plane, and the NS planes } { CEL 11 Apr 95} procedure cspam_BC; begin {BH} wptr.b^[2] := wptr.b^[2] or cdat[offset+0]; wptr.b^[3] := wptr.b^[3] or cdat[offset+0]; {BL} wptr.b^[0] := wptr.b^[0] or cdat[offset+1]; wptr.b^[1] := wptr.b^[1] or cdat[offset+1]; {BH} wptr.b^[6] := wptr.b^[6] or cdat[offset+4]; wptr.b^[7] := wptr.b^[7] or cdat[offset+4]; {BL} wptr.b^[4] := wptr.b^[4] or cdat[offset+5]; wptr.b^[5] := wptr.b^[5] or cdat[offset+5]; end; procedure cspam_WE; begin {WH} wptr.b^[12] := wptr.b^[12] or cdat[offset+0]; wptr.b^[13] := wptr.b^[13] or cdat[offset+0]; {WL} wptr.b^[ 8] := wptr.b^[ 8] or cdat[offset+1]; wptr.b^[ 9] := wptr.b^[ 9] or cdat[offset+1]; {EH} wptr.b^[14] := wptr.b^[14] or cdat[offset+4]; wptr.b^[15] := wptr.b^[15] or cdat[offset+4]; {EL} wptr.b^[10] := wptr.b^[10] or cdat[offset+5]; wptr.b^[11] := wptr.b^[11] or cdat[offset+5]; end; procedure cspam_T; begin {TH} wptr.b^[18] := wptr.b^[18] or cdat[offset+0]; wptr.b^[19] := wptr.b^[19] or cdat[offset+0]; {TL} wptr.b^[16] := wptr.b^[16] or cdat[offset+1]; wptr.b^[17] := wptr.b^[17] or cdat[offset+1]; end; procedure cspam_NS; begin {N/S L} wptr.b^[20] := wptr.b^[20] or cdat[offset]; wptr.b^[21] := wptr.b^[21] or cdat[offset]; end;