#! /bin/sh # # This GUI script allows one to move an MX controlled motor. # # \ exec mxwish_script "$0" ${1+"$@"} option add *textBackground white proc main { record_list argv } { if { [ llength $argv ] != 1 } { puts stderr "" puts stderr "Usage: mw_motor motorname" puts stderr "" exit } set motor_name [ lindex $argv 0 ] set motor [ $record_list get_record $motor_name ] wm title . $motor_name # Display the motor name. set top .top_frame frame $top pack $top label $top.label -text "Motor:" pack $top.label -padx 5 -side left label $top.name -text [ $motor get_field "name" ] pack $top.name -padx 5 -side left # Top separator set sep1 .sep1 frame $sep1 -height 2 -borderwidth 1 -relief sunken pack $sep1 -expand yes -fill both # Middle frame set middle .middle frame $middle pack $middle set row 0 # Position label $middle.plabel -text "Position" grid $middle.plabel -row $row -column 0 -sticky w label $middle.position -fg blue -text "---" grid $middle.position -row $row -column 1 -sticky w label $middle.moving -fg green -text "" -width 6 grid $middle.moving -row $row -column 2 -sticky w incr row # Destination label $middle.dlabel -text "Destination" grid $middle.dlabel -row $row -column 0 -sticky w iwidgets::entryfield $middle.destination -width 20 $middle.destination configure -validate \ { iwidgets::Entryfield::real %P } $middle.destination configure -command \ [ itcl::code move_motor $middle.destination $motor ] grid $middle.destination -row $row -column 1 -sticky w label $middle.units -text [ $motor get_field "units" ] grid $middle.units -row $row -column 2 -sticky w incr row # Abort button $middle.abort -bg red -activebackground pink $middle.abort configure -text Abort $middle.abort configure -command [ itcl::code $motor soft_abort ] grid $middle.abort -row $row -column 2 -sticky w # Bottom separator set sep2 .sep2 frame $sep2 -height 2 -borderwidth 1 -relief sunken pack $sep2 -expand yes -fill both # Display the Close button set bottom .bottom_frame frame $bottom pack $bottom button $bottom.close -text Close -command exit pack $bottom.close # Arrange for position updates after 1 update_position $middle $motor } proc update_position { middle motor } { set position [ $motor get_position ] $middle.position configure -text $position if [ $motor is_busy ] { $middle.moving configure -text "Moving" } else { $middle.moving configure -text "" } after 1000 update_position $middle $motor } proc move_motor { entryfield motor } { set destination [ $entryfield get ] $motor move_absolute $destination }