#! /bin/bash -norc
#==============================================================
#
#  Abs:  enables alarming for specified branch of the
#        alarm handler tree
#
#  Name: enableALHGroup.bash
#
#  Args:  alh group name
#
#  Usage: called from command line
#         group name can be found by clicking the "G"uidance
#         button on the alarm handler gui
#
#--------------------------------------------------------------
#
#. /usr/local/lcls/epics/setup/epicsSetup.bash
acc=lcls2
dev="N"
if [ -d /afs/slac/g/lcls ]; then
    source /afs/slac/g/lcls/epics/setup/epicsSetup.bash
    dev="Y"
else
    source  /usr/local/lcls2/epics/setup/epicsSetup.bash
fi


if [ $# -lt 1 ]; then
   echo "========================================================"
   echo "Please specify a group name."
   echo "Group names can be found in the ALH gui Guidance window:"
   echo "Click the G button adjacent to the group."
   echo "========================================================"
else
#   echo "ENABLING alarming for group $1 - enter Y to continue, anything else to cancel."
#   set reply = $<
   export reply="Y"
   if [ $reply = "Y" ]; then
      echo "ENABLING alarming for group $1..."

      # go to the alh config directory to load config tree
      export here=`pwd`
      #pwd
 
      if [ "$dev" == "Y" ]; then
         NEWchangeGroupFORCEPVs.pl $1 0 $acc DEV "default"
      else
         NEWchangeGroupFORCEPVs.pl $1 0 $acc "default"
      fi

      echo "...done"
   else
      echo "CANCELLING"
   fi
fi

# end of script
