From 22e260351ccd76f09cc020853cf5adbad00e7f50 Mon Sep 17 00:00:00 2001 From: Marty Kraimer Date: Tue, 9 Jan 2018 15:14:30 -0500 Subject: [PATCH] Revert "Minor changes" --- documentation/RELEASE_NOTES.md | 15 +------ src/Makefile | 2 +- src/pv/pvaClient.h | 34 ++++++++++++++++ src/pvaClient.cpp | 2 +- src/pvaClientGet.cpp | 18 +++++++++ src/pvaClientMonitor.cpp | 62 +++++++++++++++++++++++++---- src/pvaClientProcess.cpp | 47 +++++++++++++++++++++- src/pvaClientPut.cpp | 72 ++++++++++++++++++---------------- src/pvaClientPutGet.cpp | 38 +++++++++++------- 9 files changed, 217 insertions(+), 73 deletions(-) diff --git a/documentation/RELEASE_NOTES.md b/documentation/RELEASE_NOTES.md index 6f4aab9..44b57da 100644 --- a/documentation/RELEASE_NOTES.md +++ b/documentation/RELEASE_NOTES.md @@ -1,16 +1,5 @@ -EPICS 7 release 4.7.1 -===================== - -API changes to PvaClientMonitor -------------------------------- - -The create method that had arguments for stateChangeRequester and monitorRequester no longer exists. - -API changes to PvaClientGet, ..., PvaClientMonitor --------------------------------------------------- - -pvaClientGet, ..., pvaClientMonitor all implemented PvaClientChannelStateChangeRequester. -This was never called and has been removed. +pvaClientCPP Version 4.3.0 +========================== Works with pvDataCPP-7.0 and pvAccessCPP-6.0 versions ----------------------------------------------------- diff --git a/src/Makefile b/src/Makefile index a2143f9..bfdbb0b 100644 --- a/src/Makefile +++ b/src/Makefile @@ -6,7 +6,7 @@ include $(TOP)/configure/CONFIG LIBRARY += pvaClient # shared library ABI version. -SHRLIB_VERSION ?= 4.7.1 +SHRLIB_VERSION ?= 4.3.0 INC += pv/pvaClient.h INC += pv/pvaClientMultiChannel.h diff --git a/src/pv/pvaClient.h b/src/pv/pvaClient.h index f89420d..b31092f 100644 --- a/src/pv/pvaClient.h +++ b/src/pv/pvaClient.h @@ -967,6 +967,7 @@ typedef std::tr1::shared_ptr ChannelProcessRequeste * Overview of PvaClientProcess */ class epicsShareClass PvaClientProcess : + public PvaClientChannelStateChangeRequester, public std::tr1::enable_shared_from_this { public: @@ -1053,11 +1054,13 @@ private: ProcessConnectState connectState; + PvaClientChannelStateChangeRequesterWPtr pvaClientChannelStateChangeRequester; PvaClientProcessRequesterWPtr pvaClientProcessRequester; enum ProcessState {processIdle,processActive,processComplete}; ProcessState processState; ChannelProcessRequesterImplPtr channelProcessRequester; public: + void channelStateChange(PvaClientChannelPtr const & pvaClientChannel, bool isConnected); friend class ChannelProcessRequesterImpl; }; @@ -1101,6 +1104,7 @@ public: * Overview of PvaClientGet */ class epicsShareClass PvaClientGet : + public PvaClientChannelStateChangeRequester, public std::tr1::enable_shared_from_this { public: @@ -1196,12 +1200,14 @@ private: GetConnectState connectState; + PvaClientChannelStateChangeRequesterWPtr pvaClientChannelStateChangeRequester; PvaClientGetRequesterWPtr pvaClientGetRequester; enum GetState {getIdle,getActive,getComplete}; GetState getState; ChannelGetRequesterImplPtr channelGetRequester; public: + void channelStateChange(PvaClientChannelPtr const & pvaClientChannel, bool isConnected); friend class ChannelGetRequesterImpl; }; @@ -1257,6 +1263,7 @@ public: * Overview of PvaClientPut */ class epicsShareClass PvaClientPut : + public PvaClientChannelStateChangeRequester, public std::tr1::enable_shared_from_this { public: @@ -1367,8 +1374,10 @@ private : enum PutState {putIdle,getActive,putActive,putComplete}; PutState putState; ChannelPutRequesterImplPtr channelPutRequester; + PvaClientChannelStateChangeRequesterWPtr pvaClientChannelStateChangeRequester; PvaClientPutRequesterWPtr pvaClientPutRequester; public: + void channelStateChange(PvaClientChannelPtr const & pvaClientChannel, bool isConnected); friend class ChannelPutRequesterImpl; }; @@ -1435,6 +1444,7 @@ public: * Overview of PvaClientPutGet */ class epicsShareClass PvaClientPutGet : + public PvaClientChannelStateChangeRequester, public std::tr1::enable_shared_from_this { public: @@ -1574,8 +1584,10 @@ private : enum PutGetState {putGetIdle,putGetActive,putGetComplete}; PutGetState putGetState; ChannelPutGetRequesterImplPtr channelPutGetRequester; + PvaClientChannelStateChangeRequesterWPtr pvaClientChannelStateChangeRequester; PvaClientPutGetRequesterWPtr pvaClientPutGetRequester; public: + void channelStateChange(PvaClientChannelPtr const & pvaClientChannel, bool isConnected); friend class ChannelPutGetRequesterImpl; }; @@ -1627,6 +1639,7 @@ typedef std::tr1::shared_ptr MonitorRequesterImplPtr; * Overview of PvaClientMonitor */ class epicsShareClass PvaClientMonitor : + public PvaClientChannelStateChangeRequester, public PvaClientMonitorRequester, public std::tr1::enable_shared_from_this { @@ -1643,6 +1656,25 @@ public: PvaClientChannelPtr const & pvaClientChannel, epics::pvData::PVStructurePtr const &pvRequest ); + /** @brief Create a PvaClientMonitor. + * @param pvaClient Interface to PvaClient + * @param channelName channel name + * @param providerName provider name + * @param request The request. + * @param stateChangeRequester The state change requester. Can be null. + * @param monitorRequester The monitor requester. Can be null; + * @return The new instance. + */ + static PvaClientMonitorPtr create( + PvaClientPtr const &pvaClient, + std::string const & channelName, + std::string const & providerName, + std::string const & request, + PvaClientChannelStateChangeRequesterPtr const & stateChangeRequester + = PvaClientChannelStateChangeRequesterPtr(), + PvaClientMonitorRequesterPtr const & monitorRequester + = PvaClientMonitorRequesterPtr() + ); /** @brief Destructor */ ~PvaClientMonitor(); @@ -1735,6 +1767,7 @@ private: epics::pvData::MonitorPtr monitor; epics::pvData::MonitorElementPtr monitorElement; + PvaClientChannelStateChangeRequesterWPtr pvaClientChannelStateChangeRequester; PvaClientMonitorRequesterWPtr pvaClientMonitorRequester; MonitorConnectState connectState; bool userPoll; @@ -1742,6 +1775,7 @@ private: MonitorRequesterImplPtr monitorRequester; public: + void channelStateChange(PvaClientChannelPtr const & channel, bool isConnected); void event(PvaClientMonitorPtr const & monitor); friend class MonitorRequesterImpl; }; diff --git a/src/pvaClient.cpp b/src/pvaClient.cpp index 8c17fb7..4fea159 100644 --- a/src/pvaClient.cpp +++ b/src/pvaClient.cpp @@ -231,4 +231,4 @@ size_t PvaClient::cacheSize() } }} - + diff --git a/src/pvaClientGet.cpp b/src/pvaClientGet.cpp index 77c3798..b9173d5 100644 --- a/src/pvaClientGet.cpp +++ b/src/pvaClientGet.cpp @@ -114,6 +114,24 @@ PvaClientGet::~PvaClientGet() } } +void PvaClientGet::channelStateChange(PvaClientChannelPtr const & pvaClientChannel, bool isConnected) +{ + if(PvaClient::getDebug()) { + cout<< "PvaClientGet::channelStateChange" + << " channelName " << pvaClientChannel->getChannel()->getChannelName() + << " isConnected " << (isConnected ? "true" : "false") + << endl; + } + if(isConnected&&!channelGet) + { + connectState = connectActive; + channelGet = pvaClientChannel->getChannel()->createChannelGet(channelGetRequester,pvRequest); + } + PvaClientChannelStateChangeRequesterPtr req(pvaClientChannelStateChangeRequester.lock()); + if(req) { + req->channelStateChange(pvaClientChannel,isConnected); + } +} void PvaClientGet::checkGetState() { diff --git a/src/pvaClientMonitor.cpp b/src/pvaClientMonitor.cpp index 2663407..2a7ceb8 100644 --- a/src/pvaClientMonitor.cpp +++ b/src/pvaClientMonitor.cpp @@ -83,13 +83,47 @@ PvaClientMonitorPtr PvaClientMonitor::create( PvaClientChannelPtr const & pvaClientChannel, PVStructurePtr const &pvRequest) { - + if(PvaClient::getDebug()) { + cout<< "PvaClientMonitor::create(pvaClient,pvaClientChannel,pvRequest)\n" + << " channelName " << pvaClientChannel->getChannel()->getChannelName() + << endl; + } PvaClientMonitorPtr clientMonitor(new PvaClientMonitor(pvaClient,pvaClientChannel,pvRequest)); clientMonitor->monitorRequester = MonitorRequesterImplPtr( new MonitorRequesterImpl(clientMonitor,pvaClient)); return clientMonitor; } +PvaClientMonitorPtr PvaClientMonitor::create( + PvaClientPtr const &pvaClient, + std::string const & channelName, + std::string const & providerName, + std::string const & request, + PvaClientChannelStateChangeRequesterPtr const & stateChangeRequester, + PvaClientMonitorRequesterPtr const & monitorRequester) +{ + if(PvaClient::getDebug()) { + cout<< "PvaClientMonitor::create(pvaClient,channelName,providerName,request,stateChangeRequester,monitorRequester)\n" + << " channelName " << channelName + << " providerName " << providerName + << " request " << request + << endl; + } + CreateRequest::shared_pointer createRequest(CreateRequest::create()); + PVStructurePtr pvRequest(createRequest->createRequest(request)); + if(!pvRequest) throw std::runtime_error(createRequest->getMessage()); + PvaClientChannelPtr pvaClientChannel = pvaClient->createChannel(channelName,providerName); + PvaClientMonitorPtr clientMonitor(new PvaClientMonitor(pvaClient,pvaClientChannel,pvRequest)); + clientMonitor->monitorRequester = MonitorRequesterImplPtr( + new MonitorRequesterImpl(clientMonitor,pvaClient)); + if(stateChangeRequester) clientMonitor->pvaClientChannelStateChangeRequester = stateChangeRequester; + if(monitorRequester) clientMonitor->pvaClientMonitorRequester = monitorRequester; + pvaClientChannel->setStateChangeRequester(clientMonitor); + pvaClientChannel->issueConnect(); + return clientMonitor; +} + + PvaClientMonitor::PvaClientMonitor( PvaClientPtr const &pvaClient, PvaClientChannelPtr const & pvaClientChannel, @@ -103,9 +137,7 @@ PvaClientMonitor::PvaClientMonitor( userWait(false) { if(PvaClient::getDebug()) { - cout<< "PvaClientMonitor::PvaClientMonitor\n" - << " channelName " << pvaClientChannel->getChannel()->getChannelName() - << endl; + cout<< "PvaClientMonitor::PvaClientMonitor()" << endl; } } @@ -121,13 +153,27 @@ PvaClientMonitor::~PvaClientMonitor() } } -void PvaClientMonitor::event(PvaClientMonitorPtr const & monitor) +void PvaClientMonitor::channelStateChange(PvaClientChannelPtr const & channel, bool isConnected) { if(PvaClient::getDebug()) { - cout << "PvaClientMonitor::event" - << " channelName " << pvaClientChannel->getChannel()->getChannelName() - << endl; + cout<< "PvaClientMonitor::channelStateChange" + << " channelName " << channel->getChannelName() + << " isConnected " << (isConnected ? "true" : "false") + << endl; } + if(isConnected&&!monitor) + { + connectState = connectActive; + monitor = pvaClientChannel->getChannel()->createMonitor(monitorRequester,pvRequest); + } + PvaClientChannelStateChangeRequesterPtr req(pvaClientChannelStateChangeRequester.lock()); + if(req) { + req->channelStateChange(channel,isConnected); + } +} + +void PvaClientMonitor::event(PvaClientMonitorPtr const & monitor) +{ PvaClientMonitorRequesterPtr req(pvaClientMonitorRequester.lock()); if(req) req->event(monitor); } diff --git a/src/pvaClientProcess.cpp b/src/pvaClientProcess.cpp index e8b7d06..9461768 100644 --- a/src/pvaClientProcess.cpp +++ b/src/pvaClientProcess.cpp @@ -112,6 +112,50 @@ PvaClientProcess::~PvaClientProcess() } } +void PvaClientProcess::channelStateChange(PvaClientChannelPtr const & pvaClientChannel, bool isConnected) +{ + if(PvaClient::getDebug()) { + cout<< "PvaClientProcess::channelStateChange" + << " channelName " << pvaClientChannel->getChannel()->getChannelName() + << " isConnected " << (isConnected ? "true" : "false") + << endl; + } + if(isConnected) + { + connectState = connectActive; + channelProcess = pvaClientChannel->getChannel()->createChannelProcess(channelProcessRequester,pvRequest); + } + PvaClientChannelStateChangeRequesterPtr req(pvaClientChannelStateChangeRequester.lock()); + if(req) { + req->channelStateChange(pvaClientChannel,isConnected); + } +} + +void PvaClientProcess::checkProcessState() +{ + if(PvaClient::getDebug()) { + cout << "PvaClientProcess::checkProcessState" + << " channelName " << pvaClientChannel->getChannel()->getChannelName() + << endl; + } + if(!pvaClientChannel->getChannel()->isConnected()) { + string message = string("channel ") + pvaClientChannel->getChannel()->getChannelName() + + " PvaClientProcess::checkProcessState channel not connected "; + throw std::runtime_error(message); + } + if(connectState==connectIdle) { + connect(); + } + if(connectState==connectActive){ + string message = string("channel ") + pvaClientChannel->getChannel()->getChannelName() + + " " + + channelProcessConnectStatus.getMessage(); + throw std::runtime_error(message); + } + if(processState==processIdle) process(); +} + + // from ChannelProcessRequester string PvaClientProcess::getRequesterName() { @@ -211,7 +255,6 @@ void PvaClientProcess::issueConnect() throw std::runtime_error(message); } connectState = connectActive; - channelProcessConnectStatus = Status(Status::STATUSTYPE_ERROR, "connect active"); channelProcess = pvaClientChannel->getChannel()->createChannelProcess(channelProcessRequester,pvRequest); } @@ -259,7 +302,7 @@ void PvaClientProcess::issueProcess() << endl; } if(connectState==connectIdle) connect(); - if(processState==processActive) { + if(processState!=processIdle) { string message = string("channel ") + pvaClientChannel->getChannel()->getChannelName() + " PvaClientProcess::issueProcess process aleady active "; throw std::runtime_error(message); diff --git a/src/pvaClientPut.cpp b/src/pvaClientPut.cpp index b6be8e1..561d311 100644 --- a/src/pvaClientPut.cpp +++ b/src/pvaClientPut.cpp @@ -118,6 +118,24 @@ PvaClientPut::~PvaClientPut() } } +void PvaClientPut::channelStateChange(PvaClientChannelPtr const & pvaClientChannel, bool isConnected) +{ + if(PvaClient::getDebug()) { + cout<< "PvaClientPut::channelStateChange" + << " channelName " << pvaClientChannel->getChannel()->getChannelName() + << " isConnected " << (isConnected ? "true" : "false") + << endl; + } + if(isConnected&&!channelPut) + { + connectState = connectActive; + channelPut = pvaClientChannel->getChannel()->createChannelPut(channelPutRequester,pvRequest); + } + PvaClientChannelStateChangeRequesterPtr req(pvaClientChannelStateChangeRequester.lock()); + if(req) { + req->channelStateChange(pvaClientChannel,isConnected); + } +} void PvaClientPut::checkPutState() { @@ -199,17 +217,13 @@ void PvaClientPut::getDone( << " status.isOK " << (status.isOK() ? "true" : "false") << endl; } - { - Lock xx(mutex); - channelGetPutStatus = status; - if(status.isOK()) { - PVStructurePtr pvs = pvaClientData->getPVStructure(); - pvs->copyUnchecked(*pvStructure,*bitSet); - BitSetPtr bs = pvaClientData->getChangedBitSet(); - bs->clear(); - *bs |= *bitSet; - putState = putComplete; - } + channelGetPutStatus = status; + if(status.isOK()) { + PVStructurePtr pvs = pvaClientData->getPVStructure(); + pvs->copyUnchecked(*pvStructure,*bitSet); + BitSetPtr bs = pvaClientData->getChangedBitSet(); + bs->clear(); + *bs |= *bitSet; } PvaClientPutRequesterPtr req(pvaClientPutRequester.lock()); if(req) { @@ -228,11 +242,7 @@ void PvaClientPut::putDone( << " status.isOK " << (status.isOK() ? "true" : "false") << endl; } - { - Lock xx(mutex); - channelGetPutStatus = status; - putState = putComplete; - } + channelGetPutStatus = status; PvaClientPutRequesterPtr req(pvaClientPutRequester.lock()); if(req) { req->putDone(status,shared_from_this()); @@ -341,17 +351,14 @@ Status PvaClientPut::waitGet() << " channelName " << pvaClientChannel->getChannel()->getChannelName() << endl; } - { - Lock xx(mutex); - if(putState==putComplete) return channelGetPutStatus; - if(putState!=getActive){ - string message = string("channel ") - + pvaClientChannel->getChannel()->getChannelName() - + " PvaClientPut::waitGet illegal put state"; - throw std::runtime_error(message); - } + if(putState!=getActive){ + string message = string("channel ") + + pvaClientChannel->getChannel()->getChannelName() + + " PvaClientPut::waitGet illegal put state"; + throw std::runtime_error(message); } waitForGetPut.wait(); + putState = putComplete; return channelGetPutStatus; } @@ -399,17 +406,14 @@ Status PvaClientPut::waitPut() << " channelName " << pvaClientChannel->getChannel()->getChannelName() << endl; } - { - Lock xx(mutex); - if(putState==putComplete) return channelGetPutStatus; - if(putState!=putActive){ - string message = string("channel ") - + pvaClientChannel->getChannel()->getChannelName() - + " PvaClientPut::waitPut illegal put state"; - throw std::runtime_error(message); - } + if(putState!=putActive){ + string message = string("channel ") + + pvaClientChannel->getChannel()->getChannelName() + + " PvaClientPut::waitPut illegal put state"; + throw std::runtime_error(message); } waitForGetPut.wait(); + putState = putComplete; if(channelGetPutStatus.isOK()) pvaClientData->getChangedBitSet()->clear(); return channelGetPutStatus; } diff --git a/src/pvaClientPutGet.cpp b/src/pvaClientPutGet.cpp index bde22a3..efe6e9c 100644 --- a/src/pvaClientPutGet.cpp +++ b/src/pvaClientPutGet.cpp @@ -131,6 +131,25 @@ PvaClientPutGet::~PvaClientPutGet() } } +void PvaClientPutGet::channelStateChange(PvaClientChannelPtr const & pvaClientChannel, bool isConnected) +{ + if(PvaClient::getDebug()) { + cout<< "PvaClientPutGet::channelStateChange" + << " channelName " << pvaClientChannel->getChannel()->getChannelName() + << " isConnected " << (isConnected ? "true" : "false") + << endl; + } + if(isConnected&&!channelPutGet) + { + connectState = connectActive; + channelPutGet = pvaClientChannel->getChannel()->createChannelPutGet(channelPutGetRequester,pvRequest); + } + PvaClientChannelStateChangeRequesterPtr req(pvaClientChannelStateChangeRequester.lock()); + if(req) { + req->channelStateChange(pvaClientChannel,isConnected); + } +} + void PvaClientPutGet::checkPutGetState() { if(PvaClient::getDebug()) { @@ -216,7 +235,6 @@ void PvaClientPutGet::putGetDone( << endl; } channelPutGetStatus = status; - putGetState = putGetComplete; if(status.isOK()) { PVStructurePtr pvs = pvaClientGetData->getPVStructure(); pvs->copyUnchecked(*getPVStructure,*getChangedBitSet); @@ -244,7 +262,6 @@ void PvaClientPutGet::getPutDone( << endl; } channelPutGetStatus = status; - putGetState = putGetComplete; if(status.isOK()) { PVStructurePtr pvs = pvaClientPutData->getPVStructure(); pvs->copyUnchecked(*putPVStructure,*putBitSet); @@ -272,7 +289,6 @@ void PvaClientPutGet::getGetDone( << endl; } channelPutGetStatus = status; - putGetState = putGetComplete; if(status.isOK()) { PVStructurePtr pvs = pvaClientGetData->getPVStructure(); pvs->copyUnchecked(*getPVStructure,*getChangedBitSet); @@ -391,7 +407,6 @@ Status PvaClientPutGet::waitPutGet() << " channelName " << pvaClientChannel->getChannel()->getChannelName() << endl; } - if(putGetState==putGetComplete) return channelPutGetStatus; if(putGetState!=putGetActive){ string message = string("channel ") + pvaClientChannel->getChannel()->getChannelName() @@ -399,6 +414,7 @@ Status PvaClientPutGet::waitPutGet() throw std::runtime_error(message); } waitForPutGet.wait(); + putGetState = putGetComplete; if(channelPutGetStatus.isOK()) pvaClientPutData->getChangedBitSet()->clear(); return channelPutGetStatus; } @@ -445,7 +461,6 @@ Status PvaClientPutGet::waitGetGet() << " channelName " << pvaClientChannel->getChannel()->getChannelName() << endl; } - if(putGetState==putGetComplete) return channelPutGetStatus; if(putGetState!=putGetActive){ string message = string("channel ") + pvaClientChannel->getChannel()->getChannelName() @@ -453,6 +468,7 @@ Status PvaClientPutGet::waitGetGet() throw std::runtime_error(message); } waitForPutGet.wait(); + putGetState = putGetComplete; return channelPutGetStatus; } @@ -498,7 +514,6 @@ Status PvaClientPutGet::waitGetPut() << " channelName " << pvaClientChannel->getChannel()->getChannelName() << endl; } - if(putGetState==putGetComplete) return channelPutGetStatus; if(putGetState!=putGetActive){ string message = string("channel ") + pvaClientChannel->getChannel()->getChannelName() @@ -506,6 +521,7 @@ Status PvaClientPutGet::waitGetPut() throw std::runtime_error(message); } waitForPutGet.wait(); + putGetState = putGetComplete; return channelPutGetStatus; } @@ -517,10 +533,7 @@ PvaClientGetDataPtr PvaClientPutGet::getGetData() << endl; } checkPutGetState(); - if(putGetState==putGetIdle){ - getGet(); - getPut(); - } + if(putGetState==putGetIdle) getGet(); return pvaClientGetData; } @@ -532,10 +545,7 @@ PvaClientPutDataPtr PvaClientPutGet::getPutData() << endl; } checkPutGetState(); - if(putGetState==putGetIdle){ - getGet(); - getPut(); - } + if(putGetState==putGetIdle) getPut(); return pvaClientPutData; }