Active X CA Server: LabVIEW
This example shows two LabVIEW screens serving a ProcessVariable via ChannelAccess together with two DM screens (displayed via some X server). A single EpicsCAServer is managing the PVs, one being a scalar value, the other being a 200-element array.
![]()
Requirements
The VIs in this distribution are for LabVIEW 6.0While there are low-level ActiveX VIs shipped with LabVIEW that allow access to the CA Server, it's easier to use the LabVIEW library that I created for that purpose, currently named CAServer60.llb.
Its components are explained in the following section.Hello EPICS
This diagram is taken from Tests/SimpeRndExamle.vi. It shows an infinite loop (condition wired to True) that generates random numbers. Each number is wired to a meter on the front panel, represented by an orange DBL port.
In order to serve the value via CA, these steps were taken:
- PVInit.vi is called with a PV name. It returns a PV Handle used by the remaining VIs.
- PVSet is called with this handle as well as the current value.
- PVClose will be called when the inifinite loop exits (which takes about 2 hours on a 450Mhz PentiumII)
Details
This is a short description of the VIs that support the Epics CA Server.
Within LabVIEW you can use the online help to get more information about each specific VI by pressing <CTRL-H> and hoovering the mouse pointer over the VI of interest, as can be seen in the image to the right for the PVInit.vi.
PVInit.vi Create a PV with given name to be served. Deadband might be provided. PVInitEnum.vi Create an enumerated PV to be served. This VI takes a PV name and a list of strings. Each string represents an enumerated state.
A boolean is a two state enumerated type.PVConfig.vi Allows more detailed configuration of the PV.
You can set
- a unit string
- display precision (number of trailing decimal digits)
- various high and low limits for graphical displays, alarms etc.
In a simple approach all the high limits can be wired to a common constant, the same applies to the lows. This will result in a PV being properly displayed as long as the value is in the high-low range. Values outside of this range will be displayed in an alarm state.
PVSet.vi, PVSetText, ... Update the currnt value on the CA server. PVSetEnum.vi For enumerated types the integer value is checked to be valid, i.e. if a corresponding state string was supplied to the PVInitEnum.vi. PVCheckInput.vi See example below. PVClose.vi Stop serving this PV, close the PV handle.
This VI also holds some error reporting code:
If some PV related VI fails, all remaining PV VIs will ignore this PV handle and the PVClose.vi wired to the end of the handle will display the error.Support for CA 'get' and 'put'
The first example used a Init-Set-Close sequence to serve a PV. Its value is available to Epics clients that issue a CA 'get'.
The first example did not respond to CA 'put' requests. Clients like display managers might issue 'puts' to change the PV according to user input.
When the server receives a CA 'put', it does not change the PV! Instead, the new value is sent to the PV's owner via an ActiveX event. Then the owner can decide to ignore the value, modify it (e.g. to restrict it to a certain range) or use the value as it came and accordingly change the current value of the PV.
This diagram (taken from Tests/KnobExample.vi) implements support for both 'get' and 'put':
- PVSet.vi is used to serve the current value (a front panel knob) to 'get' clients.
- PVCheckInput is called to test for 'puts' from clients. If a client sent new data, the "Value" of the controller on the front panel is updated. In the next step, the value of that controller is then used to set the PV's value. Consequently, outside CA 'puts' change the PV's value.
More...
I hope this gets you started. The server comes with more examples.