fixed connection problems
This commit is contained in:
@ -75,10 +75,8 @@ private:
|
||||
bool isDestroyed;
|
||||
bool firstMonitor;
|
||||
PVCopyPtr pvCopy;
|
||||
// MultipleElementQueuePtr queue;
|
||||
MonitorElementQueuePtr queue;
|
||||
MonitorElementPtr activeElement;
|
||||
bool queueIsFull;
|
||||
PVCopyMonitorPtr pvCopyMonitor;
|
||||
Mutex mutex;
|
||||
};
|
||||
@ -112,8 +110,6 @@ void MonitorLocal::destroy()
|
||||
if(isDestroyed) return;
|
||||
isDestroyed = true;
|
||||
}
|
||||
unlisten();
|
||||
stop();
|
||||
pvCopyMonitor->destroy();
|
||||
pvCopy->destroy();
|
||||
pvCopyMonitor.reset();
|
||||
@ -127,15 +123,16 @@ Status MonitorLocal::start()
|
||||
{
|
||||
cout << "MonitorLocal::start() " << endl;
|
||||
}
|
||||
Lock xx(mutex);
|
||||
if(isDestroyed) return wasDestroyedStatus;
|
||||
firstMonitor = true;
|
||||
queue->clear();
|
||||
queueIsFull = false;
|
||||
activeElement = queue->getFree();
|
||||
activeElement->changedBitSet->clear();
|
||||
activeElement->overrunBitSet->clear();
|
||||
pvCopyMonitor->startMonitoring();
|
||||
{
|
||||
Lock xx(mutex);
|
||||
firstMonitor = true;
|
||||
queue->clear();
|
||||
activeElement = queue->getFree();
|
||||
activeElement->changedBitSet->clear();
|
||||
activeElement->overrunBitSet->clear();
|
||||
}
|
||||
pvCopyMonitor->startMonitoring(activeElement);
|
||||
return Status::Ok;
|
||||
}
|
||||
|
||||
@ -144,7 +141,7 @@ Status MonitorLocal::stop()
|
||||
if(pvRecord->getTraceLevel()>0){
|
||||
cout << "MonitorLocal::stop() " << endl;
|
||||
}
|
||||
Lock xx(mutex);
|
||||
if(isDestroyed) return Status::Ok;
|
||||
pvCopyMonitor->stopMonitoring();
|
||||
return Status::Ok;
|
||||
}
|
||||
@ -155,10 +152,8 @@ MonitorElementPtr MonitorLocal::poll()
|
||||
{
|
||||
cout << "MonitorLocal::poll() " << endl;
|
||||
}
|
||||
if(isDestroyed) return NULLMonitorElement;
|
||||
Lock xx(mutex);
|
||||
if(isDestroyed) {
|
||||
return NULLMonitorElement;
|
||||
}
|
||||
return queue->getUsed();
|
||||
}
|
||||
|
||||
@ -168,43 +163,39 @@ void MonitorLocal::release(MonitorElementPtr const & monitorElement)
|
||||
{
|
||||
cout << "MonitorLocal::release() " << endl;
|
||||
}
|
||||
if(isDestroyed) return;
|
||||
Lock xx(mutex);
|
||||
if(isDestroyed) {
|
||||
return;
|
||||
}
|
||||
queue->releaseUsed(monitorElement);
|
||||
queueIsFull = false;
|
||||
}
|
||||
|
||||
|
||||
MonitorElementPtr MonitorLocal::getActiveElement()
|
||||
{
|
||||
if(pvRecord->getTraceLevel()>0)
|
||||
if(pvRecord->getTraceLevel()>1)
|
||||
{
|
||||
cout << "MonitorLocal::getActiveElement() " << endl;
|
||||
}
|
||||
if(isDestroyed) return activeElement;
|
||||
Lock xx(mutex);
|
||||
return activeElement;
|
||||
}
|
||||
|
||||
MonitorElementPtr MonitorLocal::releaseActiveElement()
|
||||
{
|
||||
if(pvRecord->getTraceLevel()>0)
|
||||
if(pvRecord->getTraceLevel()>1)
|
||||
{
|
||||
cout << "MonitorLocal::releaseActiveElement() " << endl;
|
||||
}
|
||||
if(isDestroyed) return activeElement;
|
||||
{
|
||||
Lock xx(mutex);
|
||||
if(queueIsFull) return activeElement;
|
||||
MonitorElementPtr newActive = queue->getFree();
|
||||
if(newActive==NULL) return activeElement;
|
||||
pvCopy->updateCopyFromBitSet(activeElement->pvStructurePtr,activeElement->changedBitSet);
|
||||
BitSetUtil::compress(activeElement->changedBitSet,activeElement->pvStructurePtr);
|
||||
BitSetUtil::compress(activeElement->overrunBitSet,activeElement->pvStructurePtr);
|
||||
queue->setUsed(activeElement);
|
||||
activeElement = queue->getFree();
|
||||
if(activeElement==NULL) {
|
||||
throw std::logic_error("MultipleLocal::releaseActiveElement logic error");
|
||||
}
|
||||
if(queue->getNumberFree()==0) queueIsFull = true;
|
||||
activeElement = newActive;
|
||||
activeElement->changedBitSet->clear();
|
||||
activeElement->overrunBitSet->clear();
|
||||
}
|
||||
|
@ -58,7 +58,8 @@ PVCopyMonitor::PVCopyMonitor(
|
||||
pvCopyMonitorRequester(pvCopyMonitorRequester),
|
||||
isGroupPut(false),
|
||||
dataChanged(false),
|
||||
isMonitoring(false)
|
||||
isMonitoring(false),
|
||||
isDestroyed(false)
|
||||
{
|
||||
}
|
||||
|
||||
@ -117,17 +118,22 @@ void PVCopyMonitor::destroy()
|
||||
{
|
||||
cout << "PVCopyMonitor::destroy()" << endl;
|
||||
}
|
||||
if(isDestroyed) return;
|
||||
Lock xx(mutex);
|
||||
isDestroyed = true;
|
||||
stopMonitoring();
|
||||
pvCopyMonitorRequester.reset();
|
||||
pvCopy.reset();
|
||||
}
|
||||
|
||||
void PVCopyMonitor::startMonitoring()
|
||||
void PVCopyMonitor::startMonitoring(MonitorElementPtr const & startElement)
|
||||
{
|
||||
if(pvRecord->getTraceLevel()>0)
|
||||
{
|
||||
cout << "PVCopyMonitor::startMonitoring()" << endl;
|
||||
}
|
||||
if(isDestroyed) return;
|
||||
monitorElement = startElement;
|
||||
Lock xx(mutex);
|
||||
if(isMonitoring) return;
|
||||
isMonitoring = true;
|
||||
@ -137,13 +143,9 @@ void PVCopyMonitor::startMonitoring()
|
||||
{
|
||||
(*iter)->monitorPlugin->startMonitoring();
|
||||
}
|
||||
monitorElement = pvCopyMonitorRequester->getActiveElement();
|
||||
if(monitorElement==NULL) {
|
||||
throw std::logic_error("getActiveElement should not return null");
|
||||
}
|
||||
pvRecord->addListener(getPtrSelf());
|
||||
pvRecord->lock();
|
||||
try {
|
||||
pvRecord->addListener(getPtrSelf());
|
||||
pvCopy->traverseMaster(getPtrSelf());
|
||||
monitorElement->changedBitSet->clear();
|
||||
monitorElement->overrunBitSet->clear();
|
||||
@ -166,15 +168,16 @@ void PVCopyMonitor::stopMonitoring()
|
||||
{
|
||||
cout << "PVCopyMonitor::stopMonitoring()" << endl;
|
||||
}
|
||||
Lock xx(mutex);
|
||||
if(isDestroyed) return;
|
||||
if(!isMonitoring) return;
|
||||
pvRecord->removeListener(getPtrSelf());
|
||||
Lock xx(mutex);
|
||||
std::list<PVCopyMonitorFieldNodePtr>::iterator iter;
|
||||
for (iter = monitorFieldNodeList.begin();iter!=monitorFieldNodeList.end();++iter)
|
||||
{
|
||||
(*iter)->monitorPlugin->stopMonitoring();
|
||||
}
|
||||
isMonitoring = false;
|
||||
pvRecord->removeListener(getPtrSelf());
|
||||
}
|
||||
|
||||
|
||||
@ -193,6 +196,7 @@ void PVCopyMonitor::dataPut(PVRecordFieldPtr const & pvRecordField)
|
||||
{
|
||||
cout << "PVCopyMonitor::dataPut(pvRecordField)" << endl;
|
||||
}
|
||||
if(isDestroyed) return;
|
||||
bool causeMonitor = true;
|
||||
{
|
||||
Lock xx(mutex);
|
||||
@ -227,6 +231,7 @@ void PVCopyMonitor::dataPut(
|
||||
{
|
||||
cout << "PVCopyMonitor::dataPut(requested,pvRecordField)" << endl;
|
||||
}
|
||||
if(isDestroyed) return;
|
||||
bool causeMonitor = true;
|
||||
{
|
||||
Lock xx(mutex);
|
||||
@ -259,10 +264,11 @@ void PVCopyMonitor::dataPut(
|
||||
|
||||
void PVCopyMonitor::beginGroupPut(PVRecordPtr const & pvRecord)
|
||||
{
|
||||
if(pvRecord->getTraceLevel()>0)
|
||||
if(pvRecord->getTraceLevel()>1)
|
||||
{
|
||||
cout << "PVCopyMonitor::beginGroupPut()" << endl;
|
||||
}
|
||||
if(isDestroyed) return;
|
||||
{
|
||||
Lock xx(mutex);
|
||||
isGroupPut = true;
|
||||
@ -279,10 +285,11 @@ void PVCopyMonitor::beginGroupPut(PVRecordPtr const & pvRecord)
|
||||
|
||||
void PVCopyMonitor::endGroupPut(PVRecordPtr const & pvRecord)
|
||||
{
|
||||
if(pvRecord->getTraceLevel()>0)
|
||||
if(pvRecord->getTraceLevel()>1)
|
||||
{
|
||||
cout << "PVCopyMonitor::endGroupPut() dataChanged " << dataChanged << endl;
|
||||
}
|
||||
if(isDestroyed) return;
|
||||
std::list<PVCopyMonitorFieldNodePtr>::iterator iter;
|
||||
for (iter = monitorFieldNodeList.begin();iter!=monitorFieldNodeList.end();++iter)
|
||||
{
|
||||
@ -300,6 +307,11 @@ void PVCopyMonitor::endGroupPut(PVRecordPtr const & pvRecord)
|
||||
|
||||
void PVCopyMonitor::unlisten(PVRecordPtr const & pvRecord)
|
||||
{
|
||||
if(pvRecord->getTraceLevel()>1)
|
||||
{
|
||||
cout << "PVCopyMonitor::unlisten\n";
|
||||
}
|
||||
if(isDestroyed) return;
|
||||
pvCopyMonitorRequester->unlisten();
|
||||
}
|
||||
|
||||
|
@ -58,7 +58,8 @@ public:
|
||||
epics::pvData::PVCopyPtr const & pvCopy);
|
||||
virtual ~PVCopyMonitor();
|
||||
virtual void destroy();
|
||||
void startMonitoring();
|
||||
void startMonitoring(
|
||||
epics::pvData::MonitorElementPtr const & monitorElement);
|
||||
void stopMonitoring();
|
||||
// following are PVListener methods
|
||||
virtual void detach(PVRecordPtr const & pvRecord);
|
||||
@ -89,6 +90,7 @@ private:
|
||||
bool isGroupPut;
|
||||
bool dataChanged;
|
||||
bool isMonitoring;
|
||||
bool isDestroyed;
|
||||
epics::pvData::Mutex mutex;
|
||||
std::list<PVCopyMonitorFieldNodePtr> monitorFieldNodeList;
|
||||
};
|
||||
|
Reference in New Issue
Block a user