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

An easy to use alternative to directly calling the Channel methods of pvAccess. More...

#include "pvaClient.h"

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

Public Member Functions

 POINTER_DEFINITIONS (PvaClientChannel)
 
 ~PvaClientChannel ()
 Destructor. More...
 
void setStateChangeRequester (PvaClientChannelStateChangeRequesterPtr const &stateChangeRequester)
 Set a client stateChangeRequester. More...
 
std::string getChannelName ()
 Get the name of the channel to which PvaClientChannel is connected. More...
 
epics::pvAccess::Channel::shared_pointer getChannel ()
 Get the the channel to which PvaClientChannel is connected. More...
 
void connect (double timeout=5.0)
 Connect to the channel. More...
 
void issueConnect ()
 Issue a connect request and return immediately. More...
 
epics::pvData::Status waitConnect (double timeout=5.0)
 Wait until the connection completes or for timeout. More...
 
PvaClientFieldPtr createField (std::string const &subField="")
 Create a PvaClientField for the specified subField. More...
 
PvaClientProcessPtr createProcess (std::string const &request="")
 First call createRequest as implemented by pvDataCPP and then call the next method. More...
 
PvaClientProcessPtr createProcess (epics::pvData::PVStructurePtr const &pvRequest)
 
PvaClientGetPtr get (std::string const &request="field(value,alarm,timeStamp)")
 create a PvaChannelGet More...
 
PvaClientGetPtr createGet (std::string const &request="field(value,alarm,timeStamp)")
 create a PvaClientGet. More...
 
PvaClientGetPtr createGet (epics::pvData::PVStructurePtr const &pvRequest)
 Creates an PvaClientGet. More...
 
double getDouble (std::string const &request="field(value)")
 Get the value as a double. More...
 
std::string getString (std::string const &request="field(value)")
 
epics::pvData::shared_vector< const double > getDoubleArray (std::string const &request="field(value)")
 Get the value as a double array. More...
 
epics::pvData::shared_vector< const std::string > getStringArray (std::string const &request="field(value)")
 Get the value as a string array. More...
 
PvaClientPutPtr put (std::string const &request="field(value)")
 create a PvaClientPut. More...
 
PvaClientPutPtr createPut (std::string const &request="field(value)")
 create a PvaClientPut. More...
 
PvaClientPutPtr createPut (epics::pvData::PVStructurePtr const &pvRequest)
 Create a PvaClientPut. More...
 
void putDouble (double value, std::string const &request="field(value)")
 Put the value as a double. More...
 
void putString (std::string const &value, std::string const &request="field(value)")
 Put the value as a string. More...
 
void putDoubleArray (epics::pvData::shared_vector< const double > const &value, std::string const &request="field(value)")
 Copy the array to the value field. More...
 
void putStringArray (epics::pvData::shared_vector< const std::string > const &value, std::string const &request="field(value)")
 Copy array to the value field. More...
 
void putStringArray (std::vector< std::string > const &value, std::string const &request="field(value)")
 Copy array to the value field. More...
 
PvaClientPutGetPtr createPutGet (std::string const &request="putField(argument)getField(result)")
 create a PvaClientPutGet. More...
 
PvaClientPutGetPtr createPutGet (epics::pvData::PVStructurePtr const &pvRequest)
 Create a PvaClientPutGet. More...
 
PvaClientArrayPtr createArray (std::string const &request="field(value)")
 Create a PvaClientArray. More...
 
PvaClientArrayPtr createArray (epics::pvData::PVStructurePtr const &pvRequest)
 Create a PvaClientArray. More...
 
PvaClientMonitorPtr monitor (std::string const &request="field(value,alarm,timeStamp)")
 Create a PvaClientMonitor. More...
 
PvaClientMonitorPtr monitor (PvaClientMonitorRequesterPtr const &pvaClientMonitorRequester)
 Call the next method with request = "field(value,alarm,timeStamp)". More...
 
PvaClientMonitorPtr monitor (std::string const &request, PvaClientMonitorRequesterPtr const &pvaClientMonitorRequester)
 Create and connect to a new PvaClientMonitor. More...
 
PvaClientMonitorPtr createMonitor (std::string const &request="field(value,alarm,timeStamp)")
 First call createRequest as implemented by pvDataJava and then call the next method. More...
 
PvaClientMonitorPtr createMonitor (epics::pvData::PVStructurePtr const &pvRequest)
 
epics::pvData::PVStructurePtr rpc (epics::pvData::PVStructurePtr const &pvRequest, epics::pvData::PVStructurePtr const &pvArgument)
 Issue a channelRPC request. More...
 
epics::pvData::PVStructurePtr rpc (epics::pvData::PVStructurePtr const &pvArgument)
 Issue a channelRPC request. More...
 
PvaClientRPCPtr createRPC ()
 Create a PvaClientRPC. More...
 
PvaClientRPCPtr createRPC (epics::pvData::PVStructurePtr const &pvRequest)
 Create a PvaClientRPC. More...
 
void showCache ()
 Show the list of cached gets and puts. More...
 
size_t cacheSize ()
 Get the number of cached gets and puts. More...
 
virtual std::string getRequesterName ()
 
virtual void message (std::string const &message, epics::pvData::MessageType messageType)
 
virtual void channelCreated (const epics::pvData::Status &status, epics::pvAccess::Channel::shared_pointer const &channel)
 
virtual void channelStateChange (epics::pvAccess::Channel::shared_pointer const &channel, epics::pvAccess::Channel::ConnectionState connectionState)
 
- Public Member Functions inherited from epics::pvAccess::ChannelRequester
 POINTER_DEFINITIONS (ChannelRequester)
 
 ChannelRequester ()
 
virtual ~ChannelRequester ()
 
virtual void channelCreated (const epics::pvData::Status &status, Channel::shared_pointer const &channel)=0
 
virtual void channelStateChange (Channel::shared_pointer const &channel, Channel::ConnectionState connectionState)=0
 
virtual std::tr1::shared_ptr< const PeerInfogetPeerInfo ()
 Return information on connected peer if applicable. More...
 
- Public Member Functions inherited from epics::pvAccess::Requester
 POINTER_DEFINITIONS (Requester)
 
virtual ~Requester ()
 
virtual void message (std::string const &message, MessageType messageType=errorMessage)
 

Friends

class PvaClient
 

Additional Inherited Members

- Public Types inherited from epics::pvAccess::ChannelRequester
typedef Channel operation_type
 
- Static Public Attributes inherited from epics::pvAccess::ChannelRequester
static size_t num_instances
 

Detailed Description

An easy to use alternative to directly calling the Channel methods of pvAccess.

Overview of PvaClientChannel

Definition at line 237 of file pvaClient.h.

Constructor & Destructor Documentation

epics::pvaClient::PvaClientChannel::~PvaClientChannel ( )

Destructor.

Definition at line 151 of file pvaClientChannel.cpp.

152 {
153  if(PvaClient::getDebug()) {
154  cout << "PvaClientChannel::~PvaClientChannel() "
155  << " channelName " << channelName
156  << endl;
157  }
159 }
void showCache()
Show the list of cached gets and puts.
static bool getDebug()
Is debug set?
Definition: pvaClient.cpp:97

Member Function Documentation

size_t epics::pvaClient::PvaClientChannel::cacheSize ( )

Get the number of cached gets and puts.

Definition at line 608 of file pvaClientChannel.cpp.

609 {
610  return pvaClientGetCache->cacheSize() + pvaClientPutCache->cacheSize();
611 }
void epics::pvaClient::PvaClientChannel::channelCreated ( const epics::pvData::Status status,
epics::pvAccess::Channel::shared_pointer const &  channel 
)
virtual

Definition at line 161 of file pvaClientChannel.cpp.

162 {
163  if(PvaClient::getDebug()) {
164  cout << "PvaClientChannel::channelCreated"
165  << " channelName " << channelName
166  << " connectState " << connectState
167  << " isConnected " << (channel->isConnected() ? "true" : "false")
168  << " status.isOK " << (status.isOK() ? "true" : "false")
169  << endl;
170  }
171  Lock xx(mutex);
172  this->channel = channel;
173  if(connectState==connected) return;
174  if(connectState!=connectActive) {
175  string message("PvaClientChannel::channelCreated");
176  message += " channel " + channelName
177  + " why was this called when connectState!=ConnectState.connectActive";
178  throw std::runtime_error(message);
179  }
180  if(!status.isOK()) {
181  string message("PvaClientChannel::channelCreated");
182  + " status " + status.getMessage() + " why??";
183  throw std::runtime_error(message);
184  }
185  if(channel->isConnected()) {
186  connectState = connected;
187  waitForConnect.signal();
188  }
189 }
A lock for multithreading.
Definition: lock.h:36
const std::string & getMessage() const
Definition: status.h:80
virtual void message(std::string const &message, epics::pvData::MessageType messageType)
bool isOK() const
Definition: status.h:95
static bool getDebug()
Is debug set?
Definition: pvaClient.cpp:97
void epics::pvaClient::PvaClientChannel::channelStateChange ( epics::pvAccess::Channel::shared_pointer const &  channel,
epics::pvAccess::Channel::ConnectionState  connectionState 
)
virtual

Definition at line 191 of file pvaClientChannel.cpp.

194 {
195  if(PvaClient::getDebug()) {
196  cout << " PvaClientChannel::channelStateChange "
197  << " channelName " << channelName
198  << " " << Channel::ConnectionStateNames[connectionState]
199  << endl;
200  }
201  bool waitingForConnect = false;
202  if(connectState==connectActive) waitingForConnect = true;
203  if(connectionState!=Channel::CONNECTED) {
204  Lock xx(mutex);
205  string mess(channelName +
206  " connection state " + Channel::ConnectionStateNames[connectionState]);
207  message(mess,errorMessage);
208  connectState = notConnected;
209  } else {
210  Lock xx(mutex);
211  this->channel = channel;
212  connectState = connected;
213  }
214  if(waitingForConnect) {
215  Lock xx(mutex);
216  waitForConnect.signal();
217  }
218  PvaClientChannelStateChangeRequesterPtr req(stateChangeRequester.lock());
219  if(req) {
220  bool value = (connectionState==Channel::CONNECTED ? true : false);
221  req->channelStateChange(shared_from_this(),value);
222  }
223 }
Definition: link.h:174
A lock for multithreading.
Definition: lock.h:36
virtual void message(std::string const &message, epics::pvData::MessageType messageType)
std::tr1::shared_ptr< PvaClientChannelStateChangeRequester > PvaClientChannelStateChangeRequesterPtr
Definition: pvaClient.h:56
static bool getDebug()
Is debug set?
Definition: pvaClient.cpp:97
void epics::pvaClient::PvaClientChannel::connect ( double  timeout = 5.0)

Connect to the channel.

This calls issueConnect and waitConnect.

Parameters
timeoutThe time to wait for connecting to the channel. The defaut is 5 seconds.
Exceptions
runtime_errorif connection fails.

Definition at line 260 of file pvaClientChannel.cpp.

261 {
262  if(PvaClient::getDebug()) {
263  cout << "PvaClientChannel::connect"
264  << " channelName " << channelName << endl;
265  }
266  issueConnect();
268  if(status.isOK()) return;
269  if(PvaClient::getDebug()) cout << "PvaClientChannel::connect waitConnect failed\n";
270  string message = string("channel ") + channelName
271  + " PvaClientChannel::connect " + status.getMessage();
272  throw std::runtime_error(message);
273 }
double timeout
Definition: pvutils.cpp:25
pvd::Status status
void issueConnect()
Issue a connect request and return immediately.
const std::string & getMessage() const
Definition: status.h:80
epics::pvData::Status waitConnect(double timeout=5.0)
Wait until the connection completes or for timeout.
virtual void message(std::string const &message, epics::pvData::MessageType messageType)
bool isOK() const
Definition: status.h:95
static bool getDebug()
Is debug set?
Definition: pvaClient.cpp:97
PvaClientArrayPtr epics::pvaClient::PvaClientChannel::createArray ( std::string const &  request = "field(value)")

Create a PvaClientArray.

First call createRequest as implemented by pvDataJava and then call the next method.

Parameters
requestThe syntax of request is defined by the copy facility of pvData.
Returns
The interface.
Exceptions
runtime_errorif failure.
PvaClientArrayPtr epics::pvaClient::PvaClientChannel::createArray ( epics::pvData::PVStructurePtr const &  pvRequest)

Create a PvaClientArray.

Parameters
pvRequestThe syntax of pvRequest is defined by the copy facility of pvData.
Returns
The interface.
Exceptions
runtime_errorif failure.

Definition at line 510 of file pvaClientChannel.cpp.

511 {
512  if(connectState!=connected) connect(5.0);
513  throw std::runtime_error("PvaClientChannel::createArray not implemented");
514 }
void connect(double timeout=5.0)
Connect to the channel.
PvaClientFieldPtr epics::pvaClient::PvaClientChannel::createField ( std::string const &  subField = "")

Create a PvaClientField for the specified subField.

Parameters
subFieldThe desired subField, i. e. "field.field...." An empty string, i. e. "", asks for the entire top level struture as defined by the server.
Returns
The interface.

Definition at line 323 of file pvaClientChannel.cpp.

324 {
325  if(connectState!=connected) connect(5.0);
326  throw std::runtime_error("PvaClientChannel::createField not implemented");
327 }
void connect(double timeout=5.0)
Connect to the channel.
PvaClientGetPtr epics::pvaClient::PvaClientChannel::createGet ( std::string const &  request = "field(value,alarm,timeStamp)")

create a PvaClientGet.

First call createRequest as implemented by pvData and then call the next method.

Parameters
requestThe syntax of request is defined by the copy facility of pvData.
Returns
The interface.
Exceptions
runtime_errorif failure.
PvaClientGetPtr epics::pvaClient::PvaClientChannel::createGet ( epics::pvData::PVStructurePtr const &  pvRequest)

Creates an PvaClientGet.

Parameters
pvRequestThe syntax of request is defined by the copy facility of pvData.
Returns
The interface.
The interface.
Exceptions
runtime_errorif failure.

Definition at line 375 of file pvaClientChannel.cpp.

376 {
377  if(connectState!=connected) connect(5.0);
378  PvaClientPtr yyy = pvaClient.lock();
379  if(!yyy) throw std::runtime_error("PvaClient was destroyed");
380  return PvaClientGet::create(yyy,shared_from_this(),pvRequest);
381 }
std::tr1::shared_ptr< PvaClient > PvaClientPtr
Definition: pvaClient.h:46
static PvaClientGetPtr create(PvaClientPtr const &pvaClient, PvaClientChannelPtr const &pvaClientChannel, epics::pvData::PVStructurePtr const &pvRequest)
Create a PvaClientGet.
void connect(double timeout=5.0)
Connect to the channel.
PvaClientMonitorPtr epics::pvaClient::PvaClientChannel::createMonitor ( std::string const &  request = "field(value,alarm,timeStamp)")

First call createRequest as implemented by pvDataJava and then call the next method.

Parameters
requestThe syntax of request is defined by the copy facility of pvData.
Returns
The interface.
Exceptions
runtime_errorif failure.
PvaClientMonitorPtr epics::pvaClient::PvaClientChannel::createMonitor ( epics::pvData::PVStructurePtr const &  pvRequest)

Create an PvaClientMonitor.

Parameters
pvRequestThe syntax of pvRequest is defined by the copy facility of pvData.
Returns
The interface.
Exceptions
runtime_errorif failure.

Definition at line 552 of file pvaClientChannel.cpp.

553 {
554  if(connectState!=connected) connect(5.0);
555  PvaClientPtr yyy = pvaClient.lock();
556  if(!yyy) throw std::runtime_error("PvaClient was destroyed");
557  return PvaClientMonitor::create(yyy,shared_from_this(),pvRequest);
558 }
std::tr1::shared_ptr< PvaClient > PvaClientPtr
Definition: pvaClient.h:46
static PvaClientMonitorPtr create(PvaClientPtr const &pvaClient, PvaClientChannelPtr const &pvaClientChannel, epics::pvData::PVStructurePtr const &pvRequest)
Create a PvaClientMonitor.
void connect(double timeout=5.0)
Connect to the channel.
PvaClientProcessPtr epics::pvaClient::PvaClientChannel::createProcess ( std::string const &  request = "")

First call createRequest as implemented by pvDataCPP and then call the next method.

Parameters
requestThe syntax of request is defined by the copy facility of pvData.
Returns
The interface.
Exceptions
runtime_errorif failure.
PvaClientProcessPtr epics::pvaClient::PvaClientChannel::createProcess ( epics::pvData::PVStructurePtr const &  pvRequest)

Creates a PvaClientProcess.

Parameters
pvRequestThe syntax of pvRequest is defined by the copy facility of pvData.
Returns
The interface.
Exceptions
runtime_errorif failure.

Definition at line 341 of file pvaClientChannel.cpp.

342 {
343  if(connectState!=connected) connect(5.0);
344  PvaClientPtr yyy = pvaClient.lock();
345  if(!yyy) throw std::runtime_error("PvaClient was destroyed");
346  return PvaClientProcess::create(yyy,shared_from_this(),pvRequest);
347 }
std::tr1::shared_ptr< PvaClient > PvaClientPtr
Definition: pvaClient.h:46
static PvaClientProcessPtr create(PvaClientPtr const &pvaClient, PvaClientChannelPtr const &pvaClientChannel, epics::pvData::PVStructurePtr const &pvRequest)
Create a PvaClientProcess.
void connect(double timeout=5.0)
Connect to the channel.
PvaClientPutPtr epics::pvaClient::PvaClientChannel::createPut ( std::string const &  request = "field(value)")

create a PvaClientPut.

First call createRequest as implemented by pvDataJava and then call the next method.

Parameters
requestThe syntax of request is defined by the copy facility of pvData.
Returns
The interface.
Exceptions
runtime_errorif failure.
PvaClientPutPtr epics::pvaClient::PvaClientChannel::createPut ( epics::pvData::PVStructurePtr const &  pvRequest)

Create a PvaClientPut.

Parameters
pvRequestThe syntax of pvRequest is defined by the copy facility of pvData.
Returns
The interface.

Definition at line 430 of file pvaClientChannel.cpp.

431 {
432  if(connectState!=connected) connect(5.0);
433  PvaClientPtr yyy = pvaClient.lock();
434  if(!yyy) throw std::runtime_error("PvaClient was destroyed");
435  return PvaClientPut::create(yyy,shared_from_this(),pvRequest);
436 }
std::tr1::shared_ptr< PvaClient > PvaClientPtr
Definition: pvaClient.h:46
static PvaClientPutPtr create(PvaClientPtr const &pvaClient, PvaClientChannelPtr const &pvaClientChannel, epics::pvData::PVStructurePtr const &pvRequest)
Create a PvaClientPut.
void connect(double timeout=5.0)
Connect to the channel.
PvaClientPutGetPtr epics::pvaClient::PvaClientChannel::createPutGet ( std::string const &  request = "putField(argument)getField(result)")

create a PvaClientPutGet.

First call createRequest as implemented by pvDataJava and then calls the next method.

Parameters
requestThe syntax of request is defined by the copy facility of pvData.
Returns
The interface.
Exceptions
runtime_errorif failure.
PvaClientPutGetPtr epics::pvaClient::PvaClientChannel::createPutGet ( epics::pvData::PVStructurePtr const &  pvRequest)

Create a PvaClientPutGet.

Parameters
pvRequestThe syntax of pvRequest is defined by the copy facility of pvData.
Returns
The interface.

Definition at line 488 of file pvaClientChannel.cpp.

489 {
490  if(connectState!=connected) connect(5.0);
491  PvaClientPtr yyy = pvaClient.lock();
492  if(!yyy) throw std::runtime_error("PvaClient was destroyed");
493  return PvaClientPutGet::create(yyy,shared_from_this(),pvRequest);
494 }
std::tr1::shared_ptr< PvaClient > PvaClientPtr
Definition: pvaClient.h:46
static PvaClientPutGetPtr create(PvaClientPtr const &pvaClient, PvaClientChannelPtr const &pvaClientChannel, epics::pvData::PVStructurePtr const &pvRequest)
Create a PvaClientPutGet.
void connect(double timeout=5.0)
Connect to the channel.
PvaClientRPCPtr epics::pvaClient::PvaClientChannel::createRPC ( )

Create a PvaClientRPC.

Returns
The interface.
Exceptions
runtime_errorif failure.

Definition at line 576 of file pvaClientChannel.cpp.

577 {
578  if(connectState!=connected) connect(5.0);
579  PvaClientPtr yyy = pvaClient.lock();
580  if(!yyy) throw std::runtime_error("PvaClient was destroyed");
581  return PvaClientRPC::create(yyy,channel);
582 }
std::tr1::shared_ptr< PvaClient > PvaClientPtr
Definition: pvaClient.h:46
static PvaClientRPCPtr create(PvaClientPtr const &pvaClient, epics::pvAccess::Channel::shared_pointer const &channel)
Create a PvaClientRPC.
void connect(double timeout=5.0)
Connect to the channel.
PvaClientRPCPtr epics::pvaClient::PvaClientChannel::createRPC ( epics::pvData::PVStructurePtr const &  pvRequest)

Create a PvaClientRPC.

Parameters
pvRequestThe pvRequest that must have the same interface as a pvArgument that is passed to an rpc request.
Returns
The interface.
Exceptions
runtime_errorif failure.

Definition at line 584 of file pvaClientChannel.cpp.

585 {
586  if(connectState!=connected) connect(5.0);
587  PvaClientPtr yyy = pvaClient.lock();
588  if(!yyy) throw std::runtime_error("PvaClient was destroyed");
589  return PvaClientRPC::create(yyy,channel,pvRequest);
590 }
std::tr1::shared_ptr< PvaClient > PvaClientPtr
Definition: pvaClient.h:46
static PvaClientRPCPtr create(PvaClientPtr const &pvaClient, epics::pvAccess::Channel::shared_pointer const &channel)
Create a PvaClientRPC.
void connect(double timeout=5.0)
Connect to the channel.
PvaClientGetPtr epics::pvaClient::PvaClientChannel::get ( std::string const &  request = "field(value,alarm,timeStamp)")

create a PvaChannelGet

Get a cached PvaClientGet or create and connect to a new PvaClientGet.

Returns
The interface.
Exceptions
runtime_errorif failure.

Definition at line 350 of file pvaClientChannel.cpp.

351 {
352  PvaClientGetPtr pvaClientGet = pvaClientGetCache->getGet(request);
353  if(!pvaClientGet) {
354  pvaClientGet = createGet(request);
355  pvaClientGet->connect();
356  pvaClientGetCache->addGet(request,pvaClientGet);
357  }
358  pvaClientGet->get();
359  return pvaClientGet;
360 }
std::string request
PvaClientGetPtr createGet(std::string const &request="field(value,alarm,timeStamp)")
create a PvaClientGet.
std::tr1::shared_ptr< PvaClientGet > PvaClientGetPtr
Definition: pvaClient.h:71
Channel::shared_pointer epics::pvaClient::PvaClientChannel::getChannel ( )

Get the the channel to which PvaClientChannel is connected.

Returns
The channel interface.

Definition at line 246 of file pvaClientChannel.cpp.

247 {
248  return channel;
249 }
string epics::pvaClient::PvaClientChannel::getChannelName ( )

Get the name of the channel to which PvaClientChannel is connected.

Returns
The channel name.

Definition at line 241 of file pvaClientChannel.cpp.

242 {
243  return channelName;
244 }
double epics::pvaClient::PvaClientChannel::getDouble ( std::string const &  request = "field(value)")

Get the value as a double.

Parameters
requestThe syntax of request is defined by the copy facility of pvData.
Returns
The value.
Exceptions
runtime_errorif failure.

Definition at line 383 of file pvaClientChannel.cpp.

384 {
385  return get(request)->getData()->getDouble();
386 }
std::string request
shared_vector< const double > epics::pvaClient::PvaClientChannel::getDoubleArray ( std::string const &  request = "field(value)")

Get the value as a double array.

Parameters
requestThe syntax of request is defined by the copy facility of pvData.
Returns
The value.
Exceptions
runtime_errorif failure.

Definition at line 393 of file pvaClientChannel.cpp.

394 {
395  return get(request)->getData()->getDoubleArray();
396 }
std::string request
string epics::pvaClient::PvaClientChannel::getRequesterName ( )
virtual

The requester must have a name.

Returns
The requester's name.

Implements epics::pvAccess::Requester.

Definition at line 225 of file pvaClientChannel.cpp.

226 {
227  PvaClientPtr yyy = pvaClient.lock();
228  if(!yyy) return string("PvaClientChannel::getRequesterName() PvaClient isDestroyed");
229  return yyy->getRequesterName();
230 }
std::tr1::shared_ptr< PvaClient > PvaClientPtr
Definition: pvaClient.h:46
string epics::pvaClient::PvaClientChannel::getString ( std::string const &  request = "field(value)")

Get the value as a string.

Parameters
requestThe syntax of request is defined by the copy facility of pvData.
Returns
The value.
Exceptions
runtime_errorif failure.

Definition at line 388 of file pvaClientChannel.cpp.

389 {
390  return get(request)->getData()->getString();
391 }
std::string request
shared_vector< const std::string > epics::pvaClient::PvaClientChannel::getStringArray ( std::string const &  request = "field(value)")

Get the value as a string array.

Parameters
requestThe syntax of request is defined by the copy facility of pvData.
Returns
The value.
Exceptions
runtime_errorif failure.

Definition at line 398 of file pvaClientChannel.cpp.

399 {
400  return get(request)->getData()->getStringArray();
401 }
std::string request
void epics::pvaClient::PvaClientChannel::issueConnect ( )

Issue a connect request and return immediately.

Definition at line 275 of file pvaClientChannel.cpp.

276 {
277  if(PvaClient::getDebug()) {
278  cout << "PvaClientChannel::issueConnect"
279  << " channelName " << channelName << endl;
280  }
281  {
282  Lock xx(mutex);
283  if(connectState==connected) return;
284  if(connectState!=connectIdle) {
285  throw std::runtime_error("pvaClientChannel already connected");
286  }
287  connectState = connectActive;
288  }
289  ChannelProviderRegistry::shared_pointer reg(ChannelProviderRegistry::clients());
290  channelProvider = reg->getProvider(providerName);
291  if(!channelProvider) {
292  throw std::runtime_error(channelName + " provider " + providerName + " not registered");
293  }
294  if(PvaClient::getDebug()) cout << "PvaClientChannel::issueConnect calling provider->createChannel\n";
295  channel = channelProvider->createChannel(channelName,shared_from_this(),ChannelProvider::PRIORITY_DEFAULT);
296  if(!channel) {
297  throw std::runtime_error(channelName + " channelCreate failed ");
298  }
299 }
A lock for multithreading.
Definition: lock.h:36
ChannelProviderRegistry::shared_pointer clients
static bool getDebug()
Is debug set?
Definition: pvaClient.cpp:97
void epics::pvaClient::PvaClientChannel::message ( std::string const &  message,
epics::pvData::MessageType  messageType 
)
virtual

Definition at line 232 of file pvaClientChannel.cpp.

235 {
236  PvaClientPtr yyy = pvaClient.lock();
237  if(!yyy) return;
238  yyy->message(channelName + " " + message, messageType);
239 }
std::tr1::shared_ptr< PvaClient > PvaClientPtr
Definition: pvaClient.h:46
virtual void message(std::string const &message, epics::pvData::MessageType messageType)
PvaClientMonitorPtr epics::pvaClient::PvaClientChannel::monitor ( std::string const &  request = "field(value,alarm,timeStamp)")

Create a PvaClientMonitor.

Create and connect to a new PvaClientMonitor. Then call it's start method. If connection can not be made an exception is thrown.

Parameters
requestThe syntax of request is defined by the copy facility of pvData.
Returns
The interface.
Exceptions
runtime_errorif failure.
PvaClientMonitorPtr epics::pvaClient::PvaClientChannel::monitor ( PvaClientMonitorRequesterPtr const &  pvaClientMonitorRequester)

Call the next method with request = "field(value,alarm,timeStamp)".

Parameters
pvaClientMonitorRequesterThe client callback.
Returns
The interface.
Exceptions
runtime_errorif failure.

Definition at line 525 of file pvaClientChannel.cpp.

526 {
527  return monitor("field(value,alarm,timeStamp)",pvaClientMonitorRequester);
528 }
PvaClientMonitorPtr monitor(std::string const &request="field(value,alarm,timeStamp)")
Create a PvaClientMonitor.
PvaClientMonitorPtr epics::pvaClient::PvaClientChannel::monitor ( std::string const &  request,
PvaClientMonitorRequesterPtr const &  pvaClientMonitorRequester 
)

Create and connect to a new PvaClientMonitor.

Then call it's start method. If connection can not be made an exception is thrown.

Parameters
requestThe syntax of request is defined by the copy facility of pvData.
pvaClientMonitorRequesterThe client callback.
Returns
The interface.
Exceptions
runtime_errorif failure.
epics::pvaClient::PvaClientChannel::POINTER_DEFINITIONS ( PvaClientChannel  )
PvaClientPutPtr epics::pvaClient::PvaClientChannel::put ( std::string const &  request = "field(value)")

create a PvaClientPut.

Get a cached PvaClientPut or create and connect to a new PvaClientPut. Then call it's get method.

Parameters
requestThe syntax of request is defined by the copy facility of pvData.
Returns
The interface.
Exceptions
runtime_errorif connection fails

Definition at line 404 of file pvaClientChannel.cpp.

405 {
406  PvaClientPutPtr pvaClientPut = pvaClientPutCache->getPut(request);
407  if(pvaClientPut) return pvaClientPut;
408  if(!pvaClientPut) {
409  pvaClientPut = createPut(request);
410  pvaClientPut->connect();
411  pvaClientPut->get();
412  pvaClientPutCache->addPut(request,pvaClientPut);
413  }
414  return pvaClientPut;
415 }
PvaClientPutPtr createPut(std::string const &request="field(value)")
create a PvaClientPut.
std::string request
std::tr1::shared_ptr< PvaClientPut > PvaClientPutPtr
Definition: pvaClient.h:76
void epics::pvaClient::PvaClientChannel::putDouble ( double  value,
std::string const &  request = "field(value)" 
)

Put the value as a double.

Parameters
valueThe new value.
requestThe syntax of request is defined by the copy facility of pvData.
Exceptions
runtime_errorif failure.

Definition at line 438 of file pvaClientChannel.cpp.

439 {
440  PvaClientPutPtr clientPut = put(request);
441  PvaClientPutDataPtr putData = clientPut->getData();
442  putData->putDouble(value); clientPut->put();
443 }
Definition: link.h:174
std::string request
std::tr1::shared_ptr< PvaClientPut > PvaClientPutPtr
Definition: pvaClient.h:76
PvaClientPutPtr put(std::string const &request="field(value)")
create a PvaClientPut.
std::tr1::shared_ptr< PvaClientPutData > PvaClientPutDataPtr
Definition: pvaClient.h:52
void epics::pvaClient::PvaClientChannel::putDoubleArray ( epics::pvData::shared_vector< const double > const &  value,
std::string const &  request = "field(value)" 
)

Copy the array to the value field.

Parameters
valueThe new value.
requestThe syntax of request is defined by the copy facility of pvData.
Exceptions
runtime_errorif failure.

Definition at line 452 of file pvaClientChannel.cpp.

455 {
456  PvaClientPutPtr clientPut = put(request);
457  PvaClientPutDataPtr putData = clientPut->getData();
458  size_t n = value.size();
459  shared_vector<double> valueArray(n);
460  for(size_t i=0; i<n; ++i) valueArray[i] = value[i];
461  putData->putDoubleArray(freeze(valueArray)); clientPut->put();
462 }
std::string request
int i
Definition: scan.c:967
std::tr1::shared_ptr< PvaClientPut > PvaClientPutPtr
Definition: pvaClient.h:76
size_t size() const
Number of elements visible through this vector.
Definition: sharedVector.h:220
PvaClientPutPtr put(std::string const &request="field(value)")
create a PvaClientPut.
std::tr1::shared_ptr< PvaClientPutData > PvaClientPutDataPtr
Definition: pvaClient.h:52
void epics::pvaClient::PvaClientChannel::putString ( std::string const &  value,
std::string const &  request = "field(value)" 
)

Put the value as a string.

Parameters
valueThe new value.
requestThe syntax of request is defined by the copy facility of pvData.
Exceptions
runtime_errorif failure.

Definition at line 445 of file pvaClientChannel.cpp.

446 {
447  PvaClientPutPtr clientPut = put(request);
448  PvaClientPutDataPtr putData = clientPut->getData();
449  putData->putString(value); clientPut->put();
450 }
Definition: link.h:174
std::string request
std::tr1::shared_ptr< PvaClientPut > PvaClientPutPtr
Definition: pvaClient.h:76
PvaClientPutPtr put(std::string const &request="field(value)")
create a PvaClientPut.
std::tr1::shared_ptr< PvaClientPutData > PvaClientPutDataPtr
Definition: pvaClient.h:52
void epics::pvaClient::PvaClientChannel::putStringArray ( epics::pvData::shared_vector< const std::string > const &  value,
std::string const &  request = "field(value)" 
)

Copy array to the value field.

Parameters
valueThe new value.
requestThe syntax of request is defined by the copy facility of pvData.
Exceptions
runtime_errorif failure.
void epics::pvaClient::PvaClientChannel::putStringArray ( std::vector< std::string > const &  value,
std::string const &  request = "field(value)" 
)

Copy array to the value field.

Parameters
valueThe data used to update the channel value.
requestThe request as a string to pass to createRequest.
Exceptions
runtime_errorif failure.
PVStructurePtr epics::pvaClient::PvaClientChannel::rpc ( epics::pvData::PVStructurePtr const &  pvRequest,
epics::pvData::PVStructurePtr const &  pvArgument 
)

Issue a channelRPC request.

Parameters
pvRequestThe pvRequest that is passed to createRPC.
pvArgumentThe argument for a request.
Returns
The result.
Exceptions
runtime_errorif failure.

Definition at line 560 of file pvaClientChannel.cpp.

563 {
564 
565  PvaClientRPCPtr rpc = createRPC(pvRequest);
566  return rpc->request(pvArgument);
567 }
PvaClientRPCPtr createRPC()
Create a PvaClientRPC.
epics::pvData::PVStructurePtr rpc(epics::pvData::PVStructurePtr const &pvRequest, epics::pvData::PVStructurePtr const &pvArgument)
Issue a channelRPC request.
std::tr1::shared_ptr< PvaClientRPC > PvaClientRPCPtr
Definition: pvaClient.h:90
PVStructurePtr epics::pvaClient::PvaClientChannel::rpc ( epics::pvData::PVStructurePtr const &  pvArgument)

Issue a channelRPC request.

Parameters
pvArgumentThe argument for the request.
Returns
The result.
Exceptions
runtime_errorif failure.

Definition at line 569 of file pvaClientChannel.cpp.

571 {
573  return rpc->request(pvArgument);
574 }
PvaClientRPCPtr createRPC()
Create a PvaClientRPC.
epics::pvData::PVStructurePtr rpc(epics::pvData::PVStructurePtr const &pvRequest, epics::pvData::PVStructurePtr const &pvArgument)
Issue a channelRPC request.
std::tr1::shared_ptr< PvaClientRPC > PvaClientRPCPtr
Definition: pvaClient.h:90
void epics::pvaClient::PvaClientChannel::setStateChangeRequester ( PvaClientChannelStateChangeRequesterPtr const &  stateChangeRequester)

Set a client stateChangeRequester.

Parameters
stateChangeRequesterThe client stateChangeRequester implementation.

Definition at line 251 of file pvaClientChannel.cpp.

253 {
254  this->stateChangeRequester = stateChangeRequester;
255  bool isConnected = false;
256  if(channel) isConnected = channel->isConnected();
257  stateChangeRequester->channelStateChange(shared_from_this(),isConnected);
258 }
void epics::pvaClient::PvaClientChannel::showCache ( )

Show the list of cached gets and puts.

Definition at line 592 of file pvaClientChannel.cpp.

593 {
594  if(pvaClientGetCache->cacheSize()>=1) {
595  cout << " pvaClientGet cache" << endl;
596  pvaClientGetCache->showCache();
597  } else {
598  cout << " pvaClientGet cache is empty\n";
599  }
600  if(pvaClientPutCache->cacheSize()>=1) {
601  cout << " pvaClientPut cache" << endl;
602  pvaClientPutCache->showCache();
603  } else {
604  cout << " pvaClientPut cache is empty\n";
605  }
606 }
Status epics::pvaClient::PvaClientChannel::waitConnect ( double  timeout = 5.0)

Wait until the connection completes or for timeout.

Parameters
timeoutThe time in seconds to wait. A value of 0 means forever.
Returns
status.

Definition at line 301 of file pvaClientChannel.cpp.

302 {
303  if(PvaClient::getDebug()) {
304  cout << "PvaClientChannel::waitConnect"
305  << " channelName " << channelName << endl;
306  }
307  {
308  Lock xx(mutex);
309  if(!channel) return Status(Status::STATUSTYPE_ERROR,"");
310  if(channel->isConnected()) return Status::Ok;
311  }
312  if(timeout>0.0) {
313  waitForConnect.wait(timeout);
314  } else {
315  waitForConnect.wait();
316  }
317  if(!channel) return Status(Status::STATUSTYPE_ERROR,"pvaClientChannel::waitConnect channel is null");
318  if(channel->isConnected()) return Status::Ok;
319  return Status(Status::STATUSTYPE_ERROR," not connected");
320 }
double timeout
Definition: pvutils.cpp:25
A lock for multithreading.
Definition: lock.h:36
static bool getDebug()
Is debug set?
Definition: pvaClient.cpp:97

Friends And Related Function Documentation

friend class PvaClient
friend

Definition at line 561 of file pvaClient.h.


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