@ -21,21 +21,37 @@ using namespace std;
|
|||||||
|
|
||||||
namespace epics { namespace pvDatabase {
|
namespace epics { namespace pvDatabase {
|
||||||
|
|
||||||
|
#define DEBUG_LEVEL 0
|
||||||
|
|
||||||
static PVDatabasePtr pvDatabaseMaster;
|
static PVDatabasePtr pvDatabaseMaster;
|
||||||
|
|
||||||
|
bool PVDatabase::getMasterFirstCall = true;
|
||||||
|
|
||||||
PVDatabasePtr PVDatabase::getMaster()
|
PVDatabasePtr PVDatabase::getMaster()
|
||||||
{
|
{
|
||||||
if(!pvDatabaseMaster) pvDatabaseMaster = PVDatabasePtr(new PVDatabase());
|
if(getMasterFirstCall) {
|
||||||
|
getMasterFirstCall = false;
|
||||||
|
pvDatabaseMaster = PVDatabasePtr(new PVDatabase());
|
||||||
|
}
|
||||||
return pvDatabaseMaster;
|
return pvDatabaseMaster;
|
||||||
}
|
}
|
||||||
|
|
||||||
PVDatabase::PVDatabase()
|
PVDatabase::PVDatabase()
|
||||||
{
|
{
|
||||||
|
if(DEBUG_LEVEL>0) cout << "PVDatabase::PVDatabase()\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
PVDatabase::~PVDatabase()
|
PVDatabase::~PVDatabase()
|
||||||
{
|
{
|
||||||
cout << "PVDatabase::~PVDatabase()\n";
|
if(DEBUG_LEVEL>0) cout << "PVDatabase::~PVDatabase()\n";
|
||||||
|
size_t len = recordMap.size();
|
||||||
|
shared_vector<string> names(len);
|
||||||
|
PVRecordMap::iterator iter;
|
||||||
|
size_t i = 0;
|
||||||
|
for(iter = recordMap.begin(); iter!=recordMap.end(); ++iter) {
|
||||||
|
names[i++] = (*iter).first;
|
||||||
|
}
|
||||||
|
for(size_t i=0; i<len; ++i) removeRecord(findRecord(names[i]));
|
||||||
}
|
}
|
||||||
|
|
||||||
void PVDatabase::lock() {
|
void PVDatabase::lock() {
|
||||||
@ -83,7 +99,6 @@ bool PVDatabase::removeRecord(PVRecordPtr const & record)
|
|||||||
if(iter!=recordMap.end()) {
|
if(iter!=recordMap.end()) {
|
||||||
PVRecordPtr pvRecord = (*iter).second;
|
PVRecordPtr pvRecord = (*iter).second;
|
||||||
recordMap.erase(iter);
|
recordMap.erase(iter);
|
||||||
if(pvRecord) pvRecord->destroy();
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -46,11 +46,62 @@ PVRecord::PVRecord(
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PVRecord::notifyClients()
|
||||||
|
{
|
||||||
|
{
|
||||||
|
epicsGuard<epics::pvData::Mutex> guard(mutex);
|
||||||
|
if(traceLevel>0) {
|
||||||
|
cout << "PVRecord::notifyClients() " << recordName
|
||||||
|
<< " isDestroyed " << (isDestroyed ? "true" : "false")
|
||||||
|
<< endl;
|
||||||
|
}
|
||||||
|
if(isDestroyed) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
isDestroyed = true;
|
||||||
|
}
|
||||||
|
pvTimeStamp.detach();
|
||||||
|
for(std::list<PVListenerWPtr>::iterator iter = pvListenerList.begin();
|
||||||
|
iter!=pvListenerList.end();
|
||||||
|
iter++ )
|
||||||
|
{
|
||||||
|
PVListenerPtr listener = iter->lock();
|
||||||
|
if(!listener) continue;
|
||||||
|
if(traceLevel>0) {
|
||||||
|
cout << "PVRecord::notifyClients() calling listener->unlisten "
|
||||||
|
<< recordName << endl;
|
||||||
|
}
|
||||||
|
listener->unlisten(shared_from_this());
|
||||||
|
}
|
||||||
|
pvListenerList.clear();
|
||||||
|
for (std::list<PVRecordClientWPtr>::iterator iter = clientList.begin();
|
||||||
|
iter!=clientList.end();
|
||||||
|
iter++ )
|
||||||
|
{
|
||||||
|
PVRecordClientPtr client = iter->lock();
|
||||||
|
if(!client) continue;
|
||||||
|
if(traceLevel>0) {
|
||||||
|
cout << "PVRecord::notifyClients() calling client->detach "
|
||||||
|
<< recordName << endl;
|
||||||
|
}
|
||||||
|
client->detach(shared_from_this());
|
||||||
|
}
|
||||||
|
if(traceLevel>0) {
|
||||||
|
cout << "PVRecord::notifyClients() calling clientList.clear() "
|
||||||
|
<< recordName << endl;
|
||||||
|
}
|
||||||
|
clientList.clear();
|
||||||
|
if(traceLevel>0) {
|
||||||
|
cout << "PVRecord::notifyClients() returning " << recordName << endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
PVRecord::~PVRecord()
|
PVRecord::~PVRecord()
|
||||||
{
|
{
|
||||||
if(traceLevel>0) {
|
if(traceLevel>0) {
|
||||||
cout << "~PVRecord() " << recordName << endl;
|
cout << "~PVRecord() " << recordName << endl;
|
||||||
}
|
}
|
||||||
|
notifyClients();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PVRecord::initPVRecord()
|
void PVRecord::initPVRecord()
|
||||||
@ -65,45 +116,9 @@ void PVRecord::initPVRecord()
|
|||||||
|
|
||||||
void PVRecord::destroy()
|
void PVRecord::destroy()
|
||||||
{
|
{
|
||||||
{
|
|
||||||
epicsGuard<epics::pvData::Mutex> guard(mutex);
|
|
||||||
if(traceLevel>0) {
|
|
||||||
cout << "PVRecord::destroy() " << recordName
|
|
||||||
<< " isDestroyed " << (isDestroyed ? "true" : "false")
|
|
||||||
<< endl;
|
|
||||||
}
|
|
||||||
if(isDestroyed) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
isDestroyed = true;
|
|
||||||
}
|
|
||||||
PVDatabasePtr pvDatabase(PVDatabase::getMaster());
|
PVDatabasePtr pvDatabase(PVDatabase::getMaster());
|
||||||
if(pvDatabase) pvDatabase->removeRecord(shared_from_this());
|
if(pvDatabase) pvDatabase->removeRecord(shared_from_this());
|
||||||
pvTimeStamp.detach();
|
notifyClients();
|
||||||
for(std::list<PVListenerWPtr>::iterator iter = pvListenerList.begin();
|
|
||||||
iter!=pvListenerList.end();
|
|
||||||
iter++ )
|
|
||||||
{
|
|
||||||
PVListenerPtr listener = iter->lock();
|
|
||||||
if(!listener) continue;
|
|
||||||
if(traceLevel>0) {
|
|
||||||
cout << "PVRecord::destroy() calling listener->unlisten " << recordName << endl;
|
|
||||||
}
|
|
||||||
listener->unlisten(shared_from_this());
|
|
||||||
}
|
|
||||||
pvListenerList.clear();
|
|
||||||
for (std::list<PVRecordClientPtr>::iterator iter = clientList.begin();
|
|
||||||
iter!=clientList.end();
|
|
||||||
iter++ )
|
|
||||||
{
|
|
||||||
PVRecordClientPtr client = *iter;
|
|
||||||
if(!client) continue;
|
|
||||||
if(traceLevel>0) {
|
|
||||||
cout << "PVRecord::destroy() calling client->detach " << recordName << endl;
|
|
||||||
}
|
|
||||||
client->detach(shared_from_this());
|
|
||||||
}
|
|
||||||
clientList.clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PVRecord::process()
|
void PVRecord::process()
|
||||||
@ -194,47 +209,31 @@ bool PVRecord::addPVRecordClient(PVRecordClientPtr const & pvRecordClient)
|
|||||||
if(isDestroyed) {
|
if(isDestroyed) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
std::list<PVRecordClientPtr>::iterator iter;
|
// clean clientList
|
||||||
for (iter = clientList.begin();
|
bool clientListClean = false;
|
||||||
iter!=clientList.end();
|
while(!clientListClean) {
|
||||||
iter++ )
|
if(clientList.empty()) break;
|
||||||
{
|
clientListClean = true;
|
||||||
PVRecordClientPtr client = *iter;
|
std::list<PVRecordClientWPtr>::iterator iter;
|
||||||
if(client==pvRecordClient) {
|
for (iter = clientList.begin();
|
||||||
return false;
|
iter!=clientList.end();
|
||||||
|
iter++ )
|
||||||
|
{
|
||||||
|
PVRecordClientPtr client = iter->lock();
|
||||||
|
if(client) continue;
|
||||||
|
if(traceLevel>1) {
|
||||||
|
cout << "PVRecord::addPVRecordClient() erasing client"
|
||||||
|
<< recordName << endl;
|
||||||
|
}
|
||||||
|
clientList.erase(iter);
|
||||||
|
clientListClean = false;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(traceLevel>1) {
|
|
||||||
cout << "PVRecord::addPVRecordClient() calling clientList.push_back(pvRecordClient)" << recordName << endl;
|
|
||||||
}
|
|
||||||
clientList.push_back(pvRecordClient);
|
clientList.push_back(pvRecordClient);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PVRecord::removePVRecordClient(PVRecordClientPtr const & pvRecordClient)
|
|
||||||
{
|
|
||||||
if(traceLevel>1) {
|
|
||||||
cout << "PVRecord::removePVRecordClient() " << recordName << endl;
|
|
||||||
}
|
|
||||||
epicsGuard<epics::pvData::Mutex> guard(mutex);
|
|
||||||
if(isDestroyed) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
std::list<PVRecordClientPtr>::iterator iter;
|
|
||||||
for (iter = clientList.begin();
|
|
||||||
iter!=clientList.end();
|
|
||||||
iter++ )
|
|
||||||
{
|
|
||||||
PVRecordClientPtr client = *iter;
|
|
||||||
if(!client) continue;
|
|
||||||
if(client==pvRecordClient) {
|
|
||||||
clientList.erase(iter);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool PVRecord::addListener(
|
bool PVRecord::addListener(
|
||||||
PVListenerPtr const & pvListener,
|
PVListenerPtr const & pvListener,
|
||||||
PVCopyPtr const & pvCopy)
|
PVCopyPtr const & pvCopy)
|
||||||
@ -246,15 +245,6 @@ bool PVRecord::addListener(
|
|||||||
if(isDestroyed) {
|
if(isDestroyed) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
std::list<PVListenerWPtr>::iterator iter;
|
|
||||||
for (iter = pvListenerList.begin(); iter!=pvListenerList.end(); iter++ )
|
|
||||||
{
|
|
||||||
PVListenerPtr listener = iter->lock();
|
|
||||||
if(!listener.get()) continue;
|
|
||||||
if(listener.get()==pvListener.get()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
pvListenerList.push_back(pvListener);
|
pvListenerList.push_back(pvListener);
|
||||||
this->pvListener = pvListener;
|
this->pvListener = pvListener;
|
||||||
isAddListener = true;
|
isAddListener = true;
|
||||||
@ -394,14 +384,6 @@ bool PVRecordField::addListener(PVListenerPtr const & pvListener)
|
|||||||
if(pvRecord && pvRecord->getTraceLevel()>1) {
|
if(pvRecord && pvRecord->getTraceLevel()>1) {
|
||||||
cout << "PVRecordField::addListener() " << getFullName() << endl;
|
cout << "PVRecordField::addListener() " << getFullName() << endl;
|
||||||
}
|
}
|
||||||
std::list<PVListenerWPtr>::iterator iter;
|
|
||||||
for (iter = pvListenerList.begin(); iter!=pvListenerList.end(); iter++ ) {
|
|
||||||
PVListenerPtr listener = iter->lock();
|
|
||||||
if(!listener.get()) continue;
|
|
||||||
if(listener.get()==pvListener.get()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
pvListenerList.push_back(pvListener);
|
pvListenerList.push_back(pvListener);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -450,7 +432,8 @@ void PVRecordField::postSubField()
|
|||||||
{
|
{
|
||||||
callListener();
|
callListener();
|
||||||
if(isStructure) {
|
if(isStructure) {
|
||||||
PVRecordStructurePtr pvrs = static_pointer_cast<PVRecordStructure>(shared_from_this());
|
PVRecordStructurePtr pvrs =
|
||||||
|
static_pointer_cast<PVRecordStructure>(shared_from_this());
|
||||||
PVRecordFieldPtrArrayPtr pvRecordFields = pvrs->getPVRecordFields();
|
PVRecordFieldPtrArrayPtr pvRecordFields = pvrs->getPVRecordFields();
|
||||||
PVRecordFieldPtrArray::iterator iter;
|
PVRecordFieldPtrArray::iterator iter;
|
||||||
for(iter = pvRecordFields->begin() ; iter !=pvRecordFields->end(); iter++) {
|
for(iter = pvRecordFields->begin() ; iter !=pvRecordFields->end(); iter++) {
|
||||||
|
@ -39,60 +39,20 @@
|
|||||||
|
|
||||||
#include <pv/pvDatabase.h>
|
#include <pv/pvDatabase.h>
|
||||||
|
|
||||||
|
|
||||||
namespace epics { namespace pvDatabase {
|
namespace epics { namespace pvDatabase {
|
||||||
|
|
||||||
|
|
||||||
class MonitorFactory;
|
|
||||||
typedef std::tr1::shared_ptr<MonitorFactory> MonitorFactoryPtr;
|
|
||||||
|
|
||||||
class MonitorLocal;
|
|
||||||
typedef std::tr1::shared_ptr<MonitorLocal> MonitorLocalPtr;
|
|
||||||
|
|
||||||
|
|
||||||
class ChannelProviderLocal;
|
class ChannelProviderLocal;
|
||||||
typedef std::tr1::shared_ptr<ChannelProviderLocal> ChannelProviderLocalPtr;
|
typedef std::tr1::shared_ptr<ChannelProviderLocal> ChannelProviderLocalPtr;
|
||||||
|
typedef std::tr1::weak_ptr<ChannelProviderLocal> ChannelProviderLocalWPtr;
|
||||||
class ChannelLocal;
|
class ChannelLocal;
|
||||||
typedef std::tr1::shared_ptr<ChannelLocal> ChannelLocalPtr;
|
typedef std::tr1::shared_ptr<ChannelLocal> ChannelLocalPtr;
|
||||||
|
typedef std::tr1::weak_ptr<ChannelLocal> ChannelLocalWPtr;
|
||||||
|
|
||||||
epicsShareFunc MonitorFactoryPtr getMonitorFactory();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief MonitorFactory
|
|
||||||
*
|
|
||||||
* This class provides a static method to create a monitor for a PVRecord
|
|
||||||
*/
|
|
||||||
class epicsShareClass MonitorFactory
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
POINTER_DEFINITIONS(MonitorFactory);
|
|
||||||
/**
|
|
||||||
* @brief Destructor
|
|
||||||
*/
|
|
||||||
virtual ~MonitorFactory();
|
|
||||||
/**
|
|
||||||
* @brief Create a monitor on a record.
|
|
||||||
*
|
|
||||||
* This is called by the local channel provider.
|
|
||||||
* @param pvRecord The record to monitor.
|
|
||||||
* @param monitorRequester The client callback.
|
|
||||||
* @param pvRequest Options specified by the client.
|
|
||||||
* This includes the subset of the fields in the record to monitor.
|
|
||||||
* @return A shared pointer to the newly created monitor.
|
|
||||||
* If the monitor can not be created a null monitor is returned.
|
|
||||||
* This means the pvRequest specified options that could not be satisfied.
|
|
||||||
*/
|
|
||||||
epics::pvData::MonitorPtr createMonitor(
|
|
||||||
PVRecordPtr const & pvRecord,
|
|
||||||
epics::pvData::MonitorRequester::shared_pointer const & monitorRequester,
|
|
||||||
epics::pvData::PVStructurePtr const & pvRequest);
|
|
||||||
private:
|
|
||||||
MonitorFactory();
|
|
||||||
friend class MonitorLocal;
|
|
||||||
friend epicsShareFunc MonitorFactoryPtr getMonitorFactory();
|
|
||||||
epics::pvData::Mutex mutex;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
epicsShareFunc epics::pvData::MonitorPtr createMonitorLocal(
|
||||||
|
PVRecordPtr const & pvRecord,
|
||||||
|
epics::pvData::MonitorRequester::shared_pointer const & monitorRequester,
|
||||||
|
epics::pvData::PVStructurePtr const & pvRequest);
|
||||||
|
|
||||||
epicsShareFunc ChannelProviderLocalPtr getChannelProviderLocal();
|
epicsShareFunc ChannelProviderLocalPtr getChannelProviderLocal();
|
||||||
|
|
||||||
@ -124,11 +84,13 @@ public:
|
|||||||
virtual void destroy() EPICS_DEPRECATED {};
|
virtual void destroy() EPICS_DEPRECATED {};
|
||||||
/**
|
/**
|
||||||
* @brief Returns the channel provider name.
|
* @brief Returns the channel provider name.
|
||||||
|
*
|
||||||
* @return <b>local</b>
|
* @return <b>local</b>
|
||||||
*/
|
*/
|
||||||
virtual std::string getProviderName();
|
virtual std::string getProviderName();
|
||||||
/**
|
/**
|
||||||
* @brief Returns either a null channelFind or a channelFind for records in the PVDatabase.
|
* @brief Returns either a null channelFind or a channelFind for records in the PVDatabase.
|
||||||
|
*
|
||||||
* @param channelName The name of the channel desired.
|
* @param channelName The name of the channel desired.
|
||||||
* @param channelFindRequester The client callback.
|
* @param channelFindRequester The client callback.
|
||||||
* @return shared pointer to ChannelFind.
|
* @return shared pointer to ChannelFind.
|
||||||
@ -204,11 +166,10 @@ public:
|
|||||||
* @brief ChannelFind method.
|
* @brief ChannelFind method.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
virtual void cancel();
|
virtual void cancel() {}
|
||||||
private:
|
private:
|
||||||
friend epicsShareFunc ChannelProviderLocalPtr getChannelProviderLocal();
|
friend epicsShareFunc ChannelProviderLocalPtr getChannelProviderLocal();
|
||||||
PVDatabasePtr pvDatabase;
|
PVDatabaseWPtr pvDatabase;
|
||||||
epics::pvData::Mutex mutex;
|
|
||||||
int traceLevel;
|
int traceLevel;
|
||||||
friend class ChannelProviderLocalRun;
|
friend class ChannelProviderLocalRun;
|
||||||
};
|
};
|
||||||
@ -249,8 +210,7 @@ public:
|
|||||||
* @brief Detach from the record.
|
* @brief Detach from the record.
|
||||||
*
|
*
|
||||||
* This is called when a record is being removed from the database.
|
* This is called when a record is being removed from the database.
|
||||||
* Calls destroy.
|
* @param pvRecord The record being removed.
|
||||||
* @param pvRecord The record being destroyed.
|
|
||||||
*/
|
*/
|
||||||
virtual void detach(PVRecordPtr const &pvRecord);
|
virtual void detach(PVRecordPtr const &pvRecord);
|
||||||
/**
|
/**
|
||||||
@ -270,10 +230,7 @@ public:
|
|||||||
* @brief Get the channel provider
|
* @brief Get the channel provider
|
||||||
* @return The provider.
|
* @return The provider.
|
||||||
*/
|
*/
|
||||||
virtual epics::pvAccess::ChannelProvider::shared_pointer getProvider()
|
virtual epics::pvAccess::ChannelProvider::shared_pointer getProvider();
|
||||||
{
|
|
||||||
return provider;
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* @brief Get the remote address
|
* @brief Get the remote address
|
||||||
* @return <b>local</b>
|
* @return <b>local</b>
|
||||||
@ -412,8 +369,8 @@ protected:
|
|||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
epics::pvAccess::ChannelRequester::shared_pointer requester;
|
epics::pvAccess::ChannelRequester::shared_pointer requester;
|
||||||
ChannelProviderLocalPtr provider;
|
ChannelProviderLocalWPtr provider;
|
||||||
PVRecordPtr pvRecord;
|
PVRecordWPtr pvRecord;
|
||||||
epics::pvData::Mutex mutex;
|
epics::pvData::Mutex mutex;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -13,7 +13,6 @@
|
|||||||
|
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <deque>
|
|
||||||
|
|
||||||
#include <pv/pvData.h>
|
#include <pv/pvData.h>
|
||||||
#include <pv/pvCopy.h>
|
#include <pv/pvCopy.h>
|
||||||
@ -46,6 +45,7 @@ typedef std::tr1::weak_ptr<PVRecordStructure> PVRecordStructureWPtr;
|
|||||||
|
|
||||||
class PVRecordClient;
|
class PVRecordClient;
|
||||||
typedef std::tr1::shared_ptr<PVRecordClient> PVRecordClientPtr;
|
typedef std::tr1::shared_ptr<PVRecordClient> PVRecordClientPtr;
|
||||||
|
typedef std::tr1::weak_ptr<PVRecordClient> PVRecordClientWPtr;
|
||||||
|
|
||||||
class PVListener;
|
class PVListener;
|
||||||
typedef std::tr1::shared_ptr<PVListener> PVListenerPtr;
|
typedef std::tr1::shared_ptr<PVListener> PVListenerPtr;
|
||||||
@ -53,6 +53,7 @@ typedef std::tr1::weak_ptr<PVListener> PVListenerWPtr;
|
|||||||
|
|
||||||
class PVDatabase;
|
class PVDatabase;
|
||||||
typedef std::tr1::shared_ptr<PVDatabase> PVDatabasePtr;
|
typedef std::tr1::shared_ptr<PVDatabase> PVDatabasePtr;
|
||||||
|
typedef std::tr1::weak_ptr<PVDatabase> PVDatabaseWPtr;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Base interface for a PVRecord.
|
* @brief Base interface for a PVRecord.
|
||||||
@ -97,12 +98,16 @@ public:
|
|||||||
*/
|
*/
|
||||||
virtual void process();
|
virtual void process();
|
||||||
/**
|
/**
|
||||||
* @brief Optional method for derived class.
|
* @brief Destroy the record.
|
||||||
*
|
*
|
||||||
* Destroy the PVRecord. Release any resources used and
|
* Destroy the PVRecord. Release any resources used and
|
||||||
* get rid of listeners and requesters.
|
* get rid of listeners and requesters.
|
||||||
* If derived class overrides this then it must call PVRecord::destroy()
|
* If derived class overrides this then it must call PVRecord::destroy()
|
||||||
* after it has destroyed any resorces it uses.
|
* after it has destroyed any resorces it uses.
|
||||||
|
*
|
||||||
|
* Note: for most classes destroy no longer exists or has been deprecated.
|
||||||
|
* This method makes it possible to remove a record from a database
|
||||||
|
* while the database is still running.
|
||||||
*/
|
*/
|
||||||
virtual void destroy();
|
virtual void destroy();
|
||||||
/**
|
/**
|
||||||
@ -195,13 +200,6 @@ public:
|
|||||||
* @return <b>true</b> if the client is added.
|
* @return <b>true</b> if the client is added.
|
||||||
*/
|
*/
|
||||||
bool addPVRecordClient(PVRecordClientPtr const & pvRecordClient);
|
bool addPVRecordClient(PVRecordClientPtr const & pvRecordClient);
|
||||||
/**
|
|
||||||
* @brief Remove a client.
|
|
||||||
*
|
|
||||||
* @param pvRecordClient The client.
|
|
||||||
* @return <b>true</b> if the client is removed.
|
|
||||||
*/
|
|
||||||
bool removePVRecordClient(PVRecordClientPtr const & pvRecordClient);
|
|
||||||
/**
|
/**
|
||||||
* @brief Add a PVListener.
|
* @brief Add a PVListener.
|
||||||
*
|
*
|
||||||
@ -268,23 +266,23 @@ private:
|
|||||||
PVRecordFieldPtr findPVRecordField(
|
PVRecordFieldPtr findPVRecordField(
|
||||||
PVRecordStructurePtr const & pvrs,
|
PVRecordStructurePtr const & pvrs,
|
||||||
epics::pvData::PVFieldPtr const & pvField);
|
epics::pvData::PVFieldPtr const & pvField);
|
||||||
|
void notifyClients();
|
||||||
|
|
||||||
std::string recordName;
|
std::string recordName;
|
||||||
epics::pvData::PVStructurePtr pvStructure;
|
epics::pvData::PVStructurePtr pvStructure;
|
||||||
PVRecordStructurePtr pvRecordStructure;
|
PVRecordStructurePtr pvRecordStructure;
|
||||||
std::list<PVListenerWPtr> pvListenerList;
|
std::list<PVListenerWPtr> pvListenerList;
|
||||||
std::list<PVRecordClientPtr> clientList;
|
std::list<PVRecordClientWPtr> clientList;
|
||||||
epics::pvData::Mutex mutex;
|
epics::pvData::Mutex mutex;
|
||||||
std::size_t depthGroupPut;
|
std::size_t depthGroupPut;
|
||||||
int traceLevel;
|
int traceLevel;
|
||||||
bool isDestroyed;
|
bool isDestroyed;
|
||||||
|
|
||||||
epics::pvData::PVTimeStamp pvTimeStamp;
|
|
||||||
epics::pvData::TimeStamp timeStamp;
|
|
||||||
|
|
||||||
// following only valid while addListener or removeListener is active.
|
// following only valid while addListener or removeListener is active.
|
||||||
bool isAddListener;
|
bool isAddListener;
|
||||||
PVListenerWPtr pvListener;
|
PVListenerWPtr pvListener;
|
||||||
|
|
||||||
|
epics::pvData::PVTimeStamp pvTimeStamp;
|
||||||
|
epics::pvData::TimeStamp timeStamp;
|
||||||
};
|
};
|
||||||
|
|
||||||
epicsShareFunc std::ostream& operator<<(std::ostream& o, const PVRecord& record);
|
epicsShareFunc std::ostream& operator<<(std::ostream& o, const PVRecord& record);
|
||||||
@ -527,6 +525,7 @@ private:
|
|||||||
void unlock();
|
void unlock();
|
||||||
PVRecordMap recordMap;
|
PVRecordMap recordMap;
|
||||||
epics::pvData::Mutex mutex;
|
epics::pvData::Mutex mutex;
|
||||||
|
static bool getMasterFirstCall;
|
||||||
};
|
};
|
||||||
|
|
||||||
}}
|
}}
|
||||||
|
@ -31,25 +31,6 @@ using std::string;
|
|||||||
namespace epics { namespace pvDatabase {
|
namespace epics { namespace pvDatabase {
|
||||||
|
|
||||||
static StructureConstPtr nullStructure;
|
static StructureConstPtr nullStructure;
|
||||||
static PVStructurePtr nullPVStructure;
|
|
||||||
static BitSetPtr nullBitSet;
|
|
||||||
static Status channelDestroyedStatus(
|
|
||||||
Status::STATUSTYPE_ERROR,
|
|
||||||
"was destroyed"
|
|
||||||
);
|
|
||||||
static Status illegalOffsetStatus(
|
|
||||||
Status::STATUSTYPE_ERROR,
|
|
||||||
"count must be >0"
|
|
||||||
);
|
|
||||||
static Status illegalCountStatus(
|
|
||||||
Status::STATUSTYPE_ERROR,
|
|
||||||
"count must be >0"
|
|
||||||
);
|
|
||||||
static Status illegalStrideStatus(
|
|
||||||
Status::STATUSTYPE_ERROR,
|
|
||||||
"stride must be >0"
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
class ChannelProcessLocal;
|
class ChannelProcessLocal;
|
||||||
typedef std::tr1::shared_ptr<ChannelProcessLocal> ChannelProcessLocalPtr;
|
typedef std::tr1::shared_ptr<ChannelProcessLocal> ChannelProcessLocalPtr;
|
||||||
@ -59,8 +40,6 @@ class ChannelPutLocal;
|
|||||||
typedef std::tr1::shared_ptr<ChannelPutLocal> ChannelPutLocalPtr;
|
typedef std::tr1::shared_ptr<ChannelPutLocal> ChannelPutLocalPtr;
|
||||||
class ChannelPutGetLocal;
|
class ChannelPutGetLocal;
|
||||||
typedef std::tr1::shared_ptr<ChannelPutGetLocal> ChannelPutGetLocalPtr;
|
typedef std::tr1::shared_ptr<ChannelPutGetLocal> ChannelPutGetLocalPtr;
|
||||||
class ChannelMonitorLocal;
|
|
||||||
typedef std::tr1::shared_ptr<ChannelMonitorLocal> ChannelMonitorLocalPtr;
|
|
||||||
class ChannelRPCLocal;
|
class ChannelRPCLocal;
|
||||||
typedef std::tr1::shared_ptr<ChannelRPCLocal> ChannelRPCLocalPtr;
|
typedef std::tr1::shared_ptr<ChannelRPCLocal> ChannelRPCLocalPtr;
|
||||||
class ChannelArrayLocal;
|
class ChannelArrayLocal;
|
||||||
@ -90,13 +69,7 @@ class ChannelProcessLocal :
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
POINTER_DEFINITIONS(ChannelProcessLocal);
|
POINTER_DEFINITIONS(ChannelProcessLocal);
|
||||||
virtual ~ChannelProcessLocal()
|
virtual ~ChannelProcessLocal();
|
||||||
{
|
|
||||||
if(pvRecord->getTraceLevel()>0)
|
|
||||||
{
|
|
||||||
cout << "~ChannelProcessLocal() " << endl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
static ChannelProcessLocalPtr create(
|
static ChannelProcessLocalPtr create(
|
||||||
ChannelLocalPtr const &channelLocal,
|
ChannelLocalPtr const &channelLocal,
|
||||||
ChannelProcessRequester::shared_pointer const & channelProcessRequester,
|
ChannelProcessRequester::shared_pointer const & channelProcessRequester,
|
||||||
@ -104,12 +77,11 @@ public:
|
|||||||
PVRecordPtr const &pvRecord);
|
PVRecordPtr const &pvRecord);
|
||||||
virtual void process();
|
virtual void process();
|
||||||
virtual void destroy() EPICS_DEPRECATED {};
|
virtual void destroy() EPICS_DEPRECATED {};
|
||||||
virtual std::tr1::shared_ptr<Channel> getChannel()
|
virtual std::tr1::shared_ptr<Channel> getChannel();
|
||||||
{return channelLocal;}
|
|
||||||
virtual void cancel(){}
|
virtual void cancel(){}
|
||||||
|
virtual void lock();
|
||||||
|
virtual void unlock();
|
||||||
virtual void lastRequest() {}
|
virtual void lastRequest() {}
|
||||||
virtual void lock() {pvRecord->lock();}
|
|
||||||
virtual void unlock() {pvRecord->unlock();}
|
|
||||||
private:
|
private:
|
||||||
shared_pointer getPtrSelf()
|
shared_pointer getPtrSelf()
|
||||||
{
|
{
|
||||||
@ -127,9 +99,9 @@ private:
|
|||||||
nProcess(nProcess)
|
nProcess(nProcess)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
ChannelLocalPtr channelLocal;
|
ChannelLocalWPtr channelLocal;
|
||||||
ChannelProcessRequester::weak_pointer channelProcessRequester;
|
ChannelProcessRequester::weak_pointer channelProcessRequester;
|
||||||
PVRecordPtr pvRecord;
|
PVRecordWPtr pvRecord;
|
||||||
int nProcess;
|
int nProcess;
|
||||||
Mutex mutex;
|
Mutex mutex;
|
||||||
};
|
};
|
||||||
@ -172,21 +144,50 @@ ChannelProcessLocalPtr ChannelProcessLocal::create(
|
|||||||
return process;
|
return process;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ChannelProcessLocal::~ChannelProcessLocal()
|
||||||
|
{
|
||||||
|
PVRecordPtr pvr(pvRecord.lock());
|
||||||
|
if(pvr && pvr->getTraceLevel()>0) {
|
||||||
|
cout << "~ChannelProcessLocal() " << pvr->getRecordName() << endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::tr1::shared_ptr<Channel> ChannelProcessLocal::getChannel()
|
||||||
|
{
|
||||||
|
ChannelLocalPtr channel(channelLocal.lock());
|
||||||
|
return channel;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ChannelProcessLocal::lock()
|
||||||
|
{
|
||||||
|
PVRecordPtr pvr(pvRecord.lock());
|
||||||
|
if(!pvr) throw std::logic_error("pvRecord is deleted");
|
||||||
|
pvr->lock();
|
||||||
|
}
|
||||||
|
void ChannelProcessLocal::unlock()
|
||||||
|
{
|
||||||
|
PVRecordPtr pvr(pvRecord.lock());
|
||||||
|
if(!pvr) throw std::logic_error("pvRecord is deleted");
|
||||||
|
pvr->unlock();
|
||||||
|
}
|
||||||
|
|
||||||
void ChannelProcessLocal::process()
|
void ChannelProcessLocal::process()
|
||||||
{
|
{
|
||||||
ChannelProcessRequester::shared_pointer requester = channelProcessRequester.lock();
|
ChannelProcessRequester::shared_pointer requester = channelProcessRequester.lock();
|
||||||
if(!requester) return;
|
if(!requester) return;
|
||||||
if(pvRecord->getTraceLevel()>1)
|
PVRecordPtr pvr(pvRecord.lock());
|
||||||
|
if(!pvr) throw std::logic_error("pvRecord is deleted");
|
||||||
|
if(pvr->getTraceLevel()>1)
|
||||||
{
|
{
|
||||||
cout << "ChannelProcessLocal::process";
|
cout << "ChannelProcessLocal::process";
|
||||||
cout << " nProcess " << nProcess << endl;
|
cout << " nProcess " << nProcess << endl;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
for(int i=0; i< nProcess; i++) {
|
for(int i=0; i< nProcess; i++) {
|
||||||
epicsGuard <PVRecord> guard(*pvRecord);
|
epicsGuard <PVRecord> guard(*pvr);
|
||||||
pvRecord->beginGroupPut();
|
pvr->beginGroupPut();
|
||||||
pvRecord->process();
|
pvr->process();
|
||||||
pvRecord->endGroupPut();
|
pvr->endGroupPut();
|
||||||
}
|
}
|
||||||
requester->processDone(Status::Ok,getPtrSelf());
|
requester->processDone(Status::Ok,getPtrSelf());
|
||||||
} catch(std::exception& ex) {
|
} catch(std::exception& ex) {
|
||||||
@ -201,13 +202,7 @@ class ChannelGetLocal :
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
POINTER_DEFINITIONS(ChannelGetLocal);
|
POINTER_DEFINITIONS(ChannelGetLocal);
|
||||||
virtual ~ChannelGetLocal()
|
virtual ~ChannelGetLocal();
|
||||||
{
|
|
||||||
if(pvRecord->getTraceLevel()>0)
|
|
||||||
{
|
|
||||||
cout << "~ChannelGetLocal()" << endl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
static ChannelGetLocalPtr create(
|
static ChannelGetLocalPtr create(
|
||||||
ChannelLocalPtr const &channelLocal,
|
ChannelLocalPtr const &channelLocal,
|
||||||
ChannelGetRequester::shared_pointer const & channelGetRequester,
|
ChannelGetRequester::shared_pointer const & channelGetRequester,
|
||||||
@ -215,12 +210,11 @@ public:
|
|||||||
PVRecordPtr const &pvRecord);
|
PVRecordPtr const &pvRecord);
|
||||||
virtual void get();
|
virtual void get();
|
||||||
virtual void destroy() EPICS_DEPRECATED {};
|
virtual void destroy() EPICS_DEPRECATED {};
|
||||||
virtual std::tr1::shared_ptr<Channel> getChannel()
|
virtual std::tr1::shared_ptr<Channel> getChannel();
|
||||||
{return channelLocal;}
|
|
||||||
virtual void cancel(){}
|
virtual void cancel(){}
|
||||||
|
virtual void lock();
|
||||||
|
virtual void unlock();
|
||||||
virtual void lastRequest() {}
|
virtual void lastRequest() {}
|
||||||
virtual void lock() {pvRecord->lock();}
|
|
||||||
virtual void unlock() {pvRecord->unlock();}
|
|
||||||
private:
|
private:
|
||||||
shared_pointer getPtrSelf()
|
shared_pointer getPtrSelf()
|
||||||
{
|
{
|
||||||
@ -247,12 +241,12 @@ private:
|
|||||||
}
|
}
|
||||||
bool firstTime;
|
bool firstTime;
|
||||||
bool callProcess;
|
bool callProcess;
|
||||||
ChannelLocalPtr channelLocal;
|
ChannelLocalWPtr channelLocal;
|
||||||
ChannelGetRequester::weak_pointer channelGetRequester;
|
ChannelGetRequester::weak_pointer channelGetRequester;
|
||||||
PVCopyPtr pvCopy;
|
PVCopyPtr pvCopy;
|
||||||
PVStructurePtr pvStructure;
|
PVStructurePtr pvStructure;
|
||||||
BitSetPtr bitSet;
|
BitSetPtr bitSet;
|
||||||
PVRecordPtr pvRecord;
|
PVRecordWPtr pvRecord;
|
||||||
Mutex mutex;
|
Mutex mutex;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -298,19 +292,48 @@ ChannelGetLocalPtr ChannelGetLocal::create(
|
|||||||
return get;
|
return get;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ChannelGetLocal::~ChannelGetLocal()
|
||||||
|
{
|
||||||
|
PVRecordPtr pvr(pvRecord.lock());
|
||||||
|
if(pvr && pvr->getTraceLevel()>0) {
|
||||||
|
cout << "~ChannelGetLocal() " << pvr->getRecordName() << endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::tr1::shared_ptr<Channel> ChannelGetLocal::getChannel()
|
||||||
|
{
|
||||||
|
ChannelLocalPtr channel(channelLocal.lock());
|
||||||
|
return channel;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ChannelGetLocal::lock()
|
||||||
|
{
|
||||||
|
PVRecordPtr pvr(pvRecord.lock());
|
||||||
|
if(!pvr) throw std::logic_error("pvRecord is deleted");
|
||||||
|
pvr->lock();
|
||||||
|
}
|
||||||
|
void ChannelGetLocal::unlock()
|
||||||
|
{
|
||||||
|
PVRecordPtr pvr(pvRecord.lock());
|
||||||
|
if(!pvr) throw std::logic_error("pvRecord is deleted");
|
||||||
|
pvr->unlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void ChannelGetLocal::get()
|
void ChannelGetLocal::get()
|
||||||
{
|
{
|
||||||
ChannelGetRequester::shared_pointer requester = channelGetRequester.lock();
|
ChannelGetRequester::shared_pointer requester = channelGetRequester.lock();
|
||||||
if(!requester) return;
|
if(!requester) return;
|
||||||
|
PVRecordPtr pvr(pvRecord.lock());
|
||||||
|
if(!pvr) throw std::logic_error("pvRecord is deleted");
|
||||||
try {
|
try {
|
||||||
bitSet->clear();
|
bitSet->clear();
|
||||||
{
|
{
|
||||||
epicsGuard <PVRecord> guard(*pvRecord);
|
epicsGuard <PVRecord> guard(*pvr);
|
||||||
if(callProcess) {
|
if(callProcess) {
|
||||||
pvRecord->beginGroupPut();
|
pvr->beginGroupPut();
|
||||||
pvRecord->process();
|
pvr->process();
|
||||||
pvRecord->endGroupPut();
|
pvr->endGroupPut();
|
||||||
}
|
}
|
||||||
pvCopy->updateCopySetBitSet(pvStructure, bitSet);
|
pvCopy->updateCopySetBitSet(pvStructure, bitSet);
|
||||||
}
|
}
|
||||||
@ -324,7 +347,7 @@ void ChannelGetLocal::get()
|
|||||||
getPtrSelf(),
|
getPtrSelf(),
|
||||||
pvStructure,
|
pvStructure,
|
||||||
bitSet);
|
bitSet);
|
||||||
if(pvRecord->getTraceLevel()>1)
|
if(pvr->getTraceLevel()>1)
|
||||||
{
|
{
|
||||||
cout << "ChannelGetLocal::get" << endl;
|
cout << "ChannelGetLocal::get" << endl;
|
||||||
}
|
}
|
||||||
@ -341,13 +364,7 @@ class ChannelPutLocal :
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
POINTER_DEFINITIONS(ChannelPutLocal);
|
POINTER_DEFINITIONS(ChannelPutLocal);
|
||||||
virtual ~ChannelPutLocal()
|
virtual ~ChannelPutLocal();
|
||||||
{
|
|
||||||
if(pvRecord->getTraceLevel()>0)
|
|
||||||
{
|
|
||||||
cout << "~ChannelPutLocal()" << endl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
static ChannelPutLocalPtr create(
|
static ChannelPutLocalPtr create(
|
||||||
ChannelLocalPtr const &channelLocal,
|
ChannelLocalPtr const &channelLocal,
|
||||||
ChannelPutRequester::shared_pointer const & channelPutRequester,
|
ChannelPutRequester::shared_pointer const & channelPutRequester,
|
||||||
@ -356,12 +373,11 @@ public:
|
|||||||
virtual void put(PVStructurePtr const &pvStructure,BitSetPtr const &bitSet);
|
virtual void put(PVStructurePtr const &pvStructure,BitSetPtr const &bitSet);
|
||||||
virtual void get();
|
virtual void get();
|
||||||
virtual void destroy() EPICS_DEPRECATED {};
|
virtual void destroy() EPICS_DEPRECATED {};
|
||||||
virtual std::tr1::shared_ptr<Channel> getChannel()
|
virtual std::tr1::shared_ptr<Channel> getChannel();
|
||||||
{return channelLocal;}
|
|
||||||
virtual void cancel(){}
|
virtual void cancel(){}
|
||||||
|
virtual void lock();
|
||||||
|
virtual void unlock();
|
||||||
virtual void lastRequest() {}
|
virtual void lastRequest() {}
|
||||||
virtual void lock() {pvRecord->lock();}
|
|
||||||
virtual void unlock() {pvRecord->unlock();}
|
|
||||||
private:
|
private:
|
||||||
shared_pointer getPtrSelf()
|
shared_pointer getPtrSelf()
|
||||||
{
|
{
|
||||||
@ -382,10 +398,10 @@ private:
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
bool callProcess;
|
bool callProcess;
|
||||||
ChannelLocalPtr channelLocal;
|
ChannelLocalWPtr channelLocal;
|
||||||
ChannelPutRequester::weak_pointer channelPutRequester;
|
ChannelPutRequester::weak_pointer channelPutRequester;
|
||||||
PVCopyPtr pvCopy;
|
PVCopyPtr pvCopy;
|
||||||
PVRecordPtr pvRecord;
|
PVRecordWPtr pvRecord;
|
||||||
Mutex mutex;
|
Mutex mutex;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -429,22 +445,52 @@ ChannelPutLocalPtr ChannelPutLocal::create(
|
|||||||
return put;
|
return put;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ChannelPutLocal::~ChannelPutLocal()
|
||||||
|
{
|
||||||
|
PVRecordPtr pvr(pvRecord.lock());
|
||||||
|
if(pvr && pvr->getTraceLevel()>0) {
|
||||||
|
cout << "~ChannelPutLocal() " << pvr->getRecordName() << endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::tr1::shared_ptr<Channel> ChannelPutLocal::getChannel()
|
||||||
|
{
|
||||||
|
ChannelLocalPtr channel(channelLocal.lock());
|
||||||
|
return channel;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ChannelPutLocal::lock()
|
||||||
|
{
|
||||||
|
PVRecordPtr pvr(pvRecord.lock());
|
||||||
|
if(!pvr) throw std::logic_error("pvRecord is deleted");
|
||||||
|
pvr->lock();
|
||||||
|
}
|
||||||
|
void ChannelPutLocal::unlock()
|
||||||
|
{
|
||||||
|
PVRecordPtr pvr(pvRecord.lock());
|
||||||
|
if(!pvr) throw std::logic_error("pvRecord is deleted");
|
||||||
|
pvr->unlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void ChannelPutLocal::get()
|
void ChannelPutLocal::get()
|
||||||
{
|
{
|
||||||
ChannelPutRequester::shared_pointer requester = channelPutRequester.lock();
|
ChannelPutRequester::shared_pointer requester = channelPutRequester.lock();
|
||||||
if(!requester) return;
|
if(!requester) return;
|
||||||
|
PVRecordPtr pvr(pvRecord.lock());
|
||||||
|
if(!pvr) throw std::logic_error("pvRecord is deleted");
|
||||||
try {
|
try {
|
||||||
PVStructurePtr pvStructure = pvCopy->createPVStructure();
|
PVStructurePtr pvStructure = pvCopy->createPVStructure();
|
||||||
BitSetPtr bitSet(new BitSet(pvStructure->getNumberFields()));
|
BitSetPtr bitSet(new BitSet(pvStructure->getNumberFields()));
|
||||||
bitSet->clear();
|
bitSet->clear();
|
||||||
bitSet->set(0);
|
bitSet->set(0);
|
||||||
{
|
{
|
||||||
epicsGuard <PVRecord> guard(*pvRecord);
|
epicsGuard <PVRecord> guard(*pvr);
|
||||||
pvCopy->updateCopyFromBitSet(pvStructure, bitSet);
|
pvCopy->updateCopyFromBitSet(pvStructure, bitSet);
|
||||||
}
|
}
|
||||||
requester->getDone(
|
requester->getDone(
|
||||||
Status::Ok,getPtrSelf(),pvStructure,bitSet);
|
Status::Ok,getPtrSelf(),pvStructure,bitSet);
|
||||||
if(pvRecord->getTraceLevel()>1)
|
if(pvr->getTraceLevel()>1)
|
||||||
{
|
{
|
||||||
cout << "ChannelPutLocal::get" << endl;
|
cout << "ChannelPutLocal::get" << endl;
|
||||||
}
|
}
|
||||||
@ -461,18 +507,20 @@ void ChannelPutLocal::put(
|
|||||||
{
|
{
|
||||||
ChannelPutRequester::shared_pointer requester = channelPutRequester.lock();
|
ChannelPutRequester::shared_pointer requester = channelPutRequester.lock();
|
||||||
if(!requester) return;
|
if(!requester) return;
|
||||||
|
PVRecordPtr pvr(pvRecord.lock());
|
||||||
|
if(!pvr) throw std::logic_error("pvRecord is deleted");
|
||||||
try {
|
try {
|
||||||
{
|
{
|
||||||
epicsGuard <PVRecord> guard(*pvRecord);
|
epicsGuard <PVRecord> guard(*pvr);
|
||||||
pvRecord->beginGroupPut();
|
pvr->beginGroupPut();
|
||||||
pvCopy->updateMaster(pvStructure, bitSet);
|
pvCopy->updateMaster(pvStructure, bitSet);
|
||||||
if(callProcess) {
|
if(callProcess) {
|
||||||
pvRecord->process();
|
pvr->process();
|
||||||
}
|
}
|
||||||
pvRecord->endGroupPut();
|
pvr->endGroupPut();
|
||||||
}
|
}
|
||||||
requester->putDone(Status::Ok,getPtrSelf());
|
requester->putDone(Status::Ok,getPtrSelf());
|
||||||
if(pvRecord->getTraceLevel()>1)
|
if(pvr->getTraceLevel()>1)
|
||||||
{
|
{
|
||||||
cout << "ChannelPutLocal::put" << endl;
|
cout << "ChannelPutLocal::put" << endl;
|
||||||
}
|
}
|
||||||
@ -489,13 +537,7 @@ class ChannelPutGetLocal :
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
POINTER_DEFINITIONS(ChannelPutGetLocal);
|
POINTER_DEFINITIONS(ChannelPutGetLocal);
|
||||||
virtual ~ChannelPutGetLocal()
|
virtual ~ChannelPutGetLocal();
|
||||||
{
|
|
||||||
if(pvRecord->getTraceLevel()>0)
|
|
||||||
{
|
|
||||||
cout << "~ChannelPutGetLocal()" << endl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
static ChannelPutGetLocalPtr create(
|
static ChannelPutGetLocalPtr create(
|
||||||
ChannelLocalPtr const &channelLocal,
|
ChannelLocalPtr const &channelLocal,
|
||||||
ChannelPutGetRequester::shared_pointer const & channelPutGetRequester,
|
ChannelPutGetRequester::shared_pointer const & channelPutGetRequester,
|
||||||
@ -507,12 +549,11 @@ public:
|
|||||||
virtual void getPut();
|
virtual void getPut();
|
||||||
virtual void getGet();
|
virtual void getGet();
|
||||||
virtual void destroy() EPICS_DEPRECATED {};
|
virtual void destroy() EPICS_DEPRECATED {};
|
||||||
virtual std::tr1::shared_ptr<Channel> getChannel()
|
virtual std::tr1::shared_ptr<Channel> getChannel();
|
||||||
{return channelLocal;}
|
|
||||||
virtual void cancel(){}
|
virtual void cancel(){}
|
||||||
|
virtual void lock();
|
||||||
|
virtual void unlock();
|
||||||
virtual void lastRequest() {}
|
virtual void lastRequest() {}
|
||||||
virtual void lock() {pvRecord->lock();}
|
|
||||||
virtual void unlock() {pvRecord->unlock();}
|
|
||||||
private:
|
private:
|
||||||
shared_pointer getPtrSelf()
|
shared_pointer getPtrSelf()
|
||||||
{
|
{
|
||||||
@ -539,13 +580,13 @@ private:
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
bool callProcess;
|
bool callProcess;
|
||||||
ChannelLocalPtr channelLocal;
|
ChannelLocalWPtr channelLocal;
|
||||||
ChannelPutGetRequester::weak_pointer channelPutGetRequester;
|
ChannelPutGetRequester::weak_pointer channelPutGetRequester;
|
||||||
PVCopyPtr pvPutCopy;
|
PVCopyPtr pvPutCopy;
|
||||||
PVCopyPtr pvGetCopy;
|
PVCopyPtr pvGetCopy;
|
||||||
PVStructurePtr pvGetStructure;
|
PVStructurePtr pvGetStructure;
|
||||||
BitSetPtr getBitSet;
|
BitSetPtr getBitSet;
|
||||||
PVRecordPtr pvRecord;
|
PVRecordWPtr pvRecord;
|
||||||
Mutex mutex;
|
Mutex mutex;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -597,25 +638,54 @@ ChannelPutGetLocalPtr ChannelPutGetLocal::create(
|
|||||||
return putGet;
|
return putGet;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ChannelPutGetLocal::~ChannelPutGetLocal()
|
||||||
|
{
|
||||||
|
PVRecordPtr pvr(pvRecord.lock());
|
||||||
|
if(pvr && pvr->getTraceLevel()>0) {
|
||||||
|
cout << "~ChannelPutGetLocal() " << pvr->getRecordName() << endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::tr1::shared_ptr<Channel> ChannelPutGetLocal::getChannel()
|
||||||
|
{
|
||||||
|
ChannelLocalPtr channel(channelLocal.lock());
|
||||||
|
return channel;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ChannelPutGetLocal::lock()
|
||||||
|
{
|
||||||
|
PVRecordPtr pvr(pvRecord.lock());
|
||||||
|
if(!pvr) throw std::logic_error("pvRecord is deleted");
|
||||||
|
pvr->lock();
|
||||||
|
}
|
||||||
|
void ChannelPutGetLocal::unlock()
|
||||||
|
{
|
||||||
|
PVRecordPtr pvr(pvRecord.lock());
|
||||||
|
if(!pvr) throw std::logic_error("pvRecord is deleted");
|
||||||
|
pvr->unlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void ChannelPutGetLocal::putGet(
|
void ChannelPutGetLocal::putGet(
|
||||||
PVStructurePtr const &pvPutStructure,BitSetPtr const &putBitSet)
|
PVStructurePtr const &pvPutStructure,BitSetPtr const &putBitSet)
|
||||||
{
|
{
|
||||||
ChannelPutGetRequester::shared_pointer requester = channelPutGetRequester.lock();
|
ChannelPutGetRequester::shared_pointer requester = channelPutGetRequester.lock();
|
||||||
if(!requester) return;
|
if(!requester) return;
|
||||||
|
PVRecordPtr pvr(pvRecord.lock());
|
||||||
|
if(!pvr) throw std::logic_error("pvRecord is deleted");
|
||||||
try {
|
try {
|
||||||
{
|
{
|
||||||
epicsGuard <PVRecord> guard(*pvRecord);
|
epicsGuard <PVRecord> guard(*pvr);
|
||||||
pvRecord->beginGroupPut();
|
pvr->beginGroupPut();
|
||||||
pvPutCopy->updateMaster(pvPutStructure, putBitSet);
|
pvPutCopy->updateMaster(pvPutStructure, putBitSet);
|
||||||
if(callProcess) pvRecord->process();
|
if(callProcess) pvr->process();
|
||||||
getBitSet->clear();
|
getBitSet->clear();
|
||||||
pvGetCopy->updateCopySetBitSet(pvGetStructure, getBitSet);
|
pvGetCopy->updateCopySetBitSet(pvGetStructure, getBitSet);
|
||||||
pvRecord->endGroupPut();
|
pvr->endGroupPut();
|
||||||
}
|
}
|
||||||
requester->putGetDone(
|
requester->putGetDone(
|
||||||
Status::Ok,getPtrSelf(),pvGetStructure,getBitSet);
|
Status::Ok,getPtrSelf(),pvGetStructure,getBitSet);
|
||||||
if(pvRecord->getTraceLevel()>1)
|
if(pvr->getTraceLevel()>1)
|
||||||
{
|
{
|
||||||
cout << "ChannelPutGetLocal::putGet" << endl;
|
cout << "ChannelPutGetLocal::putGet" << endl;
|
||||||
}
|
}
|
||||||
@ -629,16 +699,18 @@ void ChannelPutGetLocal::getPut()
|
|||||||
{
|
{
|
||||||
ChannelPutGetRequester::shared_pointer requester = channelPutGetRequester.lock();
|
ChannelPutGetRequester::shared_pointer requester = channelPutGetRequester.lock();
|
||||||
if(!requester) return;
|
if(!requester) return;
|
||||||
|
PVRecordPtr pvr(pvRecord.lock());
|
||||||
|
if(!pvr) throw std::logic_error("pvRecord is deleted");
|
||||||
try {
|
try {
|
||||||
PVStructurePtr pvPutStructure = pvPutCopy->createPVStructure();
|
PVStructurePtr pvPutStructure = pvPutCopy->createPVStructure();
|
||||||
BitSetPtr putBitSet(new BitSet(pvPutStructure->getNumberFields()));
|
BitSetPtr putBitSet(new BitSet(pvPutStructure->getNumberFields()));
|
||||||
{
|
{
|
||||||
epicsGuard <PVRecord> guard(*pvRecord);
|
epicsGuard <PVRecord> guard(*pvr);
|
||||||
pvPutCopy->initCopy(pvPutStructure, putBitSet);
|
pvPutCopy->initCopy(pvPutStructure, putBitSet);
|
||||||
}
|
}
|
||||||
requester->getPutDone(
|
requester->getPutDone(
|
||||||
Status::Ok,getPtrSelf(),pvPutStructure,putBitSet);
|
Status::Ok,getPtrSelf(),pvPutStructure,putBitSet);
|
||||||
if(pvRecord->getTraceLevel()>1)
|
if(pvr->getTraceLevel()>1)
|
||||||
{
|
{
|
||||||
cout << "ChannelPutGetLocal::getPut" << endl;
|
cout << "ChannelPutGetLocal::getPut" << endl;
|
||||||
}
|
}
|
||||||
@ -654,15 +726,17 @@ void ChannelPutGetLocal::getGet()
|
|||||||
{
|
{
|
||||||
ChannelPutGetRequester::shared_pointer requester = channelPutGetRequester.lock();
|
ChannelPutGetRequester::shared_pointer requester = channelPutGetRequester.lock();
|
||||||
if(!requester) return;
|
if(!requester) return;
|
||||||
|
PVRecordPtr pvr(pvRecord.lock());
|
||||||
|
if(!pvr) throw std::logic_error("pvRecord is deleted");
|
||||||
try {
|
try {
|
||||||
getBitSet->clear();
|
getBitSet->clear();
|
||||||
{
|
{
|
||||||
epicsGuard <PVRecord> guard(*pvRecord);
|
epicsGuard <PVRecord> guard(*pvr);
|
||||||
pvGetCopy->updateCopySetBitSet(pvGetStructure, getBitSet);
|
pvGetCopy->updateCopySetBitSet(pvGetStructure, getBitSet);
|
||||||
}
|
}
|
||||||
requester->getGetDone(
|
requester->getGetDone(
|
||||||
Status::Ok,getPtrSelf(),pvGetStructure,getBitSet);
|
Status::Ok,getPtrSelf(),pvGetStructure,getBitSet);
|
||||||
if(pvRecord->getTraceLevel()>1)
|
if(pvr->getTraceLevel()>1)
|
||||||
{
|
{
|
||||||
cout << "ChannelPutGetLocal::getGet" << endl;
|
cout << "ChannelPutGetLocal::getGet" << endl;
|
||||||
}
|
}
|
||||||
@ -696,19 +770,11 @@ public:
|
|||||||
channelLocal(channelLocal),
|
channelLocal(channelLocal),
|
||||||
channelRPCRequester(channelRPCRequester),
|
channelRPCRequester(channelRPCRequester),
|
||||||
service(service),
|
service(service),
|
||||||
pvRecord(pvRecord),
|
pvRecord(pvRecord)
|
||||||
isLastRequest()
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ~ChannelRPCLocal()
|
virtual ~ChannelRPCLocal();
|
||||||
{
|
|
||||||
if(pvRecord->getTraceLevel()>0)
|
|
||||||
{
|
|
||||||
cout << "~ChannelRPCLocal()" << endl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void processRequest(RPCService::shared_pointer const & service,
|
void processRequest(RPCService::shared_pointer const & service,
|
||||||
PVStructurePtr const & pvArgument);
|
PVStructurePtr const & pvArgument);
|
||||||
|
|
||||||
@ -724,37 +790,21 @@ public:
|
|||||||
PVStructurePtr const & pvArgument);
|
PVStructurePtr const & pvArgument);
|
||||||
|
|
||||||
virtual void request(PVStructurePtr const & pvArgument);
|
virtual void request(PVStructurePtr const & pvArgument);
|
||||||
|
virtual Channel::shared_pointer getChannel();
|
||||||
void lastRequest()
|
|
||||||
{
|
|
||||||
isLastRequest.set();
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual Channel::shared_pointer getChannel()
|
|
||||||
{
|
|
||||||
return channelLocal;
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void cancel() {}
|
virtual void cancel() {}
|
||||||
|
|
||||||
virtual void destroy() EPICS_DEPRECATED {};
|
virtual void destroy() EPICS_DEPRECATED {};
|
||||||
|
|
||||||
virtual void lock() {}
|
virtual void lock() {}
|
||||||
|
|
||||||
virtual void unlock() {}
|
virtual void unlock() {}
|
||||||
|
virtual void lastRequest() {}
|
||||||
private:
|
private:
|
||||||
|
|
||||||
shared_pointer getPtrSelf()
|
shared_pointer getPtrSelf()
|
||||||
{
|
{
|
||||||
return shared_from_this();
|
return shared_from_this();
|
||||||
}
|
}
|
||||||
|
ChannelLocalWPtr channelLocal;
|
||||||
ChannelLocalPtr channelLocal;
|
|
||||||
ChannelRPCRequester::weak_pointer channelRPCRequester;
|
ChannelRPCRequester::weak_pointer channelRPCRequester;
|
||||||
RPCServiceAsync::shared_pointer service;
|
RPCServiceAsync::shared_pointer service;
|
||||||
PVRecordPtr pvRecord;
|
PVRecordWPtr pvRecord;
|
||||||
AtomicBoolean isLastRequest;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
ChannelRPCLocalPtr ChannelRPCLocal::create(
|
ChannelRPCLocalPtr ChannelRPCLocal::create(
|
||||||
@ -788,6 +838,21 @@ ChannelRPCLocalPtr ChannelRPCLocal::create(
|
|||||||
return rpc;
|
return rpc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ChannelRPCLocal::~ChannelRPCLocal()
|
||||||
|
{
|
||||||
|
PVRecordPtr pvr(pvRecord.lock());
|
||||||
|
if(pvr && pvr->getTraceLevel()>0) {
|
||||||
|
cout << "~ChannelRPCLocal() " << pvr->getRecordName() << endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::tr1::shared_ptr<Channel> ChannelRPCLocal::getChannel()
|
||||||
|
{
|
||||||
|
ChannelLocalPtr channel(channelLocal.lock());
|
||||||
|
return channel;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void ChannelRPCLocal::processRequest(
|
void ChannelRPCLocal::processRequest(
|
||||||
RPCService::shared_pointer const & service,
|
RPCService::shared_pointer const & service,
|
||||||
PVStructurePtr const & pvArgument)
|
PVStructurePtr const & pvArgument)
|
||||||
@ -823,9 +888,6 @@ void ChannelRPCLocal::processRequest(
|
|||||||
}
|
}
|
||||||
ChannelRPCRequester::shared_pointer requester = channelRPCRequester.lock();
|
ChannelRPCRequester::shared_pointer requester = channelRPCRequester.lock();
|
||||||
if(requester) requester->requestDone(status, getPtrSelf(), result);
|
if(requester) requester->requestDone(status, getPtrSelf(), result);
|
||||||
|
|
||||||
if (isLastRequest.get())
|
|
||||||
destroy();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChannelRPCLocal::processRequest(
|
void ChannelRPCLocal::processRequest(
|
||||||
@ -842,8 +904,6 @@ void ChannelRPCLocal::processRequest(
|
|||||||
Status errorStatus(Status::STATUSTYPE_FATAL, ex.what());
|
Status errorStatus(Status::STATUSTYPE_FATAL, ex.what());
|
||||||
ChannelRPCRequester::shared_pointer requester = channelRPCRequester.lock();
|
ChannelRPCRequester::shared_pointer requester = channelRPCRequester.lock();
|
||||||
if(requester) requester->requestDone(errorStatus, getPtrSelf(), PVStructurePtr());
|
if(requester) requester->requestDone(errorStatus, getPtrSelf(), PVStructurePtr());
|
||||||
if (isLastRequest.get())
|
|
||||||
destroy();
|
|
||||||
}
|
}
|
||||||
catch (...)
|
catch (...)
|
||||||
{
|
{
|
||||||
@ -852,9 +912,6 @@ void ChannelRPCLocal::processRequest(
|
|||||||
"Unexpected exception caught while calling RPCServiceAsync.request(PVStructure, RPCResponseCallback).");
|
"Unexpected exception caught while calling RPCServiceAsync.request(PVStructure, RPCResponseCallback).");
|
||||||
ChannelRPCRequester::shared_pointer requester = channelRPCRequester.lock();
|
ChannelRPCRequester::shared_pointer requester = channelRPCRequester.lock();
|
||||||
if(requester) requester->requestDone(errorStatus, shared_from_this(), PVStructurePtr());
|
if(requester) requester->requestDone(errorStatus, shared_from_this(), PVStructurePtr());
|
||||||
|
|
||||||
if (isLastRequest.get())
|
|
||||||
destroy();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// we wait for callback to be called
|
// we wait for callback to be called
|
||||||
@ -863,9 +920,9 @@ void ChannelRPCLocal::processRequest(
|
|||||||
|
|
||||||
void ChannelRPCLocal::request(PVStructurePtr const & pvArgument)
|
void ChannelRPCLocal::request(PVStructurePtr const & pvArgument)
|
||||||
{
|
{
|
||||||
if(pvRecord->getTraceLevel()>1)
|
PVRecordPtr pvr(pvRecord.lock());
|
||||||
{
|
if(pvr && pvr->getTraceLevel()>0) {
|
||||||
cout << "ChannelRPCLocal::request" << endl;
|
cout << "ChannelRPCLocal::request " << pvr->getRecordName() << endl;
|
||||||
}
|
}
|
||||||
RPCService::shared_pointer rpcService =
|
RPCService::shared_pointer rpcService =
|
||||||
std::tr1::dynamic_pointer_cast<RPCService>(service);
|
std::tr1::dynamic_pointer_cast<RPCService>(service);
|
||||||
@ -893,13 +950,7 @@ class ChannelArrayLocal :
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
POINTER_DEFINITIONS(ChannelArrayLocal);
|
POINTER_DEFINITIONS(ChannelArrayLocal);
|
||||||
virtual ~ChannelArrayLocal()
|
virtual ~ChannelArrayLocal();
|
||||||
{
|
|
||||||
if(pvRecord->getTraceLevel()>0)
|
|
||||||
{
|
|
||||||
cout << "~ChannelArrayLocal()" << endl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
static ChannelArrayLocalPtr create(
|
static ChannelArrayLocalPtr create(
|
||||||
ChannelLocalPtr const &channelLocal,
|
ChannelLocalPtr const &channelLocal,
|
||||||
ChannelArrayRequester::shared_pointer const & channelArrayRequester,
|
ChannelArrayRequester::shared_pointer const & channelArrayRequester,
|
||||||
@ -912,12 +963,11 @@ public:
|
|||||||
virtual void getLength();
|
virtual void getLength();
|
||||||
virtual void setLength(size_t length);
|
virtual void setLength(size_t length);
|
||||||
virtual void destroy() EPICS_DEPRECATED {};
|
virtual void destroy() EPICS_DEPRECATED {};
|
||||||
virtual std::tr1::shared_ptr<Channel> getChannel()
|
virtual std::tr1::shared_ptr<Channel> getChannel();
|
||||||
{return channelLocal;}
|
|
||||||
virtual void cancel(){}
|
virtual void cancel(){}
|
||||||
|
virtual void lock();
|
||||||
|
virtual void unlock();
|
||||||
virtual void lastRequest() {}
|
virtual void lastRequest() {}
|
||||||
virtual void lock() {pvRecord->lock();}
|
|
||||||
virtual void unlock() {pvRecord->unlock();}
|
|
||||||
private:
|
private:
|
||||||
shared_pointer getPtrSelf()
|
shared_pointer getPtrSelf()
|
||||||
{
|
{
|
||||||
@ -938,11 +988,11 @@ private:
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
ChannelLocalPtr channelLocal;
|
ChannelLocalWPtr channelLocal;
|
||||||
ChannelArrayRequester::weak_pointer channelArrayRequester;
|
ChannelArrayRequester::weak_pointer channelArrayRequester;
|
||||||
PVArrayPtr pvArray;
|
PVArrayPtr pvArray;
|
||||||
PVArrayPtr pvCopy;
|
PVArrayPtr pvCopy;
|
||||||
PVRecordPtr pvRecord;
|
PVRecordWPtr pvRecord;
|
||||||
Mutex mutex;
|
Mutex mutex;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -1030,19 +1080,47 @@ ChannelArrayLocalPtr ChannelArrayLocal::create(
|
|||||||
return array;
|
return array;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ChannelArrayLocal::~ChannelArrayLocal()
|
||||||
|
{
|
||||||
|
PVRecordPtr pvr(pvRecord.lock());
|
||||||
|
if(pvr && pvr->getTraceLevel()>0) {
|
||||||
|
cout << "~ChannelArrayLocal() " << pvr->getRecordName() << endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::tr1::shared_ptr<Channel> ChannelArrayLocal::getChannel()
|
||||||
|
{
|
||||||
|
ChannelLocalPtr channel(channelLocal.lock());
|
||||||
|
return channel;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ChannelArrayLocal::lock()
|
||||||
|
{
|
||||||
|
PVRecordPtr pvr(pvRecord.lock());
|
||||||
|
if(!pvr) throw std::logic_error("pvRecord is deleted");
|
||||||
|
pvr->lock();
|
||||||
|
}
|
||||||
|
void ChannelArrayLocal::unlock()
|
||||||
|
{
|
||||||
|
PVRecordPtr pvr(pvRecord.lock());
|
||||||
|
if(!pvr) throw std::logic_error("pvRecord is deleted");
|
||||||
|
pvr->unlock();
|
||||||
|
}
|
||||||
|
|
||||||
void ChannelArrayLocal::getArray(size_t offset, size_t count, size_t stride)
|
void ChannelArrayLocal::getArray(size_t offset, size_t count, size_t stride)
|
||||||
{
|
{
|
||||||
ChannelArrayRequester::shared_pointer requester = channelArrayRequester.lock();
|
ChannelArrayRequester::shared_pointer requester = channelArrayRequester.lock();
|
||||||
if(!requester) return;
|
if(!requester) return;
|
||||||
|
PVRecordPtr pvr(pvRecord.lock());
|
||||||
if(pvRecord->getTraceLevel()>1)
|
if(!pvr) throw std::logic_error("pvRecord is deleted");
|
||||||
|
if(pvr->getTraceLevel()>1)
|
||||||
{
|
{
|
||||||
cout << "ChannelArrayLocal::getArray" << endl;
|
cout << "ChannelArrayLocal::getArray" << endl;
|
||||||
}
|
}
|
||||||
const char *exceptionMessage = NULL;
|
const char *exceptionMessage = NULL;
|
||||||
try {
|
try {
|
||||||
bool ok = false;
|
bool ok = false;
|
||||||
epicsGuard <PVRecord> guard(*pvRecord);
|
epicsGuard <PVRecord> guard(*pvr);
|
||||||
while(true) {
|
while(true) {
|
||||||
size_t length = pvArray->getLength();
|
size_t length = pvArray->getLength();
|
||||||
if(length<=0) break;
|
if(length<=0) break;
|
||||||
@ -1075,8 +1153,9 @@ void ChannelArrayLocal::putArray(
|
|||||||
{
|
{
|
||||||
ChannelArrayRequester::shared_pointer requester = channelArrayRequester.lock();
|
ChannelArrayRequester::shared_pointer requester = channelArrayRequester.lock();
|
||||||
if(!requester) return;
|
if(!requester) return;
|
||||||
|
PVRecordPtr pvr(pvRecord.lock());
|
||||||
if(pvRecord->getTraceLevel()>1)
|
if(!pvr) throw std::logic_error("pvRecord is deleted");
|
||||||
|
if(pvr->getTraceLevel()>1)
|
||||||
{
|
{
|
||||||
cout << "ChannelArrayLocal::putArray" << endl;
|
cout << "ChannelArrayLocal::putArray" << endl;
|
||||||
}
|
}
|
||||||
@ -1084,7 +1163,7 @@ void ChannelArrayLocal::putArray(
|
|||||||
if(newLength<pvArray->getLength()) pvArray->setLength(newLength);
|
if(newLength<pvArray->getLength()) pvArray->setLength(newLength);
|
||||||
const char *exceptionMessage = NULL;
|
const char *exceptionMessage = NULL;
|
||||||
try {
|
try {
|
||||||
epicsGuard <PVRecord> guard(*pvRecord);
|
epicsGuard <PVRecord> guard(*pvr);
|
||||||
copy(pvArray,0,1,this->pvArray,offset,stride,count);
|
copy(pvArray,0,1,this->pvArray,offset,stride,count);
|
||||||
} catch(std::exception e) {
|
} catch(std::exception e) {
|
||||||
exceptionMessage = e.what();
|
exceptionMessage = e.what();
|
||||||
@ -1100,10 +1179,12 @@ void ChannelArrayLocal::getLength()
|
|||||||
{
|
{
|
||||||
ChannelArrayRequester::shared_pointer requester = channelArrayRequester.lock();
|
ChannelArrayRequester::shared_pointer requester = channelArrayRequester.lock();
|
||||||
if(!requester) return;
|
if(!requester) return;
|
||||||
|
PVRecordPtr pvr(pvRecord.lock());
|
||||||
|
if(!pvr) throw std::logic_error("pvRecord is deleted");
|
||||||
size_t length = 0;
|
size_t length = 0;
|
||||||
const char *exceptionMessage = NULL;
|
const char *exceptionMessage = NULL;
|
||||||
try {
|
try {
|
||||||
epicsGuard <PVRecord> guard(*pvRecord);
|
epicsGuard <PVRecord> guard(*pvr);
|
||||||
length = pvArray->getLength();
|
length = pvArray->getLength();
|
||||||
} catch(std::exception e) {
|
} catch(std::exception e) {
|
||||||
exceptionMessage = e.what();
|
exceptionMessage = e.what();
|
||||||
@ -1119,14 +1200,15 @@ void ChannelArrayLocal::setLength(size_t length)
|
|||||||
{
|
{
|
||||||
ChannelArrayRequester::shared_pointer requester = channelArrayRequester.lock();
|
ChannelArrayRequester::shared_pointer requester = channelArrayRequester.lock();
|
||||||
if(!requester) return;
|
if(!requester) return;
|
||||||
|
PVRecordPtr pvr(pvRecord.lock());
|
||||||
if(pvRecord->getTraceLevel()>1)
|
if(!pvr) throw std::logic_error("pvRecord is deleted");
|
||||||
|
if(pvr->getTraceLevel()>1)
|
||||||
{
|
{
|
||||||
cout << "ChannelArrayLocal::setLength" << endl;
|
cout << "ChannelArrayLocal::setLength" << endl;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
{
|
{
|
||||||
epicsGuard <PVRecord> guard(*pvRecord);
|
epicsGuard <PVRecord> guard(*pvr);
|
||||||
if(pvArray->getLength()!=length) pvArray->setLength(length);
|
if(pvArray->getLength()!=length) pvArray->setLength(length);
|
||||||
}
|
}
|
||||||
requester->setLengthDone(Status::Ok,getPtrSelf());
|
requester->setLengthDone(Status::Ok,getPtrSelf());
|
||||||
@ -1157,13 +1239,18 @@ ChannelLocal::ChannelLocal(
|
|||||||
|
|
||||||
ChannelLocal::~ChannelLocal()
|
ChannelLocal::~ChannelLocal()
|
||||||
{
|
{
|
||||||
if(pvRecord->getTraceLevel()>0)
|
PVRecordPtr pvr(pvRecord.lock());
|
||||||
|
if(!pvr) return;
|
||||||
|
if(pvr->getTraceLevel()>0)
|
||||||
{
|
{
|
||||||
cout << "~ChannelLocal()" << endl;
|
cout << "~ChannelLocal()" << endl;
|
||||||
}
|
}
|
||||||
pvRecord->removePVRecordClient(getPtrSelf());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ChannelProvider::shared_pointer ChannelLocal::getProvider()
|
||||||
|
{
|
||||||
|
return provider.lock();
|
||||||
|
}
|
||||||
|
|
||||||
void ChannelLocal::detach(PVRecordPtr const & pvRecord)
|
void ChannelLocal::detach(PVRecordPtr const & pvRecord)
|
||||||
{
|
{
|
||||||
@ -1180,9 +1267,10 @@ void ChannelLocal::detach(PVRecordPtr const & pvRecord)
|
|||||||
|
|
||||||
string ChannelLocal::getRequesterName()
|
string ChannelLocal::getRequesterName()
|
||||||
{
|
{
|
||||||
if(pvRecord->getTraceLevel()>1) {
|
PVRecordPtr pvr(pvRecord.lock());
|
||||||
|
if(pvr && pvr->getTraceLevel()>0) {
|
||||||
cout << "ChannelLocal::getRequesterName() "
|
cout << "ChannelLocal::getRequesterName() "
|
||||||
<< " recordName " << pvRecord->getRecordName()
|
<< " recordName " << pvr->getRecordName()
|
||||||
<< " requester exists " << (requester ? "true" : "false")
|
<< " requester exists " << (requester ? "true" : "false")
|
||||||
<< endl;
|
<< endl;
|
||||||
}
|
}
|
||||||
@ -1195,9 +1283,10 @@ void ChannelLocal::message(
|
|||||||
string const &message,
|
string const &message,
|
||||||
MessageType messageType)
|
MessageType messageType)
|
||||||
{
|
{
|
||||||
if(pvRecord->getTraceLevel()>1) {
|
PVRecordPtr pvr(pvRecord.lock());
|
||||||
|
if(pvr && pvr->getTraceLevel()>1) {
|
||||||
cout << "ChannelLocal::message() "
|
cout << "ChannelLocal::message() "
|
||||||
<< " recordName " << pvRecord->getRecordName()
|
<< " recordName " << pvr->getRecordName()
|
||||||
<< " requester exists " << (requester ? "true" : "false")
|
<< " requester exists " << (requester ? "true" : "false")
|
||||||
<< endl;
|
<< endl;
|
||||||
}
|
}
|
||||||
@ -1205,7 +1294,9 @@ void ChannelLocal::message(
|
|||||||
requester->message(message,messageType);
|
requester->message(message,messageType);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
cout << pvRecord->getRecordName()
|
string recordName("record deleted");
|
||||||
|
if(pvr) recordName = pvr->getRecordName();
|
||||||
|
cout << recordName
|
||||||
<< " message " << message
|
<< " message " << message
|
||||||
<< " messageType " << getMessageTypeName(messageType)
|
<< " messageType " << getMessageTypeName(messageType)
|
||||||
<< endl;
|
<< endl;
|
||||||
@ -1223,7 +1314,10 @@ Channel::ConnectionState ChannelLocal::getConnectionState()
|
|||||||
|
|
||||||
string ChannelLocal::getChannelName()
|
string ChannelLocal::getChannelName()
|
||||||
{
|
{
|
||||||
return pvRecord->getRecordName();
|
PVRecordPtr pvr(pvRecord.lock());
|
||||||
|
string name("record deleted");
|
||||||
|
if(pvr) name = pvr->getRecordName();
|
||||||
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
ChannelRequester::shared_pointer ChannelLocal::getChannelRequester()
|
ChannelRequester::shared_pointer ChannelLocal::getChannelRequester()
|
||||||
@ -1239,14 +1333,16 @@ bool ChannelLocal::isConnected()
|
|||||||
void ChannelLocal::getField(GetFieldRequester::shared_pointer const &requester,
|
void ChannelLocal::getField(GetFieldRequester::shared_pointer const &requester,
|
||||||
string const &subField)
|
string const &subField)
|
||||||
{
|
{
|
||||||
|
PVRecordPtr pvr(pvRecord.lock());
|
||||||
|
if(!pvr) throw std::logic_error("pvRecord is deleted");
|
||||||
if(subField.size()<1) {
|
if(subField.size()<1) {
|
||||||
StructureConstPtr structure =
|
StructureConstPtr structure =
|
||||||
pvRecord->getPVRecordStructure()->getPVStructure()->getStructure();
|
pvr->getPVRecordStructure()->getPVStructure()->getStructure();
|
||||||
requester->getDone(Status::Ok,structure);
|
requester->getDone(Status::Ok,structure);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
PVFieldPtr pvField =
|
PVFieldPtr pvField =
|
||||||
pvRecord->getPVRecordStructure()->getPVStructure()->getSubField(subField);
|
pvr->getPVRecordStructure()->getPVStructure()->getSubField(subField);
|
||||||
if(pvField) {
|
if(pvField) {
|
||||||
requester->getDone(Status::Ok,pvField->getField());
|
requester->getDone(Status::Ok,pvField->getField());
|
||||||
return;
|
return;
|
||||||
@ -1266,9 +1362,11 @@ ChannelProcess::shared_pointer ChannelLocal::createChannelProcess(
|
|||||||
ChannelProcessRequester::shared_pointer const & channelProcessRequester,
|
ChannelProcessRequester::shared_pointer const & channelProcessRequester,
|
||||||
PVStructure::shared_pointer const & pvRequest)
|
PVStructure::shared_pointer const & pvRequest)
|
||||||
{
|
{
|
||||||
if(pvRecord->getTraceLevel()>0) {
|
PVRecordPtr pvr(pvRecord.lock());
|
||||||
|
if(!pvr) throw std::logic_error("pvRecord is deleted");
|
||||||
|
if(pvr->getTraceLevel()>0) {
|
||||||
cout << "ChannelLocal::createChannelProcess() "
|
cout << "ChannelLocal::createChannelProcess() "
|
||||||
<< " recordName " << pvRecord->getRecordName()
|
<< " recordName " << pvr->getRecordName()
|
||||||
<< " requester exists " << (requester ? "true" : "false")
|
<< " requester exists " << (requester ? "true" : "false")
|
||||||
<< endl;
|
<< endl;
|
||||||
}
|
}
|
||||||
@ -1277,7 +1375,7 @@ ChannelProcess::shared_pointer ChannelLocal::createChannelProcess(
|
|||||||
getPtrSelf(),
|
getPtrSelf(),
|
||||||
channelProcessRequester,
|
channelProcessRequester,
|
||||||
pvRequest,
|
pvRequest,
|
||||||
pvRecord);
|
pvr);
|
||||||
return channelProcess;
|
return channelProcess;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1285,9 +1383,11 @@ ChannelGet::shared_pointer ChannelLocal::createChannelGet(
|
|||||||
ChannelGetRequester::shared_pointer const &channelGetRequester,
|
ChannelGetRequester::shared_pointer const &channelGetRequester,
|
||||||
PVStructure::shared_pointer const &pvRequest)
|
PVStructure::shared_pointer const &pvRequest)
|
||||||
{
|
{
|
||||||
if(pvRecord->getTraceLevel()>0) {
|
PVRecordPtr pvr(pvRecord.lock());
|
||||||
|
if(!pvr) throw std::logic_error("pvRecord is deleted");
|
||||||
|
if(pvr->getTraceLevel()>0) {
|
||||||
cout << "ChannelLocal::createChannelGet() "
|
cout << "ChannelLocal::createChannelGet() "
|
||||||
<< " recordName " << pvRecord->getRecordName()
|
<< " recordName " << pvr->getRecordName()
|
||||||
<< " requester exists " << (requester ? "true" : "false")
|
<< " requester exists " << (requester ? "true" : "false")
|
||||||
<< endl;
|
<< endl;
|
||||||
}
|
}
|
||||||
@ -1296,7 +1396,7 @@ ChannelGet::shared_pointer ChannelLocal::createChannelGet(
|
|||||||
getPtrSelf(),
|
getPtrSelf(),
|
||||||
channelGetRequester,
|
channelGetRequester,
|
||||||
pvRequest,
|
pvRequest,
|
||||||
pvRecord);
|
pvr);
|
||||||
return channelGet;
|
return channelGet;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1304,9 +1404,11 @@ ChannelPut::shared_pointer ChannelLocal::createChannelPut(
|
|||||||
ChannelPutRequester::shared_pointer const &channelPutRequester,
|
ChannelPutRequester::shared_pointer const &channelPutRequester,
|
||||||
PVStructure::shared_pointer const &pvRequest)
|
PVStructure::shared_pointer const &pvRequest)
|
||||||
{
|
{
|
||||||
if(pvRecord->getTraceLevel()>0) {
|
PVRecordPtr pvr(pvRecord.lock());
|
||||||
|
if(!pvr) throw std::logic_error("pvRecord is deleted");
|
||||||
|
if(pvr->getTraceLevel()>0) {
|
||||||
cout << "ChannelLocal::createChannelPut() "
|
cout << "ChannelLocal::createChannelPut() "
|
||||||
<< " recordName " << pvRecord->getRecordName()
|
<< " recordName " << pvr->getRecordName()
|
||||||
<< " requester exists " << (requester ? "true" : "false")
|
<< " requester exists " << (requester ? "true" : "false")
|
||||||
<< endl;
|
<< endl;
|
||||||
}
|
}
|
||||||
@ -1316,7 +1418,7 @@ ChannelPut::shared_pointer ChannelLocal::createChannelPut(
|
|||||||
getPtrSelf(),
|
getPtrSelf(),
|
||||||
channelPutRequester,
|
channelPutRequester,
|
||||||
pvRequest,
|
pvRequest,
|
||||||
pvRecord);
|
pvr);
|
||||||
return channelPut;
|
return channelPut;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1324,9 +1426,11 @@ ChannelPutGet::shared_pointer ChannelLocal::createChannelPutGet(
|
|||||||
ChannelPutGetRequester::shared_pointer const &channelPutGetRequester,
|
ChannelPutGetRequester::shared_pointer const &channelPutGetRequester,
|
||||||
PVStructure::shared_pointer const &pvRequest)
|
PVStructure::shared_pointer const &pvRequest)
|
||||||
{
|
{
|
||||||
if(pvRecord->getTraceLevel()>0) {
|
PVRecordPtr pvr(pvRecord.lock());
|
||||||
|
if(!pvr) throw std::logic_error("pvRecord is deleted");
|
||||||
|
if(pvr->getTraceLevel()>0) {
|
||||||
cout << "ChannelLocal::createChannelPutGet() "
|
cout << "ChannelLocal::createChannelPutGet() "
|
||||||
<< " recordName " << pvRecord->getRecordName()
|
<< " recordName " << pvr->getRecordName()
|
||||||
<< " requester exists " << (requester ? "true" : "false")
|
<< " requester exists " << (requester ? "true" : "false")
|
||||||
<< endl;
|
<< endl;
|
||||||
}
|
}
|
||||||
@ -1336,7 +1440,7 @@ ChannelPutGet::shared_pointer ChannelLocal::createChannelPutGet(
|
|||||||
getPtrSelf(),
|
getPtrSelf(),
|
||||||
channelPutGetRequester,
|
channelPutGetRequester,
|
||||||
pvRequest,
|
pvRequest,
|
||||||
pvRecord);
|
pvr);
|
||||||
return channelPutGet;
|
return channelPutGet;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1344,9 +1448,11 @@ ChannelRPC::shared_pointer ChannelLocal::createChannelRPC(
|
|||||||
ChannelRPCRequester::shared_pointer const & channelRPCRequester,
|
ChannelRPCRequester::shared_pointer const & channelRPCRequester,
|
||||||
PVStructure::shared_pointer const & pvRequest)
|
PVStructure::shared_pointer const & pvRequest)
|
||||||
{
|
{
|
||||||
if(pvRecord->getTraceLevel()>0) {
|
PVRecordPtr pvr(pvRecord.lock());
|
||||||
|
if(!pvr) throw std::logic_error("pvRecord is deleted");
|
||||||
|
if(pvr->getTraceLevel()>0) {
|
||||||
cout << "ChannelLocal::createChannelRPC() "
|
cout << "ChannelLocal::createChannelRPC() "
|
||||||
<< " recordName " << pvRecord->getRecordName()
|
<< " recordName " << pvr->getRecordName()
|
||||||
<< " requester exists " << (requester ? "true" : "false")
|
<< " requester exists " << (requester ? "true" : "false")
|
||||||
<< endl;
|
<< endl;
|
||||||
}
|
}
|
||||||
@ -1356,7 +1462,7 @@ ChannelRPC::shared_pointer ChannelLocal::createChannelRPC(
|
|||||||
getPtrSelf(),
|
getPtrSelf(),
|
||||||
channelRPCRequester,
|
channelRPCRequester,
|
||||||
pvRequest,
|
pvRequest,
|
||||||
pvRecord);
|
pvr);
|
||||||
return channelRPC;
|
return channelRPC;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1364,16 +1470,17 @@ Monitor::shared_pointer ChannelLocal::createMonitor(
|
|||||||
MonitorRequester::shared_pointer const &monitorRequester,
|
MonitorRequester::shared_pointer const &monitorRequester,
|
||||||
PVStructure::shared_pointer const &pvRequest)
|
PVStructure::shared_pointer const &pvRequest)
|
||||||
{
|
{
|
||||||
if(pvRecord->getTraceLevel()>0) {
|
PVRecordPtr pvr(pvRecord.lock());
|
||||||
|
if(!pvr) throw std::logic_error("pvRecord is deleted");
|
||||||
|
if(pvr->getTraceLevel()>0) {
|
||||||
cout << "ChannelLocal::createMonitor() "
|
cout << "ChannelLocal::createMonitor() "
|
||||||
<< " recordName " << pvRecord->getRecordName()
|
<< " recordName " << pvr->getRecordName()
|
||||||
<< " requester exists " << (requester ? "true" : "false")
|
<< " requester exists " << (requester ? "true" : "false")
|
||||||
<< endl;
|
<< endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
MonitorPtr monitor =
|
MonitorPtr monitor = createMonitorLocal(
|
||||||
getMonitorFactory()->createMonitor(
|
pvr,
|
||||||
pvRecord,
|
|
||||||
monitorRequester,
|
monitorRequester,
|
||||||
pvRequest);
|
pvRequest);
|
||||||
return monitor;
|
return monitor;
|
||||||
@ -1383,9 +1490,11 @@ ChannelArray::shared_pointer ChannelLocal::createChannelArray(
|
|||||||
ChannelArrayRequester::shared_pointer const &channelArrayRequester,
|
ChannelArrayRequester::shared_pointer const &channelArrayRequester,
|
||||||
PVStructure::shared_pointer const &pvRequest)
|
PVStructure::shared_pointer const &pvRequest)
|
||||||
{
|
{
|
||||||
if(pvRecord->getTraceLevel()>0) {
|
PVRecordPtr pvr(pvRecord.lock());
|
||||||
|
if(!pvr) throw std::logic_error("pvRecord is deleted");
|
||||||
|
if(pvr->getTraceLevel()>0) {
|
||||||
cout << "ChannelLocal::createChannelArray() "
|
cout << "ChannelLocal::createChannelArray() "
|
||||||
<< " recordName " << pvRecord->getRecordName()
|
<< " recordName " << pvr->getRecordName()
|
||||||
<< " requester exists " << (requester ? "true" : "false")
|
<< " requester exists " << (requester ? "true" : "false")
|
||||||
<< endl;
|
<< endl;
|
||||||
}
|
}
|
||||||
@ -1394,7 +1503,7 @@ ChannelArray::shared_pointer ChannelLocal::createChannelArray(
|
|||||||
getPtrSelf(),
|
getPtrSelf(),
|
||||||
channelArrayRequester,
|
channelArrayRequester,
|
||||||
pvRequest,
|
pvRequest,
|
||||||
pvRecord);
|
pvr);
|
||||||
return channelArray;
|
return channelArray;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,14 +11,12 @@
|
|||||||
|
|
||||||
#include <epicsThread.h>
|
#include <epicsThread.h>
|
||||||
|
|
||||||
|
|
||||||
#include <pv/serverContext.h>
|
#include <pv/serverContext.h>
|
||||||
#include <pv/syncChannelFind.h>
|
#include <pv/syncChannelFind.h>
|
||||||
|
|
||||||
#define epicsExportSharedSymbols
|
#define epicsExportSharedSymbols
|
||||||
|
|
||||||
#include <pv/channelProviderLocal.h>
|
#include <pv/channelProviderLocal.h>
|
||||||
#include <pv/traceRecord.h>
|
|
||||||
|
|
||||||
using namespace epics::pvData;
|
using namespace epics::pvData;
|
||||||
using namespace epics::pvAccess;
|
using namespace epics::pvAccess;
|
||||||
@ -30,9 +28,6 @@ using std::string;
|
|||||||
|
|
||||||
namespace epics { namespace pvDatabase {
|
namespace epics { namespace pvDatabase {
|
||||||
|
|
||||||
class LocalChannelProviderFactory;
|
|
||||||
typedef std::tr1::shared_ptr<LocalChannelProviderFactory> LocalChannelProviderFactoryPtr;
|
|
||||||
|
|
||||||
static string providerName("local");
|
static string providerName("local");
|
||||||
static ChannelProviderLocalPtr channelProvider;
|
static ChannelProviderLocalPtr channelProvider;
|
||||||
|
|
||||||
@ -48,8 +43,8 @@ public:
|
|||||||
}
|
}
|
||||||
virtual ChannelProvider::shared_pointer newInstance()
|
virtual ChannelProvider::shared_pointer newInstance()
|
||||||
{
|
{
|
||||||
cout << "LocalChannelProviderFactory::newInstance()\n";
|
throw std::logic_error(
|
||||||
throw std::logic_error("newInstance not Implemented");
|
"LocalChannelProviderFactory::newInstance() not Implemented");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -72,12 +67,15 @@ ChannelProviderLocal::ChannelProviderLocal()
|
|||||||
: pvDatabase(PVDatabase::getMaster()),
|
: pvDatabase(PVDatabase::getMaster()),
|
||||||
traceLevel(0)
|
traceLevel(0)
|
||||||
{
|
{
|
||||||
|
if(traceLevel>0) {
|
||||||
|
cout << "ChannelProviderLocal::ChannelProviderLocal()\n";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ChannelProviderLocal::~ChannelProviderLocal()
|
ChannelProviderLocal::~ChannelProviderLocal()
|
||||||
{
|
{
|
||||||
if(traceLevel>0) {
|
if(traceLevel>0) {
|
||||||
cout << "ChannelProviderLocal::~ChannelProviderLocal() \n";
|
cout << "ChannelProviderLocal::~ChannelProviderLocal()\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -86,11 +84,6 @@ std::tr1::shared_ptr<ChannelProvider> ChannelProviderLocal::getChannelProvider()
|
|||||||
return shared_from_this();
|
return shared_from_this();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChannelProviderLocal::cancel()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
string ChannelProviderLocal::getProviderName()
|
string ChannelProviderLocal::getProviderName()
|
||||||
{
|
{
|
||||||
return providerName;
|
return providerName;
|
||||||
@ -103,8 +96,15 @@ ChannelFind::shared_pointer ChannelProviderLocal::channelFind(
|
|||||||
if(traceLevel>1) {
|
if(traceLevel>1) {
|
||||||
cout << "ChannelProviderLocal::channelFind " << "channelName" << endl;
|
cout << "ChannelProviderLocal::channelFind " << "channelName" << endl;
|
||||||
}
|
}
|
||||||
Lock xx(mutex);
|
PVDatabasePtr pvdb(pvDatabase.lock());
|
||||||
PVRecordPtr pvRecord = pvDatabase->findRecord(channelName);
|
if(!pvdb) {
|
||||||
|
Status notFoundStatus(Status::STATUSTYPE_ERROR,"pvDatabase was deleted");
|
||||||
|
channelFindRequester->channelFindResult(
|
||||||
|
notFoundStatus,
|
||||||
|
shared_from_this(),
|
||||||
|
false);
|
||||||
|
}
|
||||||
|
PVRecordPtr pvRecord = pvdb->findRecord(channelName);
|
||||||
if(pvRecord) {
|
if(pvRecord) {
|
||||||
channelFindRequester->channelFindResult(
|
channelFindRequester->channelFindResult(
|
||||||
Status::Ok,
|
Status::Ok,
|
||||||
@ -127,13 +127,11 @@ ChannelFind::shared_pointer ChannelProviderLocal::channelList(
|
|||||||
if(traceLevel>1) {
|
if(traceLevel>1) {
|
||||||
cout << "ChannelProviderLocal::channelList\n";
|
cout << "ChannelProviderLocal::channelList\n";
|
||||||
}
|
}
|
||||||
PVStringArrayPtr records;
|
PVDatabasePtr pvdb(pvDatabase.lock());
|
||||||
{
|
if(!pvdb)throw std::logic_error("pvDatabase was deleted");
|
||||||
Lock guard(mutex);
|
PVStringArrayPtr records(pvdb->getRecordNames());
|
||||||
records = pvDatabase->getRecordNames();
|
channelListRequester->channelListResult(
|
||||||
}
|
Status::Ok, shared_from_this(), records->view(), false);
|
||||||
|
|
||||||
channelListRequester->channelListResult(Status::Ok, shared_from_this(), records->view(), false);
|
|
||||||
return shared_from_this();
|
return shared_from_this();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -145,23 +143,23 @@ Channel::shared_pointer ChannelProviderLocal::createChannel(
|
|||||||
if(traceLevel>1) {
|
if(traceLevel>1) {
|
||||||
cout << "ChannelProviderLocal::createChannel " << "channelName" << endl;
|
cout << "ChannelProviderLocal::createChannel " << "channelName" << endl;
|
||||||
}
|
}
|
||||||
Lock xx(mutex);
|
ChannelLocalPtr channel;
|
||||||
PVRecordPtr pvRecord = pvDatabase->findRecord(channelName);
|
Status status = Status::Ok;
|
||||||
if(pvRecord) {
|
PVDatabasePtr pvdb(pvDatabase.lock());
|
||||||
ChannelLocalPtr channel(new ChannelLocal(
|
if(!pvdb) {
|
||||||
shared_from_this(),channelRequester,pvRecord));
|
status = Status::error("pvDatabase was deleted");
|
||||||
channelRequester->channelCreated(
|
} else {
|
||||||
Status::Ok,
|
PVRecordPtr pvRecord = pvdb->findRecord(channelName);
|
||||||
channel);
|
if(pvRecord) {
|
||||||
pvRecord->addPVRecordClient(channel);
|
channel = ChannelLocalPtr(new ChannelLocal(
|
||||||
return channel;
|
shared_from_this(),channelRequester,pvRecord));
|
||||||
}
|
pvRecord->addPVRecordClient(channel);
|
||||||
Status notFoundStatus(Status::STATUSTYPE_ERROR,"pv not found");
|
} else {
|
||||||
channelRequester->channelCreated(
|
status = Status::error("pv not found");
|
||||||
notFoundStatus,
|
}
|
||||||
Channel::shared_pointer());
|
}
|
||||||
return Channel::shared_pointer();
|
channelRequester->channelCreated(status,channel);
|
||||||
|
return channel;
|
||||||
}
|
}
|
||||||
|
|
||||||
Channel::shared_pointer ChannelProviderLocal::createChannel(
|
Channel::shared_pointer ChannelProviderLocal::createChannel(
|
||||||
|
@ -29,13 +29,16 @@ using std::string;
|
|||||||
|
|
||||||
namespace epics { namespace pvDatabase {
|
namespace epics { namespace pvDatabase {
|
||||||
|
|
||||||
|
class MonitorLocal;
|
||||||
|
typedef std::tr1::shared_ptr<MonitorLocal> MonitorLocalPtr;
|
||||||
|
|
||||||
static MonitorPtr nullMonitor;
|
static MonitorPtr nullMonitor;
|
||||||
static MonitorElementPtr NULLMonitorElement;
|
static MonitorElementPtr NULLMonitorElement;
|
||||||
static Status failedToCreateMonitorStatus(Status::STATUSTYPE_ERROR,"failed to create monitor");
|
static Status failedToCreateMonitorStatus(
|
||||||
|
Status::STATUSTYPE_ERROR,"failed to create monitor");
|
||||||
static Status alreadyStartedStatus(Status::STATUSTYPE_ERROR,"already started");
|
static Status alreadyStartedStatus(Status::STATUSTYPE_ERROR,"already started");
|
||||||
static Status notStartedStatus(Status::STATUSTYPE_ERROR,"not started");
|
static Status notStartedStatus(Status::STATUSTYPE_ERROR,"not started");
|
||||||
static Status destroyedStatus(Status::STATUSTYPE_ERROR,"record is destroyed");
|
static Status deletedStatus(Status::STATUSTYPE_ERROR,"record is deleted");
|
||||||
|
|
||||||
class MonitorElementQueue;
|
class MonitorElementQueue;
|
||||||
typedef std::tr1::shared_ptr<MonitorElementQueue> MonitorElementQueuePtr;
|
typedef std::tr1::shared_ptr<MonitorElementQueue> MonitorElementQueuePtr;
|
||||||
@ -127,7 +130,7 @@ class MonitorLocal :
|
|||||||
public PVListener,
|
public PVListener,
|
||||||
public std::tr1::enable_shared_from_this<MonitorLocal>
|
public std::tr1::enable_shared_from_this<MonitorLocal>
|
||||||
{
|
{
|
||||||
enum MonitorState {idle,active,destroyed};
|
enum MonitorState {idle,active,deleted};
|
||||||
public:
|
public:
|
||||||
POINTER_DEFINITIONS(MonitorLocal);
|
POINTER_DEFINITIONS(MonitorLocal);
|
||||||
virtual ~MonitorLocal();
|
virtual ~MonitorLocal();
|
||||||
@ -197,7 +200,7 @@ Status MonitorLocal::start()
|
|||||||
{
|
{
|
||||||
Lock xx(mutex);
|
Lock xx(mutex);
|
||||||
if(state==active) return alreadyStartedStatus;
|
if(state==active) return alreadyStartedStatus;
|
||||||
if(state==destroyed) return destroyedStatus;
|
if(state==deleted) return deletedStatus;
|
||||||
}
|
}
|
||||||
pvRecord->addListener(getPtrSelf(),pvCopy);
|
pvRecord->addListener(getPtrSelf(),pvCopy);
|
||||||
epicsGuard <PVRecord> guard(*pvRecord);
|
epicsGuard <PVRecord> guard(*pvRecord);
|
||||||
@ -221,7 +224,7 @@ Status MonitorLocal::stop()
|
|||||||
{
|
{
|
||||||
Lock xx(mutex);
|
Lock xx(mutex);
|
||||||
if(state==idle) return notStartedStatus;
|
if(state==idle) return notStartedStatus;
|
||||||
if(state==destroyed) return destroyedStatus;
|
if(state==deleted) return deletedStatus;
|
||||||
state = idle;
|
state = idle;
|
||||||
}
|
}
|
||||||
pvRecord->removeListener(getPtrSelf(),pvCopy);
|
pvRecord->removeListener(getPtrSelf(),pvCopy);
|
||||||
@ -371,7 +374,7 @@ void MonitorLocal::unlisten(PVRecordPtr const & pvRecord)
|
|||||||
}
|
}
|
||||||
{
|
{
|
||||||
Lock xx(mutex);
|
Lock xx(mutex);
|
||||||
state = destroyed;
|
state = deleted;
|
||||||
}
|
}
|
||||||
MonitorRequesterPtr requester = monitorRequester.lock();
|
MonitorRequesterPtr requester = monitorRequester.lock();
|
||||||
if(requester) {
|
if(requester) {
|
||||||
@ -445,29 +448,19 @@ bool MonitorLocal::init(PVStructurePtr const & pvRequest)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MonitorPtr createMonitorLocal(
|
||||||
MonitorFactory::MonitorFactory()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
MonitorFactory::~MonitorFactory()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
MonitorPtr MonitorFactory::createMonitor(
|
|
||||||
PVRecordPtr const & pvRecord,
|
PVRecordPtr const & pvRecord,
|
||||||
MonitorRequester::shared_pointer const & monitorRequester,
|
MonitorRequester::shared_pointer const & monitorRequester,
|
||||||
PVStructurePtr const & pvRequest)
|
PVStructurePtr const & pvRequest)
|
||||||
{
|
{
|
||||||
Lock xx(mutex);
|
|
||||||
MonitorLocalPtr monitor(new MonitorLocal(
|
MonitorLocalPtr monitor(new MonitorLocal(
|
||||||
monitorRequester,pvRecord));
|
monitorRequester,pvRecord));
|
||||||
bool result = monitor->init(pvRequest);
|
bool result = monitor->init(pvRequest);
|
||||||
if(!result) {
|
if(!result) {
|
||||||
MonitorPtr monitor;
|
MonitorPtr monitor;
|
||||||
StructureConstPtr structure;
|
StructureConstPtr structure;
|
||||||
monitorRequester->monitorConnect(failedToCreateMonitorStatus,monitor,structure);
|
monitorRequester->monitorConnect(
|
||||||
|
failedToCreateMonitorStatus,monitor,structure);
|
||||||
return nullMonitor;
|
return nullMonitor;
|
||||||
}
|
}
|
||||||
if(pvRecord->getTraceLevel()>0)
|
if(pvRecord->getTraceLevel()>0)
|
||||||
@ -478,19 +471,4 @@ MonitorPtr MonitorFactory::createMonitor(
|
|||||||
return monitor;
|
return monitor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
MonitorFactoryPtr getMonitorFactory()
|
|
||||||
{
|
|
||||||
static MonitorFactoryPtr monitorFactoryPtr;
|
|
||||||
static Mutex mutex;
|
|
||||||
Lock xx(mutex);
|
|
||||||
|
|
||||||
if(!monitorFactoryPtr) {
|
|
||||||
monitorFactoryPtr = MonitorFactoryPtr(
|
|
||||||
new MonitorFactory());
|
|
||||||
}
|
|
||||||
return monitorFactoryPtr;
|
|
||||||
}
|
|
||||||
|
|
||||||
}}
|
}}
|
||||||
|
Reference in New Issue
Block a user