source: sans/utils/bt5/tilt/tilt @ 90

Last change on this file since 90 was 90, checked in by ajj, 15 years ago

Added Init code to set motor channel and velocity and print some info.

File size: 2.3 KB
Line 
1#!/usr/bin/expectk
2
3##################################
4## Talk to tilt controller on bt5
5##
6## Andrew Jackson, April 2007
7##################################
8
9package require Tix
10
11proc exec_cmd {cmd_text} {
12        global tf
13
14        $tf.output insert end "$cmd_text\n"
15        exp_send "$cmd_text\r"
16
17}
18
19
20proc goButProc {changeVal} {
21        global tf
22
23        $tf.output insert end "REL A1 $changeVal G\n"
24        exp_send "REL A1 $changeVal G\r"
25
26}
27
28log_user 0
29set port /dev/ttyS0
30set serialid [spawn -noecho -open [open $port w+]]
31set baud 19200
32#stty ispeed $baud ospeed $baud -raw cs8 -parenb -cstopb < $port
33stty -F $port ispeed $baud ospeed $baud raw icrnl
34
35
36#Build GUI
37#Create main frame
38frame .fmain
39
40#Create Notebook tabs
41set nb  [tixNoteBook .fmain.noteb]
42$nb add simple -label "Tilt Adjust" -underline 0
43$nb add tiltterm -label "Command line" -underline 0
44#Get frames for each tab
45set simpletab [frame [$nb subwidget simple].f]
46set termtab [frame [$nb subwidget tiltterm].f]
47
48
49#Populate simple tab
50set sf [frame $simpletab.sframe -background grey]
51
52pack [tixLabelEntry $sf.motorval -label "Number of clicks"] -padx 10 -pady 10
53pack [button $sf.gobut -text "Change Tilt"\
54         -command {goButProc [ [$sf.motorval subwidget entry] get] } ]\
55         -padx 10 -pady 10 -anchor s
56pack $sf -fill both -expand true
57
58#Populate term tab
59set tf [frame $termtab.tframe]
60
61pack [text $tf.output] -fill both -anchor nw -expand true
62pack [entry $tf.cmdentry] -side left -fill x -expand true -anchor w
63pack [button $tf.verbut -text "Execute Command"\
64         -command { exec_cmd [$tf.cmdentry get] } ]\
65                 -side right
66
67pack $tf -fill x
68
69#Pack up and go
70pack $nb $simpletab $termtab -fill both -expand true
71pack .fmain -fill both -expand true -anchor nw
72
73exp_send "\r"
74expect -re ">" { $tf.output insert end $expect_out(buffer)
75                exec_cmd "VER"
76                }
77expect -re ">" { $tf.output insert end $expect_out(buffer)
78                 exec_cmd "CHL A1=0"
79                }
80expect -re ">" { $tf.output insert end $expect_out(buffer)
81                exec_cmd "VEL A1 0=100"
82                }
83expect -re ">" { $tf.output insert end $expect_out(buffer)
84                exec_cmd "VEL A1 0"
85                }
86expect -re ">" { $tf.output insert end $expect_out(buffer)
87                exec_cmd "ACC A1 0"
88                }
89expect -re ">" { $tf.output insert end $expect_out(buffer) }
90
91expect_background {
92        -re ">" {
93                $tf.output insert end $expect_out(buffer)
94        }
95        -re "\\?" {
96                $tf.output insert end $expect_out(buffer)
97        }
98}               
Note: See TracBrowser for help on using the repository browser.