forked from ISISComputingGroup/EPICS-lvDCOM
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMainPage.dox
294 lines (237 loc) · 14.5 KB
/
MainPage.dox
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
<HTML>
/** @mainpage lvDCOM (%LabVIEW DCOM EPICS Support Module)
lvDCOM is an <A HREF="http://www.aps.anl.gov/epics/">EPICS</A> support module
that can exports front panel variables from <A HREF="http://www.ni.com/labview/">National Instruments LabVIEW(TM)</A> software applications
as EPICS process variables on computers running the Microsoft Windows operating system. The
program allows you to rapidly "EPICS enable" existing %LabVIEW applications as it is not
necessary to modify Virtual Instrument (VI) internals, so it could be used to conveniently
wrap e.g. manufacturer supplied applications. As the program uses DCOM for communication, this (ActiveX) needs
to be selected in the "VI Server" options of %LabVIEW, but this is the only required change to a VI.
<P>
For an alternative approach using network shared variables, which can additionally be used on Linux,
see <A HREF="http://epics.isis.stfc.ac.uk/wiki/NETSHRVAR">NetShrVar (Network Shared Variable EPICS Support Module)</A>
For a brief introduction to lvDCOM see the
<A HREF="http://www.epics2013.org/dms/EPICS2013/presentations/friday/Session_1/LabVIEW-via-DCOM-IOC-EPICS-2013/LabVIEW%20via%20DCOM%20IOC%20EPICS%202013.ppt">following presentation
from the EPICS 2013 spring meeting</A> (also available as PDF in doc directory of distribution)
</P><P>
lvDCOM allows %LabVIEW variables to be accessed by EPICS aware tools, if you wish to instead display
existing EPICS process variables on %LabVIEW front panels then
<A HREF="http://www-csr.bessy.de/control/SoftDist/CA_Lab/">CA Lab</A> is the program to use.
</P>
Features of lvDCOM are:
<UL>
<LI> Able to communicate with either native %LabVIEW VIs or compiled %LabVIEW applications (.EXE)
<UL>
<LI> For a compiled %LabVIEW application, you need to select the
"advanced properties" and check the "enable ActiveX server" box and
specify an "ActiveX server name" when you build the application. If
you give, for example, "MyApp" here then you would specify
"MyApp.Application" as the progid parameter to lvDCOMConfigure() in
your @link st.cmd IOC startup file. @endlink
</UL>
<LI> Can (optionally) automatically start and/or stop VIs on IOC startup/shutdown (see #lvDCOMOptions)
<LI> Can communicate with remote Windows PCs using standard DCOM authentication or
a supplied (in @link st.cmd @endlink) username + password
<LI> Can handle additional front panel logic e.g. automatically push a front panel button either
before doing a read from, of after doing a write to, another front panel variable
<LI> Is able to trigger %LabVIEW events in most circumstances by writing via a "proxy VI". Writing via Windows DCOM
to a front panel %LabVIEW control does not directly trigger events, but a generic proxy VI is included that can be used to achieve this. The
VI also checks limits on front panel controls and their enabled/disabled state, this is something else that is
bypassed by DCOM. To enable this feature see the comments in @link lvinput.xml @endlink regarding using the "extint" tag.
</UL>
</P><P>
The lvDCOM software is an EPICS
<A HREF="http://www.aps.anl.gov/epics/modules/soft/asyn/">Asyn driver</A> that
uses DCOM to communicate with %LabVIEW. %LabVIEW front panel items (controls and indicators)
are mapped to asyn driver parameters via an XML configuration file @link lvinput.xml @endlink,
each "section" in the XML file being accessed via a specified asyn "port name". These driver parameters
can then be linked to process variables via @link example.db @endlink.
</P><P>
The syntax of the XML configuration file is described in the
comments in @link lvinput.xml @endlink and @link lvDCOMinput.xsd @endlink .
An initial XML file can first be generated by the procedure
below and then adjusted accordingly. Various TODO: comments are inserted in the file
to indicate where changes are likely to be needed, in particular an absolute
path to a VI is required but this is not passed to the tool by the export process.
This procedure will also attempt to map %LabVIEW rings/enums into
EPICS MBBI/MBBO records, but as some of the value information is not
available in the %LabVIEW controls export process the resulting enum/ring numeric values
may need to be adjusted before use.
</P>
See the doc directory of the distribution for further information.
<H2>Download</H2>
Source code is hosted on <A HREF="https://github.com/ISISComputingGroup/EPICS-lvDCOM">Github</A> and a pre-build Windows binary of lvDCOM can be downloaded from the
<A HREF="http://epics.isis.stfc.ac.uk/">ISIS EPICS homepage</A>.
<P>
It is not necessary to create a new lvDCOM IOC to talk to a different
set of VIs. Everything is configured from @link st.cmd @endlink via @link lvinput.xml @endlink
and so the same executable can be re-used. The @link lvinput.xml @endlink file supports
multiple VI config section and so can also be shared between IOCs.
</P>
<H2>Requirements</H2>
The sed and xsltproc programs are required to generate an initial configuration
file from the "exported strings" of a %LabVIEW front panel. Windows binaries for these are
available from http://gnuwin32.sourceforge.net/packages/sed.htm
and http://gnuwin32.sourceforge.net/packages/libxslt.htm alternatively these
steps could be carried out on a Linux computer and the results transferred back to Windows.
A Linux specific @link fix_xml.sh @endlink is provided to help with this, but you may
need to adjust line endings (<CR> <-> <CR><LF>) on some of the input/output files. For this you
can use the dos2unix and unix2dos programs or some of the following sed commands on Linux:
<PRE>
sed -e 's/$/\\r/' unix_file > windows_file # unix2dos equivalent
sed -e 's/\\r$//' windows_file > unix_file # dos2unix equivalent
sed -i -e 's/$/\\r/' unix2windows_file # unix2dos -o (in place conversion) equivalent
sed -i -e 's/\\r$//' windows2unix_file # dos2unix -o (in place conversion) equivalent
</PRE>
<P>
Building lvDCOM from source requires the full version of the
Microsoft Visual Studio C++ compiler
(<A HREF="http://en.wikipedia.org/wiki/Active_Template_Library">ATL</A>
is used for DCOM and that is not available
in the express compiler version). A pre-built win32 lvDCOM binary can, however,
be downloaded from http://epics.isis.stfc.ac.uk/ and this does not require any additional
Microsoft tools/libraries to be installed.
</P><P>
To build from source, unpack the ZIP file, adjust configure/RELEASE
in the usual way to reflect your setup, then type make.
</P>
<H3>Automatically generate XML configuration and EPICS DB files</H3>
We first need to obtain a list of the available controls/indicators on the VI via:
<UL>
<LI> Open VI in %LabVIEW
<LI> Go to Tools menu, Advanced, Export Strings... and uncheck the wizard
option for "block diagram strings" and save the export results to a text file e.g. <b>@link controls.txt @endlink</b>
(Note: you may need write access to the VI itself to do this, so might have
to make a local copy of the VI first)
</UL>
<P>
For the next couple of steps you need both the xsltproc and sed programs in
your PATH - see requirements section above.
</P><P>
First we need to adjust the "exported strings" from %LabVIEW so they can be
read by XML utilities, via:
<PRE>
fix_xml.cmd controls.txt controls.xml
</PRE>
which generates a <b>@link controls.xml @endlink</b> file (if you are on Linux use <b>@link fix_xml.sh @endlink</b> instead)
Then to generate the initial LvDCOM XML input file run:
<PRE>
xsltproc lvstrings2input.xsl controls.xml > lvinput.xml
</PRE>
you can now edit <b>@link lvinput.xml @endlink</b> to remove or rename items etc. You will
need to adjust the "path" to the %LabVIEW Vi to make it absolute, the original path information
is unfortunately not passed on from "Export Strings..." above. You can use EPICS macros
known to the IOC like $(TOP) as part of the path. An XML
schema definition file <b>@link lvDCOMinput.xsd @endlink</b> is also provided and, if
present in the same directory as <b>@link lvinput.xml @endlink</b>, should be picked up
automatically by XML aware editors to make editing easier. Certain types of complex/nested
controls are not currently handled by @link lvstrings2input.xsl @endlink
so you may need to edit controls.xml and remove them if you get an incorrect lvinput.xml
(If you can send me an example controls.xml that causes problems, I can improve @link lvstrings2input.xsl @endlink)
Finally, to
generate an initial EPICS DB file run:
<PRE>
xsltproc lvinput2db.xsl lvinput.xml > example.db
</PRE>
</P><P>
As before, <b>@link example.db @endlink</b> can then be adjusted as appropriate.
The <b>@link fix_xml.cmd @endlink</b> and <b>xsltproc</b> commands above should not produce
any screen output - if they do it is probably because they encountered an
error parsing the file.
</P>
<H2>Remote Connection</H2>
If you wish to run an lvDCOM IOC and %LabVIEW on different computers, then you will probably need to
configure some additional DCOM options on the target (%LabVIEW) computer.
First make sure LabVIEW is DCOM registered by running (as administrator):
<PRE>
LabVIEW.exe /RegServer
</PRE>
next run the <b>dcomcnfg</b> command, typical LabVIEW.Application DCOM options to modify would be:
<UL>
<LI>On the Security tab, depending on the username you connect with (add appropriate launch/activation permissions)
<LI>On the Identity tab, depending on how the target machine is configured/used (e.g. as Interactive User)
</UL>
If you are running a 32bit LabVIEW on a 64bit computer, then you will not see LabVIEW listed if you just type <b>dcomcnfg</b> as there are separate 32 bit and 64 bit com registries. Instead you need to type:
<PRE>
cd C:\\WINDOWS\\SysWOW64
mmc comexp.msc /32
</PRE>
See https://msdn.microsoft.com/en-us/library/windows/desktop/ms678426(v=vs.85).aspx for more details
If you find that your DCOM settings are being ignored (e.g. a second instance of %LabVIEW is started when
one is already running locally despite "Interactive User" been specified in the "Identity" tab) then
it may be that the %LabVIEW <b>AppId</b> is missing from one part of the Windows registry. You
can attempt to check/fix this using the procedure below but <B>changes to the windows registry must be done with care and you may wish to check with your local Windows operating system expert first</B>.
<UL>
<LI> Find the CLSID of %LabVIEW - you can use the windows <I>dcomcnfg</I> command for this, or search the registry.
<LI> Under HKEY_LOCAL_MACHINE\\SOFTWARE\\Classes\\AppID, find LabVIEW.exe and copy the AppId value
<LI> Under HKEY_LOCAL_MACHINE\\SOFTWARE\\Classes\\CLSID\\{%LabVIEW CLSID from step 1}, add a new string value called AppId and set its value to the AppId recorded previously.
</UL>
If you don't see LabVIEW under CLSID, check you did run /RegServer above as an administrator.
Note that there are separate 32bit and 64 bit registries, if you are running 32bit %LabVIEW on a 64 bit computer you will not find LabVIEW.exe if you just run <b>regedit</b> - instead you need to:
<PRE>
cd C:\\WINDOWS\\SysWOW64
regedit
</PRE>
<H2>SECI option (ISIS only)</H2>
lvDCOM can read information from a running instance of SECI and generate an appropriate lvinput.xml
and an EPICS DB substitution file to load @link lvDCOM_int32.template @endlink etc. and provide PVs for reading on
other instruments. This is done using lvDCOMSECIConfigure() and then loading the generated substitutions
file with dbLoadTemplate()
<PRE>
lvDCOMSECIConfigure("lvfp", "P=$(MYPVPREFIX)CS:SBX:,PORT=lvfp", "frontpanel", "$(TOP)/db/seci.xml", "$(TOP)/db/seci.substitutions")
dbLoadTemplate("$(TOP)/db/seci.substitutions")
</PRE>
<H2>Note on %LabVIEW projects</H2>
If the VI you are using is part of a %LabVIEW project, then you may need to be aware of "Application Instances".
If you open the VI via project explorer and then run the lvDCOM IOC, you will find that you
can read values OK but writes seem to be "ignored". The write will actually have gone to a separate "application instance".
This is something that you will probably only come across if you are developing and testing code on the same computer.
In the bottom left of the VI opened via "project explorer" you will see the name of the application instance,
if you right click on this you can change it to be "main application instance" which is the instance used by VIs not
opened via project explorer (such as those accessed via external programs such as lvDCOM).
See the National Instruments "Working with Application Instances" documentation for further details.
<H2>Support</H2>
If you need further help, or discover any problems, or have any suggestions for
new features/improvements, please contact Freddie Akeroyd ([email protected])
<H2>License</H2>
lvDCOM is Copyright (c) 2013 <A HREF="http://www.isis.stfc.ac.uk/">STFC ISIS Facility, Rutherford Appleton Laboratory, GB</A>. All rights reserved.<BR />
It is distributed under the <A HREF="http://www.aps.anl.gov/epics/license/index.php">EPICS Open License</A>
as detailed in the included LICENSE.txt file.
<P>
When distributed in binary form, lvDCOM will have been linked against
the <A HREF="http://www.aps.anl.gov/epics/base/">EPICS BASE</A>,
<A HREF="http://www.aps.anl.gov/bcda/synApps/autosave/autosave.html">autosave</A>
and <A HREF="http://www.aps.anl.gov/epics/modules/soft/asyn/">ASYN driver</A> software.
These works are covered by
licences detailed in the LICENSE_EPICS_BASE.txt, LICENSE_AUTOSAVE.txt
and LICENSE_ASYN.txt files contained within the distribution and the following
copyright notices:
<H3>EPICS BASE</H3>
<PRE>
Copyright (c) 1991-2011 UChicago Argonne LLC.
Copyright (c) 1991-2006 The Regents of the University of California.
Copyright (c) 2006-2011. Los Alamos National Security, LLC. Some of this
material was produced under U.S. Government contract DE-AC52-06NA25396
for Los Alamos National Laboratory (LANL), which is operated by Los Alamos
National Security, LLC for the U.S. Department of Energy.
</PRE>
<H3>AUTOSAVE</H3>
<PRE>
Copyright (c) 2005 University of Chicago and the Regents of the University of
California. All rights reserved.
</PRE>
<H3>ASYN DRIVER</H3>
<PRE>
Copyright (c) 2002 University of Chicago, The Regents of the
University of California, and Berliner Elektronenspeicherring
Gesellschaft fuer Synchrotronstrahlung m.b.H. (BESSY) All rights
reserved.
Copyright (c) 2004 by Danfysik and Cosylab (Danfysik has funded the work
performed by Cosylab).
</PRE>
</P>
%LabVIEW is a trademark of National Instruments. Neither STFC, nor any software programs or other
goods or services offered by STFC, are affiliated with, endorsed by, or sponsored by National Instruments.
*/
<!-- $Id$ -->
</HTML>