yet more PDB
This commit is contained in:
@ -38,6 +38,8 @@ struct BaseChannel : public epics::pvAccess::Channel
|
||||
virtual void getField(epics::pvAccess::GetFieldRequester::shared_pointer const & requester,std::string const & subField)
|
||||
{ requester->getDone(epics::pvData::Status(), fielddesc); }
|
||||
|
||||
virtual epics::pvAccess::AccessRights getAccessRights(const epics::pvData::PVField::shared_pointer &pvField)
|
||||
{ return epics::pvAccess::readWrite; }
|
||||
|
||||
virtual epics::pvAccess::ChannelProcess::shared_pointer createChannelProcess(
|
||||
epics::pvAccess::ChannelProcessRequester::shared_pointer const & requester,
|
||||
|
@ -163,9 +163,33 @@ PDBProvider::createChannel(std::string const & channelName,
|
||||
short priority, std::string const & address)
|
||||
{
|
||||
pva::Channel::shared_pointer ret;
|
||||
PDBPV::shared_pointer pv;
|
||||
pvd::Status status;
|
||||
// find channel and set ret
|
||||
status = pvd::Status(pvd::Status::STATUSTYPE_ERROR, "not found");
|
||||
{
|
||||
epicsGuard<epicsMutex> G(transient_pv_map.mutex());
|
||||
|
||||
pv = transient_pv_map.find(channelName);
|
||||
if(!pv) {
|
||||
persist_pv_map_t::const_iterator it=persist_pv_map.find(channelName);
|
||||
if(it!=persist_pv_map.end()) {
|
||||
pv = it->second;
|
||||
}
|
||||
}
|
||||
if(!pv) {
|
||||
dbChannel *pchan = dbChannelCreate(channelName.c_str());
|
||||
if(pchan) {
|
||||
DBCH chan(pchan);
|
||||
pv.reset(new PDBSinglePV(chan, shared_from_this()));
|
||||
transient_pv_map.insert(channelName, pv);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(pv) {
|
||||
ret = pv->connect(shared_from_this(), requester);
|
||||
}
|
||||
if(!ret) {
|
||||
status = pvd::Status(pvd::Status::STATUSTYPE_ERROR, "not found");
|
||||
}
|
||||
requester->channelCreated(status, ret);
|
||||
return ret;
|
||||
}
|
||||
|
@ -7,7 +7,7 @@
|
||||
|
||||
struct PDBProvider;
|
||||
|
||||
struct PDBPV : public std::tr1::enable_shared_from_this<PDBPV>
|
||||
struct PDBPV
|
||||
{
|
||||
POINTER_DEFINITIONS(PDBPV);
|
||||
|
||||
@ -22,7 +22,8 @@ struct PDBPV : public std::tr1::enable_shared_from_this<PDBPV>
|
||||
const epics::pvAccess::ChannelRequester::shared_pointer& req) =0;
|
||||
};
|
||||
|
||||
struct PDBProvider : public epics::pvAccess::ChannelProvider
|
||||
struct PDBProvider : public epics::pvAccess::ChannelProvider,
|
||||
public std::tr1::enable_shared_from_this<PDBProvider>
|
||||
{
|
||||
POINTER_DEFINITIONS(PDBProvider);
|
||||
|
||||
@ -43,7 +44,7 @@ struct PDBProvider : public epics::pvAccess::ChannelProvider
|
||||
typedef std::map<std::string, PDBPV::shared_pointer> persist_pv_map_t;
|
||||
persist_pv_map_t persist_pv_map;
|
||||
|
||||
typedef std::map<std::string, PDBPV::shared_pointer> transient_pv_map_t;
|
||||
typedef weak_value_map<std::string, PDBPV> transient_pv_map_t;
|
||||
transient_pv_map_t transient_pv_map;
|
||||
};
|
||||
|
||||
|
@ -6,6 +6,14 @@
|
||||
namespace pvd = epics::pvData;
|
||||
namespace pva = epics::pvAccess;
|
||||
|
||||
pva::Channel::shared_pointer
|
||||
PDBGroupPV::connect(const std::tr1::shared_ptr<PDBProvider>& prov,
|
||||
const pva::ChannelRequester::shared_pointer& req)
|
||||
{
|
||||
pva::Channel::shared_pointer ret(new PDBGroupChannel(shared_from_this(), prov, req));
|
||||
return ret;
|
||||
}
|
||||
|
||||
PDBGroupChannel::PDBGroupChannel(const PDBGroupPV::shared_pointer& pv,
|
||||
const std::tr1::shared_ptr<pva::ChannelProvider>& prov,
|
||||
const pva::ChannelRequester::shared_pointer& req)
|
||||
|
@ -12,7 +12,7 @@
|
||||
#include "pvif.h"
|
||||
#include "pdb.h"
|
||||
|
||||
struct PDBGroupPV : public PDBPV
|
||||
struct PDBGroupPV : public PDBPV, public std::tr1::enable_shared_from_this<PDBGroupPV>
|
||||
{
|
||||
POINTER_DEFINITIONS(PDBGroupPV);
|
||||
|
||||
|
@ -6,6 +6,14 @@
|
||||
namespace pvd = epics::pvData;
|
||||
namespace pva = epics::pvAccess;
|
||||
|
||||
pva::Channel::shared_pointer
|
||||
PDBSinglePV::connect(const std::tr1::shared_ptr<PDBProvider>& prov,
|
||||
const pva::ChannelRequester::shared_pointer& req)
|
||||
{
|
||||
pva::Channel::shared_pointer ret(new PDBSingleChannel(shared_from_this(), req));
|
||||
return ret;
|
||||
}
|
||||
|
||||
PDBSingleChannel::PDBSingleChannel(const PDBSinglePV::shared_pointer& pv,
|
||||
const pva::ChannelRequester::shared_pointer& req)
|
||||
:BaseChannel(dbChannelName(pv->chan), pv->provider, req, pv->fielddesc)
|
||||
|
@ -11,15 +11,20 @@
|
||||
#include "pvif.h"
|
||||
#include "pdb.h"
|
||||
|
||||
struct PDBSinglePV : public PDBPV
|
||||
struct PDBSinglePV : public PDBPV, public std::tr1::enable_shared_from_this<PDBSinglePV>
|
||||
{
|
||||
POINTER_DEFINITIONS(PDBSinglePV);
|
||||
|
||||
DBCH chan;
|
||||
PDBProvider::shared_pointer provider;
|
||||
|
||||
PDBSinglePV(const char *name,
|
||||
const PDBProvider::shared_pointer& prov);
|
||||
PDBSinglePV(DBCH& chan,
|
||||
const PDBProvider::shared_pointer& prov)
|
||||
:provider(prov)
|
||||
{
|
||||
this->chan.swap(chan);
|
||||
}
|
||||
virtual ~PDBSinglePV() {}
|
||||
|
||||
epics::pvAccess::Channel::shared_pointer
|
||||
connect(const std::tr1::shared_ptr<PDBProvider>& prov,
|
||||
|
Reference in New Issue
Block a user