pva2pva 1.4.2
Loading...
Searching...
No Matches
PDBSinglePut Struct Reference
Inheritance diagram for PDBSinglePut:
Collaboration diagram for PDBSinglePut:

Public Types

typedef epics::pvAccess::ChannelPutRequester requester_t

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 void destroy () OVERRIDE FINAL
virtual std::tr1::shared_ptr< epics::pvAccess::Channel > getChannel () 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 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< PVIF > pvif
p2p::auto_ptr< PVIF > wait_pvif
processNotify notify
int notifyBusy
PVIF::proc_t doProc
bool doWait

Static Public Attributes

static size_t num_instances

Detailed Description

Definition at line 102 of file pdbsingle.h.

Member Typedef Documentation

◆ requester_t

typedef epics::pvAccess::ChannelPutRequester PDBSinglePut::requester_t

Definition at line 107 of file pdbsingle.h.

Constructor & Destructor Documentation

◆ PDBSinglePut()

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

Definition at line 305 of file pdbsingle.cpp.

308 :channel(channel)
309 ,requester(requester)
310 ,changed(new pvd::BitSet(channel->fielddesc->getNumberFields()))
311 ,pvf(pvd::getPVDataCreate()->createPVStructure(channel->fielddesc))
312 ,pvif(channel->pv->builder->attach(pvf, FieldName()))
313 ,notifyBusy(0)
314 ,doProc(PVIF::ProcPassive)
315 ,doWait(false)
316{
317 epics::atomic::increment(num_instances);
318 dbChannel *chan = channel->pv->chan;
319
320 try {
321 getS<pvd::boolean>(pvReq, "record._options.block", doWait);
322 } catch(std::runtime_error& e) {
323 requester->message(std::string("block= not understood : ")+e.what(), pva::warningMessage);
324 }
325
326 std::string proccmd;
327 if(getS<std::string>(pvReq, "record._options.process", proccmd)) {
328 if(proccmd=="true") {
329 doProc = PVIF::ProcForce;
330 } else if(proccmd=="false") {
331 doProc = PVIF::ProcInhibit;
332 doWait = false; // no point in waiting
333 } else if(proccmd=="passive") {
334 doProc = PVIF::ProcPassive;
335 } else {
336 requester->message("process= expects: true|false|passive", pva::warningMessage);
337 }
338 }
339
340 memset((void*)&notify, 0, sizeof(notify));
341 notify.usrPvt = (void*)this;
342 notify.chan = chan;
343 notify.putCallback = &single_put_callback;
344 notify.doneCallback = &single_done_callback;
345}

◆ ~PDBSinglePut()

PDBSinglePut::~PDBSinglePut ( )
virtual

Definition at line 347 of file pdbsingle.cpp.

348{
349 cancel();
350 epics::atomic::decrement(num_instances);
351}

Member Function Documentation

◆ cancel()

void PDBSinglePut::cancel ( )
virtual

Definition at line 426 of file pdbsingle.cpp.

427{
428 if(epics::atomic::compareAndSwap(notifyBusy, 1, 2)==1) {
429 dbNotifyCancel(&notify);
430 wait_changed.reset();
431 wait_pvif.reset();
432 epics::atomic::set(notifyBusy, 0);
433 }
434}

◆ destroy()

virtual void PDBSinglePut::destroy ( )
inlinevirtual

Definition at line 128 of file pdbsingle.h.

128{ pvif.reset(); channel.reset(); requester.reset(); }

◆ get()

void PDBSinglePut::get ( )
virtual

Definition at line 436 of file pdbsingle.cpp.

437{
438 changed->clear();
439 {
440 DBScanLocker L(pvif->chan);
441 LocalFL FL(NULL, pvif->chan);
442 pvif->put(*changed, DBE_VALUE|DBE_ALARM|DBE_PROPERTY, FL.pfl);
443 }
444 //TODO: report unused fields as changed?
445 changed->clear();
446 changed->set(0);
447
448 requester_type::shared_pointer req(requester.lock());
449 if(req)
450 req->getDone(pvd::Status(), shared_from_this(), pvf, changed);
451}

◆ getChannel()

virtual std::tr1::shared_ptr< epics::pvAccess::Channel > PDBSinglePut::getChannel ( )
inlinevirtual

Definition at line 129 of file pdbsingle.h.

129{ return channel; }

◆ lastRequest()

virtual void PDBSinglePut::lastRequest ( )
inlinevirtual

Definition at line 131 of file pdbsingle.h.

131{}

◆ put()

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

Definition at line 353 of file pdbsingle.cpp.

355{
356 dbChannel *chan = channel->pv->chan;
357 dbFldDes *fld = dbChannelFldDes(chan);
358
359 AsWritePvt asWritePvt (
360 asTrapWriteWithData(channel->aspvt.aspvt,
361 std::string(channel->cred.user.begin(), channel->cred.user.end()).c_str(),
362 std::string(channel->cred.host.begin(), channel->cred.host.end()).c_str(),
363 chan,
364 chan->final_type,
365 chan->final_no_elements,
366 NULL
367 )
368 );
369
370 pvd::Status ret;
371 if(!channel->aspvt.canWrite()) {
372 ret = pvd::Status::error("Put not permitted");
373
374 } else if(dbChannelFieldType(chan)>=DBF_INLINK && dbChannelFieldType(chan)<=DBF_FWDLINK) {
375 try{
376 std::string lval(value->getSubFieldT<pvd::PVScalar>("value")->getAs<std::string>());
377 long status = dbChannelPutField(chan, DBF_STRING, lval.c_str(), 1);
378 if(status)
379 ret = pvd::Status(pvd::Status::error("dbPutField() error"));
380 }catch(std::exception& e) {
381 std::ostringstream strm;
382 strm<<"Failed to put link field "<<dbChannelName(chan)<<"."<<fld->name<<" : "<<e.what()<<"\n";
383 ret = pvd::Status(pvd::Status::error(strm.str()));
384 }
385
386 } else if(doWait) {
387 // TODO: dbNotify doesn't allow us for force processing
388
389 // assume value may be a different struct each time
390 p2p::auto_ptr<PVIF> putpvif(channel->pv->builder->attach(value, FieldName()));
391 unsigned mask = putpvif->dbe(*changed);
392
393 if(mask!=DBE_VALUE) {
394 requester_type::shared_pointer req(requester.lock());
395 if(req)
396 req->message("block=true only supports .value (empty put mask)", pva::warningMessage);
397 }
398
399 if(epics::atomic::compareAndSwap(notifyBusy, 0, 1)!=0)
400 throw std::logic_error("Previous put() not complete");
401
402 notify.requestType = (mask&DBE_VALUE) ? putProcessRequest : processRequest;
403
404 wait_pvif = PTRMOVE(putpvif);
405 wait_changed = changed;
406
407 dbProcessNotify(&notify);
408
409 return; // skip notification
410 } else {
411 // assume value may be a different struct each time
412 p2p::auto_ptr<PVIF> putpvif(channel->pv->builder->attach(value, FieldName()));
413 try{
414 DBScanLocker L(chan);
415 ret = putpvif->get(*changed, doProc);
416
417 }catch(std::runtime_error& e){
418 ret = pvd::Status::error(e.what());
419 }
420 }
421 requester_type::shared_pointer req(requester.lock());
422 if(req)
423 req->putDone(ret, shared_from_this());
424}

Member Data Documentation

◆ changed

epics::pvData::BitSetPtr PDBSinglePut::changed

Definition at line 111 of file pdbsingle.h.

◆ channel

PDBSingleChannel::shared_pointer PDBSinglePut::channel

Definition at line 108 of file pdbsingle.h.

◆ doProc

PVIF::proc_t PDBSinglePut::doProc

Definition at line 118 of file pdbsingle.h.

◆ doWait

bool PDBSinglePut::doWait

Definition at line 119 of file pdbsingle.h.

◆ notify

processNotify PDBSinglePut::notify

Definition at line 114 of file pdbsingle.h.

◆ notifyBusy

int PDBSinglePut::notifyBusy

Definition at line 115 of file pdbsingle.h.

◆ num_instances

size_t PDBSinglePut::num_instances
static

Definition at line 121 of file pdbsingle.h.

◆ pvf

epics::pvData::PVStructurePtr PDBSinglePut::pvf

Definition at line 112 of file pdbsingle.h.

◆ pvif

p2p::auto_ptr<PVIF> PDBSinglePut::pvif

Definition at line 113 of file pdbsingle.h.

◆ requester

requester_t::weak_pointer PDBSinglePut::requester

Definition at line 109 of file pdbsingle.h.

◆ wait_changed

epics::pvData::BitSetPtr PDBSinglePut::wait_changed

Definition at line 111 of file pdbsingle.h.

◆ wait_pvif

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: