EPICS exampleJava/exampleLink

Release 4.1 - 2016.03.14

Abstract

exampleLink implements a PVRecord that uses pvAccess to access another channel.

For more information about EPICS generally, please refer to the home page of the Experimental Physics and Industrial Control System.

Table of Contents


Overview

Start as a main program

mrk> pwd
/home/epicsv4/master/exampleJava/exampleLink/shell
mrk> ./exampleLink

exampleLinkClient

A pvaClient test is available to test exampleLink. Start the exampleLink and then:

mrk> pwd
/home/epicsv4/master/exampleJava/exampleLink/shell/shell
mrk> ./exampleLinkClient

Discussion

Access Alternatives

The process routine of a PVRecord can access other PVRecords in two ways:

Directly accessing local pvDatabase
If the other PVRecord is accessed via the master PVDatabase then threading issues are up to the implementation.
Access via channelProvider pva or ca
If provider pva or ca is used then locking is handled by pvAccess.
Access via channelProvider local
If provider local is used the implementation must be careful that it does not cause deadlocks. When the process method is called the pvRecord for the process method is locked. When it makes a pvAccess get, put, etc request the other record is locked. Thus if a set of pvAccess links are implemented the possibility of deadlocks exists. A simple example is two records that have links to each other. More complex sets are easily created. Unless the developer has complete control of the set of records then remote pvAccess should be used. But this results in more context switches.

Data synchronization

If pvAccess (provider pva or ca) is used then it handles data synchronization. This is done by making a copy of the data that is transferred between the two pvRecords. This is true if either remote or local pvAccess is used. Each get, put, etc request results in data being copied between the two records.

If the linked channel is a local pvRecord then, for scalar and structure arrays, raw data is NOT copied for gets. This is because pvData uses shared_vector to hold the raw data. Instead of copying the raw data the reference count is incremented.

For puts the linked array will force a new allocation of the raw data in the linked record, i. e. copy on write semantics are enforced. This is done automatically by pvData and not by pvDatabase.

Some details

As mentioned before a pvDatabase server can be either a separate process, i. e. a main program, or can be part of a V3IOC.

A main pvDatabase server issues the following calls:

...
    PVDatabase master = PVDatabaseFactory.getMaster();
    ChannelProvider channelProvider = ChannelProviderLocalFactory.getChannelServer();
    PvaClient pva= PvaClient.get("providerList");  // only needed if records access other records via pva or ca
    ServerContextImpl context = ServerContextImpl.startPVAServer(PVAConstants.PVA_ALL_PROVIDERS,0,true,null);
    
... 
    master.addRecord(...
...
    context.destroy();
...

Using exampleLinkMain to test providers local, pva, and ca

Options

The options supported by exampleLinkMain are shown by:

mrk> pwd
/home/epicsv4/master/exampleJava/exampleLink/shell
mrk> ./exampleLinkMain -help
provider exampleLinkRecordName . generateLinkedRecord
default
pva exampleLink doubleArray true
mrk> 

Thus to run it with default options:

./exampleLinkMain 

exampleLinkMain creates an instance of ExampleLinkRecord. The record name is exampleLinkRecordName. The ExampleLinkRecord monitors linkedRecordName using the specified provider.

Monitor exampleLink

After exampleLinkMain is started then in another window:

pvget -m -r "field()" exampleLink

This can be kept running while exampleLinkMain is stopped and then restarted with other options as long as exampleLinkRecordName is doubleArray.

exampleLinkClient

This makes changes to the record that exampleLink monitors. It has the options:

mrk> pwd
/home/epicsv4/master/exampleJava/exampleLink/shell
mrk> ./exampleLinkClient -help
provider
default
pva

NOTE: If exampleLinkMain is stated with provider ca then exampleLinkClient must also be run with provider ca

exampleLinkClient only works if linkedRecordName is doubleArray.

Testing via provider local

This can be tested via:

./exampleLinkMain local 

Testing via provider pva

This can be done via the default options:

./exampleLinkMain 

It can also be run with pva accessing a record in another IOC:

./exampleLinkMain pva exampleLink doubleArray  false

But this only starts running when the following is also started:

mrk> pwd
/home/epicsv4/master/exampleJava/exampleLink/shell
mrk> ./doubleArrayMain 

NOTE do not leave this running for other exampleLinkMain options.

Testing via provider ca

This can be tested as follows:

./exampleLinkMain ca exampleLink doubleArray  false

But a softIoc for record doubleArray must also be started:

mrk> pwd
/home/epicsv4/master/exampleJava/exampleLink/v3IOC
mrk> softIoc st.cmd