From 9a77eb328ff7e8951d75f8230bd862a74b057c05 Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Mon, 10 Jul 2017 14:39:23 +0200 Subject: [PATCH] pvaTestClient: put bitset --- examples/putme.cpp | 22 ++++++++++++++++++---- src/testing/pv/pvaTestClient.h | 7 ++++++- src/testing/pvaTestClientGet.cpp | 13 ++++++++----- 3 files changed, 32 insertions(+), 10 deletions(-) diff --git a/examples/putme.cpp b/examples/putme.cpp index 5ec23ee..c691521 100644 --- a/examples/putme.cpp +++ b/examples/putme.cpp @@ -66,19 +66,33 @@ struct PutTracker : public TestClientChannel::PutCallback op.cancel(); } - virtual pvd::PVStructure::const_shared_pointer putBuild(const epics::pvData::StructureConstPtr &build) + virtual void putBuild(const epics::pvData::StructureConstPtr &build, TestClientChannel::PutCallback::Args& args) OVERRIDE FINAL { + // At this point we have the user provided value string 'value' + // and the server provided structure (with types). + + // note: an exception thrown here will result in putDone() w/ Fail + + // allocate a new structure instance. + // we are one-shot so don't bother to re-use pvd::PVStructurePtr root(pvd::getPVDataCreate()->createPVStructure(build)); + // we only know about writes to scalar 'value' field pvd::PVScalarPtr valfld(root->getSubFieldT("value")); + // attempt convert string to actual field type valfld->putFrom(value); - std::cout<<"Put value "< const + + // mark only 'value' field to be sent. + // other fields w/ default values won't be sent. + args.tosend.set(valfld->getFieldOffset()); + + std::cout<<"Put value "<putBuild(structure); + cb->putBuild(structure, args); + if(!args.root) + throw std::logic_error("No put value provided"); + else if(args.root->getStructure().get()!=structure.get()) + throw std::logic_error("Provided put value with wrong type"); }catch(std::exception& e){ if(putcb) { event.message = e.what(); @@ -111,10 +116,8 @@ struct GetPutter : public pva::ChannelPutRequester, } // check putcb again after UnGuard if(putcb) { - pvd::BitSet::shared_pointer all(new pvd::BitSet); - all->set(0); channelPut->lastRequest(); - channelPut->put(std::tr1::const_pointer_cast(val), all); + channelPut->put(std::tr1::const_pointer_cast(args.root), tosend); started = true; } }