ISIS Logo
lvDCOM
An EPICS support module to export LabVIEW values as process variables
lvDCOM (LabVIEW DCOM EPICS Support Module)

lvDCOM is an EPICS support module that can exports front panel variables from National Instruments LabVIEW(TM) 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.

For an alternative approach using network shared variables, which can additionally be used on Linux, see NetShrVar (Network Shared Variable EPICS Support Module)

For a brief introduction to lvDCOM see the following presentation from the EPICS 2013 spring meeting (also available as PDF in doc directory of distribution)

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 CA Lab is the program to use.

Features of lvDCOM are:

The lvDCOM software is an EPICS Asyn driver 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 lvinput.xml, 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 example.db.

The syntax of the XML configuration file is described in the comments in lvinput.xml and lvDCOMinput.xsd . 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.

See the doc directory of the distribution for further information.

Download

Source code is hosted on Github and a pre-build Windows binary of lvDCOM can be downloaded from the ISIS EPICS homepage.

It is not necessary to create a new lvDCOM IOC to talk to a different set of VIs. Everything is configured from st.cmd via lvinput.xml and so the same executable can be re-used. The lvinput.xml file supports multiple VI config section and so can also be shared between IOCs.

Requirements

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 fix_xml.sh 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:

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

Building lvDCOM from source requires the full version of the Microsoft Visual Studio C++ compiler (ATL 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.

To build from source, unpack the ZIP file, adjust configure/RELEASE in the usual way to reflect your setup, then type make.

Automatically generate XML configuration and EPICS DB files

We first need to obtain a list of the available controls/indicators on the VI via:

For the next couple of steps you need both the xsltproc and sed programs in your PATH - see requirements section above.

First we need to adjust the "exported strings" from LabVIEW so they can be read by XML utilities, via:

fix_xml.cmd controls.txt controls.xml

which generates a controls.xml file (if you are on Linux use fix_xml.sh instead) Then to generate the initial LvDCOM XML input file run:

xsltproc lvstrings2input.xsl controls.xml > lvinput.xml

you can now edit lvinput.xml 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 as part of the path. An XML schema definition file lvDCOMinput.xsd is also provided and, if present in the same directory as lvinput.xml, should be picked up automatically by XML aware editors to make editing easier. Certain types of complex/nested controls are not currently handled by lvstrings2input.xsl 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 lvstrings2input.xsl)

Finally, to generate an initial EPICS DB file run:

xsltproc lvinput2db.xsl lvinput.xml > example.db

As before, example.db can then be adjusted as appropriate. The fix_xml.cmd and xsltproc commands above should not produce any screen output - if they do it is probably because they encountered an error parsing the file.

Remote Connection

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):

LabVIEW.exe /RegServer

next run the dcomcnfg command, typical LabVIEW.Application DCOM options to modify would be:

If you are running a 32bit LabVIEW on a 64bit computer, then you will not see LabVIEW listed if you just type dcomcnfg as there are separate 32 bit and 64 bit com registries. Instead you need to type:

cd C:\WINDOWS\SysWOW64
mmc comexp.msc /32

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 AppId is missing from one part of the Windows registry. You can attempt to check/fix this using the procedure below but changes to the windows registry must be done with care and you may wish to check with your local Windows operating system expert first.

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 regedit - instead you need to:

cd C:\WINDOWS\SysWOW64
regedit

SECI option (ISIS only)

lvDCOM can read information from a running instance of SECI and generate an appropriate lvinput.xml and an EPICS DB substitution file to load lvDCOM_int32.template etc. and provide PVs for reading on other instruments. This is done using lvDCOMSECIConfigure() and then loading the generated substitutions file with dbLoadTemplate()

    lvDCOMSECIConfigure("lvfp", "P=$(MYPVPREFIX)CS:SBX:,PORT=lvfp", "frontpanel", "$(TOP)/db/seci.xml", "$(TOP)/db/seci.substitutions")
    dbLoadTemplate("$(TOP)/db/seci.substitutions")

Note on LabVIEW projects

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.

Support

If you need further help, or discover any problems, or have any suggestions for new features/improvements, please contact Freddie Akeroyd (fredd.nosp@m.ie.a.nosp@m.keroy.nosp@m.d@st.nosp@m.fc.ac.nosp@m..uk)

License

lvDCOM is Copyright (c) 2013 STFC ISIS Facility, Rutherford Appleton Laboratory, GB. All rights reserved.
It is distributed under the EPICS Open License as detailed in the included LICENSE.txt file.

When distributed in binary form, lvDCOM will have been linked against the EPICS BASE, autosave and ASYN driver 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:

EPICS BASE

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.

AUTOSAVE

Copyright (c) 2005 University of Chicago and the Regents of the University of 
California. All rights reserved.

ASYN DRIVER

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).

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.

Copyright © 2013 Science and Technology Facilities Council | Generated by   doxygen 1.8.5