;+
; Project     :	SOHO - CDS
;
; Name        :	GET_HOME_POS
;
; Purpose     : Recovers the home position from the CDHS state database.
;
; Explanation :	Definition of the home position may change.
;
; Use         : <struct = get_home_pos ()>
;
; Inputs      : None
;
; Opt. Inputs : None.
;
; Outputs     : struct = structure containing home position information
;               The structure  {state_structure} has the tags :
;                  .mode    : character indicating CDHS mode
;                                   'B' = Ready BOTH
;                                   'G' = Ready GIS      
;                                   'N' = Ready NIS     
;                                   'X' = Unknown.    
;                  .solarx  : integer giving solar x position (arcsecs)
;                  .solary  : integer giving solar y position (arcsecs)
;                  .slitn   : integer giving slit number      
;                  .gsetid  : integer giving GSET database ID                       
;               Assumes for now that mode is READY BOTH.
;
; Opt. Outputs:	None.
;
; Keywords    : None.
;
; Calls       :	cp_get_mnemonic, cp_get_indeces, ops_point.
;                
; Common      :	None.
;
; Restrictions:	None.
;
; Side effects:	None.
;
; Category    :	Command preparation.
;
; Prev. Hist. :	None.
;
; Written     :	Version 0.0, Martin Carter, RAL, 14/8/95
;
; Modified    :	Version 0.1, MKC, 4/9/95
;                 Changed so that returns short ints in state structure
;               Version 0.2, MKC, 2/11/95
;                 Changed so that detector is now a character.
;               Version 0.3, MKC, 7/11/95
;                 Modified to use cp_get_entry.
;                 Added gsetid.
;
; Version     :	Version 0.3, 7/11/95
;-
;**********************************************************

FUNCTION get_home_pos

  ; get ops and slit number home positions

  ss = cp_get_entry ( 'CB2POSN', [2,3,4] )

  ; constants

  opsl_home  = ss(0).active ; ops left    home position
  opsr_home  = ss(1).active ; ops right   home position
  slitn_home = ss(2).active ; slit number home position

  ; calculate solar x and y home positions

  ops_point, FIX(opsl_home), FIX(opsr_home), solx_home, soly_home

  ; return state_structure

  RETURN, { state_structure, mode:'B', solarx:FIX(solx_home), solary:FIX(soly_home), $
                             slitn:FIX(slitn_home), gsetid:0}

END
