This is Unofficial EPICS BASE Doxygen Site
epics::pvAccess::ca::CAChannel Class Reference

#include "caChannel.h"

+ Inheritance diagram for epics::pvAccess::ca::CAChannel:
+ Collaboration diagram for epics::pvAccess::ca::CAChannel:

Public Member Functions

 POINTER_DEFINITIONS (CAChannel)
 
virtual ~CAChannel ()
 
chid getChannelID ()
 
virtual std::tr1::shared_ptr< ChannelProvidergetProvider ()
 
virtual std::string getRemoteAddress ()
 
virtual ConnectionState getConnectionState ()
 
virtual std::string getChannelName ()
 
virtual std::tr1::shared_ptr< ChannelRequestergetChannelRequester ()
 
virtual void getField (GetFieldRequester::shared_pointer const &requester, std::string const &subField)
 
virtual AccessRights getAccessRights (epics::pvData::PVField::shared_pointer const &pvField)
 
virtual ChannelGet::shared_pointer createChannelGet (ChannelGetRequester::shared_pointer const &channelGetRequester, epics::pvData::PVStructurePtr const &pvRequest)
 
virtual ChannelPut::shared_pointer createChannelPut (ChannelPutRequester::shared_pointer const &channelPutRequester, epics::pvData::PVStructurePtr const &pvRequest)
 
virtual Monitor::shared_pointer createMonitor (MonitorRequester::shared_pointer const &monitorRequester, epics::pvData::PVStructurePtr const &pvRequest)
 
virtual void printInfo (std::ostream &out)
 
void attachContext ()
 
void disconnectChannel ()
 
void connect (bool isConnected)
 
void notifyClient ()
 
- Public Member Functions inherited from epics::pvAccess::Channel
 POINTER_DEFINITIONS (Channel)
 
 Channel ()
 
virtual ~Channel ()
 
virtual std::string getRequesterName ()
 
virtual void message (std::string const &message, epics::pvData::MessageType messageType)
 
virtual bool isConnected ()
 
virtual ChannelProcess::shared_pointer createChannelProcess (ChannelProcessRequester::shared_pointer const &requester, epics::pvData::PVStructure::shared_pointer const &pvRequest)
 
virtual ChannelGet::shared_pointer createChannelGet (ChannelGetRequester::shared_pointer const &requester, epics::pvData::PVStructure::shared_pointer const &pvRequest)
 
virtual ChannelPut::shared_pointer createChannelPut (ChannelPutRequester::shared_pointer const &requester, epics::pvData::PVStructure::shared_pointer const &pvRequest)
 
virtual ChannelPutGet::shared_pointer createChannelPutGet (ChannelPutGetRequester::shared_pointer const &requester, epics::pvData::PVStructure::shared_pointer const &pvRequest)
 
virtual ChannelRPC::shared_pointer createChannelRPC (ChannelRPCRequester::shared_pointer const &requester, epics::pvData::PVStructure::shared_pointer const &pvRequest)
 
virtual Monitor::shared_pointer createMonitor (MonitorRequester::shared_pointer const &requester, epics::pvData::PVStructure::shared_pointer const &pvRequest)
 
virtual ChannelArray::shared_pointer createChannelArray (ChannelArrayRequester::shared_pointer const &requester, epics::pvData::PVStructure::shared_pointer const &pvRequest)
 
virtual void printInfo ()
 
- Public Member Functions inherited from epics::pvAccess::Requester
 POINTER_DEFINITIONS (Requester)
 
virtual ~Requester ()
 
virtual void message (std::string const &message, MessageType messageType=errorMessage)
 
- Public Member Functions inherited from epics::pvAccess::Destroyable
 POINTER_DEFINITIONS (Destroyable)
 

Static Public Member Functions

static CAChannelPtr create (CAChannelProvider::shared_pointer const &channelProvider, std::string const &channelName, short priority, ChannelRequester::shared_pointer const &channelRequester)
 

Additional Inherited Members

- Public Types inherited from epics::pvAccess::Channel
enum  ConnectionState { NEVER_CONNECTED, CONNECTED, DISCONNECTED, DESTROYED }
 
typedef ChannelRequester requester_type
 
- Static Public Attributes inherited from epics::pvAccess::Channel
static size_t num_instances
 
static const char * ConnectionStateNames [] = { "NEVER_CONNECTED", "CONNECTED", "DISCONNECTED", "DESTROYED" }
 
- Protected Member Functions inherited from epics::pvAccess::Destroyable
virtual ~Destroyable ()
 

Detailed Description

Definition at line 88 of file caChannel.h.

Constructor & Destructor Documentation

epics::pvAccess::ca::CAChannel::~CAChannel ( )
virtual

Definition at line 162 of file caChannel.cpp.

163 {
164  if(DEBUG_LEVEL>0) {
165  cout << "CAChannel::~CAChannel() " << channelName
166  << " channelCreated " << (channelCreated ? "true" : "false")
167  << endl;
168  }
169  {
170  Lock lock(requestsMutex);
171  if(!channelCreated) return;
172  }
174 }
#define DEBUG_LEVEL
Definition: caProviderPvt.h:25
epicsMutexId lock
Definition: osiClockTime.c:37
A lock for multithreading.
Definition: lock.h:36

Member Function Documentation

void epics::pvAccess::ca::CAChannel::attachContext ( )

Definition at line 424 of file caChannel.cpp.

425 {
426  CAChannelProviderPtr provider(channelProvider.lock());
427  if(provider) {
428  std::tr1::static_pointer_cast<CAChannelProvider>(provider)->attachContext();
429  return;
430  }
431  string mess("CAChannel::attachContext provider does not exist ");
432  mess += getChannelName();
433  throw std::runtime_error(mess);
434 }
shared_ptr< T > static_pointer_cast(shared_ptr< U > const &r) BOOST_NOEXCEPT
Definition: shared_ptr.hpp:788
std::tr1::shared_ptr< CAChannelProvider > CAChannelProviderPtr
Definition: caProviderPvt.h:43
virtual std::string getChannelName()
Definition: caChannel.cpp:240
void epics::pvAccess::ca::CAChannel::connect ( bool  isConnected)

Definition at line 61 of file caChannel.cpp.

62 {
63  if(DEBUG_LEVEL>0) {
64  cout<< "CAChannel::connect " << channelName << endl;
65  }
66  {
67  Lock lock(requestsMutex);
68  channelConnected = isConnected;
69  }
70  channelConnectThread->channelConnected(notifyChannelRequester);
71 }
#define DEBUG_LEVEL
Definition: caProviderPvt.h:25
epicsMutexId lock
Definition: osiClockTime.c:37
A lock for multithreading.
Definition: lock.h:36
virtual bool isConnected()
Definition: pvAccess.cpp:49
CAChannel::shared_pointer epics::pvAccess::ca::CAChannel::create ( CAChannelProvider::shared_pointer const &  channelProvider,
std::string const &  channelName,
short  priority,
ChannelRequester::shared_pointer const &  channelRequester 
)
static

Definition at line 36 of file caChannel.cpp.

40 {
41  if(DEBUG_LEVEL>0) {
42  cout<< "CAChannel::create " << channelName << endl;
43  }
44  CAChannelPtr caChannel(
45  new CAChannel(channelName, channelProvider, channelRequester));
46  caChannel->activate(priority);
47  return caChannel;
48 }
#define DEBUG_LEVEL
Definition: caProviderPvt.h:25
std::tr1::shared_ptr< CAChannel > CAChannelPtr
Definition: caChannel.h:31
ChannelGet::shared_pointer epics::pvAccess::ca::CAChannel::createChannelGet ( ChannelGetRequester::shared_pointer const &  channelGetRequester,
epics::pvData::PVStructurePtr const &  pvRequest 
)
virtual

Definition at line 281 of file caChannel.cpp.

284 {
285  if(DEBUG_LEVEL>0) {
286  cout << "CAChannel::createChannelGet " << channelName << endl;
287  }
288  CAChannelGetPtr channelGet =
289  CAChannelGet::create(shared_from_this(), channelGetRequester, pvRequest);
290  {
291  Lock lock(requestsMutex);
293  getQueue.push(channelGet);
294  return channelGet;
295  }
296  }
297  channelGet->activate();
298  return channelGet;
299 }
#define DEBUG_LEVEL
Definition: caProviderPvt.h:25
epicsMutexId lock
Definition: osiClockTime.c:37
virtual ConnectionState getConnectionState()
Definition: caChannel.cpp:234
static CAChannelGet::shared_pointer create(CAChannel::shared_pointer const &channel, ChannelGetRequester::shared_pointer const &channelGetRequester, epics::pvData::PVStructurePtr const &pvRequest)
Definition: caChannel.cpp:436
A lock for multithreading.
Definition: lock.h:36
std::tr1::shared_ptr< CAChannelGet > CAChannelGetPtr
Definition: caChannel.h:63
ChannelPut::shared_pointer epics::pvAccess::ca::CAChannel::createChannelPut ( ChannelPutRequester::shared_pointer const &  channelPutRequester,
epics::pvData::PVStructurePtr const &  pvRequest 
)
virtual

Definition at line 302 of file caChannel.cpp.

305 {
306  if(DEBUG_LEVEL>0) {
307  cout << "CAChannel::createChannelPut " << channelName << endl;
308  }
309  CAChannelPutPtr channelPut =
310  CAChannelPut::create(shared_from_this(), channelPutRequester, pvRequest);
311  {
312  Lock lock(requestsMutex);
314  putQueue.push(channelPut);
315  return channelPut;
316  }
317  }
318  channelPut->activate();
319  return channelPut;
320 }
#define DEBUG_LEVEL
Definition: caProviderPvt.h:25
epicsMutexId lock
Definition: osiClockTime.c:37
virtual ConnectionState getConnectionState()
Definition: caChannel.cpp:234
A lock for multithreading.
Definition: lock.h:36
static CAChannelPut::shared_pointer create(CAChannel::shared_pointer const &channel, ChannelPutRequester::shared_pointer const &channelPutRequester, epics::pvData::PVStructurePtr const &pvRequest)
Definition: caChannel.cpp:557
std::tr1::shared_ptr< CAChannelPut > CAChannelPutPtr
Definition: caChannel.h:60
Monitor::shared_pointer epics::pvAccess::ca::CAChannel::createMonitor ( MonitorRequester::shared_pointer const &  monitorRequester,
epics::pvData::PVStructurePtr const &  pvRequest 
)
virtual

Definition at line 323 of file caChannel.cpp.

326 {
327  if(DEBUG_LEVEL>0) {
328  cout << "CAChannel::createMonitor " << channelName << endl;
329  }
330  CAChannelMonitorPtr channelMonitor =
331  CAChannelMonitor::create(shared_from_this(), monitorRequester, pvRequest);
332  {
333  Lock lock(requestsMutex);
335  monitorQueue.push(channelMonitor);
336  return channelMonitor;
337  }
338  }
339  channelMonitor->activate();
340  addMonitor(channelMonitor);
341  return channelMonitor;
342 }
#define DEBUG_LEVEL
Definition: caProviderPvt.h:25
epicsMutexId lock
Definition: osiClockTime.c:37
virtual ConnectionState getConnectionState()
Definition: caChannel.cpp:234
A lock for multithreading.
Definition: lock.h:36
std::tr1::shared_ptr< CAChannelMonitor > CAChannelMonitorPtr
Definition: caChannel.h:66
static CAChannelMonitor::shared_pointer create(CAChannel::shared_pointer const &channel, MonitorRequester::shared_pointer const &monitorRequester, epics::pvData::PVStructurePtr const &pvRequest)
Definition: caChannel.cpp:815
void epics::pvAccess::ca::CAChannel::disconnectChannel ( )

Definition at line 176 of file caChannel.cpp.

177 {
178  if(DEBUG_LEVEL>0) {
179  cout << "CAChannel::disconnectChannel() "
180  << channelName
181  << " channelCreated " << (channelCreated ? "true" : "false")
182  << endl;
183  }
184  {
185  Lock lock(requestsMutex);
186  if(!channelCreated) return;
187  channelCreated = false;
188  }
189  std::vector<CAChannelMonitorWPtr>::iterator it;
190  for(it = monitorlist.begin(); it!=monitorlist.end(); ++it)
191  {
192  CAChannelMonitorPtr mon = (*it).lock();
193  if(!mon) continue;
194  mon->stop();
195  }
196  monitorlist.resize(0);
197  /* Clear CA Channel */
198  CAChannelProviderPtr provider(channelProvider.lock());
199  if(provider) {
200  std::tr1::static_pointer_cast<CAChannelProvider>(provider)->attachContext();
201  }
202  int result = ca_clear_channel(channelID);
203  if (result == ECA_NORMAL) return;
204  string mess("CAChannel::disconnectChannel() ");
205  mess += ca_message(result);
206  cerr << mess << endl;
207 }
#define DEBUG_LEVEL
Definition: caProviderPvt.h:25
pvac::PutEvent result
Definition: clientSync.cpp:117
epicsMutexId lock
Definition: osiClockTime.c:37
shared_ptr< T > static_pointer_cast(shared_ptr< U > const &r) BOOST_NOEXCEPT
Definition: shared_ptr.hpp:788
A lock for multithreading.
Definition: lock.h:36
#define ECA_NORMAL
Definition: caerr.h:77
std::tr1::shared_ptr< CAChannelProvider > CAChannelProviderPtr
Definition: caProviderPvt.h:43
std::tr1::shared_ptr< CAChannelMonitor > CAChannelMonitorPtr
Definition: caChannel.h:66
int epicsStdCall ca_clear_channel(chid pChan)
Definition: access.cpp:363
const char *epicsStdCall ca_message(long ca_status)
Definition: access.cpp:561
AccessRights epics::pvAccess::ca::CAChannel::getAccessRights ( epics::pvData::PVField::shared_pointer const &  pvField)
virtual

Not useful...

Parameters
pvFieldThe field for which access rights is desired.
Returns
The access rights.

Reimplemented from epics::pvAccess::Channel.

Definition at line 270 of file caChannel.cpp.

271 {
272  if (ca_write_access(channelID))
273  return readWrite;
274  else if (ca_read_access(channelID))
275  return read;
276  else
277  return none;
278 }
LIBCA_API unsigned epicsStdCall ca_write_access(chid chan)
LIBCA_API unsigned epicsStdCall ca_read_access(chid chan)
chid epics::pvAccess::ca::CAChannel::getChannelID ( )

Definition at line 209 of file caChannel.cpp.

210 {
211  return channelID;
212 }
std::string epics::pvAccess::ca::CAChannel::getChannelName ( )
virtual

The name passed to ChannelProvider::createChannel()

Implements epics::pvAccess::Channel.

Definition at line 240 of file caChannel.cpp.

241 {
242  return channelName;
243 }
std::tr1::shared_ptr< ChannelRequester > epics::pvAccess::ca::CAChannel::getChannelRequester ( )
virtual

The ChannelRequester passed to ChannelProvider::createChannel()

Exceptions
std::tr1::bad_weak_ptr

Implements epics::pvAccess::Channel.

Definition at line 246 of file caChannel.cpp.

247 {
248  return channelRequester.lock();
249 }
Channel::ConnectionState epics::pvAccess::ca::CAChannel::getConnectionState ( )
virtual

Poll the connection state in more detail

Reimplemented from epics::pvAccess::Channel.

Definition at line 234 of file caChannel.cpp.

235 {
236  return cs2CS[ca_state(channelID)];
237 }
LIBCA_API enum channel_state epicsStdCall ca_state(chid chan)
void epics::pvAccess::ca::CAChannel::getField ( GetFieldRequester::shared_pointer const &  requester,
std::string const &  subField 
)
virtual

Initiate a request to retrieve a description of the structure of this Channel.

While the type described by calls to getField() should match what is provided for all operations except RPC.

GetFieldRequester::getDone() will be called before getField() returns, or at some time afterwards.

Parameters
RequesterThe Requester.
subFieldEmpty string, or the field name of a sub-structure.

Reimplemented from epics::pvAccess::Channel.

Definition at line 251 of file caChannel.cpp.

253 {
254  if(DEBUG_LEVEL>0) {
255  cout << "CAChannel::getField " << channelName << endl;
256  }
258  new CAChannelGetField(shared_from_this(),requester,subField));
259  {
260  Lock lock(requestsMutex);
262  getFieldQueue.push(getField);
263  return;
264  }
265  }
266  getField->callRequester(shared_from_this());
267 }
#define DEBUG_LEVEL
Definition: caProviderPvt.h:25
epicsMutexId lock
Definition: osiClockTime.c:37
virtual ConnectionState getConnectionState()
Definition: caChannel.cpp:234
A lock for multithreading.
Definition: lock.h:36
virtual void getField(GetFieldRequester::shared_pointer const &requester, std::string const &subField)
Definition: caChannel.cpp:251
std::tr1::shared_ptr< CAChannelGetField > CAChannelGetFieldPtr
Definition: caChannel.h:57
const ChannelProcessRequester::weak_pointer requester
Definition: pvAccess.cpp:68
std::tr1::shared_ptr< ChannelProvider > epics::pvAccess::ca::CAChannel::getProvider ( )
virtual

The ChannelProvider from which this Channel was requested. May never be NULL.

Implements epics::pvAccess::Channel.

Definition at line 214 of file caChannel.cpp.

215 {
216  return channelProvider.lock();
217 }
std::string epics::pvAccess::ca::CAChannel::getRemoteAddress ( )
virtual

Returns the channel's remote address, signal name, etc... For example:

  • client side channel would return server's address, e.g. "/192.168.1.101:5064"
  • server side channel would return underlying bus address, e.g. "#C0 S1".

The value returned here will changed depending on the connection status. A disconnected channel should return an empty() string.

Implements epics::pvAccess::Channel.

Definition at line 220 of file caChannel.cpp.

221 {
222  return std::string(ca_host_name(channelID));
223 }
LIBCA_API const char *epicsStdCall ca_host_name(chid channel)
void epics::pvAccess::ca::CAChannel::notifyClient ( )

Definition at line 73 of file caChannel.cpp.

74 {
75  if(DEBUG_LEVEL>0) {
76  cout<< "CAChannel::notifyClient " << channelName << endl;
77  }
78  CAChannelProviderPtr provider(channelProvider.lock());
79  if(!provider) return;
80  bool isConnected = false;
81  {
82  Lock lock(requestsMutex);
83  isConnected = channelConnected;
84  }
85  if(!isConnected) {
86  ChannelRequester::shared_pointer req(channelRequester.lock());
87  if(req) {
88  EXCEPTION_GUARD(req->channelStateChange(
89  shared_from_this(), Channel::DISCONNECTED));
90  }
91  return;
92  }
93  while(!getFieldQueue.empty()) {
94  getFieldQueue.front()->activate();
95  getFieldQueue.pop();
96  }
97  while(!putQueue.empty()) {
98  putQueue.front()->activate();
99  putQueue.pop();
100  }
101  while(!getQueue.empty()) {
102  getQueue.front()->activate();
103  getQueue.pop();
104  }
105  while(!monitorQueue.empty()) {
106  CAChannelMonitorPtr monitor(monitorQueue.front());
107  monitor->activate();
108  addMonitor(monitor);
109  monitorQueue.pop();
110  }
111  ChannelRequester::shared_pointer req(channelRequester.lock());
112  if(req) {
113  EXCEPTION_GUARD(req->channelStateChange(
114  shared_from_this(), Channel::CONNECTED));
115  }
116 }
#define DEBUG_LEVEL
Definition: caProviderPvt.h:25
epicsMutexId lock
Definition: osiClockTime.c:37
A lock for multithreading.
Definition: lock.h:36
std::tr1::shared_ptr< CAChannelProvider > CAChannelProviderPtr
Definition: caProviderPvt.h:43
std::tr1::shared_ptr< CAChannelMonitor > CAChannelMonitorPtr
Definition: caChannel.h:66
#define EXCEPTION_GUARD(code)
Definition: caChannel.cpp:31
virtual bool isConnected()
Definition: pvAccess.cpp:49
epics::pvAccess::ca::CAChannel::POINTER_DEFINITIONS ( CAChannel  )
void epics::pvAccess::ca::CAChannel::printInfo ( std::ostream &  out)
virtual

Prints detailed information about the context to the specified output stream.

Parameters
outthe output stream.

Reimplemented from epics::pvAccess::Channel.

Definition at line 357 of file caChannel.cpp.

358 {
359  out << "CHANNEL : " << getChannelName() << std::endl;
360 
362  out << "STATE : " << ConnectionStateNames[state] << std::endl;
363  if (state == CONNECTED)
364  {
365  out << "ADDRESS : " << getRemoteAddress() << std::endl;
366  //out << "RIGHTS : " << getAccessRights() << std::endl;
367  }
368 }
virtual ConnectionState getConnectionState()
Definition: caChannel.cpp:234
virtual std::string getRemoteAddress()
Definition: caChannel.cpp:220
static const char * ConnectionStateNames[]
Definition: pvAccess.h:910
virtual std::string getChannelName()
Definition: caChannel.cpp:240

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