#! /bin/csh -f
#==============================================================
#
#  Abs:  Starts a Feedback  Matlab application
#
#  Name: FeedbackStart
#
#  Facility:  SLAC
#
#  Auth: 06-dec-2006 dfairley
#    from 12-Mar-2006, Mike Zelazny (zelazny@stanford.edu):
#
#
#  Run the feedback indicated by the configuration filename
#
#  input parameter $1 is the feedback configuration filename
#==============================================================
#
# Setup LCLS Environment
#
if (-e ${LCROOT}/tools/script/ENVS.csh) then
#
  source ${LCROOT}/tools/script/ENVS.csh

# {}
#
# {}
#
# Log file on nfs
#
  set user=`whoami`-
  set date=`date`
  set year=`echo $date | cut -d" " -f6`-
  set month=`echo $date | cut -d" " -f2`-
  set day=`echo $date | cut -d" " -f3`-
  set time=`echo $date | cut -d" " -f4 | cut -c1-5`

  if (-e $MATLABDATAFILES/Feedback/log) then
    set log_file=$MATLABDATAFILES/Feedback/log/$1$user$year$month$day$time.log
  else
    set log_file=$1$user$year$month$day$time.log
  endif
#
# Start a Matlab slow Feedback with config file $1
#
  matlab -nosplash -nodesktop -r "startLCLS,fbStart('$1')"
#
else
#
# No afs access
#
  echo 'Sorry, cant find LCLS environment setup'
endif
