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

Public Types

typedef epics::pvAccess::ChannelPutRequester requester_t

Public Member Functions

 POINTER_DEFINITIONS (PDBGroupPut)
 PDBGroupPut (const PDBGroupChannel::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

PDBGroupChannel::shared_pointer channel
requester_type::weak_pointer requester
bool atomic
bool doWait
PVIF::proc_t doProc
epics::pvData::BitSetPtr changed
epics::pvData::PVStructurePtr pvf
std::vector< std::tr1::shared_ptr< PVIF > > pvif

Static Public Attributes

static size_t num_instances

Detailed Description

Definition at line 163 of file pdbgroup.h.

Member Typedef Documentation

◆ requester_t

typedef epics::pvAccess::ChannelPutRequester PDBGroupPut::requester_t

Definition at line 167 of file pdbgroup.h.

Constructor & Destructor Documentation

◆ PDBGroupPut()

PDBGroupPut::PDBGroupPut ( const PDBGroupChannel::shared_pointer & channel,
const epics::pvAccess::ChannelPutRequester::shared_pointer & requester,
const epics::pvData::PVStructure::shared_pointer & pvReq )

Definition at line 295 of file pdbgroup.cpp.

298 :channel(channel)
299 ,requester(requester)
300 ,atomic(channel->pv->pgatomic)
301 ,doWait(false)
302 ,doProc(PVIF::ProcPassive)
303 ,changed(new pvd::BitSet(channel->fielddesc->getNumberFields()))
304 ,pvf(pvd::getPVDataCreate()->createPVStructure(channel->fielddesc))
305{
306 epics::atomic::increment(num_instances);
307 try {
308 getS<pvd::boolean>(pvReq, "record._options.atomic", atomic);
309
310 getS<pvd::boolean>(pvReq, "record._options.block", doWait);
311
312 std::string proccmd;
313 if(getS<std::string>(pvReq, "record._options.process", proccmd)) {
314 if(proccmd=="true") {
315 doProc = PVIF::ProcForce;
316 } else if(proccmd=="false") {
317 doProc = PVIF::ProcInhibit;
318 doWait = false; // no point in waiting
319 } else if(proccmd=="passive") {
320 doProc = PVIF::ProcPassive;
321 } else {
322 requester->message("process= expects: true|false|passive", pva::warningMessage);
323 }
324 }
325 }catch(std::exception& e){
326 requester->message(std::string("Error processing request options: ")+e.what());
327 }
328
329 pvf->getSubFieldT<pvd::PVBoolean>("record._options.atomic")->put(atomic);
330
331
332 const size_t npvs = channel->pv->members.size();
333 pvif.resize(npvs);
334 for(size_t i=0; i<npvs; i++)
335 {
336 PDBGroupPV::Info& info = channel->pv->members[i];
337
338 pvif[i].reset(info.builder->attach(pvf, info.attachment));
339 }
340}

◆ ~PDBGroupPut()

PDBGroupPut::~PDBGroupPut ( )
virtual

Definition at line 342 of file pdbgroup.cpp.

343{
344 epics::atomic::decrement(num_instances);
345}

Member Function Documentation

◆ cancel()

virtual void PDBGroupPut::cancel ( )
inlinevirtual

Definition at line 188 of file pdbgroup.h.

188{}

◆ destroy()

virtual void PDBGroupPut::destroy ( )
inlinevirtual

Definition at line 186 of file pdbgroup.h.

186{ pvif.clear(); channel.reset(); requester.reset(); }

◆ get()

void PDBGroupPut::get ( )
virtual

Definition at line 404 of file pdbgroup.cpp.

405{
406 const size_t npvs = pvif.size();
407
408 changed->clear();
409 if(atomic) {
410 DBManyLocker L(channel->pv->locker);
411 for(size_t i=0; i<npvs; i++) {
412 LocalFL FL(NULL, channel->pv->members[i].chan);
413 pvif[i]->put(*changed, DBE_VALUE|DBE_ALARM|DBE_PROPERTY, FL.pfl);
414 }
415 } else {
416
417 for(size_t i=0; i<npvs; i++)
418 {
419 PDBGroupPV::Info& info = channel->pv->members[i];
420
421 DBScanLocker L(dbChannelRecord(info.chan));
422 LocalFL FL(NULL, info.chan);
423 pvif[i]->put(*changed, DBE_VALUE|DBE_ALARM|DBE_PROPERTY, FL.pfl);
424 }
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}

◆ getChannel()

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

Definition at line 187 of file pdbgroup.h.

187{ return channel; }

◆ lastRequest()

virtual void PDBGroupPut::lastRequest ( )
inlinevirtual

Definition at line 189 of file pdbgroup.h.

189{}

◆ put()

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

Definition at line 347 of file pdbgroup.cpp.

349{
350 // assume value may be a different struct each time... lot of wasted prep work
351 const size_t npvs = channel->pv->members.size();
352 std::vector<std::tr1::shared_ptr<PVIF> > putpvif(npvs);
353 pvd::shared_vector<AsWritePvt> asWritePvt(npvs);
354
355 for(size_t i=0; i<npvs; i++)
356 {
357 PDBGroupPV::Info& info = channel->pv->members[i];
358
359 AsWritePvt wrt(asTrapWriteWithData(
360 channel->aspvt.at(i).aspvt,
361 &channel->cred.user[0],
362 &channel->cred.host[0],
363 info.chan.chan,
364 info.chan->final_type,
365 info.chan->final_no_elements,
366 NULL
367 )
368 );
369 asWritePvt[i].swap(wrt);
370
371 if(!info.allowProc) continue;
372 putpvif[i].reset(info.builder->attach(value, info.attachment));
373 }
374
375 pvd::Status ret;
376 if(atomic) {
377 DBManyLocker L(channel->pv->locker);
378 for(size_t i=0; ret && i<npvs; i++) {
379 if(!putpvif[i].get()) continue;
380
381 ret |= putpvif[i]->get(*changed, doProc, channel->aspvt[i].canWrite());
382 }
383
384 } else {
385 for(size_t i=0; ret && i<npvs; i++)
386 {
387 if(!putpvif[i].get()) continue;
388
389 PDBGroupPV::Info& info = channel->pv->members[i];
390
391 DBScanLocker L(dbChannelRecord(info.chan));
392
393 ret |= putpvif[i]->get(*changed,
394 info.allowProc ? doProc : PVIF::ProcInhibit,
395 channel->aspvt[i].canWrite());
396 }
397 }
398
399 requester_type::shared_pointer req(requester.lock());
400 if(req)
401 req->putDone(ret, shared_from_this());
402}

Member Data Documentation

◆ atomic

bool PDBGroupPut::atomic

Definition at line 172 of file pdbgroup.h.

◆ changed

epics::pvData::BitSetPtr PDBGroupPut::changed

Definition at line 175 of file pdbgroup.h.

◆ channel

PDBGroupChannel::shared_pointer PDBGroupPut::channel

Definition at line 168 of file pdbgroup.h.

◆ doProc

PVIF::proc_t PDBGroupPut::doProc

Definition at line 173 of file pdbgroup.h.

◆ doWait

bool PDBGroupPut::doWait

Definition at line 172 of file pdbgroup.h.

◆ num_instances

size_t PDBGroupPut::num_instances
static

Definition at line 179 of file pdbgroup.h.

◆ pvf

epics::pvData::PVStructurePtr PDBGroupPut::pvf

Definition at line 176 of file pdbgroup.h.

◆ pvif

std::vector<std::tr1::shared_ptr<PVIF> > PDBGroupPut::pvif

Definition at line 177 of file pdbgroup.h.

◆ requester

requester_type::weak_pointer PDBGroupPut::requester

Definition at line 169 of file pdbgroup.h.


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