Changeset 169 for trunk/MultiChannelUSB
- Timestamp:
- Oct 18, 2012, 1:13:15 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MultiChannelUSB/UserInterface.tcl
r168 r169 8 8 9 9 wm minsize . 990 680 10 11 image create bitmap leftarrow -data " 12 #define leftarrow_width 5\n 13 #define leftarrow_height 5\n 14 static unsigned char leftarrow_bits\[\] = {\n 15 0x10, 0x1C, 0x1F, 0x1C, 0x10};" 16 image create bitmap rightarrow -data " 17 #define rightarrow_width 5\n 18 #define rightarrow_height 5\n 19 static unsigned char rightarrow_bits\[\] = {\n 20 0x01, 0x07, 0x1F, 0x07, 0x01};" 10 21 11 22 namespace eval ::mca { … … 114 125 unset handle 115 126 } 116 if { 1} {127 if {0} { 117 128 while {[catch {usb::connect 0x09FB 0x6001 1 1 0} result]} { 118 129 set answer [tk_messageBox -icon error -type retrycancel \ … … 429 440 ${config}.thrs_field set 25 430 441 442 my set xmin_val 0 443 my set xmax_val 4095 444 445 trace add variable [myvar xmin_val] write [myproc xmin_val_update] 446 trace add variable [myvar xmax_val] write [myproc xmax_val_update] 447 448 my stat_update 449 431 450 set cntr_tmp 1200000000 432 451 my set cntr_val $cntr_tmp … … 444 463 ${config}.chan_frame.axisx_value configure -text 0.0 445 464 465 ${config}.stat_frame.tot_value configure -text 0.0 466 ${config}.stat_frame.bkg_value configure -text 0.0 467 446 468 # my cntr_reset 447 469 } … … 461 483 $graph legend configure -hide yes 462 484 485 $graph marker create line -name xmin -coords "0 -Inf 0 Inf" -linewidth 2 -outline red 486 $graph marker create line -name xmax -coords "4095 -Inf 4095 Inf" -linewidth 2 -outline red 487 $graph marker bind xmin <Enter> [list [self] marker_enter xmin] 488 $graph marker bind xmin <Leave> [list [self] marker_leave xmin] 489 $graph marker bind xmax <Enter> [list [self] marker_enter xmax] 490 $graph marker bind xmax <Leave> [list [self] marker_leave xmax] 491 463 492 set config [frame ${master}.config -width 170] 464 493 465 494 checkbutton ${config}.axis_check -text {log scale} -variable [myvar axis] 466 495 467 frame ${config}.spc1 -width 170 -height 30496 frame ${config}.spc1 -width 170 -height 20 468 497 469 498 frame ${config}.rate_frame -borderwidth 0 -width 170 … … 471 500 legendLabel ${config}.rate_frame 1 mean {Avg. rate, 1/s} 472 501 473 frame ${config}.spc2 -width 170 -height 30502 frame ${config}.spc2 -width 170 -height 10 474 503 475 504 frame ${config}.chan_frame -borderwidth 0 -width 170 476 505 legendLabel ${config}.chan_frame 0 entr {Total entries} 477 legendLabel ${config}.chan_frame 1 empty {} 506 frame ${config}.chan_frame.spc1 -height 10 507 grid ${config}.chan_frame.spc1 -row 1 478 508 legendLabel ${config}.chan_frame 2 axisy {Bin entries} 479 509 legendLabel ${config}.chan_frame 3 axisx {Bin number} 480 481 frame ${config}.spc3 -width 170 -height 30 510 511 frame ${config}.spc3 -width 170 -height 10 512 513 label ${config}.roi -text {Region of interest} 514 frame ${config}.roi_frame -borderwidth 0 -width 170 515 label ${config}.roi_frame.min_title -anchor w -text {start:} 516 label ${config}.roi_frame.min_value -width 4 -anchor e -text {} 517 label ${config}.roi_frame.spc1 -width 5 -anchor w -text {} 518 label ${config}.roi_frame.max_title -anchor w -text {end:} 519 label ${config}.roi_frame.max_value -width 4 -anchor e -text {} 520 521 grid ${config}.roi_frame.min_title ${config}.roi_frame.min_value \ 522 ${config}.roi_frame.spc1 ${config}.roi_frame.max_title \ 523 ${config}.roi_frame.max_value 524 525 frame ${config}.stat_frame -borderwidth 0 -width 17 526 527 legendLabel ${config}.stat_frame 0 tot {total entries} 528 legendLabel ${config}.stat_frame 1 bkg {bkg entries} 529 530 frame ${config}.spc4 -width 170 -height 20 482 531 483 532 checkbutton ${config}.thrs_check -text {amplitude threshold} -variable [myvar thrs] … … 486 535 -validate all -vcmd {::mca::validate 4095 4 %P} 487 536 488 frame ${config}.spc 4 -width 170 -height 30537 frame ${config}.spc5 -width 170 -height 20 489 538 490 539 label ${config}.cntr -text {time of exposure} … … 504 553 ${config}.cntr_frame.m_field ${config}.cntr_frame.m ${config}.cntr_frame.s_field ${config}.cntr_frame.s 505 554 506 frame ${config}.spc 5 -width 170 -height 10555 frame ${config}.spc6 -width 170 -height 20 507 556 508 557 button ${config}.start -text Start \ … … 511 560 -bg red -activebackground red -command [myproc cntr_reset] 512 561 513 frame ${config}.spc 6 -width 170 -height 30562 frame ${config}.spc7 -width 170 -height 20 514 563 515 564 button ${config}.register -text Register \ 516 565 -bg lightblue -activebackground lightblue -command [myproc register] 517 566 518 frame ${config}.spc 7 -width 170 -height 30567 frame ${config}.spc8 -width 170 -height 20 519 568 520 569 button ${config}.recover -text {Read file} \ … … 527 576 grid ${config}.chan_frame -sticky ew -padx 5 528 577 grid ${config}.spc3 578 grid ${config}.roi -sticky w -pady 1 -padx 5 579 grid ${config}.roi_frame -sticky ew -padx 5 580 grid ${config}.stat_frame -sticky ew -padx 5 581 grid ${config}.spc4 529 582 grid ${config}.thrs_check -sticky w 530 583 grid ${config}.thrs_field -sticky ew -pady 1 -padx 5 531 grid ${config}.spc 4584 grid ${config}.spc5 532 585 grid ${config}.cntr -sticky w -pady 1 -padx 3 533 586 grid ${config}.cntr_frame -sticky ew -padx 5 534 grid ${config}.spc 5587 grid ${config}.spc6 535 588 grid ${config}.start -sticky ew -pady 3 -padx 5 536 589 grid ${config}.reset -sticky ew -pady 3 -padx 5 537 grid ${config}.spc 6590 grid ${config}.spc7 538 591 grid ${config}.register -sticky ew -pady 3 -padx 5 539 grid ${config}.spc 7592 grid ${config}.spc8 540 593 grid ${config}.recover -sticky ew -pady 3 -padx 5 541 594 … … 549 602 grid columnconfigure ${config}.rate_frame 1 -weight 1 550 603 grid columnconfigure ${config}.chan_frame 1 -weight 1 604 grid columnconfigure ${config}.stat_frame 1 -weight 1 551 605 552 606 my crosshairs $graph … … 556 610 # create one element with data for the x and y axis, no dots 557 611 $graph element create Spectrum1 -color blue -linewidth 2 -symbol none -smooth step -xdata [myvar xvec] -ydata [myvar yvec] 612 } 613 614 # ------------------------------------------------------------------------- 615 616 HstDisplay instproc marker_enter {marker} { 617 my instvar config graph 618 $graph configure -cursor hand2 619 $graph crosshairs off 620 blt::RemoveBindTag $graph zoom-$graph 621 $graph marker bind $marker <ButtonPress-1> [list [self] marker_press $marker] 622 $graph marker bind $marker <ButtonRelease-1> [list [self] marker_release $marker] 623 } 624 625 # ------------------------------------------------------------------------- 626 627 HstDisplay instproc marker_leave {marker} { 628 my instvar config graph 629 $graph configure -cursor crosshair 630 $graph crosshairs on 631 blt::AddBindTag $graph zoom-$graph 632 $graph marker bind $marker <ButtonPress-1> {} 633 $graph marker bind $marker <ButtonRelease-1> {} 634 } 635 636 # ------------------------------------------------------------------------- 637 638 HstDisplay instproc marker_press {marker} { 639 my instvar config graph 640 $graph marker bind $marker <Motion> [list [self] ${marker}_motion %W %x %y] 641 } 642 643 # ------------------------------------------------------------------------- 644 645 HstDisplay instproc marker_release {marker} { 646 my instvar config graph 647 $graph marker bind $marker <Motion> {} 648 } 649 650 # ------------------------------------------------------------------------- 651 652 HstDisplay instproc xmin_motion {W x y} { 653 my instvar config graph xmin_val 654 set index [$graph axis invtransform x $x] 655 set index [::tcl::mathfunc::round $index] 656 if {$index < 0} { 657 set index 0 658 } 659 set xmin_val $index 660 } 661 662 # ------------------------------------------------------------------------- 663 664 HstDisplay instproc xmax_motion {W x y} { 665 my instvar config graph xmax_val 666 set index [$graph axis invtransform x $x] 667 set index [::tcl::mathfunc::round $index] 668 if {$index > 4095} { 669 set index 4095 670 } 671 set xmax_val $index 558 672 } 559 673 … … 572 686 } 573 687 } 688 574 689 # ------------------------------------------------------------------------- 575 690 … … 622 737 # ------------------------------------------------------------------------- 623 738 739 HstDisplay instproc stat_update {} { 740 my instvar config graph xmin_val xmax_val 741 set ymin_val [[myvar yvec] index $xmin_val] 742 set ymax_val [[myvar yvec] index $xmax_val] 743 744 ${config}.roi_frame.min_value configure -text $xmin_val 745 ${config}.roi_frame.max_value configure -text $xmax_val 746 747 ${config}.stat_frame.tot_value configure \ 748 -text [usb::integrateBlt [myvar yvec] $xmin_val $xmax_val 0] 749 750 ${config}.stat_frame.bkg_value configure \ 751 -text [expr {($xmax_val - $xmin_val + 1) * ($ymin_val + $ymax_val) / 2.0}] 752 } 753 # ------------------------------------------------------------------------- 754 755 HstDisplay instproc xmin_val_update args { 756 my instvar config graph xmin_val xmax_val 757 if {$xmin_val > 4075} { 758 set xmin_val 4075 759 } 760 if {$xmin_val > $xmax_val - 20} { 761 set xmax_val [expr {$xmin_val + 20}] 762 } 763 $graph marker configure xmin -coords "$xmin_val -Inf $xmin_val Inf" 764 my stat_update 765 } 766 767 # ------------------------------------------------------------------------- 768 769 HstDisplay instproc xmax_val_update args { 770 my instvar config graph xmin_val xmax_val 771 if {$xmax_val < 20} { 772 set xmax_val 20 773 } 774 if {$xmax_val < $xmin_val + 20} { 775 set xmin_val [expr {$xmax_val - 20}] 776 } 777 $graph marker configure xmax -coords "$xmax_val -Inf $xmax_val Inf" 778 my stat_update 779 } 780 781 # ------------------------------------------------------------------------- 782 624 783 HstDisplay instproc rate_val_update {name key op} { 625 784 my instvar config rate_val … … 737 896 set cntr_bak $cntr_tmp 738 897 set cntr_old $cntr_tmp 739 set yvec_bak [usb::integrateBlt [myvar yvec] 0 ]898 set yvec_bak [usb::integrateBlt [myvar yvec] 0 4095 0] 740 899 set yvec_old $yvec_bak 741 900 … … 824 983 825 984 $controller usbCmdReadRaw $command [expr {$size * 4}] [myvar data] 826 set yvec_new [usb::integrateBlt [myvar yvec] 0 ]985 set yvec_new [usb::integrateBlt [myvar yvec] 0 4095 0] 827 986 828 987 set prefix [format {%x} [expr {5 + ${number}}]] … … 836 995 set rate_val(mean) [expr {($yvec_new - $yvec_bak)*20000000/($cntr_bak - $cntr_new)}] 837 996 ${config}.chan_frame.entr_value configure -text $yvec_new 997 my stat_update 838 998 839 999 set yvec_old $yvec_new … … 913 1073 914 1074 HstDisplay instproc recover {} { 1075 my instvar config 915 1076 my open_data 1077 ${config}.chan_frame.entr_value configure -text [usb::integrateBlt [myvar yvec] 0 4095 0] 1078 my stat_update 916 1079 } 917 1080 … … 1299 1462 1300 1463 ${config}.chan_frame.mean_value configure \ 1301 -text [format {%.2e} [usb::integrateBlt [myvar yvec] 1]]1464 -text [format {%.2e} [usb::integrateBlt [myvar yvec] 0 9999 1]] 1302 1465 ${config}.chan_frame.entr_value configure \ 1303 -text [usb::integrateBlt [myvar yvec] 0 ]1466 -text [usb::integrateBlt [myvar yvec] 0 9999 0] 1304 1467 1305 1468 }
Note:
See TracChangeset
for help on using the changeset viewer.