Index: trunk/3DEES/UserInterface.tcl
===================================================================
--- trunk/3DEES/UserInterface.tcl	(revision 180)
+++ trunk/3DEES/UserInterface.tcl	(revision 181)
@@ -32,12 +32,64 @@
     variable adcCodes
     array set adcCodes {
-        1 {ADC 1}
-        2 {ADC 2}
-        3 {ADC 3}
-        4 {ADC 4}
-        5 {ADC 5}
-        6 {ADC 6}
-    }
-
+        1 {S1_F}
+        2 {S1_S}
+        3 {S2}
+        4 {D1}
+        5 {D2}
+        6 {D3}
+    }
+
+# -------------------------------------------------------------------------
+
+    variable cfgCodes
+    array set cfgCodes {
+        {1_0} 0
+        {1_1} 6
+        {2_0} 1
+        {2_1} 7
+        {3_0} 2
+        {3_1} 8
+        {3_2} 9
+        {3_3} 10
+        {4_0} 3
+        {4_1} 11
+        {4_2} 12
+        {4_3} 13
+        {5_0} 4
+        {5_1} 14
+        {5_2} 15
+        {5_3} 16
+        {6_0} 5
+        {6_1} 17
+        {6_2} 18
+        {6_3} 19
+    }
+# -------------------------------------------------------------------------
+
+    variable cfgThrs
+    array set cfgThrs {
+        0  20
+        6  2000
+        1  20
+        7  2000
+        2  20
+        8  200
+        9  2000
+        10 3000
+        3  20
+        11 200
+        12 2000
+        13 3000
+        4  20
+        14 200
+        15 2000
+        16 3000
+        5  20
+        17 200
+        18 2000
+        19 3000
+    }
+
+    
 # -------------------------------------------------------------------------
 
@@ -253,22 +305,21 @@
     CfgDisplay instproc start {} {
         variable adcCodes
-        my instvar config
+        variable cfgThrs
+
+        foreach {ch id} [array get adcCodes] {
+            my set delay($ch) 32
+            my set decay($ch) 1000
+        }
+
+        foreach {i value} [array get cfgThrs] {
+            my set thrs($i) $value
+        }
 
         trace add variable [myvar decay] write [myproc decay_update]
         trace add variable [myvar delay] write [myproc delay_update]
         trace add variable [myvar thrs] write [myproc thrs_update]
-
-        foreach {ch id} [array get adcCodes] {
-            ${config(clip)}.delay_${ch} set 32
-            ${config(clip)}.decay_${ch} set 1000
-        }
-
-        for {set i 0} {$i <= 3} {incr i} {
-            ${config(thrs)}.thrs_${i} set 100
-        }
-
-        for {set i 4} {$i <= 19} {incr i} {
-            ${config(bins)}.thrs_${i} set 100
-        }
+        
+        my delay_update
+        my thrs_update
     }
 
@@ -277,4 +328,5 @@
     CfgDisplay instproc setup {} {
         variable adcCodes
+        variable cfgCodes
         my instvar number master
         my instvar config
@@ -294,10 +346,10 @@
 
         foreach {ch id} [array get adcCodes {[1-2]}] {
-            label ${config(thrs)}.chan_${ch} -text "${ch} "
+            label ${config(thrs)}.chan_${ch} -text "${id} "
             grid ${config(thrs)}.chan_${ch} -row ${ch} -column 0 -sticky ew -padx 5 -pady 7
             foreach {num} [list 0 1] {
                 set column [expr {$num + 1}]
-                set value [expr {2 * ($ch - 1) + $num}]
-                puts "${num} ${ch} ${value}"
+                set value $cfgCodes(${ch}_${num})
+                puts "${ch} ${num} ${value}"
                 spinbox ${config(thrs)}.thrs_${value} -from 0 -to 4095 \
                   -increment 10 -width 10 -textvariable [myvar thrs($value)] \
@@ -319,10 +371,10 @@
 
         foreach {ch id} [array get adcCodes {[3-6]}] {
-            label ${config(bins)}.chan_${ch} -text "${ch} "
+            label ${config(bins)}.chan_${ch} -text "${id} "
             grid ${config(bins)}.chan_${ch} -row ${ch} -column 0 -sticky ew -padx 5 -pady 7
             foreach {num} [list 0 1 2 3] {
                 set column [expr {$num + 1}]
-                set value [expr {4 * ($ch - 2) + $num}]
-                puts "${num} ${ch} ${value}"
+                set value $cfgCodes(${ch}_${num})
+                puts "${ch} ${num} ${value}"
                 spinbox ${config(bins)}.thrs_${value} -from 0 -to 4095 \
                   -increment 10 -width 10 -textvariable [myvar thrs($value)] \
@@ -344,5 +396,5 @@
 
         foreach {ch id} [array get adcCodes] {
-            label ${config(clip)}.chan_${ch} -text "${ch} "
+            label ${config(clip)}.chan_${ch} -text "${id} "
             grid ${config(clip)}.chan_${ch} -row ${ch} -column 0 -sticky ew -padx 5 -pady 7
             spinbox ${config(clip)}.delay_${ch} -from 0 -to 62 \
@@ -381,5 +433,5 @@
             set a $delay($i).0
             set b $decay($i).0
-            set value [expr int(exp(-${a}/${b})*1024*17)]
+            set value [expr int(exp(-${a}/${b})*1024*20)]
             append command [format {000200%02x0004%04x} [expr {30 + 2 * (${i} - 1)}] $value]
         }
@@ -492,6 +544,6 @@
                 incr column
             }
-            foreach {ch dummy} $adcList {
-                label $config($osc).chan_${ch} -text "${ch} "
+            foreach {ch id} $adcList {
+                label $config($osc).chan_${ch} -text "${id} "
                 grid $config($osc).chan_${ch} -row ${ch} -column 0 -sticky ew
                 foreach {code input} $inpList {
