#!/bin/bash
#==============================================================
# luKlystronSupportSetInitialConditionsIOC
#
# ARGUMENTS:
#
# OPTION:     
#
# Facility:  SLAC/LCLS
#
# For a Linac Upgrade CAMAC RTEMS ioc, run the script
# to set the initial Klystron PV values. The script gets the data from SLCCAS PVs
# and puts the data to the new PVs. The sector's RTEMS CAMAC IOC and the must 
# be up before running this script.
#
# Usage: luKlystronSupportSetInitialConditionsIOC <location>
#
# Arguments: 
#            location: ioc location name, for example li28
# 
#----------------------------------------------------------------------------
# Mod:
#        
#==============================================================

loca=`echo $1 | tr '[:upper:]' '[:lower:]'`

LOCA=`echo $1 | tr '[:lower:]' '[:upper:]'`

appdir=`ls -l $EPICS_IOCS/sioc-${loca}-ky00/bin_epics | awk 'BEGIN {FS="/"} ; {print $15}'`

echo  Setting ${LOCA} Klystron PV Initial Values...

datestr=`date '+%d-%h-%Y-%h:%M.%S'`
$EPICS_IOC_TOP/KlystronSupport/${appdir}/iocBoot/sioc-${loca}-ky00/setInitialConditionsIOC > $EPICS_IOC_TOP/KlystronSupport/${appdir}/iocBoot/sioc-${loca}-ky00/setInitialConditionsIOC-${datestr}

exit 0

