This is Unofficial EPICS BASE Doxygen Site
pvalink::pvaLinkChannel Struct Reference

#include "pvalink.h"

+ Inheritance diagram for pvalink::pvaLinkChannel:
+ Collaboration diagram for pvalink::pvaLinkChannel:

Classes

struct  LinkSort
 

Public Types

typedef std::set< pvaLink *, LinkSortlinks_t
 

Public Member Functions

 pvaLinkChannel (const pvaGlobal_t::channels_key_t &key, const epics::pvData::PVStructure::const_shared_pointer &pvRequest)
 
virtual ~pvaLinkChannel ()
 
void open ()
 
void put (bool force=false)
 
virtual void monitorEvent (const pvac::MonitorEvent &evt) OVERRIDE FINAL
 
virtual void putBuild (const epics::pvData::StructureConstPtr &build, pvac::ClientChannel::PutCallback::Args &args) OVERRIDE FINAL
 
virtual void putDone (const pvac::PutEvent &evt) OVERRIDE FINAL
 Put operation is complete. More...
 
- Public Member Functions inherited from pvac::ClientChannel::MonitorCallback
virtual ~MonitorCallback ()
 
- Public Member Functions inherited from pvac::ClientChannel::PutCallback
virtual ~PutCallback ()
 

Public Attributes

const pvaGlobal_t::channels_key_t key
 
const pvd::PVStructure::const_shared_pointer pvRequest
 
pvd::Mutex lock
 
epicsEvent run_done
 
pvac::ClientChannel chan
 
pvac::Monitor op_mon
 
pvac::Operation op_put
 
std::string providerName
 
size_t num_disconnect
 
size_t num_type_change
 
bool connected
 
bool connected_latched
 
bool isatomic
 
bool queued
 
bool debug
 
std::tr1::shared_ptr< const void > previous_root
 
links_t links
 
bool links_changed
 

Static Public Attributes

static size_t num_instances
 

Detailed Description

Definition at line 132 of file pvalink.h.

Member Typedef Documentation

Definition at line 162 of file pvalink.h.

Constructor & Destructor Documentation

pvalink::pvaLinkChannel::pvaLinkChannel ( const pvaGlobal_t::channels_key_t key,
const epics::pvData::PVStructure::const_shared_pointer &  pvRequest 
)

Definition at line 39 of file pvalink_channel.cpp.

40  :key(key)
42  ,num_disconnect(0u)
43  ,num_type_change(0u)
44  ,connected(false)
45  ,connected_latched(false)
46  ,isatomic(false)
47  ,queued(false)
48  ,debug(false)
49  ,links_changed(false)
50 {}
pvalink::pvaLinkChannel::~pvaLinkChannel ( )
virtual

Definition at line 52 of file pvalink_channel.cpp.

52  {
53  {
54  Guard G(pvaGlobal->lock);
55  pvaGlobal->channels.erase(key);
56  }
57 
58  Guard G(lock);
59 
60  assert(links.empty());
61  REFTRACE_DECREMENT(num_instances);
62 }
#define assert(exp)
Declare that a condition should be true.
Definition: epicsAssert.h:70

Member Function Documentation

void pvalink::pvaLinkChannel::monitorEvent ( const pvac::MonitorEvent evt)
virtual

New monitor event

  • MonitorEvent::Fail - An Error occurred. Check evt.message
  • MonitorEvent::Cancel - Monitor::cancel() called
  • MonitorEvent::Disconnect - Underlying ClientChannel becomes disconnected
  • MonitorEvent::Data - FIFO becomes not empty.Call Monitor::poll()

Implements pvac::ClientChannel::MonitorCallback.

Definition at line 212 of file pvalink_channel.cpp.

213 {
214  bool queue = false;
215 
216  {
217  DEBUG(this, <<key.first<<" EVENT "<<evt.event);
218  Guard G(lock);
219 
220  switch(evt.event) {
224  queue = true;
225  break;
227  break; // no-op
229  connected = false;
230  queue = true;
231  errlogPrintf("%s: PVA link monitor ERROR: %s\n", chan.name().c_str(), evt.message.c_str());
232  break;
233  }
234 
235  if(queued)
236  return; // already scheduled
237 
238  queued = queue;
239  }
240 
241  if(queue) {
242  pvaGlobal->queue.add(shared_from_this());
243  }
244 }
std::string message
set for event=Fail
Definition: client.h:192
subscription interrupted due to loss of communication
Definition: client.h:189
std::string name() const
Channel name or an empty string.
Definition: client.cpp:158
void add(const value_type &work)
Definition: tpool.cpp:79
subscription ends in cancellation
Definition: client.h:188
int errlogPrintf(const char *pFormat,...)
Definition: errlog.c:105
enum pvac::MonitorEvent::event_t event
Data queue not empty. Call Monitor::poll()
Definition: client.h:190
subscription ends in an error
Definition: client.h:187
void pvalink::pvaLinkChannel::open ( )

Definition at line 64 of file pvalink_channel.cpp.

65 {
66  Guard G(lock);
67 
68  try {
70  DEBUG(this, <<key.first<<" OPEN Local");
72  } catch(std::exception& e){
73  // The PDBProvider doesn't have a way to communicate to us
74  // whether this is an invalid record or group name,
75  // or if this is some sort of internal error.
76  // So we are forced to assume it is an invalid name.
77  DEBUG(this, <<key.first<<" OPEN Not local "<<e.what());
78  }
79  if(!pvaLinkIsolate && !chan) {
81  DEBUG(this, <<key.first<<" OPEN Remote ");
83  }
84 
85  op_mon = chan.monitor(this, pvRequest);
86 
87  REFTRACE_INCREMENT(num_instances);
88 }
std::string name() const
Definition: client.cpp:288
ClientChannel connect(const std::string &name, const ClientChannel::Options &conf=ClientChannel::Options())
Definition: client.cpp:295
Monitor monitor(MonitorCallback *cb, epics::pvData::PVStructure::const_shared_pointer pvRequest=epics::pvData::PVStructure::const_shared_pointer())
void pvalink::pvaLinkChannel::put ( bool  force = false)

Definition at line 103 of file pvalink_channel.cpp.

104 {
105  pvd::PVStructurePtr pvReq(pvd::getPVDataCreate()->createPVStructure(putRequestType));
106  pvReq->getSubFieldT<pvd::PVBoolean>("record._options.block")->put(false); // TODO: some way to expose completion...
107 
108  unsigned reqProcess = 0;
109  bool doit = force;
110  for(links_t::iterator it(links.begin()), end(links.end()); it!=end; ++it)
111  {
112  pvaLink *link = *it;
113 
114  if(!link->used_scratch) continue;
115 
117  temp.swap(link->put_scratch);
118  link->used_scratch = false;
119  temp.swap(link->put_queue);
120  link->used_queue = true;
121 
122  doit = true;
123 
124  switch(link->pp) {
125  case pvaLink::NPP:
126  reqProcess |= 1;
127  break;
128  case pvaLink::Default:
129  break;
130  case pvaLink::PP:
131  case pvaLink::CP:
132  case pvaLink::CPP:
133  reqProcess |= 2;
134  break;
135  }
136  }
137 
138  /* By default, use remote default (passive).
139  * Request processing, or not, if any link asks.
140  * Prefer PP over NPP if both are specified.
141  *
142  * TODO: per field granularity?
143  */
144  const char *proc = "passive";
145  if((reqProcess&2) || force) {
146  proc = "true";
147  } else if(reqProcess&1) {
148  proc = "false";
149  }
150  pvReq->getSubFieldT<pvd::PVString>("record._options.process")->put(proc);
151 
152  DEBUG(this, <<key.first<<"Start put "<<doit);
153  if(doit) {
154  // start net Put, cancels in-progress put
155  op_put = chan.put(this, pvReq);
156  }
157 }
Operation put(PutCallback *cb, epics::pvData::PVStructure::const_shared_pointer pvRequest=epics::pvData::PVStructure::const_shared_pointer(), bool getprevious=false)
Definition: clientPut.cpp:211
PVString is special case, since it implements SerializableArray.
Definition: pvData.h:521
void swap(shared_vector_base &o)
Swap the contents of this vector with another.
Definition: sharedVector.h:199
std::tr1::shared_ptr< PVStructure > PVStructurePtr
Definition: pvData.h:87
Class that holds the data for each possible scalar type.
Definition: pvData.h:54
FORCE_INLINE const PVDataCreatePtr & getPVDataCreate()
Definition: pvData.h:1648
void pvalink::pvaLinkChannel::putBuild ( const epics::pvData::StructureConstPtr build,
pvac::ClientChannel::PutCallback::Args args 
)
virtual

Server provides expected structure.

Implementation must instanciate (or re-use) a PVStructure into args.root, then initialize any necessary fields and set bits in args.tosend as approprate.

If this method throws, then putDone() is called with PutEvent::Fail

Implements pvac::ClientChannel::PutCallback.

Definition at line 159 of file pvalink_channel.cpp.

160 {
161  Guard G(lock);
162 
163  pvd::PVStructurePtr top(pvaGlobal->create->createPVStructure(build));
164 
165  for(links_t::iterator it(links.begin()), end(links.end()); it!=end; ++it)
166  {
167  pvaLink *link = *it;
168 
169  if(!link->used_queue) continue;
170  link->used_queue = false; // clear early so unexpected exception won't get us in a retry loop
171 
172  pvd::PVFieldPtr value(link->fieldName.empty() ? pvd::PVFieldPtr(top) : top->getSubField(link->fieldName));
173  if(value && value->getField()->getType()==pvd::structure) {
174  // maybe drill into NTScalar et al.
175  pvd::PVFieldPtr sub(static_cast<pvd::PVStructure*>(value.get())->getSubField("value"));
176  if(sub)
177  value.swap(sub);
178  }
179 
180  if(!value) continue; // TODO: how to signal error?
181 
182  pvd::PVStringArray::const_svector choices; // TODO populate from op_mon
183 
184  DEBUG(this, <<key.first<<" <- "<<value->getFullName());
185  copyDBF2PVD(link->put_queue, value, args.tosend, choices);
186 
187  link->put_queue.clear();
188  }
189  DEBUG(this, <<key.first<<" Put built");
190 
191  args.root = top;
192 }
Definition: link.h:174
epics::pvData::PVStructure::const_shared_pointer root
Callee must fill this in with an instance of the Structure passed as the &#39;build&#39; argument.
Definition: client.h:363
std::tr1::shared_ptr< PVStructure > PVStructurePtr
Definition: pvData.h:87
std::tr1::shared_ptr< PVField > PVFieldPtr
Definition: pvData.h:66
epics::pvData::BitSet & tosend
Callee must set bits corresponding to the fields of &#39;root&#39; which will actually be sent...
Definition: client.h:365
long copyDBF2PVD(const pvd::shared_vector< const void > &inbuf, const pvd::PVField::shared_pointer &outraw, pvd::BitSet &changed, const pvd::PVStringArray::const_svector &choices)
Definition: dbf_copy.cpp:164
::epics::pvData::shared_vector< const T > const_svector
Definition: pvData.h:1185
void pvalink::pvaLinkChannel::putDone ( const pvac::PutEvent evt)
virtual

Put operation is complete.

Implements pvac::ClientChannel::PutCallback.

Definition at line 194 of file pvalink_channel.cpp.

195 {
196  if(evt.event==pvac::PutEvent::Fail) {
197  errlogPrintf("%s PVA link put ERROR: %s\n", key.first.c_str(), evt.message.c_str());
198  }
199 
200  Guard G(lock);
201 
202  DEBUG(this, <<key.first<<" Put result "<<evt.event);
203 
205 
206  if(evt.event==pvac::PutEvent::Success) {
207  // see if we need start a queue'd put
208  put();
209  }
210 }
Handle for in-progress get/put/rpc operation.
Definition: client.h:50
std::string message
Check when event==Fail.
Definition: client.h:95
enum pvac::PutEvent::event_t event
int errlogPrintf(const char *pFormat,...)
Definition: errlog.c:105
request ends in failure. Check message
Definition: client.h:91
It worked!
Definition: client.h:93

Member Data Documentation

pvac::ClientChannel pvalink::pvaLinkChannel::chan

Definition at line 145 of file pvalink.h.

bool pvalink::pvaLinkChannel::connected

Definition at line 151 of file pvalink.h.

bool pvalink::pvaLinkChannel::connected_latched

Definition at line 152 of file pvalink.h.

bool pvalink::pvaLinkChannel::debug

Definition at line 155 of file pvalink.h.

bool pvalink::pvaLinkChannel::isatomic

Definition at line 153 of file pvalink.h.

const pvaGlobal_t::channels_key_t pvalink::pvaLinkChannel::key

Definition at line 137 of file pvalink.h.

links_t pvalink::pvaLinkChannel::links

Definition at line 166 of file pvalink.h.

bool pvalink::pvaLinkChannel::links_changed

Definition at line 169 of file pvalink.h.

pvd::Mutex pvalink::pvaLinkChannel::lock

Definition at line 142 of file pvalink.h.

size_t pvalink::pvaLinkChannel::num_disconnect

Definition at line 150 of file pvalink.h.

size_t pvalink::pvaLinkChannel::num_instances
static

Definition at line 140 of file pvalink.h.

size_t pvalink::pvaLinkChannel::num_type_change

Definition at line 150 of file pvalink.h.

pvac::Monitor pvalink::pvaLinkChannel::op_mon

Definition at line 146 of file pvalink.h.

pvac::Operation pvalink::pvaLinkChannel::op_put

Definition at line 147 of file pvalink.h.

std::tr1::shared_ptr<const void> pvalink::pvaLinkChannel::previous_root

Definition at line 156 of file pvalink.h.

std::string pvalink::pvaLinkChannel::providerName

Definition at line 149 of file pvalink.h.

const pvd::PVStructure::const_shared_pointer pvalink::pvaLinkChannel::pvRequest

Definition at line 138 of file pvalink.h.

bool pvalink::pvaLinkChannel::queued

Definition at line 154 of file pvalink.h.

epicsEvent pvalink::pvaLinkChannel::run_done

Definition at line 143 of file pvalink.h.


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