~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Open Mash Cross Reference
mash/tcl/applications/avswitch-client/avswitch-ui.tcl

Component: ~ [ mash ] ~ [ apps ] ~ [ gsm ] ~ [ lib ] ~ [ otcl ] ~ [ srm ] ~ [ tcl8.3 ] ~ [ tclcl ] ~ [ tk8.3 ] ~ [ tutorials ] ~

  1 # avswitch-ui.tcl --
  2 #
  3 #       FIXME: This file needs a description here.
  4 #
  5 # Copyright (c) 1996-2002 The Regents of the University of California.
  6 # All rights reserved.
  7 #
  8 # Redistribution and use in source and binary forms, with or without
  9 # modification, are permitted provided that the following conditions are met:
 10 #
 11 # A. Redistributions of source code must retain the above copyright notice,
 12 #    this list of conditions and the following disclaimer.
 13 # B. Redistributions in binary form must reproduce the above copyright notice,
 14 #    this list of conditions and the following disclaimer in the documentation
 15 #    and/or other materials provided with the distribution.
 16 # C. Neither the names of the copyright holders nor the names of its
 17 #    contributors may be used to endorse or promote products derived from this
 18 #    software without specific prior written permission.
 19 #
 20 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
 21 # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 22 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 23 # ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR
 24 # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 25 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 26 # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
 27 # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 28 # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 29 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 30 #
 31 # @(#) $Header: /usr/mash/src/repository/mash/mash-1/tcl/applications/avswitch-client/avswitch-ui.tcl,v 1.14 2002/02/03 04:21:34 lim Exp $
 32 
 33 
 34 #
 35 # UI for talking to an AVSwitchServer
 36 #
 37 Class AVSwitchUI
 38 
 39 
 40 #
 41 # init method takes window and and address specificationx
 42 #
 43 AVSwitchUI public init {w addrspec} {
 44 
 45     $self instvar al_ audio_ video_ routingType_ in_update_
 46 
 47     # if addrspec includes a name, turn it into IP addr
 48     set firstchar [string index $addrspec 0]
 49     if [string match \[a-zA-Z\] $firstchar] {
 50         set n [lindex [split $addrspec "/"] 0]
 51         set p [lindex [split $addrspec "/"] 1]
 52         set s [gethostbyname $n]
 53         if { $s == "" } {
 54             puts "cannot find address for '$n'"
 55             exit
 56         }
 57         set addrspec $s/$p
 58     }
 59 
 60     set routingType_ b
 61     set al_ [new ALM/AVSw/Client $addrspec $self]
 62     for {set j 1} {$j < 9} {incr j} {
 63         set audio_($j) 0
 64         set video_($j) 0
 65     }
 66     set in_update_ 0
 67 
 68     $al_ announce refresh_settings
 69     $self build_gui $w
 70     update
 71     $self refresh_ui
 72 }
 73 
 74 #
 75 # destructor method
 76 #
 77 AVSwitchUI public destroy {} {
 78     $self instvar al_
 79     delete $al_
 80     eval [list $self] next
 81 }
 82 
 83 AVSwitchUI public print_status {} {
 84     $self instvar audio_ video_
 85 
 86     puts ""
 87     puts "       Routing"
 88     puts "   1:2:3:4:5:6:7:8"
 89     for {set i 1} {$i <= 8} {incr i} {
 90         puts -nonewline "$i: "
 91         if {$audio_($i) == $video_($i)} {
 92             # just a "B"
 93             $self put_letter "B" $audio_($i)
 94             puts ""
 95         } else {
 96             # put a "V" and "A"
 97             if {$audio_($i) < $video_($i)} {
 98                 $self put_letter "A" $audio_($i)
 99                 $self put_letter "V" [expr $video_($i) - $audio_($i)]
100                 puts ""
101             } else {
102                 $self put_letter "V" $video_($i)
103                 $self put_letter "A" [expr $audio_($i) - $video_($i)]
104                 puts ""
105             }
106         }
107     }
108     puts ""
109 }
110 
111 AVSwitchUI private put_letter {letter dist} {
112     for {set j 1} {$j < $dist} {incr j} {
113         puts -nonewline "  "
114     }
115     puts -nonewline "$letter "
116 }
117 
118 AVSwitchUI private build_gui {w} {
119     $self instvar al_ routingType_ matrix_ input_labels_
120 
121     # build bottom informational label
122     set il $w.infolabel
123     frame $il -relief groove
124     label $il.l -text "A/V Switch Controller (326 Soda CoLab)"
125     pack $il -side bottom -fill x -expand 1
126     pack $il.l -in $il -side bottom
127 
128     # build button colums
129     set b $w.btns
130     frame $b -relief groove
131     pack $b -side left -anchor s
132     button $b.b1 -command "$al_ announce refresh_settings" \
133             -text "resynchronize"
134     button $b.b2 -command "$al_ announce test_LEDs" -text "test lights"
135     button $b.b3 -command "$self print_status" -text "print status"
136     button $b.e -command "exit" -text "EXIT"
137     pack $b.e $b.b3 $b.b2 $b.b1 -fill x -side bottom
138 
139     frame $b.routing -relief groove
140     label $b.routing.label -text "Route:"
141     radiobutton $b.routing.a -variable routingType -text "Audio" -value a \
142             -fg darkgreen -command "$self set routingType_ a"
143     radiobutton $b.routing.v -variable routingType -text "Video" -value v \
144             -fg blue -command "$self set routingType_ v"
145     radiobutton $b.routing.b -variable routingType -text "Both" -value b \
146             -fg "#b03060" -command "$self set routingType_ b"
147     pack $b.routing.label -in $b.routing -anchor w -side left
148     pack $b.routing.b $b.routing.v $b.routing.a -in $b.routing
149     pack $b.routing -fill x -expand 1 -pady 2 -side bottom
150     $b.routing.$routingType_ invoke
151 
152     # build routing matrix
153     set m $w.matrix
154     set matrix_ $m
155     frame $m
156     pack $m -side right
157     set rowLabels [list "monitor 1" "monitor 2" "monitor 3" "VCR" \
158             "(null)" "diamond" "heart" "club"]
159 
160     for {set i 1} {$i <= 8} {incr i} {
161         frame $m.rowFrame$i
162         label $m.rowFrame$i.l -text [lindex $rowLabels [expr $i-1]]
163     }
164 
165     for {set i 1} {$i <= 8} {incr i} {
166         for {set j 1} {$j <= 8} {incr j} {
167             checkbutton $m.r$i$j -command "$self invoke_button $i $j"
168         }
169     }
170     # these are for the iput labels
171     $self build_input_labels
172     frame $m.rowFrame0
173     pack $m.rowFrame0 -expand 1 -in $m -anchor w
174     label $m.rowFrame0.l -image $input_labels_
175     pack $m.rowFrame0.l -in $m.rowFrame0 -side left -padx 3
176     for {set i 1} {$i <= 8} {incr i} {
177         pack $m.rowFrame$i -expand 1 -in $m -anchor w
178         pack $m.rowFrame$i.l -in $m.rowFrame$i -side right
179     }
180     for {set i 1} {$i <= 8} {incr i} {
181         for {set j 1} {$j <= 8} {incr j} {
182             pack $m.r$i$j -in $m.rowFrame$i -side left
183         }
184     }
185 
186     bind . <q> exit
187 }
188 
189 AVSwitchUI private repaint_matrix {} {
190     $self instvar audio_ video_ matrix_ in_update_
191 
192     if {$in_update_ == 1} {
193         return
194     }
195 
196     set m $matrix_
197 
198     # check if still waiting for update
199     if {[lsearch [array get audio_] 0] != -1 || \
200             [lsearch [array get video_] 0] != -1} {
201 #puts "waiting for update..."
202         [$self set al_] announce refresh_settings
203         return
204     }
205 
206     set in_update_ 1
207 
208     for {set i 1} {$i <= 8} {incr i} {
209         for {set j 1} {$j <= 8} {incr j} {
210             $m.r$i$j deselect
211         }
212     }
213     for {set i 1} {$i <= 8} {incr i} {
214         if {$audio_($i) == $video_($i)} {
215             $m.r$i$audio_($i) configure -selectcolor "#b03060"
216             $m.r$i$audio_($i) select
217         } else {
218             $m.r$i$audio_($i) configure -selectcolor darkgreen
219             $m.r$i$audio_($i) select
220             $m.r$i$video_($i) configure -selectcolor blue
221             $m.r$i$video_($i) select
222         }
223     }
224     set in_update_ 0
225 }
226 
227 AVSwitchUI private invoke_button {i j} {
228     $self instvar routingType_ audio_ video_
229     #puts "$routingType_: $i $j"
230 
231     set al [$self set al_]
232     if {$routingType_ == "a"} {
233         set audio_($i) $j
234         $al announce "route_audio $i $j"
235     } elseif {$routingType_ == "v"} {
236         set video_($i) $j
237         $al announce "route_video $i $j"
238     } else {
239         set audio_($i) $j
240         set video_($i) $j
241         $al announce "route_both $i $j"
242     }
243     $self repaint_matrix
244 }
245 
246 AVSwitchUI private refresh_ui {} {
247     $self repaint_matrix
248 }
249 
250 
251 #
252 # This is an embedded gif of vertical input labels
253 #
254 
255 # -- These cmds generate a list that can then be rotated, saved
256 # -- as a .gif, and put into the avswitch via conversion by image2tcl
257 #
258 #set columnLabels [list "heart" "diamond" "club" "VCR" "cam1 (red)" \
259 #               "cam2 (yellow)" "cam3 (blue)" "cam4 (green)"]
260 #for  {set i 1} {$i <= 8} {incr i} {
261 #       label .l$i -text [lindex $columnLabels [expr $i-1]]
262 #       pack .l$i -anchor w -pady  3 }
263 #
264 # -- The result for the current inputs are embedded in the following
265 AVSwitchUI private build_input_labels {} {
266     $self instvar input_labels_
267 
268     image create photo AVSwInputs
269     AVSwInputs put \x47\x49\x46\x38\x39\x61\xC2\x\x56\x\x91\x\x\xD8\xD8\xD8\x\x\x\xFF\xFF\xFF\xFF\xFF\xFF\x21\xF9\x4\x\x\x\x\x\x2C\x\x\x\x\xC2\x\x56\x\x\x2\xFF\x84\x8F\xA9\xCB\xED\xF\xA3\x9C\x31\xD8\x4B\xB3\xDE\xBC\xFB\xF\x2A\xD7\x88\x85\xE6\x89\xA6\x6A\x56\x22\xED\xA\xC7\xF2\x2C\x5\x8E\x4D\xE7\xFA\xCE\xF7\xFE\xF\xC\xA\x87\xC4\x90\xA5\x68\x20\xE1\x90\x4C\x18\x49\xA8\x1C\x35\xA7\xAA\xA7\xEF\x95\x3C\x52\xB7\x27\x6D\x6F\xB9\x\x73\xC7\x13\x2B\xF9\x8C\xBE\x49\xD3\xEC\x76\x58\xFC\x35\xBB\xE7\x9\x79\xDC\x4E\x77\xE3\xBF\xF9\xBE\x8\xBE\xA1\xC4\x1\xE8\x57\x18\x18\xE5\x55\x23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x17\x8E\xAC\xF5\x62\xC9\x7C\x90\xE7\x4A\x93\xEC\x39\xB4\xE8\x78\x95\x47\x2F\xED\x6C\x7A\xF1\xDE\xD4\x45\x9E\x71\xED\xE4\x39\x15\xC6\x5E\x97\xC7\xB2\x85\x4D\xB2\x34\xE5\x44\x16\xDF\xF6\x74\xE4\xFB\x27\x57\x24\xC1\x35\x66\x99\x2A\x12\xAA\xBD\xB8\x1D\x75\xEF\x46\xD\x55\x4B\xEF\xB8\x1C\xA5\x87\xF9\xBA\x99\xCD\xF0\xB1\xB6\x7B\x77\x1A\x2E\x91\xE6\x7\xD0\x6D\xB6\x23\x37\xEC\xEE\xFC\xA1\x37\xF9\x58\x7\x35\x6F\x3E\xE2\x60\x7F\xD9\xB1\xD6\xFF\x4D\x9F\x2C\x74\xCC\xAF\xEF\xBF\xFF\x21\x6F\x9F\x7F\xFF\x9\xC8\x5F\x75\x29\x1\xF8\x9B\x81\x62\x2D\x91\xD9\x6A\x1\x4D\xE6\x56\x7A\x8F\x40\xD8\x55\x5\xEA\x45\xD5\x5E\x86\xE3\x9\x57\xDD\x37\x17\xF2\x55\x61\x45\xF9\x35\x68\x19\x89\xCD\xC9\xA6\xDB\x7E\x25\x12\xD8\x5D\x65\x8\x42\xA3\x62\x8B\x24\xDE\xE6\xD5\x63\x99\x15\x37\xA0\x8B\x14\x4E\xA4\xA1\x71\xF7\xF4\x98\x47\x7C\x21\x36\x3\x24\x4D\x2C\xCA\x54\x9B\x8C\xB3\x39\x68\xE3\x88\xFD\x1D\xA9\x59\x60\xC7\x89\x58\x91\x77\xEA\x54\x89\x65\x6E\x50\xAE\x28\xA4\x8\x35\xF2\x38\xA1\x97\x45\x12\xB9\x61\x91\xFC\x10\x39\x52\x84\x61\x32\x79\xD6\x93\x49\xCA\xE8\x24\x92\x4\xAD\xB7\xE5\x89\x37\x7E\x47\xA5\x96\x26\xC6\x8\x67\x55\x69\x86\xB9\xA7\x8B\x7C\xB2\xD4\xE1\x8F\xEE\xFC\xB9\x92\xA1\x84\x5A\x55\xE7\xA2\x18\x22\x6A\xA1\xA2\xC9\x55\xF8\xA2\x97\x95\x22\xE9\xDC\x78\xB1\xBC\x39\x67\x9D\xB4\xCD\xB8\x29\x2E\x5B\x86\xA\x25\x8E\xE2\x25\x65\xE2\x3B\xE0\x4D\x89\x66\x97\x96\x34\x2A\x57\x8C\xA6\xFA\x38\xE4\x51\x9C\x22\xB7\x2A\x73\x6B\xE6\x1A\xE2\xA5\x51\xA\xCA\x9D\x5B\xA0\x6\xCB\xE\xB1\x28\x19\xDB\x16\xAB\xBA\x36\x82\xF9\x1A\x9B\x2F\x91\xB9\x2C\x88\xD1\xCA\xF3\xA1\xB4\xBD\x2\x59\x68\xB5\x1\xF2\x3A\x6D\x5E\xD9\x76\xDB\x57\x74\x2E\xD\xE5\xA9\xAC\xB0\x72\x99\x65\x43\x9C\xEA\x33\x6B\x8E\x1\x8D\xEA\x6A\x8A\xB0\xCA\xFB\x42\x1\x\x3B
270 
271     set input_labels_ AVSwInputs
272 }
273 
274 
275 #----------------------------------------------
276 
277 import AnnounceListenManager
278 
279 #
280 # AVSwitch RPC-style interface client
281 #
282 Class ALM/AVSw/Client -superclass AnnounceListenManager
283 
284 
285 ALM/AVSw/Client public init {addrspec parent {mtu 1500}} {
286     eval [list $self] next $addrspec $mtu
287 
288     $self instvar parent_
289     set parent_ $parent
290     $self ttl 16
291 }
292 
293 #
294 # receive (only) matrix state updates of the form
295 # "v: <array> ; a: <array>"
296 #
297 ALM/AVSw/Client private recv_announcement {addr port data size} {
298     #puts "Msg: $addr/$port\[$size\]: $data"
299     $self instvar parent_
300 
301     # filter other client's requests
302     if {$data == "refresh_settings"} {return}
303 
304     set t [split $data ";"]
305     set vid [lindex $t 0]
306     set aud [lindex $t 1]
307     set vid [string trim  $vid " "]
308     set aud [string trim  $aud " "]
309     if {[string range $vid 0 2] != "v: " || [string range $aud 0 2] != "a: "} {
310                 puts "bad msg received from AVSw server: $data"
311                 return
312     }
313     #puts "got status"
314     set vid [string range $vid 3 end]
315     set aud [string range $aud 3 end]
316     $parent_ array set audio_ $aud
317     $parent_ array set video_ $vid
318     $parent_ refresh_ui
319 }
320 
321 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.