#!/bin/csh -f
#==============================================================
#
#  Abs:  Starts the Restore Actuators feedback application
#
#  Name: RestoreActuators
#
#  Facility:  SLAC
#
#  Auth: 06-dec-2006 dfairley
#    from 12-Mar-2006, Mike Zelazny (zelazny@stanford.edu):
#
#
#  This script starts the RestoreActuators application, used to
#  restore a feedback's actuator values to their original values
#  saved before the feedback was started. Used to recover from
#  feedback errors.
#
#  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/rstr_$user$year$month$day$time.log
  else
    set log_file=rstr_$user$year$month$day$time.log
  endif
#
# Start the RestoreActuators Matlab script
#
  matlab -nosplash -nodesktop -r "startLCLS,fbRestoreActuators('$1')"
#
else
#
# No afs access
#
  echo Sorry, can't find LCLS environment setup
endif
