#!/bin/sh  
# \
exec oagtclsh "$0" "$@"

set auto_path [linsert $auto_path 0  /usr/local/oag/apps/lib/$env(HOST_ARCH)]
set auto_path [linsert $auto_path 0 /usr/local/oag/lib_patch/$env(HOST_ARCH)]

set plane h
set setpoint 0
set corrAOAItolerance 2.0
set corrDacAOtolerance 0.1
set unified 0
set args $argv
APSParseArguments {plane setpooint corrAOAItolerance corrDacAOtolerance unified}

#this is to be called by python to be able to run with other executions in parallel
#python EPICS in corrbpm does not work (startoc.py, however prepareoc.py works
#the difference between startoc.py and prepareoc.py is that startoc.py has orbitControllaw class which 
#which calls pyEpics, and corrbpm class which also uses pyEpics; however prepareoc.py only
#has corrbpm class. -- could be that two classes pyEpics and conflict? 
#do not know; but looks like this tcl script runs faster than the initialization part in python
#it is better to call this scrip then:)
APSStandardSetup

if [catch {APSInitializeCorrVector -plane [string tolower $plane] -setpoint $setpoint \
             -AOAItolerance $corrAOAItolerance -dacAOtolerance $corrDacAOtolerance} result] {
    puts stderr "Error SRInitializeCorrVector: $result"
    exit 1
}

exit 0
