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

Open Mash Cross Reference
mash/tcl/psvp/synch-ui.tcl

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

  1 # synch-ui.tcl --
  2 #
  3 #       FIXME: This file needs a description here.
  4 #
  5 # Copyright (c) 1999-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 Class SynchSourceUI
 32 
 33 SynchSourceUI instproc init {switch src frame} {
 34     $self instvar switch_;
 35     $self instvar synch_src_;
 36     $self instvar frame_;
 37     $self instvar tscale_;
 38     $self instvar num_latbars_;
 39 
 40     set switch_ $switch;
 41     set synch_src_ $src;
 42     set frame_ $frame;
 43 
 44     set tscale_ 1.5;
 45 
 46     $self instvar l_ c_ lat_lab_;
 47 
 48     set l_ [label $frame.l];
 49     set c_ [canvas $frame.c -width 150 -height 30];
 50     set lat_lab_ [label $frame.lat_l];
 51 
 52     $l_ configure -text "[[$src set sess_] set spec_]/[[$src set src_] srcid]";
 53 
 54     pack $l_ -side top;
 55     pack $c_ -side top;
 56     pack $lat_lab_ -side top;
 57 
 58     $self instvar latbars_
 59 
 60     set num_latbars_ 10;
 61 
 62     for {set i 0} {$i < $num_latbars_} {incr i} {
 63         set y1 [expr ((30*$i)/$num_latbars_)];
 64         set y2 [expr ((30*($i+1))/$num_latbars_)];
 65 
 66         set latbars_($i) [$c_ create rectangle 75 $y1 75 $y2 -fill black -outline black];
 67     }
 68 
 69     $self instvar last_num_frames_;
 70     $self instvar last_update_time_;
 71 
 72     set last_update_time_ [clock clicks];
 73     set last_num_frames_ [$synch_src_ num_frames];
 74 
 75     $self instvar update_period_;
 76     set update_period_ 500;
 77     after $update_period_ "$self update_latency";
 78 }
 79 
 80 SynchSourceUI instproc update_latency {} {
 81     $self instvar last_num_frames_ last_update_time_;
 82     $self instvar synch_src_;
 83 
 84     set lat [$synch_src_ buffer_latency];
 85 
 86     $self instvar l_ lat_lab_ tscale_ c_ latbars_
 87 
 88     set nf [$synch_src_ num_frames];
 89     set now [clock clicks];
 90 
 91     set fr [expr double($nf - $last_num_frames_) / (double($now - $last_update_time_) / 1000000.0)];
 92     set last_num_frames_ $nf;
 93     set last_update_time_ $now;
 94 
 95     $lat_lab_ configure -text "$fr fps :: $lat latency"
 96 
 97     $self instvar num_latbars_;
 98 
 99     for {set i 0} {$i < [expr $num_latbars_ - 1]} {incr i} {
100         $c_ move $latbars_($i) 0 [expr 30/$num_latbars_];
101     }
102     $c_ delete $latbars_([expr $num_latbars_ - 1]);
103 
104     for {set i [expr $num_latbars_-1]} {$i > 0} {incr i -1} {
105         set latbars_($i) $latbars_([expr $i-1]);
106     }
107 
108     if {$lat < 0.0} {
109         set color red;
110     } else {
111         set color black;
112     }
113     set x [expr int((($lat / $tscale_) * 75.0) + 75.0)];
114 
115     set latbars_(0) [$c_ create rectangle 75 0 $x [expr 30/$num_latbars_] -fill $color -outline $color];
116 
117     $self instvar update_period_;
118     after $update_period_ "$self update_latency";
119 }
120 
121 Class SynchTransmitterUI
122 
123 SynchTransmitterUI instproc init {switch xmitter frame} {
124     $self instvar switch_ xmitter_ frame_ stype_
125 
126     set switch_ $switch;
127     set xmitter_ $xmitter;
128     set frame_ $frame;
129 
130     set stype_ straight
131 
132     $self instvar l_ src_b_ switch_type_ src_m_ switch_m_;
133 
134     set l_ [label $frame_.l -text "Sink: [$xmitter set spec_]"];
135 
136     if {[$xmitter_ set cur_src_] == ""} {
137         set src_b_ [menubutton $frame_.mb -text "Source: None" -menu $frame_.mb.m];
138     } else {
139         set src_b_ [menubutton $frame_.mb -text "Source: [[[$xmitter_ set cur_src_] set sess_] set spec_]" -menu $frame_.mb.m];
140     }
141     set src_m_ [menu $frame_.mb.m];
142     bind $src_b_ <Button-1> "$self make_src_menu; continue";
143 
144     set switch_type_ [menubutton $frame_.stype -text "Switch Type: straight" -menu $frame_.stype.m];
145     set switch_m_ [menu $frame_.stype.m];
146     $switch_m_ add command -label "straight" -command "$switch_type_ configure -text {Switch Type: straight}; $self set stype_ straight;"
147     $switch_m_ add command -label "pre prep" -command "$switch_type_ configure -text {Switch Type: pre prep}; $self set stype_ pre_prep;"
148     $switch_m_ add command -label "post prep" -command "$switch_type_ configure -text {Switch Type: post prep}; $self set stype_ post_prep;"
149 
150     pack $l_ -side top;
151     pack $src_b_ -side top;
152     pack $switch_type_ -side top;
153 }
154 
155 SynchTransmitterUI instproc make_src_menu {} {
156     $self instvar xmitter_ switch_ src_m_ src_b_;
157 
158     set slist [$switch_ set sources_];
159 
160     $src_m_ delete 0 end
161 
162     foreach s $slist {
163         $src_m_ add command -label "[[$s set sess_] set spec_]" \
164             -command "     \
165             $src_b_ configure -text \"Source: [[$s set sess_] set spec_]\";\
166             $self execute_switch $s;"
167     }
168 }
169 
170 SynchTransmitterUI instproc execute_switch {src} {
171     $self instvar xmitter_ switch_ stype_;
172 
173     if {$stype_ == "straight"} {
174         $switch_ straight_switch $src $xmitter_;
175     } elseif {$stype_ == "pre_prep"} {
176         $switch_ prep_switch $src $xmitter_ 1;
177     } elseif {$stype_ == "post_prep"} {
178         $switch_ switch_prep $src $xmitter_ 1;
179     }
180 }
181 
182 

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