Merge pull request #5 from mrkraimer/master
multi channel support removed for now; will be redone soon
This commit is contained in:
@@ -33,21 +33,6 @@ examplePvaClientMonitor_LIBS += pvAccess
|
||||
examplePvaClientMonitor_LIBS += pvData
|
||||
examplePvaClientMonitor_LIBS += Com
|
||||
|
||||
PROD_HOST += examplePvaClientMultiDouble
|
||||
examplePvaClientMultiDouble_SRCS += examplePvaClientMultiDouble.cpp
|
||||
examplePvaClientMultiDouble_LIBS += pvaClient
|
||||
examplePvaClientMultiDouble_LIBS += pvAccess
|
||||
examplePvaClientMultiDouble_LIBS += pvData
|
||||
examplePvaClientMultiDouble_LIBS += Com
|
||||
|
||||
PROD_HOST += examplePvaClientNTMultiChannel
|
||||
examplePvaClientNTMultiChannel_SRCS += examplePvaClientNTMultiChannel.cpp
|
||||
examplePvaClientNTMultiChannel_LIBS += pvaClient
|
||||
examplePvaClientNTMultiChannel_LIBS += pvAccess
|
||||
examplePvaClientNTMultiChannel_LIBS += nt
|
||||
examplePvaClientNTMultiChannel_LIBS += pvData
|
||||
examplePvaClientNTMultiChannel_LIBS += Com
|
||||
|
||||
PROD_HOST += helloWorldRPC
|
||||
helloWorldRPC_SRCS += helloWorldRPC.cpp
|
||||
helloWorldRPC_LIBS += pvaClient
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/*examplePvaClientClientMonitor.cpp */
|
||||
/*examplePvaClientMonitor.cpp */
|
||||
/**
|
||||
* Copyright - See the COPYRIGHT that is included with this distribution.
|
||||
* EPICS pvData is distributed subject to a Software License Agreement found
|
||||
@@ -24,10 +24,18 @@ using namespace epics::pvaClient;
|
||||
|
||||
static void exampleMonitor(PvaClientPtr const &pva)
|
||||
{
|
||||
PvaClientMonitorPtr monitor = pva->channel("examplePowerSupply")->monitor("");
|
||||
PvaClientMonitorPtr monitor = pva->channel("exampleDouble")->monitor("");
|
||||
PvaClientMonitorDataPtr pvaData = monitor->getData();
|
||||
while(true) {
|
||||
monitor->waitEvent();
|
||||
PvaClientPutPtr put = pva->channel("exampleDouble")->put("");
|
||||
PvaClientPutDataPtr putData = put->getData();
|
||||
for(size_t ntimes=0; ntimes<5; ++ntimes)
|
||||
{
|
||||
double value = ntimes;
|
||||
putData->putDouble(value); put->put();
|
||||
if(!monitor->waitEvent()) {
|
||||
cout << "waitEvent returned false. Why???";
|
||||
continue;
|
||||
}
|
||||
cout << "changed\n";
|
||||
pvaData->showChanged(cout);
|
||||
cout << "overrun\n";
|
||||
|
||||
@@ -1,84 +0,0 @@
|
||||
/*examplePvaClientMultiDouble.cpp */
|
||||
/**
|
||||
* Copyright - See the COPYRIGHT that is included with this distribution.
|
||||
* EPICS pvData is distributed subject to a Software License Agreement found
|
||||
* in file LICENSE that is included with this distribution.
|
||||
*/
|
||||
/**
|
||||
* @author mrk
|
||||
*/
|
||||
|
||||
/* Author: Marty Kraimer */
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include <pv/pvaClientMultiDouble.h>
|
||||
|
||||
using namespace std;
|
||||
using namespace epics::pvData;
|
||||
using namespace epics::pvAccess;
|
||||
using namespace epics::pvaClient;
|
||||
|
||||
|
||||
static void example(PvaClientPtr const &pva)
|
||||
{
|
||||
cout << "example multiDouble\n";
|
||||
size_t num = 5;
|
||||
shared_vector<string> channelNames(num);
|
||||
channelNames[0] = "exampleDouble01";
|
||||
channelNames[1] = "exampleDouble02";
|
||||
channelNames[2] = "exampleDouble03";
|
||||
channelNames[3] = "exampleDouble04";
|
||||
channelNames[4] = "exampleDouble05";
|
||||
PVStringArrayPtr pvNames =
|
||||
getPVDataCreate()->createPVScalarArray<PVStringArray>();
|
||||
pvNames->replace(freeze(channelNames));
|
||||
PvaClientMultiDoublePtr multiDouble(PvaClientMultiDouble::create(pva,pvNames));
|
||||
try {
|
||||
shared_vector<double> data = multiDouble->get();
|
||||
cout << "initial " << data << endl;
|
||||
for(size_t i=0; i<num; ++i) data[i] = data[i] + 1.1;
|
||||
multiDouble->put(data);
|
||||
data = multiDouble->get();
|
||||
cout << "final " << data << endl;
|
||||
} catch (std::runtime_error e) {
|
||||
cout << "exception " << e.what() << endl;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static void exampleCA(PvaClientPtr const &pva)
|
||||
{
|
||||
cout << "example multiDouble\n";
|
||||
size_t num = 5;
|
||||
shared_vector<string> channelNames(num);
|
||||
channelNames[0] = "double01";
|
||||
channelNames[1] = "double02";
|
||||
channelNames[2] = "double03";
|
||||
channelNames[3] = "double04";
|
||||
channelNames[4] = "double05";
|
||||
PVStringArrayPtr pvNames =
|
||||
getPVDataCreate()->createPVScalarArray<PVStringArray>();
|
||||
pvNames->replace(freeze(channelNames));
|
||||
PvaClientMultiDoublePtr multiDouble(PvaClientMultiDouble::create(pva,pvNames,5.0,"ca"));
|
||||
try {
|
||||
shared_vector<double> data = multiDouble->get();
|
||||
cout << "initial " << data << endl;
|
||||
for(size_t i=0; i<num; ++i) data[i] = data[i] + 1.1;
|
||||
multiDouble->put(data);
|
||||
data = multiDouble->get();
|
||||
cout << "final " << data << endl;
|
||||
} catch (std::runtime_error e) {
|
||||
cout << "exception " << e.what() << endl;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
int main(int argc,char *argv[])
|
||||
{
|
||||
PvaClientPtr pva = PvaClient::create();
|
||||
example(pva);
|
||||
exampleCA(pva);
|
||||
return 0;
|
||||
}
|
||||
@@ -1,101 +0,0 @@
|
||||
/*examplePvaClientNTMultiChannel.cpp */
|
||||
/**
|
||||
* Copyright - See the COPYRIGHT that is included with this distribution.
|
||||
* EPICS pvData is distributed subject to a Software License Agreement found
|
||||
* in file LICENSE that is included with this distribution.
|
||||
*/
|
||||
/**
|
||||
* @author mrk
|
||||
*/
|
||||
|
||||
/* Author: Marty Kraimer */
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include <pv/pvaClientNTMultiChannel.h>
|
||||
|
||||
using namespace std;
|
||||
using namespace epics::pvData;
|
||||
using namespace epics::pvAccess;
|
||||
using namespace epics::pvaClient;
|
||||
using namespace epics::nt;
|
||||
|
||||
|
||||
static void example(PvaClientPtr const &pva)
|
||||
{
|
||||
cout << "example ntMultiChannel\n";
|
||||
size_t num = 5;
|
||||
shared_vector<string> channelNames(num);
|
||||
channelNames[0] = "exampleDouble";
|
||||
channelNames[1] = "exampleDoubleArray";
|
||||
channelNames[2] = "exampleString";
|
||||
channelNames[3] = "exampleBoolean";
|
||||
channelNames[4] = "exampleEnum";
|
||||
PVStringArrayPtr pvNames =
|
||||
getPVDataCreate()->createPVScalarArray<PVStringArray>();
|
||||
pvNames->replace(freeze(channelNames));
|
||||
NTMultiChannelBuilderPtr builder = NTMultiChannel::createBuilder();
|
||||
StructureConstPtr structure = builder->
|
||||
addTimeStamp()->
|
||||
addSeverity() ->
|
||||
addStatus() ->
|
||||
addMessage() ->
|
||||
addSecondsPastEpoch() ->
|
||||
addNanoseconds() ->
|
||||
addUserTag() ->
|
||||
createStructure();
|
||||
PvaClientNTMultiChannelPtr multi = PvaClientNTMultiChannel::create(
|
||||
pva,pvNames,structure);
|
||||
try {
|
||||
NTMultiChannelPtr nt = multi->get();
|
||||
cout << "initial\n" << nt->getPVStructure() << endl;
|
||||
|
||||
} catch (std::runtime_error e) {
|
||||
cout << "exception " << e.what() << endl;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static void exampleCA(PvaClientPtr const &pva)
|
||||
{
|
||||
cout << "example ntMultiChannel\n";
|
||||
size_t num = 5;
|
||||
shared_vector<string> channelNames(num);
|
||||
channelNames[0] = "double00";
|
||||
channelNames[1] = "doubleArray";
|
||||
channelNames[2] = "string00";
|
||||
channelNames[3] = "mbbiwierd";
|
||||
channelNames[4] = "enum01";
|
||||
PVStringArrayPtr pvNames =
|
||||
getPVDataCreate()->createPVScalarArray<PVStringArray>();
|
||||
pvNames->replace(freeze(channelNames));
|
||||
NTMultiChannelBuilderPtr builder = NTMultiChannel::createBuilder();
|
||||
StructureConstPtr structure = builder->
|
||||
addTimeStamp()->
|
||||
addSeverity() ->
|
||||
addStatus() ->
|
||||
addMessage() ->
|
||||
addSecondsPastEpoch() ->
|
||||
addNanoseconds() ->
|
||||
addUserTag() ->
|
||||
createStructure();
|
||||
PvaClientNTMultiChannelPtr multi = PvaClientNTMultiChannel::create(
|
||||
pva,pvNames,structure,5.0,"ca");
|
||||
try {
|
||||
NTMultiChannelPtr nt = multi->get();
|
||||
cout << "initial\n" << nt->getPVStructure() << endl;
|
||||
|
||||
} catch (std::runtime_error e) {
|
||||
cout << "exception " << e.what() << endl;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
int main(int argc,char *argv[])
|
||||
{
|
||||
PvaClientPtr pva = PvaClient::create();
|
||||
example(pva);
|
||||
exampleCA(pva);
|
||||
return 0;
|
||||
}
|
||||
@@ -6,8 +6,6 @@ include $(TOP)/configure/CONFIG
|
||||
LIBRARY += pvaClient
|
||||
|
||||
INC += pvaClient.h
|
||||
INC += pvaClientMultiDouble.h
|
||||
INC += pvaClientNTMultiChannel.h
|
||||
|
||||
LIBSRCS += pvaClient.cpp
|
||||
LIBSRCS += pvaClientPutData.cpp
|
||||
@@ -19,9 +17,6 @@ LIBSRCS += pvaClientGet.cpp
|
||||
LIBSRCS += pvaClientPut.cpp
|
||||
LIBSRCS += pvaClientMonitor.cpp
|
||||
LIBSRCS += pvaClientPutGet.cpp
|
||||
LIBSRCS += pvaClientMultiChannel.cpp
|
||||
LIBSRCS += pvaClientMultiDouble.cpp
|
||||
LIBSRCS += pvaClientNTMultiChannel.cpp
|
||||
|
||||
pvaClient_LIBS += pvAccess pvData nt Com
|
||||
pvaClient_LIBS += $(EPICS_BASE_IOC_LIBS)
|
||||
|
||||
@@ -148,15 +148,6 @@ PvaClientPtr PvaClient::create()
|
||||
return xx;
|
||||
}
|
||||
|
||||
PVStructurePtr PvaClient::createRequest(string const &request)
|
||||
{
|
||||
CreateRequest::shared_pointer createRequest = CreateRequest::create();
|
||||
PVStructurePtr pvRequest = createRequest->createRequest(request);
|
||||
if(!pvRequest) {
|
||||
throw std::invalid_argument("invalid pvRequest: " + createRequest->getMessage());
|
||||
}
|
||||
return pvRequest;
|
||||
}
|
||||
|
||||
PvaClient::PvaClient()
|
||||
: pvaClientChannelCache(new PvaClientChannelCache()),
|
||||
@@ -176,8 +167,6 @@ void PvaClient::destroy()
|
||||
isDestroyed = true;
|
||||
}
|
||||
pvaClientChannelCache.reset();
|
||||
channelList.clear();
|
||||
multiChannelList.clear();
|
||||
StartStopClientFactory::PvaClientBeingDestroyed();
|
||||
}
|
||||
|
||||
@@ -243,18 +232,5 @@ size_t PvaClient::cacheSize()
|
||||
return pvaClientChannelCache->cacheSize();
|
||||
}
|
||||
|
||||
PvaClientMultiChannelPtr PvaClient::createMultiChannel(
|
||||
epics::pvData::PVStringArrayPtr const & channelNames)
|
||||
{
|
||||
return createMultiChannel(channelNames,"pvaClient");
|
||||
}
|
||||
|
||||
PvaClientMultiChannelPtr PvaClient::createMultiChannel(
|
||||
epics::pvData::PVStringArrayPtr const & channelNames,
|
||||
std::string const & providerName)
|
||||
{
|
||||
return PvaClientMultiChannel::create(getPtrSelf(),channelNames,providerName);
|
||||
}
|
||||
|
||||
}}
|
||||
|
||||
|
||||
186
src/pvaClient.h
186
src/pvaClient.h
@@ -70,16 +70,7 @@ class PvaClientMonitorRequester;
|
||||
typedef std::tr1::shared_ptr<PvaClientMonitorRequester> PvaClientMonitorRequesterPtr;
|
||||
class PvaClientArray;
|
||||
typedef std::tr1::shared_ptr<PvaClientArray> PvaClientArrayPtr;
|
||||
class PvaClientRPC;
|
||||
typedef std::tr1::shared_ptr<PvaClientRPC> PvaClientRPCPtr;
|
||||
|
||||
typedef epics::pvData::shared_vector<const PvaClientChannelPtr> PvaClientChannelArray;
|
||||
typedef std::tr1::shared_ptr<PvaClientChannelArray> PvaClientChannelArrayPtr;
|
||||
typedef std::tr1::weak_ptr<PvaClientChannelArray> PvaClientChannelArrayWPtr;
|
||||
|
||||
class PvaClientMultiChannel;
|
||||
typedef std::tr1::shared_ptr<PvaClientMultiChannel> PvaClientMultiChannelPtr;
|
||||
class PvaClientMultiChannelGet;
|
||||
|
||||
// following are private to pvaClient
|
||||
class PvaClientChannelCache;
|
||||
@@ -168,20 +159,6 @@ public:
|
||||
/** Get the number of cached channels.
|
||||
*/
|
||||
size_t cacheSize();
|
||||
/** Create an PvaClientMultiChannel. The provider is pvAccess.
|
||||
* @param channelName The channelName array.
|
||||
* @return The interface.
|
||||
*/
|
||||
PvaClientMultiChannelPtr createMultiChannel(
|
||||
epics::pvData::PVStringArrayPtr const & channelNames);
|
||||
/** Create an PvaClientMultiChannel with the specified provider.
|
||||
* @param channelName The channelName array.
|
||||
* @param providerName The provider.
|
||||
* @return The interface.
|
||||
*/
|
||||
PvaClientMultiChannelPtr createMultiChannel(
|
||||
epics::pvData::PVStringArrayPtr const & channelNames,
|
||||
std::string const & providerName);
|
||||
/** Get shared pointer to this
|
||||
*/
|
||||
PvaClientPtr getPtrSelf()
|
||||
@@ -192,9 +169,6 @@ private:
|
||||
PvaClient();
|
||||
PvaClientChannelCachePtr pvaClientChannelCache;
|
||||
|
||||
epics::pvData::PVStructurePtr createRequest(std::string const &request);
|
||||
std::list<PvaClientChannelPtr> channelList;
|
||||
std::list<PvaClientMultiChannelPtr> multiChannelList;
|
||||
epics::pvData::Requester::weak_pointer requester;
|
||||
bool isDestroyed;
|
||||
epics::pvData::Mutex mutex;
|
||||
@@ -218,7 +192,7 @@ public:
|
||||
/** Create a PvaClientChannel.
|
||||
* @param channelName The name of the channel.
|
||||
* @param providerName The name of the provider.
|
||||
* @return The interface to the PvaClientStructure.
|
||||
* @return The interface to the PvaClientChannel.
|
||||
*/
|
||||
static PvaClientChannelPtr create(
|
||||
PvaClientPtr const &pvaClient,
|
||||
@@ -337,21 +311,6 @@ public:
|
||||
* @return The interface.
|
||||
*/
|
||||
PvaClientPutGetPtr createPutGet(epics::pvData::PVStructurePtr const & pvRequest);
|
||||
/** Call createRPC(PVStructure(null))
|
||||
* @return The interface.
|
||||
*/
|
||||
PvaClientRPCPtr createRPC();
|
||||
/**
|
||||
* @brief First call createRequest as implemented by pvDataJava and then calls the next method.
|
||||
* @param request The request as described in package org.epics.pvdata.copy
|
||||
* @return The interface.
|
||||
*/
|
||||
PvaClientRPCPtr createRPC(std::string const & request);
|
||||
/** Create an PvaClientRPC.
|
||||
* @param pvRequest The syntax of pvRequest is described in package org.epics.pvdata.copy.
|
||||
* @return The interface.
|
||||
*/
|
||||
PvaClientRPCPtr createRPC(epics::pvData::PVStructurePtr const & pvRequest);
|
||||
/** Call the next method with request = "field(value)";
|
||||
* @return The interface.
|
||||
*/
|
||||
@@ -479,7 +438,7 @@ public:
|
||||
* This shows which fields have changed value.
|
||||
* @return The bitSet
|
||||
*/
|
||||
epics::pvData::BitSetPtr getBitSet();
|
||||
epics::pvData::BitSetPtr getChangedBitSet();
|
||||
/** Show the fields that have changed.
|
||||
* @param out The stream that shows the changed fields.
|
||||
* @return The stream that was input
|
||||
@@ -597,7 +556,7 @@ public:
|
||||
* This shows which fields have changed value.
|
||||
* @return The bitSet
|
||||
*/
|
||||
epics::pvData::BitSetPtr getBitSet();
|
||||
epics::pvData::BitSetPtr getChangedBitSet();
|
||||
/** Show the fields that have changed.
|
||||
* @param out The stream that shows the changed fields.
|
||||
* @return The stream that was input
|
||||
@@ -739,11 +698,6 @@ public:
|
||||
* @return The stream that was input
|
||||
*/
|
||||
std::ostream & showOverrun(std::ostream & out);
|
||||
/**
|
||||
* @brief New data is present.
|
||||
* @param monitorElement The new data.
|
||||
*/
|
||||
void setData(epics::pvData::MonitorElementPtr const & monitorElement);
|
||||
/** Is there a top level field named value.
|
||||
* @return The answer.
|
||||
*/
|
||||
@@ -807,10 +761,16 @@ public:
|
||||
* @return The timeStamp.
|
||||
*/
|
||||
epics::pvData::TimeStamp getTimeStamp();
|
||||
/*
|
||||
* This is called by pvaClientMonitor when it gets a monitor.
|
||||
* @param monitorElement The new data.
|
||||
* @param monitorElement The new data.
|
||||
*/
|
||||
void setData(epics::pvData::MonitorElementPtr const & monitorElement);
|
||||
private:
|
||||
PvaClientMonitorData(epics::pvData::StructureConstPtr const & structure);
|
||||
void checkValue();
|
||||
|
||||
|
||||
epics::pvData::StructureConstPtr structure;
|
||||
epics::pvData::PVStructurePtr pvStructure;
|
||||
epics::pvData::BitSetPtr changedBitSet;
|
||||
@@ -820,6 +780,7 @@ private:
|
||||
epics::pvData::PVFieldPtr pvValue;
|
||||
epics::pvData::PVAlarm pvAlarm;
|
||||
epics::pvData::PVTimeStamp pvTimeStamp;
|
||||
friend class PvaClientMonitor;
|
||||
};
|
||||
|
||||
class ChannelProcessRequesterImpl; // private to PvaClientProcess
|
||||
@@ -834,14 +795,12 @@ public:
|
||||
POINTER_DEFINITIONS(PvaClientProcess);
|
||||
/** Create a PvaClientProcess.
|
||||
* @param &pvaClient Interface to PvaClient
|
||||
* @param pvaClientChannel Interface to PvaClientChannel
|
||||
* @param channel Interface to Channel
|
||||
* @param pvRequest The request structure.
|
||||
* @return The interface to the PvaClientStructure.
|
||||
* @return The interface to the PvaClientProcess.
|
||||
*/
|
||||
static PvaClientProcessPtr create(
|
||||
PvaClientPtr const &pvaClient,
|
||||
PvaClientChannelPtr const & pvaClientChannel,
|
||||
epics::pvAccess::Channel::shared_pointer const & channel,
|
||||
epics::pvData::PVStructurePtr const &pvRequest
|
||||
);
|
||||
@@ -877,7 +836,6 @@ public:
|
||||
private:
|
||||
PvaClientProcess(
|
||||
PvaClientPtr const &pvaClient,
|
||||
PvaClientChannelPtr const & pvaClientChannel,
|
||||
epics::pvAccess::Channel::shared_pointer const & channel,
|
||||
epics::pvData::PVStructurePtr const &pvRequest);
|
||||
std::string getRequesterName();
|
||||
@@ -888,18 +846,15 @@ private:
|
||||
void processDone(
|
||||
const epics::pvData::Status& status,
|
||||
epics::pvAccess::ChannelProcess::shared_pointer const & channelProcess);
|
||||
void checkProcessState();
|
||||
enum ProcessConnectState {connectIdle,connectActive,connected};
|
||||
|
||||
PvaClient::weak_pointer pvaClient;
|
||||
PvaClientChannel::weak_pointer pvaClientChannel;
|
||||
epics::pvAccess::Channel::shared_pointer channel;
|
||||
epics::pvAccess::ChannelProcessRequester::shared_pointer processRequester;
|
||||
epics::pvData::PVStructurePtr pvRequest;
|
||||
epics::pvData::Mutex mutex;
|
||||
epics::pvData::Event waitForConnect;
|
||||
epics::pvData::Event waitForProcess;
|
||||
std::string messagePrefix;
|
||||
|
||||
bool isDestroyed;
|
||||
epics::pvData::Status channelProcessConnectStatus;
|
||||
@@ -925,14 +880,12 @@ public:
|
||||
POINTER_DEFINITIONS(PvaClientGet);
|
||||
/** Create a PvaClientGet.
|
||||
* @param &pvaClient Interface to PvaClient
|
||||
* @param pvaClientChannel Interface to PvaClientChannel
|
||||
* @param channel Interface to Channel
|
||||
* @param pvRequest The request structure.
|
||||
* @return The interface to the PvaClientStructure.
|
||||
* @return The interface to the PvaClientGet.
|
||||
*/
|
||||
static PvaClientGetPtr create(
|
||||
PvaClientPtr const &pvaClient,
|
||||
PvaClientChannelPtr const & pvaClientChannel,
|
||||
epics::pvAccess::Channel::shared_pointer const & channel,
|
||||
epics::pvData::PVStructurePtr const &pvRequest
|
||||
);
|
||||
@@ -975,7 +928,6 @@ public:
|
||||
private:
|
||||
PvaClientGet(
|
||||
PvaClientPtr const &pvaClient,
|
||||
PvaClientChannelPtr const & pvaClientChannel,
|
||||
epics::pvAccess::Channel::shared_pointer const & channel,
|
||||
epics::pvData::PVStructurePtr const &pvRequest);
|
||||
std::string getRequesterName();
|
||||
@@ -993,7 +945,6 @@ private:
|
||||
enum GetConnectState {connectIdle,connectActive,connected};
|
||||
|
||||
PvaClient::weak_pointer pvaClient;
|
||||
PvaClientChannel::weak_pointer pvaClientChannel;
|
||||
epics::pvAccess::Channel::shared_pointer channel;
|
||||
epics::pvAccess::ChannelGetRequester::shared_pointer getRequester;
|
||||
epics::pvData::PVStructurePtr pvRequest;
|
||||
@@ -1027,14 +978,12 @@ public:
|
||||
POINTER_DEFINITIONS(PvaClientPut);
|
||||
/** Create a PvaClientPut.
|
||||
* @param &pvaClient Interface to PvaClient
|
||||
* @param pvaClientChannel Interface to PvaClientChannel
|
||||
* @param channel Interface to Channel
|
||||
* @param pvRequest The request structure.
|
||||
* @return The interface to the PvaClientStructure.
|
||||
* @return The interface to the PvaClientPut.
|
||||
*/
|
||||
static PvaClientPutPtr create(
|
||||
PvaClientPtr const &pvaClient,
|
||||
PvaClientChannelPtr const & pvaClientChannel,
|
||||
epics::pvAccess::Channel::shared_pointer const & channel,
|
||||
epics::pvData::PVStructurePtr const &pvRequest
|
||||
);
|
||||
@@ -1087,7 +1036,6 @@ public:
|
||||
private :
|
||||
PvaClientPut(
|
||||
PvaClientPtr const &pvaClient,
|
||||
PvaClientChannelPtr const & pvaClientChannel,
|
||||
epics::pvAccess::Channel::shared_pointer const & channel,
|
||||
epics::pvData::PVStructurePtr const &pvRequest);
|
||||
std::string getRequesterName();
|
||||
@@ -1108,7 +1056,6 @@ private :
|
||||
enum PutConnectState {connectIdle,connectActive,connected};
|
||||
|
||||
PvaClient::weak_pointer pvaClient;
|
||||
PvaClientChannel::weak_pointer pvaClientChannel;
|
||||
epics::pvAccess::Channel::shared_pointer channel;
|
||||
epics::pvAccess::ChannelPutRequester::shared_pointer putRequester;
|
||||
epics::pvData::PVStructurePtr pvRequest;
|
||||
@@ -1116,13 +1063,11 @@ private :
|
||||
epics::pvData::Event waitForConnect;
|
||||
epics::pvData::Event waitForGetPut;
|
||||
PvaClientPutDataPtr pvaClientData;
|
||||
std::string messagePrefix;
|
||||
|
||||
bool isDestroyed;
|
||||
epics::pvData::Status channelPutConnectStatus;
|
||||
epics::pvData::Status channelGetPutStatus;
|
||||
epics::pvAccess::ChannelPut::shared_pointer channelPut;
|
||||
|
||||
PutConnectState connectState;
|
||||
|
||||
enum PutState {putIdle,getActive,putActive,putComplete};
|
||||
@@ -1141,14 +1086,12 @@ public:
|
||||
POINTER_DEFINITIONS(PvaClientPutGet);
|
||||
/** Create a PvaClientPutGet.
|
||||
* @param &pvaClient Interface to PvaClient
|
||||
* @param pvaClientChannel Interface to PvaClientChannel
|
||||
* @param channel Interface to Channel
|
||||
* @param pvRequest The request structure.
|
||||
* @return The interface to the PvaClientStructure.
|
||||
* @return The interface to the PvaClientPutGet.
|
||||
*/
|
||||
static PvaClientPutGetPtr create(
|
||||
PvaClientPtr const &pvaClient,
|
||||
PvaClientChannelPtr const & pvaClientChannel,
|
||||
epics::pvAccess::Channel::shared_pointer const & channel,
|
||||
epics::pvData::PVStructurePtr const &pvRequest
|
||||
);
|
||||
@@ -1217,7 +1160,6 @@ public:
|
||||
private :
|
||||
PvaClientPutGet(
|
||||
PvaClientPtr const &pvaClient,
|
||||
PvaClientChannelPtr const & pvaClientChannel,
|
||||
epics::pvAccess::Channel::shared_pointer const & channel,
|
||||
epics::pvData::PVStructurePtr const &pvRequest);
|
||||
std::string getRequesterName();
|
||||
@@ -1246,7 +1188,6 @@ private :
|
||||
enum PutGetConnectState {connectIdle,connectActive,connected};
|
||||
|
||||
PvaClient::weak_pointer pvaClient;
|
||||
PvaClientChannel::weak_pointer pvaClientChannel;
|
||||
epics::pvAccess::Channel::shared_pointer channel;
|
||||
epics::pvAccess::ChannelPutGetRequester::shared_pointer putGetRequester;
|
||||
epics::pvData::PVStructurePtr pvRequest;
|
||||
@@ -1255,15 +1196,12 @@ private :
|
||||
epics::pvData::Event waitForPutGet;
|
||||
PvaClientGetDataPtr pvaClientGetData;
|
||||
PvaClientPutDataPtr pvaClientPutData;
|
||||
std::string messagePrefix;
|
||||
|
||||
bool isDestroyed;
|
||||
epics::pvData::Status channelPutGetConnectStatus;
|
||||
epics::pvData::Status channelGetPutGetStatus;
|
||||
epics::pvAccess::ChannelPutGet::shared_pointer channelPutGet;
|
||||
|
||||
PutGetConnectState connectState;
|
||||
epics::pvData::Status channelPutGetStatus;
|
||||
epics::pvAccess::ChannelPutGet::shared_pointer channelPutGet;
|
||||
PutGetConnectState connectState;
|
||||
|
||||
enum PutGetState {putGetIdle,putGetActive,putGetComplete};
|
||||
PutGetState putGetState;
|
||||
@@ -1299,14 +1237,12 @@ public:
|
||||
POINTER_DEFINITIONS(PvaClientMonitor);
|
||||
/** Create a PvaClientMonitor.
|
||||
* @param &pvaClient Interface to PvaClient
|
||||
* @param pvaClientChannel Interface to PvaClientChannel
|
||||
* @param channel Interface to Channel
|
||||
* @param pvRequest The request structure.
|
||||
* @return The interface to the PvaClientStructure.
|
||||
* @return The interface to the PvaClientMonitor.
|
||||
*/
|
||||
static PvaClientMonitorPtr create(
|
||||
PvaClientPtr const &pvaClient,
|
||||
PvaClientChannelPtr const & pvaClientChannel,
|
||||
epics::pvAccess::Channel::shared_pointer const & channel,
|
||||
epics::pvData::PVStructurePtr const &pvRequest
|
||||
);
|
||||
@@ -1366,7 +1302,6 @@ public:
|
||||
private:
|
||||
PvaClientMonitor(
|
||||
PvaClientPtr const &pvaClient,
|
||||
PvaClientChannelPtr const & pvaClientChannel,
|
||||
epics::pvAccess::Channel::shared_pointer const & channel,
|
||||
epics::pvData::PVStructurePtr const &pvRequest);
|
||||
std::string getRequesterName();
|
||||
@@ -1381,7 +1316,6 @@ private:
|
||||
enum MonitorConnectState {connectIdle,connectActive,connected,monitorStarted};
|
||||
|
||||
PvaClient::weak_pointer pvaClient;
|
||||
PvaClientChannel::weak_pointer pvaClientChannel;
|
||||
epics::pvAccess::Channel::shared_pointer channel;
|
||||
epics::pvData::PVStructurePtr pvRequest;
|
||||
epics::pvData::MonitorRequester::shared_pointer monitorRequester;
|
||||
@@ -1389,7 +1323,6 @@ private:
|
||||
epics::pvData::Event waitForConnect;
|
||||
epics::pvData::Event waitForEvent;
|
||||
PvaClientMonitorDataPtr pvaClientData;
|
||||
std::string messagePrefix;
|
||||
|
||||
bool isDestroyed;
|
||||
epics::pvData::Status connectStatus;
|
||||
@@ -1403,89 +1336,6 @@ private:
|
||||
friend class ChannelMonitorRequester;
|
||||
};
|
||||
|
||||
/**
|
||||
* Provides access to multiple channels.
|
||||
*
|
||||
* @author mrk
|
||||
*/
|
||||
class epicsShareClass PvaClientMultiChannel :
|
||||
public std::tr1::enable_shared_from_this<PvaClientMultiChannel>
|
||||
{
|
||||
public:
|
||||
POINTER_DEFINITIONS(PvaClientMultiChannel);
|
||||
/** Create a PvaClientMultiChannel.
|
||||
* @param channelNames The name. of the channel..
|
||||
* @param providerName The name of the provider.
|
||||
* @return The interface to the PvaClientStructure.
|
||||
*/
|
||||
static PvaClientMultiChannelPtr create(
|
||||
PvaClientPtr const &pvaClient,
|
||||
epics::pvData::PVStringArrayPtr const & channelNames,
|
||||
std::string const & providerName = "pva");
|
||||
~PvaClientMultiChannel();
|
||||
/** Destroy the pvAccess connection.
|
||||
*/
|
||||
void destroy();
|
||||
/** Get the channelNames.
|
||||
* @return The names.
|
||||
*/
|
||||
epics::pvData::PVStringArrayPtr getChannelNames();
|
||||
/** Connect to the channels.
|
||||
* This calls issueConnect and waitConnect.
|
||||
* An exception is thrown if connect fails.
|
||||
* @param timeout The time to wait for connecting to the channel.
|
||||
* @param maxNotConnected Maximum number of channels that do not connect.
|
||||
* @return status of request
|
||||
*/
|
||||
epics::pvData::Status connect(
|
||||
double timeout=5,
|
||||
size_t maxNotConnected=0);
|
||||
/** Are all channels connected?
|
||||
* @return if all are connected.
|
||||
*/
|
||||
bool allConnected();
|
||||
/** Has a connection state change occured?
|
||||
* @return (true, false) if (at least one, no) channel has changed state.
|
||||
*/
|
||||
bool connectionChange();
|
||||
/** Get the connection state of each channel.
|
||||
* @return The state of each channel.
|
||||
*/
|
||||
epics::pvData::PVBooleanArrayPtr getIsConnected();
|
||||
/** Get the pvaClientChannelArray.
|
||||
* @return The weak shared pointer.
|
||||
*/
|
||||
PvaClientChannelArrayWPtr getPvaClientChannelArray();
|
||||
/** Get pvaClient.
|
||||
* @return The weak shared pointer.
|
||||
*/
|
||||
PvaClient::weak_pointer getPvaClient();
|
||||
/** Get the shared pointer to self.
|
||||
* @return The shared pointer.
|
||||
*/
|
||||
PvaClientMultiChannelPtr getPtrSelf()
|
||||
{
|
||||
return shared_from_this();
|
||||
}
|
||||
private:
|
||||
PvaClientMultiChannel(
|
||||
PvaClientPtr const &pvaClient,
|
||||
epics::pvData::PVStringArrayPtr const & channelName,
|
||||
std::string const & providerName);
|
||||
|
||||
PvaClient::weak_pointer pvaClient;
|
||||
epics::pvData::PVStringArrayPtr channelName;
|
||||
std::string providerName;
|
||||
size_t numChannel;
|
||||
epics::pvData::Mutex mutex;
|
||||
|
||||
size_t numConnected;
|
||||
PvaClientChannelArrayPtr pvaClientChannelArray;
|
||||
epics::pvData::PVBooleanArrayPtr isConnected;
|
||||
bool isDestroyed;
|
||||
};
|
||||
|
||||
|
||||
}}
|
||||
|
||||
#endif /* PVACLIENT_H */
|
||||
|
||||
@@ -182,6 +182,7 @@ void PvaClientChannel::channelStateChange(
|
||||
Channel::shared_pointer const & channel,
|
||||
Channel::ConnectionState connectionState)
|
||||
{
|
||||
Lock xx(mutex);
|
||||
if(isDestroyed) return;
|
||||
bool waitingForConnect = false;
|
||||
if(connectState==connectActive) waitingForConnect = true;
|
||||
@@ -193,6 +194,7 @@ void PvaClientChannel::channelStateChange(
|
||||
connectState = notConnected;
|
||||
} else {
|
||||
connectState = connected;
|
||||
channelConnectStatus = Status::Ok;
|
||||
}
|
||||
if(waitingForConnect) waitForConnect.signal();
|
||||
}
|
||||
@@ -211,7 +213,7 @@ void PvaClientChannel::message(
|
||||
if(isDestroyed) throw std::runtime_error("pvaClientChannel was destroyed");
|
||||
PvaClientPtr yyy = pvaClient.lock();
|
||||
if(!yyy) throw std::runtime_error("PvaClient was destroyed");
|
||||
yyy->message(message, messageType);
|
||||
yyy->message(channelName + " " + message, messageType);
|
||||
}
|
||||
|
||||
void PvaClientChannel::destroy()
|
||||
@@ -269,7 +271,7 @@ void PvaClientChannel::issueConnect()
|
||||
}
|
||||
channel = provider->createChannel(channelName,channelRequester,ChannelProvider::PRIORITY_DEFAULT);
|
||||
if(!channel) {
|
||||
throw std::runtime_error(channelConnectStatus.getMessage());
|
||||
throw std::runtime_error(getChannelName() + " channelCreate failed ");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -277,8 +279,7 @@ Status PvaClientChannel::waitConnect(double timeout)
|
||||
{
|
||||
if(isDestroyed) throw std::runtime_error("pvaClientChannel was destroyed");
|
||||
waitForConnect.wait(timeout);
|
||||
if(connectState==connected) return Status::Ok;
|
||||
return Status(Status::STATUSTYPE_ERROR,channelConnectStatus.getMessage());
|
||||
return channelConnectStatus;
|
||||
}
|
||||
|
||||
PvaClientFieldPtr PvaClientChannel::createField()
|
||||
@@ -288,6 +289,7 @@ PvaClientFieldPtr PvaClientChannel::createField()
|
||||
|
||||
PvaClientFieldPtr PvaClientChannel::createField(string const & subField)
|
||||
{
|
||||
if(connectState!=connected) connect(5.0);
|
||||
throw std::runtime_error("PvaClientChannel::createField not implemented");
|
||||
}
|
||||
|
||||
@@ -311,10 +313,9 @@ PvaClientProcessPtr PvaClientChannel::createProcess(string const & request)
|
||||
PvaClientProcessPtr PvaClientChannel::createProcess(PVStructurePtr const & pvRequest)
|
||||
{
|
||||
if(connectState!=connected) connect(5.0);
|
||||
if(connectState!=connected) throw std::runtime_error("PvaClientChannel::creatProcess not connected");
|
||||
PvaClientPtr yyy = pvaClient.lock();
|
||||
if(!yyy) throw std::runtime_error("PvaClient was destroyed");
|
||||
return PvaClientProcess::create(yyy,getPtrSelf(),channel,pvRequest);
|
||||
return PvaClientProcess::create(yyy,channel,pvRequest);
|
||||
}
|
||||
|
||||
PvaClientGetPtr PvaClientChannel::get() {return get("value,alarm,timeStamp");}
|
||||
@@ -349,10 +350,9 @@ PvaClientGetPtr PvaClientChannel::createGet(string const & request)
|
||||
PvaClientGetPtr PvaClientChannel::createGet(PVStructurePtr const & pvRequest)
|
||||
{
|
||||
if(connectState!=connected) connect(5.0);
|
||||
if(connectState!=connected) throw std::runtime_error("PvaClientChannel::creatGet not connected");
|
||||
PvaClientPtr yyy = pvaClient.lock();
|
||||
if(!yyy) throw std::runtime_error("PvaClient was destroyed");
|
||||
return PvaClientGet::create(yyy,getPtrSelf(),channel,pvRequest);
|
||||
return PvaClientGet::create(yyy,channel,pvRequest);
|
||||
}
|
||||
|
||||
PvaClientPutPtr PvaClientChannel::put() {return put("value");}
|
||||
@@ -388,10 +388,9 @@ PvaClientPutPtr PvaClientChannel::createPut(string const & request)
|
||||
PvaClientPutPtr PvaClientChannel::createPut(PVStructurePtr const & pvRequest)
|
||||
{
|
||||
if(connectState!=connected) connect(5.0);
|
||||
if(connectState!=connected) throw std::runtime_error("PvaClientChannel::creatPut not connected");
|
||||
PvaClientPtr yyy = pvaClient.lock();
|
||||
if(!yyy) throw std::runtime_error("PvaClient was destroyed");
|
||||
return PvaClientPut::create(yyy,getPtrSelf(),channel,pvRequest);
|
||||
return PvaClientPut::create(yyy,channel,pvRequest);
|
||||
}
|
||||
|
||||
PvaClientPutGetPtr PvaClientChannel::createPutGet()
|
||||
@@ -414,33 +413,11 @@ PvaClientPutGetPtr PvaClientChannel::createPutGet(string const & request)
|
||||
PvaClientPutGetPtr PvaClientChannel::createPutGet(PVStructurePtr const & pvRequest)
|
||||
{
|
||||
if(connectState!=connected) connect(5.0);
|
||||
if(connectState!=connected) throw std::runtime_error("PvaClientChannel::creatPutGet not connected");
|
||||
PvaClientPtr yyy = pvaClient.lock();
|
||||
if(!yyy) throw std::runtime_error("PvaClient was destroyed");
|
||||
return PvaClientPutGet::create(yyy,getPtrSelf(),channel,pvRequest);
|
||||
return PvaClientPutGet::create(yyy,channel,pvRequest);
|
||||
}
|
||||
|
||||
PvaClientRPCPtr PvaClientChannel::createRPC()
|
||||
{
|
||||
return createRPC("");
|
||||
}
|
||||
|
||||
PvaClientRPCPtr PvaClientChannel::createRPC(string const & request)
|
||||
{
|
||||
PVStructurePtr pvRequest = createRequest->createRequest(request);
|
||||
if(!pvRequest) {
|
||||
stringstream ss;
|
||||
ss << "channel " << getChannelName();
|
||||
ss << " PvaClientChannel::createRPC invalid pvRequest: " + createRequest->getMessage();
|
||||
throw std::runtime_error(ss.str());
|
||||
}
|
||||
return createRPC(pvRequest);
|
||||
}
|
||||
|
||||
PvaClientRPCPtr PvaClientChannel::createRPC(PVStructurePtr const & pvRequest)
|
||||
{
|
||||
throw std::runtime_error("PvaClientChannel::createRPC not implemented");
|
||||
}
|
||||
|
||||
PvaClientArrayPtr PvaClientChannel::createArray()
|
||||
{
|
||||
@@ -461,6 +438,7 @@ PvaClientArrayPtr PvaClientChannel::createArray(string const & request)
|
||||
|
||||
PvaClientArrayPtr PvaClientChannel::createArray(PVStructurePtr const & pvRequest)
|
||||
{
|
||||
if(connectState!=connected) connect(5.0);
|
||||
throw std::runtime_error("PvaClientChannel::createArray not implemented");
|
||||
}
|
||||
|
||||
@@ -476,7 +454,8 @@ PvaClientMonitorPtr PvaClientChannel::monitor(string const & request)
|
||||
}
|
||||
|
||||
PvaClientMonitorPtr PvaClientChannel::monitor(PvaClientMonitorRequesterPtr const & pvaClientMonitorRequester)
|
||||
{ return monitor("value,alarm,timeStamp",pvaClientMonitorRequester);
|
||||
{
|
||||
return monitor("value,alarm,timeStamp",pvaClientMonitorRequester);
|
||||
}
|
||||
|
||||
PvaClientMonitorPtr PvaClientChannel::monitor(string const & request,
|
||||
@@ -509,10 +488,9 @@ PvaClientMonitorPtr PvaClientChannel::createMonitor(string const & request)
|
||||
PvaClientMonitorPtr PvaClientChannel::createMonitor(PVStructurePtr const & pvRequest)
|
||||
{
|
||||
if(connectState!=connected) connect(5.0);
|
||||
if(connectState!=connected) throw std::runtime_error("PvaClientChannel::createMonitor not connected");
|
||||
PvaClientPtr yyy = pvaClient.lock();
|
||||
if(!yyy) throw std::runtime_error("PvaClient was destroyed");
|
||||
return PvaClientMonitor::create(yyy,getPtrSelf(),channel,pvRequest);
|
||||
return PvaClientMonitor::create(yyy,channel,pvRequest);
|
||||
}
|
||||
|
||||
void PvaClientChannel::showCache()
|
||||
|
||||
@@ -47,11 +47,9 @@ public:
|
||||
|
||||
PvaClientGet::PvaClientGet(
|
||||
PvaClientPtr const &pvaClient,
|
||||
PvaClientChannelPtr const & pvaClientChannel,
|
||||
Channel::shared_pointer const & channel,
|
||||
PVStructurePtr const &pvRequest)
|
||||
: pvaClient(pvaClient),
|
||||
pvaClientChannel(pvaClientChannel),
|
||||
channel(channel),
|
||||
pvRequest(pvRequest),
|
||||
isDestroyed(false),
|
||||
@@ -99,6 +97,7 @@ void PvaClientGet::channelGetConnect(
|
||||
if(status.isOK()) {
|
||||
pvaClientData = PvaClientGetData::create(structure);
|
||||
pvaClientData->setMessagePrefix(channel->getChannelName());
|
||||
connectState = connected;
|
||||
}
|
||||
waitForConnect.signal();
|
||||
|
||||
@@ -158,17 +157,14 @@ void PvaClientGet::issueConnect()
|
||||
Status PvaClientGet::waitConnect()
|
||||
{
|
||||
if(isDestroyed) throw std::runtime_error("pvaClientGet was destroyed");
|
||||
if(connectState==connected) return channelGetConnectStatus;
|
||||
if(connectState!=connectActive) {
|
||||
stringstream ss;
|
||||
ss << "channel " << channel->getChannelName() << " pvaClientGet illegal connect state ";
|
||||
throw std::runtime_error(ss.str());
|
||||
}
|
||||
waitForConnect.wait();
|
||||
if(channelGetConnectStatus.isOK()){
|
||||
connectState = connected;
|
||||
return Status::Ok;
|
||||
}
|
||||
connectState = connectIdle;
|
||||
connectState = channelGetConnectStatus.isOK() ? connected : connectIdle;
|
||||
return channelGetConnectStatus;
|
||||
}
|
||||
|
||||
@@ -219,11 +215,10 @@ PvaClientGetDataPtr PvaClientGet::getData()
|
||||
|
||||
PvaClientGetPtr PvaClientGet::create(
|
||||
PvaClientPtr const &pvaClient,
|
||||
PvaClientChannelPtr const & pvaClientChannel,
|
||||
Channel::shared_pointer const & channel,
|
||||
PVStructurePtr const &pvRequest)
|
||||
{
|
||||
PvaClientGetPtr epv(new PvaClientGet(pvaClient,pvaClientChannel,channel,pvRequest));
|
||||
PvaClientGetPtr epv(new PvaClientGet(pvaClient,channel,pvRequest));
|
||||
return epv;
|
||||
}
|
||||
|
||||
|
||||
@@ -47,7 +47,9 @@ PvaClientGetDataPtr PvaClientGetData::create(StructureConstPtr const & structure
|
||||
|
||||
PvaClientGetData::PvaClientGetData(StructureConstPtr const & structure)
|
||||
: structure(structure)
|
||||
{}
|
||||
{
|
||||
messagePrefix = "";
|
||||
}
|
||||
|
||||
void PvaClientGetData::checkValue()
|
||||
{
|
||||
@@ -69,7 +71,7 @@ PVStructurePtr PvaClientGetData::getPVStructure()
|
||||
throw std::runtime_error(messagePrefix + noStructure);
|
||||
}
|
||||
|
||||
BitSetPtr PvaClientGetData::getBitSet()
|
||||
BitSetPtr PvaClientGetData::getChangedBitSet()
|
||||
{
|
||||
if(bitSet)return bitSet;
|
||||
throw std::runtime_error(messagePrefix + noStructure);
|
||||
@@ -132,9 +134,7 @@ PVScalarPtr PvaClientGetData::getScalarValue()
|
||||
{
|
||||
checkValue();
|
||||
PVScalarPtr pv = pvStructure->getSubField<PVScalar>("value");
|
||||
if(!pv) {
|
||||
throw std::runtime_error(messagePrefix + noScalar);
|
||||
}
|
||||
if(!pv) throw std::runtime_error(messagePrefix + noScalar);
|
||||
return pv;
|
||||
}
|
||||
|
||||
@@ -142,9 +142,7 @@ PVArrayPtr PvaClientGetData::getArrayValue()
|
||||
{
|
||||
checkValue();
|
||||
PVArrayPtr pv = pvStructure->getSubField<PVArray>("value");
|
||||
if(!pv) {
|
||||
throw std::runtime_error(messagePrefix + noArray);
|
||||
}
|
||||
if(!pv) throw std::runtime_error(messagePrefix + noArray);
|
||||
return pv;
|
||||
}
|
||||
|
||||
@@ -152,9 +150,7 @@ PVScalarArrayPtr PvaClientGetData::getScalarArrayValue()
|
||||
{
|
||||
checkValue();
|
||||
PVScalarArrayPtr pv = pvStructure->getSubField<PVScalarArray>("value");
|
||||
if(!pv) {
|
||||
throw std::runtime_error(messagePrefix + noScalarArray);
|
||||
}
|
||||
if(!pv) throw std::runtime_error(messagePrefix + noScalarArray);
|
||||
return pv;
|
||||
}
|
||||
|
||||
@@ -182,9 +178,7 @@ shared_vector<const double> PvaClientGetData::getDoubleArray()
|
||||
{
|
||||
checkValue();
|
||||
PVDoubleArrayPtr pv = pvStructure->getSubField<PVDoubleArray>("value");
|
||||
if(!pv) {
|
||||
throw std::runtime_error(messagePrefix + notDoubleArray);
|
||||
}
|
||||
if(!pv) throw std::runtime_error(messagePrefix + notDoubleArray);
|
||||
return pv->view();
|
||||
}
|
||||
|
||||
@@ -192,18 +186,14 @@ shared_vector<const string> PvaClientGetData::getStringArray()
|
||||
{
|
||||
checkValue();
|
||||
PVStringArrayPtr pv = pvStructure->getSubField<PVStringArray>("value");
|
||||
if(!pv) {
|
||||
throw std::runtime_error(messagePrefix + notStringArray);
|
||||
}
|
||||
if(!pv) throw std::runtime_error(messagePrefix + notStringArray);
|
||||
return pv->view();
|
||||
}
|
||||
|
||||
|
||||
Alarm PvaClientGetData::getAlarm()
|
||||
{
|
||||
if(!pvStructure) {
|
||||
throw std::runtime_error(messagePrefix + noAlarm);
|
||||
}
|
||||
if(!pvStructure) throw new std::runtime_error(messagePrefix + noStructure);
|
||||
PVStructurePtr pvs = pvStructure->getSubField<PVStructure>("alarm");
|
||||
if(!pvs) throw std::runtime_error(messagePrefix + noAlarm);
|
||||
pvAlarm.attach(pvs);
|
||||
@@ -218,9 +208,7 @@ Alarm PvaClientGetData::getAlarm()
|
||||
|
||||
TimeStamp PvaClientGetData::getTimeStamp()
|
||||
{
|
||||
if(!pvStructure) {
|
||||
throw std::runtime_error(messagePrefix + noTimeStamp);
|
||||
}
|
||||
if(!pvStructure) throw new std::runtime_error(messagePrefix + noStructure);
|
||||
PVStructurePtr pvs = pvStructure->getSubField<PVStructure>("timeStamp");
|
||||
if(!pvs) throw std::runtime_error(messagePrefix + noTimeStamp);
|
||||
pvTimeStamp.attach(pvs);
|
||||
|
||||
@@ -48,11 +48,9 @@ public:
|
||||
|
||||
PvaClientMonitor::PvaClientMonitor(
|
||||
PvaClientPtr const &pvaClient,
|
||||
PvaClientChannelPtr const & pvaClientChannel,
|
||||
Channel::shared_pointer const & channel,
|
||||
PVStructurePtr const &pvRequest)
|
||||
: pvaClient(pvaClient),
|
||||
pvaClientChannel(pvaClientChannel),
|
||||
channel(channel),
|
||||
pvRequest(pvRequest),
|
||||
isDestroyed(false),
|
||||
@@ -108,6 +106,7 @@ void PvaClientMonitor::monitorConnect(
|
||||
|
||||
void PvaClientMonitor::monitorEvent(MonitorPtr const & monitor)
|
||||
{
|
||||
if(isDestroyed) throw std::runtime_error("pvaClientMonitor was destroyed");
|
||||
PvaClientMonitorRequesterPtr req = pvaClientMonitorRequester.lock();
|
||||
if(req) req->event(getPtrSelf());
|
||||
if(userWait) waitForEvent.signal();
|
||||
@@ -118,7 +117,6 @@ void PvaClientMonitor::unlisten()
|
||||
destroy();
|
||||
}
|
||||
|
||||
// from PvaClientMonitor
|
||||
void PvaClientMonitor::destroy()
|
||||
{
|
||||
{
|
||||
@@ -128,6 +126,7 @@ void PvaClientMonitor::destroy()
|
||||
}
|
||||
if(monitor) monitor->destroy();
|
||||
monitor.reset();
|
||||
monitorElement.reset();
|
||||
}
|
||||
|
||||
void PvaClientMonitor::connect()
|
||||
@@ -163,12 +162,8 @@ Status PvaClientMonitor::waitConnect()
|
||||
throw std::runtime_error(ss.str());
|
||||
}
|
||||
waitForConnect.wait();
|
||||
if(connectStatus.isOK()){
|
||||
connectState = connected;
|
||||
return Status::Ok;
|
||||
}
|
||||
connectState = connectIdle;
|
||||
return Status(Status::STATUSTYPE_ERROR,connectStatus.getMessage());
|
||||
connectState = connectStatus.isOK() ? connected : connectIdle;
|
||||
return connectStatus;
|
||||
}
|
||||
|
||||
void PvaClientMonitor::setRequester(PvaClientMonitorRequesterPtr const & pvaClientMonitorrRequester)
|
||||
@@ -210,7 +205,7 @@ bool PvaClientMonitor::poll()
|
||||
bool PvaClientMonitor::waitEvent(double secondsToWait)
|
||||
{
|
||||
if(isDestroyed) throw std::runtime_error("pvaClientMonitor was destroyed");
|
||||
if(connectState!=monitorStarted) throw std::runtime_error("PvaClientMonitor::poll illegal state");
|
||||
if(connectState!=monitorStarted) throw std::runtime_error("PvaClientMonitor::waitEvent illegal state");
|
||||
if(poll()) return true;
|
||||
userWait = true;
|
||||
if(secondsToWait==0.0) {
|
||||
@@ -239,11 +234,10 @@ PvaClientMonitorDataPtr PvaClientMonitor::getData()
|
||||
|
||||
PvaClientMonitorPtr PvaClientMonitor::create(
|
||||
PvaClientPtr const &pvaClient,
|
||||
PvaClientChannelPtr const & pvaClientChannel,
|
||||
Channel::shared_pointer const & channel,
|
||||
PVStructurePtr const &pvRequest)
|
||||
{
|
||||
PvaClientMonitorPtr epv(new PvaClientMonitor(pvaClient,pvaClientChannel,channel,pvRequest));
|
||||
PvaClientMonitorPtr epv(new PvaClientMonitor(pvaClient,channel,pvRequest));
|
||||
return epv;
|
||||
}
|
||||
|
||||
|
||||
@@ -27,9 +27,12 @@ namespace epics { namespace pvaClient {
|
||||
|
||||
|
||||
typedef std::tr1::shared_ptr<PVArray> PVArrayPtr;
|
||||
|
||||
static ConvertPtr convert = getConvert();
|
||||
|
||||
static StructureConstPtr nullStructure;
|
||||
static PVStructurePtr nullPVStructure;
|
||||
static ConvertPtr convert = getConvert();
|
||||
|
||||
static string noStructure("no pvStructure ");
|
||||
static string noValue("no value field");
|
||||
static string noScalar("value is not a scalar");
|
||||
@@ -41,6 +44,7 @@ static string notStringArray("value is not a stringArray");
|
||||
static string noAlarm("no alarm");
|
||||
static string noTimeStamp("no timeStamp");
|
||||
|
||||
|
||||
PvaClientMonitorDataPtr PvaClientMonitorData::create(StructureConstPtr const & structure)
|
||||
{
|
||||
PvaClientMonitorDataPtr epv(new PvaClientMonitorData(structure));
|
||||
@@ -49,8 +53,17 @@ PvaClientMonitorDataPtr PvaClientMonitorData::create(StructureConstPtr const & s
|
||||
|
||||
PvaClientMonitorData::PvaClientMonitorData(StructureConstPtr const & structure)
|
||||
: structure(structure)
|
||||
{}
|
||||
{
|
||||
messagePrefix = "";
|
||||
}
|
||||
|
||||
void PvaClientMonitorData::setData(MonitorElementPtr const & monitorElement)
|
||||
{
|
||||
pvStructure = monitorElement->pvStructurePtr;
|
||||
changedBitSet = monitorElement->changedBitSet;
|
||||
overrunBitSet = monitorElement->overrunBitSet;
|
||||
pvValue = pvStructure->getSubField("value");
|
||||
}
|
||||
|
||||
void PvaClientMonitorData::checkValue()
|
||||
{
|
||||
@@ -120,14 +133,6 @@ std::ostream & PvaClientMonitorData::showOverrun(std::ostream & out)
|
||||
return out;
|
||||
}
|
||||
|
||||
void PvaClientMonitorData::setData(MonitorElementPtr const & monitorElement)
|
||||
{
|
||||
pvStructure = monitorElement->pvStructurePtr;
|
||||
changedBitSet = monitorElement->changedBitSet;
|
||||
overrunBitSet = monitorElement->overrunBitSet;
|
||||
pvValue = pvStructure->getSubField("value");
|
||||
}
|
||||
|
||||
bool PvaClientMonitorData::hasValue()
|
||||
{
|
||||
if(!pvValue) return false;
|
||||
|
||||
@@ -1,165 +0,0 @@
|
||||
/* pvaClientMultiChannel.cpp */
|
||||
/**
|
||||
* Copyright - See the COPYRIGHT that is included with this distribution.
|
||||
* EPICS pvData is distributed subject to a Software License Agreement found
|
||||
* in file LICENSE that is included with this distribution.
|
||||
*/
|
||||
/**
|
||||
* @author mrk
|
||||
* @date 2015.02
|
||||
*/
|
||||
#define epicsExportSharedSymbols
|
||||
|
||||
#include <map>
|
||||
#include <sstream>
|
||||
#include <pv/event.h>
|
||||
#include <pv/lock.h>
|
||||
#include <pv/pvaClient.h>
|
||||
#include <pv/createRequest.h>
|
||||
|
||||
|
||||
using std::tr1::static_pointer_cast;
|
||||
using namespace epics::pvData;
|
||||
using namespace epics::pvAccess;
|
||||
using namespace std;
|
||||
|
||||
namespace epics { namespace pvaClient {
|
||||
|
||||
|
||||
|
||||
PvaClientMultiChannel::PvaClientMultiChannel(
|
||||
PvaClientPtr const &pvaClient,
|
||||
PVStringArrayPtr const & channelName,
|
||||
string const & providerName)
|
||||
: pvaClient(pvaClient),
|
||||
channelName(channelName),
|
||||
providerName(providerName),
|
||||
numChannel(channelName->getLength()),
|
||||
isConnected(getPVDataCreate()->createPVScalarArray<PVBooleanArray>()),
|
||||
isDestroyed(false)
|
||||
{
|
||||
}
|
||||
|
||||
PvaClientMultiChannel::~PvaClientMultiChannel()
|
||||
{
|
||||
destroy();
|
||||
}
|
||||
|
||||
void PvaClientMultiChannel::destroy()
|
||||
{
|
||||
{
|
||||
Lock xx(mutex);
|
||||
if(isDestroyed) return;
|
||||
isDestroyed = true;
|
||||
}
|
||||
pvaClientChannelArray.reset();
|
||||
}
|
||||
|
||||
PVStringArrayPtr PvaClientMultiChannel::getChannelNames()
|
||||
{
|
||||
if(isDestroyed) throw std::runtime_error("pvaClientMultiChannel was destroyed");
|
||||
return channelName;
|
||||
}
|
||||
|
||||
Status PvaClientMultiChannel::connect(double timeout,size_t maxNotConnected)
|
||||
{
|
||||
if(isDestroyed) throw std::runtime_error("pvaClientMultiChannel was destroyed");
|
||||
if(pvaClientChannelArray) throw std::runtime_error("pvaClientMultiChannel already connected");
|
||||
PvaClientPtr pvaClient = this->pvaClient.lock();
|
||||
if(!pvaClient) return Status(Status::STATUSTYPE_ERROR,"pvaClient is gone");
|
||||
shared_vector<PvaClientChannelPtr> pvaClientChannel(numChannel,PvaClientChannelPtr());
|
||||
PVStringArray::const_svector channelNames = channelName->view();
|
||||
shared_vector<boolean> isConnected(numChannel,false);
|
||||
for(size_t i=0; i< numChannel; ++i) {
|
||||
pvaClientChannel[i] = pvaClient->createChannel(channelNames[i],providerName);
|
||||
pvaClientChannel[i]->issueConnect();
|
||||
}
|
||||
Status returnStatus = Status::Ok;
|
||||
Status status = Status::Ok;
|
||||
size_t numBad = 0;
|
||||
for(size_t i=0; i< numChannel; ++i) {
|
||||
if(numBad==0) {
|
||||
status = pvaClientChannel[i]->waitConnect(timeout);
|
||||
} else {
|
||||
status = pvaClientChannel[i]->waitConnect(.001);
|
||||
}
|
||||
if(status.isOK()) {
|
||||
++numConnected;
|
||||
isConnected[i] = true;
|
||||
continue;
|
||||
}
|
||||
if(returnStatus.isOK()) returnStatus = status;
|
||||
++numBad;
|
||||
if(numBad>maxNotConnected) break;
|
||||
}
|
||||
pvaClientChannelArray = PvaClientChannelArrayPtr(new PvaClientChannelArray(freeze(pvaClientChannel)));
|
||||
this->isConnected->replace(freeze(isConnected));
|
||||
return numBad>maxNotConnected ? returnStatus : Status::Ok;
|
||||
}
|
||||
|
||||
|
||||
bool PvaClientMultiChannel::allConnected()
|
||||
{
|
||||
if(isDestroyed) throw std::runtime_error("pvaClientMultiChannel was destroyed");
|
||||
if(!pvaClientChannelArray) throw std::runtime_error("pvaClientMultiChannel not connected");
|
||||
if(numConnected==numChannel) return true;
|
||||
return (numConnected==numChannel) ? true : false;
|
||||
}
|
||||
|
||||
bool PvaClientMultiChannel::connectionChange()
|
||||
{
|
||||
if(isDestroyed) throw std::runtime_error("pvaClientMultiChannel was destroyed");
|
||||
if(!pvaClientChannelArray) throw std::runtime_error("pvaClientMultiChannel not connected");
|
||||
if(numConnected==numChannel) return true;
|
||||
PVBooleanArray::const_svector isConnected = this->isConnected->view();
|
||||
shared_vector<const PvaClientChannelPtr> channels = *pvaClientChannelArray.get();
|
||||
for(size_t i=0; i<numChannel; ++i) {
|
||||
const PvaClientChannelPtr pvaClientChannel = channels[i];
|
||||
Channel::shared_pointer channel = pvaClientChannel->getChannel();
|
||||
Channel::ConnectionState stateNow = channel->getConnectionState();
|
||||
bool connectedNow = stateNow==Channel::CONNECTED ? true : false;
|
||||
if(connectedNow!=isConnected[i]) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
PVBooleanArrayPtr PvaClientMultiChannel::getIsConnected()
|
||||
{
|
||||
if(isDestroyed) throw std::runtime_error("pvaClientMultiChannel was destroyed");
|
||||
if(!pvaClientChannelArray) throw std::runtime_error("pvaClientMultiChannel not connected");
|
||||
if(!connectionChange()) return isConnected;
|
||||
shared_vector<boolean> isConnected(numChannel,false);
|
||||
shared_vector<const PvaClientChannelPtr> channels = *pvaClientChannelArray.get();
|
||||
for(size_t i=0; i<numChannel; ++i) {
|
||||
const PvaClientChannelPtr pvaClientChannel = channels[i];
|
||||
Channel::shared_pointer channel = pvaClientChannel->getChannel();
|
||||
Channel::ConnectionState stateNow = channel->getConnectionState();
|
||||
if(stateNow==Channel::CONNECTED) isConnected[i] = true;
|
||||
}
|
||||
this->isConnected->replace(freeze(isConnected));
|
||||
return this->isConnected;
|
||||
}
|
||||
|
||||
PvaClientChannelArrayWPtr PvaClientMultiChannel::getPvaClientChannelArray()
|
||||
{
|
||||
if(isDestroyed) throw std::runtime_error("pvaClientMultiChannel was destroyed");
|
||||
if(!pvaClientChannelArray) throw std::runtime_error("pvaClientMultiChannel not connected");
|
||||
return pvaClientChannelArray;
|
||||
}
|
||||
|
||||
PvaClient::weak_pointer PvaClientMultiChannel::getPvaClient()
|
||||
{
|
||||
if(isDestroyed) throw std::runtime_error("pvaClientMultiChannel was destroyed");
|
||||
return pvaClient;
|
||||
}
|
||||
|
||||
PvaClientMultiChannelPtr PvaClientMultiChannel::create(
|
||||
PvaClientPtr const &pvaClient,
|
||||
PVStringArrayPtr const & channelNames,
|
||||
string const & providerName)
|
||||
{
|
||||
PvaClientMultiChannelPtr channel(new PvaClientMultiChannel(pvaClient,channelNames,providerName));
|
||||
return channel;
|
||||
}
|
||||
|
||||
}}
|
||||
@@ -1,139 +0,0 @@
|
||||
/* pvaClientMultiDouble.cpp */
|
||||
/**
|
||||
* Copyright - See the COPYRIGHT that is included with this distribution.
|
||||
* EPICS pvData is distributed subject to a Software License Agreement found
|
||||
* in file LICENSE that is included with this distribution.
|
||||
*/
|
||||
/**
|
||||
* @author mrk
|
||||
* @date 2015.03
|
||||
*/
|
||||
|
||||
#define epicsExportSharedSymbols
|
||||
#include <pv/pvaClientMultiDouble.h>
|
||||
|
||||
using std::tr1::static_pointer_cast;
|
||||
using namespace epics::pvData;
|
||||
using namespace epics::pvAccess;
|
||||
using namespace std;
|
||||
|
||||
namespace epics { namespace pvaClient {
|
||||
|
||||
PvaClientMultiDoublePtr PvaClientMultiDouble::create(
|
||||
PvaClientPtr const & pvaClient,
|
||||
PVStringArrayPtr const & channelName,
|
||||
double timeout,
|
||||
std::string const & providerName)
|
||||
{
|
||||
PvaClientMultiChannelPtr pvaClientMultiChannel(
|
||||
PvaClientMultiChannel::create(pvaClient,channelName,providerName));
|
||||
Status status = pvaClientMultiChannel->connect(timeout,0);
|
||||
if(!status.isOK()) throw std::runtime_error(status.getMessage());
|
||||
return PvaClientMultiDoublePtr(new PvaClientMultiDouble(pvaClientMultiChannel));
|
||||
}
|
||||
|
||||
PvaClientMultiDouble::PvaClientMultiDouble(PvaClientMultiChannelPtr const &pvaClientMultiChannel)
|
||||
:
|
||||
pvaClientMultiChannel(pvaClientMultiChannel)
|
||||
{}
|
||||
|
||||
PvaClientMultiDouble::~PvaClientMultiDouble()
|
||||
{
|
||||
}
|
||||
|
||||
void PvaClientMultiDouble::createGet()
|
||||
{
|
||||
PvaClientChannelArrayPtr pvaClientChannelArray = pvaClientMultiChannel->getPvaClientChannelArray().lock();
|
||||
if(!pvaClientChannelArray) throw std::runtime_error("pvaClientChannelArray is gone");
|
||||
shared_vector<const PvaClientChannelPtr> pvaClientChannels = *pvaClientChannelArray;
|
||||
size_t numChannel = pvaClientChannels.size();
|
||||
pvaClientGet = std::vector<PvaClientGetPtr>(numChannel,PvaClientGetPtr());
|
||||
bool allOK = true;
|
||||
string message;
|
||||
for(size_t i=0; i<numChannel; ++i)
|
||||
{
|
||||
pvaClientGet[i] = pvaClientChannels[i]->createGet("value");
|
||||
pvaClientGet[i]->issueConnect();
|
||||
}
|
||||
for(size_t i=0; i<numChannel; ++i)
|
||||
{
|
||||
Status status = pvaClientGet[i]->waitConnect();
|
||||
if(!status.isOK()) {
|
||||
message = "connect status " + status.getMessage();
|
||||
allOK = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!allOK) throw std::runtime_error(message);
|
||||
}
|
||||
|
||||
void PvaClientMultiDouble::createPut()
|
||||
{
|
||||
PvaClientChannelArrayPtr pvaClientChannelArray = pvaClientMultiChannel->getPvaClientChannelArray().lock();
|
||||
if(!pvaClientChannelArray) throw std::runtime_error("pvaClientChannelArray is gone");
|
||||
shared_vector<const PvaClientChannelPtr> pvaClientChannels = *pvaClientChannelArray;
|
||||
size_t numChannel = pvaClientChannels.size();
|
||||
pvaClientPut = std::vector<PvaClientPutPtr>(numChannel,PvaClientPutPtr());
|
||||
bool allOK = true;
|
||||
string message;
|
||||
for(size_t i=0; i<numChannel; ++i)
|
||||
{
|
||||
pvaClientPut[i] = pvaClientChannels[i]->createPut("value");
|
||||
pvaClientPut[i]->issueConnect();
|
||||
}
|
||||
for(size_t i=0; i<numChannel; ++i)
|
||||
{
|
||||
Status status = pvaClientPut[i]->waitConnect();
|
||||
if(!status.isOK()) {
|
||||
message = "connect status " + status.getMessage();
|
||||
allOK = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!allOK) throw std::runtime_error(message);
|
||||
}
|
||||
|
||||
epics::pvData::shared_vector<double> PvaClientMultiDouble::get()
|
||||
{
|
||||
if(pvaClientGet.empty()) createGet();
|
||||
shared_vector<const string> channelNames = pvaClientMultiChannel->getChannelNames()->view();
|
||||
size_t numChannel = channelNames.size();
|
||||
epics::pvData::shared_vector<double> data(channelNames.size());
|
||||
for(size_t i=0; i<numChannel; ++i)
|
||||
{
|
||||
pvaClientGet[i]->issueGet();
|
||||
}
|
||||
for(size_t i=0; i<numChannel; ++i)
|
||||
{
|
||||
Status status = pvaClientGet[i]->waitGet();
|
||||
if(!status.isOK()) {
|
||||
string message = channelNames[i] + " " + status.getMessage();
|
||||
throw std::runtime_error(message);
|
||||
}
|
||||
data[i] = pvaClientGet[i]->getData()->getDouble();
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
void PvaClientMultiDouble::put(shared_vector<double> const &value)
|
||||
{
|
||||
if(pvaClientPut.empty()) createPut();
|
||||
shared_vector<const string> channelNames = pvaClientMultiChannel->getChannelNames()->view();
|
||||
size_t numChannel = channelNames.size();
|
||||
for(size_t i=0; i<numChannel; ++i)
|
||||
{
|
||||
pvaClientPut[i]->getData()->putDouble(value[i]);
|
||||
pvaClientPut[i]->issuePut();
|
||||
}
|
||||
for(size_t i=0; i<numChannel; ++i)
|
||||
{
|
||||
Status status = pvaClientPut[i]->waitPut();
|
||||
if(!status.isOK()) {
|
||||
string message = channelNames[i] + " " + status.getMessage();
|
||||
throw std::runtime_error(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}}
|
||||
@@ -1,75 +0,0 @@
|
||||
/* pvaClientMultiDouble.h */
|
||||
/**
|
||||
* Copyright - See the COPYRIGHT that is included with this distribution.
|
||||
* EPICS pvData is distributed subject to a Software License Agreement found
|
||||
* in file LICENSE that is included with this distribution.
|
||||
*/
|
||||
/**
|
||||
* @author mrk
|
||||
* @date 2015.02
|
||||
*/
|
||||
#ifndef PVACLIENTMULTIDOUBLE_H
|
||||
#define PVACLIENTMULTIDOUBLE_H
|
||||
|
||||
#ifdef epicsExportSharedSymbols
|
||||
# define pvaClientEpicsExportSharedSymbols
|
||||
# undef epicsExportSharedSymbols
|
||||
#endif
|
||||
|
||||
#include <pv/pvaClient.h>
|
||||
|
||||
namespace epics { namespace pvaClient {
|
||||
|
||||
class PvaClientMultiDouble;
|
||||
typedef std::tr1::shared_ptr<PvaClientMultiDouble> PvaClientMultiDoublePtr;
|
||||
|
||||
/** Support for multiple channels where each channel has a value field that is a scalar double.
|
||||
* If any problems arise an exception is thrown.
|
||||
*
|
||||
* @author mrk
|
||||
*/
|
||||
class epicsShareClass PvaClientMultiDouble
|
||||
{
|
||||
public:
|
||||
POINTER_DEFINITIONS(PvaClientMultiDouble);
|
||||
/** Create a PvaClientMultiDouble.
|
||||
* @param &pvaClient Interface to PvaClient
|
||||
* @param channelName PVStringArray of channelNames.
|
||||
* @param timeout The timeout in seconds for connecting.
|
||||
* @param providerName The name of the channelProvider for each channel.
|
||||
* @return The interface to PvaClientMultiDouble.
|
||||
*/
|
||||
static PvaClientMultiDoublePtr create(
|
||||
PvaClientPtr const & pvaClient,
|
||||
epics::pvData::PVStringArrayPtr const & channelName,
|
||||
double timeout = 5.0,
|
||||
std::string const & providerName = "pva");
|
||||
/** Destructor
|
||||
*/
|
||||
~PvaClientMultiDouble();
|
||||
/** Destroy all resources used.
|
||||
*/
|
||||
void destroy();
|
||||
/** Get the value of all the channels.
|
||||
* @return The data.
|
||||
*/
|
||||
epics::pvData::shared_vector<double> get();
|
||||
/** Put a new value to each channel.
|
||||
* @param value The data.
|
||||
*/
|
||||
void put(epics::pvData::shared_vector<double> const &value);
|
||||
PvaClientMultiChannelPtr getPvaClientMultiChannel();
|
||||
private:
|
||||
PvaClientMultiDouble(
|
||||
PvaClientMultiChannelPtr const & channelName);
|
||||
void createGet();
|
||||
void createPut();
|
||||
|
||||
PvaClientMultiChannelPtr pvaClientMultiChannel;
|
||||
std::vector<PvaClientGetPtr> pvaClientGet;
|
||||
std::vector<PvaClientPutPtr> pvaClientPut;
|
||||
};
|
||||
|
||||
}}
|
||||
|
||||
#endif // PVACLIENTMULTIDOUBLE_H
|
||||
@@ -1,268 +0,0 @@
|
||||
/* pvaClientNTMultiChannel.cpp */
|
||||
/**
|
||||
* Copyright - See the COPYRIGHT that is included with this distribution.
|
||||
* EPICS pvData is distributed subject to a Software License Agreement found
|
||||
* in file LICENSE that is included with this distribution.
|
||||
*/
|
||||
/**
|
||||
* @author mrk
|
||||
* @date 2015.03
|
||||
*/
|
||||
|
||||
#define epicsExportSharedSymbols
|
||||
#include <pv/pvaClientNTMultiChannel.h>
|
||||
|
||||
using std::tr1::static_pointer_cast;
|
||||
using namespace epics::pvData;
|
||||
using namespace epics::pvAccess;
|
||||
using namespace epics::nt;
|
||||
using namespace std;
|
||||
|
||||
namespace epics { namespace pvaClient {
|
||||
|
||||
PvaClientNTMultiChannelPtr PvaClientNTMultiChannel::create(
|
||||
PvaClientPtr const & pvaClient,
|
||||
PVStringArrayPtr const & channelName,
|
||||
StructureConstPtr const &structure,
|
||||
double timeout,
|
||||
std::string const & providerName)
|
||||
{
|
||||
PvaClientMultiChannelPtr pvaClientMultiChannel(
|
||||
PvaClientMultiChannel::create(pvaClient,channelName,providerName));
|
||||
Status status = pvaClientMultiChannel->connect(timeout,0);
|
||||
if(!status.isOK()) throw std::runtime_error(status.getMessage());
|
||||
if(!NTMultiChannel::is_a(structure)) throw std::runtime_error("structure is not valid");
|
||||
PVStructurePtr pvStructure = getPVDataCreate()->createPVStructure(structure);
|
||||
pvStructure->getSubField<PVStringArray>("channelName")->
|
||||
replace(pvaClientMultiChannel->getChannelNames()->view());
|
||||
pvStructure->getSubField<PVBooleanArray>("isConnected")->
|
||||
replace(pvaClientMultiChannel->getIsConnected()->view());
|
||||
NTMultiChannelPtr ntMultiChannel(NTMultiChannel::wrap(pvStructure));
|
||||
return PvaClientNTMultiChannelPtr(new PvaClientNTMultiChannel(pvaClientMultiChannel,ntMultiChannel));
|
||||
}
|
||||
|
||||
PvaClientNTMultiChannel::PvaClientNTMultiChannel(
|
||||
PvaClientMultiChannelPtr const &pvaClientMultiChannel,
|
||||
NTMultiChannelPtr const &ntMultiChannel)
|
||||
:
|
||||
pvaClientMultiChannel(pvaClientMultiChannel),
|
||||
ntMultiChannel(ntMultiChannel),
|
||||
pvUnionArray(ntMultiChannel->getPVStructure()->getSubField<PVUnionArray>("value")),
|
||||
pvDataCreate(getPVDataCreate())
|
||||
{}
|
||||
|
||||
PvaClientNTMultiChannel::~PvaClientNTMultiChannel()
|
||||
{
|
||||
}
|
||||
|
||||
void PvaClientNTMultiChannel::createGet()
|
||||
{
|
||||
PVStructurePtr pvStructure = ntMultiChannel->getPVStructure();
|
||||
bool getAlarm = false;
|
||||
if(pvStructure->getSubField("severity")) getAlarm = true;
|
||||
if(pvStructure->getSubField("status")) getAlarm = true;
|
||||
if(pvStructure->getSubField("severity")) getAlarm = true;
|
||||
bool getTimeStamp = false;
|
||||
if(pvStructure->getSubField("secondsPastEpoch")) getTimeStamp = true;
|
||||
if(pvStructure->getSubField("nanoseconds")) getTimeStamp = true;
|
||||
if(pvStructure->getSubField("userTag")) getTimeStamp = true;
|
||||
string request = "value";
|
||||
if(getAlarm) request += ",alarm";
|
||||
if(getTimeStamp) request += ",timeStamp";
|
||||
PvaClientChannelArrayPtr pvaClientChannelArray = pvaClientMultiChannel->getPvaClientChannelArray().lock();
|
||||
if(!pvaClientChannelArray) throw std::runtime_error("pvaClientChannelArray is gone");
|
||||
shared_vector<const PvaClientChannelPtr> pvaClientChannels = *pvaClientChannelArray;
|
||||
size_t numChannel = pvaClientChannels.size();
|
||||
pvaClientGet = std::vector<PvaClientGetPtr>(numChannel,PvaClientGetPtr());
|
||||
bool allOK = true;
|
||||
string message;
|
||||
for(size_t i=0; i<numChannel; ++i)
|
||||
{
|
||||
pvaClientGet[i] = pvaClientChannels[i]->createGet(request);
|
||||
pvaClientGet[i]->issueConnect();
|
||||
}
|
||||
for(size_t i=0; i<numChannel; ++i)
|
||||
{
|
||||
Status status = pvaClientGet[i]->waitConnect();
|
||||
if(!status.isOK()) {
|
||||
message = "connect status " + status.getMessage();
|
||||
allOK = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!allOK) throw std::runtime_error(message);
|
||||
|
||||
}
|
||||
|
||||
void PvaClientNTMultiChannel::createPut()
|
||||
{
|
||||
PvaClientChannelArrayPtr pvaClientChannelArray = pvaClientMultiChannel->getPvaClientChannelArray().lock();
|
||||
if(!pvaClientChannelArray) throw std::runtime_error("pvaClientChannelArray is gone");
|
||||
shared_vector<const PvaClientChannelPtr> pvaClientChannels = *pvaClientChannelArray;
|
||||
size_t numChannel = pvaClientChannels.size();
|
||||
pvaClientPut = std::vector<PvaClientPutPtr>(numChannel,PvaClientPutPtr());
|
||||
bool allOK = true;
|
||||
string message;
|
||||
for(size_t i=0; i<numChannel; ++i)
|
||||
{
|
||||
pvaClientPut[i] = pvaClientChannels[i]->createPut("value");
|
||||
pvaClientPut[i]->issueConnect();
|
||||
}
|
||||
for(size_t i=0; i<numChannel; ++i)
|
||||
{
|
||||
Status status = pvaClientPut[i]->waitConnect();
|
||||
if(!status.isOK()) {
|
||||
message = "connect status " + status.getMessage();
|
||||
allOK = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!allOK) throw std::runtime_error(message);
|
||||
}
|
||||
|
||||
NTMultiChannelPtr PvaClientNTMultiChannel::get()
|
||||
{
|
||||
if(pvaClientGet.empty()) createGet();
|
||||
PVStructurePtr pvStructure = ntMultiChannel->getPVStructure();
|
||||
shared_vector<const string> channelNames = pvaClientMultiChannel->getChannelNames()->view();
|
||||
size_t numChannel = channelNames.size();
|
||||
bool severityExists = false;
|
||||
bool statusExists = false;
|
||||
bool messageExists = false;
|
||||
bool secondsPastEpochExists = false;
|
||||
bool nanosecondsExists = false;
|
||||
bool userTagExists = false;
|
||||
if(pvStructure->getSubField("severity")) {
|
||||
severity.resize(numChannel);
|
||||
severityExists = true;
|
||||
}
|
||||
if(pvStructure->getSubField("status")) {
|
||||
status.resize(numChannel);
|
||||
statusExists = true;
|
||||
}
|
||||
if(pvStructure->getSubField("message")) {
|
||||
message.resize(numChannel);
|
||||
messageExists = true;
|
||||
}
|
||||
if(pvStructure->getSubField("secondsPastEpoch")) {
|
||||
secondsPastEpoch.resize(numChannel);
|
||||
secondsPastEpochExists = true;
|
||||
}
|
||||
if(pvStructure->getSubField("nanoseconds")) {
|
||||
nanoseconds.resize(numChannel);
|
||||
nanosecondsExists = true;
|
||||
}
|
||||
if(pvStructure->getSubField("userTag")) {
|
||||
userTag.resize(numChannel);
|
||||
userTagExists = true;
|
||||
}
|
||||
shared_vector<PVUnionPtr> valueVector(numChannel);
|
||||
for(size_t i=0; i<numChannel; ++i)
|
||||
{
|
||||
pvaClientGet[i]->issueGet();
|
||||
}
|
||||
for(size_t i=0; i<numChannel; ++i)
|
||||
{
|
||||
Status stat = pvaClientGet[i]->waitGet();
|
||||
if(!stat.isOK()) {
|
||||
string message = channelNames[i] + " " + stat.getMessage();
|
||||
throw std::runtime_error(message);
|
||||
}
|
||||
PVStructurePtr pvStructure = pvaClientGet[i]->getData()->getPVStructure();
|
||||
PVFieldPtr pvField = pvStructure->getSubField("value");
|
||||
if(!pvField) {
|
||||
string message = channelNames[i] + " no value field";
|
||||
throw std::runtime_error(message);
|
||||
}
|
||||
UnionConstPtr u = pvUnionArray->getUnionArray()->getUnion();
|
||||
if(u->isVariant()) {
|
||||
PVUnionPtr pvUnion = pvDataCreate->createPVVariantUnion();
|
||||
pvUnion->set(pvDataCreate->createPVField(pvField));
|
||||
valueVector[i] = pvUnion;
|
||||
} else {
|
||||
PVUnionPtr pvUnion = pvDataCreate->createPVUnion(u);
|
||||
pvUnion->set(pvField);
|
||||
valueVector[i] = pvUnion;
|
||||
}
|
||||
pvField = pvStructure->getSubField("alarm");
|
||||
if(pvField) {
|
||||
if(pvAlarm.attach(pvField)) {
|
||||
pvAlarm.get(alarm);
|
||||
if(severityExists) severity[i] = alarm.getSeverity();
|
||||
if(statusExists) status[i] = alarm.getStatus();
|
||||
if(messageExists) message[i] = alarm.getMessage();
|
||||
}
|
||||
}
|
||||
pvField = pvStructure->getSubField("timeStamp");
|
||||
if(pvField) {
|
||||
if(pvTimeStamp.attach(pvField)) {
|
||||
pvTimeStamp.get(timeStamp);
|
||||
if(secondsPastEpochExists) secondsPastEpoch[i] =
|
||||
timeStamp.getSecondsPastEpoch();
|
||||
if(nanosecondsExists) nanoseconds[i] =
|
||||
timeStamp.getNanoseconds();
|
||||
if(userTagExists) userTag[i] = timeStamp.getUserTag();
|
||||
}
|
||||
}
|
||||
}
|
||||
pvUnionArray->replace(freeze(valueVector));
|
||||
if(severityExists) {
|
||||
pvStructure->getSubField<PVIntArray>("severity")->replace(
|
||||
freeze(severity));
|
||||
}
|
||||
if(statusExists) {
|
||||
pvStructure->getSubField<PVIntArray>("status")->replace(
|
||||
freeze(status));
|
||||
}
|
||||
if(messageExists) {
|
||||
pvStructure->getSubField<PVStringArray>("message")->replace(freeze(message));
|
||||
}
|
||||
if(secondsPastEpochExists) {
|
||||
pvStructure->getSubField<PVLongArray>("secondsPastEpoch")->replace(freeze(secondsPastEpoch));
|
||||
}
|
||||
if(nanosecondsExists) {
|
||||
pvStructure->getSubField<PVIntArray>("nanoseconds")->replace(freeze(nanoseconds));
|
||||
}
|
||||
if(userTagExists) {
|
||||
pvStructure->getSubField<PVIntArray>("userTag")->replace(freeze(userTag));
|
||||
}
|
||||
return ntMultiChannel;
|
||||
}
|
||||
|
||||
void PvaClientNTMultiChannel::put(NTMultiChannelPtr const &value)
|
||||
{
|
||||
if(pvaClientPut.empty()) createPut();
|
||||
shared_vector<const string> channelNames = pvaClientMultiChannel->getChannelNames()->view();
|
||||
size_t numChannel = channelNames.size();
|
||||
PVUnionArrayPtr pvValue = value->getPVStructure()->
|
||||
getSubField<PVUnionArray>("value");
|
||||
shared_vector<const PVUnionPtr> valueVector = pvValue->view();
|
||||
for(size_t i=0; i<numChannel; ++i)
|
||||
{
|
||||
try {
|
||||
PVFieldPtr pvFrom = valueVector[i]->get();
|
||||
PVFieldPtr pvTo = pvaClientPut[i]->getData()->getValue();
|
||||
Type typeFrom = pvFrom->getField()->getType();
|
||||
Type typeTo = pvTo->getField()->getType();
|
||||
if(typeFrom==typeTo) {
|
||||
if(typeFrom==scalar || typeFrom==scalarArray) {
|
||||
pvTo->copy(*pvFrom);
|
||||
}
|
||||
}
|
||||
pvaClientPut[i]->issuePut();
|
||||
} catch (std::exception e) {
|
||||
string message = channelNames[i] + " " + e.what();
|
||||
throw std::runtime_error(message);
|
||||
}
|
||||
}
|
||||
for(size_t i=0; i<numChannel; ++i)
|
||||
{
|
||||
Status status = pvaClientPut[i]->waitPut();
|
||||
if(!status.isOK()) {
|
||||
string message = channelNames[i] + " " + status.getMessage();
|
||||
throw std::runtime_error(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}}
|
||||
@@ -1,96 +0,0 @@
|
||||
/* pvaClientNTMultiChannel.h */
|
||||
/**
|
||||
* Copyright - See the COPYRIGHT that is included with this distribution.
|
||||
* EPICS pvData is distributed subject to a Software License Agreement found
|
||||
* in file LICENSE that is included with this distribution.
|
||||
*/
|
||||
/**
|
||||
* @author mrk
|
||||
* @date 2015.02
|
||||
*/
|
||||
#ifndef PVACLIENTNTMULTIChannel_H
|
||||
#define PVACLIENTNTMULTIChannel_H
|
||||
|
||||
#ifdef epicsExportSharedSymbols
|
||||
# define pvaClientEpicsExportSharedSymbols
|
||||
# undef epicsExportSharedSymbols
|
||||
#endif
|
||||
|
||||
#include <pv/pvaClient.h>
|
||||
|
||||
namespace epics { namespace pvaClient {
|
||||
|
||||
class PvaClientNTMultiChannel;
|
||||
typedef std::tr1::shared_ptr<PvaClientNTMultiChannel> PvaClientNTMultiChannelPtr;
|
||||
|
||||
/** Support for multiple channels where each channel has a value field that
|
||||
* is a scalar, scalarArray, or enumerated structure.
|
||||
* The data is provided via normativeType NTMultiChannel.
|
||||
* If any problems arise an exception is thrown.
|
||||
*
|
||||
* @author mrk
|
||||
*/
|
||||
class epicsShareClass PvaClientNTMultiChannel
|
||||
{
|
||||
public:
|
||||
POINTER_DEFINITIONS(PvaClientNTMultiChannel);
|
||||
/** Create a PvaClientNTMultiChannel.
|
||||
* @param &pvaClient Interface to PvaClient
|
||||
* @param channelName PVStringArray of channelNames.
|
||||
* @param structure valid NTMultiChannel structure.
|
||||
* @param timeout Timeout for connecting.
|
||||
* @param providerName The provider for each channel.
|
||||
* @return The interface to PvaClientNTMultiChannel.
|
||||
*/
|
||||
static PvaClientNTMultiChannelPtr create(
|
||||
PvaClientPtr const & pvaClient,
|
||||
epics::pvData::PVStringArrayPtr const & channelName,
|
||||
epics::pvData::StructureConstPtr const & structure,
|
||||
double timeout = 5.0,
|
||||
std::string const & providerName = "pva");
|
||||
/** Destructor
|
||||
*/
|
||||
~PvaClientNTMultiChannel();
|
||||
/** Destroy all resources used.
|
||||
*/
|
||||
void destroy();
|
||||
/** Get the value of all the channels.
|
||||
* @return The data.
|
||||
*/
|
||||
epics::nt::NTMultiChannelPtr get();
|
||||
/** Put a new value to each channel.
|
||||
* @param value The data.
|
||||
*/
|
||||
void put(epics::nt::NTMultiChannelPtr const &value);
|
||||
/** Get the PvaClientMultiChannel.
|
||||
* @return The interface.
|
||||
*/
|
||||
PvaClientMultiChannelPtr getPvaClientMultiChannel();
|
||||
private:
|
||||
PvaClientNTMultiChannel(
|
||||
PvaClientMultiChannelPtr const & channelName,
|
||||
epics::nt::NTMultiChannelPtr const &ntMultiChannel);
|
||||
void createGet();
|
||||
void createPut();
|
||||
|
||||
PvaClientMultiChannelPtr pvaClientMultiChannel;
|
||||
epics::nt::NTMultiChannelPtr ntMultiChannel;
|
||||
epics::pvData::PVUnionArrayPtr pvUnionArray;
|
||||
epics::pvData::PVDataCreatePtr pvDataCreate;
|
||||
std::vector<PvaClientGetPtr> pvaClientGet;
|
||||
std::vector<PvaClientPutPtr> pvaClientPut;
|
||||
epics::pvData::shared_vector<epics::pvData::int32> severity;
|
||||
epics::pvData::shared_vector<epics::pvData::int32> status;
|
||||
epics::pvData::shared_vector<std::string> message;
|
||||
epics::pvData::shared_vector<epics::pvData::int64> secondsPastEpoch;
|
||||
epics::pvData::shared_vector<epics::pvData::int32> nanoseconds;
|
||||
epics::pvData::shared_vector<epics::pvData::int32> userTag;
|
||||
epics::pvData::Alarm alarm;
|
||||
epics::pvData::PVAlarm pvAlarm;
|
||||
epics::pvData::TimeStamp timeStamp;;
|
||||
epics::pvData::PVTimeStamp pvTimeStamp;
|
||||
};
|
||||
|
||||
}}
|
||||
|
||||
#endif // PVACLIENTNTMULTIChannel_H
|
||||
@@ -44,11 +44,9 @@ public:
|
||||
|
||||
PvaClientProcess::PvaClientProcess(
|
||||
PvaClientPtr const &pvaClient,
|
||||
PvaClientChannelPtr const & pvaClientChannel,
|
||||
Channel::shared_pointer const & channel,
|
||||
PVStructurePtr const &pvRequest)
|
||||
: pvaClient(pvaClient),
|
||||
pvaClientChannel(pvaClientChannel),
|
||||
channel(channel),
|
||||
pvRequest(pvRequest),
|
||||
isDestroyed(false),
|
||||
@@ -62,13 +60,6 @@ PvaClientProcess::~PvaClientProcess()
|
||||
destroy();
|
||||
}
|
||||
|
||||
void PvaClientProcess::checkProcessState()
|
||||
{
|
||||
if(isDestroyed) throw std::runtime_error("pvaClientProcess was destroyed");
|
||||
if(connectState==connectIdle) connect();
|
||||
if(processState==processIdle) process();
|
||||
}
|
||||
|
||||
// from ChannelProcessRequester
|
||||
string PvaClientProcess::getRequesterName()
|
||||
{
|
||||
@@ -89,7 +80,7 @@ void PvaClientProcess::channelProcessConnect(
|
||||
const Status& status,
|
||||
ChannelProcess::shared_pointer const & channelProcess)
|
||||
{
|
||||
if(isDestroyed) throw std::runtime_error("pvaClientProcess was destroyed");
|
||||
if(isDestroyed) return;
|
||||
channelProcessConnectStatus = status;
|
||||
this->channelProcess = channelProcess;
|
||||
waitForConnect.signal();
|
||||
@@ -100,7 +91,7 @@ void PvaClientProcess::processDone(
|
||||
const Status& status,
|
||||
ChannelProcess::shared_pointer const & channelProcess)
|
||||
{
|
||||
if(isDestroyed) throw std::runtime_error("pvaClientProcess was destroyed");
|
||||
if(isDestroyed) return;
|
||||
channelProcessStatus = status;
|
||||
waitForProcess.signal();
|
||||
}
|
||||
@@ -151,12 +142,8 @@ Status PvaClientProcess::waitConnect()
|
||||
throw std::runtime_error(ss.str());
|
||||
}
|
||||
waitForConnect.wait();
|
||||
if(channelProcessConnectStatus.isOK()){
|
||||
connectState = connected;
|
||||
return Status::Ok;
|
||||
}
|
||||
connectState = connectIdle;
|
||||
return Status(Status::STATUSTYPE_ERROR,channelProcessConnectStatus.getMessage());
|
||||
connectState = channelProcessConnectStatus.isOK() ? connected : connectIdle;
|
||||
return channelProcessConnectStatus;
|
||||
}
|
||||
|
||||
void PvaClientProcess::process()
|
||||
@@ -193,19 +180,15 @@ Status PvaClientProcess::waitProcess()
|
||||
}
|
||||
waitForProcess.wait();
|
||||
processState = processIdle;
|
||||
if(channelProcessStatus.isOK()) {
|
||||
return Status::Ok;
|
||||
}
|
||||
return Status(Status::STATUSTYPE_ERROR,channelProcessStatus.getMessage());
|
||||
return channelProcessStatus;
|
||||
}
|
||||
|
||||
PvaClientProcessPtr PvaClientProcess::create(
|
||||
PvaClientPtr const &pvaClient,
|
||||
PvaClientChannelPtr const & pvaClientChannel,
|
||||
Channel::shared_pointer const & channel,
|
||||
PVStructurePtr const &pvRequest)
|
||||
{
|
||||
PvaClientProcessPtr epv(new PvaClientProcess(pvaClient,pvaClientChannel,channel,pvRequest));
|
||||
PvaClientProcessPtr epv(new PvaClientProcess(pvaClient,channel,pvRequest));
|
||||
return epv;
|
||||
}
|
||||
|
||||
|
||||
@@ -50,11 +50,9 @@ public:
|
||||
|
||||
PvaClientPut::PvaClientPut(
|
||||
PvaClientPtr const &pvaClient,
|
||||
PvaClientChannelPtr const & pvaClientChannel,
|
||||
Channel::shared_pointer const & channel,
|
||||
PVStructurePtr const &pvRequest)
|
||||
: pvaClient(pvaClient),
|
||||
pvaClientChannel(pvaClientChannel),
|
||||
channel(channel),
|
||||
pvRequest(pvRequest),
|
||||
isDestroyed(false),
|
||||
@@ -103,7 +101,7 @@ void PvaClientPut::channelPutConnect(
|
||||
this->channelPut = channelPut;
|
||||
if(status.isOK()) {
|
||||
pvaClientData = PvaClientPutData::create(structure);
|
||||
pvaClientData->setMessagePrefix(pvaClientChannel.lock()->getChannelName());
|
||||
pvaClientData->setMessagePrefix(channel->getChannelName());
|
||||
}
|
||||
waitForConnect.signal();
|
||||
|
||||
@@ -120,7 +118,7 @@ void PvaClientPut::getDone(
|
||||
if(status.isOK()) {
|
||||
PVStructurePtr pvs = pvaClientData->getPVStructure();
|
||||
pvs->copyUnchecked(*pvStructure,*bitSet);
|
||||
BitSetPtr bs = pvaClientData->getBitSet();
|
||||
BitSetPtr bs = pvaClientData->getChangedBitSet();
|
||||
bs->clear();
|
||||
*bs |= *bitSet;
|
||||
}
|
||||
@@ -182,12 +180,8 @@ Status PvaClientPut::waitConnect()
|
||||
throw std::runtime_error(ss.str());
|
||||
}
|
||||
waitForConnect.wait();
|
||||
if(channelPutConnectStatus.isOK()) {
|
||||
connectState = connected;
|
||||
return Status::Ok;
|
||||
}
|
||||
connectState = connectIdle;
|
||||
return Status(Status::STATUSTYPE_ERROR,channelPutConnectStatus.getMessage());
|
||||
connectState = channelPutConnectStatus.isOK() ? connected : connectIdle;
|
||||
return channelPutConnectStatus;
|
||||
}
|
||||
|
||||
void PvaClientPut::get()
|
||||
@@ -211,7 +205,7 @@ void PvaClientPut::issueGet()
|
||||
throw std::runtime_error(ss.str());
|
||||
}
|
||||
putState = getActive;
|
||||
pvaClientData->getBitSet()->clear();
|
||||
pvaClientData->getChangedBitSet()->clear();
|
||||
channelPut->get();
|
||||
}
|
||||
|
||||
@@ -225,10 +219,7 @@ Status PvaClientPut::waitGet()
|
||||
}
|
||||
waitForGetPut.wait();
|
||||
putState = putIdle;
|
||||
if(channelGetPutStatus.isOK()) {
|
||||
return Status::Ok;
|
||||
}
|
||||
return Status(Status::STATUSTYPE_ERROR,channelGetPutStatus.getMessage());
|
||||
return channelGetPutStatus;
|
||||
}
|
||||
|
||||
void PvaClientPut::put()
|
||||
@@ -252,7 +243,7 @@ void PvaClientPut::issuePut()
|
||||
throw std::runtime_error(ss.str());
|
||||
}
|
||||
putState = putActive;
|
||||
channelPut->put(pvaClientData->getPVStructure(),pvaClientData->getBitSet());
|
||||
channelPut->put(pvaClientData->getPVStructure(),pvaClientData->getChangedBitSet());
|
||||
}
|
||||
|
||||
Status PvaClientPut::waitPut()
|
||||
@@ -265,11 +256,8 @@ Status PvaClientPut::waitPut()
|
||||
}
|
||||
waitForGetPut.wait();
|
||||
putState = putIdle;
|
||||
if(channelGetPutStatus.isOK()) {
|
||||
pvaClientData->getBitSet()->clear();
|
||||
return Status::Ok;
|
||||
}
|
||||
return Status(Status::STATUSTYPE_ERROR,channelGetPutStatus.getMessage());
|
||||
if(channelGetPutStatus.isOK()) pvaClientData->getChangedBitSet()->clear();
|
||||
return channelGetPutStatus;
|
||||
}
|
||||
|
||||
PvaClientPutDataPtr PvaClientPut::getData()
|
||||
@@ -280,11 +268,10 @@ PvaClientPutDataPtr PvaClientPut::getData()
|
||||
|
||||
PvaClientPutPtr PvaClientPut::create(
|
||||
PvaClientPtr const &pvaClient,
|
||||
PvaClientChannelPtr const & pvaClientChannel,
|
||||
Channel::shared_pointer const & channel,
|
||||
PVStructurePtr const &pvRequest)
|
||||
{
|
||||
PvaClientPutPtr epv(new PvaClientPut(pvaClient,pvaClientChannel,channel,pvRequest));
|
||||
PvaClientPutPtr epv(new PvaClientPut(pvaClient,channel,pvRequest));
|
||||
return epv;
|
||||
}
|
||||
|
||||
|
||||
@@ -57,6 +57,7 @@ PvaClientPutData::PvaClientPutData(StructureConstPtr const & structure)
|
||||
pvStructure(getPVDataCreate()->createPVStructure(structure)),
|
||||
bitSet(BitSetPtr(new BitSet(pvStructure->getNumberFields())))
|
||||
{
|
||||
messagePrefix = "";
|
||||
size_t nfields = pvStructure->getNumberFields();
|
||||
postHandler.resize(nfields);
|
||||
PVFieldPtr pvField;
|
||||
@@ -95,7 +96,7 @@ StructureConstPtr PvaClientPutData::getStructure()
|
||||
PVStructurePtr PvaClientPutData::getPVStructure()
|
||||
{return pvStructure;}
|
||||
|
||||
BitSetPtr PvaClientPutData::getBitSet()
|
||||
BitSetPtr PvaClientPutData::getChangedBitSet()
|
||||
{return bitSet;}
|
||||
|
||||
std::ostream & PvaClientPutData::showChanged(std::ostream & out)
|
||||
@@ -145,9 +146,7 @@ PVScalarPtr PvaClientPutData::getScalarValue()
|
||||
{
|
||||
checkValue();
|
||||
PVScalarPtr pv = pvStructure->getSubField<PVScalar>("value");
|
||||
if(!pv) {
|
||||
throw std::runtime_error(messagePrefix + notScalar);
|
||||
}
|
||||
if(!pv) throw std::runtime_error(messagePrefix + notScalar);
|
||||
return pv;
|
||||
}
|
||||
|
||||
@@ -155,9 +154,7 @@ PVArrayPtr PvaClientPutData::getArrayValue()
|
||||
{
|
||||
checkValue();
|
||||
PVArrayPtr pv = pvStructure->getSubField<PVArray>("value");
|
||||
if(!pv) {
|
||||
throw std::runtime_error(messagePrefix + notArray);
|
||||
}
|
||||
if(!pv) throw std::runtime_error(messagePrefix + notArray);
|
||||
return pv;
|
||||
}
|
||||
|
||||
@@ -165,9 +162,7 @@ PVScalarArrayPtr PvaClientPutData::getScalarArrayValue()
|
||||
{
|
||||
checkValue();
|
||||
PVScalarArrayPtr pv = pvStructure->getSubField<PVScalarArray>("value");
|
||||
if(!pv) {
|
||||
throw std::runtime_error(messagePrefix + notScalarArray);
|
||||
}
|
||||
if(!pv) throw std::runtime_error(messagePrefix + notScalarArray);
|
||||
return pv;
|
||||
}
|
||||
|
||||
@@ -180,7 +175,7 @@ double PvaClientPutData::getDouble()
|
||||
return pvDouble->get();
|
||||
}
|
||||
if(!ScalarTypeFunc::isNumeric(scalarType)) {
|
||||
throw std::runtime_error(notCompatibleScalar);
|
||||
throw std::runtime_error(messagePrefix + notCompatibleScalar);
|
||||
}
|
||||
return convert->toDouble(pvScalar);
|
||||
}
|
||||
|
||||
@@ -43,9 +43,9 @@ public:
|
||||
const epics::pvData::Status& status,
|
||||
epics::pvAccess::ChannelPutGet::shared_pointer const & channelPutGet,
|
||||
epics::pvData::PVStructurePtr const & getPVStructure,
|
||||
epics::pvData::BitSetPtr const & getBitSet)
|
||||
epics::pvData::BitSetPtr const & getChangedBitSet)
|
||||
{
|
||||
pvaClientPutGet->putGetDone(status,channelPutGet,getPVStructure,getBitSet);
|
||||
pvaClientPutGet->putGetDone(status,channelPutGet,getPVStructure,getChangedBitSet);
|
||||
}
|
||||
void getPutDone(
|
||||
const epics::pvData::Status& status,
|
||||
@@ -59,19 +59,17 @@ public:
|
||||
const epics::pvData::Status& status,
|
||||
epics::pvAccess::ChannelPutGet::shared_pointer const & channelPutGet,
|
||||
epics::pvData::PVStructurePtr const & getPVStructure,
|
||||
epics::pvData::BitSet::shared_pointer const & getBitSet)
|
||||
epics::pvData::BitSet::shared_pointer const & getChangedBitSet)
|
||||
{
|
||||
pvaClientPutGet->getGetDone(status,channelPutGet,getPVStructure,getBitSet);
|
||||
pvaClientPutGet->getGetDone(status,channelPutGet,getPVStructure,getChangedBitSet);
|
||||
}
|
||||
};
|
||||
|
||||
PvaClientPutGet::PvaClientPutGet(
|
||||
PvaClientPtr const &pvaClient,
|
||||
PvaClientChannelPtr const & pvaClientChannel,
|
||||
Channel::shared_pointer const & channel,
|
||||
PVStructurePtr const &pvRequest)
|
||||
: pvaClient(pvaClient),
|
||||
pvaClientChannel(pvaClientChannel),
|
||||
channel(channel),
|
||||
pvRequest(pvRequest),
|
||||
isDestroyed(false),
|
||||
@@ -121,9 +119,9 @@ void PvaClientPutGet::channelPutGetConnect(
|
||||
this->channelPutGet = channelPutGet;
|
||||
if(status.isOK()) {
|
||||
pvaClientPutData = PvaClientPutData::create(putStructure);
|
||||
pvaClientPutData->setMessagePrefix(pvaClientChannel.lock()->getChannelName());
|
||||
pvaClientPutData->setMessagePrefix(channel->getChannelName());
|
||||
pvaClientGetData = PvaClientGetData::create(getStructure);
|
||||
pvaClientGetData->setMessagePrefix(pvaClientChannel.lock()->getChannelName());
|
||||
pvaClientGetData->setMessagePrefix(channel->getChannelName());
|
||||
}
|
||||
waitForConnect.signal();
|
||||
|
||||
@@ -133,12 +131,12 @@ void PvaClientPutGet::putGetDone(
|
||||
const Status& status,
|
||||
ChannelPutGet::shared_pointer const & channelPutGet,
|
||||
PVStructurePtr const & getPVStructure,
|
||||
BitSetPtr const & getBitSet)
|
||||
BitSetPtr const & getChangedBitSet)
|
||||
{
|
||||
if(isDestroyed) throw std::runtime_error("pvaClientPutGet was destroyed");
|
||||
channelPutGetStatus = status;
|
||||
if(status.isOK()) {
|
||||
pvaClientGetData->setData(getPVStructure,getBitSet);
|
||||
pvaClientGetData->setData(getPVStructure,getChangedBitSet);
|
||||
}
|
||||
waitForPutGet.signal();
|
||||
}
|
||||
@@ -150,11 +148,11 @@ void PvaClientPutGet::getPutDone(
|
||||
BitSetPtr const & putBitSet)
|
||||
{
|
||||
if(isDestroyed) throw std::runtime_error("pvaClientPutGet was destroyed");
|
||||
channelGetPutGetStatus = status;
|
||||
channelPutGetStatus = status;
|
||||
if(status.isOK()) {
|
||||
PVStructurePtr pvs = pvaClientPutData->getPVStructure();
|
||||
pvs->copyUnchecked(*putPVStructure,*putBitSet);
|
||||
BitSetPtr bs = pvaClientPutData->getBitSet();
|
||||
BitSetPtr bs = pvaClientPutData->getChangedBitSet();
|
||||
bs->clear();
|
||||
*bs |= *putBitSet;
|
||||
}
|
||||
@@ -165,12 +163,12 @@ void PvaClientPutGet::getGetDone(
|
||||
const Status& status,
|
||||
ChannelPutGet::shared_pointer const & channelPutGet,
|
||||
PVStructurePtr const & getPVStructure,
|
||||
BitSetPtr const & getBitSet)
|
||||
BitSetPtr const & getChangedBitSet)
|
||||
{
|
||||
if(isDestroyed) throw std::runtime_error("pvaClientPutGet was destroyed");
|
||||
channelPutGetStatus = status;
|
||||
if(status.isOK()) {
|
||||
pvaClientGetData->setData(getPVStructure,getBitSet);
|
||||
pvaClientGetData->setData(getPVStructure,getChangedBitSet);
|
||||
}
|
||||
waitForPutGet.signal();
|
||||
}
|
||||
@@ -222,12 +220,8 @@ Status PvaClientPutGet::waitConnect()
|
||||
throw std::runtime_error(ss.str());
|
||||
}
|
||||
waitForConnect.wait();
|
||||
if(channelPutGetConnectStatus.isOK()) {
|
||||
connectState = connected;
|
||||
return Status::Ok;
|
||||
}
|
||||
connectState = connectIdle;
|
||||
return Status(Status::STATUSTYPE_ERROR,channelPutGetConnectStatus.getMessage());
|
||||
connectState = channelPutGetConnectStatus.isOK() ? connected : connectIdle;
|
||||
return channelPutGetConnectStatus;
|
||||
}
|
||||
|
||||
|
||||
@@ -252,7 +246,7 @@ void PvaClientPutGet::issuePutGet()
|
||||
throw std::runtime_error(ss.str());
|
||||
}
|
||||
putGetState = putGetActive;
|
||||
channelPutGet->putGet(pvaClientPutData->getPVStructure(),pvaClientPutData->getBitSet());
|
||||
channelPutGet->putGet(pvaClientPutData->getPVStructure(),pvaClientPutData->getChangedBitSet());
|
||||
}
|
||||
|
||||
|
||||
@@ -266,10 +260,7 @@ Status PvaClientPutGet::waitPutGet()
|
||||
}
|
||||
waitForPutGet.wait();
|
||||
putGetState = putGetIdle;
|
||||
if(channelGetPutGetStatus.isOK()) {
|
||||
return Status::Ok;
|
||||
}
|
||||
return Status(Status::STATUSTYPE_ERROR,channelGetPutGetStatus.getMessage());
|
||||
return channelPutGetStatus;
|
||||
}
|
||||
|
||||
void PvaClientPutGet::getGet()
|
||||
@@ -306,10 +297,7 @@ Status PvaClientPutGet::waitGetGet()
|
||||
}
|
||||
waitForPutGet.wait();
|
||||
putGetState = putGetIdle;
|
||||
if(channelGetPutGetStatus.isOK()) {
|
||||
return Status::Ok;
|
||||
}
|
||||
return Status(Status::STATUSTYPE_ERROR,channelGetPutGetStatus.getMessage());
|
||||
return channelPutGetStatus;
|
||||
}
|
||||
|
||||
void PvaClientPutGet::getPut()
|
||||
@@ -346,10 +334,7 @@ Status PvaClientPutGet::waitGetPut()
|
||||
}
|
||||
waitForPutGet.wait();
|
||||
putGetState = putGetIdle;
|
||||
if(channelGetPutGetStatus.isOK()) {
|
||||
return Status::Ok;
|
||||
}
|
||||
return Status(Status::STATUSTYPE_ERROR,channelGetPutGetStatus.getMessage());
|
||||
return channelPutGetStatus;
|
||||
}
|
||||
|
||||
PvaClientGetDataPtr PvaClientPutGet::getGetData()
|
||||
@@ -366,11 +351,10 @@ PvaClientPutDataPtr PvaClientPutGet::getPutData()
|
||||
|
||||
PvaClientPutGetPtr PvaClientPutGet::create(
|
||||
PvaClientPtr const &pvaClient,
|
||||
PvaClientChannelPtr const & pvaClientChannel,
|
||||
Channel::shared_pointer const & channel,
|
||||
PVStructurePtr const &pvRequest)
|
||||
{
|
||||
PvaClientPutGetPtr epv(new PvaClientPutGet(pvaClient,pvaClientChannel,channel,pvRequest));
|
||||
PvaClientPutGetPtr epv(new PvaClientPutGet(pvaClient,channel,pvRequest));
|
||||
return epv;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user