also address issue 35
This commit is contained in:
@@ -31,25 +31,6 @@ using std::string;
|
||||
namespace epics { namespace pvDatabase {
|
||||
|
||||
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;
|
||||
typedef std::tr1::shared_ptr<ChannelProcessLocal> ChannelProcessLocalPtr;
|
||||
@@ -59,8 +40,6 @@ class ChannelPutLocal;
|
||||
typedef std::tr1::shared_ptr<ChannelPutLocal> ChannelPutLocalPtr;
|
||||
class ChannelPutGetLocal;
|
||||
typedef std::tr1::shared_ptr<ChannelPutGetLocal> ChannelPutGetLocalPtr;
|
||||
class ChannelMonitorLocal;
|
||||
typedef std::tr1::shared_ptr<ChannelMonitorLocal> ChannelMonitorLocalPtr;
|
||||
class ChannelRPCLocal;
|
||||
typedef std::tr1::shared_ptr<ChannelRPCLocal> ChannelRPCLocalPtr;
|
||||
class ChannelArrayLocal;
|
||||
@@ -90,13 +69,7 @@ class ChannelProcessLocal :
|
||||
{
|
||||
public:
|
||||
POINTER_DEFINITIONS(ChannelProcessLocal);
|
||||
virtual ~ChannelProcessLocal()
|
||||
{
|
||||
if(pvRecord->getTraceLevel()>0)
|
||||
{
|
||||
cout << "~ChannelProcessLocal() " << endl;
|
||||
}
|
||||
}
|
||||
virtual ~ChannelProcessLocal();
|
||||
static ChannelProcessLocalPtr create(
|
||||
ChannelLocalPtr const &channelLocal,
|
||||
ChannelProcessRequester::shared_pointer const & channelProcessRequester,
|
||||
@@ -104,12 +77,11 @@ public:
|
||||
PVRecordPtr const &pvRecord);
|
||||
virtual void process();
|
||||
virtual void destroy() EPICS_DEPRECATED {};
|
||||
virtual std::tr1::shared_ptr<Channel> getChannel()
|
||||
{return channelLocal;}
|
||||
virtual std::tr1::shared_ptr<Channel> getChannel();
|
||||
virtual void cancel(){}
|
||||
virtual void lock();
|
||||
virtual void unlock();
|
||||
virtual void lastRequest() {}
|
||||
virtual void lock() {pvRecord->lock();}
|
||||
virtual void unlock() {pvRecord->unlock();}
|
||||
private:
|
||||
shared_pointer getPtrSelf()
|
||||
{
|
||||
@@ -127,9 +99,9 @@ private:
|
||||
nProcess(nProcess)
|
||||
{
|
||||
}
|
||||
ChannelLocalPtr channelLocal;
|
||||
ChannelLocalWPtr channelLocal;
|
||||
ChannelProcessRequester::weak_pointer channelProcessRequester;
|
||||
PVRecordPtr pvRecord;
|
||||
PVRecordWPtr pvRecord;
|
||||
int nProcess;
|
||||
Mutex mutex;
|
||||
};
|
||||
@@ -172,21 +144,50 @@ ChannelProcessLocalPtr ChannelProcessLocal::create(
|
||||
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()
|
||||
{
|
||||
ChannelProcessRequester::shared_pointer requester = channelProcessRequester.lock();
|
||||
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 << " nProcess " << nProcess << endl;
|
||||
}
|
||||
try {
|
||||
for(int i=0; i< nProcess; i++) {
|
||||
epicsGuard <PVRecord> guard(*pvRecord);
|
||||
pvRecord->beginGroupPut();
|
||||
pvRecord->process();
|
||||
pvRecord->endGroupPut();
|
||||
epicsGuard <PVRecord> guard(*pvr);
|
||||
pvr->beginGroupPut();
|
||||
pvr->process();
|
||||
pvr->endGroupPut();
|
||||
}
|
||||
requester->processDone(Status::Ok,getPtrSelf());
|
||||
} catch(std::exception& ex) {
|
||||
@@ -201,13 +202,7 @@ class ChannelGetLocal :
|
||||
{
|
||||
public:
|
||||
POINTER_DEFINITIONS(ChannelGetLocal);
|
||||
virtual ~ChannelGetLocal()
|
||||
{
|
||||
if(pvRecord->getTraceLevel()>0)
|
||||
{
|
||||
cout << "~ChannelGetLocal()" << endl;
|
||||
}
|
||||
}
|
||||
virtual ~ChannelGetLocal();
|
||||
static ChannelGetLocalPtr create(
|
||||
ChannelLocalPtr const &channelLocal,
|
||||
ChannelGetRequester::shared_pointer const & channelGetRequester,
|
||||
@@ -215,12 +210,11 @@ public:
|
||||
PVRecordPtr const &pvRecord);
|
||||
virtual void get();
|
||||
virtual void destroy() EPICS_DEPRECATED {};
|
||||
virtual std::tr1::shared_ptr<Channel> getChannel()
|
||||
{return channelLocal;}
|
||||
virtual std::tr1::shared_ptr<Channel> getChannel();
|
||||
virtual void cancel(){}
|
||||
virtual void lock();
|
||||
virtual void unlock();
|
||||
virtual void lastRequest() {}
|
||||
virtual void lock() {pvRecord->lock();}
|
||||
virtual void unlock() {pvRecord->unlock();}
|
||||
private:
|
||||
shared_pointer getPtrSelf()
|
||||
{
|
||||
@@ -247,12 +241,12 @@ private:
|
||||
}
|
||||
bool firstTime;
|
||||
bool callProcess;
|
||||
ChannelLocalPtr channelLocal;
|
||||
ChannelLocalWPtr channelLocal;
|
||||
ChannelGetRequester::weak_pointer channelGetRequester;
|
||||
PVCopyPtr pvCopy;
|
||||
PVStructurePtr pvStructure;
|
||||
BitSetPtr bitSet;
|
||||
PVRecordPtr pvRecord;
|
||||
PVRecordWPtr pvRecord;
|
||||
Mutex mutex;
|
||||
};
|
||||
|
||||
@@ -298,19 +292,48 @@ ChannelGetLocalPtr ChannelGetLocal::create(
|
||||
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()
|
||||
{
|
||||
ChannelGetRequester::shared_pointer requester = channelGetRequester.lock();
|
||||
if(!requester) return;
|
||||
PVRecordPtr pvr(pvRecord.lock());
|
||||
if(!pvr) throw std::logic_error("pvRecord is deleted");
|
||||
try {
|
||||
bitSet->clear();
|
||||
{
|
||||
epicsGuard <PVRecord> guard(*pvRecord);
|
||||
epicsGuard <PVRecord> guard(*pvr);
|
||||
if(callProcess) {
|
||||
pvRecord->beginGroupPut();
|
||||
pvRecord->process();
|
||||
pvRecord->endGroupPut();
|
||||
pvr->beginGroupPut();
|
||||
pvr->process();
|
||||
pvr->endGroupPut();
|
||||
}
|
||||
pvCopy->updateCopySetBitSet(pvStructure, bitSet);
|
||||
}
|
||||
@@ -324,7 +347,7 @@ void ChannelGetLocal::get()
|
||||
getPtrSelf(),
|
||||
pvStructure,
|
||||
bitSet);
|
||||
if(pvRecord->getTraceLevel()>1)
|
||||
if(pvr->getTraceLevel()>1)
|
||||
{
|
||||
cout << "ChannelGetLocal::get" << endl;
|
||||
}
|
||||
@@ -341,13 +364,7 @@ class ChannelPutLocal :
|
||||
{
|
||||
public:
|
||||
POINTER_DEFINITIONS(ChannelPutLocal);
|
||||
virtual ~ChannelPutLocal()
|
||||
{
|
||||
if(pvRecord->getTraceLevel()>0)
|
||||
{
|
||||
cout << "~ChannelPutLocal()" << endl;
|
||||
}
|
||||
}
|
||||
virtual ~ChannelPutLocal();
|
||||
static ChannelPutLocalPtr create(
|
||||
ChannelLocalPtr const &channelLocal,
|
||||
ChannelPutRequester::shared_pointer const & channelPutRequester,
|
||||
@@ -356,12 +373,11 @@ public:
|
||||
virtual void put(PVStructurePtr const &pvStructure,BitSetPtr const &bitSet);
|
||||
virtual void get();
|
||||
virtual void destroy() EPICS_DEPRECATED {};
|
||||
virtual std::tr1::shared_ptr<Channel> getChannel()
|
||||
{return channelLocal;}
|
||||
virtual std::tr1::shared_ptr<Channel> getChannel();
|
||||
virtual void cancel(){}
|
||||
virtual void lock();
|
||||
virtual void unlock();
|
||||
virtual void lastRequest() {}
|
||||
virtual void lock() {pvRecord->lock();}
|
||||
virtual void unlock() {pvRecord->unlock();}
|
||||
private:
|
||||
shared_pointer getPtrSelf()
|
||||
{
|
||||
@@ -382,10 +398,10 @@ private:
|
||||
{
|
||||
}
|
||||
bool callProcess;
|
||||
ChannelLocalPtr channelLocal;
|
||||
ChannelLocalWPtr channelLocal;
|
||||
ChannelPutRequester::weak_pointer channelPutRequester;
|
||||
PVCopyPtr pvCopy;
|
||||
PVRecordPtr pvRecord;
|
||||
PVRecordWPtr pvRecord;
|
||||
Mutex mutex;
|
||||
};
|
||||
|
||||
@@ -429,22 +445,52 @@ ChannelPutLocalPtr ChannelPutLocal::create(
|
||||
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()
|
||||
{
|
||||
ChannelPutRequester::shared_pointer requester = channelPutRequester.lock();
|
||||
if(!requester) return;
|
||||
PVRecordPtr pvr(pvRecord.lock());
|
||||
if(!pvr) throw std::logic_error("pvRecord is deleted");
|
||||
try {
|
||||
PVStructurePtr pvStructure = pvCopy->createPVStructure();
|
||||
BitSetPtr bitSet(new BitSet(pvStructure->getNumberFields()));
|
||||
bitSet->clear();
|
||||
bitSet->set(0);
|
||||
{
|
||||
epicsGuard <PVRecord> guard(*pvRecord);
|
||||
epicsGuard <PVRecord> guard(*pvr);
|
||||
pvCopy->updateCopyFromBitSet(pvStructure, bitSet);
|
||||
}
|
||||
requester->getDone(
|
||||
Status::Ok,getPtrSelf(),pvStructure,bitSet);
|
||||
if(pvRecord->getTraceLevel()>1)
|
||||
if(pvr->getTraceLevel()>1)
|
||||
{
|
||||
cout << "ChannelPutLocal::get" << endl;
|
||||
}
|
||||
@@ -461,18 +507,20 @@ void ChannelPutLocal::put(
|
||||
{
|
||||
ChannelPutRequester::shared_pointer requester = channelPutRequester.lock();
|
||||
if(!requester) return;
|
||||
PVRecordPtr pvr(pvRecord.lock());
|
||||
if(!pvr) throw std::logic_error("pvRecord is deleted");
|
||||
try {
|
||||
{
|
||||
epicsGuard <PVRecord> guard(*pvRecord);
|
||||
pvRecord->beginGroupPut();
|
||||
epicsGuard <PVRecord> guard(*pvr);
|
||||
pvr->beginGroupPut();
|
||||
pvCopy->updateMaster(pvStructure, bitSet);
|
||||
if(callProcess) {
|
||||
pvRecord->process();
|
||||
pvr->process();
|
||||
}
|
||||
pvRecord->endGroupPut();
|
||||
pvr->endGroupPut();
|
||||
}
|
||||
requester->putDone(Status::Ok,getPtrSelf());
|
||||
if(pvRecord->getTraceLevel()>1)
|
||||
if(pvr->getTraceLevel()>1)
|
||||
{
|
||||
cout << "ChannelPutLocal::put" << endl;
|
||||
}
|
||||
@@ -489,13 +537,7 @@ class ChannelPutGetLocal :
|
||||
{
|
||||
public:
|
||||
POINTER_DEFINITIONS(ChannelPutGetLocal);
|
||||
virtual ~ChannelPutGetLocal()
|
||||
{
|
||||
if(pvRecord->getTraceLevel()>0)
|
||||
{
|
||||
cout << "~ChannelPutGetLocal()" << endl;
|
||||
}
|
||||
}
|
||||
virtual ~ChannelPutGetLocal();
|
||||
static ChannelPutGetLocalPtr create(
|
||||
ChannelLocalPtr const &channelLocal,
|
||||
ChannelPutGetRequester::shared_pointer const & channelPutGetRequester,
|
||||
@@ -507,12 +549,11 @@ public:
|
||||
virtual void getPut();
|
||||
virtual void getGet();
|
||||
virtual void destroy() EPICS_DEPRECATED {};
|
||||
virtual std::tr1::shared_ptr<Channel> getChannel()
|
||||
{return channelLocal;}
|
||||
virtual std::tr1::shared_ptr<Channel> getChannel();
|
||||
virtual void cancel(){}
|
||||
virtual void lock();
|
||||
virtual void unlock();
|
||||
virtual void lastRequest() {}
|
||||
virtual void lock() {pvRecord->lock();}
|
||||
virtual void unlock() {pvRecord->unlock();}
|
||||
private:
|
||||
shared_pointer getPtrSelf()
|
||||
{
|
||||
@@ -539,13 +580,13 @@ private:
|
||||
{
|
||||
}
|
||||
bool callProcess;
|
||||
ChannelLocalPtr channelLocal;
|
||||
ChannelLocalWPtr channelLocal;
|
||||
ChannelPutGetRequester::weak_pointer channelPutGetRequester;
|
||||
PVCopyPtr pvPutCopy;
|
||||
PVCopyPtr pvGetCopy;
|
||||
PVStructurePtr pvGetStructure;
|
||||
BitSetPtr getBitSet;
|
||||
PVRecordPtr pvRecord;
|
||||
PVRecordWPtr pvRecord;
|
||||
Mutex mutex;
|
||||
};
|
||||
|
||||
@@ -597,25 +638,54 @@ ChannelPutGetLocalPtr ChannelPutGetLocal::create(
|
||||
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(
|
||||
PVStructurePtr const &pvPutStructure,BitSetPtr const &putBitSet)
|
||||
{
|
||||
ChannelPutGetRequester::shared_pointer requester = channelPutGetRequester.lock();
|
||||
if(!requester) return;
|
||||
PVRecordPtr pvr(pvRecord.lock());
|
||||
if(!pvr) throw std::logic_error("pvRecord is deleted");
|
||||
try {
|
||||
{
|
||||
epicsGuard <PVRecord> guard(*pvRecord);
|
||||
pvRecord->beginGroupPut();
|
||||
epicsGuard <PVRecord> guard(*pvr);
|
||||
pvr->beginGroupPut();
|
||||
pvPutCopy->updateMaster(pvPutStructure, putBitSet);
|
||||
if(callProcess) pvRecord->process();
|
||||
if(callProcess) pvr->process();
|
||||
getBitSet->clear();
|
||||
pvGetCopy->updateCopySetBitSet(pvGetStructure, getBitSet);
|
||||
pvRecord->endGroupPut();
|
||||
pvr->endGroupPut();
|
||||
}
|
||||
requester->putGetDone(
|
||||
Status::Ok,getPtrSelf(),pvGetStructure,getBitSet);
|
||||
if(pvRecord->getTraceLevel()>1)
|
||||
if(pvr->getTraceLevel()>1)
|
||||
{
|
||||
cout << "ChannelPutGetLocal::putGet" << endl;
|
||||
}
|
||||
@@ -629,16 +699,18 @@ void ChannelPutGetLocal::getPut()
|
||||
{
|
||||
ChannelPutGetRequester::shared_pointer requester = channelPutGetRequester.lock();
|
||||
if(!requester) return;
|
||||
PVRecordPtr pvr(pvRecord.lock());
|
||||
if(!pvr) throw std::logic_error("pvRecord is deleted");
|
||||
try {
|
||||
PVStructurePtr pvPutStructure = pvPutCopy->createPVStructure();
|
||||
BitSetPtr putBitSet(new BitSet(pvPutStructure->getNumberFields()));
|
||||
{
|
||||
epicsGuard <PVRecord> guard(*pvRecord);
|
||||
epicsGuard <PVRecord> guard(*pvr);
|
||||
pvPutCopy->initCopy(pvPutStructure, putBitSet);
|
||||
}
|
||||
requester->getPutDone(
|
||||
Status::Ok,getPtrSelf(),pvPutStructure,putBitSet);
|
||||
if(pvRecord->getTraceLevel()>1)
|
||||
if(pvr->getTraceLevel()>1)
|
||||
{
|
||||
cout << "ChannelPutGetLocal::getPut" << endl;
|
||||
}
|
||||
@@ -654,15 +726,17 @@ void ChannelPutGetLocal::getGet()
|
||||
{
|
||||
ChannelPutGetRequester::shared_pointer requester = channelPutGetRequester.lock();
|
||||
if(!requester) return;
|
||||
PVRecordPtr pvr(pvRecord.lock());
|
||||
if(!pvr) throw std::logic_error("pvRecord is deleted");
|
||||
try {
|
||||
getBitSet->clear();
|
||||
{
|
||||
epicsGuard <PVRecord> guard(*pvRecord);
|
||||
epicsGuard <PVRecord> guard(*pvr);
|
||||
pvGetCopy->updateCopySetBitSet(pvGetStructure, getBitSet);
|
||||
}
|
||||
requester->getGetDone(
|
||||
Status::Ok,getPtrSelf(),pvGetStructure,getBitSet);
|
||||
if(pvRecord->getTraceLevel()>1)
|
||||
if(pvr->getTraceLevel()>1)
|
||||
{
|
||||
cout << "ChannelPutGetLocal::getGet" << endl;
|
||||
}
|
||||
@@ -696,19 +770,11 @@ public:
|
||||
channelLocal(channelLocal),
|
||||
channelRPCRequester(channelRPCRequester),
|
||||
service(service),
|
||||
pvRecord(pvRecord),
|
||||
isLastRequest()
|
||||
pvRecord(pvRecord)
|
||||
{
|
||||
}
|
||||
|
||||
virtual ~ChannelRPCLocal()
|
||||
{
|
||||
if(pvRecord->getTraceLevel()>0)
|
||||
{
|
||||
cout << "~ChannelRPCLocal()" << endl;
|
||||
}
|
||||
}
|
||||
|
||||
virtual ~ChannelRPCLocal();
|
||||
void processRequest(RPCService::shared_pointer const & service,
|
||||
PVStructurePtr const & pvArgument);
|
||||
|
||||
@@ -724,37 +790,21 @@ public:
|
||||
PVStructurePtr const & pvArgument);
|
||||
|
||||
virtual void request(PVStructurePtr const & pvArgument);
|
||||
|
||||
void lastRequest()
|
||||
{
|
||||
isLastRequest.set();
|
||||
}
|
||||
|
||||
virtual Channel::shared_pointer getChannel()
|
||||
{
|
||||
return channelLocal;
|
||||
}
|
||||
|
||||
virtual Channel::shared_pointer getChannel();
|
||||
virtual void cancel() {}
|
||||
|
||||
virtual void destroy() EPICS_DEPRECATED {};
|
||||
|
||||
virtual void lock() {}
|
||||
|
||||
virtual void unlock() {}
|
||||
|
||||
virtual void lastRequest() {}
|
||||
private:
|
||||
|
||||
shared_pointer getPtrSelf()
|
||||
{
|
||||
return shared_from_this();
|
||||
}
|
||||
|
||||
ChannelLocalPtr channelLocal;
|
||||
ChannelLocalWPtr channelLocal;
|
||||
ChannelRPCRequester::weak_pointer channelRPCRequester;
|
||||
RPCServiceAsync::shared_pointer service;
|
||||
PVRecordPtr pvRecord;
|
||||
AtomicBoolean isLastRequest;
|
||||
PVRecordWPtr pvRecord;
|
||||
};
|
||||
|
||||
ChannelRPCLocalPtr ChannelRPCLocal::create(
|
||||
@@ -788,6 +838,21 @@ ChannelRPCLocalPtr ChannelRPCLocal::create(
|
||||
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(
|
||||
RPCService::shared_pointer const & service,
|
||||
PVStructurePtr const & pvArgument)
|
||||
@@ -823,9 +888,6 @@ void ChannelRPCLocal::processRequest(
|
||||
}
|
||||
ChannelRPCRequester::shared_pointer requester = channelRPCRequester.lock();
|
||||
if(requester) requester->requestDone(status, getPtrSelf(), result);
|
||||
|
||||
if (isLastRequest.get())
|
||||
destroy();
|
||||
}
|
||||
|
||||
void ChannelRPCLocal::processRequest(
|
||||
@@ -842,8 +904,6 @@ void ChannelRPCLocal::processRequest(
|
||||
Status errorStatus(Status::STATUSTYPE_FATAL, ex.what());
|
||||
ChannelRPCRequester::shared_pointer requester = channelRPCRequester.lock();
|
||||
if(requester) requester->requestDone(errorStatus, getPtrSelf(), PVStructurePtr());
|
||||
if (isLastRequest.get())
|
||||
destroy();
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
@@ -852,9 +912,6 @@ void ChannelRPCLocal::processRequest(
|
||||
"Unexpected exception caught while calling RPCServiceAsync.request(PVStructure, RPCResponseCallback).");
|
||||
ChannelRPCRequester::shared_pointer requester = channelRPCRequester.lock();
|
||||
if(requester) requester->requestDone(errorStatus, shared_from_this(), PVStructurePtr());
|
||||
|
||||
if (isLastRequest.get())
|
||||
destroy();
|
||||
}
|
||||
|
||||
// we wait for callback to be called
|
||||
@@ -863,9 +920,9 @@ void ChannelRPCLocal::processRequest(
|
||||
|
||||
void ChannelRPCLocal::request(PVStructurePtr const & pvArgument)
|
||||
{
|
||||
if(pvRecord->getTraceLevel()>1)
|
||||
{
|
||||
cout << "ChannelRPCLocal::request" << endl;
|
||||
PVRecordPtr pvr(pvRecord.lock());
|
||||
if(pvr && pvr->getTraceLevel()>0) {
|
||||
cout << "ChannelRPCLocal::request " << pvr->getRecordName() << endl;
|
||||
}
|
||||
RPCService::shared_pointer rpcService =
|
||||
std::tr1::dynamic_pointer_cast<RPCService>(service);
|
||||
@@ -893,13 +950,7 @@ class ChannelArrayLocal :
|
||||
{
|
||||
public:
|
||||
POINTER_DEFINITIONS(ChannelArrayLocal);
|
||||
virtual ~ChannelArrayLocal()
|
||||
{
|
||||
if(pvRecord->getTraceLevel()>0)
|
||||
{
|
||||
cout << "~ChannelArrayLocal()" << endl;
|
||||
}
|
||||
}
|
||||
virtual ~ChannelArrayLocal();
|
||||
static ChannelArrayLocalPtr create(
|
||||
ChannelLocalPtr const &channelLocal,
|
||||
ChannelArrayRequester::shared_pointer const & channelArrayRequester,
|
||||
@@ -912,12 +963,11 @@ public:
|
||||
virtual void getLength();
|
||||
virtual void setLength(size_t length);
|
||||
virtual void destroy() EPICS_DEPRECATED {};
|
||||
virtual std::tr1::shared_ptr<Channel> getChannel()
|
||||
{return channelLocal;}
|
||||
virtual std::tr1::shared_ptr<Channel> getChannel();
|
||||
virtual void cancel(){}
|
||||
virtual void lock();
|
||||
virtual void unlock();
|
||||
virtual void lastRequest() {}
|
||||
virtual void lock() {pvRecord->lock();}
|
||||
virtual void unlock() {pvRecord->unlock();}
|
||||
private:
|
||||
shared_pointer getPtrSelf()
|
||||
{
|
||||
@@ -938,11 +988,11 @@ private:
|
||||
{
|
||||
}
|
||||
|
||||
ChannelLocalPtr channelLocal;
|
||||
ChannelLocalWPtr channelLocal;
|
||||
ChannelArrayRequester::weak_pointer channelArrayRequester;
|
||||
PVArrayPtr pvArray;
|
||||
PVArrayPtr pvCopy;
|
||||
PVRecordPtr pvRecord;
|
||||
PVRecordWPtr pvRecord;
|
||||
Mutex mutex;
|
||||
};
|
||||
|
||||
@@ -1030,19 +1080,47 @@ ChannelArrayLocalPtr ChannelArrayLocal::create(
|
||||
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)
|
||||
{
|
||||
ChannelArrayRequester::shared_pointer requester = channelArrayRequester.lock();
|
||||
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 << "ChannelArrayLocal::getArray" << endl;
|
||||
}
|
||||
const char *exceptionMessage = NULL;
|
||||
try {
|
||||
bool ok = false;
|
||||
epicsGuard <PVRecord> guard(*pvRecord);
|
||||
epicsGuard <PVRecord> guard(*pvr);
|
||||
while(true) {
|
||||
size_t length = pvArray->getLength();
|
||||
if(length<=0) break;
|
||||
@@ -1075,8 +1153,9 @@ void ChannelArrayLocal::putArray(
|
||||
{
|
||||
ChannelArrayRequester::shared_pointer requester = channelArrayRequester.lock();
|
||||
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 << "ChannelArrayLocal::putArray" << endl;
|
||||
}
|
||||
@@ -1084,7 +1163,7 @@ void ChannelArrayLocal::putArray(
|
||||
if(newLength<pvArray->getLength()) pvArray->setLength(newLength);
|
||||
const char *exceptionMessage = NULL;
|
||||
try {
|
||||
epicsGuard <PVRecord> guard(*pvRecord);
|
||||
epicsGuard <PVRecord> guard(*pvr);
|
||||
copy(pvArray,0,1,this->pvArray,offset,stride,count);
|
||||
} catch(std::exception e) {
|
||||
exceptionMessage = e.what();
|
||||
@@ -1100,10 +1179,12 @@ void ChannelArrayLocal::getLength()
|
||||
{
|
||||
ChannelArrayRequester::shared_pointer requester = channelArrayRequester.lock();
|
||||
if(!requester) return;
|
||||
PVRecordPtr pvr(pvRecord.lock());
|
||||
if(!pvr) throw std::logic_error("pvRecord is deleted");
|
||||
size_t length = 0;
|
||||
const char *exceptionMessage = NULL;
|
||||
try {
|
||||
epicsGuard <PVRecord> guard(*pvRecord);
|
||||
epicsGuard <PVRecord> guard(*pvr);
|
||||
length = pvArray->getLength();
|
||||
} catch(std::exception e) {
|
||||
exceptionMessage = e.what();
|
||||
@@ -1119,14 +1200,15 @@ void ChannelArrayLocal::setLength(size_t length)
|
||||
{
|
||||
ChannelArrayRequester::shared_pointer requester = channelArrayRequester.lock();
|
||||
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 << "ChannelArrayLocal::setLength" << endl;
|
||||
}
|
||||
try {
|
||||
{
|
||||
epicsGuard <PVRecord> guard(*pvRecord);
|
||||
epicsGuard <PVRecord> guard(*pvr);
|
||||
if(pvArray->getLength()!=length) pvArray->setLength(length);
|
||||
}
|
||||
requester->setLengthDone(Status::Ok,getPtrSelf());
|
||||
@@ -1157,13 +1239,18 @@ ChannelLocal::ChannelLocal(
|
||||
|
||||
ChannelLocal::~ChannelLocal()
|
||||
{
|
||||
if(pvRecord->getTraceLevel()>0)
|
||||
PVRecordPtr pvr(pvRecord.lock());
|
||||
if(!pvr) return;
|
||||
if(pvr->getTraceLevel()>0)
|
||||
{
|
||||
cout << "~ChannelLocal()" << endl;
|
||||
}
|
||||
pvRecord->removePVRecordClient(getPtrSelf());
|
||||
}
|
||||
|
||||
ChannelProvider::shared_pointer ChannelLocal::getProvider()
|
||||
{
|
||||
return provider.lock();
|
||||
}
|
||||
|
||||
void ChannelLocal::detach(PVRecordPtr const & pvRecord)
|
||||
{
|
||||
@@ -1180,9 +1267,10 @@ void ChannelLocal::detach(PVRecordPtr const & pvRecord)
|
||||
|
||||
string ChannelLocal::getRequesterName()
|
||||
{
|
||||
if(pvRecord->getTraceLevel()>1) {
|
||||
PVRecordPtr pvr(pvRecord.lock());
|
||||
if(pvr && pvr->getTraceLevel()>0) {
|
||||
cout << "ChannelLocal::getRequesterName() "
|
||||
<< " recordName " << pvRecord->getRecordName()
|
||||
<< " recordName " << pvr->getRecordName()
|
||||
<< " requester exists " << (requester ? "true" : "false")
|
||||
<< endl;
|
||||
}
|
||||
@@ -1195,9 +1283,10 @@ void ChannelLocal::message(
|
||||
string const &message,
|
||||
MessageType messageType)
|
||||
{
|
||||
if(pvRecord->getTraceLevel()>1) {
|
||||
PVRecordPtr pvr(pvRecord.lock());
|
||||
if(pvr && pvr->getTraceLevel()>1) {
|
||||
cout << "ChannelLocal::message() "
|
||||
<< " recordName " << pvRecord->getRecordName()
|
||||
<< " recordName " << pvr->getRecordName()
|
||||
<< " requester exists " << (requester ? "true" : "false")
|
||||
<< endl;
|
||||
}
|
||||
@@ -1205,7 +1294,9 @@ void ChannelLocal::message(
|
||||
requester->message(message,messageType);
|
||||
return;
|
||||
}
|
||||
cout << pvRecord->getRecordName()
|
||||
string recordName("record deleted");
|
||||
if(pvr) recordName = pvr->getRecordName();
|
||||
cout << recordName
|
||||
<< " message " << message
|
||||
<< " messageType " << getMessageTypeName(messageType)
|
||||
<< endl;
|
||||
@@ -1223,7 +1314,10 @@ Channel::ConnectionState ChannelLocal::getConnectionState()
|
||||
|
||||
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()
|
||||
@@ -1239,14 +1333,16 @@ bool ChannelLocal::isConnected()
|
||||
void ChannelLocal::getField(GetFieldRequester::shared_pointer const &requester,
|
||||
string const &subField)
|
||||
{
|
||||
PVRecordPtr pvr(pvRecord.lock());
|
||||
if(!pvr) throw std::logic_error("pvRecord is deleted");
|
||||
if(subField.size()<1) {
|
||||
StructureConstPtr structure =
|
||||
pvRecord->getPVRecordStructure()->getPVStructure()->getStructure();
|
||||
pvr->getPVRecordStructure()->getPVStructure()->getStructure();
|
||||
requester->getDone(Status::Ok,structure);
|
||||
return;
|
||||
}
|
||||
PVFieldPtr pvField =
|
||||
pvRecord->getPVRecordStructure()->getPVStructure()->getSubField(subField);
|
||||
pvr->getPVRecordStructure()->getPVStructure()->getSubField(subField);
|
||||
if(pvField) {
|
||||
requester->getDone(Status::Ok,pvField->getField());
|
||||
return;
|
||||
@@ -1266,9 +1362,11 @@ ChannelProcess::shared_pointer ChannelLocal::createChannelProcess(
|
||||
ChannelProcessRequester::shared_pointer const & channelProcessRequester,
|
||||
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() "
|
||||
<< " recordName " << pvRecord->getRecordName()
|
||||
<< " recordName " << pvr->getRecordName()
|
||||
<< " requester exists " << (requester ? "true" : "false")
|
||||
<< endl;
|
||||
}
|
||||
@@ -1277,7 +1375,7 @@ ChannelProcess::shared_pointer ChannelLocal::createChannelProcess(
|
||||
getPtrSelf(),
|
||||
channelProcessRequester,
|
||||
pvRequest,
|
||||
pvRecord);
|
||||
pvr);
|
||||
return channelProcess;
|
||||
}
|
||||
|
||||
@@ -1285,9 +1383,11 @@ ChannelGet::shared_pointer ChannelLocal::createChannelGet(
|
||||
ChannelGetRequester::shared_pointer const &channelGetRequester,
|
||||
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() "
|
||||
<< " recordName " << pvRecord->getRecordName()
|
||||
<< " recordName " << pvr->getRecordName()
|
||||
<< " requester exists " << (requester ? "true" : "false")
|
||||
<< endl;
|
||||
}
|
||||
@@ -1296,7 +1396,7 @@ ChannelGet::shared_pointer ChannelLocal::createChannelGet(
|
||||
getPtrSelf(),
|
||||
channelGetRequester,
|
||||
pvRequest,
|
||||
pvRecord);
|
||||
pvr);
|
||||
return channelGet;
|
||||
}
|
||||
|
||||
@@ -1304,9 +1404,11 @@ ChannelPut::shared_pointer ChannelLocal::createChannelPut(
|
||||
ChannelPutRequester::shared_pointer const &channelPutRequester,
|
||||
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() "
|
||||
<< " recordName " << pvRecord->getRecordName()
|
||||
<< " recordName " << pvr->getRecordName()
|
||||
<< " requester exists " << (requester ? "true" : "false")
|
||||
<< endl;
|
||||
}
|
||||
@@ -1316,7 +1418,7 @@ ChannelPut::shared_pointer ChannelLocal::createChannelPut(
|
||||
getPtrSelf(),
|
||||
channelPutRequester,
|
||||
pvRequest,
|
||||
pvRecord);
|
||||
pvr);
|
||||
return channelPut;
|
||||
}
|
||||
|
||||
@@ -1324,9 +1426,11 @@ ChannelPutGet::shared_pointer ChannelLocal::createChannelPutGet(
|
||||
ChannelPutGetRequester::shared_pointer const &channelPutGetRequester,
|
||||
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() "
|
||||
<< " recordName " << pvRecord->getRecordName()
|
||||
<< " recordName " << pvr->getRecordName()
|
||||
<< " requester exists " << (requester ? "true" : "false")
|
||||
<< endl;
|
||||
}
|
||||
@@ -1336,7 +1440,7 @@ ChannelPutGet::shared_pointer ChannelLocal::createChannelPutGet(
|
||||
getPtrSelf(),
|
||||
channelPutGetRequester,
|
||||
pvRequest,
|
||||
pvRecord);
|
||||
pvr);
|
||||
return channelPutGet;
|
||||
}
|
||||
|
||||
@@ -1344,9 +1448,11 @@ ChannelRPC::shared_pointer ChannelLocal::createChannelRPC(
|
||||
ChannelRPCRequester::shared_pointer const & channelRPCRequester,
|
||||
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() "
|
||||
<< " recordName " << pvRecord->getRecordName()
|
||||
<< " recordName " << pvr->getRecordName()
|
||||
<< " requester exists " << (requester ? "true" : "false")
|
||||
<< endl;
|
||||
}
|
||||
@@ -1356,7 +1462,7 @@ ChannelRPC::shared_pointer ChannelLocal::createChannelRPC(
|
||||
getPtrSelf(),
|
||||
channelRPCRequester,
|
||||
pvRequest,
|
||||
pvRecord);
|
||||
pvr);
|
||||
return channelRPC;
|
||||
}
|
||||
|
||||
@@ -1364,15 +1470,17 @@ Monitor::shared_pointer ChannelLocal::createMonitor(
|
||||
MonitorRequester::shared_pointer const &monitorRequester,
|
||||
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() "
|
||||
<< " recordName " << pvRecord->getRecordName()
|
||||
<< " recordName " << pvr->getRecordName()
|
||||
<< " requester exists " << (requester ? "true" : "false")
|
||||
<< endl;
|
||||
}
|
||||
|
||||
MonitorPtr monitor = createMonitorLocal(
|
||||
pvRecord,
|
||||
pvr,
|
||||
monitorRequester,
|
||||
pvRequest);
|
||||
return monitor;
|
||||
@@ -1382,9 +1490,11 @@ ChannelArray::shared_pointer ChannelLocal::createChannelArray(
|
||||
ChannelArrayRequester::shared_pointer const &channelArrayRequester,
|
||||
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() "
|
||||
<< " recordName " << pvRecord->getRecordName()
|
||||
<< " recordName " << pvr->getRecordName()
|
||||
<< " requester exists " << (requester ? "true" : "false")
|
||||
<< endl;
|
||||
}
|
||||
@@ -1393,7 +1503,7 @@ ChannelArray::shared_pointer ChannelLocal::createChannelArray(
|
||||
getPtrSelf(),
|
||||
channelArrayRequester,
|
||||
pvRequest,
|
||||
pvRecord);
|
||||
pvr);
|
||||
return channelArray;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user