1 # datasrc-local.tcl --
2 #
3 # DataSrc/Local -- local receiver that knows how to send data
4 #
5 # Copyright (c) 1997-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
32 Class DataSrc/Local -superclass DataSrc
33
34 DataSrc/Local instproc init {} {
35 $self next
36 }
37
38 # REVIEW: should be possible to put more than one event onto one packet...
39 DataSrc/Local instproc next_ADU {maxLen} {
40 # REVIEW: should for overflowing maxlen
41
42 $self instvar outbox_ events_ outbox_
43 set outItem [removeFirst outbox_]
44 # for events, append the content of the event
45 if {[lindex $outItem 0]=="e"} {
46 set eId [lindex $outItem 1]
47 return [lappend outItem $events_($eId)]
48 } else {
49 return $outItem
50 }
51 }
52
53 # REVIEW: this should go into a linked list in C++
54 DataSrc/Local instproc req_send_event {eventId} {
55 $self instvar outbox_ atobjRcvr_ events_
56 lappend outbox_ [list e $eventId]
57 $atobjRcvr_ begin_xmit [expr \
58 [string length $events_($eventId)] + 6 \
59 + [string length $eventId] ]
60 }
61
62 DataSrc/Local instproc req_sent_ctrl {ctrlMsg} {
63 $self instvar outbox_ atobjRcvr_
64 set m [list c $ctrlMsg]
65 set l [string length $m]
66 lappend outbox_ $m
67 $atobjRcvr_ begin_xmit $l
68 }
69
70 # gives the source a chance to send out any data...
71 DataSrc/Local instproc setup {} {
72 }
73
74 # this procedure provides the loopback + outflow to network that we need
75 DataSrc/Local instproc handle {eId event} {
76 # DbgOut "handle: $event, eId: $eId"
77 $self req_send_event $eId
78
79 # this sends the data up to the view
80 $self next $eId $event
81 }
82
83 DataSrc/Local instproc advance {time} {
84 $self instvar view_
85 # advance first
86 $self next $time
87 $view_ update $time
88 set min [$view_ oldestEId]
89 set max [$view_ newestEId]
90
91 $self req_sent_ctrl [list r $time $min $max]
92 DbgOut req_sent-ctrl r $min $max $time
93 }
94
95
This page was automatically generated by the
LXR engine.
Visit the LXR main site for more
information.