#!/bin/bash


SCOPE_ADDRESS=""
ARG=""
FUNC="usage"

function usage {
    echo "usage: `basename \"$0\"` [option]"
    echo ""
    echo "Options:"
    echo "    -a <address>  Specify the scope <address>"
    echo "    -h            Show help."
    echo "    -s <setup>    Choose <setup> number (1-3)"
    echo ""

    exit 0
}

################################ ################################ 
if [ $1 = SCOP:LR20:BC01 ]
then
 echo "# Configuring BCS scope 1 (scop-lr20-bc01)"
 ################################
 if [ $2 = recall_1 ]
  then
   echo "#Recall Setup 1 (Laser pulse and gate)"
   caput SCOP:LR20:BC01:MBBO_SC_CH0_SCL  200mV #Ch 1 to 200mV, let user change
   caput SCOP:LR20:BC01:MBBO_SC_CH2_SCL  1V #Ch 3 to 1V, let user change
   caput SCOP:LR20:BC01:BO_SC_CH0_ENABLE 1    #Ch 1 enabled
   caput SCOP:LR20:BC01:BO_SC_CH1_ENABLE 0    #Ch 2 disabled
   caput SCOP:LR20:BC01:BO_SC_CH2_ENABLE 1    #Ch 3 enabled
   caput SCOP:LR20:BC01:BO_SC_CH3_ENABLE 0    #Ch 4 disabled
   caput SCOP:LR20:BC01:MBBO_SC_TRIG_SOUR EXT # external EVR trigger
   caput SCOP:LR20:BC01:AO_SC_TRIG_LEV 1	   # trigger at 1V
   caput SCOP:LR20:BC01:MBBO_SC_TIM_DIV_U ns #Horizontal scale in ns
   caput SCOP:LR20:BC01:MBBO_SC_TIM_DIV_V 10   #Horizontal scale 10 ns
   caput SCOP:LR20:BC01:AO_SC_CH0_POS -4.0
  #We do this one again, sometimes it's needed twice
   caput SCOP:LR20:BC01:MBBO_SC_CH0_SCL  200mV #Ch 1 to 200mV, let user change
   caput SCOP:LR20:BC01:MBBO_SC_CH2_SCL  1V #Ch 3 to 1V, let user change
   caput SCOP:LR20:BC01:BO_SC_CH0_ENABLE 1    #Ch 1 enabled
   caput SCOP:LR20:BC01:BO_SC_CH1_ENABLE 0    #Ch 2 disabled
   caput SCOP:LR20:BC01:BO_SC_CH2_ENABLE 1    #Ch 3 enabled
   caput SCOP:LR20:BC01:BO_SC_CH3_ENABLE 0    #Ch 4 disabled
   caput SCOP:LR20:BC01:MBBO_SC_TRIG_SOUR EXT # external EVR trigger
   caput SCOP:LR20:BC01:AO_SC_TRIG_LEV 1	   # trigger at 1V
   caput SCOP:LR20:BC01:MBBO_SC_TIM_DIV_U ns #Horizontal scale in ns
   caput SCOP:LR20:BC01:MBBO_SC_TIM_DIV_V 10   #Horizontal scale 10 ns
   caput SCOP:LR20:BC01:AO_SC_CH0_POS -4.0
 elif [ $2 = recall_2 ]
  then 
   echo "#Recall Setup 2 (BCS digital and gate)"
   caput SCOP:LR20:BC01:BO_SC_CH0_ENABLE 0    #Ch 1 disabled
   caput SCOP:LR20:BC01:BO_SC_CH1_ENABLE 1    #Ch 2 enabled
   caput SCOP:LR20:BC01:BO_SC_CH2_ENABLE 1    #Ch 3 enabled
   caput SCOP:LR20:BC01:BO_SC_CH3_ENABLE 0    #Ch 4 disabled
   caput SCOP:LR20:BC01:MBBO_SC_TRIG_SOUR EXT # external EVR trigger
   caput SCOP:LR20:BC01:AO_SC_TRIG_LEV 1	   # trigger at 1V
   caput SCOP:LR20:BC01:MBBO_SC_TIM_DIV_U ns #Horizontal scale in ns
   caput SCOP:LR20:BC01:MBBO_SC_TIM_DIV_V 10   #Horizontal scale 10 ns
  #We do this one again, sometimes it's needed twice
   caput SCOP:LR20:BC01:BO_SC_CH0_ENABLE 0    #Ch 1 disabled
   caput SCOP:LR20:BC01:BO_SC_CH1_ENABLE 1    #Ch 2 enabled
   caput SCOP:LR20:BC01:BO_SC_CH2_ENABLE 1    #Ch 3 enabled
   caput SCOP:LR20:BC01:BO_SC_CH3_ENABLE 0    #Ch 4 disabled
   caput SCOP:LR20:BC01:MBBO_SC_TRIG_SOUR EXT # external EVR trigger
   caput SCOP:LR20:BC01:AO_SC_TRIG_LEV 1	   # trigger at 1V
   caput SCOP:LR20:BC01:MBBO_SC_TIM_DIV_U ns #Horizontal scale in ns
   caput SCOP:LR20:BC01:MBBO_SC_TIM_DIV_V 10   #Horizontal scale 10 ns
 elif [ $2 = recall_3 ]
  then
   echo "#Recall Setup 3 (LED pulse and gate)"
   caput SCOP:LR20:BC01:BO_SC_CH0_ENABLE 1   #Ch 1 enabled
   caput SCOP:LR20:BC01:BO_SC_CH1_ENABLE 0   #Ch 2 disabled
   caput SCOP:LR20:BC01:BO_SC_CH2_ENABLE 0   #Ch 3 disabled
   caput SCOP:LR20:BC01:BO_SC_CH3_ENABLE 1   #Ch 4 disabled
   caput SCOP:LR20:BC01:MBBO_SC_CH0_SCL  50mV #Ch 1 to 50mV
   caput SCOP:LR20:BC01:MBBO_SC_TRIG_SOUR Chan4 # trigger on channel 3
   caput SCOP:LR20:BC01:AO_SC_TRIG_LEV 2	   # trigger at 2V
   caput SCOP:LR20:BC01:MBBO_SC_TIM_DIV_U ns #Horizontal scale in ns
   caput SCOP:LR20:BC01:MBBO_SC_TIM_DIV_V 10   #Horizontal scale 10 ns
  #We do this one again, sometimes it's needed twice
   caput SCOP:LR20:BC01:BO_SC_CH0_ENABLE 1   #Ch 1 enabled
   caput SCOP:LR20:BC01:BO_SC_CH1_ENABLE 0   #Ch 2 disabled
   caput SCOP:LR20:BC01:BO_SC_CH2_ENABLE 0   #Ch 3 disabled
   caput SCOP:LR20:BC01:BO_SC_CH3_ENABLE 1   #Ch 4 disabled
   caput SCOP:LR20:BC01:MBBO_SC_CH0_SCL  50mV #Ch 1 to 50mV
   caput SCOP:LR20:BC01:MBBO_SC_TRIG_SOUR Chan4 # trigger on channel 3
   caput SCOP:LR20:BC01:AO_SC_TRIG_LEV 2	   # trigger at 2V
   caput SCOP:LR20:BC01:MBBO_SC_TIM_DIV_U ns #Horizontal scale in ns
   caput SCOP:LR20:BC01:MBBO_SC_TIM_DIV_V 10   #Horizontal scale 10 ns
 elif [ $2 = recall_4 ]
  then
   echo "#Recall Setup 4 (LED digital and gate)"
   caput SCOP:LR20:BC01:BO_SC_CH0_ENABLE 0   #Ch 1 disabled
   caput SCOP:LR20:BC01:BO_SC_CH1_ENABLE 1   #Ch 2 enabled
   caput SCOP:LR20:BC01:BO_SC_CH2_ENABLE 0   #Ch 3 disabled
   caput SCOP:LR20:BC01:BO_SC_CH3_ENABLE 1   #Ch 4 abled
   caput SCOP:LR20:BC01:MBBO_SC_TRIG_SOUR Chan4 # trigger on channel 3
   caput SCOP:LR20:BC01:AO_SC_TRIG_LEV 2	   # trigger at 2V
   caput SCOP:LR20:BC01:MBBO_SC_TIM_DIV_U ns #Horizontal scale in ns
   caput SCOP:LR20:BC01:MBBO_SC_TIM_DIV_V 10   #Horizontal scale 10 ns
  #We do this one again, sometimes it's needed twice
   caput SCOP:LR20:BC01:BO_SC_CH0_ENABLE 0   #Ch 1 enabled
   caput SCOP:LR20:BC01:BO_SC_CH1_ENABLE 1   #Ch 2 disabled
   caput SCOP:LR20:BC01:BO_SC_CH2_ENABLE 0   #Ch 3 disabled
   caput SCOP:LR20:BC01:BO_SC_CH3_ENABLE 1   #Ch 4 disabled
   caput SCOP:LR20:BC01:MBBO_SC_TRIG_SOUR Chan4 # trigger on channel 3
   caput SCOP:LR20:BC01:AO_SC_TRIG_LEV 2	   # trigger at 2V
   caput SCOP:LR20:BC01:MBBO_SC_TIM_DIV_U ns #Horizontal scale in ns
   caput SCOP:LR20:BC01:MBBO_SC_TIM_DIV_V 10   #Horizontal scale 10 ns
  else
   echo "Error Defining Recall"
 fi
################################ ################################ 
elif [ $1=SCOP:LR20:BC02 ]
then
echo "# Configuring Coherent #1(scop-lr20-bc02)"
################################ 
 if [ $2 = recall_1 ]
  then
   echo "#Recall Setup 1 (Laser pulse and gate)"
   caput SCOP:LR20:BC02:MBBO_SC_CH0_SCL  200mV #Ch 1 to 200mV, let user change
   caput SCOP:LR20:BC02:MBBO_SC_CH2_SCL  1V #Ch 3 to 1V, let user change
   caput SCOP:LR20:BC02:BO_SC_CH0_ENABLE 1    #Ch 1 enabled
   caput SCOP:LR20:BC02:BO_SC_CH1_ENABLE 0    #Ch 2 disabled
   caput SCOP:LR20:BC02:BO_SC_CH2_ENABLE 1    #Ch 3 enabled
   caput SCOP:LR20:BC02:BO_SC_CH3_ENABLE 0    #Ch 4 disabled
   caput SCOP:LR20:BC02:MBBO_SC_TRIG_SOUR EXT # external EVR trigger
   caput SCOP:LR20:BC02:AO_SC_TRIG_LEV 1	   # trigger at 1V
   caput SCOP:LR20:BC02:MBBO_SC_TIM_DIV_U ns #Horizontal scale in ns
   caput SCOP:LR20:BC02:MBBO_SC_TIM_DIV_V 10   #Horizontal scale 10 ns
   caput SCOP:LR20:BC02:AO_SC_CH0_POS -4.0 #Bottom of waveform at bottom of screen, for max range
  #We do this one again, sometimes it's needed twice
   caput SCOP:LR20:BC02:MBBO_SC_CH0_SCL  200mV #Ch 1 to 200mV, let user change
   caput SCOP:LR20:BC02:MBBO_SC_CH2_SCL  1V #Ch 3 to 1V, let user change
   caput SCOP:LR20:BC02:BO_SC_CH0_ENABLE 1    #Ch 1 enabled
   caput SCOP:LR20:BC02:BO_SC_CH1_ENABLE 0    #Ch 2 disabled
   caput SCOP:LR20:BC02:BO_SC_CH2_ENABLE 1    #Ch 3 enabled
   caput SCOP:LR20:BC02:BO_SC_CH3_ENABLE 0    #Ch 4 disabled
   caput SCOP:LR20:BC02:MBBO_SC_TRIG_SOUR EXT # external EVR trigger
   caput SCOP:LR20:BC02:AO_SC_TRIG_LEV 1	   # trigger at 1V
   caput SCOP:LR20:BC02:MBBO_SC_TIM_DIV_U ns #Horizontal scale in ns
   caput SCOP:LR20:BC02:MBBO_SC_TIM_DIV_V 10   #Horizontal scale 10 ns
   caput SCOP:LR20:BC02:AO_SC_CH0_POS -4.0#Bottom of waveform at bottom of screen, for max range
 elif [ $2 = recall_2 ]
  then 
   echo "#Recall Setup 2 (BCS digital and gate)"
   caput SCOP:LR20:BC02:BO_SC_CH0_ENABLE 0    #Ch 1 disabled
   caput SCOP:LR20:BC02:BO_SC_CH1_ENABLE 1    #Ch 2 enabled
   caput SCOP:LR20:BC02:BO_SC_CH2_ENABLE 1    #Ch 3 enabled
   caput SCOP:LR20:BC02:BO_SC_CH3_ENABLE 0    #Ch 4 disabled
   caput SCOP:LR20:BC02:MBBO_SC_TRIG_SOUR EXT # external EVR trigger
   caput SCOP:LR20:BC02:AO_SC_TRIG_LEV 1	   # trigger at 1V
   caput SCOP:LR20:BC02:MBBO_SC_TIM_DIV_U ns #Horizontal scale in ns
   caput SCOP:LR20:BC02:MBBO_SC_TIM_DIV_V 10   #Horizontal scale 10 ns
  #We do this one again, sometimes it's needed twice
   caput SCOP:LR20:BC02:BO_SC_CH0_ENABLE 0    #Ch 1 disabled
   caput SCOP:LR20:BC02:BO_SC_CH1_ENABLE 1    #Ch 2 enabled
   caput SCOP:LR20:BC02:BO_SC_CH2_ENABLE 1    #Ch 3 enabled
   caput SCOP:LR20:BC02:BO_SC_CH3_ENABLE 0    #Ch 4 disabled
   caput SCOP:LR20:BC02:MBBO_SC_TRIG_SOUR EXT # external EVR trigger
   caput SCOP:LR20:BC02:AO_SC_TRIG_LEV 1	   # trigger at 1V
   caput SCOP:LR20:BC02:MBBO_SC_TIM_DIV_U ns #Horizontal scale in ns
   caput SCOP:LR20:BC02:MBBO_SC_TIM_DIV_V 10   #Horizontal scale 10 ns
 elif [ $2 = recall_3 ]
  then
   echo "#Recall Setup 3 (LED pulse and gate)"
   caput SCOP:LR20:BC02:BO_SC_CH0_ENABLE 1   #Ch 1 enabled
   caput SCOP:LR20:BC02:BO_SC_CH1_ENABLE 0   #Ch 2 disabled
   caput SCOP:LR20:BC02:BO_SC_CH2_ENABLE 0   #Ch 3 disabled
   caput SCOP:LR20:BC02:BO_SC_CH3_ENABLE 1   #Ch 4 enabled
   caput SCOP:LR20:BC02:MBBO_SC_CH0_SCL  50mV #Ch 1 to 50mV
   caput SCOP:LR20:BC02:MBBO_SC_TRIG_SOUR Chan4 # trigger on channel 3
   caput SCOP:LR20:BC02:AO_SC_TRIG_LEV 2	   # trigger at 2V
   caput SCOP:LR20:BC02:MBBO_SC_TIM_DIV_U ns #Horizontal scale in ns
   caput SCOP:LR20:BC02:MBBO_SC_TIM_DIV_V 10   #Horizontal scale 10 ns
  #We do this one again, sometimes it's needed twice
   caput SCOP:LR20:BC02:BO_SC_CH0_ENABLE 1   #Ch 1 enabled
   caput SCOP:LR20:BC02:BO_SC_CH1_ENABLE 0   #Ch 2 disabled
   caput SCOP:LR20:BC02:BO_SC_CH2_ENABLE 0   #Ch 3 disabled
   caput SCOP:LR20:BC02:BO_SC_CH3_ENABLE 1   #Ch 4 enabled
   caput SCOP:LR20:BC02:MBBO_SC_CH0_SCL  50mV #Ch 1 to 50mV
   caput SCOP:LR20:BC02:MBBO_SC_TRIG_SOUR Chan4 # trigger on channel 3
   caput SCOP:LR20:BC02:AO_SC_TRIG_LEV 2	   # trigger at 2V
   caput SCOP:LR20:BC02:MBBO_SC_TIM_DIV_U ns #Horizontal scale in ns
   caput SCOP:LR20:BC02:MBBO_SC_TIM_DIV_V 10   #Horizontal scale 10 ns
 elif [ $2 = recall_4 ]
  then
   echo "#Recall Setup 4 (LED digital and gate)"
   caput SCOP:LR20:BC02:BO_SC_CH0_ENABLE 0   #Ch 1 disabled
   caput SCOP:LR20:BC02:BO_SC_CH1_ENABLE 1   #Ch 2 enabled
   caput SCOP:LR20:BC02:BO_SC_CH2_ENABLE 0   #Ch 3 disabled
   caput SCOP:LR20:BC02:BO_SC_CH3_ENABLE 1   #Ch 4 enabled
   caput SCOP:LR20:BC02:MBBO_SC_TRIG_SOUR Chan4 # trigger on channel 3
   caput SCOP:LR20:BC02:AO_SC_TRIG_LEV 2	   # trigger at 2V
   caput SCOP:LR20:BC02:MBBO_SC_TIM_DIV_U ns #Horizontal scale in ns
   caput SCOP:LR20:BC02:MBBO_SC_TIM_DIV_V 10   #Horizontal scale 10 ns
  #We do this one again, sometimes it's needed twice
   caput SCOP:LR20:BC02:BO_SC_CH0_ENABLE 0   #Ch 1 disabled
   caput SCOP:LR20:BC02:BO_SC_CH1_ENABLE 1   #Ch 2 enabled
   caput SCOP:LR20:BC02:BO_SC_CH2_ENABLE 0   #Ch 3 disabled
   caput SCOP:LR20:BC02:BO_SC_CH3_ENABLE 1   #Ch 4 enabled
   caput SCOP:LR20:BC02:MBBO_SC_TRIG_SOUR Chan4 # trigger on channel 3
   caput SCOP:LR20:BC02:AO_SC_TRIG_LEV 2	   # trigger at 2V
   caput SCOP:LR20:BC02:MBBO_SC_TIM_DIV_U ns #Horizontal scale in ns
   caput SCOP:LR20:BC02:MBBO_SC_TIM_DIV_V 10   #Horizontal scale 10 ns
else
   echo "Error in Defining Recall"
 fi

else    
echo "Error No Scope Set"
fi

exit
