simulate_probe
1 #!/usr/bin/wish 2 3 # simulate a probe 4 # You must disconnect hal connections to motion.probe-input 5 6 package require Hal 7 set this [file tail $::argv0] 8 9 if [catch {hal setp motion.probe-input 0} msg] { 10 if {[string last connected $msg] >= 0} { 11 puts "\nThe pin motion.probe-input is currently connected to a signal" 12 puts "Remove the connection to use $this\n" 13 exit 14 } else { 15 puts "\nIs LinuxCNC running? <$msg>" 16 puts "Start LinuxCNC before starting $this\n" 17 } 18 exit 19 } 20 21 pack [label .l -width 20 -height 10 -bg lightgray -fg black \ 22 -relief raised -bd 5 \ 23 -text "Push to simulate\nProbe touch"] \ 24 -fill both -expand 1 25 bind .l <ButtonPress-1> probetouch 26 bind .l <ButtonRelease-1> proberelease 27 28 set ::pulse 0 29 pack [checkbutton .c -text Pulse -variable ::pulse] \ 30 -fill x -expand 0 31 32 proc probetouch {} { 33 .l configure -bg red -fg white -text ProbeON 34 if [catch {hal setp motion.probe-input 1} msg] { 35 puts stderr "Is LinuxCNC running? <$msg>" 36 return 37 } 38 if $::pulse { 39 after 100 proberelease 40 if [catch {hal setp motion.probe-input 0} msg] { 41 puts stderr "Is LinuxCNC running? <$msg>" 42 return 43 } 44 } 45 } 46 proc proberelease {} { 47 .l configure -bg lightgray -fg black -text ProbeOFF 48 if [catch {hal setp motion.probe-input 0} msg] { 49 puts stderr "Is LinuxCNC running? <$msg>" 50 } 51 }