#! /bin/csh -f
# option -f to avoid running .cshrc and override PATH set with setmod
#*************************************************************************
# E.S.O. - VLT project
#
# "@(#) $Id: guidecamLite,v 1.25.1.6 2005/12/09 18:38:46 vltsccm Exp $"
#
# who       when      what
# --------  --------  ----------------------------------------------
# mcomin    29/11/96  created
# 

#************************************************************************
#   NAME
#   guidecamStart.sh - start the TCS Real Time Display
# 
#   SYNOPSIS
#   guidecamStart.sh -camera <camera> -env <WS env.>  -lcuEnv <LCU env.> 
#       -insroot <INS root> -agProc <proc name> -tcsEnv <tcs env. name>
#       -tcsProc <proc name> -cat 
# 
#   DESCRIPTION
#   This shell script pops up the TCS Real Time Display.
#   
#   -camera  <camera>     camera name, also root point in DB 
#                        (default env. var. CCDNAME)
#   -cat                 Switch to activate the catalog menu.
#                        (By default the menu does not appear)
#   -env     <WS env.>   Local environment (default env. var. RTAPENV)
#   -lcuEnv  <LCU env.>  LCU environment (default env. var. CCDLENV)
#   -insroot <INS root>  INS_ROOT environment variable
#   -agProc  <proc name> Name of the autoguide process.
#   -tcsEnv  <env. name> Name of the environment where tcs runs
#   -tcsProc <proc name> Name of the TCS control process
#
#   FILES
#
#   ENVIRONMENT
#
#   CCDNAME      default for camera name (e.g. ccdFors)
#   RTAPENV      default for WS local environment (e.g. wte13)
#   CCDLENV      default for LCU environment (e.g lte25) 
#   INS_ROOT     default root directory for instrument data 
#   INS_USER     default SYSTEM
#   RTD_LIBRARY  Path to the rtd tcl widget library
#
#   RETURN VALUES
#
#   CAUTIONS
#
#   EXAMPLES
#
#   Start TCS Real Time Display with the "tccds" camera on environments wte67 
#   (WS) and lte14 (LCU).
#
#   guidecamStart.sh -camera tccds -cat -env wte67 -lcuEnv lte14
#                     -agProc agwsControl
#
#   SEE ALSO
#
#   BUGS     
#
#------------------------------------------------------------------------
#

#
# set environment variables (if not yet done)
#

if (!($?TCSENV)) then
   # If TCSENV is not defined, take RTAPENV or set it to dummy
   if (!($?RTAPENV)) then
      set tcsEnv     = dummy
   else
      set tcsEnv     = ${RTAPENV}
   endif

else 
  set tcsEnv     = ${TCSENV}
endif


set agProcName = agwsControl
set tcsProc    = tifCA
set catFlag    = 1
set debugFlag  = 0
 
@ idx = 1

while ( $idx <= $#argv )

    switch ($argv[$idx])

       case -cat :
         set catFlag = 1
         breaksw

       case -camera :
         @ idx++
         setenv CCDNAME $argv[$idx] 
         breaksw

       case -env
         @ idx++
         setenv RTAPENV $argv[$idx] 
         breaksw

       case -lcuEnv :
         @ idx++
         setenv CCDLENV $argv[$idx] 
         breaksw

       case -insroot :
         @ idx++
         setenv INS_ROOT $argv[$idx] 
         breaksw

       case -agProc :
         @ idx++
         set agProcName = $argv[$idx]
         breaksw

       case -tcsEnv :
         @ idx++
         set tcsEnv = $argv[$idx]
         breaksw

       case -tcsProc :
         @ idx++
         set tcsProc = $argv[$idx]
         breaksw

       default :
         echo "parameter list : "
         echo "$argv[*]"
         echo "Illegal Option ($argv[$idx])"
         exit
    endsw

    @ idx++
end

#
# set environment variables (Default Values ...if not yet defined )
#

if (!($?CCDDID)) then
  setenv CCDDID CCDDCS
endif

if (!($?CCDNAME)) then
  setenv CCDNAME tccds
endif

if (!($?RTAPENV)) then
  setenv RTAPENV tccds
endif

if (!($?CCDLENV)) then
  setenv CCDLENV lte14
endif

if (!($?INS_ROOT)) then
  setenv INS_ROOT /diskb/introot/alo_insroot
endif

if (!($?INS_USER)) then
  setenv INS_USER SYSTEM
endif

if (!($?RTD_LIBRARY)) then

   if (!($?SKYCATDIR)) then
      setenv RTD_LIBRARY /usr/local/lib/rtd
   else 
      setenv RTD_LIBRARY $SKYCATDIR/lib/rtd
   endif

endif

guidecamMain -agProcName $agProcName -tcsEnvName $tcsEnv -cat $catFlag -tcsProc $tcsProc& 
#
# ___oOo___
