#!/bin/bash
#==============================================================
#  Name: rfInitResAD10.sh
#  Abs:  Initialize AD10 resonance chassis
#        For now, this means simply program Kintex firmware
#
#  Facility: LCLS-II
#
#  Auth: Sonya Hoobler, 12 Nov 2018
#  Rev:  dd-mmm-yyyy, First Lastname (USERNAME)
#
#
#--------------------------------------------------------------
#  Mod:
#   
#--------------------------------------------------------------
#
#  Usage:
#         rfInitResAD10.sh
#
#         Must be run from cpu-ad10-cm01
#
#============================================================

function usage {
echo "
   Purpose: Initialize the AD10 LLRF Resonance Chassis.
            This loads the Kintex FPGA firmware.
            Previous settings/values will be lost.
            Must be run from cpu-ad10-cm01
            
   Usage:
          rfInitResAD10.sh 
"
}

QF2DIR=/afs/slac/g/lcls/package/lcls2_llrf/software/submodules/qf2_pre
R=192.168.0.100
BITFILE=/afs/slac/g/lcls/tools/FEED/firmware/res_ctl/resonance_control_qf2_20181009a.bit

echo "rfInitResAD10.sh: Initializing resonance chassis..."
source /afs/slac/g/lcls/epics/iocCommon/cpu-ad10-cm01/GoPythonLinuxRTEnvs.sh

CURRENT=`pwd`
echo $CURRENT
cd $QF2DIR
echo "Executing this command: python -m qf2_python.scripts.program_kintex_7 -t $R -b $BITFILE -v"
python -m qf2_python.scripts.program_kintex_7 -t $R -b $BITFILE -v
cd $CURRENT

exit 0
