#!/usr/bin/tclsh
#-------------------------------------------------------------------------
# This is the regression test for SICS on the TASP instrument
#
# Mark Koennecke, November 2006
#------------------------------------------------------------------------
source sicstcldebug.tcl
source insttestutil.tcl
source taspinventory.tcl

#------ If there is another argument, test at localhost: for debugging...
if {$argc > 0} {
	set instrument local
} else {
	set instrument tasp
} 

initSicsDebug $instrument
config rights lnsmanager lnsSICSlns

set ompos [SICSValue a3]
backup beforetest.tcl
#---------- configuration
exe upload
exe append sc a3 0 da3 .1 np 2 ti 2
exe append drive a3 90
exe forcesave insttestbatch.tcl

set notList [list forceqe dil mf nv]

lappend commandList "sc a3 0 da3 .1 np 2 ti 2"
#--------- the TAS set...
lappend commandList "do insttestbatch.tcl"
lappend commandList "ou a4"
lappend commandList "fi a4"
lappend commandList "fix a4"
lappend commandList "cl a4"
lappend commandList "co ti 5"
lappend commandList "pr a3,a4"
lappend commandList "se title hugo"
lappend commandList  "li"

#---------- The MAD set ...
lappend commandList "se as 4.558 bs 4.558 cs 4.558 bb 90 cc 90 aa 90"
lappend commandList "se ax 1 ay 1 az 0"
lappend commandList "se bx 0 by 0 bz 1"
lappend commandList  "se ss 1 sa -1"
lappend commandList  "se fx 2" 
lappend commandList  "dr ei 7.8"
lappend commandList  "dr ef 8. "
lappend commandList  "dr qh 1 1 1"
lappend commandList  "testVarValue ei 7.8 .1" 
lappend commandList  "testVarValue ef 8.0 .1" 
lappend commandList  "testVarValue en .2 .1" 
lappend commandList  "testVarValue a1 -28.86 .1" 
lappend commandList  "testVarValue a2 -57.73 .1" 
lappend commandList  "testVarValue a3 -88.04 .1" 
lappend commandList  "testVarValue a4 75.37 .1" 
lappend commandList  "testVarValue a5 -28.47 .1" 
lappend commandList  "testVarValue a6 -56.94 .1" 
lappend commandList  "testVarValue qm  2.38 .1" 

lappend interruptList "dr om 90"
lappend interruptList "co ti 120"
lappend interruptList "exe insttestbatch.tcl"

lappend varList [list "da" 3.3546 .01]
lappend varList [list "sm" -1 .01]
lappend varList [list "dm" 3.3546 .01]


set par(inventory) $inventory
set par(driveCommand) dr
set par(motorList) $motors
set par(notList) $notList
set par(commandList) $commandList
set par(interruptList) $interruptList
set par(instrument) $instrument
set par(user) lnsmanager
set par(password) lnsSICSlns
set par(varList) $varList

#================= actually test =====================================
set counters [runStandardTests par]

#--------- put detector back where it was
recover beforetest.tcl
dr a3 $ompos

#------------ print a summary
set inst [string toupper $instrument]
puts stdout "Test Summary for $inst"
printStandardSummary $counters

