fixups
This commit is contained in:
@ -137,6 +137,8 @@ MonitorCacheEntry::monitorEvent(pvd::MonitorPtr const & monitor)
|
||||
|
||||
{
|
||||
Guard G(usr->mutex());
|
||||
if(usr->initial)
|
||||
continue; // no start() yet
|
||||
if(!usr->running || usr->empty.empty()) {
|
||||
usr->inoverflow = true;
|
||||
|
||||
@ -157,7 +159,7 @@ MonitorCacheEntry::monitorEvent(pvd::MonitorPtr const & monitor)
|
||||
|
||||
AUTO_VAL(elem, usr->empty.front());
|
||||
|
||||
elem->overrunBitSet->clear();
|
||||
*elem->overrunBitSet = *update->overrunBitSet;
|
||||
assign(elem, update); // TODO: nice to avoid copy
|
||||
|
||||
usr->filled.push_back(elem);
|
||||
@ -272,7 +274,7 @@ MonitorUser::start()
|
||||
Guard G(mutex());
|
||||
|
||||
if(initial) {
|
||||
initial = true;
|
||||
initial = false;
|
||||
|
||||
empty.resize(entry->bufferSize);
|
||||
pvd::PVDataCreatePtr fact(pvd::getPVDataCreate());
|
||||
@ -284,17 +286,19 @@ MonitorUser::start()
|
||||
overflowElement.reset(new pvd::MonitorElement(fact->createPVStructure(typedesc)));
|
||||
}
|
||||
|
||||
doEvt = filled.empty();
|
||||
|
||||
if(lval && !empty.empty()) {
|
||||
//already running, notify of initial element
|
||||
|
||||
pvd::MonitorElementPtr elem(empty.front());
|
||||
elem->pvStructurePtr = lval;
|
||||
elem->changedBitSet->set(0); // indicate all changed?
|
||||
elem->changedBitSet->set(0); // indicate all changed
|
||||
filled.push_back(elem);
|
||||
empty.pop_front();
|
||||
|
||||
doEvt = true;
|
||||
}
|
||||
|
||||
doEvt &= !filled.empty();
|
||||
running = true;
|
||||
}
|
||||
if(doEvt)
|
||||
@ -341,6 +345,7 @@ MonitorUser::release(pvd::MonitorElementPtr const & monitorElement)
|
||||
filled.push_back(overflowElement);
|
||||
overflowElement = monitorElement;
|
||||
overflowElement->changedBitSet->clear();
|
||||
overflowElement->overrunBitSet->clear();
|
||||
|
||||
inoverflow = false;
|
||||
} else {
|
||||
|
@ -162,6 +162,90 @@ struct TestMonitor {
|
||||
mon->destroy();
|
||||
mon2->destroy();
|
||||
}
|
||||
|
||||
void test_ds_no_start()
|
||||
{
|
||||
testDiag("Test downstream monitor never start()s");
|
||||
|
||||
TestChannelMonitorRequester::shared_pointer mreq(new TestChannelMonitorRequester);
|
||||
pvd::Monitor::shared_pointer mon(client->createMonitor(mreq, makeRequest(2)));
|
||||
if(!mon) testAbort("Failed to create monitor");
|
||||
|
||||
upstream->dispatch(); // trigger monitorEvent() from upstream to gateway
|
||||
|
||||
testOk1(mreq->eventCnt==0);
|
||||
testOk1(!mon->poll());
|
||||
|
||||
pvd::BitSet changed;
|
||||
changed.set(1);
|
||||
test1_x=50;
|
||||
test1->post(changed, false);
|
||||
test1_x=51;
|
||||
test1->post(changed, false);
|
||||
test1_x=52;
|
||||
test1->post(changed, false);
|
||||
test1_x=53;
|
||||
test1->post(changed);
|
||||
|
||||
testOk1(!mon->poll());
|
||||
|
||||
mon->destroy();
|
||||
}
|
||||
|
||||
void test_overflow_upstream()
|
||||
{
|
||||
testDiag("Check behavour when upstream monitor overflows (mostly transparent)");
|
||||
|
||||
TestChannelMonitorRequester::shared_pointer mreq(new TestChannelMonitorRequester);
|
||||
pvd::Monitor::shared_pointer mon(client->createMonitor(mreq, makeRequest(2)));
|
||||
if(!mon) testAbort("Failed to create monitor");
|
||||
|
||||
testOk1(mreq->eventCnt==0);
|
||||
testOk1(mon->start().isSuccess());
|
||||
upstream->dispatch(); // trigger monitorEvent() from upstream to gateway
|
||||
testOk1(mreq->eventCnt==1);
|
||||
|
||||
testDiag("poll initial update");
|
||||
pvd::MonitorElementPtr elem(mon->poll());
|
||||
testOk1(!!elem.get());
|
||||
if(elem) mon->release(elem);
|
||||
|
||||
pvd::BitSet changed;
|
||||
changed.set(1);
|
||||
test1_x=50;
|
||||
test1->post(changed, false);
|
||||
test1_x=51;
|
||||
test1->post(changed, false);
|
||||
test1_x=52;
|
||||
test1->post(changed, false);
|
||||
test1_x=53;
|
||||
test1->post(changed);
|
||||
|
||||
elem = mon->poll();
|
||||
testOk1(!!elem.get());
|
||||
|
||||
testOk1(elem && elem->pvStructurePtr->getSubFieldT<pvd::PVInt>("x")->get()==50);
|
||||
testOk1(elem && elem->changedBitSet->nextSetBit(0)==1);
|
||||
testOk1(elem && elem->changedBitSet->nextSetBit(2)==-1);
|
||||
testOk1(elem && elem->overrunBitSet->nextSetBit(0)==-1);
|
||||
|
||||
if(elem) mon->release(elem);
|
||||
|
||||
elem = mon->poll();
|
||||
testOk1(!!elem.get());
|
||||
|
||||
testOk1(elem && elem->pvStructurePtr->getSubFieldT<pvd::PVInt>("x")->get()==53);
|
||||
testOk1(elem && elem->changedBitSet->nextSetBit(0)==1);
|
||||
testOk1(elem && elem->changedBitSet->nextSetBit(2)==-1);
|
||||
testOk1(elem && elem->overrunBitSet->nextSetBit(0)==1);
|
||||
testOk1(elem && elem->overrunBitSet->nextSetBit(2)==-1);
|
||||
|
||||
if(elem) mon->release(elem);
|
||||
|
||||
testOk1(!mon->poll());
|
||||
|
||||
mon->destroy();
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace
|
||||
@ -171,6 +255,8 @@ MAIN(testmon)
|
||||
testPlan(0);
|
||||
TEST_METHOD(TestMonitor, test_event);
|
||||
TEST_METHOD(TestMonitor, test_share);
|
||||
TEST_METHOD(TestMonitor, test_ds_no_start);
|
||||
TEST_METHOD(TestMonitor, test_overflow_upstream);
|
||||
TestProvider::testCounts();
|
||||
int ok = 1;
|
||||
size_t temp;
|
||||
|
@ -386,7 +386,7 @@ void TestPVMonitor::release(pvd::MonitorElementPtr const & monitorElement)
|
||||
testDiag("TestPVMonitor::release %p %p", this, monitorElement.get());
|
||||
|
||||
if(inoverflow) {
|
||||
assert(!buffer.empty());
|
||||
// buffer.empty() may be true if all elements poll()d by user
|
||||
assert(this->free.empty());
|
||||
|
||||
monitorElement->pvStructurePtr->copyUnchecked(*overflow->pvStructurePtr);
|
||||
@ -447,6 +447,9 @@ void TestPV::post(const pvd::BitSet& changed, bool notify)
|
||||
{
|
||||
TestPVMonitor *mon = it2->get();
|
||||
|
||||
if(!mon->running)
|
||||
continue;
|
||||
|
||||
mon->overflow->pvStructurePtr->copyUnchecked(*value, changed);
|
||||
|
||||
if(mon->free.empty()) {
|
||||
|
Reference in New Issue
Block a user