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

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

Basic GUI - two tabs with simple #clicks in first and full command interface in second.

File size: 1.8 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
73expect_background {
74        -re ">" {
75                $tf.output insert end $expect_out(buffer)
76        }
77        -re "\\?" {
78                $tf.output insert end $expect_out(buffer)
79        }
80}               
81
82exp_send "\r"
Note: See TracBrowser for help on using the repository browser.