From 9d4d09854eb456ba591b17c10eac67bd528ea2d0 Mon Sep 17 00:00:00 2001 From: koennecke Date: Tue, 3 Feb 2009 08:11:59 +0000 Subject: [PATCH] - Expanded test cases --- test/DataNumber | 2 +- test/sicsstat.tcl | 87 +++++++++++++++++++++++++++----- test/testini.tcl | 35 +++++++++++-- test/testsics | 3 ++ test/testsicsdata.tcl | 2 +- test/testsinglex.tcl | 115 ++++++++++++++++++++++++++++++++++++++++++ test/testutil.tcl | 42 +++++++++++++-- 7 files changed, 265 insertions(+), 21 deletions(-) create mode 100644 test/testsinglex.tcl diff --git a/test/DataNumber b/test/DataNumber index 75148a66..4d167238 100644 --- a/test/DataNumber +++ b/test/DataNumber @@ -1,3 +1,3 @@ - 131 + 231 NEVER, EVER modify or delete this file You'll risk eternal damnation and a reincarnation as a cockroach!|n \ No newline at end of file diff --git a/test/sicsstat.tcl b/test/sicsstat.tcl index 01fca9a5..ffabebb3 100644 --- a/test/sicsstat.tcl +++ b/test/sicsstat.tcl @@ -9,8 +9,8 @@ lotte setAccess 2 # Motor brumm brumm sign 1.000000 brumm SoftZero 0.000000 -brumm SoftLowerLim -180.000000 -brumm SoftUpperLim 180.000000 +brumm SoftLowerLim -181.000000 +brumm SoftUpperLim 179.000000 brumm Fixed -1.000000 brumm InterruptMode 0.000000 brumm precision 0.010000 @@ -22,8 +22,8 @@ brumm movecount 10.000000 # Motor miau miau sign 1.000000 miau SoftZero 0.000000 -miau SoftLowerLim -180.000000 -miau SoftUpperLim 180.000000 +miau SoftLowerLim -181.000000 +miau SoftUpperLim 179.000000 miau Fixed -1.000000 miau InterruptMode 0.000000 miau precision 0.010000 @@ -33,16 +33,16 @@ miau failafter 3.000000 miau maxretry 3.000000 miau movecount 10.000000 # Counter aba -aba SetPreset 1000.000000 +aba SetPreset 10.000000 aba SetMode Timer # Counter hugo -hugo SetPreset 1000.000000 +hugo SetPreset 2.000000 hugo SetMode Timer # Counter lieselotte -lieselotte SetPreset 1000.000000 +lieselotte SetPreset 2.000000 lieselotte SetMode Timer # Counter multi -multi SetPreset 0.000000 +multi SetPreset 2.000000 multi SetMode Timer # Motor a1 a1 sign 1.000000 @@ -148,14 +148,40 @@ sgl AccessCode 2.000000 sgl failafter 3.000000 sgl maxretry 3.000000 sgl movecount 10.000000 +# Motor chi +chi sign 1.000000 +chi SoftZero 0.000000 +chi SoftLowerLim 0.000000 +chi SoftUpperLim 360.000000 +chi Fixed -1.000000 +chi InterruptMode 0.000000 +chi precision 0.010000 +chi ignorefault 0.000000 +chi AccessCode 2.000000 +chi failafter 3.000000 +chi maxretry 3.000000 +chi movecount 10.000000 +# Motor phi +phi sign 1.000000 +phi SoftZero 0.000000 +phi SoftLowerLim 0.000000 +phi SoftUpperLim 360.000000 +phi Fixed -1.000000 +phi InterruptMode 0.000000 +phi precision 0.010000 +phi ignorefault 0.000000 +phi AccessCode 2.000000 +phi failafter 3.000000 +phi maxretry 3.000000 +phi movecount 10.000000 # Counter scancter -scancter SetPreset 0.000000 +scancter SetPreset 2.000000 scancter SetMode Timer hm CountMode timer -hm preset 10.000000 +hm preset 2.000000 tof CountMode timer -tof preset 10.000000 -tof genbin 10.000000 12.000000 100 +tof preset 2.000000 +tof genbin 500.000000 300.000000 20 tof init #---- tasUB module tasub tasub mono dd 3.350000 @@ -183,3 +209,40 @@ tasub r2 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 tasub update #----- MultiMotor sa sa recovernampos noeff a3 24 a4 48 +sa recovernampos gurke a3 27.000000 a4 48.000000 +ref addax 2.000000 2.000000 0.000000 35.800000 17.900000 180.642000 86.229000 +ref addax 0.000000 0.000000 3.000000 16.498000 8.249000 268.331000 333.714000 +ref addax 1.000000 0.000000 0.000000 12.478000 6.239000 181.549000 131.232000 +singlex cell 5.4202 5.4202 12.3228 90 90 90 +singlex oldub 0.121551 -0.13871 -0.00211888 -0.138705 -0.121629 0.00105057 -0.00497155 0.00204805 -0.0811159 +singlex ub 0.121567 -0.138726 -0.00212036 -0.138709 -0.121624 0.0010473 -0.00498763 0.00206415 -0.0811627 +singlex planenormal 0 0 0 +singlex mode bi +singlex spacegroup P +singlex peaksearch +singlex peaksearch/min2t 5 +singlex peaksearch/step2t 1 +singlex peaksearch/max2t 15 +singlex peaksearch/stepchi 2 +singlex peaksearch/stepphi 0.5 +singlex peaksearch/stepom 0.5 +singlex peaksearch/stepnu 0.5 +singlex peaksearch/phimin 0 +singlex peaksearch/phimax 180 +singlex peaksearch/chimin 90 +singlex peaksearch/chimax 180 +#HKL Settings +hkl scantolerance 2.500000 +ubcalc difftheta 0.300000 +ubcalc maxindex 5 +ubcalc maxlist 10 +fmess weak 0 +fmess weakthreshold 20 +fmess hkllim -10 -10 10 10 10 10 +fmess sttlim 5 180 +fmess table clear +cone target 0 0 0 +cone qscale 1 +cone center unknown +simidx sttlim 0.2 +simidx anglim 0.5 diff --git a/test/testini.tcl b/test/testini.tcl index 56c567c9..2a10e7c9 100644 --- a/test/testini.tcl +++ b/test/testini.tcl @@ -38,8 +38,8 @@ ServerOption InterruptPort 2913 # Syntax: SicsUser name password userRightsCode SicsUser Mugger Mugger 1 SicsUser User User 2 -#SicsUser Spy Spy 3 -SicsUser Spy 007 1 +SicsUser Spy Spy 3 +#SicsUser Spy 007 1 #----------------- SICS Variable VarMake lotte Text User @@ -95,6 +95,9 @@ Motor a5 SIM -180 180 -.1 10 Motor a6 SIM -180 180 -.1 10 Motor sgu SIM -20 20 -.1 10 Motor sgl SIM -20 20 -.1 10 +Motor chi SIM 0 360 -.1 10 +Motor phi SIM 0 360 -.1 10 + MakeMultiCounter scanCter aba proc scantransfer {} { @@ -457,7 +460,7 @@ makesctdriveobj schnecke /sics/farm/schnegge DriveAdapter farmser } #---------- test http -set httptest 1 +set httptest 0 if {$httptest == 1} { makesctcontroller amorhmsct sinqhttp amorhm data 180 spy 007 @@ -511,3 +514,29 @@ amorhmsct poll /sics/amorhm/collapse 20 #source ../sim/mars/julcho.tcl +MakeSingleX +singlex configure stt a4 +singlex configure om a3 +singlex configure chi chi +singlex configure phi phi +singlex configure lambda gfrth66jjjhh +singlex configure nu chi +singlex configure sgu chi +singlex configure sgl phi +singlex mode bi + +set secMotortest 0 + +if {$secMotortest == 1} { +proc hdbReadOnly {} { + error "Parameter is READ ONLY" +} + +source ../tcl/secsim.tcl +MakeSecSim mig3 -20 20 5 + +makesctcontroller pmac01 pmac ldm-elec-dev:1025 5 +pmac01 debug 0 +source ../tcl/deltatau.tcl +MakeDeltaTau mig15 pmac01 02 +} diff --git a/test/testsics b/test/testsics index 5fabdb39..f80eed96 100755 --- a/test/testsics +++ b/test/testsics @@ -54,6 +54,9 @@ source nxscripttest.tcl #------------ test SANS MultiMotor source testmumo.tcl +#------------ test SingleX +source testsinglex.tcl + #------------ print test summary cleanupTests exit 1 diff --git a/test/testsicsdata.tcl b/test/testsicsdata.tcl index c42b5fa9..b6175661 100644 --- a/test/testsicsdata.tcl +++ b/test/testsicsdata.tcl @@ -164,7 +164,7 @@ test sicsdata-1.8 {Testing UU write} -body { test sicsdata-1.9 {Testing file dump} -body { data clear data copyhm 0 hm - testOK "data dump test.dat" + testOK "data dumpxy test.dat" set status [catch {exec diff test.dat sicsdatasoll.dat} msg] if {$status != 0} { error "Difference in dump file: $msg" diff --git a/test/testsinglex.tcl b/test/testsinglex.tcl new file mode 100644 index 00000000..5b94cc21 --- /dev/null +++ b/test/testsinglex.tcl @@ -0,0 +1,115 @@ +#--------------------------------------------------------------- +# This is for testing the new coordinated single crystal stuff +# for SICS. +# +# Mark Koennecke, July - August 2008 +#--------------------------------------------------------------- +puts stdout "Testing Four Circle Codes" + +set testub ".1215666 -.138694 -.0021278 -.1386887 -.1216454 .0010515 -.0049867 .0020612 -.081156" +set testcell "5.4202 5.4202 12.3228 90. 90. 90." +#--------------------------------------------------------------- +proc testReflection {ref} { + drive h [lindex $ref 0] k [lindex $ref 1] l [lindex $ref 2] + set stt [SICSValue a4] + compareValue $stt [lindex $ref 3] + set om [SICSValue a3] + compareValue $om [lindex $ref 4] + set chi [SICSValue chi] + compareValue $chi [lindex $ref 5] + set phi [SICSValue phi] + compareValue $phi [lindex $ref 6] +} +#-------------------------------------------------------------- +proc testAng {ref} { + set stt [SICSValue a4] + compareValue $stt [lindex $ref 0] + set om [SICSValue a3] + compareValue $om [lindex $ref 1] + set chi [SICSValue chi] + compareValue $chi [lindex $ref 2] + set phi [SICSValue phi] + compareValue $phi [lindex $ref 3] +} +#======================= Tests ================================= +test singlex-1.0 {Testing Setting Lambda} -body { + testPar "singlex lambda" 1.1785 User + return OK +} -result OK + +test singlex-1.1 {Testing Mode Setting} -body { + testPar "singlex mode" bi User + testPar "singlex mode" nb User + testPar "singlex mode" tas User + set test [catch {singlex mode shitty} msg] + if {$test == 0} { + if {[string first ERROR $msg] < 0} { + error "Test for shitty mode failed" + } + } + return OK +} -result OK + +test singlex-1.2 {Testing Setting Cell} -body { + testMultiPar "singlex cell" $testcell User + return OK +} -result OK + +test singlex-1.3 {Testing Setting UB} -body { + testMultiPar "singlex ub" $testub User + return OK +} -result OK + +config rights User User +singlex ub $testub +singlex lambda 1.178 + +test singlex-1.4 {Driving Reflection} -body { + set ref [list 2 2 0 35.80 17.90 180.6425 86.229] + testReflection $ref + return OK +} -result OK + +test singlex-1.5 {Driving Reflection though hkl} -body { + hkl drive 2 2 0 + set ref [list 35.80 17.90 180.6425 86.229] + testAng $ref + return OK +} -result OK + + +test singlex-1.6 {UB Calculation, 2 Reflections, Cell} -body { + singlex cell $testcell + ref clear + ref addax 2 2 0 35.80 17.90 180.642 86.229 + ref addax 0 0 3 16.498 8.249 268.331 333.714 + ubcalc ub2ref 0000 0001 + ubcalc activate + set ubr [SICSValue "singlex ub"] + compareMultiValue $ubr $testub + return OK +} -result OK + +test singlex-1.7 {UB Calculation, 3 Reflections} -body { + ref clear + ref addax 2 2 0 35.80 17.90 180.642 86.229 + ref addax 0 0 3 16.498 8.249 268.331 333.714 + ref addax 1 0 0 12.478 6.239 181.549 131.232 + ubcalc ub3ref 0000 0001 0002 + ubcalc activate + set ubr [SICSValue "singlex ub"] + compareMultiValue $ubr $testub + return OK +} -result OK + +test singlex-1.8 {Cell from UB} -body { + ref clear + ref addax 2 2 0 35.80 17.90 180.642 86.229 + ref addax 0 0 3 16.498 8.249 268.331 333.714 + ref addax 1 0 0 12.478 6.239 181.549 131.232 + ubcalc ub3ref 0000 0001 0002 + set cell [ubcalc cellub] + compareMultiValue $cell $testcell .03 + return OK +} -result OK + diff --git a/test/testutil.tcl b/test/testutil.tcl index c8b3d1c5..d25064ac 100644 --- a/test/testutil.tcl +++ b/test/testutil.tcl @@ -11,9 +11,9 @@ proc SICSValue {command} { return [string trim [lindex $l 1]] } #----------------------------------------------------------------------------- -proc compareValue {is should} { +proc compareValue {is should {delta .01} } { if {[string is double $is] == 1} { - if {abs($should - $is) > .01} { + if {abs($should - $is) > $delta} { error "Bad compare is: $is, should $should" } } else { @@ -23,6 +23,18 @@ proc compareValue {is should} { } return OK } +#----------------------------------------------------------------------------- +proc compareMultiValue {is should {delta .01} } { + set l1 [split [string trim $is]] + set l2 [split [string trim $should]] + if {[llength $l1 ] != [llength $l2]} { + error "List length mismatch in compareMultiValue" + } + for {set i 0} {$i < [llength $l1]} {incr i } { + compareValue [lindex $l1 $i] [lindex $l2 $i] $delta + } + return OK +} #------------------------------------------------------------------------------ proc testPar {name testval priv } { config rights Spy Spy @@ -41,6 +53,24 @@ proc testPar {name testval priv } { eval $name $value return "OK" } +#------------------------------------------------------------------------------ +proc testMultiPar {name testval priv} { + config rights Spy Spy + set value [SICSValue $name] + set res [eval $name $testval] + if {[string first ERROR $res] < 0} { + error "Managed to set parameter even if not allowed" + } + config rights $priv $priv + set res [eval $name $testval] + if {[string first ERROR $res] >= 0} { + error "Setting parameter failed with $res" + } + set readback [SICSValue $name] + compareMultiValue $readback $testval + eval $name $value + return "OK" +} #------------------------------------------------------------------------------- proc testROPar {name val} { config rights Mugger Mugger @@ -48,9 +78,13 @@ proc testROPar {name val} { compareValue $value $val catch {$name [expr $val + 1]} msg set value [SICSValue $name] - compareValue $value $val + set status [catch {compareValue $value $val} msg] config rights Spy Spy - return OK + if {$status == 0} { + error "Was able to change read-only parameter name" + } else { + return OK + } } #------------------------------------------------------------------------------ proc testDrive {name value priv} {