;+
; NAME:
;     GET_CFG_STRUCT
; PURPOSE:
;     Define structure necessary for holding information from OVRO APC
;     config segment.
; CATEGORY:
;     OVRO APC DATA ANALYSIS
; CALLING SEQUENCE:
;     cfg = get_cfg_struct()
; INPUTS:
; OPTIONAL (KEYWORD) INPUT PARAMETERS:
; ROUTINES CALLED:
; OUTPUTS:
;     cfg     an empty config segment structure
; COMMENTS:
; SIDE EFFECTS:
; RESTRICTIONS:
; MODIFICATION HISTORY:
;     Written 13-Jan-1998 by Dale Gary
;     24-Jun-1998  DG
;       Added bx, by, bz and htdiff entries to structure.
;     16-Jul-2000  DG
;       Added MUXARR entry to structure
;     13-Jan-2001  DG
;       Added MUX sequence decoding
;     15-Jan-2002  DG
;       Added HACORR structure
;     04-Apr-2002  DG
;       Added CHANPHZ array
;     07-Nov-2002  DG
;       Added BLDIR array
;-
function get_cfg_struct

   cfg = {config, antype:         intarr(8),$  ;Antenna type (0=none,
                                               ;  1=27m, 2=2m equatorial,
                                               ;  3= 2m alt-az, 4=other)
                  antxyz:       lonarr(3,8),$  ;Nominal ant locations (mm)
                  muxarr:       intarr(8,8),$  ;Baseline type: 0=AB,1=CA,-1=BC
                  bx:           dblarr(8,8),$  ;Matrix of baseline x components (nsec)
                  by:           dblarr(8,8),$  ;Matrix of baseline y components (nsec)
                  bz:           dblarr(8,8),$  ;Matrix of baseline z components (nsec)
                  htdiff:       dblarr(8,8),$  ;Matrix of baseline height differences (nsec)
                  antpol:       intarr(2,8),$  ;Receiver poln codes (0=rcp,
                                               ;  1=lcp, 2=vert linear,
                                               ;  3=hor linear)
                  feedrot:        intarr(8),$  ;Feed rotation code
                                               ;  (0=equatorial fixed,
                                               ;   1=alt-az fixed)
                  intvalms:               0,$  ;Interrupt interval (ms)
                  sampintms:              0,$  ;Sample interval (ms)
                  msoff:        intarr(8,8),$  ;Time offset for chan ij (ms)
                  nintvals:     intarr(8,8),$  ;Number of integ for chan ij
                  momint:       intarr(8,8),$  ;First moment of I.T> for
                                               ;  channel ij
                  hifrqref:              0L,$  ;High freq reference (Hz)
                  plofrq:                0L,$  ;Phase lock reference (Hz)
                  dlamode:                0,$  ;Delay mode (0=fixed,
                                               ;  1=tracking,2=stepping)
                  dlastep:                0,$  ;Delay steps if delay mode 2
                  ndlacyc:                0,$  ;Number of cycles between
                                               ;  delay steps
                  dlacent:        intarr(8),$  ;Antenna delay centers (ns)
                  bedlaoff:       intarr(2),$  ;Backend channel delays (A,B)
                  ut1mutc:               0L,$  ;UT1-UTC (ms)
                  tdtmut1:               0L,$  ;TDT-UT1 (ms)
                  clockerr:              0L,$  ;Clock error (ms)
                  clockdrift:            0L,$  ;Clock drift (tbd)
                  zencoder:     lonarr(2,8),$  ;Encoder/secctor boundary
                                               ;  zeroes for each antenna
                  antoff:       lonarr(2,8),$  ;Fixed antenna offsets (mdeg)
                  aligntab:     lonarr(4,8),$  ;Antenna alignment parameters
                                               ;  for each ant (millideg)
                  refractivity:          0L,$  ;Nominal refractivity
                  muxseqid:              0L,$  ;MUX sequence number
                  nmux:                  0L,$  ;Number of elements in MUX sequence
                  pmuxseq:       ptr_new(0),$  ;Pointer to array of sequence entries
                  hodo:         lonarr(2,8),$  ;HO, DO offsets for each antenna
                  hacorr: {hacorr,          $  ;HACORR structure
                                n:intarr(2),$  ;  Number of non-zero values for each ant
                            ha:lonarr(2,32),$  ;  List of HA values at which to apply
                         corr:lonarr(2,32)},$  ; List of corrections
                  chanphz:      fltarr(8,8),$  ; Channel-based phases, differences for
                                               ;  each baseline according to AB, BC, or CA
                  bldir:     intarr(8,8)*0+1}  ; Baseline direction flag (BLDIR=+1 if
                                               ;  increasing 1-2 or 4-5, =-1 if 2-1 or 5-4)

return,cfg
end