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

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

initSicsDebug $instrument
config rights lnsmanager lnsSICSlns

#---------- configuration

standardPrelude $instrument count

lappend notList ""
lappend commandList "count timer 2"
lappend commandList "repeat 2"
lappend commandList "wwwsics"

lappend varList [list "mono dd" 3.3537 .1]
lappend varList [list "mono ss" 1 .1]
lappend varList [list "mono vk1"  -.00259 .1]
lappend varList [list "mono vk2"  5.35166 .1]

set om [SICSValue a3]

lappend interruptList "drive a3 20"
lappend interruptList "count timer 120"
lappend interruptList "exe insttestbatch.tcl"

#---------- configure parameter array
set par(inventory) $inventory
set par(driveCommand) drive
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]

#--------- Test detection system
puts stdout "Testing detector"
set det 1
count timer 600
set counts [SICSValue "banana sum 0 400"]
if {$counts <= 0}  {
   set det 0
}
if {$det == 1} {
	puts stdout "Detector passed"
} else {
   puts stdout "Check detector, found no noise after 10 minutes counting"
}
drive a3 $om

standardRestore

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


