-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathezcaIDLGuide.html
executable file
·625 lines (616 loc) · 25.5 KB
/
ezcaIDLGuide.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xml:lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>ezcaIDL User's Guide</title>
<meta content="text/html; charset=iso-8859-1" http-equiv="Content-Type" />
</head>
<body xml:lang="en">
<div style="text-align: center">
<h1>
ezcaIDL User's Guide</h1>
<h2>
December 12, 2012</h2>
<h3>
Mark Rivers</h3>
<h3>
Center for Advanced Radiation Sources</h3>
<h3>
University of Chicago</h3>
<h3>
rivers@cars.uchicago.edu</h3>
</div>
<h2>
Table of Contents</h2>
<ul>
<li><a href="#Overview">Overview</a></li>
<li><a href="#Release">Release notes</a></li>
<li><a href="#Procedures">Procedures and Functions</a></li>
<li><a href="#Routines">List of Routines by Functional Group</a></li>
<li><a href="#Related">Related Documentation</a></li>
<li><a href="#Synchronous">Synchronous Groups</a></li>
<li><a href="#Error">Error Handling</a></li>
<li><a href="#Debugging">Debugging</a></li>
<li><a href="#Files">Files</a></li>
<li><a href="#Libraries">Required Support Libraries</a></li>
<li><a href="#UnixSetup">Unix Setup</a></li>
<li><a href="#VMSSetup">VMS Setup</a></li>
<li><a href="#Examples">Examples</a></li>
<li><a href="#Widgets">IDL Widgets</a></li>
</ul>
<h2>
<a id="Overview">Overview</a></h2>
<p>
ezcaIDL is a library of routines for <a href="http://sslab.colorado.edu:2222/projects/IDL/idl_ssl_home.html">
IDL</a> and <a href="http://www.vni.com/pvwave.dir/wavehome.html">PV-WAVE</a>
which provides an interface to EPICS Channel Access through the EZCA and EzcaScan
libraries.
</p>
<p>
PV-WAVE and IDL are closely related packages which are described as <cite>Data Visualization
Tools</cite>. They consist of a general purpose interpreted language with very
good graphics routines. Although not described as tools for data collection and
control applications, their rapid prototyping capabilities and sophisticated graphics
make them a nice environment for these applications. Both also provide easy to use
widget toolkits for quickly developing GUI applications.
</p>
<p>
Although there is nearly a one-for-one match between the routines in ezcaIDL and
the EZCA and EzcaScan libraries, the syntax of the IDL routines is not the same
as the syntax of the corresponding EZCA and EzcaScan routines. The reason for this
is that IDL is more "object oriented" and relieves the programmer of much of the
detailed bookkeeping required of the C programmer. Thus for example, the IDL routine
<code>caGet()</code> returns, by default, a value which has the native data type
and element count of the process variable. This is not true of the corresponding
C routine <code>ezcaGet()</code>, which requires the user to specify the data type
and number of elements to be returned.
</p>
<h2>
<a id="Release">Release notes</a></h2>
<p>
The following are the more important notes taken from the CVS log file.</p>
<h3>
2012/12/12</h3>
<ul>
<li>Added a new function ezcaPVNameToByte which is now called instead of ezcaStringToByte
for all PV names; it allows up to MAX_PVNAME_SIZE=128 characters in a PV name, rather
than MAX_STRING_SIZE=40. EPICS CA should now be the limit on PV name size, not ezcaIDL.</li>
</ul>
<h3>
2011/10/21</h3>
<ul>
<li>Added optional count parameter to caSetMonitor.</li>
<li>ezcaIDL now finds the shareable library either by the environment variable EZCA_IDL_SHARE
or by a new mechanism: the shareable library is searched for in IDL_PATH using the
name base_VERSION.OS_VERSION.ARCH, where base is libezcaIDL.so or ezcaIDL.dll.</li>
</ul>
<h3>
2001/9/28</h3>
<p>
This was a signficant rewrite.</p>
<ul>
<li>No string variables are passed to the shareable libraries in this version. This
was done to simplify things, since there are now at least 4 different conventions
for passing strings to shareable libraries (PVWAVE, IDL prior to 5.1 on Windows,
IDL 5.1-5.4, and IDL 5.5 and later). We now only pass byte arrays, not strings.
This permits a single shareable library to be used for any version of PV-WAVE or
IDL.</li>
<li>There are now 2 constants in ezca_common, MAX_STRING_SIZE and MAX_ENUM_STATES.
These values are set to 40 and 16 respectively in caInit. It is now MANDATORY to
call caInit before calling any other routine in this file, preferably in the IDL_STARTUP
file.</li>
<li>Reformatted a lot of the code, and used ENDIF and ENDFOR consistently rather than
simple END statements.</li>
<li>Added support for unsigned short and unsigned long integer data types.</li>
</ul>
<h2>
<a id="Procedures">Procedures and Functions</a></h2>
<p>
PV-WAVE and IDL are similar to FORTRAN in that they have two types of routines,
procedures and functions. Procedure are similar to FORTRAN subroutines: they do
not return a value. Functions, as in C or FORTRAN, return a value. ezcaIDL uses
functions for all EZCA routines which return either status or data. Procedures are
used for routines which return <code>void</code>, i.e. neither data nor status.
</p>
<p>
Procedure and function names are not case sensitive. Of course, the names of channel
access process variables <em>are</em> case sensitive and must be specified correctly.
</p>
<h2>
<a id="Routines">List of Routines by Functional Group</a></h2>
<p>
ezcaIDL consists of the following routines, grouped by functionality:</p>
<ul>
<li>Initialization routines
<pre>
caInit [,flag] [,help=help]
String = caVersion()
</pre>
</li>
<li>Routines which return information about process variables
<pre>
Status = caGet(pvname, value, /STRING, max_elements=max_elements)
Status = caGetArray(pvnames, pdata, max=no, type=i, /TYPE, /EVENT)
Status = caGetControlLimits(pvname, low, high)
Status = caGetGraphicLimits(pvname, low, high)
Status = caGetPrecision(pvname, precision)
Status = caGetStatus(pvname, timestamp, status, severity)
Status = caGetUnits(pvname, units)
Status = caGetEnumStrings(pvname, strings)
Status = caGetCountAndType(pvname, count, type)
Status = caSearch(pvnames)
String = caTimeStamp(pvname)
</pre>
</li>
<li>Routines which write new values to process variables
<pre>
Status = caPut(pvname, value)
Status = caPutArray(pvname, pdata, /event)
</pre>
</li>
<li>Routines which control channel access timeouts
<pre>
Timeout = caGetTimeout()
caSetTimeout, timeout
RetryCount = caGetRetryCount()
caSetRetryCount, retrycount
caPendEvent [,time=0.001] [,help=help]
caPendIO, time=time, list_time=list_time
</pre>
</li>
<li>Routines which control synchronous groups
<pre>
caStartGroup
stat = caEndGroup(status)
</pre>
</li>
<li>Routines which control channel access monitors
<pre>
Status = caSetMonitor(pvname)
Status = caClearMonitor(pvname)
State = caCheckMonitor(pvname)
Status = caMonitor(pvname, vals, num, overflow, op_keyword, type_keyword, max=no)
</pre>
</li>
<li>Routines which collect data with the EPICS scan record
<pre>
Status = caScan(name, pvnames, nonames, npts, vals, op_keyword, max=no)
</pre>
</li>
<li>Routines which control debugging and error messages
<pre>
caDebug, state
caTrace, state
caError, err_string, /ON, /OFF, /PRINT, prefix=prefix
Status = caGetError(Pvname, Err)
</pre>
</li>
</ul>
<h2>
<a id="Related">Related Documentation</a></h2>
<p>
In addition to this ezcaIDL Users' Guide the following documentation will be useful
to the IDL programmer using ezcaIDL.</p>
<ul>
<li><a href="ezcaIDLRef.html">ezcaIDL Reference Guide</a> This document contains a
detailed description of all of the ezcaIDL routines. It is extracted directly from
the standard documentation headers for each routine in the source file <code>ezcaIDL.pro</code>.
</li>
<li><a href="http://epics.aps.anl.gov/asd/controls/epics/manuals/EzCaPrimer/EzcaPrimer.html">
EZCA Primer</a> This document contains an overview of the EZCA C library, which
is used by ezcaIDL. </li>
</ul>
<h2>
<a id="Synchronous">Synchronous Groups</a></h2>
<p>
Normally all ezcaIDL calls, such as <code>caGet()</code> and <code>caPut()</code>
wait for all required channel access operations to complete before they return.
This is often convenient, but it is very inefficient if one wants to read/write
a large number of process variables. In this case it is much more efficient to submit
a group of channel access requests, and then wait for them all to complete.
</p>
<p>
ezcaIDL supports the concept of "synchronous groups" in the EZCA library. A synchronous
group is started by calling</p>
<pre>
caStartGroup
</pre>
<p>
Once a synchronous group is started, subsequent calls to routines like <code>caGet()</code>,
<code>caPut()</code>, etc. simply queue a channel access operation, and do not actually
perform the channel access I/O. Calling</p>
<pre>
status = caEndGroup()
</pre>
<p>
ends a synchronous group. This causes all of the queued channel access calls to
be issued and waits for them to complete.
</p>
<p>
There are two important restrictions which must be kept in mind when calling any
of the <code>caGetxxx()</code> routines (e.g. <code>caGet()</code>, <code>caGetUnits()</code>,
<code>caGetControlLimits()</code>, etc.) from inside a synchronous group, i.e. after
calling <code>caStartGroup</code> and before calling <code>caEndGroup()</code>.
</p>
<ol>
<li>The IDL variable(s) which contain the return data values must not be "re-used"
or deleted before the call to <code>caEndGroup()</code>. The reason for this is
that EZCA has been passed the addresses of these variables as the locations to which
the data are to be copied when <code>caEndGroup()</code> is called. Thus, these
locations must still point to a valid memory location when <code>caEndGroup()</code>
is called. <em>If the output variables are re-used then IDL's behavior is unpredictable,
and bus errors/access violations could occur.</em> In practice, fatal errors have
not been observed, but they are possible. </li>
<li>When using <code>caGet()</code> to read strings, the data type returned will be
a byte array, rather than a string. The reason has to do with the manner in which
IDL passes strings, which requires that EZCA actually be passed pointers to byte
arrays. When <code>caGet()</code> is called outside of a group it automatically
converts the byte array to a string before returning the value. However when <code>
caGet()</code> is called inside of a synchronous group it cannot perform this
conversion, since it cannot be done until after the data is read, which does not
occur until <code>caEndGroup()</code> is called. Thus, it is the user's responsibility
to convert the data from a byte array to a string after calling <code>caEndGroup()</code>.
This is done very simply with the <code>string()</code> function. </li>
</ol>
<p>
The following is an example of a valid grouped operation. It also shows how to handle
strings.</p>
<pre>
caStartGroup
status = caGet('test_mca1.VAL', mca_value)
status = caGet('test_vme1.DESC', vme_desc) ; This is a string PV
status = caEndGroup()
vme_desc = string(vme_desc) ; Convert from byte array to string
</pre>
<p>
The following is an example of an <em>invalid</em> grouped operation.</p>
<pre>
caStartGroup
status = caGet('test_mca1.VAL', mca_value)
status = caGet('test_vme1.VAL', vme_value)
mca_value=0
status = caEndGroup()
</pre>
<p>
Note that <code>mca_value</code> was redefined before calling <code>caEndGroup()</code>,
so the previous location became undefined. <strong>Do not do this!</strong>></p>
<h2>
<a id="Error">Error Handling</a></h2>
<p>
All ezcaIDL routines which can generate errors return a status code to indicate
success or failure. 0 indicates success, any other value indicates failure. These
status codes are generally those returned by the routines in ezca.c, although some
errors are returned directly from routines in <code>ezcaIDL.pro</code> and <code>ezcaIDL.c</code>.
</p>
<p>
The EZCA routines will, by default, print brief diagnostic error messages when errors
occur. These messages can be turned off by calling:</p>
<pre>
caError, /OFF
</pre>
<p>
A message describing the most recent error can be printed on stdout by calling:</p>
<pre>
caError, /PRINT
</pre>
<p>
A string describing the most recent error can be returned to the caller with:</p>
<pre>
caErrror, err_string
</pre>
<p>
For more information on error messages see the <a href="ezcaIDLRef.html#caError">description
of caError in the ezcaIDL Reference Guide</a></p>
<h2>
<a id="Debugging">Debugging</a></h2>
<p>
Detailed trace information for the EZCA routines can be obtained by calling:</p>
<pre>
caTrace, 1
</pre>
<p>
This can be turned off by calling</p>
<pre>
caTrace, 0
</pre>
<p>
Even more detailed debugging information for the EZCA routines can be obtained by
calling:</p>
<pre>
caDebug, 1
</pre>
<p>
This can be turned off by calling</p>
<pre>
caDebug, 0
</pre>
<h2>
<a id="Files">Files</a></h2>
<p>
ezcaIDL consists of the following files:</p>
<dl>
<dt><code>ezcaIDL.c</code></dt>
<dd>
This file is a thin interface between IDL and PV-WAVE and EZCA and EzcaScan. It
converts the parameters passed by IDL <code>call_external()</code> or PV-WAVE <code>
linknload()</code> to the form required by EZCA and EzcaScan. It directly implements
some functions which are not provided in the EZCA library. These include <code>ezcaIDLGetCountAndType()</code>
and <code>ezcaIDLGetEnumStrings()</code>. This file is compiled and linked into
a shareable object file, typically <code>ezcaIDL.so</code> on Unix and <code>ezcaIDL.EXE</code>
on VMS.</dd>
<dt><code>ezcaIDL.pro</code></dt>
<dd>
This file contains the IDL/PV-WAVE functions and procedures.</dd>
<dt><code>ezcaWidgets.pro</code></dt>
<dd>
This file contains routines which simplify the use of widgets in IDL channel access
applications. These routines only work with IDL, not with PV-WAVE.</dd>
<dt><code>ezcaIDLGuide.html</code></dt>
<dd>
This documentation file.</dd>
<dt><a href="ezcaIDLRef.html"><code>ezcaIDLRef.html</code></a></dt>
<dd>
This document contains a detailed description of all of the routines. It is extracted
directly from the standard documentation headers for each routine in <code>ezcaIDL.pro</code>.</dd>
</dl>
<h2>
<a id="Libraries">Required Support Libraries</a></h2>
<p>
ezcaIDL requires the following support libraries in order to build the shareable
object file. Users who want to port ezcaIDL to another architecture need to port
these libraries first.</p>
<pre>
extensions/src/ezca
extensions/src/EzcaScan
base/src/ca
base/src/libCom
</pre>
<h2>
<a id="UnixSetup">Unix Setup</a></h2>
<p>
The following additions to your <code>.login</code> file will facilitate the use
of ezcaIDL.
</p>
<pre>
# Define an IDL or PV-WAVE startup file to be executed when IDL or PV-WAVE are
# started
setenv IDL_STARTUP ~/idl_startup.pro
setenv WAVE_STARTUP ~/wave_startup.pro
#
# Define the location of ezcaIDL.so so this file can be located
# no matter what the current default directory is. This needs to be modified
# according to where the .so file is placed on your system.
setenv EZCA_IDL_SHARE /usr/local/epics/extensions/bin/solaris/ezcaIDL.so
</pre>
<p>
In the IDL or PV-WAVE startup files (<code>~/idl_startup.pro</code> or <code>~/wave_startup.pro</code>
in the preceeding example <code>.login</code> file) add the following lines</p>
<pre>
;
!QUIET=1 ; So things will compile without informational messages
.RUN ezcaIDL ; For both IDL and PV-WAVE
.RUN ezcaIDLWidgets ; For IDL widget users
caInit ; To define some required constants
;
</pre>
<h2>
<a id="VMSSetup">VMS Setup</a></h2>
<p>
The following additions to your <code>LOGIN.COM</code> file will facilitate the
use of ezcaIDL.
</p>
<pre>
$! Define an IDL or PV-WAVE startup file to be executed when IDL or PV-WAVE
$! are started
$ DEFINE IDL_STARTUP SYS$LOGIN:idl_startup.pro
$ DEFINE WAVE_STARTUP SYS$LOGIN:wave_startup.pro
$!
$! Define the location of ezcaIDL.EXE so this file can be
$! located no matter what the current default directory is.
$! These need to be modified according to where the .EXE file is placed on
$! your system.
$ DEFINE ezcaIDL_EXE PUBLIC_DISK:[PUBLIC.EPICS.EXTENSIONS.BIN]ezcaIDL.EXE
$ DEFINE EZCA_IDL_SHARE ezcaIDL_EXE
</pre>
<p>
In the IDL or PV-WAVE startup files (<code>idl_startup.pro</code> or <code>wave_startup.pro</code>
in the preceeding example <code>login.com</code> file) add the following lines</p>
<pre>
;
!QUIET=1 ; So things will compile without informational messages
.RUN ezcaIDL ; For both IDL and PV-WAVE
.RUN ezcaIDLWidgets ; For IDL widget users
caInit
;
</pre>
<h2>
<a id="Examples">Examples</a></h2>
<p>
The following examples illustrate how to use some of the routines in ezcaIDL.</p>
<pre>
; Create a sine wave array, write it to a waveform record, read it back again
; and plot it.
IDL> name = "idl_test:wf1"
IDL> status = caGetCountAndType(name, n, type)
IDL> data = sin(dindgen(n) * 2 * !PI / (n-1))
IDL> status = caPut(name, data)
IDL> status = caGet(name, readback)
IDL> plot, readback
; Print the list of valid values for the .SCAN field of a record as strings,
; one per line.
status = caGetEnumStrings('idl_test:ai1.SCAN', choices)
for i=0, n_elements(choices)-1 do print, choices(i)
; Print out the next 10 values for a process variable which is changing by
; waiting for monitor events.
;
pv = 'mlr_scanner'
status = caSetMonitor(pv) ; Add a monitor on this pv
status = caGet(pv, data) ; Read the value, which clears the monitor flag
for i=1, 10 do begin
count = 0
status = 0
while (caCheckMonitor(pv) ne 0) and (count le 100) do begin
wait, .01
count = count + 1 ; Assumes new monitors come faster
if (count eq 100) then status = -1 ; than 1 per second
endwhile
if (status ne 0) then begin
print, 'Monitor wait failed for ', pv
endif else begin
status = caGet(pv, data)
print, 'New value = ', data
endelse
endfor
status = caClearMonitor(pv)
; The following is an example of a synchronous group operation
; It also shows how to handle strings in synchronous groups.
caStartGroup
status = caGet('test_mca1.VAL', mca_value)
status = caGet('test_vme1.VAL', vme_value)
status = caGet('test_vme1.DESC', vme_desc) ; This is a string PV
status = caEndGroup()
vme_desc = string(vme_desc) ; Convert from byte array to string
</pre>
<h2>
<a id="Widgets">IDL Widgets</a></h2>
<p>
The file <code>ezcaIDLWidgets.pro</code> contains 3 routines which simplify the
use of channel access, and particularly channel access monitors, with the IDL widget
toolkit.
</p>
<h3>
caWidgetSetMonitor(name, widget_id, time=time)</h3>
<p>
This function first adds a monitor on process variable "name", using routine <code>
caSetMonitor()</code>.
</p>
<p>
If this is the first time <code>caWidgetSetMonitor</code> has been called then it
creates a dummy (iconified) widget which runs a timer routine. The timer routine
periodically calls <code>caCheckMonitor(name)</code> to determine whether a channel
access monitor has arrived for "name". If a monitor has occurred then an event will
be sent to the widget whose ID is specified by "widget_id".
</p>
<p>
The event structure is as follows:</p>
<pre>
event =
{ id ; The widget ID which was passed to caWidgetSetMonitor
top: ; The top level widget in this hierarchy
handler: ; The widget handler routine
name: ; The name of the process variable for which a monitor has
; occurred.
}
</pre>
<p>
When the event is sent, the event handler routine for the specified widget will
be called. Generally this routine look at the <code>event.id</code> field to determine
that this is a monitor event (rather than a mouse event). If the same event handler
can receive monitor events from more than one process variable, (because <code>caWidgetSetMonitor</code>
was called for several process variables) the event handler will then look at the
<code>event.name</code> field to determine which process variable generated the
monitor event.
</p>
<p>
Typically the widget_id which is passed to <code>caWidgetSetMonitor</code> should
be the id of a base widget. Base widgets cannot generate events due to mouse clicks,
etc. so the widget event handler routine can distinguish monitor events from mouse
events by looking at the <code>widget.id</code> field. This is the same concept
which is described in the IDL documentation for timer events, e.g.</p>
<pre>
widget_control, wid, timer=1.0
</pre>
<p>
<code>caWidgetSetMonitor</code> can be called for many different process variable
names and widget_ids. The widgets do not need to belong to the same widget hierarchy.
Multiple widgets can monitor the same process variable, and the same widget can
be used to monitor several process variables. Internally <code>caWidgetSetMonitor</code>
maintains a list of all monitored process variables, and which widget_id(s) are
to receive events from each process variable.
</p>
<p>
The "time" keyword to <code>caWidgetSetMonitor</code> can be used to control the
time interval between polling cycles. The default is 0.1 seconds.
</p>
<p>
This routine sounds complex, but in fact it is simple to use and greatly simplifies
the use of channel access monitors with IDL widget, since without it each widget
event routine would have to poll to detect the arrival of channel access monitors.
The following is a simple example of the use of this routine:
</p>
<pre>
pro example_event, event
common example_common, pv_name, widget_ids
; This is the event handler routine, called whenever any type of event
; (monitor, mouse, timer) occurs.
case event.id of
widget_ids.monitor: begin
; Read the new value and display it
status = caGet(event.name, value, /string)
widget_control, widget_ids.value, set_value=value
end
widget_ids.exit: begin
t=CaWidgetClearMonitor(pv_name, widget_ids.monitor)
widget_control, event.top, /destroy
end
endcase
end
pro example, name
common example_common, pv_name, widget_ids
; This is the main routine for the example.
; It is passed the name of a process variable to monitor.
; It creates a simple screen with a value field for the monitored process
; variable and an EXIT button
widget_ids= { $
monitor: 0L, $
value: 0L, $
exit: 0L }
base=widget_base(title="Example", /column) ; The base widget
widget_ids.monitor=base ; The monitor widget id=base
widget_ids.value=widget_text(base, xsize=20) ; Widget to display new value
widget_ids.exit=widget_button(base, value="Exit") ; Exit button
widget_control, base, /realize ; Display the widgets
t=caWidgetSetMonitor(name, widget_ids.monitor); Call caWidgetSetMonitor
pv_name = name ; Copy name to common
xmanager, "example", base ; Start the program
end
</pre>
<h3>
caWidgetClearMonitor(name, widget_id)</h3>
<p>
This routine cancels the effect of <code>caWidgetSetMonitor</code>. If there are
no other widgets monitoring this process variable then <code>caClearMonitor</code>
is called to completely remove the channel access monitor on this name.
</p>
<h3>
CaWidgetAdjust(name, font=font, min=min, max=max, label=label, group=group)
</h3>
<p>
This is a general purpose routine for adjusting and monitoring a process variable.
It creates widget which is appropriate for the data type of "name", i.e. a mutually
exclusive menu for DBF_ENUM, a text entry widget for DBF_STRING and an editable
slider widget for any numeric data type. This routine can be called from the event
handler of larger applications when all that needs to be done is adjust the value
of a process variable.
</p>
<p>
<code>name</code> is the name of the process variable to be adjusted.
</p>
<p>
The <code>font</code> keyword can be used to specify a font to use.
</p>
<p>
The <code>min</code> and <code>max</code> keywords can be used to specify the upper
and lower limits of the slider widget when adjusting numeric process variables.
</p>
<p>
The <code>label</code> keyword can be used to put a descriptive label at the top
of the widget.
</p>
<p>
The <code>group</code> keyword can be used to set the id of the parent widget. If
the widget specified by <code>group</code> is deleted, then the widget created by
<code>CaWidgetAdjust</code> will also be deleted.
</p>
</body>
</html>