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

Open Mash Cross Reference
mash/tcl/vd/cf/cf.tcl

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

  1 # cf.tcl --
  2 #
  3 #       Provides content follower.  Causes one RVC to show the same thing that
  4 #       is on the projector in 405.
  5 #
  6 # Copyright (c) 2000-2002 The Regents of the University of California.
  7 # All rights reserved.
  8 #
  9 # Redistribution and use in source and binary forms, with or without
 10 # modification, are permitted provided that the following conditions are met:
 11 #
 12 # A. Redistributions of source code must retain the above copyright notice,
 13 #    this list of conditions and the following disclaimer.
 14 # B. Redistributions in binary form must reproduce the above copyright notice,
 15 #    this list of conditions and the following disclaimer in the documentation
 16 #    and/or other materials provided with the distribution.
 17 # C. Neither the names of the copyright holders nor the names of its
 18 #    contributors may be used to endorse or promote products derived from this
 19 #    software without specific prior written permission.
 20 #
 21 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
 22 # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 23 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 24 # ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR
 25 # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 26 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 27 # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
 28 # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 29 # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 30 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 31 
 32 Import enable
 33 
 34 import 405Client
 35 
 36 # use the Tcl namespace facility to prevent conflicts
 37 namespace eval ContentFollower {
 38     variable self
 39     variable enabled
 40     variable outputSource
 41 }
 42 
 43 Class ContentFollower
 44 
 45 ContentFollower instproc init {base {extendedGUI 1}} {
 46     $self instvar 405_
 47 
 48     set 405_ [new 405Client]
 49 
 50     # so that the callback can refer to this object
 51     set ContentFollower::self $self
 52 
 53     set callback "$self processAmxMsg"
 54     set filter [$self getFilter]
 55     $405_ callback_register $callback $filter
 56 
 57     $self initUI $base $extendedGUI
 58 }
 59 
 60 ContentFollower instproc initUI {base extendedGUI} {
 61     frame $base.controls -borderwidth 3
 62     pack $base.controls -side top -fill x
 63 
 64     checkbutton $base.controls.onOff -text "Enable Content Following" -variable ContentFollower::enabled -command "$self toggleOnOff"
 65     pack $base.controls.onOff -side left
 66 
 67     if {$extendedGUI} {
 68         frame $base.outputs -borderwidth 3
 69         pack $base.outputs -side top -fill x
 70 
 71         # I have to give each button its own frame to make it look pretty and
 72         #  line up correctly
 73         frame $base.outputs.labelFrame
 74         pack $base.outputs.labelFrame -side top -fill x
 75         label $base.outputs.labelFrame.outputLabel -text "Output Sources"
 76         pack $base.outputs.labelFrame.outputLabel -side left
 77 
 78         frame $base.outputs.htsrBut
 79         pack $base.outputs.htsrBut -side top -fill x
 80         radiobutton $base.outputs.htsrBut.htsr -text "htsr" -variable ContentFollower::outputSource -value "htsr"
 81         pack $base.outputs.htsrBut.htsr -side left
 82 
 83         frame $base.outputs.htsr2But
 84         pack $base.outputs.htsr2But -side top -fill x
 85         radiobutton $base.outputs.htsr2But.htsr2 -text "htsr2" -variable ContentFollower::outputSource -value "htsr2"
 86         pack $base.outputs.htsr2But.htsr2 -side left
 87     }
 88 
 89 
 90      # put all the inits down here in case we call toggleOnOff, which needs
 91     #   ContentFollower::outputSource to be defined already
 92 
 93     set ContentFollower::outputSource "htsr"
 94 
 95     # if you want the default to be on, have to set ContentFollower::enabled
 96     #   to 1 and call toggleOnOff manually
 97     set ContentFollower::enabled 0
 98 #    set ContentFollower::enabled 1
 99 #    $self toggleOnOff
100 }
101 
102 ContentFollower public toggleOnOff {} {
103     $self instvar 405_
104 
105     set callback "$self processAmxMsg"
106     if {$ContentFollower::enabled == 0} {
107         $405_ callback_disable $callback
108     } else {
109         $405_ callback_enable $callback
110     }
111 
112 }
113 
114 ContentFollower public AMXSwitch { target output } {
115     $self instvar 405_
116 
117     $405_ matrix_switchVideoStream $target $output
118 }
119 
120 ContentFollower public processAmxMsg { amxMsg } {
121 #    puts stdout "amxMsg is $amxMsg"
122 
123     if {[llength $amxMsg] != 0} {
124         set eventInfo [lindex $amxMsg 0]
125         set type [lindex $eventInfo 0]
126         set eventData [lindex $amxMsg 1]
127         set cmd [lindex $eventData 0]
128         set dev [lindex $eventData 1]
129         set chan_str [lindex $eventData 2]
130 #       puts stdout "processAmxMsg: received type=$type, cmd=$cmd, dev=$dev, chan_str=$chan_str"
131     } else {
132         puts stderr "processAmxMsg: nothing received"
133         return
134     }
135 
136     if {$type != "amxResponse"} {
137         # it couldn't possibly be a button push
138         return
139     }
140 
141     if {$dev == "remotePanel" || $dev == "touchPanel"} {
142         if {$cmd == "push"} {
143             # it is a user pushing a button on the touch panel
144             #           puts stdout "matrix command"
145             switch -exact -- $chan_str {
146                 pcToProj {
147                     # PC
148 #                   puts stdout "switching to PC"
149                     $self AMXSwitch frontPC $ContentFollower::outputSource
150                 }
151                 vcrToProj {
152                     # vcr
153 #                   puts stdout "switching to VCR"
154                     $self AMXSwitch frontVCR $ContentFollower::outputSource
155                 }
156                 elmoToProj {
157                     # elmo
158 #                   puts stdout "switching to elmo"
159                     $self AMXSwitch elmo $ContentFollower::outputSource
160                 }
161                 laptopToProj {
162                     # laptop
163 #                   puts stdout "switching to laptop"
164                     $self AMXSwitch laptop $ContentFollower::outputSource
165                 }
166                 sgiToProj {
167                     # sgi
168 #                   puts stdout "switching to sgi"
169                     $self AMXSwitch sgiPC $ContentFollower::outputSource
170                 }
171                 default {
172                     # something not related to matrix
173 #                   puts stdout "non-matrix button pushed -- autoswitch ignoring"
174                 }
175             }
176         }
177     }
178 
179     return ""
180 }
181 
182 ContentFollower public setOutput {output} {
183     switch -exact -- $output {
184         htsr -
185         htsr2 {
186             set ContentFollower::outputSource $output
187         }
188         default {
189             return -code error "ContentFollower::setOutput: output must be \[htsr, htsr2\]"
190         }
191     }
192 }
193 
194 ContentFollower public enable {} {
195     set ContentFollower::enabled 1
196     $self toggleOnOff
197 }
198 
199 ContentFollower public disable {} {
200     set ContentFollower::enabled 0
201     $self toggleOnOff
202 }
203 
204 ContentFollower instproc getFilter {} {
205     # this filters out everything but button pushes on the touch panel or
206     #   remote panel
207     #
208     # we don't try to filter out for specific buttons, since that is too much
209     #   work!
210     set filter ""
211     set filter "$filter set doCallback 0\n"
212     set filter "$filter set info \[lindex \$arg 0\]\n"
213     set filter "$filter set type \[lindex \$info 0\]\n"
214     set filter "$filter set data \[lindex \$arg 1\]\n"
215     set filter "$filter if \{\$type == \"amxResponse\"\} \{\n"
216     set filter "$filter set cmd \[lindex \$data 0\]\n"
217     set filter "$filter set dev \[lindex \$data 1\]\n"
218     set filter "$filter set chan \[lindex \$data 2\]\n"
219     set filter "$filter if \{\$dev == \"remotePanel\" || \$dev == \"touchPanel\"\} \{\n"
220     set filter "$filter if \{\$cmd == \"push\"\} \{\n"
221     set filter "$filter set doCallback 1\n"
222     set filter "$filter \}\n"
223     set filter "$filter \}\n"
224     set filter "$filter \}\n"
225 
226     return $filter
227 }
228 
229 

~ [ 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.