#!/bin/bash

echo "#####################################################"
echo "# Fairwood Start calibration script
echo "# Version 1.0
echo ""

# ######## declare variables
declare -ri EXIT_FAILURE=1
declare -ri EXIT_SUCCESS=0

declare -r phase=$1
declare base_dir=/proj/ops/ssi/$phase

strToFile()
{
    #echo "$2    -> $1"
    echo $2>>$1
}

declare -r idl_cal_start=$base_dir/bin/config/StartCal.pro
declare -r log_file=$base_dir/bin/log/cal.log
declare -r status_file=$base_dir/bin/status/cal_queue.status

echo Base Dir = $base_dir
echo CalStart = $idl_cal_start
echo log_file = $log_file


echo "##### build Idl calibration start procedure"
 
rm -f $idl_cal_start
strToFile $idl_cal_start "!path = expand_path('+/proj/ops/ssi/idl') + ':' + !path"
strToFile $idl_cal_start "cd, '$base_dir/queues/toCal'"
strToFile $idl_cal_start "cal_queue, './', '../ical_in', LOGFILE='$log_file', statusfile ='$status_file'"
strToFile $idl_cal_start "exit"

echo "##### Start idl"
idl $idl_cal_start&
echo OK


#echo "     Starting dummyCal"
#$dummyCal -incoming=$in_queue -pipe=$out_queue>$log_dir/dummycal.log







