C+
C	NAME:
C		WBS_STRUCT
C	PURPOSE:
C		Define the following WBS specific database structures
C			* WBS_QS_Instr_Rec         
C			* WBS_QS_Offset_Rec        
C			* WBS_QS_Del_Rec           
C			* WBS_QS_Conv1_Rec         
C			* WBS_QS_Conv2_Rec         
C			* WBS_Index_Rec            
C			* WBS_DHK_Data_Rec         
C			* WBS_PC_Data_Rec          
C			* WBS_PH_Data_Rec          
C			* WBS_RoadMap_Rec          
C
C	CALLING SEQUENCE:
C		WBS_STRUCT
C	HISTORY:
C		written by Mons Morrison, Fall 90.
C
C-
C	---------------------------------------------------------------

	STRUCTURE	/WBS_QS_Instr_Rec/
					!	NOT IMPLEMENTED AS OF 25-Mar-92]

	  integer*2	entry_type /'5011'x/
					! 00- Structure/Entry type

	  integer*4	st_time		! 02- Start time (millisec of day) entries are valid
	  integer*2	st_day		! 06- Start day (since 1-Jan-79)
	  integer*4	en_time		! 08- End time (millisec of day)
	  integer*2	en_day		! 12- End day (since 1-Jan-79)

	  byte		gain(32)	! 14- Gain information						W49 F32n+1,3,5,7,17,19,21,23

	  byte		spare(18)	! 46-
	END STRUCTURE			! 64- Total

	integer*4	nWBS_QS_Instr_Rec
	parameter	(nWBS_QS_Instr_Rec = 64)

	STRUCTURE	/WBS_QS_Offset_Rec/	! Start time (offset?) of 1st PC data
					!	NOT IMPLEMENTED AS OF 25-Mar-92]

	  integer*2	entry_type /'5021'x/
					! 00- Structure/Entry type

	  integer*4	st_time		! 02- Start time (millisec of day) entries are valid
	  integer*2	st_day		! 06- Start day (since 1-Jan-79)
	  integer*4	en_time		! 08- End time (millisec of day)
	  integer*2	en_day		! 12- End day (since 1-Jan-79)

	  integer*4	sxs_pc		! 14- SXS offset relative to the time in the main
					!     index record.  The units are in increments
					!     of 1 microsec.  The delay is mainly due 
					!     to the DP software.
	  integer*4	hxs_pc		! 18- hxs offset
	  integer*4	grs_pc1		! 22- grs1 offset
	  integer*4	grs_pc2		! 26- grs2 offset
	  integer*4	rbm_pc		! 30- rbm offset
	  integer*4	gbd_pc		! 34- gbd offset
	  integer*4	dhk		! 38- dhk offset

	  integer*2	solution_ver	! 42- Solution version

	  byte		spare(20)	! 44-
	END STRUCTURE			! 64 Total

	integer*4	nWBS_QS_Offset_Rec
	parameter	(nWBS_QS_Offset_Rec = 64)


	STRUCTURE	/WBS_QS_Del_Rec/	!Time between Samples
						![two values ? one for hi, one for med]

					!	NOT IMPLEMENTED AS OF 25-Mar-92]
	  integer*2	entry_type /'5031'x/
					! 00- Structure/Entry type

	  integer*4	st_time		! 02- Start time (millisec of day) entries are valid
	  integer*2	st_day		! 06- Start day (since 1-Jan-79)
	  integer*4	en_time		! 08- End time (millisec of day)
	  integer*2	en_day		! 12- End day (since 1-Jan-79)

	  integer*4	sxs_pc		! 14- SXS interval between samples in units of
					!     microseconds.  The values include 
					!     corrections for satellite clock variations.
	  integer*4	hxs_pc		! 18- hxs interval
	  integer*4	grs_pc1		! 22- grs1 interval
	  integer*4	grs_pc2		! 26- grs2 interval
	  integer*4	rbm_pc		! 30- rbm interval
	  integer*4	gbd_pc		! 34- gbd interval
	  integer*4	dhk		! 38- dhk interval

	  integer*2	solution_ver	! 42- Solution version

	  byte		spare(20)	! 44-
	END STRUCTURE			! 64 Total

	integer*4	nWBS_QS_Del_Rec
	parameter	(nWBS_QS_Del_Rec = 64)


	STRUCTURE	/WBS_QS_Conv1_Rec/	! Conversion Factors for PH data
					!	NOT IMPLEMENTED AS OF 25-Mar-92]
	  integer*2	entry_type /'5041'x/
					! 00- Structure/Entry type

	  integer*4	st_time		! 02- Start time (millisec of day) entries are valid
	  integer*2	st_day		! 06- Start day (since 1-Jan-79)
	  integer*4	en_time		! 08- End time (millisec of day)
	  integer*2	en_day		! 12- End day (since 1-Jan-79)

	  integer*4	sxs_ph0		! 14- energy * 0.01 keV
	  integer*4	sxs_phw		! 18- width  * 0.001 keV/ch
	  integer*4	hxs_ph0		! 22- base   * 0.01 sq(keV)
	  integer*4	hxs_phw		! 26- width  * 0.01 sq(keV)/ch
	  integer*4	hxs_chw		! 30- Factor * 0.001
	  integer*4	rbm_ph0		! 34- base   * 0.01 sq(keV)
	  integer*4	rbm_phw		! 38- width  * 0.01 sq(keV)/ch
	  integer*4	rbm_chw		! 42- Factor * 0.001
	  integer*4	grs1_ph0	! 46- base   * 0.01 sq(keV)
	  integer*4	grs1_phw	! 50- width  * 0.01 sq(keV)/ch
	  integer*4	grs1_chw	! 54- Factor * 0.01
	  integer*4	grs2_ph0	! 58- base   * 0.01 sq(keV)
	  integer*4	grs2_phw	! 62- width  * 0.01 sq(keV)/ch
	  integer*4	grs2_chw	! 66- Factor * 0.01
	  integer*4	grsh_ph0	! 70- energy *10.0 keV
	  integer*4	grsh_phw	! 74- width  * 1.00 keV/ch

	  integer*2	solution_ver	! 78- Solution version

	  byte		spare(48)	! 80-
	END STRUCTURE			!128 Total

	integer*4	nWBS_QS_Conv1_Rec
	parameter	(nWBS_QS_Conv1_Rec = 128)


	STRUCTURE	/WBS_QS_Conv2_Rec/	! Conversion Factors for AHK data
					!	NOT IMPLEMENTED AS OF 25-Mar-92]
	  integer*2	entry_type /'5051'x/
					! 00- Structure/Entry type

	  integer*4	st_time		! 02- Start time (millisec of day) entries are valid
	  integer*2	st_day		! 06- Start day (since 1-Jan-79)
	  integer*4	en_time		! 08- End time (millisec of day)
	  integer*2	en_day		! 12- End day (since 1-Jan-79)

	  integer*2	sxs_hv0		! 14- voltage * 0.1 volts
	  integer*2	sxs_hvc		! 16- voltage * 0.01 volts/chan
	  integer*2	hxs_hv0		! 18- voltage * 0.1 volts
	  integer*2	hxs_hvc		! 20- voltage * 0.01 volts/chan
	  integer*2	grs1_hv0	! 22- voltage * 0.1 volts
	  integer*2	grs1_hvc	! 24- voltage * 0.01 volts/chan
	  integer*2	grs2_hv0	! 26- voltage * 0.1 volts
	  integer*2	grs2_hvc	! 28- voltage * 0.01 volts/chan
	  integer*2	rbm_hv0		! 30- voltage * 0.1 volts
	  integer*2	rbm_hvc		! 32- voltage * 0.01 volts/chan
	  integer*2	sxst_tm0	! 34- temp * 0.01 degrees
	  integer*2	sxst_tmc	! 36- temp * 0.01 degrees/chan
	  integer*2	hxst_tm0	! 38- temp * 0.01 degrees
	  integer*2	hxst_tmc	! 40- temp * 0.01 degrees/chan
	  integer*2	grst_tm0	! 42- temp * 0.01 degrees
	  integer*2	grst_tmc	! 44- temp * 0.01 degrees/chan
	  integer*2	rbmt_tm0	! 46- temp * 0.01 degrees
	  integer*2	rbmt_tmc	! 48- temp * 0.01 degrees/chan

	  integer*2	solution_ver	! 50- Solution version

	  byte		spare(12)	! 52- 
	END STRUCTURE			! 64 Total

	integer*4	nWBS_QS_Conv2_Rec
	parameter	(nWBS_QS_Conv2_Rec = 64)

	STRUCTURE	/WBS_Index_Rec/
	  integer*2	index_version /'5011'x/
					!  0- Index structure version					Ground Info
					!	AAAABBBB CCCCDDDD

	  byte		pow_stat(2)	! 02- Power status						W48 F32n+2
					!	b7 = WBS HV enable/disable
					!	b6 = WBS on/off (set=on)
					!	b5 = WBS-A on/off (set=on)
					!	b4 = SXS-HV on/off (set=on)
					!	b3 = HXS-HV on/off (set=on)
					!	b2 = GRS-HV1 on/off (set=on)
					!	b1 = GRS-HV2 on/off (set=on)
					!	b0 = RBM-HV on/off (set=on)
	  byte		gbd_status1	! 04- [TODO - ADD INFO]						W50 F63
	  byte		gbd_status2	! 05- 								W50 F47
					!	b5   = block 1?
					!	b4   = block 0?
					!	b0:3 = ?
					!     [TODO - ADD INFO]
	  byte		PIOS(8,2)	! 06- WBS control
					!	(0,*) = GRS1 Control					W49 F32n+1
					!	   b6:7 = HV control
					!		00 = 750 V (default)
					!		01 = 720 V
					!		10 = 780 V
					!		11 = 810 V
					!	   b4:5 = Amp-L Gain
					!		00 = X1 (What is this? TODO??)
					!		01 = 1.11
					!		10 = 1.22
					!		11 = 1.33
					!	   b2:3 = Amp-H Gain
					!		00 = X1 (What is this? TODO??)
					!		01 = 1.11
					!		10 = 1.22
					!		11 = 1.33
					!	   b1   = CAL discriminator (set=60 keV, low=30 KeV)
					!	   b0   = CAL disabled/enabled
					!	(1,*) = GRS2 Control					W49 F32n+3
					!	   b6:7 = HV control
					!		00 = 700 V (default)
					!		01 = 670 V
					!		10 = 730 V
					!		11 = 760 V
					!	   b4:5 = Amp-L Gain
					!		00 = X1 (What is this? TODO??)
					!		01 = 1.11
					!		10 = 1.22
					!		11 = 1.33
					!	   b2:3 = Amp-H Gain
					!		00 = X1 (What is this? TODO??)
					!		01 = 1.11
					!		10 = 1.22
					!		11 = 1.33
					!	(2,*) HXS Control					W49 F32n+5
					!	   b6:7 = HV control
					!		00 = 730 V (default)
					!		01 = 700 V
					!		10 = 760 V
					!		11 = 790 V
					!	   b4:5 = Amp Gain
					!		00 = X1 (What is this? TODO??)
					!		01 = 1.13
					!		10 = 1.30
					!		11 = 0.43
					!	   b2   = MD Control (high=100 keV, low=50 keV)
					!	   b1   = CAL discriminator (high=1.0 MeV, low=0.5 MeV)
					!	   b0   = CAL enable/disable
					!	(3,*) = BC-DATA						W49 F32n+7
					!	(4,*) = RBM Control					W49 F32n+17
					!	   b6:7 = HV control
					!		00 = 1250 V (default)
					!		01 = 1200 V
					!		10 = 1300 V
					!		11 = 1350 V
					!	   b4:5 = Amp Gain
					!		00 = X1 (What is this? TODO??)
					!		01 = 1.15
					!		10 = 1.30
					!		11 = 0.55
					!	   b2:3 = SSD Discrimination levels
					!		00 = 20 keV (default)
					!		01 = 40 keV
					!		10 = 70 keV
					!		11 = 90 keV
					!	   b1   = MD Control (high=100 keV, low=50 keV)
					!	   b0   = SSD off/on 
					!	(5,*) = SXS1 Control					W49 F32n+19
					!	   b6:7 = HV control
					!		00 = 2300 V (default)
					!		01 = 2250 V
					!		10 = 2350 V
					!		11 = 24000 V
					!	   b4:5 = Amp Gain
					!		00 = X1 (What is this? TODO??)
					!		01 = 1.11
					!		10 = 1.22
					!		11 = 1.33
					!	   b2:3 = MD1 Control
					!		00 =  7.5 keV (default)
					!		01 = 10.0 keV
					!		10 = 12.5 keV
					!		11 = 15.0 keV
					!	   b0:1 = MD2 Control
					!		00 = 15.0 keV (default)
					!		01 = 20.0 keV
					!		10 = 25.0 keV
					!		11 = 30.0 keV
					!	(6,*) = SXS2 Control					W49 F32n+21
					!	   b7   = RBM Flag (set=on)
					!	   b4:5 = Amp Gain
					!		00 = X1 (What is this? TODO??)
					!		01 = 1.11
					!		10 = 1.22
					!		11 = 1.33
					!	   b2:3 = MD1 Control
					!		00 =  7.5 keV (default)
					!		01 = 10.0 keV
					!		10 = 12.5 keV
					!		11 = 15.0 keV
					!	   b0:1 = MD2 Control
					!		00 = 15.0 keV (default)
					!		01 = 20.0 keV
					!		10 = 25.0 keV
					!		11 = 30.0 keV
					!	(7,*) = BC-DATA						W49 F32n+23
	  byte		ahk_hv(5)	! 22- Analog house keeping (AHK) voltages			W32 F27,28,29,30,31
					!	(0) = SXS HV (0-5 V)
					!	(1) = HXS HV
					!	(2) = GRS HV1
					!	(3) = GRS HV2 
					!	(4) = RBM HV
	  byte		ahk_temp(4)	! 27- Analog house keeping (AHK) Temperatures			W32 F91,92,93,94
					!	(0) = SXS Temperature
					!	(1) = HXS Temperature
					!	(2) = GRS Temperature
					!	(3) = RBM Temperature
	  byte		bcs_a_temp	! 31- TODO - why is this here?					W32 F95

	  integer*2	sxs1		! 32- SXS2 channel 1 counts per sec.  (3-15 keV)		Derived
					!     Only SXS_PC21 are totaled
					!     NOTE: For reformatter Ver 1.06 and before,
					!           the data stored here was for PC12
	  integer*2	sxs2		! 34- SXS2 channel 2 counts per sec.  (15-40 keV)		Derived
					!     Only SXS_PC22 are totaled
					!     NOTE: For reformatter Ver 1.06 and before,
					!           the data stored here was for PC21
	  integer*2	hxs		! 36- HXS counts per sec.  (20-600 keV)				Derived
					!     HXS_PC1 and HXS_PC2 are totaled
					!     Data is decompressed first
	  integer*2	grs1		! 38- GRS1 counts per sec.  (0.2-0.7 MeV)			Derived
					!     GRS_PC11 and GRS_PC21 are totaled
					!     Data is decompressed first
	  integer*2	grs2		! 40- GRS2 counts per sec.  (0.7-4 MeV)				Derived
					!     GRS_PC12 and GRS_PC22 are totaled
					!     Data is decompressed first
	  integer*2	rbmsc		! 42- RBMSC counts per sec. (5-300 keV)				Derived
					!     PC1 and PC2 are totaled
	  integer*2	rbmsd		! 44- RBMSD counts per sec. (20 keV)				Derived
	  integer*2	unit_time	! 46- Unit time (in .01 sec)					Derived

	  byte		dataRecTypes	! 48- What data follows (set bits)
					!		b0 = wbs_dhk_data_rec
					!		b1 = wbs_pc_data_rec
					!		b2 = wbs_ph_data_rec
	  byte		nmf		! 49- "Which" major frames are in the following data
					!    		b0 = First half (even MF #s)
					!		b1 = Second half (odd MF #s)
					!	A value of (3) says there are 2 MF of data
	  byte		spare(14)	! 50
	END STRUCTURE			! 64- Total

	integer*4	nWBS_Index_Rec
	parameter	(nWBS_Index_Rec = 64)


	STRUCTURE	/WBS_DHK_Data_Rec/	!Digital House Keeping (DHK)
	  byte		sxs_ud1(8)	!   0- [add words - elaborate]					W67 F16n+0
	  byte		sxs_adct1(8)	!   8- [add words - elaborate]					W67 F16n+2
	  byte		sxs_ud2(8)	!  16- [add words - elaborate]					W67 F16n+1
	  byte		sxs_adct2(8)	!  24- [add words - elaborate]					W67 F16n+3
	  byte		hxs_ud(8)	!  32- [add words - elaborate]					W67 F16n+4
	  byte		hxs_adct(8)	!  40- [add words - elaborate]					W67 F16n+6
	  byte		hxs_cal(8)	!  48- [add words - elaborate]					W67 F16n+5
	  byte		grs_udh1(8)	!  56- [add words - elaborate]					W67 F16n+7
	  byte		grs_adclt1(8)	!  64- [add words - elaborate]					W67 F16n+10
	  byte		grs_adcht1(8)	!  72- [add words - elaborate]					W67 F16n+12
	  byte		grs_udh2(8)	!  80- [add words - elaborate]					W67 F16n+8
	  byte		grs_adclt2(8)	!  88- [add words - elaborate]					W67 F16n+11
	  byte		grs_adcht2(8)	!  96- [add words - elaborate]					W67 F16n+13
	  byte		grs_cal(8)	! 104- [add words - elaborate]					W67 F16n+9
	  byte		rbm_sc_ud(8)	! 112- [add words - elaborate]					W67 F16n+14
	  byte		rbm_sc_adct(8)	! 120- [add words - elaborate]					W67 F16n+15
	END STRUCTURE			! 128 Total

	integer*4	nWBS_DHK_Data_Rec
	parameter	(nWBS_DHK_Data_Rec = 128)


	STRUCTURE	/WBS_PC_Data_Rec/	!pulse count data
					!     Soft X-Ray Spectrometer (SXS)
	  integer*2	sxs_pc11(16)	! 00- SXS1 Detector, chan 1 (3-15 keV)				W96,W97 F8n+0
	  integer*2	sxs_pc12(16)	! 32- SXS1 Detector, chan 2 (15-40 keV)				W96,W97 F8n+1
	  integer*2	sxs_pc21(16)	! 64- SXS2 Detector, chan 1 (3-15 keV)				W96,W97 F8n+2
	  integer*2	sxs_pc22(16)	! 96- SXS2 Detector, chan 2 (15-40 keV)				W96,W97 F8n+3

					!     Hard X-Ray Spectrometer (HXS)
	  byte		hxs_pc1(32)	! 128- (20-60 keV)						W99 F4n+0
	  byte		hxs_pc2(32)	! 160- (60-600 keV)						W99 F4n+1

					!     Gamma-Ray Burst Detection (GBD)
	  byte		gbd_pc1(32)	! 192- [add words - elaborate]					W99 F4n+2
	  byte		gbd_pc2(32)	! 224- [add words - elaborate]					W99 F4n+3

					!      Gamma-Ray Spectrometer (GRS)
	  byte		grs_pc11(16)	! 256- (0.2-0.7 MeV)						W98 F8n+0
	  byte		grs_pc12(16)	! 272- (0.7-4.0 MeV)						W98 F8n+1
	  byte		grs_pc21(16)	! 288- (0.2-0.7 MeV)						W98 F8n+2
	  byte		grs_pc22(16)	! 304- (0.7-4.0 MeV)						W98 F8n+3
	  byte		grs_pc13(8)	! 320- (4-7 MeV)						W98 F16n+4
	  byte		grs_pc14(8)	! 328- (7-10 MeV)						W98 F16n+5
	  byte		grs_pc15(8)	! 336- (8-30 MeV)						W98 F16n+6
	  byte		grs_pc16(8)	! 344- (30-100 MeV)						W98 F16n+7
	  byte		grs_pc23(8)	! 352- (4-7 MeV)						W98 F16n+12
	  byte		grs_pc24(8)	! 360- (7-10 MeV)						W98 F16n+13
	  byte		grs_pc25(8)	! 368- (8-30 MeV)						W98 F16n+14
	  byte		grs_pc26(8)	! 376- (30-100 MeV)						W98 F16n+15

					!      Radiation Belt Monitor (RBM)
	  integer*2	rbm_sc_pc1(16)	! 384- NaI scintillation detector (5-60 keV)			W96,W97 F8n+4
	  integer*2	rbm_sc_pc2(16)	! 416- NaI scintillation detector (60-300 keV)			W96,W97 F8n+5
	  integer*2	rbm_sd_pc(16)	! 448- Si detector (20 kev)	 				W96,W97 F8n+6
	END STRUCTURE			! 480 Total

	integer*4	nWBS_PC_Data_Rec
	parameter	(nWBS_PC_Data_Rec = 480)


	STRUCTURE	/WBS_PH_Data_Rec/
	  byte		sxs_ph1(128,2)	!   0- SXS1 pulse height data (2-30 keV)
					!      Chan 0-127 for 1st MF, and 2nd MF
	  byte		sxs_ph2(128,2)	! 256- SXS2 pulse height data (2-30 keV)
					!      Chan 0-127 for 1st MF, and 2nd MF
	  byte		grs_phl1(128)	! 512- GRS pulse height data for lower channels (0.2-10 MeV)
					!      Chan 0-127 takes 2 MF to dump
	  byte		grs_phl2(128)	! 640- GRS pulse height data for lower channels (0.2-10 MeV)
					!      Chan 0-127 takes 2 MF to dump
	  byte		hxs_ph(32,4)	! 768- HXS pulse height data (20-400 keV)
					!      Chan 0-31 twice for 1st MF, and 2nd MF
	  byte		rbm_sc_ph(32,4)	! 896- NaI scintillation detector (5-300 keV)
					!      Chan 0-31 twice for 1st MF, and 2nd MF
	  byte		grs_phh1(16)	!1024- GRS pulse height data for higher channels (8-100 MeV)
					!      Chan 0-15							W96
	  byte		grs_phh2(16)	!1040- GRS pulse height data for higher channels (8-100 MeV)
	END STRUCTURE			!1056 Total

	integer*4	nWBS_PH_Data_Rec
	parameter	(nWBS_PH_Data_Rec = 1056)


	STRUCTURE	/WBS_RoadMap_Rec/
                                        !     For a full description of the fields,
                                        !     look at the Index_Rec definition

	  integer*4	ByteSkip	! 00- Starting byte of index rec

	  integer*4	time		! 04- Major frame time (millisec of day)
	  integer*2	day		! 08- Major frame day (since 1-Jan-79)	

	  byte		DP_mode		! 10- DP Mode
	  byte		DP_rate		! 11- DP Rate

	  byte		pow_stat	! 12- [add words - elaborate]
	  byte		flags		! 13- [add words - elaborate]

	  integer*2	sxs1		! 32- SXS2 channel 1 counts per sec.  (3-15 keV)
	  integer*2	sxs2		! 34- SXS2 channel 2 counts per sec.  (15-40 keV)
	  integer*2	hxs		! 36- HXS counts per sec.  (20-600 keV)
	  integer*2	grs1		! 38- GRS1 counts per sec.  (0.2-0.7 MeV)
	  integer*2	grs2		! 40- GRS2 counts per sec.  (0.7-4 MeV)
	  integer*2	rbmsc		! 42- RBMSC counts per sec. (5-300 keV)
	  integer*2	rbmsd		! 44- RBMSD counts per sec. (20 keV)
	  integer*2	unit_time	! 28- Unit time (in .01 sec)

	  byte		nmf		! 30- "Which" major frames are in the following data
	  byte		spare(1)	! 31
	END STRUCTURE			! 32 Total

	integer*4	nWBS_Roadmap_Rec
	parameter	(nWBS_Roadmap_Rec = 32)


	STRUCTURE       /WBS_Version_Rec/
          integer*2     roadmap /'50F2'x/
                                        ! 00- The version number of the Roadmap
                                        !     This value is not contained in the
                                        !     roadmap structure to save space.  It is
                                        !     saved in the "Pointer Record"
	  integer*2	data /'50E1'x/	! 02- Data section version number

                                        !     This structure is not written to any files
          byte          spare(12)       !     (need for automatic conversion to IDL format)
	END STRUCTURE

