#!/bin/bash
#==============================================================
# luKlystronSupportSetInitialConditions
#
# ARGUMENTS:
#
# OPTION:     
#
# Facility:  SLAC/LCLS
#
# For a Linac Upgrade Klystron Support soft ioc, run the script
# to set the initial 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 
# sector's Klystron Support soft ioc must both be up before running this script.
#
# Usage: luKlystronSupportSetInitialConditions <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/setInitialConditions > $EPICS_IOC_TOP/KlystronSupport/${appdir}/iocBoot/sioc-${loca}-ky00/setInitialConditions-${datestr}

exit 0

