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

Open Mash Cross Reference
mash/tcl/vd/qm/application-qm.tcl

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

  1 # application-qm.tcl --
  2 #
  3 #       Creates a QuestionMonitor app.
  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 Import enable
 32 
 33 import Application QuestionMonitor DpClient
 34 
 35 namespace eval QuestionMonitorApplication {
 36     variable self
 37 }
 38 
 39 Class QuestionMonitorApplication -superclass Application
 40 
 41 QuestionMonitorApplication instproc init { argv } {
 42     $self instvar qm_ serv_ port_
 43 
 44     $self next "qm"
 45 
 46     set QuestionMonitorApplication::self $self
 47 
 48     $self initArgs
 49     set options [$self options]
 50     # parse command line args
 51     $options parse_args $argv
 52 
 53     set spec [list]
 54     lappend spec [$options get_option withGui]
 55     lappend spec [$options get_option mode]
 56     lappend spec [$options get_option audioAddress]
 57     lappend spec [$options get_option audioPort]
 58     lappend spec [$options get_option logOutDir]
 59     lappend spec [$options get_option logInDir]
 60     lappend spec [$options get_option speakerThreshold]
 61     lappend spec [$options get_option audienceLeftThreshold]
 62     lappend spec [$options get_option audienceCenterThreshold]
 63     lappend spec [$options get_option audienceRightThreshold]
 64     # add other spec stuff here
 65 
 66     set withGui [$options get_option withGui]
 67     if {$withGui} {
 68         set frm [$self initUI]
 69     } else {
 70         set frm ""
 71         # get rid of the base MASH window
 72         wm withdraw .
 73     }
 74 
 75     # args are: baseFrame, spec
 76     set qm_ [new QuestionMonitor $frm $spec]
 77 
 78     set port_ [$options get_option rpcPort]
 79     set serv_ [new DpServer $port_]
 80 }
 81 
 82 QuestionMonitorApplication instproc initArgs {} {
 83     set options [$self options]
 84 
 85     # register valid options
 86     $options register_option -withGui withGui
 87     $options register_option -mode mode
 88     $options register_option -aa audioAddress
 89     $options register_option -ap audioPort
 90     $options register_option -lodir logOutDir
 91     $options register_option -lidir logInDir
 92     $options register_option -st speakerThreshold
 93     $options register_option -lt audienceLeftThreshold
 94     $options register_option -ct audienceCenterThreshold
 95     $options register_option -rt audienceRightThreshold
 96     $options register_option -port rpcPort
 97 
 98     # set up defaults
 99     $options add_default withGui 1
100     $options add_default mode record
101     $options add_default audioAddress 233.0.25.131
102     $options add_default audioPort 22446
103     $options add_default logOutDir log
104     $options add_default logInDir log-input
105     $options add_default speakerThreshold 40
106     $options add_default audienceLeftThreshold 60
107     $options add_default audienceCenterThreshold 60
108     $options add_default audienceRightThreshold 60
109     $options add_default rpcPort 6903
110 }
111 
112 QuestionMonitorApplication instproc initUI {} {
113     wm title . "Question Monitor"
114     wm minsize . 200 0
115 
116     set baseFrame .qmFrame
117     frame $baseFrame
118     pack $baseFrame -side top
119 
120     # make exit button
121     button .exit -text "Exit" -command "$self exitApp"
122     pack .exit -side bottom
123 
124     return $baseFrame
125 }
126 
127 QuestionMonitorApplication instproc setOutput {output} {
128     $self instvar qm_
129 
130     $qm_ setOutput "$output"
131 }
132 
133 QuestionMonitorApplication public exitApp {} {
134     $self instvar qm_
135 
136     set msg "Are you sure you want to exit QM?"
137     set result [tk_messageBox -message $msg -default "ok" -type okcancel -title "Question Monitor" -icon "question"]
138     if {$result == "ok"} {
139         $qm_ destroy
140         exit
141     }
142 }
143 
144 QuestionMonitorApplication instproc enableQM {} {
145     $self instvar qm_
146 
147     $qm_ enable
148 }
149 
150 QuestionMonitorApplication instproc disableQM {} {
151     $self instvar qm_
152 
153     $qm_ disable
154 }
155 
156 QuestionMonitorApplication instproc markQuestionStart {region} {
157     $self instvar qm_
158 
159     $qm_ markQuestionStart $region
160 }
161 
162 QuestionMonitorApplication instproc markQuestionEnd {region} {
163     $self instvar qm_
164 
165     $qm_ markQuestionEnd $region
166 }
167 
168 QuestionMonitorApplication instproc setThreshold {mic threshold} {
169     $self instvar qm_
170 }
171 
172 proc setOutput {output} {
173     $QuestionMonitorApplication::self setOutput $output
174 }
175 
176 proc enableQM {} {
177     $QuestionMonitorApplication::self enableQM
178 }
179 
180 proc disableQM {} {
181     $QuestionMonitorApplication::self disableQM
182 }
183 
184 proc markQuestionStart {region} {
185     $QuestionMonitorApplication::self markQuestionStart $region
186 }
187 
188 proc markQuestionEnd {region} {
189     $QuestionMonitorApplication::self markQuestionEnd $region
190 }
191 
192 proc rqm_killServer {} {
193     after 1000 "$QuestionMonitorApplication::self exitApp"
194 }
195 
196 # FIXME - this has not been fully implemented
197 proc rqm_setThreshold {mic threshold} {
198     $QuestionMonitorApplication::self setThreshold $mic $threshold
199 }

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