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

Public Types

typedef std::set< PDBSingleMonitor * > interested_t
typedef std::set< BaseMonitor::shared_pointer > interested_remove_t

Public Member Functions

 POINTER_DEFINITIONS (PDBSinglePV)
shared_pointer shared_from_this ()
 PDBSinglePV (DBCH &chan, const PDBProvider::shared_pointer &prov)
void activate ()
virtual epics::pvAccess::Channel::shared_pointer connect (const std::tr1::shared_ptr< PDBProvider > &prov, const epics::pvAccess::ChannelRequester::shared_pointer &req) OVERRIDE FINAL
void addMonitor (PDBSingleMonitor *)
void removeMonitor (PDBSingleMonitor *)
void finalizeMonitor ()
Public Member Functions inherited from PDBPV
 POINTER_DEFINITIONS (PDBPV)
virtual void show (int lvl)

Public Attributes

weak_pointer weakself
DBCH chan
DBCH chan2
PDBProvider::shared_pointer provider
epics::pvData::BitSet scratch
epicsMutex lock
p2p::auto_ptr< ScalarBuilder > builder
p2p::auto_ptr< PVIF > pvif
epics::pvData::PVStructurePtr complete
bool interested_iterating
interested_t interested
interested_t interested_add
interested_remove_t interested_remove
DBEvent evt_VALUE
DBEvent evt_PROPERTY
bool hadevent_VALUE
bool hadevent_PROPERTY
Public Attributes inherited from PDBPV
epics::pvData::StructureConstPtr fielddesc

Static Public Attributes

static size_t num_instances

Detailed Description

Definition at line 21 of file pdbsingle.h.

Member Typedef Documentation

◆ interested_remove_t

typedef std::set<BaseMonitor::shared_pointer> PDBSinglePV::interested_remove_t

Definition at line 52 of file pdbsingle.h.

◆ interested_t

typedef std::set<PDBSingleMonitor*> PDBSinglePV::interested_t

Definition at line 48 of file pdbsingle.h.

Constructor & Destructor Documentation

◆ PDBSinglePV()

PDBSinglePV::PDBSinglePV ( DBCH & chan,
const PDBProvider::shared_pointer & prov )

Definition at line 97 of file pdbsingle.cpp.

99 :provider(prov)
100 ,builder(new ScalarBuilder(chan.chan))
101 ,interested_iterating(false)
102 ,evt_VALUE(this)
103 ,evt_PROPERTY(this)
104 ,hadevent_VALUE(false)
105 ,hadevent_PROPERTY(false)
106{
107 if(ellCount(&chan.chan->pre_chain) || ellCount(&chan.chan->post_chain)) {
108 DBCH temp(dbChannelName(chan.chan));
109 this->chan2.swap(temp);
110 }
111 this->chan.swap(chan);
112 fielddesc = std::tr1::static_pointer_cast<const pvd::Structure>(builder->dtype());
113
114 complete = pvd::getPVDataCreate()->createPVStructure(fielddesc);
115 FieldName temp;
116 pvif.reset(builder->attach(complete, temp));
117
118 epics::atomic::increment(num_instances);
119}

◆ ~PDBSinglePV()

PDBSinglePV::~PDBSinglePV ( )
virtual

Definition at line 121 of file pdbsingle.cpp.

122{
123 epics::atomic::decrement(num_instances);
124}

Member Function Documentation

◆ activate()

void PDBSinglePV::activate ( )

Definition at line 126 of file pdbsingle.cpp.

127{
128 dbChannel *pchan = this->chan2.chan ? this->chan2.chan : this->chan.chan;
129 evt_VALUE.create(provider->event_context, this->chan, &pdb_single_event, DBE_VALUE|DBE_ALARM);
130 evt_PROPERTY.create(provider->event_context, pchan, &pdb_single_event, DBE_PROPERTY);
131}

◆ addMonitor()

void PDBSinglePV::addMonitor ( PDBSingleMonitor * mon)

Definition at line 146 of file pdbsingle.cpp.

147{
148 Guard G(lock);
149 if(interested.empty() && interested_add.empty()) {
150 // first monitor
151 // start subscription
152
153 hadevent_VALUE = false;
154 hadevent_PROPERTY = false;
155 db_event_enable(evt_VALUE.subscript);
156 db_event_enable(evt_PROPERTY.subscript);
157 db_post_single_event(evt_VALUE.subscript);
158 db_post_single_event(evt_PROPERTY.subscript);
159
160 } else if(hadevent_VALUE && hadevent_PROPERTY) {
161 // new subscriber and already had initial update
162 mon->post(G);
163 } // else new subscriber, but no initial update. so just wait
164
165 if(interested_iterating) {
166 interested_add.insert(mon);
167 } else {
168 interested.insert(mon);
169 }
170}
bool post(guard_t &guard, const epics::pvData::BitSet &updated, no_overflow)
post update if queue not full, if full return false w/o overflow
Definition pvahelper.h:136

◆ connect()

pva::Channel::shared_pointer PDBSinglePV::connect ( const std::tr1::shared_ptr< PDBProvider > & prov,
const epics::pvAccess::ChannelRequester::shared_pointer & req )
virtual

Implements PDBPV.

Definition at line 134 of file pdbsingle.cpp.

136{
137 PDBSingleChannel::shared_pointer ret(new PDBSingleChannel(shared_from_this(), req));
138
139 ret->cred.update(req);
140
141 ret->aspvt.add(chan, ret->cred);
142
143 return ret;
144}

◆ finalizeMonitor()

void PDBSinglePV::finalizeMonitor ( )

Definition at line 189 of file pdbsingle.cpp.

190{
191 assert(!interested_iterating);
192
193 if(interested.empty()) {
194 db_event_disable(evt_VALUE.subscript);
195 db_event_disable(evt_PROPERTY.subscript);
196 }
197}

◆ removeMonitor()

void PDBSinglePV::removeMonitor ( PDBSingleMonitor * mon)

Definition at line 172 of file pdbsingle.cpp.

173{
174 Guard G(lock);
175
176 if(interested_add.erase(mon)) {
177 // and+remove while iterating. no-op
178
179 } else if(interested_iterating) {
180 // keep monitor alive while iterating
181 interested_remove.insert(mon->shared_from_this());
182
183 } else {
184 interested.erase(mon);
185 finalizeMonitor();
186 }
187}

◆ shared_from_this()

shared_pointer PDBSinglePV::shared_from_this ( )
inline

Definition at line 25 of file pdbsingle.h.

25{ return shared_pointer(weakself); }

Member Data Documentation

◆ builder

p2p::auto_ptr<ScalarBuilder> PDBSinglePV::builder

Definition at line 43 of file pdbsingle.h.

◆ chan

DBCH PDBSinglePV::chan

Definition at line 32 of file pdbsingle.h.

◆ chan2

DBCH PDBSinglePV::chan2

Definition at line 34 of file pdbsingle.h.

◆ complete

epics::pvData::PVStructurePtr PDBSinglePV::complete

Definition at line 46 of file pdbsingle.h.

◆ evt_PROPERTY

DBEvent PDBSinglePV::evt_PROPERTY

Definition at line 55 of file pdbsingle.h.

◆ evt_VALUE

DBEvent PDBSinglePV::evt_VALUE

Definition at line 55 of file pdbsingle.h.

◆ hadevent_PROPERTY

bool PDBSinglePV::hadevent_PROPERTY

Definition at line 56 of file pdbsingle.h.

◆ hadevent_VALUE

bool PDBSinglePV::hadevent_VALUE

Definition at line 56 of file pdbsingle.h.

◆ interested

interested_t PDBSinglePV::interested

Definition at line 50 of file pdbsingle.h.

◆ interested_add

interested_t PDBSinglePV::interested_add

Definition at line 50 of file pdbsingle.h.

◆ interested_iterating

bool PDBSinglePV::interested_iterating

Definition at line 49 of file pdbsingle.h.

◆ interested_remove

interested_remove_t PDBSinglePV::interested_remove

Definition at line 53 of file pdbsingle.h.

◆ lock

epicsMutex PDBSinglePV::lock

Definition at line 41 of file pdbsingle.h.

◆ num_instances

size_t PDBSinglePV::num_instances
static

Definition at line 58 of file pdbsingle.h.

◆ provider

PDBProvider::shared_pointer PDBSinglePV::provider

Definition at line 35 of file pdbsingle.h.

◆ pvif

p2p::auto_ptr<PVIF> PDBSinglePV::pvif

Definition at line 44 of file pdbsingle.h.

◆ scratch

epics::pvData::BitSet PDBSinglePV::scratch

Definition at line 39 of file pdbsingle.h.

◆ weakself

weak_pointer PDBSinglePV::weakself

Definition at line 24 of file pdbsingle.h.


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