more work on memory issues.
Still problems. Added channelLocalDebug.
This commit is contained in:
@@ -20,10 +20,12 @@ SRC_DIRS += $(DATABASE)/pvAccess
|
||||
INC += channelProviderLocal.h
|
||||
INC += pvCopy.h
|
||||
INC += monitorAlgorithm.h
|
||||
INC += channelLocalDebugRecord.h
|
||||
LIBSRCS += channelProviderLocal.cpp
|
||||
LIBSRCS += channelLocal.cpp
|
||||
LIBSRCS += pvCopy.cpp
|
||||
LIBSRCS += monitorFactory.cpp
|
||||
LIBSRCS += channelLocalDebugRecord.cpp
|
||||
|
||||
|
||||
include $(TOP)/configure/RULES
|
||||
|
||||
+195
-107
@@ -39,12 +39,6 @@ typedef std::tr1::shared_ptr<ChannelRPCLocal> ChannelRPCLocalPtr;
|
||||
class ChannelArrayLocal;
|
||||
typedef std::tr1::shared_ptr<ChannelArrayLocal> ChannelArrayLocalPtr;
|
||||
|
||||
class ChannelLocalDebug {
|
||||
public:
|
||||
static void setLevel(int level);
|
||||
static int getLevel();
|
||||
};
|
||||
|
||||
static bool getProcess(PVStructurePtr pvRequest,bool processDefault)
|
||||
{
|
||||
PVFieldPtr pvField = pvRequest->getSubField("record._options.process");
|
||||
@@ -69,12 +63,19 @@ class ChannelProcessLocal :
|
||||
{
|
||||
public:
|
||||
POINTER_DEFINITIONS(ChannelProcessLocal);
|
||||
virtual ~ChannelProcessLocal() {destroy();}
|
||||
virtual ~ChannelProcessLocal()
|
||||
{
|
||||
if(channelLocalDebug->getLevel()>0)
|
||||
{
|
||||
std::cout << "~ChannelProcessLocal() " << std::endl;
|
||||
}
|
||||
}
|
||||
static ChannelProcessLocalPtr create(
|
||||
ChannelLocalPtr const &channelLocal,
|
||||
ChannelProcessRequester::shared_pointer const & channelProcessRequester,
|
||||
PVStructurePtr const & pvRequest,
|
||||
PVRecordPtr const &pvRecord);
|
||||
PVRecordPtr const &pvRecord,
|
||||
ChannelLocalDebugPtr const &channelLocalDebug);
|
||||
virtual void process(bool lastRequest);
|
||||
virtual void destroy();
|
||||
virtual void lock() {thelock.lock();}
|
||||
@@ -88,12 +89,14 @@ private:
|
||||
ChannelLocalPtr const &channelLocal,
|
||||
ChannelProcessRequester::shared_pointer const & channelProcessRequester,
|
||||
PVRecordPtr const &pvRecord,
|
||||
ChannelLocalDebugPtr const &channelLocalDebug,
|
||||
int nProcess)
|
||||
:
|
||||
isDestroyed(false),
|
||||
channelLocal(channelLocal),
|
||||
channelProcessRequester(channelProcessRequester),
|
||||
pvRecord(pvRecord),
|
||||
channelLocalDebug(channelLocalDebug),
|
||||
thelock(mutex),
|
||||
nProcess(nProcess)
|
||||
{
|
||||
@@ -104,6 +107,7 @@ private:
|
||||
ChannelLocalPtr channelLocal;
|
||||
ChannelProcessRequester::shared_pointer channelProcessRequester,;
|
||||
PVRecordPtr pvRecord;
|
||||
ChannelLocalDebugPtr channelLocalDebug;
|
||||
Mutex mutex;
|
||||
Lock thelock;
|
||||
int nProcess;
|
||||
@@ -113,7 +117,8 @@ ChannelProcessLocalPtr ChannelProcessLocal::create(
|
||||
ChannelLocalPtr const &channelLocal,
|
||||
ChannelProcessRequester::shared_pointer const & channelProcessRequester,
|
||||
PVStructurePtr const & pvRequest,
|
||||
PVRecordPtr const &pvRecord)
|
||||
PVRecordPtr const &pvRecord,
|
||||
ChannelLocalDebugPtr const &channelLocalDebug)
|
||||
{
|
||||
PVFieldPtr pvField;
|
||||
PVStructurePtr pvOptions;
|
||||
@@ -137,7 +142,13 @@ ChannelProcessLocalPtr ChannelProcessLocal::create(
|
||||
channelLocal,
|
||||
channelProcessRequester,
|
||||
pvRecord,
|
||||
channelLocalDebug,
|
||||
nProcess));
|
||||
if(channelLocalDebug->getLevel()>0)
|
||||
{
|
||||
std::cout << "ChannelProcessLocal::create";
|
||||
std::cout << " recordName " << pvRecord->getRecordName() << std::endl;
|
||||
}
|
||||
channelLocal->addChannelProcess(process);
|
||||
channelProcessRequester->channelProcessConnect(Status::Ok, process);
|
||||
return process;
|
||||
@@ -146,6 +157,11 @@ ChannelProcessLocalPtr ChannelProcessLocal::create(
|
||||
|
||||
void ChannelProcessLocal::destroy()
|
||||
{
|
||||
if(channelLocalDebug->getLevel()>0)
|
||||
{
|
||||
std::cout << "ChannelProcessLocal::destroy";
|
||||
std::cout << " destroyed " << isDestroyed << std::endl;
|
||||
}
|
||||
if(isDestroyed) return;
|
||||
isDestroyed = true;
|
||||
channelLocal->removeChannelProcess(getPtrSelf());
|
||||
@@ -156,6 +172,18 @@ void ChannelProcessLocal::destroy()
|
||||
|
||||
void ChannelProcessLocal::process(bool lastRequest)
|
||||
{
|
||||
if(isDestroyed) {
|
||||
Status status(
|
||||
Status::Status::STATUSTYPE_ERROR,
|
||||
"was destroyed");
|
||||
channelProcessRequester->processDone(status);
|
||||
return;
|
||||
}
|
||||
if(channelLocalDebug->getLevel()>1)
|
||||
{
|
||||
std::cout << "ChannelProcessLocal::process";
|
||||
std::cout << " nProcess " << nProcess << std::endl;
|
||||
}
|
||||
for(int i=0; i< nProcess; i++) {
|
||||
pvRecord->lock();
|
||||
pvRecord->beginGroupPut();
|
||||
@@ -163,12 +191,6 @@ void ChannelProcessLocal::process(bool lastRequest)
|
||||
pvRecord->endGroupPut();
|
||||
pvRecord->unlock();
|
||||
}
|
||||
if(isDestroyed) {
|
||||
Status status(
|
||||
Status::Status::STATUSTYPE_ERROR,
|
||||
"was destroyed");
|
||||
channelProcessRequester->processDone(status);
|
||||
}
|
||||
channelProcessRequester->processDone(Status::Ok);
|
||||
if(lastRequest) destroy();
|
||||
}
|
||||
@@ -179,12 +201,19 @@ class ChannelGetLocal :
|
||||
{
|
||||
public:
|
||||
POINTER_DEFINITIONS(ChannelGetLocal);
|
||||
virtual ~ChannelGetLocal(){destroy();}
|
||||
virtual ~ChannelGetLocal()
|
||||
{
|
||||
if(channelLocalDebug->getLevel()>0)
|
||||
{
|
||||
std::cout << "~ChannelGetLocal()" << std::endl;
|
||||
}
|
||||
}
|
||||
static ChannelGetLocalPtr create(
|
||||
ChannelLocalPtr const &channelLocal,
|
||||
ChannelGetRequester::shared_pointer const & channelGetRequester,
|
||||
PVStructurePtr const & pvRequest,
|
||||
PVRecordPtr const &pvRecord);
|
||||
PVRecordPtr const &pvRecord,
|
||||
ChannelLocalDebugPtr const &channelLocalDebug);
|
||||
virtual void get(bool lastRequest);
|
||||
virtual void destroy();
|
||||
virtual void lock() {thelock.lock();}
|
||||
@@ -201,7 +230,8 @@ private:
|
||||
PVCopyPtr const &pvCopy,
|
||||
PVStructurePtr const&pvStructure,
|
||||
BitSetPtr const & bitSet,
|
||||
PVRecordPtr const &pvRecord)
|
||||
PVRecordPtr const &pvRecord,
|
||||
ChannelLocalDebugPtr const &channelLocalDebug)
|
||||
:
|
||||
firstTime(true),
|
||||
isDestroyed(false),
|
||||
@@ -212,6 +242,7 @@ private:
|
||||
pvStructure(pvStructure),
|
||||
bitSet(bitSet),
|
||||
pvRecord(pvRecord),
|
||||
channelLocalDebug(channelLocalDebug),
|
||||
thelock(mutex)
|
||||
{
|
||||
thelock.unlock();
|
||||
@@ -225,6 +256,7 @@ private:
|
||||
PVStructurePtr pvStructure;
|
||||
BitSetPtr bitSet;
|
||||
PVRecordPtr pvRecord;
|
||||
ChannelLocalDebugPtr channelLocalDebug;
|
||||
Mutex mutex;
|
||||
Lock thelock;
|
||||
};
|
||||
@@ -233,7 +265,8 @@ ChannelGetLocalPtr ChannelGetLocal::create(
|
||||
ChannelLocalPtr const &channelLocal,
|
||||
ChannelGetRequester::shared_pointer const & channelGetRequester,
|
||||
PVStructurePtr const & pvRequest,
|
||||
PVRecordPtr const &pvRecord)
|
||||
PVRecordPtr const &pvRecord,
|
||||
ChannelLocalDebugPtr const &channelLocalDebug)
|
||||
{
|
||||
PVCopyPtr pvCopy = PVCopy::create(
|
||||
pvRecord,
|
||||
@@ -263,7 +296,13 @@ ChannelGetLocalPtr ChannelGetLocal::create(
|
||||
pvCopy,
|
||||
pvStructure,
|
||||
bitSet,
|
||||
pvRecord));
|
||||
pvRecord,
|
||||
channelLocalDebug));
|
||||
if(channelLocalDebug->getLevel()>0)
|
||||
{
|
||||
std::cout << "ChannelGetLocal::create";
|
||||
std::cout << " recordName " << pvRecord->getRecordName() << std::endl;
|
||||
}
|
||||
channelLocal->addChannelGet(get);
|
||||
channelGetRequester->channelGetConnect(Status::Ok, get, pvStructure,bitSet);
|
||||
return get;
|
||||
@@ -272,6 +311,11 @@ ChannelGetLocalPtr ChannelGetLocal::create(
|
||||
|
||||
void ChannelGetLocal::destroy()
|
||||
{
|
||||
if(channelLocalDebug->getLevel()>0)
|
||||
{
|
||||
std::cout << "ChannelGetLocal::destroy";
|
||||
std::cout << " destroyed " << isDestroyed << std::endl;
|
||||
}
|
||||
if(isDestroyed) return;
|
||||
isDestroyed = true;
|
||||
channelLocal->removeChannelGet(getPtrSelf());
|
||||
@@ -290,6 +334,7 @@ void ChannelGetLocal::get(bool lastRequest)
|
||||
Status::Status::STATUSTYPE_ERROR,
|
||||
"was destroyed");
|
||||
channelGetRequester->getDone(status);
|
||||
return;
|
||||
}
|
||||
bitSet->clear();
|
||||
pvRecord->lock();
|
||||
@@ -306,6 +351,10 @@ void ChannelGetLocal::get(bool lastRequest)
|
||||
firstTime = false;
|
||||
}
|
||||
channelGetRequester->getDone(Status::Ok);
|
||||
if(channelLocalDebug->getLevel()>1)
|
||||
{
|
||||
std::cout << "ChannelGetLocal::get" << std::endl;
|
||||
}
|
||||
if(lastRequest) destroy();
|
||||
}
|
||||
|
||||
@@ -315,12 +364,19 @@ class ChannelPutLocal :
|
||||
{
|
||||
public:
|
||||
POINTER_DEFINITIONS(ChannelPutLocal);
|
||||
virtual ~ChannelPutLocal(){destroy();}
|
||||
virtual ~ChannelPutLocal()
|
||||
{
|
||||
if(channelLocalDebug->getLevel()>0)
|
||||
{
|
||||
std::cout << "~ChannelPutLocal()" << std::endl;
|
||||
}
|
||||
}
|
||||
static ChannelPutLocalPtr create(
|
||||
ChannelLocalPtr const &channelLocal,
|
||||
ChannelPutRequester::shared_pointer const & channelPutRequester,
|
||||
PVStructurePtr const & pvRequest,
|
||||
PVRecordPtr const &pvRecord);
|
||||
PVRecordPtr const &pvRecord,
|
||||
ChannelLocalDebugPtr const &channelLocalDebug);
|
||||
virtual void put(bool lastRequest);
|
||||
virtual void get();
|
||||
virtual void destroy();
|
||||
@@ -338,7 +394,8 @@ private:
|
||||
PVCopyPtr const &pvCopy,
|
||||
PVStructurePtr const&pvStructure,
|
||||
BitSetPtr const & bitSet,
|
||||
PVRecordPtr const &pvRecord)
|
||||
PVRecordPtr const &pvRecord,
|
||||
ChannelLocalDebugPtr const &channelLocalDebug)
|
||||
:
|
||||
isDestroyed(false),
|
||||
callProcess(callProcess),
|
||||
@@ -348,6 +405,7 @@ private:
|
||||
pvStructure(pvStructure),
|
||||
bitSet(bitSet),
|
||||
pvRecord(pvRecord),
|
||||
channelLocalDebug(channelLocalDebug),
|
||||
thelock(mutex)
|
||||
{
|
||||
thelock.unlock();
|
||||
@@ -360,6 +418,7 @@ private:
|
||||
PVStructurePtr pvStructure;
|
||||
BitSetPtr bitSet;
|
||||
PVRecordPtr pvRecord;
|
||||
ChannelLocalDebugPtr channelLocalDebug;
|
||||
Mutex mutex;
|
||||
Lock thelock;
|
||||
};
|
||||
@@ -368,7 +427,8 @@ ChannelPutLocalPtr ChannelPutLocal::create(
|
||||
ChannelLocalPtr const &channelLocal,
|
||||
ChannelPutRequester::shared_pointer const & channelPutRequester,
|
||||
PVStructurePtr const & pvRequest,
|
||||
PVRecordPtr const &pvRecord)
|
||||
PVRecordPtr const &pvRecord,
|
||||
ChannelLocalDebugPtr const &channelLocalDebug)
|
||||
{
|
||||
PVCopyPtr pvCopy = PVCopy::create(
|
||||
pvRecord,
|
||||
@@ -398,14 +458,25 @@ ChannelPutLocalPtr ChannelPutLocal::create(
|
||||
pvCopy,
|
||||
pvStructure,
|
||||
bitSet,
|
||||
pvRecord));
|
||||
pvRecord,
|
||||
channelLocalDebug));
|
||||
channelLocal->addChannelPut(put);
|
||||
channelPutRequester->channelPutConnect(Status::Ok, put, pvStructure,bitSet);
|
||||
if(channelLocalDebug->getLevel()>0)
|
||||
{
|
||||
std::cout << "ChannelPutLocal::create";
|
||||
std::cout << " recordName " << pvRecord->getRecordName() << std::endl;
|
||||
}
|
||||
return put;
|
||||
}
|
||||
|
||||
void ChannelPutLocal::destroy()
|
||||
{
|
||||
if(channelLocalDebug->getLevel()>0)
|
||||
{
|
||||
std::cout << "ChannelPutLocal::destroy";
|
||||
std::cout << " destroyed " << isDestroyed << std::endl;
|
||||
}
|
||||
if(isDestroyed) return;
|
||||
isDestroyed = true;
|
||||
channelLocal->removeChannelPut(getPtrSelf());
|
||||
@@ -424,6 +495,7 @@ void ChannelPutLocal::get()
|
||||
Status::Status::STATUSTYPE_ERROR,
|
||||
"was destroyed");
|
||||
channelPutRequester->getDone(status);
|
||||
return;
|
||||
}
|
||||
bitSet->clear();
|
||||
bitSet->set(0);
|
||||
@@ -431,6 +503,10 @@ void ChannelPutLocal::get()
|
||||
pvCopy->updateCopyFromBitSet(pvStructure, bitSet, false);
|
||||
pvRecord->unlock();
|
||||
channelPutRequester->getDone(Status::Ok);
|
||||
if(channelLocalDebug->getLevel()>1)
|
||||
{
|
||||
std::cout << "ChannelPutLocal::get" << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
void ChannelPutLocal::put(bool lastRequest)
|
||||
@@ -440,6 +516,7 @@ void ChannelPutLocal::put(bool lastRequest)
|
||||
Status::Status::STATUSTYPE_ERROR,
|
||||
"was destroyed");
|
||||
channelPutRequester->getDone(status);
|
||||
return;
|
||||
}
|
||||
pvRecord->lock();
|
||||
pvRecord->beginGroupPut();
|
||||
@@ -449,7 +526,11 @@ void ChannelPutLocal::put(bool lastRequest)
|
||||
}
|
||||
pvRecord->endGroupPut();
|
||||
pvRecord->unlock();
|
||||
channelPutRequester->getDone(Status::Ok);
|
||||
channelPutRequester->putDone(Status::Ok);
|
||||
if(channelLocalDebug->getLevel()>1)
|
||||
{
|
||||
std::cout << "ChannelPutLocal::get" << std::endl;
|
||||
}
|
||||
if(lastRequest) destroy();
|
||||
}
|
||||
|
||||
@@ -460,12 +541,19 @@ class ChannelPutGetLocal :
|
||||
{
|
||||
public:
|
||||
POINTER_DEFINITIONS(ChannelPutGetLocal);
|
||||
virtual ~ChannelPutGetLocal(){destroy();}
|
||||
virtual ~ChannelPutGetLocal()
|
||||
{
|
||||
if(channelLocalDebug->getLevel()>0)
|
||||
{
|
||||
std::cout << "~ChannelPutGetLocal()" << std::endl;
|
||||
}
|
||||
}
|
||||
static ChannelPutGetLocalPtr create(
|
||||
ChannelLocalPtr const &channelLocal,
|
||||
ChannelPutGetRequester::shared_pointer const & channelPutGetRequester,
|
||||
PVStructurePtr const & pvRequest,
|
||||
PVRecordPtr const &pvRecord);
|
||||
PVRecordPtr const &pvRecord,
|
||||
ChannelLocalDebugPtr const &channelLocalDebug);
|
||||
virtual void putGet(bool lastRequest);
|
||||
virtual void getPut();
|
||||
virtual void getGet();
|
||||
@@ -487,7 +575,8 @@ private:
|
||||
PVStructurePtr const&pvGetStructure,
|
||||
BitSetPtr const & putBitSet,
|
||||
BitSetPtr const & getBitSet,
|
||||
PVRecordPtr const &pvRecord)
|
||||
PVRecordPtr const &pvRecord,
|
||||
ChannelLocalDebugPtr const &channelLocalDebug)
|
||||
:
|
||||
isDestroyed(false),
|
||||
callProcess(callProcess),
|
||||
@@ -500,6 +589,7 @@ private:
|
||||
putBitSet(putBitSet),
|
||||
getBitSet(getBitSet),
|
||||
pvRecord(pvRecord),
|
||||
channelLocalDebug(channelLocalDebug),
|
||||
thelock(mutex)
|
||||
{
|
||||
thelock.unlock();
|
||||
@@ -515,6 +605,7 @@ private:
|
||||
BitSetPtr putBitSet;
|
||||
BitSetPtr getBitSet;
|
||||
PVRecordPtr pvRecord;
|
||||
ChannelLocalDebugPtr channelLocalDebug;
|
||||
Mutex mutex;
|
||||
Lock thelock;
|
||||
};
|
||||
@@ -523,7 +614,8 @@ ChannelPutGetLocalPtr ChannelPutGetLocal::create(
|
||||
ChannelLocalPtr const &channelLocal,
|
||||
ChannelPutGetRequester::shared_pointer const & channelPutGetRequester,
|
||||
PVStructurePtr const & pvRequest,
|
||||
PVRecordPtr const &pvRecord)
|
||||
PVRecordPtr const &pvRecord,
|
||||
ChannelLocalDebugPtr const &channelLocalDebug)
|
||||
{
|
||||
PVCopyPtr pvPutCopy = PVCopy::create(
|
||||
pvRecord,
|
||||
@@ -562,7 +654,13 @@ ChannelPutGetLocalPtr ChannelPutGetLocal::create(
|
||||
pvGetStructure,
|
||||
putBitSet,
|
||||
getBitSet,
|
||||
pvRecord));
|
||||
pvRecord,
|
||||
channelLocalDebug));
|
||||
if(channelLocalDebug->getLevel()>0)
|
||||
{
|
||||
std::cout << "ChannelPutGetLocal::create";
|
||||
std::cout << " recordName " << pvRecord->getRecordName() << std::endl;
|
||||
}
|
||||
channelLocal->addChannelPutGet(putGet);
|
||||
channelPutGetRequester->channelPutGetConnect(
|
||||
Status::Ok, putGet, pvPutStructure,pvGetStructure);
|
||||
@@ -572,6 +670,11 @@ ChannelPutGetLocalPtr ChannelPutGetLocal::create(
|
||||
|
||||
void ChannelPutGetLocal::destroy()
|
||||
{
|
||||
if(channelLocalDebug->getLevel()>0)
|
||||
{
|
||||
std::cout << "ChannelPutGetLocal::destroy";
|
||||
std::cout << " destroyed " << isDestroyed << std::endl;
|
||||
}
|
||||
if(isDestroyed) return;
|
||||
isDestroyed = true;
|
||||
channelLocal->removeChannelPutGet(getPtrSelf());
|
||||
@@ -593,6 +696,7 @@ void ChannelPutGetLocal::putGet(bool lastRequest)
|
||||
Status::Status::STATUSTYPE_ERROR,
|
||||
"was destroyed");
|
||||
channelPutGetRequester->putGetDone(status);
|
||||
return;
|
||||
}
|
||||
putBitSet->clear();
|
||||
putBitSet->set(0);
|
||||
@@ -606,6 +710,10 @@ void ChannelPutGetLocal::putGet(bool lastRequest)
|
||||
getBitSet->clear();
|
||||
getBitSet->set(0);
|
||||
channelPutGetRequester->putGetDone(Status::Ok);
|
||||
if(channelLocalDebug->getLevel()>1)
|
||||
{
|
||||
std::cout << "ChannelPutGetLocal::putGet" << std::endl;
|
||||
}
|
||||
if(lastRequest) destroy();
|
||||
}
|
||||
|
||||
@@ -616,6 +724,7 @@ void ChannelPutGetLocal::getPut()
|
||||
Status::Status::STATUSTYPE_ERROR,
|
||||
"was destroyed");
|
||||
channelPutGetRequester->getPutDone(status);
|
||||
return;
|
||||
}
|
||||
pvRecord->lock();
|
||||
pvPutCopy->updateCopySetBitSet(pvPutStructure, putBitSet, false);
|
||||
@@ -623,6 +732,10 @@ void ChannelPutGetLocal::getPut()
|
||||
putBitSet->clear();
|
||||
putBitSet->set(0);
|
||||
channelPutGetRequester->getPutDone(Status::Ok);
|
||||
if(channelLocalDebug->getLevel()>1)
|
||||
{
|
||||
std::cout << "ChannelPutGetLocal::getPut" << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
void ChannelPutGetLocal::getGet()
|
||||
@@ -632,6 +745,7 @@ void ChannelPutGetLocal::getGet()
|
||||
Status::Status::STATUSTYPE_ERROR,
|
||||
"was destroyed");
|
||||
channelPutGetRequester->getGetDone(status);
|
||||
return;
|
||||
}
|
||||
pvRecord->lock();
|
||||
pvGetCopy->updateCopySetBitSet(pvGetStructure, getBitSet, false);
|
||||
@@ -639,6 +753,10 @@ void ChannelPutGetLocal::getGet()
|
||||
getBitSet->clear();
|
||||
getBitSet->set(0);
|
||||
channelPutGetRequester->getGetDone(Status::Ok);
|
||||
if(channelLocalDebug->getLevel()>1)
|
||||
{
|
||||
std::cout << "ChannelPutGetLocal::getGet" << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
class ChannelRPCLocal :
|
||||
@@ -657,38 +775,32 @@ public:
|
||||
bool lastRequest);
|
||||
};
|
||||
|
||||
int ChannelLocalDebugLevel = 0;
|
||||
void ChannelLocalDebug::setLevel(int level) {ChannelLocalDebugLevel = level;}
|
||||
int ChannelLocalDebug::getLevel() {return ChannelLocalDebugLevel;}
|
||||
|
||||
|
||||
|
||||
ChannelLocal::ChannelLocal(
|
||||
ChannelProviderLocalPtr const & provider,
|
||||
ChannelRequester::shared_pointer const & requester,
|
||||
PVRecordPtr const & pvRecord)
|
||||
PVRecordPtr const & pvRecord,
|
||||
ChannelLocalDebugPtr const &channelLocalDebug)
|
||||
: provider(provider),
|
||||
requester(requester),
|
||||
pvRecord(pvRecord),
|
||||
channelLocalDebug(channelLocalDebug),
|
||||
beingDestroyed(false)
|
||||
{
|
||||
if(ChannelLocalDebug::getLevel()>0) {
|
||||
printf("ChannelLocal::ChannelLocal\n");
|
||||
}
|
||||
}
|
||||
|
||||
ChannelLocal::~ChannelLocal()
|
||||
{
|
||||
if(ChannelLocalDebug::getLevel()>0) {
|
||||
printf("ChannelLocal::~ChannelLocal\n");
|
||||
if(channelLocalDebug->getLevel()>0) {
|
||||
std::cout << "~ChannelLocal()" << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
void ChannelLocal::destroy()
|
||||
{
|
||||
if(ChannelLocalDebug::getLevel()>0) {
|
||||
printf("ChannelLocal::destroy beingDestroyed %s\n",
|
||||
(beingDestroyed ? "true" : "false"));
|
||||
if(channelLocalDebug->getLevel()>0) {
|
||||
std::cout << "ChannelLocal::destroy() ";
|
||||
std::cout << "beingDestroyed " << beingDestroyed << std::endl;
|
||||
}
|
||||
{
|
||||
Lock xx(mutex);
|
||||
@@ -723,13 +835,6 @@ void ChannelLocal::destroy()
|
||||
it->get()->destroy();
|
||||
channelPutGetList.erase(it);
|
||||
}
|
||||
while(true) {
|
||||
std::set<Monitor::shared_pointer>::iterator it;
|
||||
it = channelMonitorList.begin();
|
||||
if(it==channelMonitorList.end()) break;
|
||||
it->get()->destroy();
|
||||
channelMonitorList.erase(it);
|
||||
}
|
||||
while(true) {
|
||||
std::set<ChannelRPC::shared_pointer>::iterator it;
|
||||
it = channelRPCList.begin();
|
||||
@@ -750,8 +855,8 @@ void ChannelLocal::destroy()
|
||||
|
||||
void ChannelLocal::addChannelProcess(ChannelProcess::shared_pointer const & channelProcess)
|
||||
{
|
||||
if(ChannelLocalDebug::getLevel()>0) {
|
||||
printf("ChannelLocal::addChannelProcess\n");
|
||||
if(channelLocalDebug->getLevel()>1) {
|
||||
std::cout << "ChannelLocal::addChannelProcess() " << std::endl;
|
||||
}
|
||||
Lock xx(mutex);
|
||||
if(beingDestroyed) return;
|
||||
@@ -760,8 +865,8 @@ void ChannelLocal::addChannelProcess(ChannelProcess::shared_pointer const & chan
|
||||
|
||||
void ChannelLocal::addChannelGet(ChannelGet::shared_pointer const &channelGet)
|
||||
{
|
||||
if(ChannelLocalDebug::getLevel()>0) {
|
||||
printf("ChannelLocal::addChannelGet\n");
|
||||
if(channelLocalDebug->getLevel()>1) {
|
||||
std::cout << "ChannelLocal::addChannelGet() " << std::endl;
|
||||
}
|
||||
Lock xx(mutex);
|
||||
if(beingDestroyed) return;
|
||||
@@ -770,8 +875,8 @@ void ChannelLocal::addChannelGet(ChannelGet::shared_pointer const &channelGet)
|
||||
|
||||
void ChannelLocal::addChannelPut(ChannelPut::shared_pointer const &channelPut)
|
||||
{
|
||||
if(ChannelLocalDebug::getLevel()>0) {
|
||||
printf("ChannelLocal::addChannelPut\n");
|
||||
if(channelLocalDebug->getLevel()>1) {
|
||||
std::cout << "ChannelLocal::addChannelPut() " << std::endl;
|
||||
}
|
||||
Lock xx(mutex);
|
||||
if(beingDestroyed) return;
|
||||
@@ -780,28 +885,18 @@ void ChannelLocal::addChannelPut(ChannelPut::shared_pointer const &channelPut)
|
||||
|
||||
void ChannelLocal::addChannelPutGet(ChannelPutGet::shared_pointer const &channelPutGet)
|
||||
{
|
||||
if(ChannelLocalDebug::getLevel()>0) {
|
||||
printf("ChannelLocal::addChannelPutGet\n");
|
||||
if(channelLocalDebug->getLevel()>1) {
|
||||
std::cout << "ChannelLocal::addChannelPutGet() " << std::endl;
|
||||
}
|
||||
Lock xx(mutex);
|
||||
if(beingDestroyed) return;
|
||||
channelPutGetList.insert(channelPutGet);
|
||||
}
|
||||
|
||||
void ChannelLocal::addChannelMonitor(Monitor::shared_pointer const &monitor)
|
||||
{
|
||||
if(ChannelLocalDebug::getLevel()>0) {
|
||||
printf("ChannelLocal::addChannelMonitor\n");
|
||||
}
|
||||
Lock xx(mutex);
|
||||
if(beingDestroyed) return;
|
||||
channelMonitorList.insert(monitor);
|
||||
}
|
||||
|
||||
void ChannelLocal::addChannelRPC(ChannelRPC::shared_pointer const &channelRPC)
|
||||
{
|
||||
if(ChannelLocalDebug::getLevel()>0) {
|
||||
printf("ChannelLocal::addChannelRPC\n");
|
||||
if(channelLocalDebug->getLevel()>1) {
|
||||
std::cout << "ChannelLocal::addChannelRPC() " << std::endl;
|
||||
}
|
||||
Lock xx(mutex);
|
||||
if(beingDestroyed) return;
|
||||
@@ -810,8 +905,8 @@ void ChannelLocal::addChannelRPC(ChannelRPC::shared_pointer const &channelRPC)
|
||||
|
||||
void ChannelLocal::addChannelArray(ChannelArray::shared_pointer const &channelArray)
|
||||
{
|
||||
if(ChannelLocalDebug::getLevel()>0) {
|
||||
printf("ChannelLocal::addChannelArray\n");
|
||||
if(channelLocalDebug->getLevel()>1) {
|
||||
std::cout << "ChannelLocal::addChannelArray() " << std::endl;
|
||||
}
|
||||
Lock xx(mutex);
|
||||
if(beingDestroyed) return;
|
||||
@@ -820,8 +915,8 @@ void ChannelLocal::addChannelArray(ChannelArray::shared_pointer const &channelAr
|
||||
|
||||
void ChannelLocal::removeChannelProcess(ChannelProcess::shared_pointer const &ref)
|
||||
{
|
||||
if(ChannelLocalDebug::getLevel()>0) {
|
||||
printf("ChannelLocal::removeChannelProcess\n");
|
||||
if(channelLocalDebug->getLevel()>1) {
|
||||
std::cout << "ChannelLocal::removeChannelProcess() " << std::endl;
|
||||
}
|
||||
Lock xx(mutex);
|
||||
if(beingDestroyed) return;
|
||||
@@ -830,8 +925,8 @@ void ChannelLocal::removeChannelProcess(ChannelProcess::shared_pointer const &re
|
||||
|
||||
void ChannelLocal::removeChannelGet(ChannelGet::shared_pointer const &ref)
|
||||
{
|
||||
if(ChannelLocalDebug::getLevel()>0) {
|
||||
printf("ChannelLocal::removeChannelGet\n");
|
||||
if(channelLocalDebug->getLevel()>1) {
|
||||
std::cout << "ChannelLocal::removeChannelGet() " << std::endl;
|
||||
}
|
||||
Lock xx(mutex);
|
||||
if(beingDestroyed) return;
|
||||
@@ -840,8 +935,8 @@ void ChannelLocal::removeChannelGet(ChannelGet::shared_pointer const &ref)
|
||||
|
||||
void ChannelLocal::removeChannelPut(ChannelPut::shared_pointer const &ref)
|
||||
{
|
||||
if(ChannelLocalDebug::getLevel()>0) {
|
||||
printf("ChannelLocal::removeChannelPut\n");
|
||||
if(channelLocalDebug->getLevel()>1) {
|
||||
std::cout << "ChannelLocal::removeChannelPut() " << std::endl;
|
||||
}
|
||||
Lock xx(mutex);
|
||||
if(beingDestroyed) return;
|
||||
@@ -850,28 +945,18 @@ void ChannelLocal::removeChannelPut(ChannelPut::shared_pointer const &ref)
|
||||
|
||||
void ChannelLocal::removeChannelPutGet(ChannelPutGet::shared_pointer const &ref)
|
||||
{
|
||||
if(ChannelLocalDebug::getLevel()>0) {
|
||||
printf("ChannelLocal::removeChannelPutGet\n");
|
||||
if(channelLocalDebug->getLevel()>1) {
|
||||
std::cout << "ChannelLocal::removeChannelPutGet() " << std::endl;
|
||||
}
|
||||
Lock xx(mutex);
|
||||
if(beingDestroyed) return;
|
||||
channelPutGetList.erase(ref);
|
||||
}
|
||||
|
||||
void ChannelLocal::removeChannelMonitor(Monitor::shared_pointer const &ref)
|
||||
{
|
||||
if(ChannelLocalDebug::getLevel()>0) {
|
||||
printf("ChannelLocal::removeChannelMonitor\n");
|
||||
}
|
||||
Lock xx(mutex);
|
||||
if(beingDestroyed) return;
|
||||
channelMonitorList.erase(ref);
|
||||
}
|
||||
|
||||
void ChannelLocal::removeChannelRPC(ChannelRPC::shared_pointer const &ref)
|
||||
{
|
||||
if(ChannelLocalDebug::getLevel()>0) {
|
||||
printf("ChannelLocal::removeChannelRPC\n");
|
||||
if(channelLocalDebug->getLevel()>1) {
|
||||
std::cout << "ChannelLocal::removeChannelRPC() " << std::endl;
|
||||
}
|
||||
Lock xx(mutex);
|
||||
if(beingDestroyed) return;
|
||||
@@ -880,8 +965,8 @@ void ChannelLocal::removeChannelRPC(ChannelRPC::shared_pointer const &ref)
|
||||
|
||||
void ChannelLocal::removeChannelArray(ChannelArray::shared_pointer const &ref)
|
||||
{
|
||||
if(ChannelLocalDebug::getLevel()>0) {
|
||||
printf("ChannelLocal::removeChannelArray\n");
|
||||
if(channelLocalDebug->getLevel()>1) {
|
||||
std::cout << "ChannelLocal::removeChannelArray() " << std::endl;
|
||||
}
|
||||
Lock xx(mutex);
|
||||
if(beingDestroyed) return;
|
||||
@@ -900,11 +985,6 @@ void ChannelLocal::message(
|
||||
requester->message(message,messageType);
|
||||
}
|
||||
|
||||
ChannelProvider::shared_pointer ChannelLocal::getProvider()
|
||||
{
|
||||
return provider;
|
||||
}
|
||||
|
||||
String ChannelLocal::getRemoteAddress()
|
||||
{
|
||||
return String("local");
|
||||
@@ -963,7 +1043,8 @@ ChannelProcess::shared_pointer ChannelLocal::createChannelProcess(
|
||||
getPtrSelf(),
|
||||
channelProcessRequester,
|
||||
pvRequest,
|
||||
pvRecord);
|
||||
pvRecord,
|
||||
channelLocalDebug);
|
||||
return channelProcess;
|
||||
}
|
||||
|
||||
@@ -976,7 +1057,8 @@ ChannelGet::shared_pointer ChannelLocal::createChannelGet(
|
||||
getPtrSelf(),
|
||||
channelGetRequester,
|
||||
pvRequest,
|
||||
pvRecord);
|
||||
pvRecord,
|
||||
channelLocalDebug);
|
||||
return channelGet;
|
||||
}
|
||||
|
||||
@@ -989,7 +1071,8 @@ ChannelPut::shared_pointer ChannelLocal::createChannelPut(
|
||||
getPtrSelf(),
|
||||
channelPutRequester,
|
||||
pvRequest,
|
||||
pvRecord);
|
||||
pvRecord,
|
||||
channelLocalDebug);
|
||||
return channelPut;
|
||||
}
|
||||
|
||||
@@ -1002,7 +1085,8 @@ ChannelPutGet::shared_pointer ChannelLocal::createChannelPutGet(
|
||||
getPtrSelf(),
|
||||
channelPutGetRequester,
|
||||
pvRequest,
|
||||
pvRecord);
|
||||
pvRecord,
|
||||
channelLocalDebug);
|
||||
return channelPutGet;
|
||||
}
|
||||
|
||||
@@ -1021,7 +1105,11 @@ Monitor::shared_pointer ChannelLocal::createMonitor(
|
||||
PVStructure::shared_pointer const &pvRequest)
|
||||
{
|
||||
MonitorPtr monitor =
|
||||
getMonitorFactory()->createMonitor(pvRecord,monitorRequester,pvRequest);
|
||||
getMonitorFactory()->createMonitor(
|
||||
pvRecord,
|
||||
monitorRequester,
|
||||
pvRequest,
|
||||
channelLocalDebug);
|
||||
return monitor;
|
||||
}
|
||||
|
||||
@@ -1040,7 +1128,7 @@ ChannelArray::shared_pointer ChannelLocal::createChannelArray(
|
||||
|
||||
void ChannelLocal::printInfo()
|
||||
{
|
||||
printf("ChannelLocal provides access to service\n");
|
||||
std::cout << "ChannelLocal provides access to service" << std::endl;
|
||||
}
|
||||
|
||||
void ChannelLocal::printInfo(StringBuilder out)
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
/* channelListDebugRecord.cpp */
|
||||
/**
|
||||
* Copyright - See the COPYRIGHT that is included with this distribution.
|
||||
* EPICS pvData is distributed subject to a Software License Agreement found
|
||||
* in file LICENSE that is included with this distribution.
|
||||
*/
|
||||
/**
|
||||
* @author mrk
|
||||
* @date 2013.04.18
|
||||
*/
|
||||
|
||||
#include <pv/channelLocalDebugRecord.h>
|
||||
|
||||
using std::tr1::static_pointer_cast;
|
||||
using namespace epics::pvData;
|
||||
using namespace epics::pvAccess;
|
||||
using namespace std;
|
||||
|
||||
namespace epics { namespace pvDatabase {
|
||||
|
||||
ChannelLocalDebugRecordPtr ChannelLocalDebugRecord::create(
|
||||
ChannelLocalDebugPtr const &channelLocalDebug,
|
||||
epics::pvData::String const & recordName)
|
||||
{
|
||||
FieldCreatePtr fieldCreate = getFieldCreate();
|
||||
PVDataCreatePtr pvDataCreate = getPVDataCreate();
|
||||
StringArray argNames(1);
|
||||
FieldConstPtrArray argFields(1);
|
||||
argNames[0] = "value";
|
||||
argFields[0] = fieldCreate->createScalar(pvInt);
|
||||
StructureConstPtr topStructure =
|
||||
fieldCreate->createStructure(argNames,argFields);
|
||||
PVStructurePtr pvStructure = pvDataCreate->createPVStructure(topStructure);
|
||||
ChannelLocalDebugRecordPtr pvRecord(
|
||||
new ChannelLocalDebugRecord(channelLocalDebug,recordName,pvStructure));
|
||||
if(!pvRecord->init()) pvRecord.reset();
|
||||
return pvRecord;
|
||||
}
|
||||
|
||||
ChannelLocalDebugRecord::ChannelLocalDebugRecord(
|
||||
ChannelLocalDebugPtr const &channelLocalDebug,
|
||||
epics::pvData::String const & recordName,
|
||||
epics::pvData::PVStructurePtr const & pvStructure)
|
||||
: PVRecord(recordName,pvStructure),
|
||||
channelLocalDebug(channelLocalDebug)
|
||||
{
|
||||
}
|
||||
|
||||
ChannelLocalDebugRecord::~ChannelLocalDebugRecord()
|
||||
{
|
||||
}
|
||||
|
||||
void ChannelLocalDebugRecord::destroy()
|
||||
{
|
||||
PVRecord::destroy();
|
||||
}
|
||||
|
||||
bool ChannelLocalDebugRecord::init()
|
||||
{
|
||||
initPVRecord();
|
||||
PVStructurePtr pvStructure = getPVStructure();
|
||||
|
||||
pvValue = pvStructure->getIntField("value");
|
||||
if(pvValue==NULL) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
void ChannelLocalDebugRecord::process()
|
||||
{
|
||||
channelLocalDebug->setLevel(pvValue->get());
|
||||
}
|
||||
|
||||
|
||||
}}
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
/* channelLocalDebugRecord.h */
|
||||
/**
|
||||
* Copyright - See the COPYRIGHT that is included with this distribution.
|
||||
* EPICS pvData is distributed subject to a Software License Agreement found
|
||||
* in file LICENSE that is included with this distribution.
|
||||
*/
|
||||
/**
|
||||
* @author mrk
|
||||
* @date 2013.04.18
|
||||
*/
|
||||
#ifndef CHANNELLOCALREBUGRECORD_H
|
||||
#define CHANNELLOCALREBUGRECORD_H
|
||||
|
||||
#include <pv/channelProviderLocal.h>
|
||||
|
||||
namespace epics { namespace pvDatabase {
|
||||
|
||||
|
||||
class ChannelLocalDebugRecord;
|
||||
typedef std::tr1::shared_ptr<ChannelLocalDebugRecord> ChannelLocalDebugRecordPtr;
|
||||
|
||||
class ChannelLocalDebugRecord :
|
||||
public PVRecord
|
||||
{
|
||||
public:
|
||||
POINTER_DEFINITIONS(ChannelLocalDebugRecord);
|
||||
static ChannelLocalDebugRecordPtr create(
|
||||
ChannelLocalDebugPtr const &channelLocalDebug,
|
||||
epics::pvData::String const & recordName);
|
||||
virtual ~ChannelLocalDebugRecord();
|
||||
virtual void destroy();
|
||||
virtual bool init();
|
||||
virtual void process();
|
||||
private:
|
||||
ChannelLocalDebugRecord(
|
||||
ChannelLocalDebugPtr const &channelLocalDebug,
|
||||
epics::pvData::String const & recordName,
|
||||
epics::pvData::PVStructurePtr const & pvStructure);
|
||||
ChannelLocalDebugPtr channelLocalDebug;
|
||||
epics::pvData::PVIntPtr pvValue;
|
||||
bool isDestroyed;
|
||||
};
|
||||
|
||||
}}
|
||||
|
||||
#endif /* CHANNELLOCALREBUGRECORD_H */
|
||||
@@ -11,6 +11,7 @@
|
||||
|
||||
#include <pv/serverContext.h>
|
||||
#include <pv/channelProviderLocal.h>
|
||||
#include <pv/channelLocalDebugRecord.h>
|
||||
|
||||
namespace epics { namespace pvDatabase {
|
||||
|
||||
@@ -75,11 +76,13 @@ LocalChannelCTX::LocalChannelCTX(
|
||||
|
||||
LocalChannelCTX::~LocalChannelCTX()
|
||||
{
|
||||
std::cout << "LocalChannelCTX::~LocalChannelCTX()" << std::endl;
|
||||
ctx->shutdown();
|
||||
// we need thead.waitForCompletion()
|
||||
event.wait();
|
||||
epicsThreadSleep(1.0);
|
||||
ctx.reset();
|
||||
channelProvider.reset();
|
||||
delete thread;
|
||||
}
|
||||
void LocalChannelCTX::run()
|
||||
@@ -90,11 +93,7 @@ void LocalChannelCTX::run()
|
||||
ctx->initialize(getChannelAccess());
|
||||
ctx->printInfo();
|
||||
ctx->run(0);
|
||||
// Matej if I switch which is commented then errors when exit
|
||||
// BUT this way causes lots of memory leaks
|
||||
channelProvider->destroy();
|
||||
//ctx->destroy();
|
||||
// Matej end of comments
|
||||
ctx->destroy();
|
||||
event.signal();
|
||||
}
|
||||
|
||||
@@ -114,18 +113,27 @@ ChannelProviderLocalPtr getChannelProviderLocal()
|
||||
|
||||
ChannelProviderLocal::ChannelProviderLocal()
|
||||
: pvDatabase(PVDatabase::getMaster()),
|
||||
beingDestroyed(false)
|
||||
beingDestroyed(false),
|
||||
channelLocalDebug(new ChannelLocalDebug())
|
||||
{
|
||||
}
|
||||
|
||||
ChannelProviderLocal::~ChannelProviderLocal()
|
||||
{
|
||||
destroy();
|
||||
if(channelLocalDebug->getLevel()>0)
|
||||
{
|
||||
std::cout << "~ChannelProviderLocal()" << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
void ChannelProviderLocal::destroy()
|
||||
{
|
||||
Lock xx(mutex);
|
||||
if(channelLocalDebug->getLevel()>0)
|
||||
{
|
||||
std::cout << "ChannelProviderLocal::destroy";
|
||||
std::cout << " destroyed " << beingDestroyed << std::endl;
|
||||
}
|
||||
if(beingDestroyed) return;
|
||||
beingDestroyed = true;
|
||||
ChannelLocalList::iterator iter;
|
||||
@@ -135,7 +143,6 @@ void ChannelProviderLocal::destroy()
|
||||
(*iter)->destroy();
|
||||
channelList.erase(iter);
|
||||
}
|
||||
|
||||
pvDatabase->destroy();
|
||||
}
|
||||
|
||||
@@ -206,10 +213,15 @@ Channel::shared_pointer ChannelProviderLocal::createChannel(
|
||||
PVRecordPtr pvRecord = pvDatabase->findRecord(channelName);
|
||||
if(pvRecord.get()!=NULL) {
|
||||
Channel::shared_pointer channel(new ChannelLocal(
|
||||
getPtrSelf(),channelRequester,pvRecord));
|
||||
getPtrSelf(),channelRequester,pvRecord,channelLocalDebug));
|
||||
channelRequester->channelCreated(
|
||||
Status::Ok,
|
||||
channel);
|
||||
if(channelLocalDebug->getLevel()>1)
|
||||
{
|
||||
std::cout << "ChannelProviderLocal::createChannel";
|
||||
std::cout << " channelName " << channelName << std::endl;
|
||||
}
|
||||
return channel;
|
||||
}
|
||||
Status notFoundStatus(Status::STATUSTYPE_ERROR,String("pv not found"));
|
||||
@@ -228,10 +240,27 @@ void ChannelProviderLocal::removeChannel(
|
||||
for(iter = channelList.begin(); iter!=channelList.end(); ++iter)
|
||||
{
|
||||
if((*iter).get()==channel.get()) {
|
||||
if(channelLocalDebug->getLevel()>1)
|
||||
{
|
||||
std::cout << "ChannelProviderLocal::createChannel";
|
||||
std::cout << " channelName " << channel->getChannelName() << std::endl;
|
||||
}
|
||||
channelList.erase(iter);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ChannelProviderLocal::createChannelLocalDebugRecord(
|
||||
String const &recordName)
|
||||
{
|
||||
ChannelLocalDebugRecordPtr pvRecord
|
||||
= ChannelLocalDebugRecord::create(channelLocalDebug,recordName);
|
||||
PVDatabasePtr master = PVDatabase::getMaster();
|
||||
bool result = master->addRecord(pvRecord);
|
||||
if(!result) {
|
||||
cout << "result of addRecord " << recordName << " " << result << endl;
|
||||
}
|
||||
}
|
||||
|
||||
}}
|
||||
|
||||
@@ -28,9 +28,16 @@
|
||||
|
||||
namespace epics { namespace pvDatabase {
|
||||
|
||||
class ChannelLocalDebug;
|
||||
typedef std::tr1::shared_ptr<ChannelLocalDebug> ChannelLocalDebugPtr;
|
||||
|
||||
class MonitorFactory;
|
||||
typedef std::tr1::shared_ptr<MonitorFactory> MonitorFactoryPtr;
|
||||
|
||||
class MonitorLocal;
|
||||
typedef std::tr1::shared_ptr<MonitorLocal> MonitorLocalPtr;
|
||||
|
||||
|
||||
class ChannelProviderLocal;
|
||||
typedef std::tr1::shared_ptr<ChannelProviderLocal> ChannelProviderLocalPtr;
|
||||
class ChannelLocal;
|
||||
@@ -42,6 +49,23 @@ class MonitorLocal;
|
||||
typedef std::tr1::shared_ptr<MonitorLocal> MonitorLocalPtr;
|
||||
typedef std::set<MonitorLocalPtr> MonitorLocalList;
|
||||
|
||||
class ChannelLocalDebug {
|
||||
public:
|
||||
ChannelLocalDebug()
|
||||
: channelLocalDebugLevel(0)
|
||||
{}
|
||||
~ChannelLocalDebug(){}
|
||||
void setLevel(int level)
|
||||
{
|
||||
channelLocalDebugLevel = level;
|
||||
}
|
||||
int getLevel()
|
||||
{
|
||||
return channelLocalDebugLevel;
|
||||
}
|
||||
private:
|
||||
int channelLocalDebugLevel;
|
||||
};
|
||||
|
||||
class MonitorFactory
|
||||
{
|
||||
@@ -52,13 +76,14 @@ public:
|
||||
epics::pvData::MonitorPtr createMonitor(
|
||||
PVRecordPtr const & pvRecord,
|
||||
epics::pvData::MonitorRequester::shared_pointer const & monitorRequester,
|
||||
epics::pvData::PVStructurePtr const & pvRequest);
|
||||
epics::pvData::PVStructurePtr const & pvRequest,
|
||||
ChannelLocalDebugPtr const &channelLocalDebug);
|
||||
void registerMonitorAlgorithmCreate(
|
||||
MonitorAlgorithmCreatePtr const &monitorAlgorithmCreate);
|
||||
MonitorAlgorithmCreatePtr getMonitorAlgorithmCreate(epics::pvData::String algorithmName);
|
||||
MonitorAlgorithmCreatePtr getMonitorAlgorithmCreate(
|
||||
epics::pvData::String algorithmName);
|
||||
private:
|
||||
MonitorFactory();
|
||||
void removeMonitor(MonitorLocal * monitor);
|
||||
friend class MonitorLocal;
|
||||
friend MonitorFactoryPtr getMonitorFactory();
|
||||
std::set<MonitorAlgorithmCreatePtr> monitorAlgorithmCreateList;
|
||||
@@ -93,6 +118,7 @@ public:
|
||||
epics::pvData::String const &address);
|
||||
void removeChannel(
|
||||
epics::pvAccess::Channel::shared_pointer const &channel);
|
||||
void createChannelLocalDebugRecord(epics::pvData::String const &recordName);
|
||||
private:
|
||||
shared_pointer getPtrSelf()
|
||||
{
|
||||
@@ -104,6 +130,7 @@ private:
|
||||
ChannelLocalList channelList;
|
||||
epics::pvData::Mutex mutex;
|
||||
bool beingDestroyed;
|
||||
ChannelLocalDebugPtr channelLocalDebug;
|
||||
friend class ChannelProviderLocalRun;
|
||||
};
|
||||
|
||||
@@ -116,7 +143,8 @@ public:
|
||||
ChannelLocal(
|
||||
ChannelProviderLocalPtr const &channelProvider,
|
||||
epics::pvAccess::ChannelRequester::shared_pointer const & requester,
|
||||
PVRecordPtr const & pvRecord
|
||||
PVRecordPtr const & pvRecord,
|
||||
ChannelLocalDebugPtr const &channelLocalDebug
|
||||
);
|
||||
virtual ~ChannelLocal();
|
||||
virtual void destroy();
|
||||
@@ -124,7 +152,10 @@ public:
|
||||
virtual void message(
|
||||
epics::pvData::String const & message,
|
||||
epics::pvData::MessageType messageType);
|
||||
virtual epics::pvAccess::ChannelProvider::shared_pointer getProvider();
|
||||
virtual epics::pvAccess::ChannelProvider::shared_pointer getProvider()
|
||||
{
|
||||
return provider;
|
||||
}
|
||||
virtual epics::pvData::String getRemoteAddress();
|
||||
virtual epics::pvAccess::Channel::ConnectionState getConnectionState();
|
||||
virtual epics::pvData::String getChannelName();
|
||||
@@ -163,14 +194,12 @@ public:
|
||||
void addChannelGet(epics::pvAccess::ChannelGet::shared_pointer const &);
|
||||
void addChannelPut(epics::pvAccess::ChannelPut::shared_pointer const &);
|
||||
void addChannelPutGet(epics::pvAccess::ChannelPutGet::shared_pointer const &);
|
||||
void addChannelMonitor(epics::pvData::Monitor::shared_pointer const &);
|
||||
void addChannelRPC(epics::pvAccess::ChannelRPC::shared_pointer const &);
|
||||
void addChannelArray(epics::pvAccess::ChannelArray::shared_pointer const &);
|
||||
void removeChannelProcess(epics::pvAccess::ChannelProcess::shared_pointer const &);
|
||||
void removeChannelGet(epics::pvAccess::ChannelGet::shared_pointer const &);
|
||||
void removeChannelPut(epics::pvAccess::ChannelPut::shared_pointer const &);
|
||||
void removeChannelPutGet(epics::pvAccess::ChannelPutGet::shared_pointer const &);
|
||||
void removeChannelMonitor(epics::pvData::Monitor::shared_pointer const &);
|
||||
void removeChannelRPC(epics::pvAccess::ChannelRPC::shared_pointer const &);
|
||||
void removeChannelArray(epics::pvAccess::ChannelArray::shared_pointer const &);
|
||||
protected:
|
||||
@@ -182,12 +211,12 @@ private:
|
||||
ChannelProviderLocalPtr provider;
|
||||
epics::pvAccess::ChannelRequester::shared_pointer requester;
|
||||
PVRecordPtr pvRecord;
|
||||
ChannelLocalDebugPtr channelLocalDebug;
|
||||
bool beingDestroyed;
|
||||
std::set<epics::pvAccess::ChannelProcess::shared_pointer> channelProcessList;
|
||||
std::set<epics::pvAccess::ChannelGet::shared_pointer> channelGetList;
|
||||
std::set<epics::pvAccess::ChannelPut::shared_pointer> channelPutList;
|
||||
std::set<epics::pvAccess::ChannelPutGet::shared_pointer> channelPutGetList;
|
||||
std::set<epics::pvData::Monitor::shared_pointer> channelMonitorList;
|
||||
std::set<epics::pvAccess::ChannelRPC::shared_pointer> channelRPCList;
|
||||
std::set<epics::pvAccess::ChannelArray::shared_pointer> channelArrayList;
|
||||
epics::pvData::Mutex mutex;
|
||||
|
||||
@@ -38,9 +38,6 @@ typedef std::tr1::shared_ptr<NOQueue> NOQueuePtr;
|
||||
class RealQueue;
|
||||
typedef std::tr1::shared_ptr<RealQueue> RealQueuePtr;
|
||||
|
||||
class MonitorLocal;
|
||||
typedef std::tr1::shared_ptr<MonitorLocal> MonitorLocalPtr;
|
||||
|
||||
//class MonitorFieldNode
|
||||
//{
|
||||
//public:
|
||||
@@ -131,9 +128,9 @@ public:
|
||||
virtual void release(MonitorElementPtr const & monitorElement);
|
||||
bool init(PVStructurePtr const & pvRequest);
|
||||
MonitorLocal(
|
||||
ChannelProviderLocalPtr const &channelProvider,
|
||||
MonitorRequester::shared_pointer const & channelMonitorRequester,
|
||||
PVRecordPtr const &pvRecord);
|
||||
PVRecordPtr const &pvRecord,
|
||||
ChannelLocalDebugPtr const &channelLocalDebug);
|
||||
PVCopyPtr getPVCopy() { return pvCopy;}
|
||||
PVCopyMonitorPtr getPVCopyMonitor() { return pvCopyMonitor;}
|
||||
private:
|
||||
@@ -141,8 +138,9 @@ private:
|
||||
{
|
||||
return shared_from_this();
|
||||
}
|
||||
PVRecordPtr pvRecord;
|
||||
MonitorRequester::shared_pointer monitorRequester;
|
||||
PVRecordPtr pvRecord;
|
||||
ChannelLocalDebugPtr channelLocalDebug;
|
||||
bool isDestroyed;
|
||||
bool firstMonitor;
|
||||
PVCopyPtr pvCopy;
|
||||
@@ -153,11 +151,12 @@ private:
|
||||
};
|
||||
|
||||
MonitorLocal::MonitorLocal(
|
||||
ChannelProviderLocalPtr const &channelProvider,
|
||||
MonitorRequester::shared_pointer const & channelMonitorRequester,
|
||||
PVRecordPtr const &pvRecord)
|
||||
: pvRecord(pvRecord),
|
||||
monitorRequester(channelMonitorRequester),
|
||||
PVRecordPtr const &pvRecord,
|
||||
ChannelLocalDebugPtr const &channelLocalDebug)
|
||||
: monitorRequester(channelMonitorRequester),
|
||||
pvRecord(pvRecord),
|
||||
channelLocalDebug(channelLocalDebug),
|
||||
isDestroyed(false),
|
||||
firstMonitor(true)
|
||||
{
|
||||
@@ -165,17 +164,18 @@ MonitorLocal::MonitorLocal(
|
||||
|
||||
MonitorLocal::~MonitorLocal()
|
||||
{
|
||||
destroy();
|
||||
std::cout << "MonitorLocal::~MonitorLocal()" << std::endl;
|
||||
}
|
||||
|
||||
void MonitorLocal::destroy()
|
||||
{
|
||||
//std::cout << "MonitorLocal::destroy " << isDestroyed << std::endl;
|
||||
std::cout << "MonitorLocal::destroy " << isDestroyed << std::endl;
|
||||
{
|
||||
Lock xx(mutex);
|
||||
if(isDestroyed) return;
|
||||
isDestroyed = true;
|
||||
}
|
||||
unlisten();
|
||||
stop();
|
||||
// monitorFieldList.clear();
|
||||
pvCopyMonitor.reset();
|
||||
@@ -194,7 +194,7 @@ Status MonitorLocal::start()
|
||||
|
||||
Status MonitorLocal::stop()
|
||||
{
|
||||
//std::cout << "MonitorLocal::stop" << std::endl;
|
||||
std::cout << "MonitorLocal::stop" << std::endl;
|
||||
pvCopyMonitor->stopMonitoring();
|
||||
queue->stop();
|
||||
return Status::Ok;
|
||||
@@ -222,7 +222,7 @@ void MonitorLocal::dataChanged()
|
||||
|
||||
void MonitorLocal::unlisten()
|
||||
{
|
||||
//std::cout << "MonitorLocal::unlisten" << std::endl;
|
||||
std::cout << "MonitorLocal::unlisten" << std::endl;
|
||||
monitorRequester->unlisten(getPtrSelf());
|
||||
}
|
||||
|
||||
@@ -309,7 +309,7 @@ MonitorFactory::~MonitorFactory()
|
||||
|
||||
void MonitorFactory::destroy()
|
||||
{
|
||||
//std::cout << "MonitorFactory::destroy " << isDestroyed << std::endl;
|
||||
std::cout << "MonitorFactory::destroy " << isDestroyed << std::endl;
|
||||
Lock lock(mutex);
|
||||
if(isDestroyed) return;
|
||||
isDestroyed = true;
|
||||
@@ -327,7 +327,8 @@ void MonitorFactory::destroy()
|
||||
MonitorPtr MonitorFactory::createMonitor(
|
||||
PVRecordPtr const & pvRecord,
|
||||
MonitorRequester::shared_pointer const & monitorRequester,
|
||||
PVStructurePtr const & pvRequest)
|
||||
PVStructurePtr const & pvRequest,
|
||||
ChannelLocalDebugPtr const &channelLocalDebug)
|
||||
{
|
||||
Lock xx(mutex);
|
||||
if(isDestroyed) {
|
||||
@@ -335,27 +336,18 @@ MonitorPtr MonitorFactory::createMonitor(
|
||||
return nullMonitor;
|
||||
}
|
||||
MonitorLocalPtr monitor(new MonitorLocal(
|
||||
getChannelProviderLocal(),monitorRequester,pvRecord));
|
||||
monitorRequester,pvRecord,channelLocalDebug));
|
||||
bool result = monitor->init(pvRequest);
|
||||
if(!result) return nullMonitor;
|
||||
if(channelLocalDebug->getLevel()>0)
|
||||
{
|
||||
std::cout << "MonitorFactory::createMonitor";
|
||||
std::cout << " recordName " << pvRecord->getRecordName() << std::endl;
|
||||
}
|
||||
monitorLocalList.insert(monitor);
|
||||
return monitor;
|
||||
}
|
||||
|
||||
void MonitorFactory::removeMonitor(MonitorLocal * monitor)
|
||||
{
|
||||
//std::cout << "MonitorFactory::removeMonitor" << std::endl;
|
||||
Lock xx(mutex);
|
||||
if(isDestroyed) return;
|
||||
std::set<MonitorLocalPtr>::iterator iter;
|
||||
for (iter = monitorLocalList.begin(); iter!= monitorLocalList.end(); ++iter) {
|
||||
if(iter->get()==monitor) {
|
||||
monitorLocalList.erase(iter);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MonitorFactory::registerMonitorAlgorithmCreate(
|
||||
MonitorAlgorithmCreatePtr const &monitorAlgorithmCreate)
|
||||
{
|
||||
|
||||
@@ -1027,6 +1027,7 @@ void PVCopyMonitor::startMonitoring(
|
||||
|
||||
void PVCopyMonitor::stopMonitoring()
|
||||
{
|
||||
std::cout << "PVCopyMonitor::stopMonitoring()" << std::endl;
|
||||
pvRecord->removeListener(getPtrSelf());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user