ISIS Logo
NetShrVar
An EPICS support module to export National Instruments Network Shared Variables as process variables
NetShrVar (Network Shared Variable EPICS Support Module)

NetShrVar is an EPICS support module that can export National Instruments Network Shared Variables as EPICS process variables. The program can be run on either the Microsoft Windows or Linux operating systems.

Network Shared Variables (NSV) are exported by many types of National Instruments equipment - use the "Distributed System Manager" for a list of what is available on your network. NetShrVar can provide an alternative to lvDCOM for EPICS enabling LabVIEW applications. Key difference are:

So though NetShrVar is targeted more widely, it is potentially a useful tool for use with LabVIEW software. If you are using LabVIEW projects, you can create and deploy persistent network shared variables via the variable manager.

In some cases it is possible to deploy EPICS variables directly from LabVIEW, however this may require the purchase of additional software, such as the DSC module. In addition the LabVIEW EPICS I/O Server, at time of writing, does not provide full EPICS IOC functionality.

NetShrVar is a server in that it exports information to the EPICS environment, if you wish to instead display existing EPICS process variables on LabVIEW front panels then CA Lab is the program to use.

Features of NetShrVar are:

The NetShrVar software is an EPICS Asyn driver that uses NI-PSP to communicate with equipment. Variables are mapped to asyn driver parameters via an XML configuration file netvarconfig.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 TestNetShrVar.db.

The syntax of the XML configuration file is described in the comments in netvarconfig.xml and schema file NetShrVarConfig.xsd . An initial XML file can first be generated via netvarconfig2db.xsl by the procedure below and then adjusted accordingly.

See the doc directory of the distribution for further information.

Download

Source code is hosted on Github and pre-built binaries of NetShrVar can be downloaded from the ISIS EPICS homepage.

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

Requirements

The xsltproc program (part of libxml2) is required to generate an initial EPICS db file from the XML configuration file. On windows it can be downloaded from 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. 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 NetShrVar from source requires the Microsoft Visual Studio C++ compiler A pre-built win32 NetShrVar 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. The LabWindwos/CVI runtime modules is required on the machine running NetShrVar.

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

Automatically generate EPICS DB files

you need the xsltproc program in your PATH - see requirements section above.

Then to generate the initial NetShrVar XML input file run:

xsltproc netvarconfig2db.xsl netvarconfig.xml > epics.db

You can use EPICS macros known to the IOC like TOP as part of the path. An XML schema definition file NetShrVarConfig.xsd is also provided and, if present in the same directory as netvarconfig.xml, should be picked up automatically by XML aware editors to make editing easier. The resulting TestNetShrVar.db can then be adjusted as appropriate

Running Example

First Open "TestNetShrVarAPP/src/example.lvproj" then right click on example.lvlib and “deploy all” to publish example network shared variables from example.vi These variables are all in the "example" process namespace and so are prefixed //localhost/example After deployment, they should be visible in the National Instruments Distributed system manager software.

The variables are all bound to controls/indicators on the front panel of "example.vi" - see "Data Binding" from the front panel "properties" of each control/indicator

Now load example.vi into LabVIEW and start it running. The triangle next to each front panel object will turn green if the connection to the bound shared variable worked from LabVIEW.

Open a command prompt and change directory to iocBoot/iocTestNetShrVar Check the definition of TOP in the envPaths file - it should point to the top of your distribution. Any other paths present in envPaths are not important. Now type:

    runIOC st.cmd

this should start the IOC and you will finish with an epics> prompt. Check that no errors are reported. You can now type:

    asynReport

to see all your connections to shared variables and

    dbl

To see the EPICS process variables that have been created to connect to these. Process variables are the externally visible names and these are connected by the program to the asyn parameters displayed in asynReport above.

The PVs created with an _RBV suffix will be EPICS input records and update when the corresponding shared variable updates. The ones without _RBV are EPICS output records and so will not update on shared variable changes, they are just used to write to the shared variable from EPICS. So if you need to both read and write to the same shared variable you will need to create two PVs, one for setting and one for readback, both linked to the same shared variable via the XML file.

You can read the value of a variable using the dbgf commandat the epics> IOC prompt:

    dbgf TEST:ind1_RBV

or for a bit more detail using dbpr

    dbpr TEST:ind1_RBV

Using the EPICS command line utilities, you should be able to type, in a separate cmd window to the running IOC above:

    camonitor TEST:bool1_RBV

and then toggle the button on example.vi and see it change. To alter the value via EPICS type e.g.

    caput TEST:bool1 off  

(not that in epics a process variable is either read or write), we have used _RBV for "read back value" in our example db file)

To see a rapidly changing variable try:

    camonitor TEST:ind1_RBV

Rather than using a command line, you can also use various EPICS GUI client tools to check the process variable link. One good one for LabVIEW based environments is CaLab http://www-csr.bessy.de/control/SoftDist/CA_Lab/

Notes

On windows the library links against cvirte.dll but will activate ninetv.dll at run time, if you get an error loading library message it likely has not found (or found an incompatible) ninetv.dll

If you are updating a shared variable from LabVIEW, by default it will flush shared variable writes every 10ms. If you wish to have the data picked up earlier you will need to use flush shared variable data.vi after your write.

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

NetShrVar 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, NetShrVar 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.

This software is based on pugixml library (http://pugixml.org). pugixml is Copyright (C) 2006-2014 Arseny Kapoulkine. See README_pugixml.txt for further details.

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