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

Open Mash Cross Reference
mash/tcl/vd/test/matrix.tcl

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

  1 # matrix.tcl --
  2 #
  3 #       Allows raw setting of video matrix connections in 405.
  4 #
  5 # Copyright (c) 2000-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 global g_app
 32 
 33 Import enable
 34 
 35 import Application DpClient
 36 
 37 Class MatrixApp -superclass Application
 38 
 39 MatrixApp instproc init {argv} {
 40     $self instvar amx_
 41 
 42     $self next $argv
 43     $self initUI
 44 #    $self initAmx garfield.cs.berkeley.edu 6905
 45     $self initAmx htsr.bmrc.berkeley.edu 6901
 46 }
 47 
 48 #
 49 # GUI stuff
 50 #
 51 
 52 MatrixApp instproc initUI {} {
 53     $self instvar in1Text_ in2Text_ out1Text_ out2Text_ in1_ in2_ out1_ out2_
 54 
 55     wm title . "MatrixTest"
 56     wm minsize . 150 0
 57 
 58     frame .entry
 59     pack .entry -side top -pady 10
 60 
 61     label .entry.in1Label  -text "In1"
 62     pack .entry.in1Label -side left
 63     set in1Text_ [text .entry.in1Text -width 4 -height 1]
 64     pack .entry.in1Text -side left
 65     $in1Text_ insert 0.0 "1"
 66 
 67     label .entry.out1Label  -text "Out1"
 68     pack .entry.out1Label -side left
 69     set out1Text_ [text .entry.out1Text -width 4 -height 1]
 70     pack .entry.out1Text -side left
 71     $out1Text_ insert 0.0 "2"
 72 
 73     label .entry.in2Label  -text "In2"
 74     pack .entry.in2Label -side left
 75     set in2Text_ [text .entry.in2Text -width 4 -height 1]
 76     pack .entry.in2Text -side left
 77     $in2Text_ insert 0.0 "1"
 78 
 79     label .entry.out2Label  -text "Out2"
 80     pack .entry.out2Label -side left
 81     set out2Text_ [text .entry.out2Text -width 4 -height 1]
 82     pack .entry.out2Text -side left
 83     $out2Text_ insert 0.0 "7"
 84 
 85 
 86     frame .but
 87     pack .but -side top -pady 10
 88 
 89     button .but.send -text "Switch" -command "$self doSwitch"
 90     pack .but.send -side left
 91     button .but.status -text "Status" -command "$self getStatus"
 92     pack .but.status -side left
 93 
 94     button .but.test1 -text "Test 1" -command "$self doTest1"
 95     pack .but.test1 -side left
 96 
 97     # make exit button
 98     button .exit -text "Exit" -command "$self exitApp"
 99     pack .exit -side bottom
100 }
101 
102 MatrixApp instproc initAmx { {hostname htsr.bmrc.berkeley.edu} {port 6901}} {
103     $self instvar amx_
104 
105     if {[catch {new DpClient $hostname $port} amx_]} {
106         puts stderr "Fatal error:  could not connext to AMX server"
107         exit
108     }
109 }
110 
111 MatrixApp instproc exitApp {} {
112     $self instvar amx_
113 
114     $amx_ closeRPC
115     exit
116 }
117 
118 MatrixApp public doSwitch {} {
119     $self instvar amx_ in1_ in2_ out1_ out2_
120 
121     $self get_values
122 
123     puts stdout "in1=$in1_ in2=$in2_ out1=$out1_ out2=$out2_"
124 
125     # 4 means send string, 2 means send it to the matrix
126     $amx_ do matrix_rawSwitchVideoStream 1 $in1_ $out1_
127     $amx_ do matrix_rawSwitchVideoStream 2 $in2_ $out2_
128 }
129 
130 MatrixApp public doTest1 {} {
131     $self instvar amx_
132 
133     set output "htsr"
134     set result [$amx_ do matrix_getInputSource $output]
135     puts stdout "matrix_getInputSource $output returns $result"
136 
137     set output "htsr2"
138     set result [$amx_ do matrix_getInputSource $output]
139     puts stdout "matrix_getInputSource $output returns $result"
140 
141     set output "realNetworks"
142     set result [$amx_ do matrix_getInputSource $output]
143     puts stdout "matrix_getInputSource $output returns $result"
144 
145     set output "projector"
146     set result [$amx_ do matrix_getInputSource $output]
147     puts stdout "matrix_getInputSource $output returns $result"
148 
149         set output "projectorRGB"
150     set result [$amx_ do matrix_getInputSource $output]
151     puts stdout "matrix_getInputSource $output returns $result"
152 
153     puts stdout ""
154 }
155 
156 MatrixApp public getStatus {} {
157     $self instvar amx_
158 
159     set input 7
160     set output 3
161     set level 2
162 
163     puts stdout "getting status"
164 
165     for {set x 0} {$x < 1} {incr x 1} {
166         set result [$amx_ do matrix_getStatus $level input $input]
167         puts stdout "matrix_getStatus level $level input $input returns $result"
168         set result [$amx_ do matrix_getStatus $level output $output]
169         puts stdout "matrix_getStatus level $level output $output returns $result"
170     }
171 
172     set level 2
173     set input 1
174     set output 7
175 
176 
177     for {set x 0} {$x < 1} {incr x 1} {
178         set result [$amx_ do matrix_getStatus $level input $input]
179         puts stdout "matrix_getStatus level $level input $input returns $result"
180         set result [$amx_ do matrix_getStatus $level output $output]
181         puts stdout "matrix_getStatus level $level output $output returns $result"
182     }
183 }
184 
185 MatrixApp private get_values {} {
186     $self instvar in1Text_ in2Text_ out1Text_ out2Text_ in1_ in2_ out1_ out2_
187 
188     set in1_ 1
189     set in2_ 1
190     set out1_ 1
191     set out2_ 1
192 
193     set temp_str [$in1Text_ get 1.0 1.end]
194     scan $temp_str "%d" in1_
195     set temp_str [$in2Text_ get 1.0 1.end]
196     scan $temp_str "%d" in2_
197     set temp_str [$out1Text_ get 1.0 1.end]
198     scan $temp_str "%d" out1_
199     set temp_str [$out2Text_ get 1.0 1.end]
200     scan $temp_str "%d" out2_
201 }
202 
203 
204 #
205 # driver engine
206 #
207 
208 set g_app [new MatrixApp $argv]
209 
210 # next line is very important!!!
211 vwait forever
212 
213 

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