;+
; Project     : SOHO - CDS     
;                   
; Name        : PREPARE_FT
;               
; Purpose     : Writes a script file to load the current solar feature
;               tracking parameters when artificially fast tracking is
;               required.
;               
; Explanation : For test purposes only.
;               
; Use         : IDL> fast_ft
;    
; Inputs      : None
;               
; Opt. Inputs : None
;               
; Outputs     : Write file to $CDS_TCL_FTRACK
;               
; Opt. Outputs: None
;               
; Keywords    : None
;
; Calls       : None
;
; Common      : None
;               
; Restrictions: Needs CDS_TCL_FTRACK to be defined and to have write access
;               
; Side effects: None
;               
; Category    : Commanding
;               
; Prev. Hist. : None
;
; Written     : C D Pike, RAL, 30_Apr-96
;               
; Modified    : Add differential rotation and INTERVAL.  CDP, 14-May-96
;               Get parameters from database.  CDP, 22-Jul-96
;               Increase track rate and decrease time interval. CDP 31-Jul-96
;
; Version     : Version 4, 31-Jul-96
;-            

pro  fast_ft

;
;  is env. variable set?
;
if getenv('CDS_TCL_FTRACK') eq '' then begin
   print,'$CDS_TCL_FTRACK is not defined.'
   return
endif


;
;  test open output file
;
ofile = concat_dir('$CDS_TCL_FTRACK','cb2feat.fast.dt')
openw,lun,ofile,/get_lun,error=err
if err ne 0 then begin
   print,'Error opening CB2FEAT output file.'
   return
endif
free_lun, lun


;
;  get pointing parameters
;
s = cp_get_mnemonic('CB2POINT', /QUIET )
ss = cp_get_indeces(s,[4,8,10])
ops_k = ss(0).active
ops_ltheta = ss(1).active
ops_lphi   = ss(2).active
 

;
;  prepare variable values
;
get_utc,utc
dt = anytim2cal(utc)
spar = pb0r(utc,/soho,/arc)
sb0 = longhex(round(spar(1)*3600.))

;
;  prepare text
;
text = strarr(25)
text(0)  = '# cb2feat.fast.dt'
text(1)  = '# Fast feature tracking parameters.'
text(2)  = '# Written by FAST_FT on '+dt
text(3)  = '#'
text(4)  = '# OPS K length'
text(5)  = trim(ops_k)
text(6)  = '0x0'
text(7)  = '# OPS theta angle'
text(8)  = trim(ops_ltheta)
text(9)  = '0x0'
text(10) = '# OPS phi angle'
text(11) = trim(ops_lphi)
text(12) = '0x0'
text(13) = '# Update time (in 64 us) == 0.5 sec'
text(14) = '0x1e84'
text(15) = '0x0000'
text(16) = '# solar radius (arcsecs)'
text(17) = trim(round(spar(2)))
text(18) = '0x0'
text(19) = '# solar B angle (arcsecs)'
text(20) = '0x'+strmid(sb0,6,4)
text(21) = '0x'+strmid(sb0,2,4) 
text(22) = '# solar angular velocity (arcsecs/hour)
text(23) = '0x968c'
text(24) = '0x0023'

;
;  write file
;
print_str,text, file=ofile, /keep, /quiet

return
end

