#!/bin/sh
# This script is designed to check if the PGP PVs are correct after a restart.
# Setup Guide: DEVICE PGP CH

sctiming=$(caget -t $1:CAM_SC_TIMING)
nctiming=$(caget -t $1:CAM_NC_TIMING)
temp1=$(caget -t $1:$sctiming)
temp2=$(caget -t $1:$nctiming)
caput $1:$sctiming 0
caput $1:$nctiming 0
caput $1:$sctiming "$temp1"
caput $1:$nctiming "$temp2"

# Check if Acquire Time is the same
if [$1:AcquireTime -eq $1:AcquireTime_RBV]
then
	echo Acquire Time Failed to Match
	temp=$(caget -t $1:AcquireTime.VAL)
	caput $1:AcquireTime 0
	caput $1:AcquireTime "$temp"
else
	echo Acquire Time Matches
fi

# Check if Camera Trigger Delay is the same
if [$1:CamTrigDelay -eq $1:CamTrigDelay_RBV]
then
	echo Camera Trigger Delay Failed to Match
	temp=$1:CamTrigDelay.VAL
	caput $1:CamTrigDelay 0
	caput $1:CamTrigDelay "$temp"
else
	echo Camera Trigger Delay Matches
fi

# Check if Trigger Source is the same
if [$2:Ch$3:Timing:TriggerSource -eq $2:Ch$3:Timing:TriggerSource_RBV]
then
	echo Trigger Source Failed to Match
	temp=$(caget -t $2:Ch$3:Timing:TriggerSource)
	caput $2:Ch$3:Timing:TriggerSource "$temp"
else
	echo Trigger Souce Matches
fi

# Check if Rate Type is the same
if $2:Ch$3:EvrV2:RateType -eq $2:Ch$3:EvrV2:RateType_RBV
then
	echo Rate Type Failed to Match
	temp=$(caget -t $2:Ch$3:EvrV2:RateType)
	caput $2:Ch$3:EvrV2:RateType "$temp"
else
	echo Rate Type Matches
fi
