Pva C++ Overview

Table of Contents


Introduction

Pva is a synchronous API for accessing PVData via PVAccess. It also provides a number of convenience methods. It allows the client to request access without checking for failure, but throws an exception if a request fails. A client can also check for failues and thus prevent exceptions.

The Pva API has the following features:

  1. Provides a synchronous API rather than the callback API provided by pvAccess.
  2. Makes common requests pva.
  3. Provides full access to the pvAccess API for more demanding applications
  4. Allows efficient client side programs.
  5. Takes care of most object resource management problems.

Simple examples of using pva:

// pvaGet
PvaPtr pva = Pva::create();
double value = pva->channel("exampleDouble")->get()->getData()->getDouble();

// pvaPut
PvaChannelPtr channel = pva->channel("exampleDouble");
PvaPutPtr put = channel->put();
PvaPutDataPtr putData = put->getData();
putData->putDouble(3.0); put->put();

// pvaMonitor
PvaMonitorPtr monitor = pva->channel("examplePowerSupply")->monitor("");
PvaMonitorDataPtr pvaData = monitor->getData();
while(true) {
    monitor->waitEvent();
    cout << "changed\n";
    pvaData->showChanged(cout);
    cout << "overrun\n";
    pvaData->showOverrun(cout);
    monitor->releaseEvent();
}

// pvaProcess
PvaChannelPtr channel = pva->channel("exampleDouble");
PvaProcessPtr process = channel->createProcess();
process->process();

pvaExample includes a number of examples.

pva does not provide support for:

ChannelArray
TBD
ChannelRPC
pvAccess itself already provides a synchronous interface. The examples include helloWorldRPC, which is an example of using channelRP.

Pva

An instance of Pva is obtained via the call:

PvaPtr pva = Pva::create();

Pva has methods to create instances of PvaChannel. The client can specify the provider name or use the default provider. The client can manage it's own channels or can let pva cache channels. An example of using the cached method is:

PvaChannelPtr pvaChannel = pva->channel("exampleDouble");

This will attempt to connect to channel exampleDouble. Since the client did not specify a timeout an exception wll be thrown if the connection request fails. The client will block until the connection is made or an exception is thrown. If the request succeeds, pva caches the pvaChannel so that if the client makes another request for the same channel the cached object is returned to the client.

An example of using a non cached method is:

PvaChannelPtr pvaChannel = pva->createChannel("exampleDouble");

This will create an PvaChannel and return it to the client. The client must itself connect. This is useful if the client wants to connect to multiple channels in parallel.

PvaChannel - Wrapper For Single Channel

PvaChannel

This provides methods for connecting to a channel and for creating instances of PvaField, PvaProcess, ..., PvaPutGet.

Connection must be made before any create method is called or an exception is raised. The following is a synchronous connection request:

pvaChannel->connect(5.0); // BLOCKS AND THROWS IF NO CONNECT

This blocks until then connection is made or until timout occurs. An exception is raised if the connection request fails.

The same request can be made without blocking and without exceptions.

pvaChannel->issueConnect(); // DOES NOT BLOCK
.....
Status status =pvaChannel->waitConnect(5.0);  // BLOCKS DOES NOT THROW
if(!status.isOK()) {
   // failure do something
}

Once the channel is connected other Pva objects can be created. For example:

PvaGetPtr pvaGet = pvaChannel->get(); // DOES BLOCK

This is a caching request. If the client already has made an identical request the client will receive the cached object. If a new pvaGet is created than it is connected before it is returned to the client.

The client can also managed it's own objects:

PvaGetPtr pvaGet = pvaChannel->createGet(); // DOES NOT BLOCK

The client must connect the pvaGet.

PvaGetData

This provides the data returned by pvaGet and pvaPutGet. It is obtained via:

PvaGetDataPtr pvaData = pvaGet->getData();

It provides methods to get everything returned by channelGet. In addition there are methods that make it easier to handle a value field that is a scalar or a scalarArray. Also for a scalar that is a double or a scalarArray with element type double.

An example is:

double value = pvaData->getDouble();

It also keeps a bitSet showing which fields have changed since the last channelGet or channelPutGet.

PvaMonitorData

To the client this looks identical to PvaGetData except that it provides two BitSets: changedBitSet and overrrunBitSet. It is used by pvaMonitor.

PvaPutData

This is used to provided data for pvaPut and pvaPutGet. It has many of the same methods as pvaGetData. It does not have a bitSet. It also has put methods like:

void pvaData->putDouble(5.0);

PvaGet

This provides methods to connect to channelGet and to issue get request. To connect via a single synchronous call:

eastGet->connect();  // BLOCKS AND CAN THROW

This can also be done in two steps:

pvaGet->issueConnect(); // DOES NOT BLOCK
...
Status status = pvaGet->waitConnect(); // BLOCKS AND DOES NOT HROW

Once connected gets are issued via either:

void pvaGet->get(); // BLOCKS AND CAN THROW
or
pvaGet->issueGet(); // DOES NOT BLOCK
...
Status status = pvaGet->waitGet(); // BLOCKS AND DOES NOT THROW

PvaPut

This is similar to pvaGet except that it wraps channelPut instead of channelGet.

Once connected puts are issued via either:

void pvaPut->put(); // BLOCKS AND CAN THROW
or
pvaPut->issuePut(); // DOES NOT BLOCK
...
Status status = pvaPut->waitPut(); // BLOCKS AND DOES NOT THROW

PvaMonitor

Connecting is similar to pvaGet and pvaPut. The other methods are:

start
Starts monitoring
stop
Stops monitoring
poll
polls for a monitorEvent. The data is avalable via pvaMonitorData.
releaseEvent
Release the data from the last poll. Note that this must be called before another poll is requested.
waitEvent
Block until a monitorEvent is available. If true is returned a poll has already been issued.
setRequester
A client callback is registered to receive notice of monitorEvents.

PvaProcess

Connecting is similar to pvaGet. It has methods:

process
call issueProcess and waitProcess.
issueProcess
call channelProcess->process() and return immediately.
waitProcess
Wait for process to complete.

PvaPutGet

Connecting is similar to pvaGet. It has methods:

putGet
calls issuePutGet and waitPutGet. throws an exception if not successfull.
issuePutGet
Calls channel->putGet() and returns.
waitPutGet
Waits until putGet completes and returns status.
getGet,issueGetGet, and waitGetGet
Gets the data for the get part of channelPutGet.
getPut,issueGetPut,and waitGetPut
Gets the data for the put part of channelPutGet.
getPutData
Returns the PvaData for the put part of channelPutGet.
getGetData
Returns the PvaData for the get part of channelPutGet.

Look at javaDoc for details.

PvaMultiChannel - Wrapper For Multiple Channels

PvaMultiChannel

This provides methods for connecting to multiple channels. A client can either use PvaMultiChannel directly or use PvaMultiDouble or PvaNTMultiChannel. But both impose restrictions on what can be accessed.

PvaMultiDouble

This provides support for gets and puts to the value field of multiple channels. Each channel must have a value field that is a numeric scalar. The client always sees the data as a PVDoubleArray. All channels must connect. If any problems occur an exception is thrown.

PvaNTMultiChannel

This provides support for gets and puts to the value field of multiple channels. Each channel must have a value field. The client always sees the data as a NTMultiChannel, which is one of the types provided by normativeTypesCPP. All channels must connect. If any problems occur an exception is thrown.