pro bcs_struct, BCS_QS_Instr = BCS_QS_Instr,  $
                     BCS_QS_ModeInit = BCS_QS_ModeInit,  $
                     BCS_QS_Conv = BCS_QS_Conv,  $
                     BCS_QS_Group = BCS_QS_Group,  $
                     BCS_Index = BCS_Index,  $
                     BCS_DP_Sync = BCS_DP_Sync,  $
                     BCS_DPs_Head = BCS_DPs_Head,  $
                     BCS_Roadmap = BCS_Roadmap,  $
                     BCS_Version = BCS_Version
   
   
;+
;       NAME:
;               BCS_STRUCT
;       PURPOSE:
;               Define the following BCS specific database structures
;                       * BCS_QS_Instr_Rec          
;                       * BCS_QS_ModeInit_Rec          
;                       * BCS_QS_Conv_Rec          
;                       * BCS_QS_Group_Rec         
;                       * BCS_Index_Rec            
;                       * BCS_DP_Sync_Rec          
;                       * BCS_DPs_Head_Rec         
;                       * BCS_Roadmap_Rec          
;
;       CALLING SEQUENCE:
;               BCS_STRUCT
;       HISTORY:
;               written by Mons Morrison, Fall 90.
;
;-
   
   
BCS_QS_Instr = { BCS_QS_Instr_Rec,              $
      entry_type : FIX('2011'x),  $          ;
                                             ; 00- Structure/Entry type
                                             ;
      st_time: LONG(0),  $                   ; 02- Start time (millisec of day) of valid data
      st_day: FIX(0),  $                     ; 06- Start day (since 1-Jan-79)
      en_time: LONG(0),  $                   ; 08- End time (millisec of day)
      en_day: FIX(0),  $                     ; 12- End day (since 1-Jan-79)
                                             ;
                                             ;     _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
      SCAval: BYTARR(2,4),  $                ; 14- Upper and lower channel SCA settings                      W49 F32
                                             ;       (Channel, 0=lower)                                             
                                             ;       (channel, 1=upper)
      hv_control: BYTE(0),  $                ; 22- HV control (commanded)                                    W49 F32
                                             ;       b0:2 = trim for HVA
                                             ;       b4:6 = trim for HVB
                                             ;       NOTE: Changes in one orbit during a cal
      stim_control: BYTE(0),  $              ; 24- Stimulus on/off                                           W49 F32
                                             ;       b0   = Detector A internal stim generator (set=off)
                                             ;       b1   = Detector A stim source (set=internal)
                                             ;       b2   = Detector A multiplexor (set=disable)
                                             ;       b4   = Detector B internal stim generator (set=off)
                                             ;       b5   = Detector B stim source (set=internal)
                                             ;       b6   = Detector B multiplexor (set=disable)
                                             ;     _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
      Fe26_thresh: BYTE(0),  $               ; xx- Fe XXVI threshold                                         W66 F28
                                             ;       value*16 = actual threshold counts
      chan_mfd: BYTE(0),  $                  ; xx- Channels selected and min flare duration                  W66 F28
                                             ;       LSB = b0
                                             ;       b5:7 = SAA Algorithm channel
                                             ;       b4:5 = Flare algorithm channel
                                             ;       b0:3 = Mininum flare duration
      SAA_Thresh: BYTE(0),  $                ; xx- SAA Threshold                                             W66 F29
                                             ;       value*16 = actual threshold counts
      Flr_RiseThresh: BYTE(0),  $            ; xx- Flare rise threshold                                      W66 F30
                                             ;       value*16 = actual threshold counts
      Flr_DecayThresh: BYTE(0),  $           ; xx- Flare decay threshold                                     W66 F31
                                             ;       value*16 = actual threshold counts
      Flr_OptionID: BYTE(0),  $              ; xx- Flare Option ID                                           W66 F63
                                             ;     _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
                                             ;
      sensitivity: BYTARR(4),  $             ; 26- Det. Sensitivity (Nominal Val= 200)                       Ground 
      posGain: LONARR(4),  $                 ; 30- Position Gain for det (Angstrom/Bin)                      Ground 
      posOffset: LONARR(4),  $               ; 46- Position Offsets. (micro-Angstrom)                        Ground 
                                             ;       NOTE that the Gain and offset are the 
                                             ;       slope and intercept of the line giving 
                                             ;       the conversion between bin numbers and 
                                             ;       wavelength.
                                             ;
      bcs2dp_ver: FIX(0),  $                 ; 62- Algorithm and parameters used to convert                  Ground 
                                             ;       between BCS timer and DP timer
      spare: BYTARR(12) }                    ; 64-
   
   
   
BCS_QS_ModeInit = { BCS_QS_ModeInit_REC,              $
      entry_type : FIX('2021'x),  $          ;
                                             ; 00- Structure/Entry type
                                             ;
      SequenceDef: BYTARR(15),  $            ; 02- Definition of current sequence                            Mode Bl
                                             ;        (0) = Sequence ID
                                             ;        (1) = Mode A Grouper List ID
      Flr_Option: BYTARR(6),  $              ; 17- Definition of flare option being used                     Mode Bl
      GFlr_SeqID: BYTE(0),  $                ; 23- Great Flare sequence ID                                   Mode Bl
      Fe26_Thresh: BYTE(0),  $               ; 24- Fe XXVI Threshold                                         Mode Bl
      Fe26_SeqID: BYTE(0),  $                ; 25- Fe XXVI Sequence ID                                       Mode Bl
      Fe26_FlareOpt: BYTE(0),  $             ; 26- Fe XXVI Flare Option                                      Mode Bl
                                             ;
      spare: BYTARR(5) }                     ; 27- Spare
   
   
   
BCS_QS_Conv = { BCS_QS_Conv_Rec,              $
      entry_type : FIX('2031'x),  $          ;
                                             ; 00- Structure/Entry type
                                             ;
      st_time: LONG(0),  $                   ; 02- Start time (millisec of day) entries are valid
      st_day: FIX(0),  $                     ; 06- Start day (since 1-Jan-79)
      en_time: LONG(0),  $                   ; 08- End time (millisec of day)
      en_day: FIX(0),  $                     ; 12- End day (since 1-Jan-79)
                                             ;
      hv_conv: LONARR(2),  $                 ; 14- Conversion for high voltage in 0.01 KeV
                                             ;       (0) = intercept; (1) = slope
                                             ;       NOT IMPLEMENTED AS OF 25-Mar-92]
      temp_conv: LONARR(2),  $               ; 22- Conversion for temperature in 0.01 deg.
                                             ;       NOT IMPLEMENTED AS OF 25-Mar-92]
                                             ;
      solution_ver: FIX(0),  $               ; 30- Solution version
                                             ;       NOT IMPLEMENTED AS OF 25-Mar-92]
                                             ;
      spare: BYTARR(32) }                    ; 32-
   
   
   
BCS_QS_Group = { BCS_QS_Group_Rec,              $
      entry_type : FIX('2041'x),  $          ;
                                             ; 00- Structure/Entry type
                                             ;
                                             ;   - No starting and ending times are needed for the
                                             ;     grouper plan.
      time: LONG(0),  $                      ; 02- Creation time in msod
      day: FIX(0),  $                        ; 06- Creation date in days since 1-Jan-1979
                                             ;
      length: FIX(0),  $                     ; 08- Total No of bytes of data created by the plan
      ModeID: FIX(0),  $                     ; 10- The modeID that is described
      ngrp: BYTARR(4),  $                    ; 12- Number of groups for each channel
      groups: INTARR(10,4),  $               ; 16- The Grouper plan for each channel
                                             ;       groups(*,ichan) = [nout1,nbin1, nout2,nbin2, nout3,nbin3, ...]
                                             ;               where ichan is then channel in question
                                             ;                       nout1 is the number of output values
                                             ;                       nbin1 is the number of raw input values binned
      spare: BYTARR(32) }                    ; 96- Spare
   
   
   
BCS_Index = { BCS_Index_Rec,              $
      index_version : FIX('2011'x),  $       ;
                                             ; 00- Index structure version
                                             ;
      dp_time_out: BYTARR(4),  $             ; 02- DP time (timer1,2,3 and FI) for when
                                             ;     the data is read out
                                             ;     Use this time to check the state of the
                                             ;     Spacecraft during readout - see 
                                             ;     BCS_DP_Sync_Rec structure
                                             ;
                                             ;     _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
      blockID: BYTE(0),  $                   ; 06- BCS Block ID                                              Derived
                                             ;      =0: Normal Queue Data Block
                                             ;      =1: Fast Queue Data Block
                                             ;      =2: Micro Dump Block (fixed extraction)
                                             ;          Reformatter forces this mode whenever the
                                             ;          CPU is disabled
                                             ;      =3: Cal Data Block (fixed extraction)
                                             ;      =4: Queue data where the modeID in the
                                             ;          header is not recognized.
                                             ;      =5: Normal or fast queue data which have fill
                                             ;          data (garabage).  Avoid this value to avoid
                                             ;          these datasets when making light curves.
                                             ;
      ModeID: BYTE(0),  $                    ; 09- Mode ID (Grouper Plan)                                    Mode He
                                             ;       For "Normal" and "Fast" queue data
                                             ;       (BlockID = 0 or 1) this value is the
                                             ;       ModeID used in conjunction with the
                                             ;       grouper plan.
                                             ;
                                             ;       If the mode ID is not recognized, then
                                             ;       it is set to 255, and the mode header
                                             ;       is put out with the beginning of the 
                                             ;       data.
                                             ;
                                             ;       For "Cal Mode" (BlockID = 3)
                                             ;       this holds the channel number as
                                             ;       derived from PHA_CONTROL with a
                                             ;       1.5 major frame delay
                                             ;               b4:7 = first 256 bytes
                                             ;               b0:3 = last 256 bytes
                                             ;       Value = 1,2,3,4
                                             ;       Value = 0 if unknown (data dropouts)
      ModeRepNum: BYTE(0),  $                ; 10- Mode Repeat Number                                        Mode He
      ControlTally: BYTE(0),  $              ; 11- Control Byte Tally                                        Mode He
                                             ;     
      ControlByte: BYTE(0),  $               ; 12- Control Byte                                              Mode He
                                             ;
      dgi: BYTE(0),  $                       ; 13- Data Gather Interval (125 msec units)                     Mode He
                                             ;       For "Cal Mode" (BlockID = 3)
                                             ;       this value comes from                                   W49 F22
      nSampPChan: INTARR(4),  $              ; 14- Number of data samples per channel                        (From G
                                             ;
      total_cnts: INTARR(4),  $              ; 22- Total counts in each channel for the mode                 Derived
                                             ;     Saved counts have been divided by 10 to
                                             ;     to avoid overflow problems
                                             ;
      DP_Flags: BYTE(0),  $                  ; 30- DP Flags received by BCS                                  Mode He
                                             ;       b0      = Radiation Belt monitor (set = yes)
                                             ;       b1,2    = 0,0: No flare
                                             ;               = 1,0: Normal Flare
                                             ;               = 1,1: Great Flare
                                             ;               = 0,1: BCS MEM Mode
                                             ;       b3,4    = 0,0: Low (1 kps)
                                             ;               = 1,0: Med (4 kps)
                                             ;               = 0,1: Hi (32 kps)
                                             ;               = 1,1: Hi (32 kps)
                                             ;       b5      = BCS-OUT after flare (set = enable)
                                             ;       b6      = BCS-OUT after night (set = enable)
                                             ;       b7      = Currently BCS-OUT mode 
      BCS_Status: BYTE(0),  $                ; 31- BCS Status                                                Mode He
                                             ;       b0 = SAA Threshold exceeded (set = yes)
                                             ;       b1 = Flare threshold exceeded (set = yes)
                                             ;       b2 = HVU's turned off by BVS SAA algorithm
                                             ;       b3 = Fe XXVI thershold exceeded
                                             ;       b4 = BCS is in night state
                                             ;       b5 = BCS is in SAA state
                                             ;       b6 = Status of data in queue (set = hi)
                                             ;       b7 = Status of BCS flare flag (set = hi)
                                             ;
      MissBasicData: BYTE(0),  $             ; 32- Flag to mark if the DP major frames                       Derived
                                             ;     for the period when the data was taken
                                             ;     were telemetered down (set = got the data)
                                             ;       (ie: got the basic part data for
                                             ;       the period when the data was taken)
      MissModeID: BYTE(0),  $                ; 33- Missing the beginning of the data which                   Derived
                                             ;     has the mode ID so all information is
                                             ;     guessed.
                                             ;
      length: FIX(0),  $                     ; 35- Total No of bytes of data created by the plan
                                             ;     This is the array length of the output vector
                                             ;     which holds all of the channels.  This is the
                                             ;     true length, where INDEX.GEN.NDATABYTES is the
                                             ;     number of bytes written to the disk, which could
                                             ;     have padded zeros.
      spare: BYTARR(14) }                    ; 34- Spare bytes
   
   
   
BCS_DP_Sync = { BCS_DP_Sync_Rec,              $
      index_version : FIX('2022'x),  $       ;
                                             ; 00- Index structure version
                                             ;
      time: LONG(0),  $                      ; 02- Time (ms of day) of major frame during readout
      day: FIX(0),  $                        ; 06- Day since 1-Jan-79 or major frame during readout
                                             ;
      dp_time: BYTARR(4),  $                 ; 08- DP time (timer1,2,3 and FI) for when
                                             ;     the data is read out
                                             ;     (see Gen_Index for an explanation of the values)
      DP_mode: BYTE(0),  $                   ; 12- DP Mode during the readout 
                                             ;     (see Gen_Index for an explanation of the values)
      DP_rate: BYTE(0),  $                   ; 13- DP Rate during readout 
                                             ;     (see Gen_Index for an explanation of the values)
      Flare_Control: BYTE(0),  $             ; 14- Flare flag control during readout 
                                             ;     (see Gen_Index for an explanation of the values)
      Flare_Status: BYTARR(4),  $            ; 15- Flare flag status during readout 
                                             ;     (see Gen_Index for an explanation of the values)
      RBM_Status: BYTE(0),  $                ; 19- Radiation Belt Montitor Status
                                             ;     (see Gen_Index for an explanation of the values)
      Telemetry_mode: BYTE(0),  $            ; 20- Telemetry mode                   
                                             ;     (see Gen_Index for an explanation of the values)
      cal_status: BYTE(0),  $                ; 21- CAL status                       
                                             ;     (see Gen_Index for an explanation of the values)
                                             ;
                                             ;     _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
                                             ;
      All_Cnts: INTARR(4,2),  $              ; 22- All counts for the 4 channels                             W66 F00
                                             ;                                                               W66 F32
                                             ;     Units = counts per "Acc_Interval" (see below)
      Lim_Cnts: INTARR(4,2),  $              ; 38- Limited for the 4 channels                                W66 F02
                                             ;                                                               W66 F34
                                             ;     Units = counts per "Acc_Interval" (see below)
      Acc_Cnts: INTARR(4,2),  $              ; 54- Accepted for the 4 channels                               W66 F04
                                             ;                                                               W66 F36
                                             ;   NOTE: For All_Cnts, Lim_Cnts, and Acc_cnts
                                             ;       the following applies
                                             ;     Units = counts per "Acc_Interval" (see below)
                                             ;       Cnts(n,m)       n = channel
                                             ;                       m = 2 per major frame
                                             ;       The onboard counter is an unsigned 16-bit counter
                                             ;       The reformatted data is saved as a signed 16-bit value
                                             ;       If the value is negative, then 65536 (which is 2^16)
                                             ;       needs to be added to the value.
      Acc_interval: INTARR(2),  $            ; 70- Accumulation interval (sec)                               Derived
                                             ;     This value is only relevant for the differences
                                             ;     made to the PREVIOUS major frame for all_cnts(*,0)
                                             ;     Since there are two values dumped each major frame, 
                                             ;     the delta within the single major frame all_cnts(*,1)
                                             ;     is defined by the DP_RATE for that major frame.
                                             ;       Valid values are:
                                             ;               0 = Raw number (not counts/sec)
                                             ;                   Implies dropout for previous major frame
                                             ;               8 sec = 1/2 * 16 sec (med rate)
                                             ;               1 sec = 1/2 * 2 sec (high rate)
                                             ;               ? sec = transition high to med- TODO
                                             ;               ? sec = transition med to high - TODO
                                             ;     _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
                                             ;
      pha_counts: BYTARR(8),  $              ; 74- PHA Data                                                  W66 F24
                                             ;                                                                   F56
      PHA_Control: BYTARR(2),  $             ; 82- PHA Control                                               W49 F32
                                             ;     _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
      SpecStatus: BYTARR(2),  $              ; 84- Spectrometer status                                       W112 F3
                                             ;       b0 = Calibibration-B (set=enabled)
                                             ;       b1 = HVB logical flag (set=enabled)
                                             ;       b2 = HVB power (set=on)
                                             ;       b3 = Spectrometer B (set=on)
                                             ;       b4 = Calibibration-A (set=enabled)
                                             ;       b5 = HVA logical flag (set=enabled)
                                             ;       b6 = HVA power (set=on)
                                             ;       b7 = Spectrometer A (set=on)
      CommandStat: BYTARR(2),  $             ; 86- Command Status                                            W112 F3
                                             ;       b0 = Command decode (set=disabled)
                                             ;       b1 = Program address set (set=disabled)
                                             ;       b2 = Program load (set=disabled)
                                             ;       b3 = CPU processor (set=disabled)
                                             ;       b4 = Low RAM (set=enable)
                                             ;       b5 = Watchdog Timer (set=disabled)
                                             ;       b6 = Block Command (BC) (set=enable)
                                             ;       b7 = Digital Electronics (set=on)
                                             ;
      cpu: BYTARR(4,2),  $                   ; 88- Microprocessor information/diagnostics                    W66 F28
                                             ;                                                                   F60
                                             ;     Has the clock value to tie the DP clock
                                             ;     to the BCS clock.
                                             ;
                                             ;     _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
      HV_mon: BYTARR(2),  $                  ; 96- HV monitor voltage (0-255)                                W32 F32
                                             ;       SF2n ==> changes every 2 MF!!?!?!
                                             ;     (See quasi-static section for conversions)
      crytemp: BYTARR(2),  $                 ; 98- Crystal Bank Temperatures (milli-Celsius)                 W32 F31
                                             ;     (See quasi-static section for conversions)
      Elec_Temp: BYTE(0),  $                 ;100- Electronics temperature                                   W32 F33
                                             ;     (See quasi-static section for conversions)
      spare: BYTARR(11) }                    ;101
   
   
   
BCS_DPs_Head = { BCS_DPs_Head_Rec,              $
      index_version : FIX('2031'x),  $       ;
                                             ; 00- Index structure version
                                             ;
      nEntries: FIX(0),  $                   ;  2- Number of BCS_DP_Sync_Rec to follow
                                             ;
      spare: BYTARR(12) }                    ;  4- Spares
   
   
   
BCS_Roadmap = { BCS_Roadmap_Rec,              $
                                             ;     For a full description of the fields,
                                             ;     look at the Index_Rec definition
                                             ;
      ByteSkip: LONG(0),  $                  ; 00- Offset in bytes from the beginning of
                                             ;     of the data file for the beginning
                                             ;     of the data set index structure.
                                             ;
      time: LONG(0),  $                      ; 04- Time of data (millisec of day)
      day: FIX(0),  $                        ; 08- Day of data (since 1-Jan-79)
                                             ;
      blockID: BYTE(0),  $                   ; 10- BCS Block ID                                              Derived
      seqID: BYTE(0),  $                     ; 11- Observation Sequence ID
      ModeID: BYTE(0),  $                    ; 12- Mode ID (Grouper Plan)
      moderepnum: BYTE(0),  $                ; 13- Mode Repeat Number
      dgi: BYTE(0),  $                       ; 14- Data Gather Interval (125 msec units)
      DP_Flags: BYTE(0),  $                  ; 15- DP Flags received by BCS                                  (From M
      BCS_Status: BYTE(0),  $                ; 16- BCS Status                                                (From M
                                             ;
      total_cnts: INTARR(4),  $              ; 17- Total counts in each channel for the mode
                                             ;
      length: FIX(0),  $                     ; 25- Total No of bytes of data created by the plan
      ControlTally: BYTE(0),  $              ; 27- Control Byte Tally
                                             ;
      spare: BYTARR(4) }                     ; 28- Spares
   
   
   
BCS_Version = { BCS_Version_Rec,              $
      roadmap : FIX('20F1'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 "File Header Record"
                                             ;
                                             ;     This structure is not written to any files
      spare: BYTARR(14) }                    ;     (need for automatic conversion to IDL format)
   
   
   
  
  
end
