From cdc03d8e9732d40f000907772ce438ef1b8b7092 Mon Sep 17 00:00:00 2001 From: Matej Sekoranja Date: Thu, 22 May 2014 22:31:20 +0200 Subject: [PATCH] porting tests and utils --- pvAccessApp/ca/caChannel.cpp | 10 + pvAccessApp/ca/caChannel.h | 2 + pvAccessApp/client/pvAccess.h | 8 +- .../remoteClient/clientContextImpl.cpp | 44 +++- pvAccessApp/rpcService/rpcServer.cpp | 17 +- pvAccessApp/v3ioc/syncChannelFind.h | 2 +- testApp/client/MockClientImpl.cpp | 2 +- testApp/client/testChannelAccessFactory.cpp | 2 +- testApp/remote/eget.cpp | 6 +- testApp/remote/pvget.cpp | 4 +- testApp/remote/pvinfo.cpp | 2 +- testApp/remote/pvput.cpp | 4 +- testApp/remote/testChannelAccess.cpp | 2 +- testApp/remote/testChannelConnect.cpp | 2 +- testApp/remote/testGetPerformance.cpp | 2 +- testApp/remote/testRemoteClientImpl.cpp | 199 ++++++++---------- testApp/remote/testServer.cpp | 4 +- testApp/remote/testServerContext.cpp | 6 +- 18 files changed, 181 insertions(+), 137 deletions(-) diff --git a/pvAccessApp/ca/caChannel.cpp b/pvAccessApp/ca/caChannel.cpp index d7c6220..07ab5ec 100644 --- a/pvAccessApp/ca/caChannel.cpp +++ b/pvAccessApp/ca/caChannel.cpp @@ -883,6 +883,11 @@ void CAChannelGet::get() /* --------------- epics::pvData::ChannelRequest --------------- */ +Channel::shared_pointer CAChannelGet::getChannel() +{ + return channel; +} + void CAChannelGet::cancel() { // noop @@ -1200,6 +1205,11 @@ void CAChannelPut::get() /* --------------- epics::pvData::ChannelRequest --------------- */ +Channel::shared_pointer CAChannelPut::getChannel() +{ + return channel; +} + void CAChannelPut::cancel() { // noop diff --git a/pvAccessApp/ca/caChannel.h b/pvAccessApp/ca/caChannel.h index 511da8f..e0db30a 100644 --- a/pvAccessApp/ca/caChannel.h +++ b/pvAccessApp/ca/caChannel.h @@ -146,6 +146,7 @@ public: /* --------------- epics::pvData::ChannelRequest --------------- */ + virtual Channel::shared_pointer getChannel(); virtual void cancel(); virtual void lastRequest(); @@ -205,6 +206,7 @@ public: /* --------------- epics::pvData::ChannelRequest --------------- */ + virtual Channel::shared_pointer getChannel(); virtual void cancel(); virtual void lastRequest(); diff --git a/pvAccessApp/client/pvAccess.h b/pvAccessApp/client/pvAccess.h index 178f08f..bb4295b 100644 --- a/pvAccessApp/client/pvAccess.h +++ b/pvAccessApp/client/pvAccess.h @@ -115,6 +115,12 @@ namespace pvAccess { public: POINTER_DEFINITIONS(ChannelRequest); + /** + * Get a channel instance this request belongs to. + * @return the channel instance. + */ + virtual std::tr1::shared_ptr getChannel() = 0; + /** * Cancel any pending request. * Completion will be reported via request's response callback: @@ -241,7 +247,7 @@ namespace pvAccess { POINTER_DEFINITIONS(ChannelFind); virtual std::tr1::shared_ptr getChannelProvider() = 0; - virtual void cancelChannelFind() = 0; + virtual void cancel() = 0; }; /** diff --git a/pvAccessApp/remoteClient/clientContextImpl.cpp b/pvAccessApp/remoteClient/clientContextImpl.cpp index f9f6f11..cbc26da 100644 --- a/pvAccessApp/remoteClient/clientContextImpl.cpp +++ b/pvAccessApp/remoteClient/clientContextImpl.cpp @@ -112,7 +112,7 @@ namespace epics { static Status pvRequestNull; static PVStructure::shared_pointer nullPVStructure; - static Structure::shared_pointer nullStructure; + static Structure::const_shared_pointer nullStructure; static BitSet::shared_pointer nullBitSet; static BitSet::shared_pointer createBitSetFor( @@ -291,6 +291,10 @@ namespace epics { } } + + virtual Channel::shared_pointer getChannel() { + return m_channel; + } virtual void destroy() { destroy(false); @@ -396,6 +400,7 @@ namespace epics { Status BaseRequestImpl::pvRequestNull = Status(Status::STATUSTYPE_ERROR, "pvRequest == 0"); PVStructure::shared_pointer BaseRequestImpl::nullPVStructure; + Structure::const_shared_pointer BaseRequestImpl::nullStructure; BitSet::shared_pointer BaseRequestImpl::nullBitSet; PVACCESS_REFCOUNT_MONITOR_DEFINE(channelProcess); @@ -510,6 +515,11 @@ namespace epics { } } + virtual Channel::shared_pointer getChannel() + { + return BaseRequestImpl::getChannel(); + } + virtual void cancel() { BaseRequestImpl::cancel(); @@ -717,6 +727,11 @@ namespace epics { } } + virtual Channel::shared_pointer getChannel() + { + return BaseRequestImpl::getChannel(); + } + virtual void cancel() { BaseRequestImpl::cancel(); @@ -976,6 +991,11 @@ namespace epics { } } + virtual Channel::shared_pointer getChannel() + { + return BaseRequestImpl::getChannel(); + } + virtual void cancel() { BaseRequestImpl::cancel(); @@ -1299,6 +1319,11 @@ namespace epics { } } + virtual Channel::shared_pointer getChannel() + { + return BaseRequestImpl::getChannel(); + } + virtual void cancel() { BaseRequestImpl::cancel(); @@ -1488,6 +1513,11 @@ namespace epics { } } + virtual Channel::shared_pointer getChannel() + { + return BaseRequestImpl::getChannel(); + } + virtual void cancel() { BaseRequestImpl::cancel(); @@ -1847,6 +1877,11 @@ namespace epics { } } + virtual Channel::shared_pointer getChannel() + { + return BaseRequestImpl::getChannel(); + } + virtual void cancel() { BaseRequestImpl::cancel(); @@ -1964,6 +1999,11 @@ namespace epics { } + virtual Channel::shared_pointer getChannel() + { + return m_channel; + } + virtual void cancel() { // TODO // noop @@ -2885,7 +2925,7 @@ namespace epics { return m_provider; }; - virtual void cancelChannelFind() + virtual void cancel() { throw std::runtime_error("not supported"); } diff --git a/pvAccessApp/rpcService/rpcServer.cpp b/pvAccessApp/rpcService/rpcServer.cpp index 2a38379..ebc5487 100644 --- a/pvAccessApp/rpcService/rpcServer.cpp +++ b/pvAccessApp/rpcService/rpcServer.cpp @@ -19,14 +19,17 @@ class ChannelRPCServiceImpl : public std::tr1::enable_shared_from_this { private: + Channel::shared_pointer m_channel; ChannelRPCRequester::shared_pointer m_channelRPCRequester; RPCService::shared_pointer m_rpcService; AtomicBoolean m_lastRequest; public: ChannelRPCServiceImpl( + Channel::shared_pointer const & channel, ChannelRPCRequester::shared_pointer const & channelRPCRequester, RPCService::shared_pointer const & rpcService) : + m_channel(channel), m_channelRPCRequester(channelRPCRequester), m_rpcService(rpcService), m_lastRequest() @@ -87,6 +90,11 @@ class ChannelRPCServiceImpl : m_lastRequest.set(); } + virtual Channel::shared_pointer getChannel() + { + return m_channel; + } + virtual void cancel() { // noop @@ -112,7 +120,8 @@ class ChannelRPCServiceImpl : class RPCChannel : - public virtual Channel + public virtual Channel, + public std::tr1::enable_shared_from_this { private: @@ -247,7 +256,9 @@ public: return nullPtr; } - ChannelRPC::shared_pointer channelRPCImpl(new ChannelRPCServiceImpl(channelRPCRequester, m_rpcService)); + ChannelRPC::shared_pointer channelRPCImpl( + new ChannelRPCServiceImpl(shared_from_this(), channelRPCRequester, m_rpcService) + ); channelRPCRequester->channelRPCConnect(Status::Ok, channelRPCImpl); return channelRPCImpl; } @@ -333,7 +344,7 @@ public: return shared_from_this(); } - virtual void cancelChannelFind() {} + virtual void cancel() {} virtual void destroy() {} diff --git a/pvAccessApp/v3ioc/syncChannelFind.h b/pvAccessApp/v3ioc/syncChannelFind.h index 9477c54..18227b6 100644 --- a/pvAccessApp/v3ioc/syncChannelFind.h +++ b/pvAccessApp/v3ioc/syncChannelFind.h @@ -54,7 +54,7 @@ public: return m_provider.lock(); }; - virtual void cancelChannelFind() {} + virtual void cancel() {} private: ChannelProvider::weak_pointer m_provider; diff --git a/testApp/client/MockClientImpl.cpp b/testApp/client/MockClientImpl.cpp index 9914bff..bf62862 100644 --- a/testApp/client/MockClientImpl.cpp +++ b/testApp/client/MockClientImpl.cpp @@ -556,7 +556,7 @@ class MockChannelFind : public ChannelFind return m_provider; }; - virtual void cancelChannelFind() + virtual void cancel() { throw std::runtime_error("not supported"); } diff --git a/testApp/client/testChannelAccessFactory.cpp b/testApp/client/testChannelAccessFactory.cpp index 17a04b4..c24b196 100644 --- a/testApp/client/testChannelAccessFactory.cpp +++ b/testApp/client/testChannelAccessFactory.cpp @@ -37,7 +37,7 @@ public: void testChannelAccessFactory() { printf("testChannelAccessFactory... "); - ChannelAccess* ca = getChannelAccess(); + ChannelAccess* ca = getChannelProviderRegistry(); assert(ca); // empty diff --git a/testApp/remote/eget.cpp b/testApp/remote/eget.cpp index 6d546cb..5f7fa0b 100644 --- a/testApp/remote/eget.cpp +++ b/testApp/remote/eget.cpp @@ -1729,7 +1729,7 @@ int main (int argc, char *argv[]) { shared_ptr channelRequesterImpl(new ChannelRequesterImpl(quiet)); // TODO no provider check - channels[n] = getChannelAccess()->getProvider(providerNames[n])->createChannel(pvs[n], channelRequesterImpl); + channels[n] = getChannelProviderRegistry()->getProvider(providerNames[n])->createChannel(pvs[n], channelRequesterImpl); } // TODO maybe unify for nPvs == 1?! @@ -1803,7 +1803,7 @@ int main (int argc, char *argv[]) shared_ptr channelRequesterImpl(new ChannelRequesterImpl(quiet)); // TODO no provider check - channel = getChannelAccess()->getProvider(cp)->createChannel(cn, channelRequesterImpl); + channel = getChannelProviderRegistry()->getProvider(cp)->createChannel(cn, channelRequesterImpl); } if (monitor) @@ -2035,7 +2035,7 @@ int main (int argc, char *argv[]) ClientFactory::start(); - ChannelProvider::shared_pointer provider = getChannelAccess()->getProvider("pva"); + ChannelProvider::shared_pointer provider = getChannelProviderRegistry()->getProvider("pva"); shared_ptr channelRequesterImpl(new ChannelRequesterImpl(quiet)); Channel::shared_pointer channel = diff --git a/testApp/remote/pvget.cpp b/testApp/remote/pvget.cpp index 3eb8719..fdaf450 100644 --- a/testApp/remote/pvget.cpp +++ b/testApp/remote/pvget.cpp @@ -484,10 +484,10 @@ int main (int argc, char *argv[]) } ClientFactory::start(); - ChannelProvider::shared_pointer provider = getChannelAccess()->getProvider("pva"); + ChannelProvider::shared_pointer provider = getChannelProviderRegistry()->getProvider("pva"); //epics::pvAccess::ca::CAClientFactory::start(); - //ChannelProvider::shared_pointer provider = getChannelAccess()->getProvider("ca"); + //ChannelProvider::shared_pointer provider = getChannelProviderRegistry()->getProvider("ca"); // first connect to all, this allows resource (e.g. TCP connection) sharing vector channels(nPvs); diff --git a/testApp/remote/pvinfo.cpp b/testApp/remote/pvinfo.cpp index b450a54..cf9be31 100644 --- a/testApp/remote/pvinfo.cpp +++ b/testApp/remote/pvinfo.cpp @@ -122,7 +122,7 @@ int main (int argc, char *argv[]) Requester::shared_pointer requester(new RequesterImpl("pvinfo")); ClientFactory::start(); - ChannelProvider::shared_pointer provider = getChannelAccess()->getProvider("pva"); + ChannelProvider::shared_pointer provider = getChannelProviderRegistry()->getProvider("pva"); // first connect to all, this allows resource (e.g. TCP connection) sharing vector channels(nPvs); diff --git a/testApp/remote/pvput.cpp b/testApp/remote/pvput.cpp index ff95139..ebb0e2e 100644 --- a/testApp/remote/pvput.cpp +++ b/testApp/remote/pvput.cpp @@ -551,10 +551,10 @@ int main (int argc, char *argv[]) terseSeparator(fieldSeparator); ClientFactory::start(); - ChannelProvider::shared_pointer provider = getChannelAccess()->getProvider("pva"); + ChannelProvider::shared_pointer provider = getChannelProviderRegistry()->getProvider("pva"); //epics::pvAccess::ca::CAClientFactory::start(); - //ChannelProvider::shared_pointer provider = getChannelAccess()->getProvider("ca"); + //ChannelProvider::shared_pointer provider = getChannelProviderRegistry()->getProvider("ca"); bool allOK = true; diff --git a/testApp/remote/testChannelAccess.cpp b/testApp/remote/testChannelAccess.cpp index 0f1021d..ce83c4c 100755 --- a/testApp/remote/testChannelAccess.cpp +++ b/testApp/remote/testChannelAccess.cpp @@ -61,7 +61,7 @@ class ChannelAccessIFRemoteTest: public ChannelAccessIFTest { virtual ChannelProvider::shared_pointer getChannelProvider() { - return getChannelAccess()->getProvider( + return getChannelProviderRegistry()->getProvider( "pva"); } diff --git a/testApp/remote/testChannelConnect.cpp b/testApp/remote/testChannelConnect.cpp index ed5c369..cbb10de 100644 --- a/testApp/remote/testChannelConnect.cpp +++ b/testApp/remote/testChannelConnect.cpp @@ -72,7 +72,7 @@ int main() Event g_event; ClientFactory::start(); - ChannelProvider::shared_pointer provider = getChannelAccess()->getProvider("pva"); + ChannelProvider::shared_pointer provider = getChannelProviderRegistry()->getProvider("pva"); ChannelRequester::shared_pointer channelRequester(new ChannelRequesterImpl(g_event)); Channel::shared_pointer channels[N_CHANNELS]; diff --git a/testApp/remote/testGetPerformance.cpp b/testApp/remote/testGetPerformance.cpp index b1d6ca7..81b8f44 100644 --- a/testApp/remote/testGetPerformance.cpp +++ b/testApp/remote/testGetPerformance.cpp @@ -477,7 +477,7 @@ int main (int argc, char *argv[]) } ClientFactory::start(); - provider = getChannelAccess()->getProvider("pva"); + provider = getChannelProviderRegistry()->getProvider("pva"); if (!testFile.empty()) { diff --git a/testApp/remote/testRemoteClientImpl.cpp b/testApp/remote/testRemoteClientImpl.cpp index 0d0c8ab..0fbf295 100644 --- a/testApp/remote/testRemoteClientImpl.cpp +++ b/testApp/remote/testRemoteClientImpl.cpp @@ -12,6 +12,7 @@ using namespace epics::pvData; using namespace epics::pvAccess; +#define SLEEP_TIME 1.0 class ChannelFindRequesterImpl : public ChannelFindRequester { @@ -60,7 +61,7 @@ class GetFieldRequesterImpl : public GetFieldRequester std::cout << "[" << getRequesterName() << "] message(" << message << ", " << getMessageTypeName(messageType) << ")" << std::endl; } - virtual void getDone(const epics::pvData::Status& status,epics::pvData::FieldConstPtr const & field) + virtual void getDone(const epics::pvData::Status& status, epics::pvData::FieldConstPtr const & field) { std::cout << "getDone(" << status.toString() << ", "; if (status.isSuccess() && field) @@ -77,12 +78,6 @@ class GetFieldRequesterImpl : public GetFieldRequester class ChannelGetRequesterImpl : public ChannelGetRequester { - private: - - //ChannelGet::shared_pointer m_channelGet; - epics::pvData::PVStructure::shared_pointer m_pvStructure; - epics::pvData::BitSet::shared_pointer m_bitSet; - public: virtual String getRequesterName() @@ -96,8 +91,7 @@ class ChannelGetRequesterImpl : public ChannelGetRequester } virtual void channelGetConnect(const epics::pvData::Status& status,ChannelGet::shared_pointer const & /*channelGet*/, - epics::pvData::PVStructure::shared_pointer const & pvStructure, - epics::pvData::BitSet::shared_pointer const & bitSet) + epics::pvData::Structure::const_shared_pointer const & pvStructure) { std::cout << "channelGetConnect(" << status.toString() << ")" << std::endl; if (status.isSuccess()) @@ -106,20 +100,17 @@ class ChannelGetRequesterImpl : public ChannelGetRequester pvStructure->toString(&st); std::cout << st << std::endl; } - - //m_channelGet = channelGet; - m_pvStructure = pvStructure; - m_bitSet = bitSet; } - virtual void getDone(const epics::pvData::Status& status) + virtual void getDone(const epics::pvData::Status& status, ChannelGet::shared_pointer const &, + PVStructure::shared_pointer const & getData, BitSet::shared_pointer const & /*bitSet*/) { std::cout << "getDone(" << status.toString() << ")" << std::endl; if (status.isSuccess()) { String str; - m_pvStructure->toString(&str); + getData->toString(&str); std::cout << str; std::cout << std::endl; } @@ -128,12 +119,6 @@ class ChannelGetRequesterImpl : public ChannelGetRequester class ChannelPutRequesterImpl : public ChannelPutRequester { - private: - - //ChannelPut::shared_pointer m_channelPut; - epics::pvData::PVStructure::shared_pointer m_pvStructure; - epics::pvData::BitSet::shared_pointer m_bitSet; - public: virtual String getRequesterName() @@ -147,50 +132,39 @@ class ChannelPutRequesterImpl : public ChannelPutRequester } virtual void channelPutConnect(const epics::pvData::Status& status,ChannelPut::shared_pointer const & /*channelPut*/, - epics::pvData::PVStructure::shared_pointer const & pvStructure, - epics::pvData::BitSet::shared_pointer const & bitSet) + epics::pvData::Structure::const_shared_pointer const & pvStructure) { std::cout << "channelPutConnect(" << status.toString() << ")" << std::endl; - - //m_channelPut = channelPut; - m_pvStructure = pvStructure; - m_bitSet = bitSet; + if (status.isSuccess()) + { + String st; + pvStructure->toString(&st); + std::cout << st << std::endl; + } } - virtual void getDone(const epics::pvData::Status& status) + virtual void getDone(const epics::pvData::Status& status, ChannelPut::shared_pointer const &, + PVStructure::shared_pointer const & getData, BitSet::shared_pointer const & /*bitSet*/) { std::cout << "getDone(" << status.toString() << ")" << std::endl; if (status.isSuccess()) { String str; - m_pvStructure->toString(&str); + getData->toString(&str); std::cout << str; std::cout << std::endl; } } - virtual void putDone(const epics::pvData::Status& status) + virtual void putDone(const epics::pvData::Status& status, ChannelPut::shared_pointer const &) { std::cout << "putDone(" << status.toString() << ")" << std::endl; - if (status.isSuccess()) - { - String str; - m_pvStructure->toString(&str); - std::cout << str; - std::cout << std::endl; - } } }; class ChannelPutGetRequesterImpl : public ChannelPutGetRequester { - private: - - //ChannelPutGet::shared_pointer m_channelPutGet; - epics::pvData::PVStructure::shared_pointer m_putData; - epics::pvData::PVStructure::shared_pointer m_getData; - public: virtual String getRequesterName() @@ -204,62 +178,61 @@ class ChannelPutGetRequesterImpl : public ChannelPutGetRequester } virtual void channelPutGetConnect(const epics::pvData::Status& status, ChannelPutGet::shared_pointer const & /*channelPutGet*/, - epics::pvData::PVStructure::shared_pointer const & putData, - epics::pvData::PVStructure::shared_pointer const & getData) + epics::pvData::Structure::const_shared_pointer const & putData, + epics::pvData::Structure::const_shared_pointer const & getData) { std::cout << "channelGetPutConnect(" << status.toString() << ")" << std::endl; - //m_channelPutGet = channelPutGet; - m_putData = putData; - m_getData = getData; - - if (m_putData) + if (putData) { String str; - m_putData->toString(&str); + putData->toString(&str); std::cout << str; std::cout << std::endl; } - if (m_getData) + if (getData) { String str; - m_getData->toString(&str); + getData->toString(&str); std::cout << str; std::cout << std::endl; } } - virtual void getGetDone(const epics::pvData::Status& status) + virtual void getGetDone(const epics::pvData::Status& status, ChannelPutGet::shared_pointer const &, + PVStructure::shared_pointer const & getData, BitSet::shared_pointer const & /*bitSet*/) { std::cout << "getGetDone(" << status.toString() << ")" << std::endl; if (status.isSuccess()) { String str; - m_getData->toString(&str); + getData->toString(&str); std::cout << str; std::cout << std::endl; } } - virtual void getPutDone(const epics::pvData::Status& status) + virtual void getPutDone(const epics::pvData::Status& status, ChannelPutGet::shared_pointer const &, + PVStructure::shared_pointer const & putData, BitSet::shared_pointer const & /*bitSet*/) { std::cout << "getPutDone(" << status.toString() << ")" << std::endl; if (status.isSuccess()) { String str; - m_putData->toString(&str); + putData->toString(&str); std::cout << str; std::cout << std::endl; } } - virtual void putGetDone(const epics::pvData::Status& status) + virtual void putGetDone(const epics::pvData::Status& status, ChannelPutGet::shared_pointer const &, + PVStructure::shared_pointer const & putData, BitSet::shared_pointer const & /*bitSet*/) { std::cout << "putGetDone(" << status.toString() << ")" << std::endl; if (status.isSuccess()) { String str; - m_putData->toString(&str); + putData->toString(&str); std::cout << str; std::cout << std::endl; } @@ -270,8 +243,6 @@ class ChannelPutGetRequesterImpl : public ChannelPutGetRequester class ChannelRPCRequesterImpl : public ChannelRPCRequester { - //ChannelRPC::shared_pointer m_channelRPC; - virtual String getRequesterName() { return "ChannelRPCRequesterImpl"; @@ -286,11 +257,10 @@ class ChannelRPCRequesterImpl : public ChannelRPCRequester ChannelRPC::shared_pointer const & /*channelRPC*/) { std::cout << "channelRPCConnect(" << status.toString() << ")" << std::endl; - - //m_channelRPC = channelRPC; } - virtual void requestDone(const epics::pvData::Status& status,epics::pvData::PVStructure::shared_pointer const & pvResponse) + virtual void requestDone(const epics::pvData::Status& status, ChannelRPC::shared_pointer const &, + epics::pvData::PVStructure::shared_pointer const & pvResponse) { std::cout << "requestDone(" << status.toString() << ")" << std::endl; if (status.isSuccess()) @@ -305,11 +275,6 @@ class ChannelRPCRequesterImpl : public ChannelRPCRequester class ChannelArrayRequesterImpl : public ChannelArrayRequester { - private: - - //ChannelArray::shared_pointer m_channelArray; - epics::pvData::PVArray::shared_pointer m_pvArray; - public: virtual String getRequesterName() @@ -323,41 +288,46 @@ class ChannelArrayRequesterImpl : public ChannelArrayRequester } virtual void channelArrayConnect(const epics::pvData::Status& status,ChannelArray::shared_pointer const & /*channelArray*/, - epics::pvData::PVArray::shared_pointer const & pvArray) + epics::pvData::Array::const_shared_pointer const & array) { std::cout << "channelArrayConnect(" << status.toString() << ")" << std::endl; if (status.isSuccess()) { String st; - pvArray->toString(&st); + array->toString(&st); std::cout << st << std::endl; } - //m_channelArray = channelArray; - m_pvArray = pvArray; } - virtual void getArrayDone(const epics::pvData::Status& status) + virtual void getArrayDone(const epics::pvData::Status& status, ChannelArray::shared_pointer const &, + PVArray::shared_pointer const & pvArray) { std::cout << "getArrayDone(" << status.toString() << ")" << std::endl; if (status.isSuccess()) { String str; - m_pvArray->toString(&str); + pvArray->toString(&str); std::cout << str; std::cout << std::endl; } } - virtual void putArrayDone(const epics::pvData::Status& status) + virtual void putArrayDone(const epics::pvData::Status& status, ChannelArray::shared_pointer const &) { std::cout << "putArrayDone(" << status.toString() << ")" << std::endl; } - virtual void setLengthDone(const epics::pvData::Status& status) + virtual void setLengthDone(const epics::pvData::Status& status, ChannelArray::shared_pointer const &) { std::cout << "setLengthDone(" << status.toString() << ")" << std::endl; } + + virtual void getLengthDone(const epics::pvData::Status& status, ChannelArray::shared_pointer const &, + size_t length, size_t capacity) + { + std::cout << "getLengthDone(" << status.toString() << "," << length << "," << capacity << ")" << std::endl; + } }; class MonitorRequesterImpl : public MonitorRequester @@ -430,7 +400,7 @@ class ChannelProcessRequesterImpl : public ChannelProcessRequester //m_channelProcess = channelProcess; } - virtual void processDone(const epics::pvData::Status& status) + virtual void processDone(const epics::pvData::Status& status, ChannelProcess::shared_pointer const &) { std::cout << "processDone(" << status.toString() << ")" << std::endl; } @@ -449,39 +419,39 @@ int main() context->initialize(); context->printInfo(); - epicsThreadSleep ( 1.0 ); + epicsThreadSleep ( SLEEP_TIME ); ChannelProvider::shared_pointer provider = context->getProvider(); */ ClientFactory::start(); - ChannelProvider::shared_pointer provider = getChannelAccess()->getProvider("pva"); + ChannelProvider::shared_pointer provider = getChannelProviderRegistry()->getProvider("pva"); ChannelFindRequester::shared_pointer findRequester(new ChannelFindRequesterImpl()); ChannelFind::shared_pointer channelFind = provider->channelFind("testSomething", findRequester); - epicsThreadSleep ( 1.0 ); + epicsThreadSleep ( SLEEP_TIME ); //channelFind->destroy(); ChannelRequester::shared_pointer channelRequester(new ChannelRequesterImpl()); Channel::shared_pointer channel = provider->createChannel("testStructureArrayTest", channelRequester); - epicsThreadSleep ( 1.0 ); + epicsThreadSleep ( SLEEP_TIME ); channel->printInfo(); { GetFieldRequester::shared_pointer getFieldRequesterImpl(new GetFieldRequesterImpl()); channel->getField(getFieldRequesterImpl, ""); - epicsThreadSleep ( 1.0 ); + epicsThreadSleep ( SLEEP_TIME ); } { ChannelProcessRequester::shared_pointer channelProcessRequester(new ChannelProcessRequesterImpl()); PVStructure::shared_pointer pvRequest; ChannelProcess::shared_pointer channelProcess = channel->createChannelProcess(channelProcessRequester, pvRequest); - epicsThreadSleep ( 1.0 ); - channelProcess->process(false); - epicsThreadSleep ( 1.0 ); + epicsThreadSleep ( SLEEP_TIME ); + channelProcess->process(); + epicsThreadSleep ( SLEEP_TIME ); channelProcess->destroy(); - epicsThreadSleep ( 1.0 ); + epicsThreadSleep ( SLEEP_TIME ); } { @@ -489,7 +459,7 @@ int main() PVStructure::shared_pointer pvRequest = CreateRequest::create()->createRequest("field()"); ChannelGet::shared_pointer channelGet = channel->createChannelGet(channelGetRequesterImpl, pvRequest); epicsThreadSleep ( 3.0 ); - channelGet->get(false); + channelGet->get(); epicsThreadSleep ( 3.0 ); channelGet->destroy(); } @@ -498,11 +468,12 @@ int main() ChannelPutRequester::shared_pointer channelPutRequesterImpl(new ChannelPutRequesterImpl()); PVStructure::shared_pointer pvRequest = CreateRequest::create()->createRequest("field(value,timeStamp)"); ChannelPut::shared_pointer channelPut = channel->createChannelPut(channelPutRequesterImpl, pvRequest); - epicsThreadSleep ( 1.0 ); + epicsThreadSleep ( SLEEP_TIME ); channelPut->get(); - epicsThreadSleep ( 1.0 ); - channelPut->put(false); - epicsThreadSleep ( 1.0 ); + epicsThreadSleep ( SLEEP_TIME ); + // TODO !!! + //channelPut->put(); + //epicsThreadSleep ( SLEEP_TIME ); channelPut->destroy(); } @@ -510,13 +481,14 @@ int main() ChannelPutGetRequester::shared_pointer channelPutGetRequesterImpl(new ChannelPutGetRequesterImpl()); PVStructure::shared_pointer pvRequest = CreateRequest::create()->createRequest("putField(value,timeStamp)getField(timeStamp)"); ChannelPutGet::shared_pointer channelPutGet = channel->createChannelPutGet(channelPutGetRequesterImpl, pvRequest); - epicsThreadSleep ( 1.0 ); + epicsThreadSleep ( SLEEP_TIME ); channelPutGet->getGet(); - epicsThreadSleep ( 1.0 ); + epicsThreadSleep ( SLEEP_TIME ); channelPutGet->getPut(); - epicsThreadSleep ( 1.0 ); - channelPutGet->putGet(false); - epicsThreadSleep ( 1.0 ); + epicsThreadSleep ( SLEEP_TIME ); + // TODO !!! + //channelPutGet->putGet(); + //epicsThreadSleep ( SLEEP_TIME ); channelPutGet->destroy(); } @@ -524,10 +496,10 @@ int main() ChannelRPCRequester::shared_pointer channelRPCRequesterImpl(new ChannelRPCRequesterImpl()); PVStructure::shared_pointer pvRequest = CreateRequest::create()->createRequest("record[]field(arguments)"); ChannelRPC::shared_pointer channelRPC = channel->createChannelRPC(channelRPCRequesterImpl, pvRequest); - epicsThreadSleep ( 1.0 ); + epicsThreadSleep ( SLEEP_TIME ); // for test simply use pvRequest as arguments - channelRPC->request(pvRequest, false); - epicsThreadSleep ( 1.0 ); + channelRPC->request(pvRequest); + epicsThreadSleep ( SLEEP_TIME ); channelRPC->destroy(); } @@ -538,13 +510,16 @@ int main() PVStructure::shared_pointer pvRequest(getPVDataCreate()->createPVStructure(getFieldCreate()->createStructure(fieldNames, fields))); ChannelArray::shared_pointer channelArray = channel->createChannelArray(channelArrayRequesterImpl, pvRequest); - epicsThreadSleep ( 1.0 ); - channelArray->getArray(false,0,0); - epicsThreadSleep ( 1.0 ); - channelArray->putArray(false,0,0); - epicsThreadSleep ( 1.0 ); - channelArray->setLength(false,3,4); - epicsThreadSleep ( 1.0 ); + epicsThreadSleep ( SLEEP_TIME ); + channelArray->getArray(0,0,1); + epicsThreadSleep ( SLEEP_TIME ); + // TODO !!! + //channelArray->putArray(0,0,1); + //epicsThreadSleep ( SLEEP_TIME ); + channelArray->setLength(3,4); + epicsThreadSleep ( SLEEP_TIME ); + channelArray->getLength(); + epicsThreadSleep ( SLEEP_TIME ); channelArray->destroy(); } @@ -553,12 +528,12 @@ int main() PVStructure::shared_pointer pvRequest = CreateRequest::create()->createRequest("field()"); Monitor::shared_pointer monitor = channel->createMonitor(monitorRequesterImpl, pvRequest); - epicsThreadSleep( 1.0 ); + epicsThreadSleep( SLEEP_TIME ); Status status = monitor->start(); std::cout << "monitor->start() = " << status.toString() << std::endl; - epicsThreadSleep( 3.0 ); + epicsThreadSleep( 3*SLEEP_TIME ); status = monitor->stop(); std::cout << "monitor->stop() = " << status.toString() << std::endl; @@ -567,12 +542,12 @@ int main() monitor->destroy(); } - epicsThreadSleep ( 3.0 ); + epicsThreadSleep ( 3*SLEEP_TIME ); printf("Destroying channel... \n"); channel->destroy(); printf("done.\n"); - epicsThreadSleep ( 3.0 ); + epicsThreadSleep ( 3*SLEEP_TIME ); } @@ -584,7 +559,7 @@ int main() printf("done.\n"); */ - epicsThreadSleep ( 1.0 ); } + epicsThreadSleep ( SLEEP_TIME ); } //std::cout << "-----------------------------------------------------------------------" << std::endl; //epicsExitCallAtExits(); return(0); diff --git a/testApp/remote/testServer.cpp b/testApp/remote/testServer.cpp index 230e636..66fe170 100644 --- a/testApp/remote/testServer.cpp +++ b/testApp/remote/testServer.cpp @@ -2364,7 +2364,7 @@ public: return m_provider.lock(); }; - virtual void cancelChannelFind() + virtual void cancel() { throw std::runtime_error("not supported"); } @@ -2578,7 +2578,7 @@ void testServer(int timeToRun) //ServerContextImpl::shared_pointer ctx = ServerContextImpl::create(); ctx = ServerContextImpl::create(); - ChannelAccess::shared_pointer channelAccess = getChannelAccess(); + ChannelAccess::shared_pointer channelAccess = getChannelProviderRegistry(); ctx->initialize(channelAccess); ctx->printInfo(); diff --git a/testApp/remote/testServerContext.cpp b/testApp/remote/testServerContext.cpp index 765d6b9..2c41e68 100644 --- a/testApp/remote/testServerContext.cpp +++ b/testApp/remote/testServerContext.cpp @@ -48,10 +48,10 @@ public: }; -class TestChannelAccess : public ChannelAccess { +class TestChannelProviderRegistry : public ChannelProviderRegistry { public: - virtual ~TestChannelAccess() {}; + virtual ~TestChannelProviderRegistry() {}; ChannelProvider::shared_pointer getProvider(epics::pvData::String const & providerName) { @@ -81,7 +81,7 @@ void testServerContext() ServerContextImpl::shared_pointer ctx = ServerContextImpl::create(); - ChannelAccess::shared_pointer ca(new TestChannelAccess()); + ChannelProviderRegistry::shared_pointer ca(new TestChannelProviderRegistry()); ctx->initialize(ca); ctx->printInfo();