This is Unofficial EPICS BASE Doxygen Site
TestPV Struct Reference

#include "utilities.h"

+ Collaboration diagram for TestPV:

Public Types

typedef weak_set< TestPVChannelchannels_t
 

Public Member Functions

 POINTER_DEFINITIONS (TestPV)
 
 TestPV (const std::string &name, const std::tr1::shared_ptr< TestProvider > &provider, const epics::pvData::StructureConstPtr &dtype)
 
 ~TestPV ()
 
void post (bool notify=true)
 
void post (const epics::pvData::BitSet &changed, bool notify=true)
 
void disconnect ()
 

Public Attributes

std::tr1::weak_ptr< TestPVweakself
 
const std::string name
 
std::tr1::weak_ptr< TestProvider > const provider
 
epics::pvData::PVDataCreatePtr factory
 
const epics::pvData::StructureConstPtr dtype
 
epics::pvData::PVStructurePtr value
 
epicsMutex lock
 
channels_t channels
 

Friends

struct TestProvider
 

Detailed Description

Definition at line 239 of file utilities.h.

Member Typedef Documentation

Definition at line 264 of file utilities.h.

Constructor & Destructor Documentation

TestPV::TestPV ( const std::string &  name,
const std::tr1::shared_ptr< TestProvider > &  provider,
const epics::pvData::StructureConstPtr dtype 
)

Definition at line 394 of file utilities.cpp.

397  :name(name)
400  ,dtype(dtype)
401  ,value(factory->createPVStructure(dtype))
402 {
403  epicsAtomicIncrSizeT(&countTestPV);
404 }
epics::pvData::PVStructurePtr value
Definition: utilities.h:250
std::tr1::weak_ptr< TestProvider > const provider
Definition: utilities.h:245
epics::pvData::PVDataCreatePtr factory
Definition: utilities.h:247
const std::string name
Definition: utilities.h:244
static const PVDataCreatePtr & getPVDataCreate()
const epics::pvData::StructureConstPtr dtype
Definition: utilities.h:249
EPICS_ATOMIC_INLINE size_t epicsAtomicIncrSizeT(size_t *pTarget)
TestPV::~TestPV ( )

Definition at line 406 of file utilities.cpp.

407 {
408  epicsAtomicDecrSizeT(&countTestPV);
409 }
EPICS_ATOMIC_INLINE size_t epicsAtomicDecrSizeT(size_t *pTarget)

Member Function Documentation

void TestPV::disconnect ( )

Definition at line 479 of file utilities.cpp.

480 {
481  Guard G(lock);
483 
484  FOREACH(channels_t::vector_type::const_iterator, it, end, toupdate) // channel
485  {
486  TestPVChannel *chan = it->get();
487 
489  {
490  pva::ChannelRequester::shared_pointer req(chan->requester.lock());
491  UnGuard U(G);
492  if(req)
493  req->channelStateChange(*it, TestPVChannel::DISCONNECTED);
494  }
495  }
496 }
ConnectionState state
Definition: utilities.h:191
#define FOREACH(ITERTYPE, IT, END, C)
Definition: helper.h:6
channels_t channels
Definition: utilities.h:265
epicsMutex lock
Definition: utilities.h:262
vector_type lock_vector() const
Definition: weakset.h:268
std::vector< value_pointer > vector_type
Definition: weakset.h:64
const requester_type::weak_pointer requester
Definition: pvahelper.h:35
TestPV::POINTER_DEFINITIONS ( TestPV  )
void TestPV::post ( bool  notify = true)

Definition at line 411 of file utilities.cpp.

412 {
413  pvd::BitSet changed;
414  changed.set(0); // all
415  post(changed, notify);
416 }
A vector of bits.
Definition: bitSet.h:56
void post(bool notify=true)
Definition: utilities.cpp:411
BitSet & set(uint32 bitIndex)
Definition: bitSet.cpp:103
void TestPV::post ( const epics::pvData::BitSet changed,
bool  notify = true 
)

Definition at line 418 of file utilities.cpp.

419 {
420  testDiag("post %s %d changed '%s'", name.c_str(), (int)notify, toString(changed).c_str());
421  Guard G(lock);
422 
424 
425  FOREACH(channels_t::vector_type::const_iterator, it, end, toupdate) // channel
426  {
427  TestPVChannel *chan = it->get();
428 
430  FOREACH(TestPVChannel::monitors_t::vector_type::const_iterator, it2, end2, tomon) // monitor/subscription
431  {
432  TestPVMonitor *mon = it2->get();
433 
434  if(!mon->running)
435  continue;
436 
437  mon->overflow->pvStructurePtr->copyUnchecked(*value, changed);
438 
439  if(mon->free.empty()) {
440  mon->inoverflow = true;
441  mon->overflow->overrunBitSet->or_and(*mon->overflow->changedBitSet, changed); // oflow |= prev_changed & new_changed
442  *mon->overflow->changedBitSet |= changed;
443  testDiag("overflow changed '%s' overrun '%s'",
444  toString(*mon->overflow->changedBitSet).c_str(),
445  toString(*mon->overflow->overrunBitSet).c_str());
446 
447  } else {
448  assert(!mon->inoverflow);
449 
450  if(mon->buffer.empty())
451  mon->needWakeup = true;
452 
453  pvd::MonitorElementPtr& elem(mon->free.front());
454  // Note: can't use 'changed' to optimize this copy since we don't know
455  // the state of the free element
456  elem->pvStructurePtr->copyUnchecked(*mon->overflow->pvStructurePtr);
457  *elem->changedBitSet = changed;
458  elem->overrunBitSet->clear(); // redundant/paranoia
459 
460  mon->buffer.push_back(elem);
461  mon->free.pop_front();
462  testDiag("push %p changed '%s' overflow '%s'", elem.get(),
463  toString(*elem->changedBitSet).c_str(),
464  toString(*elem->overrunBitSet).c_str());
465  }
466 
467  if(mon->needWakeup && notify) {
468  testDiag(" wakeup");
469  mon->needWakeup = false;
470  pva::MonitorRequester::shared_pointer req(mon->requester.lock());
471  UnGuard U(G);
472  if(req)
473  req->monitorEvent(*it2);
474  }
475  }
476  }
477 }
monitors_t monitors
Definition: utilities.h:194
Definition: link.h:174
#define assert(exp)
Declare that a condition should be true.
Definition: epicsAssert.h:70
BitSet & clear(uint32 bitIndex)
Definition: bitSet.cpp:112
#define FOREACH(ITERTYPE, IT, END, C)
Definition: helper.h:6
const epics::pvData::MonitorRequester::weak_pointer requester
Definition: utilities.h:216
epics::pvData::MonitorElementPtr overflow
Definition: utilities.h:236
int testDiag(const char *fmt,...)
channels_t channels
Definition: utilities.h:265
epicsMutex lock
Definition: utilities.h:262
vector_type lock_vector() const
Definition: weakset.h:268
bool needWakeup
Definition: utilities.h:221
std::deque< epics::pvData::MonitorElementPtr > buffer
Definition: utilities.h:235
const std::string name
Definition: utilities.h:244
std::deque< epics::pvData::MonitorElementPtr > free
Definition: utilities.h:235
std::vector< value_pointer > vector_type
Definition: weakset.h:64
bool inoverflow
Definition: utilities.h:220
std::tr1::shared_ptr< MonitorElement > MonitorElementPtr
Definition: monitor.h:40
std::string toString(const T &tbs)
Definition: utilities.h:31

Friends And Related Function Documentation

friend struct TestProvider
friend

Definition at line 266 of file utilities.h.

Member Data Documentation

channels_t TestPV::channels

Definition at line 265 of file utilities.h.

const epics::pvData::StructureConstPtr TestPV::dtype

Definition at line 249 of file utilities.h.

Definition at line 247 of file utilities.h.

epicsMutex TestPV::lock
mutable

Definition at line 262 of file utilities.h.

const std::string TestPV::name

Definition at line 244 of file utilities.h.

std::tr1::weak_ptr<TestProvider> const TestPV::provider

Definition at line 245 of file utilities.h.

Definition at line 250 of file utilities.h.

std::tr1::weak_ptr<TestPV> TestPV::weakself

Definition at line 242 of file utilities.h.


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