#! /bin/sh
#next line is executed by sh, not by Tcl \
   exec tclsh $0 ${1+"$@"}
#--------------------------------------------------------------------------
# This is the SICS syntax checker for the SANS small angle machine
#
# Mark Koennecke, March 2003
#--------------------------------------------------------------------------
source /data/lnslib/bin/sicscheck/sicssyntaxlib.tcl

#------------------------- define SANS motors and aliases
sicsSyntaxMap som        syntaxMotor
sicsSyntaxMap sax        syntaxMotor
sicsSyntaxMap say        syntaxMotor
sicsSyntaxMap saz        syntaxMotor
sicsSyntaxMap spos       syntaxMotor
sicsSyntaxMap mz         syntaxMotor
sicsSyntaxMap mom        syntaxMotor
sicsSyntaxMap gphi       syntaxMotor
sicsSyntaxMap gtheta     syntaxMotor
sicsSyntaxMap gomega     syntaxMotor
sicsSyntaxMap detectorx  syntaxMotor
sicsSyntaxMap detectory  syntaxMotor
sicsSyntaxMap detectorrotation syntaxMotor
sicsSyntaxMap beamstopy  syntaxMotor
sicsSyntaxMap beamstopx  syntaxMotor

#------------ multimotors and their aliases
sicsSyntaxMap emagnetsampleholder mumoSyntax
set sicsPar(emagnetsampleholder.alias) [list z om]
set sicsPar(emagnetsampleholder.nampos) [list back]

sicsSyntaxMap msh mumoSyntax
set sicsPar(msh.alias) [list z om]
set sicsPar(msh.nampos) [list back]

sicsSyntaxMap cryomagnetsampleholder mumoSyntax
set sicsPar(cryomagnetsampleholder.alias) [list phi theta omega]
set sicsPar(cryomagnetsampleholder.nampos) [list back]

sicsSyntaxMap cryo mumoSyntax
set sicsPar(cryo.alias) [list phi theta omega]
set sicsPar(cryo.nampos) [list back]

sicsSyntaxMap sampletable mumoSyntax
set sicsPar(sampletable.alias) [list omega x y z posi]
set sicsPar(sampletable.nampos) [list back]

sicsSyntaxMap st mumoSyntax
set sicsPar(st.alias) [list omega x y z posi]
set sicsPar(st.nampos) [list back]

sicsSyntaxMap detector mumoSyntax
set sicsPar(detector.alias) [list x y phi]
set sicsPar(detector.nampos) [list back]

sicsSyntaxMap dt mumoSyntax
set sicsPar(dt.alias) [list x y phi]
set sicsPar(dt.nampos) [list back]

sicsSyntaxMap beamstop mumoSyntax
set sicsPar(beamstop.alias) [list x y]
set sicsPar(beamstop.nampos) [list back]

sicsSyntaxMap bs mumoSyntax
set sicsPar(bs.alias) [list x y]
set sicsPar(bs.nampos) [list back]

#------------ define SANS counters
sicsSyntaxMap counter syntaxCounter
sicsSyntaxMap banana syntaxHM

#------------ define SANS variables
sicsSyntaxMap title        syntaxTextPar
sicsSyntaxMap user         syntaxTextPar
sicsSyntaxMap collimation  syntaxTextPar
sicsSyntaxMap sample       syntaxTextPar
sicsSyntaxMap comment1     syntaxTextPar
sicsSyntaxMap comment2     syntaxTextPar
sicsSyntaxMap comment3     syntaxTextPar
sicsSyntaxMap fax          syntaxTextPar
sicsSyntaxMap email        syntaxTextPar
sicsSyntaxMap sample       syntaxTextPar
sicsSyntaxMap batchroot    syntaxTextPar
sicsSyntaxMap lambda       syntaxNumPar
sicsSyntaxMap nvs          syntaxNumPar

#----------- define SANS environment
sicsSyntaxMap temperature evSyntax
sicsSyntaxMap tt          evSyntax
sicsSyntaxMap magnet      evSyntax



#---------- define SANS auxiliary
sicsSyntaxMap beam syntaxDummy
sicsSyntaxMap detemp syntaxDummy
sicsSyntaxMap temp2 syntaxDummy
sicsSyntaxMap temp3 syntaxDummy
sicsSyntaxMap temp4 syntaxDummy
sicsSyntaxMap coll  syntaxNumPar
sicsSyntaxMap att   syntaxNumPar
sicsSyntaxMap shutter  syntaxTextPar
sicsSyntaxMap bschange syntaxNumPar
sicsSyntaxMap qrange   syntaxNumPar
sicsSyntaxMap bsin     syntaxDummy
sicsSyntaxMap bsout    syntaxDummy

#------------- SANS xy-tables
sicsSyntaxMap xydata0 syntaxXY
sicsSyntaxMap xydata1 syntaxXY
sicsSyntaxMap xydata2 syntaxXY
sicsSyntaxMap xydata3 syntaxXY
sicsSyntaxMap xydata4 syntaxXY
sicsSyntaxMap xydata5 syntaxXY
sicsSyntaxMap xydata6 syntaxXY
sicsSyntaxMap xydata7 syntaxXY
sicsSyntaxMap xydata8 syntaxXY
sicsSyntaxMap xydata9 syntaxXY
sicsSyntaxMap xydata  syntaxXY

#--------- do we need this?
sicsSyntaxMap save syntaxDummy
sicsSyntaxMap SplitReply syntaxDummy
sicsSyntaxMap Publish syntaxDummy

#--------- Main checking stuff
syntaxLoadSICS /data/lnslib/data/SANS/2003/sansstat.tcl
if { $argc < 1} {
	puts stdout "Usage: \n\tsanscheck filename"
	exit 0
}
set filename [lindex $argv 0]
lappend fileList [file tail $filename]
puts stdout "Syntax checking --> $filename <-- ........."
source $filename
puts stdout "If this completed without errors the likelihoof of your script"
puts stdout "executing properly on the instrument has increased significantly"
exit 1
 






