This is Unofficial EPICS BASE Doxygen Site
PDBSinglePut Struct Reference

#include "pdbsingle.h"

+ Inheritance diagram for PDBSinglePut:
+ Collaboration diagram for PDBSinglePut:

Public Types

typedef epics::pvAccess::ChannelPutRequester requester_t
 
- Public Types inherited from epics::pvAccess::ChannelPut
typedef ChannelPutRequester requester_type
 

Public Member Functions

 POINTER_DEFINITIONS (PDBSinglePut)
 
 PDBSinglePut (const PDBSingleChannel::shared_pointer &channel, const epics::pvAccess::ChannelPutRequester::shared_pointer &requester, const epics::pvData::PVStructure::shared_pointer &pvReq)
 
virtual ~PDBSinglePut ()
 
virtual void destroy () OVERRIDE FINAL
 
virtual std::tr1::shared_ptr< epics::pvAccess::ChannelgetChannel () OVERRIDE FINAL
 
virtual void cancel () OVERRIDE FINAL
 
virtual void lastRequest () OVERRIDE FINAL
 
virtual void put (epics::pvData::PVStructure::shared_pointer const &pvPutStructure, epics::pvData::BitSet::shared_pointer const &putBitSet) OVERRIDE FINAL
 
virtual void get () OVERRIDE FINAL
 
- Public Member Functions inherited from epics::pvAccess::ChannelPut
 POINTER_DEFINITIONS (ChannelPut)
 
virtual ~ChannelPut ()
 
- Public Member Functions inherited from epics::pvAccess::ChannelRequest
 POINTER_DEFINITIONS (ChannelRequest)
 
 ChannelRequest ()
 
virtual ~ChannelRequest ()
 
- Public Member Functions inherited from epics::pvAccess::Destroyable
 POINTER_DEFINITIONS (Destroyable)
 
- Public Member Functions inherited from epics::pvAccess::Lockable
 POINTER_DEFINITIONS (Lockable)
 
virtual ~Lockable ()
 
virtual void lock ()
 
virtual void unlock ()
 

Public Attributes

PDBSingleChannel::shared_pointer channel
 
requester_t::weak_pointer requester
 
epics::pvData::BitSetPtr changed
 
epics::pvData::BitSetPtr wait_changed
 
epics::pvData::PVStructurePtr pvf
 
p2p::auto_ptr< PVIFpvif
 
p2p::auto_ptr< PVIFwait_pvif
 
processNotify notify
 
int notifyBusy
 
PVIF::proc_t doProc
 
bool doWait
 

Static Public Attributes

static size_t num_instances
 
- Static Public Attributes inherited from epics::pvAccess::ChannelRequest
static size_t num_instances
 

Additional Inherited Members

- Protected Member Functions inherited from epics::pvAccess::Destroyable
virtual ~Destroyable ()
 

Detailed Description

Definition at line 102 of file pdbsingle.h.

Member Typedef Documentation

Constructor & Destructor Documentation

PDBSinglePut::PDBSinglePut ( const PDBSingleChannel::shared_pointer &  channel,
const epics::pvAccess::ChannelPutRequester::shared_pointer &  requester,
const epics::pvData::PVStructure::shared_pointer &  pvReq 
)

Definition at line 299 of file pdbsingle.cpp.

302  :channel(channel)
304  ,changed(new pvd::BitSet(channel->fielddesc->getNumberFields()))
305  ,pvf(pvd::getPVDataCreate()->createPVStructure(channel->fielddesc))
306  ,pvif(channel->pv->builder->attach(channel->pv->chan, pvf, FieldName()))
307  ,notifyBusy(0)
309  ,doWait(false)
310 {
311  epics::atomic::increment(num_instances);
312  dbChannel *chan = channel->pv->chan;
313 
314  try {
315  getS<pvd::boolean>(pvReq, "record._options.block", doWait);
316  } catch(std::runtime_error& e) {
317  requester->message(std::string("block= not understood : ")+e.what(), pva::warningMessage);
318  }
319 
320  std::string proccmd;
321  if(getS<std::string>(pvReq, "record._options.process", proccmd)) {
322  if(proccmd=="true") {
324  } else if(proccmd=="false") {
326  doWait = false; // no point in waiting
327  } else if(proccmd=="passive") {
329  } else {
330  requester->message("process= expects: true|false|passive", pva::warningMessage);
331  }
332  }
333 
334  memset((void*)&notify, 0, sizeof(notify));
335  notify.usrPvt = (void*)this;
336  notify.chan = chan;
337  notify.putCallback = &single_put_callback;
338  notify.doneCallback = &single_done_callback;
339 }
epics::pvData::BitSetPtr changed
Definition: pdbsingle.h:111
static size_t num_instances
Definition: pdbsingle.h:121
PDBSingleChannel::shared_pointer channel
Definition: pdbsingle.h:108
int notifyBusy
Definition: pdbsingle.h:115
A vector of bits.
Definition: bitSet.h:56
p2p::auto_ptr< PVIF > pvif
Definition: pdbsingle.h:113
requester_t::weak_pointer requester
Definition: pdbsingle.h:109
PVIF::proc_t doProc
Definition: pdbsingle.h:118
processNotify notify
Definition: pdbsingle.h:114
epics::pvData::PVStructurePtr pvf
Definition: pdbsingle.h:112
FORCE_INLINE const PVDataCreatePtr & getPVDataCreate()
Definition: pvData.h:1648
PDBSinglePut::~PDBSinglePut ( )
virtual

Definition at line 341 of file pdbsingle.cpp.

342 {
343  cancel();
344  epics::atomic::decrement(num_instances);
345 }
static size_t num_instances
Definition: pdbsingle.h:121
virtual void cancel() OVERRIDE FINAL
Definition: pdbsingle.cpp:409

Member Function Documentation

void PDBSinglePut::cancel ( )
virtual

Cancel any pending request. Completion will be reported via request's response callback:

  • if cancel() request is issued after the request was already complete, request success/failure completion will be reported and cancel() request ignored.
  • if the request was actually canceled, cancellation completion is reported.

Implements epics::pvAccess::ChannelRequest.

Definition at line 409 of file pdbsingle.cpp.

410 {
411  if(epics::atomic::compareAndSwap(notifyBusy, 1, 2)==1) {
412  dbNotifyCancel(&notify);
413  wait_changed.reset();
414  wait_pvif.reset();
415  epics::atomic::set(notifyBusy, 0);
416  }
417 }
int notifyBusy
Definition: pdbsingle.h:115
p2p::auto_ptr< PVIF > wait_pvif
Definition: pdbsingle.h:113
processNotify notify
Definition: pdbsingle.h:114
epics::pvData::BitSetPtr wait_changed
Definition: pdbsingle.h:111
virtual void PDBSinglePut::destroy ( )
inlinevirtual

Destroy this instance.

Implements epics::pvAccess::Destroyable.

Definition at line 128 of file pdbsingle.h.

128 { pvif.reset(); channel.reset(); requester.reset(); }
PDBSingleChannel::shared_pointer channel
Definition: pdbsingle.h:108
p2p::auto_ptr< PVIF > pvif
Definition: pdbsingle.h:113
requester_t::weak_pointer requester
Definition: pdbsingle.h:109
void PDBSinglePut::get ( )
virtual

Get the current data.

Ownership transfer as with ChannelGet::get()

Implements epics::pvAccess::ChannelPut.

Definition at line 419 of file pdbsingle.cpp.

420 {
421  changed->clear();
422  {
423  DBScanLocker L(pvif->chan);
425  }
426  //TODO: report unused fields as changed?
427  changed->clear();
428  changed->set(0);
429 
430  requester_type::shared_pointer req(requester.lock());
431  if(req)
432  req->getDone(pvd::Status(), shared_from_this(), pvf, changed);
433 }
epics::pvData::BitSetPtr changed
Definition: pdbsingle.h:111
#define NULL
Definition: catime.c:38
#define DBE_ALARM
Definition: caeventmask.h:41
p2p::auto_ptr< PVIF > pvif
Definition: pdbsingle.h:113
#define DBE_VALUE
Definition: caeventmask.h:38
requester_t::weak_pointer requester
Definition: pdbsingle.h:109
#define DBE_PROPERTY
Definition: caeventmask.h:42
epics::pvData::PVStructurePtr pvf
Definition: pdbsingle.h:112
virtual std::tr1::shared_ptr<epics::pvAccess::Channel> PDBSinglePut::getChannel ( )
inlinevirtual

Get a channel instance this request belongs to.

Returns
the channel instance.

Implements epics::pvAccess::ChannelRequest.

Definition at line 129 of file pdbsingle.h.

129 { return channel; }
PDBSingleChannel::shared_pointer channel
Definition: pdbsingle.h:108
virtual void PDBSinglePut::lastRequest ( )
inlinevirtual

Announce next request as last request. When last request will be completed (regardless of completion status) the remote and local instance will be destroyed.

Implements epics::pvAccess::ChannelRequest.

Definition at line 131 of file pdbsingle.h.

131 {}
PDBSinglePut::POINTER_DEFINITIONS ( PDBSinglePut  )
void PDBSinglePut::put ( epics::pvData::PVStructure::shared_pointer const &  pvPutStructure,
epics::pvData::BitSet::shared_pointer const &  putBitSet 
)
virtual

Put data to a channel.

Completion status is reported by calling ChannelPutRequester::putDone()

Ownership of the PVStructure is transfered to the ChannelPut until ChannelPutRequester::putDone() or ChannelPutRequester::channelDisconnect() is called.

Parameters
pvPutStructureThe PVStructure that holds the putData.
putBitSetputPVStructure bit-set (selects what fields to put).

Implements epics::pvAccess::ChannelPut.

Definition at line 347 of file pdbsingle.cpp.

349 {
350  dbChannel *chan = channel->pv->chan;
351  dbFldDes *fld = dbChannelFldDes(chan);
352 
353  pvd::Status ret;
354  if(!channel->aspvt.canWrite()) {
355  ret = pvd::Status::error("Put not permitted");
356 
357  } else if(dbChannelFieldType(chan)>=DBF_INLINK && dbChannelFieldType(chan)<=DBF_FWDLINK) {
358  try{
359  std::string lval(value->getSubFieldT<pvd::PVScalar>("value")->getAs<std::string>());
360  long status = dbChannelPutField(chan, DBF_STRING, lval.c_str(), 1);
361  if(status)
362  ret = pvd::Status(pvd::Status::error("dbPutField() error"));
363  }catch(std::exception& e) {
364  std::ostringstream strm;
365  strm<<"Failed to put link field "<<dbChannelName(chan)<<"."<<fld->name<<" : "<<e.what()<<"\n";
366  ret = pvd::Status(pvd::Status::error(strm.str()));
367  }
368 
369  } else if(doWait) {
370  // TODO: dbNotify doesn't allow us for force processing
371 
372  // assume value may be a different struct each time
373  p2p::auto_ptr<PVIF> putpvif(channel->pv->builder->attach(channel->pv->chan, value, FieldName()));
374  unsigned mask = putpvif->dbe(*changed);
375 
376  if(mask!=DBE_VALUE) {
377  requester_type::shared_pointer req(requester.lock());
378  if(req)
379  req->message("block=true only supports .value (empty put mask)", pva::warningMessage);
380  }
381 
382  if(epics::atomic::compareAndSwap(notifyBusy, 0, 1)!=0)
383  throw std::logic_error("Previous put() not complete");
384 
385  notify.requestType = (mask&DBE_VALUE) ? putProcessRequest : processRequest;
386 
387  wait_pvif = PTRMOVE(putpvif);
389 
390  dbProcessNotify(&notify);
391 
392  return; // skip notification
393  } else {
394  // assume value may be a different struct each time
395  p2p::auto_ptr<PVIF> putpvif(channel->pv->builder->attach(channel->pv->chan, value, FieldName()));
396  try{
397  DBScanLocker L(chan);
398  putpvif->get(*changed, doProc);
399 
400  }catch(std::runtime_error& e){
401  ret = pvd::Status::error(e.what());
402  }
403  }
404  requester_type::shared_pointer req(requester.lock());
405  if(req)
406  req->putDone(ret, shared_from_this());
407 }
Definition: link.h:174
PVScalar is the base class for each scalar field.
Definition: pvData.h:272
epics::pvData::BitSetPtr changed
Definition: pdbsingle.h:111
pvd::Status status
static Status error(const std::string &m)
Definition: status.h:50
PDBSingleChannel::shared_pointer channel
Definition: pdbsingle.h:108
int notifyBusy
Definition: pdbsingle.h:115
p2p::auto_ptr< PVIF > wait_pvif
Definition: pdbsingle.h:113
#define DBE_VALUE
Definition: caeventmask.h:38
requester_t::weak_pointer requester
Definition: pdbsingle.h:109
PVIF::proc_t doProc
Definition: pdbsingle.h:118
processNotify notify
Definition: pdbsingle.h:114
epics::pvData::BitSetPtr wait_changed
Definition: pdbsingle.h:111
#define PTRMOVE(AUTO)
Definition: helper.h:15
char * name
Definition: dbBase.h:81
T getAs() const
Definition: pvData.h:302

Member Data Documentation

epics::pvData::BitSetPtr PDBSinglePut::changed

Definition at line 111 of file pdbsingle.h.

PDBSingleChannel::shared_pointer PDBSinglePut::channel

Definition at line 108 of file pdbsingle.h.

PVIF::proc_t PDBSinglePut::doProc

Definition at line 118 of file pdbsingle.h.

bool PDBSinglePut::doWait

Definition at line 119 of file pdbsingle.h.

processNotify PDBSinglePut::notify

Definition at line 114 of file pdbsingle.h.

int PDBSinglePut::notifyBusy

Definition at line 115 of file pdbsingle.h.

size_t PDBSinglePut::num_instances
static

Definition at line 121 of file pdbsingle.h.

epics::pvData::PVStructurePtr PDBSinglePut::pvf

Definition at line 112 of file pdbsingle.h.

p2p::auto_ptr<PVIF> PDBSinglePut::pvif

Definition at line 113 of file pdbsingle.h.

requester_t::weak_pointer PDBSinglePut::requester

Definition at line 109 of file pdbsingle.h.

epics::pvData::BitSetPtr PDBSinglePut::wait_changed

Definition at line 111 of file pdbsingle.h.

p2p::auto_ptr<PVIF> PDBSinglePut::wait_pvif

Definition at line 113 of file pdbsingle.h.


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