468 lines
16 KiB
HTML
468 lines
16 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
|
"http://www.w3.org/TR/html4/loose.dtd">
|
|
<html><head>
|
|
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
|
|
<meta http-equiv="author" content="Dirk Zimoch">
|
|
<style type="text/css">
|
|
<!--
|
|
body { font-family:Arial,sans-serif,espy;
|
|
background:white; margin:0; }
|
|
body,p,ul,ol,dl,div,table {font-size:12pt; }
|
|
p { line-height:120%; }
|
|
pre,code,tt { font-family:"Courier New",Courier,monospace; }
|
|
code,tt { font-size:13pt; }
|
|
h1 { font-size: 24pt; margin-top:1ex; margin-bottom:0; text-align:center; }
|
|
h2 { font-size: 18pt; margin-bottom:0.5ex; }
|
|
h3 { font-size: 14pt; margin-bottom:0.5ex; }
|
|
h4 { font-size: 13pt; margin-bottom:0.5ex; }
|
|
h5 { font-size: 12pt; margin-bottom:0.5ex; }
|
|
small { font-size: 9pt; }
|
|
code { color:#0000C0; }
|
|
li { margin-top: 2pt; margin-bottom: 2pt; }
|
|
pre { font-size: 13pt;
|
|
white-space:pre; }
|
|
.box { border:1px solid #000000;
|
|
background-color:#f4f4f4;
|
|
padding:1ex;
|
|
margin: 0 2ex 1ex 2ex; font-size:90%; }
|
|
th.PageTitle {
|
|
font-size : 14pt;
|
|
font-weight : bold; }
|
|
.menuf {
|
|
font-size:11pt;
|
|
color:#333333;
|
|
font-weight:600;
|
|
text-decoration:none;
|
|
}
|
|
.menuf:link {color:#333333;}
|
|
.menuf:visited {color:#666666;}
|
|
.menuf:hover {color:#FF0000;}
|
|
.menuf:active {color:#FF0000;}
|
|
.menus, .menus a {
|
|
font-size:10pt;
|
|
color:#333333;
|
|
text-decoration:none;
|
|
}
|
|
.menus:visited, .menus a:visited {color:#666666;}
|
|
.menus:hover, .menus a:hover {color:#FF0000;}
|
|
.menus:active, .menus a:active {color:#FF0000;}
|
|
a:hover {color:#FF0000;}
|
|
.red {color:#FF0000;}
|
|
.green {color:#008000;}
|
|
.blue {color:#0000C0;}
|
|
|
|
@media screen {
|
|
.printlayout {display:none;}
|
|
}
|
|
|
|
@media print {
|
|
.screenlayout {display:none;}
|
|
code { color:#000000; }
|
|
a:link {color:#000000;text-decoration:none}
|
|
a:visited {color:#000000;text-decoration:none}
|
|
a:hover {color:#000000;text-decoration:none}
|
|
a:active {color:#000000;text-decoration:none}
|
|
}
|
|
-->
|
|
</style>
|
|
<link rel="shortcut icon" href="http://epics.web.psi.ch/images/sls_icon.ico">
|
|
<title>Lessons on Channel Access Client Programming</title>
|
|
</head>
|
|
<body bgcolor="#FFFFFF">
|
|
<table cellspacing="0" cellpadding="0" border="0" width="100%">
|
|
|
|
<tr class="screenlayout">
|
|
<td bgcolor="#267ab8" colspan="5" valign="bottom" height="10">
|
|
<img
|
|
src="../images/black"
|
|
width="100%" height="1" alt=""></td>
|
|
</tr>
|
|
|
|
<tr class="screenlayout">
|
|
<td rowspan="2" colspan="2" align="center">
|
|
<a class="menuf" href="http://www.psi.ch"><img
|
|
src="../images/psi_logo" border="0"
|
|
alt="PAUL SCHERRER INSTITUT"></a></td>
|
|
<td rowspan="2"><img
|
|
src="../images/space"
|
|
width="1" height="65" alt=""></td>
|
|
<th class="PageTitle"><center>
|
|
<big>EPICS at PSI<big>
|
|
</center>
|
|
</th>
|
|
<td><img
|
|
src="../images/space"
|
|
width="10" height="1" alt=""></td>
|
|
</tr>
|
|
|
|
<tr class="screenlayout">
|
|
<th width="100%" valign="bottom" align="left">
|
|
<table border="0" cellspacing="0" cellpadding="0"><tr><td><a
|
|
href="https://www.psi.ch"
|
|
class="menuf">PSI</a></td><td><img
|
|
src="../images/space"
|
|
width="10" height="1" alt=""></td><td bgcolor="black"><img
|
|
src="../images/space"
|
|
width="1" height="1" alt=""></td><td><img
|
|
src="../images/space"
|
|
width="10" height="1" alt=""></td><td><a
|
|
href="https://www.aps.anl.gov/epics"
|
|
class="menuf">EPICS</a></td><td><img
|
|
src="../images/space"
|
|
width="10" height="1" alt=""></td><td bgcolor="black"><img
|
|
src="../images/space"
|
|
width="1" height="1" alt=""></td><td><img
|
|
src="../images/space"
|
|
width="10" height="1" alt=""></td><td><a
|
|
href="https://www.psi.ch/en/sls"
|
|
class="menuf">SLS</a></td><td><img
|
|
src="../images/space"
|
|
width="10" height="1" alt=""></td><td bgcolor="black"><img
|
|
src="../images/space"
|
|
width="1" height="1" alt=""></td><td><img
|
|
src="../images/space"
|
|
width="10" height="1" alt=""></td><td><a
|
|
href="https://www.psi.ch/en/swissfel"
|
|
class="menuf">SwissFEL</a></td><td><img
|
|
src="../images/space"
|
|
width="10" height="1" alt=""></td><td bgcolor="black"><img
|
|
src="../images/space"
|
|
width="1" height="1" alt=""></td><td><img
|
|
src="../images/space"
|
|
width="10" height="1" alt=""></td><td><a
|
|
href="https://www.psi.ch/en/protontherapy"
|
|
class="menuf">Proscan</a></td></tr></table>
|
|
</th>
|
|
</tr>
|
|
|
|
<tr class="screenlayout">
|
|
<td height="5" bgcolor="#267ab8" colspan="6" valign="bottom">
|
|
<img
|
|
src="../images/black"
|
|
width="100%" height="1" alt=""></td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td class="screenlayout" bgcolor="#e3eaf6" valign="top" align="center" width="179">
|
|
<br><a href="http://www.aps.anl.gov/epics"><img
|
|
src="../images/EPICS_small"
|
|
alt="EPICS" border=0></a><br><br>
|
|
<table cellspacing="0" cellpadding="0" border="0" width="100%"><tr><td><img
|
|
src="../images/space"
|
|
width="20" height="29" alt=""></td><th width="100%" align="left"><a
|
|
href="../index.html"
|
|
class="menuf">EPICS at PSI</a>
|
|
<img
|
|
src="../images/black"
|
|
height="1" width="100%" alt=""></th></tr></table>
|
|
<table cellspacing="0" cellpadding="0" border="0" width="100%"><tr><td><img
|
|
src="../images/space"
|
|
width="20" height="29" alt=""></td><th width="100%" align="left"><a
|
|
href="../software.html"
|
|
class="menuf">Software</a>
|
|
<ul style="margin:0 0 0 0; padding-left:1em;">
|
|
<li class="menus"><a href="../software/s7plc.html"
|
|
>PLC Communication</a></li>
|
|
<li class="menus"><a href="../software/streamdevice.html"
|
|
>StreamDevice</a></li>
|
|
<li class="menus"><a href="../software/regDev.html"
|
|
>regDev</a></li>
|
|
<li class="menus"><a href="../software/iocmon.html"
|
|
>IOC Monitoring</a></li>
|
|
<li class="menus"><a href="../software/pcmon.html"
|
|
>PC Monitoring</a></li>
|
|
<li class="menus"><a href="../software/firewire.html"
|
|
>Firewire Camera</a></li>
|
|
<li class="menus"><a href="http://dps.web.psi.ch/template.html?/psc/"
|
|
>Digital PS Control</a></li>
|
|
<li class="menus"><a href="../software/tclioc.html"
|
|
>Tcl-IOC</a></li>
|
|
<li class="menus"><a href="../software/iocLogBrowser.html"
|
|
>iocLogBrowser</a></li>
|
|
<li class="menus"><a href="../software/ioc-octave.html"
|
|
>IOC-Octave</a></li>
|
|
<li class="menus"><a href="http://gfa-it.web.psi.ch/epicsSharp/"
|
|
>C# EPICS</a></li>
|
|
<li class="menus"><a href="../software/generalTime.html"
|
|
>generalTime</a></li>
|
|
<li class="menus"><a href="../software/GPMM.html"
|
|
>GPMM</a></li>
|
|
<li class="menus"><a href="../software/sequencer.html"
|
|
>SNC/SEQ</a></li>
|
|
<li class="menus"><a href="../software/caqtdm.html"
|
|
>caQtDM</a></li>
|
|
<li class="menus"><a href="../software/CSDataQuick.html"
|
|
>CSDataQuick</a></li>
|
|
</ul>
|
|
<img
|
|
src="../images/black"
|
|
height="1" width="100%" alt=""></th></tr></table>
|
|
<table cellspacing="0" cellpadding="0" border="0" width="100%"><tr><td><img
|
|
src="../images/space"
|
|
width="20" height="29" alt=""></td><th width="100%" align="left"><a
|
|
href="../training.html"
|
|
class="menuf">Training</a>
|
|
<ul style="margin:0 0 0 0; padding-left:1em;">
|
|
<li class="menus"><a href="PSI-training.html"
|
|
>Courses at PSI</a></li>
|
|
<li class="menus"><a href="caClientLessons.html"
|
|
>CA client lessons</a></li>
|
|
<li class="menus"><a href="downloads.html"
|
|
>Downloads</a></li>
|
|
</ul>
|
|
<img
|
|
src="../images/black"
|
|
height="1" width="100%" alt=""></th></tr></table>
|
|
<form method="get" action="http://www.google.com/search">
|
|
<table border="0" cellpadding="0" cellspacing="0">
|
|
<tr><td align="center" nowrap>
|
|
<input type="search" placeholder="search" name="q" size="13" maxlength="255" value=""><br>
|
|
<input type="hidden" name="domains" value="epics.web.psi.ch">
|
|
<small>
|
|
<input type="radio" name="sitesearch" value=""> web
|
|
<input type="radio" name="sitesearch" value="epics.web.psi.ch"
|
|
checked="checked"> epics.web.psi.ch<br>
|
|
</small>
|
|
</td></tr></table>
|
|
</form><p></p><small>
|
|
Author: <a href="mailto:Dirk Zimoch <dirk.zimoch@psi.ch>?subject=http://epics.web.psi.ch%2Ftraining%2FcaClientLessons%2F">Dirk Zimoch</a><br>
|
|
Phone: +41 56 310 5182<br>
|
|
Updated: 11.05.2007<br>
|
|
<br><a
|
|
href="http://epics.web.psi.ch/training/caClientLessons/%2Ftraining%2FcaClientLessons%2Findex.php?forprint"><img
|
|
src="../images/printer"
|
|
border="0" alt=""></a>
|
|
<br><a
|
|
href="http://epics.web.psi.ch/training/caClientLessons/%2Ftraining%2FcaClientLessons%2Findex.php?forprint">Printer friendly version</a>
|
|
<br> </small><br><div><a href="http://validator.w3.org/check?uri=http://epics.web.psi.ch/training/caClientLessons/index.php&ss=1"><img
|
|
border="0" src="../images/valid-html401.png"
|
|
alt="[Validate HTML]" height="31" width="88"></a><a
|
|
href="http://jigsaw.w3.org/css-validator/validator?uri=http://epics.web.psi.ch/training/caClientLessons/index.php"><img
|
|
style="border:0;width:88px;height:31px"
|
|
src="../images/vcss.png"
|
|
alt="[Validate CSS]"></a></div>
|
|
<br><img
|
|
src="../images/space"
|
|
width="179" height="1" alt=""></td>
|
|
<td width="1" bgcolor="#000000"><img
|
|
src="../images/space"
|
|
width="1" height="1" alt=""></td>
|
|
<td><img
|
|
src="../images/space"
|
|
width="10" height="1" alt=""></td>
|
|
<td valign="top" width="100%" colspan="2">
|
|
<a name="top"></a><center><h1>Lessons on Channel Access Client Programming</h1></center>
|
|
|
|
<p>
|
|
This lessons should qualify a C-programmer to make efficient use
|
|
of the Channel Access client libraries and to write his/her own
|
|
EPICS client applications in C.
|
|
Special attention is directed to network traffic and possible pitfalls.
|
|
</p>
|
|
<p>
|
|
This tutorial is not yet complete.
|
|
Whenever I have some time, I will add more lessons.
|
|
</p>
|
|
|
|
<h2>Contents</h2>
|
|
<ul>
|
|
<li>
|
|
<a href="caClientLessons.html#audience">Audience</a>
|
|
</li>
|
|
<li>
|
|
<a href="caClientLessons.html#references">References</a>
|
|
</li>
|
|
<li>
|
|
<a href="caClientLessons.html#lessons">Lessons</a>
|
|
<ul>
|
|
<li><a href="caClientLessons.html#lesson1">caLesson 1</a> - simple read access</li>
|
|
<li><a href="caClientLessons.html#lesson2">caLesson 2</a> - getting more infos from EPICS</li>
|
|
<li><a href="caClientLessons.html#lesson3">caLesson 3</a> - channel access data types</li>
|
|
<li><a href="caClientLessons.html#lesson4">caLesson 4</a> - monitors and version differences</li>
|
|
<li><a href="caClientLessons.html#lesson5">caLesson 5</a> - write and wait</li>
|
|
</ul>
|
|
</li>
|
|
</ul>
|
|
<a name="audience"></a>
|
|
<h2>Audience</h2>
|
|
<p>
|
|
The lessons are directed to all users of EPICS who want to write
|
|
their own Channel Access client applications in C.
|
|
They are recommend for all programmers who are new to Channel Access,
|
|
not only to members of the PSI controls section.
|
|
</p>
|
|
<p>
|
|
You should be experienced with C.
|
|
I will not try to explain how the C compiler, preprocessor, or linker
|
|
works and what Makefiles are.
|
|
If this is new to you, I recommend to get some programming practice first.
|
|
For some lesson, experience with multi-threading is recommended.
|
|
</p>
|
|
<p>
|
|
If you don't have experience with EPICS yet, you should participate in
|
|
an <a href="../training.html">EPICS trainig, here at PSI</a>
|
|
or <a href="http://www.aps.anl.gov/epics/docs/training.php">
|
|
at some other EPICS site</a>.
|
|
I expect that you know what the terms <i>IOC</i>, <i>record</i> and
|
|
<i>processing</i> mean in the EPICS world.
|
|
Experience with <i>medm</i> or other existing Channel Access clients is
|
|
also helpful.
|
|
</p>
|
|
|
|
<a name="references"></a>
|
|
<h2>References</h2>
|
|
<p>
|
|
See the EPICS home page <a href="http://www.aps.anl.gov/epics/">www.aps.anl.gov/epics</a> for
|
|
everything about EPICS.
|
|
An overwiew what EPICS and Channel Access are is given on the
|
|
<a href="http://www.aps.anl.gov/epics/EpicsDocumentation/EpicsGeneral/epics_overview.html">
|
|
<i>EPICS Overwiew</i> page</a>.
|
|
Especially read the
|
|
<a href="http://www.aps.anl.gov/epics/EpicsDocumentation/EpicsGeneral/epics_overview.html#channelaccess">
|
|
chaper about Channel Access</a>.
|
|
</p>
|
|
<p>
|
|
Today, two major releases of Channel Access are in use: R3.12 (which is still used
|
|
in EPICS release R3.13) and R3.14.
|
|
On the EPICS home page you can find the (very thin)
|
|
<a href="http://www.aps.anl.gov/epics/EpicsDocumentation/AppDevManuals/ChannelAccess/cadoc_1.htm">
|
|
<i>EPICS R3.12 Channel Access Reference Manual</i></a>
|
|
and the much more detailled
|
|
<a href="http://www.aps.anl.gov/epics/base/R3-14/8-docs/CAref.html">
|
|
<i>EPICS R3.14 Channel Access Reference Manual</i></a>.
|
|
</p>
|
|
<p>
|
|
APS provides many lectures in their
|
|
<a href="http://www.aps.anl.gov/epics/docs/GSWE.php">
|
|
<i>Getting Started with Epics</i> series</a>.
|
|
You should definitely read the
|
|
<a href="http://www.aps.anl.gov/aod/bcda/epicsgettingstarted/developtools/introductionchannelaccess.html">
|
|
<i>Introduction to Channel Access Clients</i></a>.
|
|
</p>
|
|
<p>
|
|
Much valueable information can be found in header files.
|
|
If you work at a standard SLS Linux PC, have a look at:<br>
|
|
<tt>/usr/local/epics/base/include/cadef.h</tt><br>
|
|
Otherwise find this file in your local EPICS installation.
|
|
</p>
|
|
|
|
<a name="lessons"></a>
|
|
<h2>Lessons</h2>
|
|
<p>
|
|
The lessons are provided as <tt>tgz</tt> archives. Unpack them anywhere in
|
|
your home directory. Each lesson is in its own directory.
|
|
The lesson itself is contained in the comments in the C files.
|
|
Read them carefully.
|
|
Some lessons contain README files. Read them first.
|
|
</p>
|
|
<p>
|
|
The provided Makefiles are tailored to the SLS installation of EPICS.
|
|
It should not be too difficult to modify them for other installations.
|
|
You may use them as a starting point for your own Channel Access clients.
|
|
</p>
|
|
<p>
|
|
The environment variable <code>EPICS_HOST_ARCH</code> must be defined.
|
|
I have tested all programs on Scientific Linux 3, where we have
|
|
<code>EPICS_HOST_ARCH=SL3-x86</code> at the SLS.
|
|
Other installation will most probably use different values.
|
|
</p>
|
|
<p>
|
|
The used record names exist at the SLS. If you are in the machine network
|
|
or in a beamline network, you will see real life data. From the SLS
|
|
office, you will either see simulations or you can
|
|
connect to the machine network with the <code>cam</code> command.
|
|
In some lessons, we will write to records.
|
|
Depending on the relative location of you and the record, you may
|
|
be allowed to write to real components of the machine!
|
|
<b>This is not a game!</b>
|
|
</p>
|
|
<p>
|
|
If you are not at SLS, you should change the record names so something
|
|
which exists at your site. Probably use a so called <i>softioc</i>
|
|
to provide some records to play with.
|
|
</p>
|
|
|
|
<a name="lesson1"></a>
|
|
<h3>caLesson1</h3>
|
|
<p>
|
|
This lesson shows how to write a very simple CA client program.
|
|
It connects to some channels, reads them, prints them and exits.
|
|
</p>
|
|
<p>
|
|
Download <a href="caClientLessons/caLesson1.tgz">caLesson1.tgz</a>.
|
|
</p>
|
|
|
|
<a name="lesson2"></a>
|
|
<h3>caLesson2</h3>
|
|
<p>
|
|
Here you will learn how to read more than a bare number from a channel.
|
|
This is very useful to format a value correctly or to know the physical
|
|
units of a value.
|
|
In fact, it is this additional information that makes the difference
|
|
between a value and a bare number.
|
|
</p>
|
|
<p>
|
|
You will also see one way to get your data a bit more structured.
|
|
There are many ways to achive the same result, of course.
|
|
You should know how macros work in C to understand this lesson.
|
|
</p>
|
|
<p>
|
|
Download <a href="caClientLessons/caLesson2.tgz">caLesson2.tgz</a>.
|
|
</p>
|
|
|
|
<a name="lesson3"></a>
|
|
<h3>caLesson3</h3>
|
|
<p>
|
|
In this lesson, you will learn about different data types in Channel Access.
|
|
You will also see the difference between "static" and "dynamic" data of a
|
|
channel and how use this to reduce network traffic when reading data
|
|
repeatedly.
|
|
</p>
|
|
<p>
|
|
Download <a href="caClientLessons/caLesson3.tgz">caLesson3.tgz</a>.
|
|
</p>
|
|
|
|
<a name="lesson4"></a>
|
|
<h3>caLesson4</h3>
|
|
<p>
|
|
This lesson introduces "monitors".
|
|
When you install a monitor, a user-defined callback function is called
|
|
by the Channel Access library whenever a channel has new values available.
|
|
This is much more "network friendly" than high rate polling.
|
|
</p>
|
|
<p>
|
|
You will also see the differences beween the Channel Access APIs of EPICS
|
|
R3.13 and R3.14.
|
|
In R3.14, you can still use the R3.13 API and Channel Access clients written
|
|
for EPICS R3.13 should work without modifications with EPICS R3.14.
|
|
Anyway, to be able to understand other people's code, you should know
|
|
both flavours and only R3.14 is designed for multi-threading.
|
|
</p>
|
|
<p>
|
|
Download <a href="caClientLessons/caLesson4.tgz">caLesson4.tgz</a>.
|
|
</p>
|
|
|
|
<a name="lesson5"></a>
|
|
<h3>caLesson5</h3>
|
|
<p>
|
|
In this lesson we will write to a device for the first time.
|
|
We will use a "put-wait" method, that does not return before the device has
|
|
understood and executed the written value.
|
|
This method is best suited for GUI-less programs which can block.
|
|
(In later lessons, we will learn a different way to write values.)
|
|
</p>
|
|
<p>
|
|
After the value is written, we will wait unil the device has finished
|
|
using a monitor on a done flag.
|
|
This is much more efficient than polling a done flag in a loop.
|
|
</p>
|
|
<p>
|
|
Download <a href="caClientLessons/caLesson5.tgz">caLesson5.tgz</a>.
|
|
</p>
|
|
<hr noshade size=1><small>
|
|
<span class="printlayout">Author: Dirk Zimoch Phone: +41 56 310 5182 Email: dirk.zimoch@psi.ch Updated: 11.05.2007 </span>
|
|
Source: /afs/psi.ch/project/epics/webhosting/training/caClientLessons/index.php
|
|
</small>
|
|
</td></tr></table>
|
|
</body></html>
|