This is Unofficial EPICS BASE Doxygen Site
epics::pvaClient::PvaClientRPC Class Reference

An easy to use alternative to RPC. More...

#include "pvaClient.h"

+ Inheritance diagram for epics::pvaClient::PvaClientRPC:
+ Collaboration diagram for epics::pvaClient::PvaClientRPC:

Public Member Functions

 POINTER_DEFINITIONS (PvaClientRPC)
 
 ~PvaClientRPC ()
 Destructor. More...
 
void setResponseTimeout (double responseTimeout)
 Set a timeout for a request. More...
 
double getResponseTimeout ()
 Get the responseTimeout. More...
 
void connect ()
 Call issueConnect and then waitConnect. More...
 
void issueConnect ()
 Issue the channelRPC connection to the channel. More...
 
epics::pvData::Status waitConnect ()
 Wait until the channelRPC connection to the channel is complete. More...
 
epics::pvData::PVStructure::shared_pointer request (epics::pvData::PVStructure::shared_pointer const &pvArgument)
 Issue a request and wait for response. More...
 
void request (epics::pvData::PVStructure::shared_pointer const &pvArgument, PvaClientRPCRequesterPtr const &pvaClientRPCRequester)
 issue a request and return immediately. More...
 

Static Public Member Functions

static PvaClientRPCPtr create (PvaClientPtr const &pvaClient, epics::pvAccess::Channel::shared_pointer const &channel)
 Create a PvaClientRPC. More...
 
static PvaClientRPCPtr create (PvaClientPtr const &pvaClient, epics::pvAccess::Channel::shared_pointer const &channel, epics::pvData::PVStructurePtr const &pvRequest)
 Create a PvaClientRPC. More...
 

Friends

class RPCRequesterImpl
 

Detailed Description

An easy to use alternative to RPC.

Overview of PvaClientRPC

Definition at line 1736 of file pvaClient.h.

Constructor & Destructor Documentation

epics::pvaClient::PvaClientRPC::~PvaClientRPC ( )

Destructor.

Definition at line 112 of file pvaClientRPC.cpp.

113 {
114  if(PvaClient::getDebug()) {
115  string channelName("disconnected");
116  Channel::shared_pointer chan(channel.lock());
117  if(chan) channelName = chan->getChannelName();
118  cout<< "PvaClientRPC::~PvaClientRPC"
119  << " channelName " << channelName
120  << endl;
121  }
122 }
static bool getDebug()
Is debug set?
Definition: pvaClient.cpp:97

Member Function Documentation

void epics::pvaClient::PvaClientRPC::connect ( )

Call issueConnect and then waitConnect.

An exception is thrown if connect fails.

Definition at line 216 of file pvaClientRPC.cpp.

217 {
218  if(PvaClient::getDebug()) cout << "PvaClientRPC::connect\n";
219  issueConnect();
221  if(status.isOK()) return;
222  Channel::shared_pointer chan(channel.lock());
223  string channelName("disconnected");
224  if(chan) channelName = chan->getChannelName();
225  string message = string("channel ")
226  + channelName
227  + " PvaClientRPC::connect "
228  + status.getMessage();
229  throw RPCRequestException(Status::STATUSTYPE_ERROR,message);
230 }
epics::pvData::Status waitConnect()
Wait until the channelRPC connection to the channel is complete.
pvd::Status status
const std::string & getMessage() const
Definition: status.h:80
void issueConnect()
Issue the channelRPC connection to the channel.
bool isOK() const
Definition: status.h:95
static bool getDebug()
Is debug set?
Definition: pvaClient.cpp:97
static PvaClientRPCPtr epics::pvaClient::PvaClientRPC::create ( PvaClientPtr const &  pvaClient,
epics::pvAccess::Channel::shared_pointer const &  channel 
)
static

Create a PvaClientRPC.

Parameters
&pvaClientInterface to PvaClient
channelInterface to Channel
Returns
The interface to the PvaClientRPC.
static PvaClientRPCPtr epics::pvaClient::PvaClientRPC::create ( PvaClientPtr const &  pvaClient,
epics::pvAccess::Channel::shared_pointer const &  channel,
epics::pvData::PVStructurePtr const &  pvRequest 
)
static

Create a PvaClientRPC.

Parameters
&pvaClientInterface to PvaClient
channelInterface to Channel
pvRequestThe request structure.
Returns
The interface to the PvaClientRPC.
double epics::pvaClient::PvaClientRPC::getResponseTimeout ( )
inline

Get the responseTimeout.

Returns
The value.

Definition at line 1775 of file pvaClient.h.

1776  {
1777  return responseTimeout;
1778  }
void epics::pvaClient::PvaClientRPC::issueConnect ( )

Issue the channelRPC connection to the channel.

This can only be called once. An exception is thrown if connect fails.

Exceptions
runtime_errorif failure.

Definition at line 232 of file pvaClientRPC.cpp.

233 {
234  if(PvaClient::getDebug()) cout << "PvaClientRPC::issueConnect\n";
235  Channel::shared_pointer chan(channel.lock());
236  if(connectState!=connectIdle) {
237  string channelName("disconnected");
238  if(chan) channelName = chan->getChannelName();
239  string message = string("channel ")
240  + channelName
241  + " pvaClientRPC already connected ";
242  throw std::runtime_error(message);
243  }
244  if(chan) {
245  connectState = connectActive;
246  channelRPC = chan->createChannelRPC(rpcRequester,pvRequest);
247  return;
248  }
249  throw std::runtime_error("PvaClientRPC::issueConnect() but channel disconnected");
250 }
static bool getDebug()
Is debug set?
Definition: pvaClient.cpp:97
epics::pvaClient::PvaClientRPC::POINTER_DEFINITIONS ( PvaClientRPC  )
epics::pvData::PVStructure::shared_pointer epics::pvaClient::PvaClientRPC::request ( epics::pvData::PVStructure::shared_pointer const &  pvArgument)

Issue a request and wait for response.

Note that if responseTimeout is ( lt 0.0, ge 0.0) then this (will, will not) block until response completes or timeout.

Parameters
pvArgumentThe data to send to the service.
Returns
The result
Exceptions
runtime_errorif failure.
void epics::pvaClient::PvaClientRPC::request ( epics::pvData::PVStructure::shared_pointer const &  pvArgument,
PvaClientRPCRequesterPtr const &  pvaClientRPCRequester 
)

issue a request and return immediately.

Parameters
pvArgumentThe data to send to the service.
pvaClientRPCRequesterThe requester that is called with the result.
Exceptions
runtime_errorif failure.
void epics::pvaClient::PvaClientRPC::setResponseTimeout ( double  responseTimeout)
inline

Set a timeout for a request.

Parameters
responseTimeoutThe time in seconds to wait for a request to complete.

Definition at line 1767 of file pvaClient.h.

1768  {
1769  this->responseTimeout = responseTimeout;
1770  }
Status epics::pvaClient::PvaClientRPC::waitConnect ( )

Wait until the channelRPC connection to the channel is complete.

Returns
status;

Definition at line 252 of file pvaClientRPC.cpp.

253 {
254  if(PvaClient::getDebug()) cout << "PvaClientRPC::waitConnect\n";
255  if(connectState==connected) {
256  if(!connectStatus.isOK()) connectState = connectIdle;
257  return connectStatus;
258  }
259  if(connectState!=connectActive) {
260  Channel::shared_pointer chan(channel.lock());
261  string channelName("disconnected");
262  if(chan) channelName = chan->getChannelName();
263  string message = string("channel ")
264  + channelName
265  + " PvaClientRPC::waitConnect illegal connect state ";
266  throw std::runtime_error(message);
267  }
268  if(PvaClient::getDebug()) {
269  cout << "PvaClientRPC::waitConnect calling waitForConnect.wait\n";
270  }
271  waitForConnect.wait();
272  connectState = connectStatus.isOK() ? connected : connectIdle;
273  if(PvaClient::getDebug()) {
274  cout << "PvaClientRPC::waitConnect"
275  << " connectStatus " << (connectStatus.isOK() ? "connected" : "not connected");
276  }
277  return connectStatus;
278 }
bool isOK() const
Definition: status.h:95
static bool getDebug()
Is debug set?
Definition: pvaClient.cpp:97

Friends And Related Function Documentation

friend class RPCRequesterImpl
friend

Definition at line 1851 of file pvaClient.h.


The documentation for this class was generated from the following files: