Changeset 77 for trunk/MultiChannelUSB
- Timestamp:
- Nov 29, 2009, 11:11:25 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MultiChannelUSB/UserInterface.tcl
r74 r77 28 28 # ------------------------------------------------------------------------- 29 29 30 Class CfgDisplay -parameter { 31 {master} 32 } 33 34 # ------------------------------------------------------------------------- 35 36 CfgDisplay instproc init {} { 37 38 my reset 39 40 my setup 41 42 next 43 } 44 45 # ------------------------------------------------------------------------- 46 47 CfgDisplay instproc destroy {} { 48 next 49 } 50 51 # ------------------------------------------------------------------------- 52 53 CfgDisplay instproc reset {} { 54 } 55 56 # ------------------------------------------------------------------------- 57 58 CfgDisplay instproc start {} { 59 my instvar config 60 61 trace add variable [myvar dac1] write [myproc dac1_update] 62 trace add variable [myvar dac2] write [myproc dac2_update] 63 trace add variable [myvar polar] write [myproc polar_update] 64 65 ${config(1)}.scale set 0 66 ${config(2)}.scale set 0 67 68 ${config(3)}.polar1 select 69 ${config(3)}.polar2 select 70 } 71 72 # ------------------------------------------------------------------------- 73 74 CfgDisplay instproc setup {} { 75 my instvar number master 76 my instvar config 77 78 set config(1) [labelframe ${master}.cfg1 -text {DAC 20}] 79 set config(2) [labelframe ${master}.cfg2 -text {DAC 24}] 80 set config(3) [labelframe ${master}.cfg3 -text {polarity inversion}] 81 82 frame ${config(1)}.limits 83 label ${config(1)}.limits.min -text {0V} 84 label ${config(1)}.limits.max -text {-3.3V} 85 scale ${config(1)}.scale -orient horizontal -from 0 -to 4095 -tickinterval 500 -variable [myvar dac1] 86 87 frame ${config(2)}.limits 88 label ${config(2)}.limits.min -text {0V} 89 label ${config(2)}.limits.max -text {-3.3V} 90 scale ${config(2)}.scale -orient horizontal -from 0 -to 4095 -tickinterval 500 -variable [myvar dac2] 91 92 checkbutton ${config(3)}.polar1 -text {channel 1} -variable [myvar polar(1)] 93 checkbutton ${config(3)}.polar2 -text {channel 2} -variable [myvar polar(2)] 94 checkbutton ${config(3)}.polar3 -text {channel 3} -variable [myvar polar(3)] 95 96 pack ${config(1)} ${config(2)} -side top -expand yes -fill x -padx 10 97 pack ${config(3)} -side top -expand yes -fill x -padx 10 98 99 pack ${config(1)}.limits.min -anchor w -side left -padx 13 100 pack ${config(1)}.limits.max -anchor e -side right -padx 5 101 pack ${config(1)}.limits ${config(1)}.scale -side top -expand yes -fill x 102 103 pack ${config(2)}.limits.min -anchor w -side left -padx 13 104 pack ${config(2)}.limits.max -anchor e -side right -padx 5 105 pack ${config(2)}.limits ${config(2)}.scale -side top -expand yes -fill x 106 107 pack ${config(3)}.polar1 -side left -expand yes -fill x -pady 10 108 pack ${config(3)}.polar2 -side left -expand yes -fill x -pady 10 109 pack ${config(3)}.polar3 -side left -expand yes -fill x -pady 10 110 111 } 112 113 # ------------------------------------------------------------------------- 114 115 CfgDisplay instproc dac1_update args { 116 my instvar dac1 117 118 set value [format {%03x} $dac1] 119 set command 0005012000050030000500[string range $value 0 1]000502[string index $value 2]0 120 121 my send_data [usb::convert $command] 122 } 123 124 # ------------------------------------------------------------------------- 125 126 CfgDisplay instproc dac2_update args { 127 my instvar dac2 128 129 set value [format {%03x} $dac2] 130 set command 0005012400050030000500[string range $value 0 1]000502[string index $value 2]0 131 132 my send_data [usb::convert $command] 133 } 134 135 # ------------------------------------------------------------------------- 136 137 CfgDisplay instproc polar_update args { 138 my instvar polar 139 140 set value [format {0%x%x%x} $polar(3) $polar(2) $polar(1)] 141 142 my send_data [usb::convert 000A${value}] 143 } 144 145 # ------------------------------------------------------------------------- 146 147 CfgDisplay instproc send_data {data} { 148 global usb_handle 149 150 if {[catch {$usb_handle writeRaw $data} result]} { 151 puts {Error during write} 152 puts $result 153 } 154 } 155 156 # ------------------------------------------------------------------------- 157 30 158 Class OscDisplay -parameter { 31 159 {number} … … 94 222 my instvar config auto thrs thrs_val disp_val trig_val 95 223 96 my set restart_command [usb::convert 0001000${number} 00000000]97 my set acquire_command [usb::convert 0002000${number} 00000000]224 my set restart_command [usb::convert 0001000${number}] 225 my set acquire_command [usb::convert 0002000${number}] 98 226 99 227 # create a graph widget and show a grid … … 103 231 $graph legend configure -hide yes 104 232 $graph axis configure x -min 0 -max 1024 233 $graph axis configure y -min 0 -max 4100 105 234 106 235 set config [frame ${master}.config] … … 172 301 grid ${config} -row 0 -column 1 173 302 303 grid rowconfigure ${master} 0 -weight 1 304 grid columnconfigure ${master} 0 -weight 1 305 grid columnconfigure ${master} 1 -weight 0 -minsize 80 306 174 307 # enable zooming 175 308 Blt_ZoomStack $graph … … 214 347 } else { 215 348 ${config}.thrs_field configure -state disabled 216 my send_data [usb::convert ${val_addr}0000 00000000]349 my send_data [usb::convert ${val_addr}0000] 217 350 } 218 351 } … … 226 359 set value [format %04x $thrs_val] 227 360 228 my send_data [usb::convert ${val_addr}${value} 00000000]361 my send_data [usb::convert ${val_addr}${value}] 229 362 } 230 363 … … 247 380 data { 248 381 set disp_mux 0 249 my send_data [usb::convert ${mux_addr}[my mux] 00000000]382 my send_data [usb::convert ${mux_addr}[my mux]] 250 383 } 251 384 uwt1 { 252 385 set disp_mux 1 253 my send_data [usb::convert ${mux_addr}[my mux] 00000000]386 my send_data [usb::convert ${mux_addr}[my mux]] 254 387 } 255 388 uwt2 { 256 389 set disp_mux 2 257 my send_data [usb::convert ${mux_addr}[my mux] 00000000]390 my send_data [usb::convert ${mux_addr}[my mux]] 258 391 } 259 392 uwt3 { 260 393 set disp_mux 3 261 my send_data [usb::convert ${mux_addr}[my mux] 00000000]394 my send_data [usb::convert ${mux_addr}[my mux]] 262 395 } 263 396 base { 264 397 set disp_mux 4 265 my send_data [usb::convert ${mux_addr}[my mux] 00000000]398 my send_data [usb::convert ${mux_addr}[my mux]] 266 399 } 267 400 } … … 278 411 data { 279 412 set trig_mux 0 280 my send_data [usb::convert ${mux_addr}[my mux] 00000000]413 my send_data [usb::convert ${mux_addr}[my mux]] 281 414 } 282 415 uwt1 { 283 416 set trig_mux 1 284 my send_data [usb::convert ${mux_addr}[my mux] 00000000]417 my send_data [usb::convert ${mux_addr}[my mux]] 285 418 } 286 419 uwt2 { 287 420 set trig_mux 2 288 my send_data [usb::convert ${mux_addr}[my mux] 00000000]421 my send_data [usb::convert ${mux_addr}[my mux]] 289 422 } 290 423 uwt3 { 291 424 set trig_mux 3 292 my send_data [usb::convert ${mux_addr}[my mux] 00000000]425 my send_data [usb::convert ${mux_addr}[my mux]] 293 426 } 294 427 base { 295 428 set trig_mux 4 296 my send_data [usb::convert ${mux_addr}[my mux] 00000000]429 my send_data [usb::convert ${mux_addr}[my mux]] 297 430 } 298 431 } … … 448 581 my instvar config auto thrs thrs_val base base_typ base_val 449 582 450 my set restart_command [usb::convert 0001001${number} 00000000]451 my set acquire_command [usb::convert 0002001${number} 00000000]583 my set restart_command [usb::convert 0001001${number}] 584 my set acquire_command [usb::convert 0002001${number}] 452 585 453 586 # create a graph widget and show a grid … … 510 643 grid ${config} -row 0 -column 1 511 644 645 grid rowconfigure ${master} 0 -weight 1 646 grid columnconfigure ${master} 0 -weight 1 647 grid columnconfigure ${master} 1 -weight 0 -minsize 80 648 512 649 # enable zooming 513 650 Blt_ZoomStack $graph … … 555 692 if {$peak} { 556 693 set peak_mux 1 557 my send_data [usb::convert ${mux_addr}[my mux] 00000000]694 my send_data [usb::convert ${mux_addr}[my mux]] 558 695 } else { 559 696 set peak_mux 0 560 my send_data [usb::convert ${mux_addr}[my mux] 00000000]697 my send_data [usb::convert ${mux_addr}[my mux]] 561 698 } 562 699 } … … 575 712 } else { 576 713 ${config}.thrs_field configure -state disabled 577 my send_data [usb::convert ${val_addr}0000 00000000]714 my send_data [usb::convert ${val_addr}0000] 578 715 } 579 716 } … … 587 724 set value [format %04x $thrs_val] 588 725 589 my send_data [usb::convert ${val_addr}${value} 00000000]726 my send_data [usb::convert ${val_addr}${value}] 590 727 } 591 728 … … 607 744 ${config}.base_field configure -state disabled 608 745 set base_mux 0 609 my send_data [usb::convert ${mux_addr}[my mux] 00000000${val_addr}000000000000]746 my send_data [usb::convert ${mux_addr}[my mux]${val_addr}0000] 610 747 } 611 748 } … … 624 761 ${config}.base_field configure -state disabled 625 762 set base_mux 1 626 my send_data [usb::convert ${mux_addr}[my mux] 00000000]763 my send_data [usb::convert ${mux_addr}[my mux]] 627 764 } 628 765 const { 629 766 ${config}.base_field configure -state normal 630 767 set base_mux 0 631 my send_data [usb::convert ${mux_addr}[my mux] 00000000${val_addr}${value}00000000]768 my send_data [usb::convert ${mux_addr}[my mux]${val_addr}${value}] 632 769 } 633 770 } … … 642 779 set value [format %04x $base_val] 643 780 644 my send_data [usb::convert ${val_addr}${value} 00000000]781 my send_data [usb::convert ${val_addr}${value}] 645 782 } 646 783 … … 725 862 namespace export HstDisplay 726 863 namespace export OscDisplay 864 namespace export CfgDisplay 727 865 } 728 866 729 set notebook [::blt::tabnotebook .notebook -s ide bottom]867 set notebook [::blt::tabnotebook .notebook -selectforeground black -side bottom] 730 868 731 869 pack $notebook -expand 1 -fill both 732 870 733 set window [frame ${notebook}.hst_2] 734 $notebook insert end -text "Histogram" -window $window -fill both 735 ::mca::HstDisplay hst_2 -number 2 -master $window 736 737 grid rowconfigure $window 0 -weight 1 738 grid columnconfigure $window 0 -weight 1 739 grid columnconfigure $window 1 -weight 0 -minsize 80 740 741 set window [frame ${notebook}.osc_2] 742 $notebook insert end -text "Pulse shape" -window $window -fill both 743 ::mca::OscDisplay osc_2 -number 2 -master $window 744 745 grid rowconfigure $window 0 -weight 1 746 grid columnconfigure $window 0 -weight 1 747 grid columnconfigure $window 1 -weight 0 -minsize 80 871 foreach i {0 1 2} { 872 set channel [expr $i + 1] 873 874 set window [frame ${notebook}.hst_$i] 875 $notebook insert end -text "Histogram $channel" -window $window -fill both 876 ::mca::HstDisplay hst_$i -number $i -master $window 877 878 set window [frame ${notebook}.osc_$i] 879 $notebook insert end -text "Pulse shape $channel" -window $window -fill both 880 ::mca::OscDisplay osc_$i -number $i -master $window 881 } 882 883 set window [frame ${notebook}.cfg] 884 $notebook insert end -text "Configuration" -window $window -fill both 885 ::mca::CfgDisplay cfg -master $window 748 886 749 887 set usb_handle {} … … 755 893 } 756 894 757 hst_2 restart 758 osc_2 restart 759 760 hst_2 start 761 osc_2 start 762 763 # configure polarity 764 # set polarity_command [usb::convert 000A011100000000] 765 set polarity_command [usb::convert 000A001100000000] 766 if {[catch {$usb_handle writeRaw $polarity_command} result]} { 895 # cfg reset 896 set reset_command [usb::convert 00000000] 897 if {[catch {$usb_handle writeRaw $reset_command} result]} { 767 898 puts {Error during write} 768 899 puts $result 769 900 } 770 901 771 hst_2 restart 772 osc_2 restart 902 cfg start 903 904 foreach i {0 1 2} { 905 hst_$i start 906 osc_$i start 907 908 hst_$i restart 909 osc_$i restart 910 }
Note:
See TracChangeset
for help on using the changeset viewer.