rcdi-tool.tcl
1: #!/usr/bin/wish
2: #
3: #
4:
5:
6: set DATA {1 3 5 6 7 9 11 12 12 10}
7: set DATA2 {-3 3 7 8 9 9 11 12 12 10}
8: set DATA3 {-1 4 8 10 2 9 11 12 2 10}
9: set UDATA {0 1000 2000 3000 4000 5000 6000 7000 8000 9000}
10:
11: set DISPLAY_W 600
12: set DISPLAY_H 180
13: set DISPLAY_PAD_X 50
14: set DISPLAY_PAD_X2 50
15: set DISPLAY_PAD_Y 50
16:
17: set move(lastX) 0
18: set move(lastY) 0
19:
20: proc plotMove {w i x y} {
21: global move
22: global PLOT
23: if {$x - $PLOT($i,x) > [expr $PLOT($i,w) / 2]} {
24: incr PLOT($i,w) [expr {$x-$move(lastX)}]
25: incr PLOT($i,h) [expr {$y-$move(lastY)}]
26: } else {
27: incr PLOT($i,x) [expr {$x-$move(lastX)}]
28: incr PLOT($i,y) [expr {$y-$move(lastY)}]
29:
30: .curve move "curve_frame_$i" [expr {$x-$move(lastX)}] [expr {$y-$move(lastY)}]
31: .curve move "curve_scale_$i" [expr {$x-$move(lastX)}] [expr {$y-$move(lastY)}]
32: .curve move "curve_bg_$i" [expr {$x-$move(lastX)}] [expr {$y-$move(lastY)}]
33: .curve move "curve_$i" [expr {$x-$move(lastX)}] [expr {$y-$move(lastY)}]
34: }
35: set move(lastX) $x
36: set move(lastY) $y
37: if {$x - $PLOT($i,x) > [expr $PLOT($i,w) / 2]} {
38: plot_bg $i
39: plot_draw_data $i
40: }
41: }
42:
43: proc plotSet {x y} {
44: global move
45: set move(lastX) $x
46: set move(lastY) $y
47: }
48:
49: proc plotMoveEnd {i} {
50: plot_redraw $i
51: }
52:
53: proc set_point {i L POINT UPDOWN} {
54: global PLOT
55: set VAL [expr [lindex $PLOT($i,ydata,$L) $POINT] + $UPDOWN]
56: set PLOT($i,ydata,$L) [lreplace $PLOT($i,ydata,$L) $POINT $POINT $VAL]
57: eval .frame$L.point_$POINT.label configure -text "[lindex $PLOT($i,ydata,$L) $POINT]"
58: plot_draw_data 1
59: puts "## $L $POINT $UPDOWN ##"
60: }
61:
62: proc plot_draw_data {i} {
63: global PLOT
64: global tk_library
65:
66: .curve delete "curve_$i"
67: .curve delete "curve_scale_$i"
68:
69: set X_OFF $PLOT($i,x)
70: set Y_OFF $PLOT($i,y)
71: set W $PLOT($i,w)
72: set H $PLOT($i,h)
73: set TITLE_X $PLOT($i,title_x)
74: set TITLE $PLOT($i,title)
75: set PAD_X $PLOT($i,pad_x1)
76: set PAD_X2 $PLOT($i,pad_x2)
77: set PAD_Y $PLOT($i,pad_y2)
78: set PAD_Y2 $PLOT($i,pad_y1)
79:
80: set L [expr ($W - $PAD_X - $PAD_X2) / 200.0]
81: set VMIN 1000000
82: set VMAX -1000000
83: foreach POINT_VAL $PLOT($i,udata) {
84: if {$VMIN > $POINT_VAL} {
85: set VMIN $POINT_VAL
86: } elseif {$VMAX < $POINT_VAL} {
87: set VMAX $POINT_VAL
88: }
89: }
90:
91: set VMIN [expr $VMIN - 0.0]
92: set VMAX [expr $VMAX + 0.0]
93: set MAX [expr $VMAX - $VMIN]
94:
95: set PM 0
96: while {[info exist PLOT($i,ydata,$PM)]} {
97: incr PM
98: }
99: if {$PAD_X2 == -1} {
100: set PAD_X2 [expr ($PM - 1) * $PAD_X]
101: }
102: if {$PAD_Y == -1} {
103: set PAD_Y 40
104: }
105:
106: set L_X $L
107: set VMIN_X $VMIN
108: set VMAX_X $VMAX
109: set MAX_X $MAX
110:
111: set PN 0
112: while {[info exist PLOT($i,ydata,$PN)]} {
113:
114: if {! [info exist PLOT($i,title_y,$PN)]} {
115: set PLOT($i,title_y,$PN) "title-y $PN"
116: }
117: if {! [info exist PLOT($i,data_color,$PN)]} {
118: set PLOT($i,data_color,$PN) "#ABABAB"
119: }
120:
121: set VMIN 1000000
122: set VMAX -1000000
123:
124: if {$PLOT($i,ysync) == 1} {
125: set PN2 0
126: while {[info exist PLOT($i,ydata,$PN2)]} {
127: foreach POINT_VAL $PLOT($i,ydata,$PN2) {
128: if {$VMIN > $POINT_VAL} {
129: set VMIN $POINT_VAL
130: } elseif {$VMAX < $POINT_VAL} {
131: set VMAX $POINT_VAL
132: }
133: }
134: incr PN2
135: }
136: } else {
137: foreach POINT_VAL $PLOT($i,ydata,$PN) {
138: if {$VMIN > $POINT_VAL} {
139: set VMIN $POINT_VAL
140: } elseif {$VMAX < $POINT_VAL} {
141: set VMAX $POINT_VAL
142: }
143: }
144: }
145: if {$PLOT($i,min,$PN) != ""} {
146: set VMIN $PLOT($i,min,$PN)
147: }
148: if {$PLOT($i,max,$PN) != ""} {
149: set VMAX $PLOT($i,max,$PN)
150: }
151:
152: set VMIN [expr $VMIN - 1.0]
153: set VMAX [expr $VMAX + 1.0]
154: set MAX [expr $VMAX - $VMIN]
155: set DMAX [llength $PLOT($i,udata)]
156:
157: set X $PAD_X
158: set Y [expr [expr $H - $PAD_Y - $PAD_Y2] - ([expr $H - $PAD_Y - $PAD_Y2] * ([lindex $PLOT($i,ydata,$PN) 0] + ($VMIN * -1)) / $MAX)]
159: set LAST_Y $Y
160: set LAST_X $X
161: set NUM 0
162: foreach POINT_VAL $PLOT($i,ydata,$PN) {
163: set Y [expr [expr $H - $PAD_Y - $PAD_Y2] - ([expr $H - $PAD_Y - $PAD_Y2] * ($POINT_VAL + ($VMIN * -1)) / $MAX)]
164: set X [expr $PAD_X + ([expr $W - $PAD_X - $PAD_X2] * ([lindex $PLOT($i,udata) $NUM] + ($VMIN_X * -1)) / $MAX_X)]
165: if {$PN == 0 && $PLOT($i,fill,$PN) == 1} {
166: .curve create polygon \
167: [expr $X_OFF + $LAST_X] \
168: [expr $Y_OFF + $LAST_Y + $PAD_Y2] \
169: [expr $X_OFF + $X] \
170: [expr $Y_OFF + $Y + $PAD_Y2] \
171: [expr $X_OFF + $X] \
172: [expr $Y_OFF + $H - $PAD_Y] \
173: [expr $X_OFF + $LAST_X] \
174: [expr $Y_OFF + $H - $PAD_Y] \
175: -fill "#ABABAB" \
176: -tag "curve_$i"
177: } elseif {$PLOT($i,fill,$PN) == 1} {
178: .curve create polygon \
179: [expr $X_OFF + $LAST_X] \
180: [expr $Y_OFF + $LAST_Y + $PAD_Y2] \
181: [expr $X_OFF + $X] \
182: [expr $Y_OFF + $Y + $PAD_Y2] \
183: [expr $X_OFF + $X] \
184: [expr $Y_OFF + $H - $PAD_Y] \
185: [expr $X_OFF + $LAST_X] \
186: [expr $Y_OFF + $H - $PAD_Y] \
187: -fill "#DEDEDE" \
188: -stipple @[file join $tk_library demos images gray25.bmp] \
189: -tag "curve_$i"
190: }
191:
192: if {$PLOT($i,bar,$PN) == 1} {
193: .curve create rectangle [expr $X_OFF + $X + ($PN * 5) - 12] [expr $Y_OFF + $PAD_Y2 + $Y] [expr $X_OFF + $X + ($PN * 5) + 12] [expr $Y_OFF + $H - $PAD_Y] -width 2 -fill "$PLOT($i,data_color_fill,$PN)" -outline "$PLOT($i,data_color_fill,$PN)" -tag "curve_$i"
194: } else {
195: .curve create line [expr $X_OFF + $LAST_X] [expr $Y_OFF + $LAST_Y + $PAD_Y2] [expr $X_OFF + $X] [expr $Y_OFF + $Y + $PAD_Y2] -width 2 -fill "$PLOT($i,data_color,$PN)" -tag "curve_$i"
196: }
197:
198:
199: set LAST_X $X
200: set LAST_Y $Y
201: incr NUM
202: }
203:
204: set X $PAD_X
205: set Y [expr [expr $H - $PAD_Y - $PAD_Y2] - ([expr $H - $PAD_Y - $PAD_Y2] * ([lindex $PLOT($i,ydata,$PN) 0] + ($VMIN * -1)) / $MAX)]
206: set LAST_Y $Y
207: set LAST_X $X
208: set NUM 0
209: foreach POINT_VAL $PLOT($i,ydata,$PN) {
210: set Y [expr [expr $H - $PAD_Y - $PAD_Y2] - ([expr $H - $PAD_Y - $PAD_Y2] * ($POINT_VAL + ($VMIN * -1)) / $MAX)]
211: set X [expr $PAD_X + ([expr $W - $PAD_X - $PAD_X2] * ([lindex $PLOT($i,udata) $NUM] + ($VMIN_X * -1)) / $MAX_X)]
212: if {$NUM > 0} {
213: if {$PLOT($i,point,$PN) == 1} {
214: .curve create text [expr $X_OFF + $X - 1] [expr $Y_OFF + $Y + $PAD_Y2 - 1] -text "[lindex $PLOT($i,udata) $NUM].[expr round($POINT_VAL * 100) / 100.0]" -fill "$PLOT($i,shadow_color)" -anchor s -tag "curve_scale_$i"
215: .curve create text [expr $X_OFF + $X + 1] [expr $Y_OFF + $Y + $PAD_Y2 + 1] -text "[lindex $PLOT($i,udata) $NUM].[expr round($POINT_VAL * 100) / 100.0]" -fill "$PLOT($i,shadow_color)" -anchor s -tag "curve_scale_$i"
216: .curve create text [expr $X_OFF + $X - 1] [expr $Y_OFF + $Y + $PAD_Y2 - 1] -text "[lindex $PLOT($i,udata) $NUM].[expr round($POINT_VAL * 100) / 100.0]" -fill "$PLOT($i,shadow_color)" -anchor s -tag "curve_scale_$i"
217: .curve create text [expr $X_OFF + $X + 1] [expr $Y_OFF + $Y + $PAD_Y2 + 1] -text "[lindex $PLOT($i,udata) $NUM].[expr round($POINT_VAL * 100) / 100.0]" -fill "$PLOT($i,shadow_color)" -anchor s -tag "curve_scale_$i"
218: .curve create text [expr $X_OFF + $X] [expr $Y_OFF + $Y + $PAD_Y2] -text "[lindex $PLOT($i,udata) $NUM].[expr round($POINT_VAL * 100) / 100.0]" -fill "$PLOT($i,data_color,$PN)" -anchor s -tag "curve_scale_$i"
219: }
220:
221: #.curve delete "curve_scale-a_$i-$PN-$NUM"
222: #.curve delete "curve_scale-b_$i-$PN-$NUM"
223: #.curve create rectangle [expr $X_OFF + $X - 5] [expr $Y_OFF + $Y + $PAD_Y2 - 10] [expr $X_OFF + $X + 5] [expr $Y_OFF + $Y + $PAD_Y2] -fill "$PLOT($i,data_color,$PN)" -tag "curve_scale-a_$i-$PN-$NUM"
224: #.curve create rectangle [expr $X_OFF + $X - 5] [expr $Y_OFF + $Y + $PAD_Y2] [expr $X_OFF + $X + 5] [expr $Y_OFF + $Y + $PAD_Y2 + 10] -fill "$PLOT($i,data_color,$PN)" -tag "curve_scale-b_$i-$PN-$NUM"
225: #eval .curve bind "curve_scale-a_$i-$PN-$NUM" <ButtonPress-1> \{set_point $i $PN $NUM 1\}
226: #eval .curve bind "curve_scale-b_$i-$PN-$NUM" <ButtonPress-1> \{set_point $i $PN $NUM -1\}
227: }
228: set LAST_X $X
229: set LAST_Y $Y
230: incr NUM
231: }
232:
233: set L [expr ($H - $PAD_Y - $PAD_Y2) / 25.0]
234: for {set POINT_VAL $VMIN} {$POINT_VAL <= $VMAX} {set POINT_VAL [expr $POINT_VAL + ($MAX / $L)]} {
235: set Y [expr [expr $H - $PAD_Y - $PAD_Y2] - ([expr $H - $PAD_Y - $PAD_Y2] * ($POINT_VAL + ($VMIN * -1)) / $MAX)]
236: if {$PN == 0} {
237:
238: if {$PLOT($i,ysync) == 1} {
239: .curve create line [expr $X_OFF + $PAD_X - 5] [expr $Y_OFF + $Y + $PAD_Y2] [expr $X_OFF + $W - $PAD_X2] [expr $Y_OFF + $Y + $PAD_Y2] -width 1 -fill "#CDCDCD" -tag "curve_scale_$i"
240: } else {
241: .curve create line [expr $X_OFF + $PAD_X - 5] [expr $Y_OFF + $Y + $PAD_Y2] [expr $X_OFF + $PAD_X] [expr $Y_OFF + $Y + $PAD_Y2] -width 1 -fill "$PLOT($i,data_color,$PN)" -tag "curve_scale_$i"
242: }
243:
244: .curve create text [expr $X_OFF + $PAD_X / 3 * 2 + 1] [expr $Y_OFF + $Y + $PAD_Y2 + 1] -text "[expr round($POINT_VAL * 100) / 100.0]" -fill "$PLOT($i,shadow_color)" -anchor c -tag "curve_scale_$i"
245: .curve create text [expr $X_OFF + $PAD_X / 3 * 2] [expr $Y_OFF + $Y + $PAD_Y2] -text "[expr round($POINT_VAL * 100) / 100.0]" -fill "$PLOT($i,data_color,$PN)" -anchor c -tag "curve_scale_$i"
246: } else {
247: .curve create line [expr $X_OFF + $W - $PAD_X2 + $PAD_X2 / (($PM - 1) * 3) * (($PN - 1) * 3 + 0)] [expr $Y_OFF + $Y + $PAD_Y2] [expr $X_OFF + $W - $PAD_X2 + $PAD_X2 / (($PM - 1) * 3) * (($PN - 1) * 3 + 0) + 5] [expr $Y_OFF + $Y + $PAD_Y2] -width 1 -fill "$PLOT($i,data_color,$PN)" -tag "curve_scale_$i"
248: .curve create text [expr $X_OFF + $W - $PAD_X2 + $PAD_X2 / (($PM - 1) * 3) * (($PN - 1) * 3 + 1) + 1] [expr $Y_OFF + $Y + $PAD_Y2 + 1] -text "[expr round($POINT_VAL * 100) / 100.0]" -fill "$PLOT($i,shadow_color)" -anchor c -tag "curve_scale_$i"
249: .curve create text [expr $X_OFF + $W - $PAD_X2 + $PAD_X2 / (($PM - 1) * 3) * (($PN - 1) * 3 + 1)] [expr $Y_OFF + $Y + $PAD_Y2] -text "[expr round($POINT_VAL * 100) / 100.0]" -fill "$PLOT($i,data_color,$PN)" -anchor c -tag "curve_scale_$i"
250: }
251: }
252:
253:
254: destroy .curve.sync2-$i-$PN
255: eval checkbutton .curve.sync2-$i-$PN -text \"\" -variable wipers -relief flat -variable PLOT($i,point,$PN) -command \{ \
256: plot_redraw $i \
257: \}
258:
259: destroy .curve.sync3-$i-$PN
260: eval checkbutton .curve.sync3-$i-$PN -text \"\" -variable wipers -relief flat -variable PLOT($i,fill,$PN) -command \{ \
261: plot_redraw $i \
262: \}
263:
264: destroy .curve.sync4-$i-$PN
265: eval checkbutton .curve.sync4-$i-$PN -text \"\" -variable wipers -relief flat -variable PLOT($i,bar,$PN) -command \{ \
266: plot_redraw $i \
267: \}
268:
269: if {$PN == 0} {
270: .curve create text [expr $X_OFF + $PAD_X / 3 + 1] [expr $Y_OFF + ($H - $PAD_Y - $PAD_Y2) / 2 + $PAD_Y2 + 1] -width 1 -text "$PLOT($i,title_y,$PN)" -fill "$PLOT($i,shadow_color)" -anchor c -justify center -tag "curve_scale_$i"
271: .curve create text [expr $X_OFF + $PAD_X / 3] [expr $Y_OFF + ($H - $PAD_Y - $PAD_Y2) / 2 + $PAD_Y2] -width 1 -text "$PLOT($i,title_y,$PN)" -fill "$PLOT($i,data_color,$PN)" -anchor c -justify center -tag "curve_scale_$i"
272:
273: .curve create window [expr $X_OFF + $PAD_X / 3] [expr $Y_OFF + $H - 5] -anchor s -window .curve.sync2-$i-$PN -tag "curve_bg_$i-$PN"
274: .curve create window [expr $X_OFF + $PAD_X / 3 + 15] [expr $Y_OFF + $H - 5] -anchor s -window .curve.sync3-$i-$PN -tag "curve_bg_$i-$PN"
275: .curve create window [expr $X_OFF + $PAD_X / 3 + 30] [expr $Y_OFF + $H - 5] -anchor s -window .curve.sync4-$i-$PN -tag "curve_bg_$i-$PN"
276: } else {
277: .curve create line [expr $X_OFF + $W - $PAD_X2 + $PAD_X2 / (($PM - 1) * 3) * (($PN - 1) * 3 + 0) + 1] [expr $Y_OFF + $PAD_Y2] [expr $X_OFF + $W - $PAD_X2 + $PAD_X2 / (($PM - 1) * 3) * (($PN - 1) * 3 + 0) + 1] [expr $Y_OFF + $H - $PAD_Y] -width 1 -fill "$PLOT($i,data_color,$PN)" -tag "curve_scale_$i"
278: .curve create text [expr $X_OFF + $W - $PAD_X2 + $PAD_X2 / (($PM - 1) * 3) * (($PN - 1) * 3 + 2) + 1] [expr $Y_OFF + ($H - $PAD_Y - $PAD_Y2) / 2 + $PAD_Y2 + 1] -width 1 -text "$PLOT($i,title_y,$PN)" -fill "$PLOT($i,shadow_color)" -anchor c -justify center -tag "curve_scale_$i"
279: .curve create text [expr $X_OFF + $W - $PAD_X2 + $PAD_X2 / (($PM - 1) * 3) * (($PN - 1) * 3 + 2)] [expr $Y_OFF + ($H - $PAD_Y - $PAD_Y2) / 2 + $PAD_Y2] -width 1 -text "$PLOT($i,title_y,$PN)" -fill "$PLOT($i,data_color,$PN)" -anchor c -justify center -tag "curve_scale_$i"
280:
281: .curve create window [expr $X_OFF + $W - $PAD_X2 + $PAD_X2 / (($PM - 1) * 3) * (($PN - 1) * 3 + 1) + 0] [expr $Y_OFF + $H - 5] -anchor s -window .curve.sync2-$i-$PN -tag "curve_bg_$i-$PN"
282: .curve create window [expr $X_OFF + $W - $PAD_X2 + $PAD_X2 / (($PM - 1) * 3) * (($PN - 1) * 3 + 1) + 15] [expr $Y_OFF + $H - 5] -anchor s -window .curve.sync3-$i-$PN -tag "curve_bg_$i-$PN"
283: .curve create window [expr $X_OFF + $W - $PAD_X2 + $PAD_X2 / (($PM - 1) * 3) * (($PN - 1) * 3 + 1) + 30] [expr $Y_OFF + $H - 5] -anchor s -window .curve.sync4-$i-$PN -tag "curve_bg_$i-$PN"
284: }
285: incr PN
286: }
287:
288: # Scale X
289: set NUM 0
290: foreach POINT_VAL $PLOT($i,udata) {
291: set X [expr $PAD_X + ([expr $W - $PAD_X - $PAD_X2] * ([lindex $PLOT($i,udata) $NUM] + ($VMIN_X * -1)) / $MAX_X)]
292: .curve create line [expr $X_OFF + $X] [expr $Y_OFF + $PAD_Y2] [expr $X_OFF + $X] [expr $Y_OFF + $H - $PAD_Y + 2] -width 1 -fill "$PLOT($i,hl_color_x)" -tag "curve_$i"
293: .curve create text [expr $X_OFF + $X + 1] [expr $Y_OFF + $H - $PAD_Y / 3 * 2 + 1] -text "[expr round($POINT_VAL * 100) / 100.0]" -fill "$PLOT($i,shadow_color)" -anchor c -tag "curve_$i"
294: .curve create text [expr $X_OFF + $X] [expr $Y_OFF + $H - $PAD_Y / 3 * 2] -text "[expr round($POINT_VAL * 100) / 100.0]" -fill "$PLOT($i,title_color)" -anchor c -tag "curve_$i"
295: incr NUM
296: }
297:
298: # Border
299: .curve create line [expr $X_OFF + $PAD_X] [expr $Y_OFF + $H - $PAD_Y] [expr $X_OFF + $W - $PAD_X2] [expr $Y_OFF + $H - $PAD_Y] -width 2 -fill "#EFEFEF" -tag "curve_scale_$i"
300: .curve create line [expr $X_OFF + $W - $PAD_X2] [expr $Y_OFF + $PAD_Y2] [expr $X_OFF + $W - $PAD_X2] [expr $Y_OFF + $H - $PAD_Y] -width 2 -fill "#EFEFEF" -tag "curve_scale_$i"
301: .curve create line [expr $X_OFF + $PAD_X] [expr $Y_OFF + $PAD_Y2] [expr $X_OFF + $W - $PAD_X2] [expr $Y_OFF + $PAD_Y2] -width 2 -fill "#ABABAB" -tag "curve_scale_$i"
302: .curve create line [expr $X_OFF + $PAD_X] [expr $Y_OFF + $PAD_Y2] [expr $X_OFF + $PAD_X] [expr $Y_OFF + $H - $PAD_Y] -width 2 -fill "#ABABAB" -tag "curve_scale_$i"
303:
304: }
305:
306: proc plot_bg {i} {
307: global PLOT
308: set X_OFF $PLOT($i,x)
309: set Y_OFF $PLOT($i,y)
310: set W $PLOT($i,w)
311: set H $PLOT($i,h)
312: set PAD_X $PLOT($i,pad_x1)
313: set PAD_X2 $PLOT($i,pad_x2)
314: set PAD_Y $PLOT($i,pad_y2)
315: set TITLE_X $PLOT($i,title_x)
316: set TITLE $PLOT($i,title)
317: set PAD_X $PLOT($i,pad_x1)
318: set PAD_X2 $PLOT($i,pad_x2)
319: set PAD_Y $PLOT($i,pad_y2)
320: set PAD_Y2 $PLOT($i,pad_y1)
321:
322: .curve delete "curve_bg_$i"
323:
324: set PM 0
325: while {[info exist PLOT($i,ydata,$PM)]} {
326: incr PM
327: }
328: if {$PAD_X2 == -1} {
329: set PAD_X2 [expr ($PM - 1) * $PAD_X]
330: }
331: if {$PAD_Y == -1} {
332: set PAD_Y 40
333: }
334:
335: .curve create rectangle $X_OFF $Y_OFF [expr $X_OFF + $W] [expr $Y_OFF + $H] -width 1 -fill "$PLOT($i,frame_color)" -tag "curve_frame_$i"
336: .curve create rectangle [expr $X_OFF + $PAD_X] [expr $Y_OFF + $PAD_Y2] [expr $X_OFF + $W - $PAD_X2] [expr $Y_OFF + $H - $PAD_Y] -width 0 -fill "$PLOT($i,bg_color)" -tag "curve_bg_$i"
337:
338: .curve create text [expr $X_OFF + $W / 2 + 1] [expr $Y_OFF + $PAD_Y2 / 2 + 1] -text "$TITLE" -fill "$PLOT($i,title_bg_color)" -anchor c -justify center -tag "curve_bg_$i" -font "12x24"
339: .curve create text [expr $X_OFF + $W / 2] [expr $Y_OFF + $PAD_Y2 / 2] -text "$TITLE" -fill "$PLOT($i,title_color)" -anchor c -justify center -tag "curve_bg_$i" -font "12x24"
340:
341: .curve create line $X_OFF [expr $Y_OFF + $H] [expr $X_OFF + $W] [expr $Y_OFF + $H] -width 2 -fill "#ABABAB" -tag "curve_bg_$i"
342: .curve create line [expr $X_OFF + $W] $Y_OFF [expr $X_OFF + $W] [expr $Y_OFF + $H] -width 2 -fill "#ABABAB" -tag "curve_bg_$i"
343: .curve create line $X_OFF $Y_OFF [expr $X_OFF + $W] $Y_OFF -width 2 -fill "#EFEFEF" -tag "curve_bg_$i"
344: .curve create line $X_OFF $Y_OFF $X_OFF [expr $Y_OFF + $H] -width 2 -fill "#EFEFEF" -tag "curve_bg_$i"
345:
346:
347: destroy .curve.sync-$i
348: eval checkbutton .curve.sync-$i -text \"Sync-Y\" -variable wipers -relief flat -variable PLOT($i,ysync) -command \{ \
349: plot_redraw $i\
350: \}
351: .curve create window [expr $X_OFF + 10] [expr $Y_OFF + 10] -anchor nw -window .curve.sync-$i -tag "curve_bg_$i"
352:
353: destroy .curve.padx-$i
354: spinbox .curve.padx-$i -from 0 -to 300 -increment 5 -format %05.2f -width 10 -textvariable PLOT($i,pad_x1) -command {
355: plot_redraw $i\
356: }
357: .curve create window [expr $X_OFF + 110] [expr $Y_OFF + 10] -anchor nw -window .curve.padx-$i -tag "curve_bg_$i"
358:
359: eval bind .curve.padx-$i <ButtonPress-4> \{set PLOT($i,pad_x1) \[expr \$PLOT($i,pad_x1) + 1\]\nplot_bg $i\nplot_draw_data $i\}
360: eval bind .curve.padx-$i <ButtonPress-5> \{set PLOT($i,pad_x1) \[expr \$PLOT($i,pad_x1) - 1\]\nplot_bg $i\nplot_draw_data $i\}
361:
362:
363:
364: .curve bind curve_frame_$i <B1-Motion> "plotMove .curve $i %x %y"
365: .curve bind curve_frame_$i <ButtonPress-1> "plotSet %x %y"
366: .curve bind curve_frame_$i <ButtonRelease-1> "plotMoveEnd $i"
367:
368:
369: }
370:
371: proc plot_redraw {i} {
372: .curve delete curve_frame_$i
373: plot_bg $i
374: plot_draw_data $i
375: }
376:
377: proc plot_add {NUM DATA} {
378: global PLOT
379: set PN 0
380: while {[info exist PLOT($NUM,ydata,$PN)]} {
381: incr PN
382: }
383: set PLOT($NUM,ydata,$PN) $DATA
384: set PLOT($NUM,title_y,$PN) "title_y0"
385: if {$PN == 1} {
386: set PLOT($NUM,data_color,$PN) "#00FF00"
387: set PLOT($NUM,data_color_fill,$PN) "#00FFF0"
388: } elseif {$PN == 2} {
389: set PLOT($NUM,data_color,$PN) "#0000FF"
390: set PLOT($NUM,data_color_fill,$PN) "#000FFF"
391: } else {
392: set PLOT($NUM,data_color,$PN) "#FFFF00"
393: set PLOT($NUM,data_color_fill,$PN) "#FFF000"
394: }
395:
396: set PLOT($NUM,point,$PN) "0"
397: set PLOT($NUM,fill,$PN) "0"
398: set PLOT($NUM,bar,$PN) "0"
399: set PLOT($NUM,min,$PN) ""
400: set PLOT($NUM,max,$PN) ""
401: }
402:
403: proc plot_new {X Y W H UDATA DATA} {
404: global PLOT
405: set NUM 1
406: while {[info exist PLOT($NUM,x)]} {
407: incr NUM
408: }
409: set PLOT($NUM,udata) $UDATA
410: set PLOT($NUM,x) $X
411: set PLOT($NUM,y) $Y
412: set PLOT($NUM,w) $W
413: set PLOT($NUM,h) $H
414: set PLOT($NUM,pad_x1) 70
415: set PLOT($NUM,pad_x2) -1
416: set PLOT($NUM,pad_y1) 70
417: set PLOT($NUM,pad_y2) 70
418: set PLOT($NUM,title_x) "title_x"
419: set PLOT($NUM,title) "title"
420:
421: set PLOT($NUM,shadow_color) "#676767"
422:
423: set PLOT($NUM,ydata,0) $DATA
424: set PLOT($NUM,title_y,0) "title_y0"
425: set PLOT($NUM,data_color,0) "#FF0000"
426: set PLOT($NUM,data_color_fill,0) "#FFF000"
427: set PLOT($NUM,point,0) "0"
428: set PLOT($NUM,fill,0) "0"
429: set PLOT($NUM,bar,0) "0"
430: set PLOT($NUM,min,0) ""
431: set PLOT($NUM,max,0) ""
432:
433: set PLOT($NUM,frame_color) "#BCBCBC"
434: set PLOT($NUM,bg_color) "#343434"
435: set PLOT($NUM,title_color) "#FFFFFF"
436: set PLOT($NUM,title_bg_color) "#000000"
437: set PLOT($NUM,hl_color_x) "#343434"
438: set PLOT($NUM,hl_color_y) "#343434"
439:
440: set PLOT($NUM,ysync) "1"
441:
442: return $NUM
443: }
444:
445: proc plot_configure {NUM NAME VALUE} {
446: global PLOT
447: set PLOT($NUM,$NAME) $VALUE
448: }
449:
450:
451:
452:
453:
454: ##############################################################################################################################################################
455:
456:
457:
458: #wm geometry . 320x240
459: wm title . "RCDI-Tool"
460:
461: canvas .curve -relief raised -width 1400 -height 700
462: pack .curve -side top -fill none -expand no
463: .curve create rectangle 0 0 1700 2400 -width 1 -fill "#121212"
464:
465: frame .frame0
466: #pack .frame0 -side top -fill both -expand yes
467:
468: frame .frame1
469: #pack .frame1 -side top -fill both -expand yes
470:
471: for {set POINT 0} {$POINT < [llength $DATA]} {incr POINT} {
472:
473: frame .frame0.point_$POINT
474: pack .frame0.point_$POINT -side left -fill x -expand yes
475:
476: eval button .frame0.point_\$POINT.up -text \"+\" -command \{set_point 1 \"0\" \"$POINT\" \"0.5\"\}
477: pack .frame0.point_$POINT.up -side top -fill x -expand yes
478:
479: eval label .frame0.point_\$POINT.label -text \"[lindex $DATA $POINT]\"
480: pack .frame0.point_$POINT.label -side top -fill x -expand yes
481:
482: eval button .frame0.point_\$POINT.down -text \"-\" -command \{set_point 1 \"0\" \"$POINT\" \"-0.5\"\}
483: pack .frame0.point_$POINT.down -side top -fill x -expand yes
484:
485: frame .frame1.point_$POINT
486: pack .frame1.point_$POINT -side left -fill x -expand yes
487:
488: eval button .frame1.point_\$POINT.up -text \"+\" -command \{set_point 1 \"1\" \"$POINT\" \"0.5\"\}
489: pack .frame1.point_$POINT.up -side top -fill x -expand yes
490:
491: eval label .frame1.point_\$POINT.label -text \"[lindex $DATA2 $POINT]\"
492: pack .frame1.point_$POINT.label -side top -fill x -expand yes
493:
494: eval button .frame1.point_\$POINT.down -text \"-\" -command \{set_point 1 \"1\" \"$POINT\" \"-0.5\"\}
495: pack .frame1.point_$POINT.down -side top -fill x -expand yes
496:
497: }
498:
499:
500:
501: set PLOT_ID [plot_new 50 20 1300 300 {} {}]
502: plot_configure $PLOT_ID "title" "Frequenzband"
503: plot_configure $PLOT_ID "title_x" "Freq"
504: plot_configure $PLOT_ID "title_y,0" "Level"
505: plot_configure $PLOT_ID "max,0" "27"
506: plot_configure $PLOT_ID "min,0" "0"
507: plot_add $PLOT_ID {}
508: plot_configure $PLOT_ID "title_y,1" "Max-Level"
509: plot_configure $PLOT_ID "max,1" "27"
510: plot_configure $PLOT_ID "min,1" "0"
511: #plot_add $PLOT_ID $DATA3
512: plot_redraw $PLOT_ID
513:
514:
515:
516: set PLOT_ID [plot_new 50 340 1300 300 $UDATA $DATA]
517: plot_configure $PLOT_ID "title" "Zuendzeitpunkt"
518: plot_configure $PLOT_ID "title_x" "RPM"
519: plot_configure $PLOT_ID "title_y,0" "Grad"
520: plot_add $PLOT_ID $DATA2
521: plot_redraw $PLOT_ID
522:
523:
524:
525:
526:
527:
528: proc Serial_Init {ComPort ComRate} {
529: set iChannel [open $ComPort w+]
530: set rate $ComRate
531: fconfigure $iChannel -mode $ComRate,n,8,1
532: fconfigure $iChannel -blocking 0
533: fconfigure $iChannel -buffering none
534: fileevent $iChannel readable ""
535: return $iChannel
536: }
537:
538:
539: proc append2_point {i L COUNT VALUE} {
540: global PLOT
541:
542: lappend PLOT($i,udata) "$COUNT"
543: lappend PLOT($i,ydata,$L) "$VALUE"
544:
545: plot_draw_data $i
546: }
547:
548: proc set2_point {i L COUNTS VALUES} {
549: global PLOT
550:
551: set PLOT($i,udata) "$COUNTS"
552: set PLOT($i,ydata,$L) "$VALUES"
553:
554: plot_draw_data $i
555: }
556:
557:
558: set line ""
559: set COUNT 0
560:
561: set max_line ""
562:
563: proc rd_chid {chid} {
564: global line
565: global max_line
566: global COUNT
567: set msg [read $chid 1]
568: if {$msg == "\n"} {
569: if {[string match "SCN;*" $line]} {
570: if {[expr $COUNT % 2] == 0} {
571:
572:
573: # puts "[lrange [split $line ";"] 1 end]"
574:
575: set max_line2 {}
576:
577: for {set NV 0} {$NV < [llength [lrange [split $line ";"] 1 end]]} {set NV [expr $NV + 1]} {
578:
579: set MVAL [lindex [split $line ";"] [expr $NV + 1]]
580: set MVAL2 [lindex $max_line $NV]
581:
582: puts "## [lindex $max_line $NV] $NV"
583:
584: if {$MVAL < $MVAL2} {
585: lappend max_line2 $MVAL2
586: } else {
587: lappend max_line2 $MVAL
588: }
589: }
590:
591: puts "$max_line -- $max_line2"
592:
593: set max_line $max_line2
594:
595:
596: set xline {}
597:
598: for {set NV 2405} {$NV < 2485} {set NV [expr $NV + 5]} {
599: lappend xline $NV
600: }
601:
602: set2_point 1 0 $xline [lrange [split $line ";"] 1 end]
603: set2_point 1 1 $xline $max_line
604:
605:
606:
607: }
608: incr COUNT
609:
610: }
611: set line ""
612: } else {
613: set line "$line$msg"
614: }
615: }
616:
617:
618:
619:
620: if {[lindex $argv 0] != ""} {
621: puts "Open Serial-Port: [lindex $argv 0]"
622: if {[lindex $argv 1] != ""} {
623: set Serial [Serial_Init "[lindex $argv 0]" [lindex $argv 1]]
624: } else {
625: set Serial [Serial_Init "[lindex $argv 0]" 38400]
626: }
627: } else {
628: puts "USAGE: rx-tool COMPORT \[BAUD\]"
629: exit 1
630: }
631:
632: fileevent $Serial readable [list rd_chid $Serial]
633: puts -nonewline $Serial "c"
634:
635:
636:
637:
638:
639: