From bf4524029cb56f4759a22e08984204861604ac6e Mon Sep 17 00:00:00 2001 From: Marty Kraimer Date: Tue, 9 Jun 2015 09:15:14 -0400 Subject: [PATCH 1/3] finish hg to git; state that no longer supported --- .gitignore | 12 ++ .hgflow | 8 - .hgignore | 11 -- README.txt | 4 + documentation/easyPVA.html | 9 +- documentation/easyPVA_20150609.html | 222 ++++++++++++++++++++++++++++ 6 files changed, 245 insertions(+), 21 deletions(-) create mode 100644 .gitignore delete mode 100644 .hgflow delete mode 100644 .hgignore create mode 100644 documentation/easyPVA_20150609.html diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..8b3be2f --- /dev/null +++ b/.gitignore @@ -0,0 +1,12 @@ +bin/ +lib/ +doc/ +include/ +db/ +dbd/ +documentation/html +documentation/*.tag +envPaths +configure/*.local +!configure/ExampleRELEASE.local +**/O.* diff --git a/.hgflow b/.hgflow deleted file mode 100644 index 9a28791..0000000 --- a/.hgflow +++ /dev/null @@ -1,8 +0,0 @@ -[branchname] -master = master -develop = default -feature = feature/ -release = release/ -hotfix = hotfix/ -support = support/ - diff --git a/.hgignore b/.hgignore deleted file mode 100644 index 20e12e6..0000000 --- a/.hgignore +++ /dev/null @@ -1,11 +0,0 @@ -^QtC- -bin/ -lib/ -doc/ -include/ -db/ -dbd/ -documentation/html -envPaths -configure/.*\.local -/O\..* diff --git a/README.txt b/README.txt index e234c21..b4d961e 100644 --- a/README.txt +++ b/README.txt @@ -1,3 +1,7 @@ +THIS MODULE IS NO LONGER SUPPORTED. +It's functionality has been moved to pvAccessCPP and renamed fro EasyPVA to Pva. + + To build do the following: cd configure diff --git a/documentation/easyPVA.html b/documentation/easyPVA.html index 487937d..dec0657 100644 --- a/documentation/easyPVA.html +++ b/documentation/easyPVA.html @@ -36,16 +36,21 @@
Latest version:
easyPVA_20150325.html + href="easyPVA_20150609.html">easyPVA_20150609.html
Previous version:
-
none
+
easyPVA_20150325.html +
Editors:
Marty Kraimer, BNL
Matej Sekoranja, Cosylab

Abstract

+

NO LONGER SUPPPORTED: +The functionality has been moved to pvAccessCPP and EasyPva renamed to Pva. +

EasyPVA (Easy PVAccess) is a software library that provides to an EPICS client programmer, a friendly client side programming interface to the data of an EPICS based control system. It is intended diff --git a/documentation/easyPVA_20150609.html b/documentation/easyPVA_20150609.html new file mode 100644 index 0000000..dec0657 --- /dev/null +++ b/documentation/easyPVA_20150609.html @@ -0,0 +1,222 @@ + + + + + + EPICS easyPVA + + + + + + + + + + + +

+

EPICS easyPVA

+ +

EPICS V4 Working Group, Working Draft, +25-Mar-2015

+
+
This version:
+
easyPVA.html +
+
Latest version:
+
easyPVA_20150609.html +
+
Previous version:
+
easyPVA_20150325.html +
+
Editors:
+
Marty Kraimer, BNL
+
Matej Sekoranja, Cosylab
+
+ +

Abstract

+

NO LONGER SUPPPORTED: +The functionality has been moved to pvAccessCPP and EasyPva renamed to Pva. +

+ +

EasyPVA (Easy PVAccess) is a software library that provides to an EPICS client programmer, a friendly +client side programming interface to the data of an EPICS based control system. It is intended +for such uses as rapid development of ad hoc programs by controls engineers, or to provide +scientists a way to directly develop analytical applications.

+ +

Specifically, easyPVA provides an easy interface for pvAccess, which is the +software support for high speed controls network communications used in EPICS version 4. +PvAccess provides a callback based interface, which can be hard to use. +EasyPVA provides an interface that does not require callbacks even for monitors. +

+

+EasyChannel provides many "convenience" methods to directly get and put +scalar and scalarArray data types. +Additional methods provide access to the full features of pvAccess. +

+

+EasyMultiChannel provides access to data from multiple channels. +It can be used directly by a client or via EasyMultiDouble or EasyNTMultiChannel. +EasyMultiDouble allows the client to get and put data to multiple channels. +But each channel must have a value field that is a numeric scalar. +EasyNTMultiChannel allows the client to get and put data to multiple channels. +Each channel must have a value field. +The data for the channels is presented via normative type NTMultiChannel. +

+ +

For more information about EPICS generally, please refer to the home page of the Experimental Physics and Industrial + Control System.

+ + + +

Status of this Document and of the EasyPVA Software

+ +

EasyPVACPP is ready for use.

+ +
+ +
+

Table of Contents

+
+ + +
+
+ +

Introduction

+ +

EasyPVA is a synchronous API for accessing PVData via PVAccess. It provides +an interface to many of the features provided by pvData and pvAccess.

+ +

This document describes the layout of the source files in this project.

+

+A user overview is available via +overview.html + +

+

+Doxygen documentation is available at +doxygenDoc + +

+

Building

+

After obtaining the source:

+
+cd configure
+cp ExampleRELEASE.local RELEASE.local
+
+

Edit RELEASE.local so that all path names are correct for you environment. +

+

+Then:

+
+cd ..
+make
+
+ +

Example and Test Database

+

The examples and tests require that an example pvAccess server is runnimg. +This distribution has a file exampleDatabaseEasyPVA.zip. +When unzipped this is used to create an example IOC database. +The database has the record used by the examples are tests that come with easyPVAJava. +It uses pvDatabaseCPP to build the database. +

+

+After unzipping the file: +

+
+cd configure
+cp ExampleRELEASE.local RELEASE.local
+edit RELEASE.local
+cd ..
+make
+cd iocBoot/exampleDatabase
+../../bin/<arch:>/exampleDatabase st.cmd
+
+

Testing

+

The tests will fail unless the example database is running.

+

Once it is running:

+
+make runtests
+
+

Examples

+

Examples are in directory example/src. +An example of how to run them is:

+
+mrk> pwd
+/home/hg/easyPVACPP/example
+mrk> bin/linux-x86_64/exampleEasyGet 
+
+

The following is a brief description of each example. +In order to understand each example it +helps to also bee loooking at the source for the example.

+

exampleEasyGet

+

This has a number of examples:

+
+
exampleDouble
+
+ This shows two methods for getting data from a channel that has a numeric + scalar value field. +
+
exampleDoubleArray
+
+ This shows two methods for getting data from a channel that has a + double array value field. +
+
exampleCADouble
+
+ This is like exampleDouble except it uses provider ca. +
+
exampleCADoubleArray
+
+ This is like exampleDoubleArray except it uses provider ca. +
+
examplePowerSupply
+
+ This is an example of getting data from a channel that does not + have a value field. +
+
+

exampleEasyMonitor

+

This is an example of creating a monitor on a channel. +It monitors a channel that models a powerSupply, i. e. it is not a "standard" record. +It does not have a value field. +

+

After starting the example a change can be made to the powerSupply by issuing:

+
+pvput -r "power.value,voltage.value" examplePowerSupply 6 6
+
+

exampleEasyPut

+

This example gets and puts to channel exampleDouble.

+

exampleEasyProcess

+

This example makes a process request to channel exampleDouble.

+

helloWorldPutGet

+

This is an example of issuing a channelPutGet.

+

exampleEasyMultiDouble

+

This is an example of issuing gets and puts to multiple channels where each +channel has a numeric scalar value field.

+

exampleEasyNTMultiChannel

+

This is an example of using NDMultiChannel to obtain data from multiple channels. +

+

helloWorldRPC

+

This is an example of issuing a channelRPC request. +It does not use easyPVA.

+
+ + From 0d0b6ebac01c37b68abb77539a2d2893accfa13b Mon Sep 17 00:00:00 2001 From: Marty Kraimer Date: Wed, 17 Jun 2015 10:57:57 -0400 Subject: [PATCH 2/3] rename easyPVACPP to pvaClientCPP; this means repository and all names; --- example/src/Makefile | 78 +-- ...pleEasyGet.cpp => examplePvaClientGet.cpp} | 90 +-- ...onitor.cpp => examplePvaClientMonitor.cpp} | 20 +- ...le.cpp => examplePvaClientMultiDouble.cpp} | 20 +- ...cpp => examplePvaClientNTMultiChannel.cpp} | 28 +- ...rocess.cpp => examplePvaClientProcess.cpp} | 16 +- ...pleEasyPut.cpp => examplePvaClientPut.cpp} | 18 +- example/src/helloWorldPutGet.cpp | 18 +- example/src/helloWorldRPC.cpp | 2 +- ...asyPVA.zip => exampleDatabasePvaClient.zip | Bin src/Makefile | 39 +- src/easyChannel.cpp | 495 --------------- src/easyMonitor.cpp | 250 -------- src/easyMultiChannel.cpp | 165 ----- src/easyMultiDouble.cpp | 138 ----- src/easyPVA.cpp | 199 ------ src/pvaClient.cpp | 199 ++++++ src/{easyPVA.h => pvaClient.h} | 570 +++++++++--------- src/pvaClientChannel.cpp | 495 +++++++++++++++ src/{easyGet.cpp => pvaClientGet.cpp} | 116 ++-- src/{easyGetData.cpp => pvaClientGetData.cpp} | 84 ++- src/pvaClientMonitor.cpp | 250 ++++++++ ...nitorData.cpp => pvaClientMonitorData.cpp} | 52 +- src/pvaClientMultiChannel.cpp | 165 +++++ src/pvaClientMultiDouble.cpp | 139 +++++ ...syMultiDouble.h => pvaClientMultiDouble.h} | 46 +- ...hannel.cpp => pvaClientNTMultiChannel.cpp} | 91 +-- ...ltiChannel.h => pvaClientNTMultiChannel.h} | 48 +- src/{easyProcess.cpp => pvaClientProcess.cpp} | 106 ++-- src/{easyPut.cpp => pvaClientPut.cpp} | 148 ++--- src/{easyPutData.cpp => pvaClientPutData.cpp} | 67 +- src/{easyPutGet.cpp => pvaClientPutGet.cpp} | 180 +++--- test/src/Makefile | 64 +- test/src/easyAllTests.c | 31 - test/src/pvaClientAllTests.c | 31 + ...syGetData.cpp => pvaClientTestGetData.cpp} | 74 +-- ...rData.cpp => pvaClientTestMonitorData.cpp} | 76 +-- ...ouble.cpp => pvaClientTestMultiDouble.cpp} | 44 +- ...el.cpp => pvaClientTestNTMultiChannel.cpp} | 28 +- ...syPutData.cpp => pvaClientTestPutData.cpp} | 94 +-- ...EasyPutGet.cpp => pvaClientTestPutGet.cpp} | 30 +- ...tor.cpp => pvaClientTestPutGetMonitor.cpp} | 44 +- 42 files changed, 2445 insertions(+), 2403 deletions(-) rename example/src/{exampleEasyGet.cpp => examplePvaClientGet.cpp} (54%) rename example/src/{exampleEasyMonitor.cpp => examplePvaClientMonitor.cpp} (59%) rename example/src/{exampleEasyMultiDouble.cpp => examplePvaClientMultiDouble.cpp} (81%) rename example/src/{exampleEasyNTMultiChannel.cpp => examplePvaClientNTMultiChannel.cpp} (80%) rename example/src/{exampleEasyProcess.cpp => examplePvaClientProcess.cpp} (69%) rename example/src/{exampleEasyPut.cpp => examplePvaClientPut.cpp} (69%) rename exampleDatabaseEasyPVA.zip => exampleDatabasePvaClient.zip (100%) delete mode 100644 src/easyChannel.cpp delete mode 100644 src/easyMonitor.cpp delete mode 100644 src/easyMultiChannel.cpp delete mode 100644 src/easyMultiDouble.cpp delete mode 100644 src/easyPVA.cpp create mode 100644 src/pvaClient.cpp rename src/{easyPVA.h => pvaClient.h} (74%) create mode 100644 src/pvaClientChannel.cpp rename src/{easyGet.cpp => pvaClientGet.cpp} (53%) rename src/{easyGetData.cpp => pvaClientGetData.cpp} (64%) create mode 100644 src/pvaClientMonitor.cpp rename src/{easyMonitorData.cpp => pvaClientMonitorData.cpp} (76%) create mode 100644 src/pvaClientMultiChannel.cpp create mode 100644 src/pvaClientMultiDouble.cpp rename src/{easyMultiDouble.h => pvaClientMultiDouble.h} (58%) rename src/{easyNTMultiChannel.cpp => pvaClientNTMultiChannel.cpp} (71%) rename src/{easyNTMultiChannel.h => pvaClientNTMultiChannel.h} (68%) rename src/{easyProcess.cpp => pvaClientProcess.cpp} (53%) rename src/{easyPut.cpp => pvaClientPut.cpp} (52%) rename src/{easyPutData.cpp => pvaClientPutData.cpp} (75%) rename src/{easyPutGet.cpp => pvaClientPutGet.cpp} (54%) delete mode 100644 test/src/easyAllTests.c create mode 100644 test/src/pvaClientAllTests.c rename test/src/{testEasyGetData.cpp => pvaClientTestGetData.cpp} (64%) rename test/src/{testEasyMonitorData.cpp => pvaClientTestMonitorData.cpp} (61%) rename test/src/{testEasyMultiDouble.cpp => pvaClientTestMultiDouble.cpp} (78%) rename test/src/{testEasyNTMultiChannel.cpp => pvaClientTestNTMultiChannel.cpp} (88%) rename test/src/{testEasyPutData.cpp => pvaClientTestPutData.cpp} (69%) rename test/src/{testEasyPutGet.cpp => pvaClientTestPutGet.cpp} (67%) rename test/src/{testEasyPutGetMonitor.cpp => pvaClientTestPutGetMonitor.cpp} (56%) diff --git a/example/src/Makefile b/example/src/Makefile index e19c5fe..3fb3d78 100644 --- a/example/src/Makefile +++ b/example/src/Makefile @@ -5,52 +5,52 @@ include $(TOP)/configure/CONFIG # ADD MACRO DEFINITIONS AFTER THIS LINE -PROD_HOST += exampleEasyProcess -exampleEasyProcess_SRCS += exampleEasyProcess.cpp -exampleEasyProcess_LIBS += easyPVA -exampleEasyProcess_LIBS += pvAccess -exampleEasyProcess_LIBS += pvData -exampleEasyProcess_LIBS += Com +PROD_HOST += examplePvaClientProcess +examplePvaClientProcess_SRCS += examplePvaClientProcess.cpp +examplePvaClientProcess_LIBS += pvaClient +examplePvaClientProcess_LIBS += pvAccess +examplePvaClientProcess_LIBS += pvData +examplePvaClientProcess_LIBS += Com -PROD_HOST += exampleEasyGet -exampleEasyGet_SRCS += exampleEasyGet.cpp -exampleEasyGet_LIBS += easyPVA -exampleEasyGet_LIBS += pvAccess -exampleEasyGet_LIBS += pvData -exampleEasyGet_LIBS += Com +PROD_HOST += examplePvaClientGet +examplePvaClientGet_SRCS += examplePvaClientGet.cpp +examplePvaClientGet_LIBS += pvaClient +examplePvaClientGet_LIBS += pvAccess +examplePvaClientGet_LIBS += pvData +examplePvaClientGet_LIBS += Com -PROD_HOST += exampleEasyPut -exampleEasyPut_SRCS += exampleEasyPut.cpp -exampleEasyPut_LIBS += easyPVA -exampleEasyPut_LIBS += pvAccess -exampleEasyPut_LIBS += pvData -exampleEasyPut_LIBS += Com +PROD_HOST += examplePvaClientPut +examplePvaClientPut_SRCS += examplePvaClientPut.cpp +examplePvaClientPut_LIBS += pvaClient +examplePvaClientPut_LIBS += pvAccess +examplePvaClientPut_LIBS += pvData +examplePvaClientPut_LIBS += Com -PROD_HOST += exampleEasyMonitor -exampleEasyMonitor_SRCS += exampleEasyMonitor.cpp -exampleEasyMonitor_LIBS += easyPVA -exampleEasyMonitor_LIBS += pvAccess -exampleEasyMonitor_LIBS += pvData -exampleEasyMonitor_LIBS += Com +PROD_HOST += examplePvaClientMonitor +examplePvaClientMonitor_SRCS += examplePvaClientMonitor.cpp +examplePvaClientMonitor_LIBS += pvaClient +examplePvaClientMonitor_LIBS += pvAccess +examplePvaClientMonitor_LIBS += pvData +examplePvaClientMonitor_LIBS += Com -PROD_HOST += exampleEasyMultiDouble -exampleEasyMultiDouble_SRCS += exampleEasyMultiDouble.cpp -exampleEasyMultiDouble_LIBS += easyPVA -exampleEasyMultiDouble_LIBS += pvAccess -exampleEasyMultiDouble_LIBS += pvData -exampleEasyMultiDouble_LIBS += Com +PROD_HOST += examplePvaClientMultiDouble +examplePvaClientMultiDouble_SRCS += examplePvaClientMultiDouble.cpp +examplePvaClientMultiDouble_LIBS += pvaClient +examplePvaClientMultiDouble_LIBS += pvAccess +examplePvaClientMultiDouble_LIBS += pvData +examplePvaClientMultiDouble_LIBS += Com -PROD_HOST += exampleEasyNTMultiChannel -exampleEasyNTMultiChannel_SRCS += exampleEasyNTMultiChannel.cpp -exampleEasyNTMultiChannel_LIBS += easyPVA -exampleEasyNTMultiChannel_LIBS += pvAccess -exampleEasyNTMultiChannel_LIBS += nt -exampleEasyNTMultiChannel_LIBS += pvData -exampleEasyNTMultiChannel_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 += easyPVA +helloWorldRPC_LIBS += pvaClient helloWorldRPC_LIBS += pvAccess helloWorldRPC_LIBS += nt helloWorldRPC_LIBS += pvData @@ -58,7 +58,7 @@ helloWorldRPC_LIBS += Com PROD_HOST += helloWorldPutGet helloWorldPutGet_SRCS += helloWorldPutGet.cpp -helloWorldPutGet_LIBS += easyPVA +helloWorldPutGet_LIBS += pvaClient helloWorldPutGet_LIBS += pvAccess helloWorldPutGet_LIBS += nt helloWorldPutGet_LIBS += pvData diff --git a/example/src/exampleEasyGet.cpp b/example/src/examplePvaClientGet.cpp similarity index 54% rename from example/src/exampleEasyGet.cpp rename to example/src/examplePvaClientGet.cpp index 97dd6e9..1e7e713 100644 --- a/example/src/exampleEasyGet.cpp +++ b/example/src/examplePvaClientGet.cpp @@ -1,4 +1,4 @@ -/*exampleEasyGet.cpp */ +/*examplePvaClientGet.cpp */ /** * Copyright - See the COPYRIGHT that is included with this distribution. * EPICS pvData is distributed subject to a Software License Agreement found @@ -12,70 +12,70 @@ #include -#include +#include using namespace std; using namespace epics::pvData; using namespace epics::pvAccess; -using namespace epics::easyPVA; +using namespace epics::pvaClient; -static void exampleDouble(EasyPVAPtr const &easyPVA) +static void exampleDouble(PvaClientPtr const &pva) { cout << "example double scalar\n"; double value; try { cout << "short way\n"; - value = easyPVA->channel("exampleDouble")->get()->getData()->getDouble(); + value = pva->channel("exampleDouble")->get()->getData()->getDouble(); cout << "as double " << value << endl; } catch (std::runtime_error e) { cout << "exception " << e.what() << endl; } cout << "long way\n"; - EasyChannelPtr easyChannel = easyPVA->createChannel("exampleDouble"); - easyChannel->issueConnect(); - Status status = easyChannel->waitConnect(2.0); + PvaClientChannelPtr pvaChannel = pva->createChannel("exampleDouble"); + pvaChannel->issueConnect(); + Status status = pvaChannel->waitConnect(2.0); if(!status.isOK()) {cout << " connect failed\n"; return;} - EasyGetPtr easyGet = easyChannel->createGet(); - easyGet->issueConnect(); - status = easyGet->waitConnect(); + PvaClientGetPtr pvaGet = pvaChannel->createGet(); + pvaGet->issueConnect(); + status = pvaGet->waitConnect(); if(!status.isOK()) {cout << " createGet failed\n"; return;} - EasyGetDataPtr easyData = easyGet->getData(); - value = easyData->getDouble(); + PvaClientGetDataPtr pvaData = pvaGet->getData(); + value = pvaData->getDouble(); cout << "as double " << value << endl; } -static void exampleDoubleArray(EasyPVAPtr const &easyPVA) +static void exampleDoubleArray(PvaClientPtr const &pva) { cout << "example double array\n"; shared_vector value; try { cout << "short way\n"; - value = easyPVA->channel("exampleDoubleArray")->get()->getData()->getDoubleArray(); + value = pva->channel("exampleDoubleArray")->get()->getData()->getDoubleArray(); cout << "as doubleArray " << value << endl; } catch (std::runtime_error e) { cout << "exception " << e.what() << endl; } try { cout << "long way\n"; - EasyChannelPtr easyChannel = easyPVA->createChannel("exampleDoubleArray"); - easyChannel->connect(2.0); - EasyGetPtr easyGet = easyChannel->createGet(); - EasyGetDataPtr easyData = easyGet->getData(); - value = easyData->getDoubleArray(); + PvaClientChannelPtr pvaChannel = pva->createChannel("exampleDoubleArray"); + pvaChannel->connect(2.0); + PvaClientGetPtr pvaGet = pvaChannel->createGet(); + PvaClientGetDataPtr pvaData = pvaGet->getData(); + value = pvaData->getDoubleArray(); cout << "as doubleArray " << value << endl; } catch (std::runtime_error e) { cout << "exception " << e.what() << endl; } } -static void examplePowerSupply(EasyPVAPtr const &easyPVA) +static void examplePowerSupply(PvaClientPtr const &pva) { cout << "example powerSupply\n"; PVStructurePtr pvStructure; try { cout << "short way\n"; - pvStructure = easyPVA->channel("examplePowerSupply")-> + pvStructure = pva->channel("examplePowerSupply")-> get("field()")->getData()->getPVStructure(); cout << pvStructure << endl; } catch (std::runtime_error e) { @@ -84,49 +84,49 @@ static void examplePowerSupply(EasyPVAPtr const &easyPVA) } -static void exampleCADouble(EasyPVAPtr const &easyPVA) +static void exampleCADouble(PvaClientPtr const &pva) { cout << "example double scalar\n"; double value; try { cout << "short way\n"; - value = easyPVA->channel("double00","ca",5.0)->get()->getData()->getDouble(); + value = pva->channel("double00","ca",5.0)->get()->getData()->getDouble(); cout << "as double " << value << endl; } catch (std::runtime_error e) { cout << "exception " << e.what() << endl; } cout << "long way\n"; - EasyChannelPtr easyChannel = easyPVA->createChannel("double00","ca"); - easyChannel->issueConnect(); - Status status = easyChannel->waitConnect(2.0); + PvaClientChannelPtr pvaChannel = pva->createChannel("double00","ca"); + pvaChannel->issueConnect(); + Status status = pvaChannel->waitConnect(2.0); if(!status.isOK()) {cout << " connect failed\n"; return;} - EasyGetPtr easyGet = easyChannel->createGet(); - easyGet->issueConnect(); - status = easyGet->waitConnect(); + PvaClientGetPtr pvaGet = pvaChannel->createGet(); + pvaGet->issueConnect(); + status = pvaGet->waitConnect(); if(!status.isOK()) {cout << " createGet failed\n"; return;} - EasyGetDataPtr easyData = easyGet->getData(); - value = easyData->getDouble(); + PvaClientGetDataPtr pvaData = pvaGet->getData(); + value = pvaData->getDouble(); cout << "as double " << value << endl; } -static void exampleCADoubleArray(EasyPVAPtr const &easyPVA) +static void exampleCADoubleArray(PvaClientPtr const &pva) { cout << "example double array\n"; shared_vector value; try { cout << "short way\n"; - value = easyPVA->channel("doubleArray","ca",5.0)->get()->getData()->getDoubleArray(); + value = pva->channel("doubleArray","ca",5.0)->get()->getData()->getDoubleArray(); cout << "as doubleArray " << value << endl; } catch (std::runtime_error e) { cout << "exception " << e.what() << endl; } try { cout << "long way\n"; - EasyChannelPtr easyChannel = easyPVA->createChannel("doubleArray","ca"); - easyChannel->connect(2.0); - EasyGetPtr easyGet = easyChannel->createGet(); - EasyGetDataPtr easyData = easyGet->getData(); - value = easyData->getDoubleArray(); + PvaClientChannelPtr pvaChannel = pva->createChannel("doubleArray","ca"); + pvaChannel->connect(2.0); + PvaClientGetPtr pvaGet = pvaChannel->createGet(); + PvaClientGetDataPtr pvaData = pvaGet->getData(); + value = pvaData->getDoubleArray(); cout << "as doubleArray " << value << endl; } catch (std::runtime_error e) { cout << "exception " << e.what() << endl; @@ -135,12 +135,12 @@ static void exampleCADoubleArray(EasyPVAPtr const &easyPVA) int main(int argc,char *argv[]) { - EasyPVAPtr easyPVA = EasyPVA::create(); - exampleDouble(easyPVA); - exampleDoubleArray(easyPVA); - examplePowerSupply(easyPVA); - exampleCADouble(easyPVA); - exampleCADoubleArray(easyPVA); + PvaClientPtr pva= PvaClient::create(); + exampleDouble(pva); + exampleDoubleArray(pva); + examplePowerSupply(pva); + exampleCADouble(pva); + exampleCADoubleArray(pva); cout << "done\n"; return 0; } diff --git a/example/src/exampleEasyMonitor.cpp b/example/src/examplePvaClientMonitor.cpp similarity index 59% rename from example/src/exampleEasyMonitor.cpp rename to example/src/examplePvaClientMonitor.cpp index 111b77e..e459bab 100644 --- a/example/src/exampleEasyMonitor.cpp +++ b/example/src/examplePvaClientMonitor.cpp @@ -1,4 +1,4 @@ -/*monitorPowerSupply.cpp */ +/*examplePvaClientClientMonitor.cpp */ /** * Copyright - See the COPYRIGHT that is included with this distribution. * EPICS pvData is distributed subject to a Software License Agreement found @@ -14,24 +14,24 @@ #include -#include +#include using namespace std; using namespace epics::pvData; using namespace epics::pvAccess; -using namespace epics::easyPVA; +using namespace epics::pvaClient; -static void exampleMonitor(EasyPVAPtr const &easyPVA) +static void exampleMonitor(PvaClientPtr const &pva) { - EasyMonitorPtr monitor = easyPVA->channel("examplePowerSupply")->monitor(""); - EasyMonitorDataPtr easyData = monitor->getData(); + PvaClientMonitorPtr monitor = pva->channel("examplePowerSupply")->monitor(""); + PvaClientMonitorDataPtr pvaData = monitor->getData(); while(true) { monitor->waitEvent(); cout << "changed\n"; - easyData->showChanged(cout); + pvaData->showChanged(cout); cout << "overrun\n"; - easyData->showOverrun(cout); + pvaData->showOverrun(cout); monitor->releaseEvent(); } } @@ -39,8 +39,8 @@ static void exampleMonitor(EasyPVAPtr const &easyPVA) int main(int argc,char *argv[]) { - EasyPVAPtr easyPVA = EasyPVA::create(); - exampleMonitor(easyPVA); + PvaClientPtr pva = PvaClient::create(); + exampleMonitor(pva); cout << "done\n"; return 0; } diff --git a/example/src/exampleEasyMultiDouble.cpp b/example/src/examplePvaClientMultiDouble.cpp similarity index 81% rename from example/src/exampleEasyMultiDouble.cpp rename to example/src/examplePvaClientMultiDouble.cpp index 681ae0a..c58cf37 100644 --- a/example/src/exampleEasyMultiDouble.cpp +++ b/example/src/examplePvaClientMultiDouble.cpp @@ -1,4 +1,4 @@ -/*exampleEasyMultiDouble.cpp */ +/*examplePvaClientMultiDouble.cpp */ /** * Copyright - See the COPYRIGHT that is included with this distribution. * EPICS pvData is distributed subject to a Software License Agreement found @@ -12,15 +12,15 @@ #include -#include +#include using namespace std; using namespace epics::pvData; using namespace epics::pvAccess; -using namespace epics::easyPVA; +using namespace epics::pvaClient; -static void example(EasyPVAPtr const &easyPVA) +static void example(PvaClientPtr const &pva) { cout << "example multiDouble\n"; size_t num = 5; @@ -33,7 +33,7 @@ static void example(EasyPVAPtr const &easyPVA) PVStringArrayPtr pvNames = getPVDataCreate()->createPVScalarArray(); pvNames->replace(freeze(channelNames)); - EasyMultiDoublePtr multiDouble(EasyMultiDouble::create(easyPVA,pvNames)); + PvaClientMultiDoublePtr multiDouble(PvaClientMultiDouble::create(pva,pvNames)); try { shared_vector data = multiDouble->get(); cout << "initial " << data << endl; @@ -47,7 +47,7 @@ static void example(EasyPVAPtr const &easyPVA) } -static void exampleCA(EasyPVAPtr const &easyPVA) +static void exampleCA(PvaClientPtr const &pva) { cout << "example multiDouble\n"; size_t num = 5; @@ -60,7 +60,7 @@ static void exampleCA(EasyPVAPtr const &easyPVA) PVStringArrayPtr pvNames = getPVDataCreate()->createPVScalarArray(); pvNames->replace(freeze(channelNames)); - EasyMultiDoublePtr multiDouble(EasyMultiDouble::create(easyPVA,pvNames,5.0,"ca")); + PvaClientMultiDoublePtr multiDouble(PvaClientMultiDouble::create(pva,pvNames,5.0,"ca")); try { shared_vector data = multiDouble->get(); cout << "initial " << data << endl; @@ -77,8 +77,8 @@ static void exampleCA(EasyPVAPtr const &easyPVA) int main(int argc,char *argv[]) { - EasyPVAPtr easyPVA = EasyPVA::create(); - example(easyPVA); - exampleCA(easyPVA); + PvaClientPtr pva = PvaClient::create(); + example(pva); + exampleCA(pva); return 0; } diff --git a/example/src/exampleEasyNTMultiChannel.cpp b/example/src/examplePvaClientNTMultiChannel.cpp similarity index 80% rename from example/src/exampleEasyNTMultiChannel.cpp rename to example/src/examplePvaClientNTMultiChannel.cpp index ca02edd..c175708 100644 --- a/example/src/exampleEasyNTMultiChannel.cpp +++ b/example/src/examplePvaClientNTMultiChannel.cpp @@ -1,4 +1,4 @@ -/*exampleEasyNTMultiChannel.cpp */ +/*examplePvaClientNTMultiChannel.cpp */ /** * Copyright - See the COPYRIGHT that is included with this distribution. * EPICS pvData is distributed subject to a Software License Agreement found @@ -12,16 +12,16 @@ #include -#include +#include using namespace std; using namespace epics::pvData; using namespace epics::pvAccess; -using namespace epics::easyPVA; +using namespace epics::pvaClient; using namespace epics::nt; -static void example(EasyPVAPtr const &easyPVA) +static void example(PvaClientPtr const &pva) { cout << "example ntMultiChannel\n"; size_t num = 5; @@ -44,10 +44,10 @@ static void example(EasyPVAPtr const &easyPVA) addNanoseconds() -> addUserTag() -> createStructure(); - EasyNTMultiChannelPtr easy = EasyNTMultiChannel::create( - easyPVA,pvNames,structure); + PvaClientNTMultiChannelPtr multi = PvaClientNTMultiChannel::create( + pva,pvNames,structure); try { - NTMultiChannelPtr nt = easy->get(); + NTMultiChannelPtr nt = multi->get(); cout << "initial\n" << nt->getPVStructure() << endl; } catch (std::runtime_error e) { @@ -56,7 +56,7 @@ static void example(EasyPVAPtr const &easyPVA) } -static void exampleCA(EasyPVAPtr const &easyPVA) +static void exampleCA(PvaClientPtr const &pva) { cout << "example ntMultiChannel\n"; size_t num = 5; @@ -79,10 +79,10 @@ static void exampleCA(EasyPVAPtr const &easyPVA) addNanoseconds() -> addUserTag() -> createStructure(); - EasyNTMultiChannelPtr easy = EasyNTMultiChannel::create( - easyPVA,pvNames,structure,5.0,"ca"); + PvaClientNTMultiChannelPtr multi = PvaClientNTMultiChannel::create( + pva,pvNames,structure,5.0,"ca"); try { - NTMultiChannelPtr nt = easy->get(); + NTMultiChannelPtr nt = multi->get(); cout << "initial\n" << nt->getPVStructure() << endl; } catch (std::runtime_error e) { @@ -94,8 +94,8 @@ static void exampleCA(EasyPVAPtr const &easyPVA) int main(int argc,char *argv[]) { - EasyPVAPtr easyPVA = EasyPVA::create(); - example(easyPVA); - exampleCA(easyPVA); + PvaClientPtr pva = PvaClient::create(); + example(pva); + exampleCA(pva); return 0; } diff --git a/example/src/exampleEasyProcess.cpp b/example/src/examplePvaClientProcess.cpp similarity index 69% rename from example/src/exampleEasyProcess.cpp rename to example/src/examplePvaClientProcess.cpp index 1c671d9..43571c4 100644 --- a/example/src/exampleEasyProcess.cpp +++ b/example/src/examplePvaClientProcess.cpp @@ -1,4 +1,4 @@ -/*exampleEasyProcess.cpp */ +/*examplePvaClientProcess.cpp */ /** * Copyright - See the COPYRIGHT that is included with this distribution. * EPICS pvData is distributed subject to a Software License Agreement found @@ -12,19 +12,19 @@ #include -#include +#include using namespace std; using namespace epics::pvData; using namespace epics::pvAccess; -using namespace epics::easyPVA; +using namespace epics::pvaClient; -static void exampleProcess(EasyPVAPtr const &easyPVA) +static void exampleProcess(PvaClientPtr const &pva) { cout << "example process\n"; - EasyChannelPtr channel = easyPVA->channel("exampleDouble"); - EasyProcessPtr process = channel->createProcess(); + PvaClientChannelPtr channel = pva->channel("exampleDouble"); + PvaClientProcessPtr process = channel->createProcess(); try { process->process(); cout << channel->get("field()")->getData()->showChanged(cout) << endl; @@ -38,7 +38,7 @@ static void exampleProcess(EasyPVAPtr const &easyPVA) int main(int argc,char *argv[]) { - EasyPVAPtr easyPVA = EasyPVA::create(); - exampleProcess(easyPVA); + PvaClientPtr pva = PvaClient::create(); + exampleProcess(pva); return 0; } diff --git a/example/src/exampleEasyPut.cpp b/example/src/examplePvaClientPut.cpp similarity index 69% rename from example/src/exampleEasyPut.cpp rename to example/src/examplePvaClientPut.cpp index 6f3d02d..a7f87e1 100644 --- a/example/src/exampleEasyPut.cpp +++ b/example/src/examplePvaClientPut.cpp @@ -1,4 +1,4 @@ -/*exampleEasyPut.cpp */ +/*examplePvaClientPut.cpp */ /** * Copyright - See the COPYRIGHT that is included with this distribution. * EPICS pvData is distributed subject to a Software License Agreement found @@ -12,20 +12,20 @@ #include -#include +#include using namespace std; using namespace epics::pvData; using namespace epics::pvAccess; -using namespace epics::easyPVA; +using namespace epics::pvaClient; -static void examplePut(EasyPVAPtr const &easyPVA) +static void examplePut(PvaClientPtr const &pva) { cout << "example put\n"; - EasyChannelPtr channel = easyPVA->channel("exampleDouble"); - EasyPutPtr put = channel->put(); - EasyPutDataPtr putData = put->getData(); + PvaClientChannelPtr channel = pva->channel("exampleDouble"); + PvaClientPutPtr put = channel->put(); + PvaClientPutDataPtr putData = put->getData(); try { putData->putDouble(3.0); put->put(); cout << channel->get("field()")->getData()->showChanged(cout) << endl; @@ -39,7 +39,7 @@ static void examplePut(EasyPVAPtr const &easyPVA) int main(int argc,char *argv[]) { - EasyPVAPtr easyPVA = EasyPVA::create(); - examplePut(easyPVA); + PvaClientPtr pva = PvaClient::create(); + examplePut(pva); return 0; } diff --git a/example/src/helloWorldPutGet.cpp b/example/src/helloWorldPutGet.cpp index f826de1..58f784d 100644 --- a/example/src/helloWorldPutGet.cpp +++ b/example/src/helloWorldPutGet.cpp @@ -12,27 +12,27 @@ #include -#include +#include using namespace std; using namespace epics::pvData; using namespace epics::pvAccess; -using namespace epics::easyPVA; +using namespace epics::pvaClient; -static void example(EasyPVAPtr const &easyPVA) +static void example(PvaClientPtr const &pva) { cout << "helloWorldPutGet\n"; try { - EasyChannelPtr channel = easyPVA->channel("exampleHello"); - EasyPutGetPtr putGet = channel->createPutGet(); + PvaClientChannelPtr channel = pva->channel("exampleHello"); + PvaClientPutGetPtr putGet = channel->createPutGet(); putGet->connect(); - EasyPutDataPtr putData = putGet->getPutData(); + PvaClientPutDataPtr putData = putGet->getPutData(); PVStructurePtr arg = putData->getPVStructure(); PVStringPtr pvValue = arg->getSubField("argument.value"); pvValue->put("World"); putGet->putGet(); - EasyGetDataPtr getData = putGet->getGetData(); + PvaClientGetDataPtr getData = putGet->getGetData(); cout << getData->getPVStructure() << endl; } catch (std::runtime_error e) { cout << "exception " << e.what() << endl; @@ -42,7 +42,7 @@ static void example(EasyPVAPtr const &easyPVA) int main(int argc,char *argv[]) { - EasyPVAPtr easyPVA = EasyPVA::create(); - example(easyPVA); + PvaClientPtr pva = PvaClient::create(); + example(pva); return 0; } diff --git a/example/src/helloWorldRPC.cpp b/example/src/helloWorldRPC.cpp index 9106842..238aad3 100644 --- a/example/src/helloWorldRPC.cpp +++ b/example/src/helloWorldRPC.cpp @@ -1,4 +1,4 @@ -/*exampleChannelRPC.cpp */ +/*helloWorldRPC.cpp */ /** * Copyright - See the COPYRIGHT that is included with this distribution. * EPICS pvData is distributed subject to a Software License Agreement found diff --git a/exampleDatabaseEasyPVA.zip b/exampleDatabasePvaClient.zip similarity index 100% rename from exampleDatabaseEasyPVA.zip rename to exampleDatabasePvaClient.zip diff --git a/src/Makefile b/src/Makefile index 29d25fb..f61bab4 100644 --- a/src/Makefile +++ b/src/Makefile @@ -3,29 +3,28 @@ TOP = .. include $(TOP)/configure/CONFIG -LIBRARY += easyPVA +LIBRARY += pvaClient -INC += easyPVA.h -INC += easyMultiDouble.h -INC += easyNTMultiChannel.h +INC += pvaClient.h +INC += pvaClientMultiDouble.h +INC += pvaClientNTMultiChannel.h -LIBSRCS += easyPVA.cpp -LIBSRCS += easyPutData.cpp -LIBSRCS += easyGetData.cpp -LIBSRCS += easyMonitorData.cpp -LIBSRCS += easyChannel.cpp -LIBSRCS += easyProcess.cpp -LIBSRCS += easyGet.cpp -LIBSRCS += easyPut.cpp -LIBSRCS += easyMonitor.cpp -LIBSRCS += easyPutGet.cpp -LIBSRCS += easyMultiChannel.cpp -LIBSRCS += easyMultiDouble.cpp -LIBSRCS += easyNTMultiChannel.cpp -#LIBSRCS += easyRPC.cpp +LIBSRCS += pvaClient.cpp +LIBSRCS += pvaClientPutData.cpp +LIBSRCS += pvaClientGetData.cpp +LIBSRCS += pvaClientMonitorData.cpp +LIBSRCS += pvaClientChannel.cpp +LIBSRCS += pvaClientProcess.cpp +LIBSRCS += pvaClientGet.cpp +LIBSRCS += pvaClientPut.cpp +LIBSRCS += pvaClientMonitor.cpp +LIBSRCS += pvaClientPutGet.cpp +LIBSRCS += pvaClientMultiChannel.cpp +LIBSRCS += pvaClientMultiDouble.cpp +LIBSRCS += pvaClientNTMultiChannel.cpp -easyPVA_LIBS += pvAccess pvData nt Com -easyPVA_LIBS += $(EPICS_BASE_IOC_LIBS) +pvaClient_LIBS += pvAccess pvData nt Com +pvaClient_LIBS += $(EPICS_BASE_IOC_LIBS) include $(TOP)/configure/RULES diff --git a/src/easyChannel.cpp b/src/easyChannel.cpp deleted file mode 100644 index 43f02ce..0000000 --- a/src/easyChannel.cpp +++ /dev/null @@ -1,495 +0,0 @@ -/* easyChannel.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 -#include -#include -#include -#include -#include - - -using std::tr1::static_pointer_cast; -using namespace epics::pvData; -using namespace epics::pvAccess; -using namespace std; - -namespace epics { namespace easyPVA { - - -class EasyGetCache -{ -public: - EasyGetCache(){} - ~EasyGetCache(); - void destroy() { - easyGetMap.clear(); - } - EasyGetPtr getGet(string const & request); - void addGet(string const & request,EasyGetPtr const & easyGet); -private: - map easyGetMap; -}; - -EasyGetCache::~EasyGetCache() -{ - destroy(); -} - -EasyGetPtr EasyGetCache::getGet(string const & request) -{ - map::iterator iter = easyGetMap.find(request); - if(iter!=easyGetMap.end()) return iter->second; - return EasyGetPtr(); -} - -void EasyGetCache::addGet(string const & request,EasyGetPtr const & easyGet) -{ - easyGetMap.insert(std::pair( - request,easyGet)); -} - - -class EasyPutCache -{ -public: - EasyPutCache(){} - ~EasyPutCache(); - void destroy() { - easyPutMap.clear(); - } - EasyPutPtr getPut(string const & request); - void addPut(string const & request,EasyPutPtr const & easyPut); -private: - map easyPutMap; -}; - -EasyPutCache::~EasyPutCache() -{ - destroy(); -} - -EasyPutPtr EasyPutCache::getPut(string const & request) -{ - map::iterator iter = easyPutMap.find(request); - if(iter!=easyPutMap.end()) return iter->second; - return EasyPutPtr(); -} - -void EasyPutCache::addPut(string const & request,EasyPutPtr const & easyPut) -{ - easyPutMap.insert(std::pair( - request,easyPut)); -} - -class ChannelRequesterImpl : public ChannelRequester -{ - EasyChannel *easyChannel; -public: - ChannelRequesterImpl(EasyChannel *easyChannel) - : easyChannel(easyChannel) {} - void channelCreated( - const Status& status, - Channel::shared_pointer const & channel) - { easyChannel->channelCreated(status,channel); } - void channelStateChange( - Channel::shared_pointer const & channel, - Channel::ConnectionState connectionState) - {easyChannel->channelStateChange(channel,connectionState);} - tr1::shared_ptr getChannel() {return easyChannel->getChannel();} - string getRequesterName() - {return easyChannel->getRequesterName();} - void message( - string const & message, - MessageType messageType) - { easyChannel->message(message,messageType); } - void destroy() {easyChannel->destroy();} -}; - - -EasyChannel::EasyChannel( - EasyPVAPtr const &easyPVA, - string const & channelName, - string const & providerName) -: easyPVA(easyPVA), - channelName(channelName), - providerName(providerName), - connectState(connectIdle), - isDestroyed(false), - createRequest(CreateRequest::create()), - easyGetCache(new EasyGetCache()), - easyPutCache(new EasyPutCache()) -{} - -EasyChannel::~EasyChannel() -{ - destroy(); -} - -void EasyChannel::channelCreated(const Status& status, Channel::shared_pointer const & channel) -{ - if(isDestroyed) throw std::runtime_error("easyChannel was destroyed"); - if(status.isOK()) { - this->channel = channel; - return; - } - cout << "EasyChannel::channelCreated status " << status.getMessage() << " why??\n"; -} - -void EasyChannel::channelStateChange( - Channel::shared_pointer const & channel, - Channel::ConnectionState connectionState) -{ - if(isDestroyed) return; - bool waitingForConnect = false; - if(connectState==connectActive) waitingForConnect = true; - if(connectionState!=Channel::CONNECTED) { - string mess(channelName + - " connection state " + Channel::ConnectionStateNames[connectionState]); - message(mess,errorMessage); - channelConnectStatus = Status(Status::STATUSTYPE_ERROR,mess); - connectState = notConnected; - } else { - connectState = connected; - } - if(waitingForConnect) waitForConnect.signal(); -} - -string EasyChannel::getRequesterName() -{ - EasyPVAPtr yyy = easyPVA.lock(); - if(!yyy) throw std::runtime_error("EasyPVA was destroyed"); - return yyy->getRequesterName(); -} - -void EasyChannel::message( - string const & message, - MessageType messageType) -{ - if(isDestroyed) throw std::runtime_error("easyChannel was destroyed"); - EasyPVAPtr yyy = easyPVA.lock(); - if(!yyy) throw std::runtime_error("EasyPVA was destroyed"); - yyy->message(message, messageType); -} - -void EasyChannel::destroy() -{ - { - Lock xx(mutex); - if(isDestroyed) return; - isDestroyed = true; - } - if(channel) channel->destroy(); - channel.reset(); - easyGetCache.reset(); - easyPutCache.reset(); -} - -string EasyChannel::getChannelName() -{ - if(isDestroyed) throw std::runtime_error("easyChannel was destroyed"); - return channelName; -} - -Channel::shared_pointer EasyChannel::getChannel() -{ - if(isDestroyed) throw std::runtime_error("easyChannel was destroyed"); - return channel; -} - -void EasyChannel::connect(double timeout) -{ - if(isDestroyed) throw std::runtime_error("easyChannel was destroyed"); - issueConnect(); - Status status = waitConnect(timeout); - if(status.isOK()) return; - stringstream ss; - ss << "channel " << getChannelName() << " EasyChannel::connect " << status.getMessage(); - throw std::runtime_error(ss.str()); -} - -void EasyChannel::issueConnect() -{ - if(isDestroyed) throw std::runtime_error("easyChannel was destroyed"); - if(connectState!=connectIdle) { - throw std::runtime_error("easyChannel already connected"); - } - channelRequester = ChannelRequester::shared_pointer(new ChannelRequesterImpl(this)); - - channelConnectStatus = Status( - Status::STATUSTYPE_ERROR, - getChannelName() + " createChannel failed"); - connectState = connectActive; - ChannelProviderRegistry::shared_pointer reg = getChannelProviderRegistry(); - ChannelProvider::shared_pointer provider = reg->getProvider(providerName); - if(!provider) { - throw std::runtime_error(getChannelName() + " provider " + providerName + " not registered"); - } - channel = provider->createChannel(channelName,channelRequester,ChannelProvider::PRIORITY_DEFAULT); - if(!channel) { - throw std::runtime_error(channelConnectStatus.getMessage()); - } -} - -Status EasyChannel::waitConnect(double timeout) -{ - if(isDestroyed) throw std::runtime_error("easyChannel was destroyed"); - waitForConnect.wait(timeout); - if(connectState==connected) return Status::Ok; - return Status(Status::STATUSTYPE_ERROR,channelConnectStatus.getMessage()); -} - -EasyFieldPtr EasyChannel::createField() -{ - return createField(""); -} - -EasyFieldPtr EasyChannel::createField(string const & subField) -{ - throw std::runtime_error("EasyChannel::createField not implemented"); -} - -EasyProcessPtr EasyChannel::createProcess() -{ - return createProcess(""); -} - -EasyProcessPtr EasyChannel::createProcess(string const & request) -{ - PVStructurePtr pvRequest = createRequest->createRequest(request); - if(!pvRequest) { - stringstream ss; - ss << "channel " << getChannelName(); - ss << " EasyChannel::createProcess invalid pvRequest: " + createRequest->getMessage(); - throw std::runtime_error(ss.str()); - } - return createProcess(pvRequest); -} - -EasyProcessPtr EasyChannel::createProcess(PVStructurePtr const & pvRequest) -{ - if(connectState!=connected) connect(5.0); - if(connectState!=connected) throw std::runtime_error("EasyChannel::creatProcess not connected"); - EasyPVAPtr yyy = easyPVA.lock(); - if(!yyy) throw std::runtime_error("EasyPVA was destroyed"); - return EasyProcess::create(yyy,getPtrSelf(),channel,pvRequest); -} - -EasyGetPtr EasyChannel::get() {return get("value,alarm,timeStamp");} - -EasyGetPtr EasyChannel::get(string const & request) -{ - EasyGetPtr easyGet = easyGetCache->getGet(request); - if(easyGet) return easyGet; - easyGet = createGet(request); - easyGet->connect(); - easyGetCache->addGet(request,easyGet); - return easyGet; -} - -EasyGetPtr EasyChannel::createGet() -{ - return EasyChannel::createGet("value,alarm,timeStamp"); -} - -EasyGetPtr EasyChannel::createGet(string const & request) -{ - PVStructurePtr pvRequest = createRequest->createRequest(request); - if(!pvRequest) { - stringstream ss; - ss << "channel " << getChannelName(); - ss << " EasyChannel::createGet invalid pvRequest: " + createRequest->getMessage(); - throw std::runtime_error(ss.str()); - } - return createGet(pvRequest); -} - -EasyGetPtr EasyChannel::createGet(PVStructurePtr const & pvRequest) -{ - if(connectState!=connected) connect(5.0); - if(connectState!=connected) throw std::runtime_error("EasyChannel::creatGet not connected"); - EasyPVAPtr yyy = easyPVA.lock(); - if(!yyy) throw std::runtime_error("EasyPVA was destroyed"); - return EasyGet::create(yyy,getPtrSelf(),channel,pvRequest); -} - -EasyPutPtr EasyChannel::put() {return put("value");} - -EasyPutPtr EasyChannel::put(string const & request) -{ - EasyPutPtr easyPut = easyPutCache->getPut(request); - if(easyPut) return easyPut; - easyPut = createPut(request); - easyPut->connect(); - easyPut->get(); - easyPutCache->addPut(request,easyPut); - return easyPut; -} - -EasyPutPtr EasyChannel::createPut() -{ - return createPut("value"); -} - -EasyPutPtr EasyChannel::createPut(string const & request) -{ - PVStructurePtr pvRequest = createRequest->createRequest(request); - if(!pvRequest) { - stringstream ss; - ss << "channel " << getChannelName(); - ss << " EasyChannel::createPut invalid pvRequest: " + createRequest->getMessage(); - throw std::runtime_error(ss.str()); - } - return createPut(pvRequest); -} - -EasyPutPtr EasyChannel::createPut(PVStructurePtr const & pvRequest) -{ - if(connectState!=connected) connect(5.0); - if(connectState!=connected) throw std::runtime_error("EasyChannel::creatPut not connected"); - EasyPVAPtr yyy = easyPVA.lock(); - if(!yyy) throw std::runtime_error("EasyPVA was destroyed"); - return EasyPut::create(yyy,getPtrSelf(),channel,pvRequest); -} - -EasyPutGetPtr EasyChannel::createPutGet() -{ - return createPutGet("putField(argument)getField(result)"); -} - -EasyPutGetPtr EasyChannel::createPutGet(string const & request) -{ - PVStructurePtr pvRequest = createRequest->createRequest(request); - if(!pvRequest) { - stringstream ss; - ss << "channel " << getChannelName(); - ss << " EasyChannel::createPutGet invalid pvRequest: " + createRequest->getMessage(); - throw std::runtime_error(ss.str()); - } - return createPutGet(pvRequest); -} - -EasyPutGetPtr EasyChannel::createPutGet(PVStructurePtr const & pvRequest) -{ - if(connectState!=connected) connect(5.0); - if(connectState!=connected) throw std::runtime_error("EasyChannel::creatPutGet not connected"); - EasyPVAPtr yyy = easyPVA.lock(); - if(!yyy) throw std::runtime_error("EasyPVA was destroyed"); - return EasyPutGet::create(yyy,getPtrSelf(),channel,pvRequest); -} - -EasyRPCPtr EasyChannel::createRPC() -{ - return createRPC(""); -} - -EasyRPCPtr EasyChannel::createRPC(string const & request) -{ - PVStructurePtr pvRequest = createRequest->createRequest(request); - if(!pvRequest) { - stringstream ss; - ss << "channel " << getChannelName(); - ss << " EasyChannel::createRPC invalid pvRequest: " + createRequest->getMessage(); - throw std::runtime_error(ss.str()); - } - return createRPC(pvRequest); -} - -EasyRPCPtr EasyChannel::createRPC(PVStructurePtr const & pvRequest) -{ - throw std::runtime_error("EasyChannel::createRPC not implemented"); -} - -EasyArrayPtr EasyChannel::createArray() -{ - return createArray("value"); -} - -EasyArrayPtr EasyChannel::createArray(string const & request) -{ - PVStructurePtr pvRequest = createRequest->createRequest(request); - if(!pvRequest) { - stringstream ss; - ss << "channel " << getChannelName(); - ss << " EasyChannel::createArray invalid pvRequest: " + createRequest->getMessage(); - throw std::runtime_error(ss.str()); - } - return createArray(pvRequest); -} - -EasyArrayPtr EasyChannel::createArray(PVStructurePtr const & pvRequest) -{ - throw std::runtime_error("EasyChannel::createArray not implemented"); -} - - -EasyMonitorPtr EasyChannel::monitor() {return monitor("value,alarm,timeStamp");} - -EasyMonitorPtr EasyChannel::monitor(string const & request) -{ - EasyMonitorPtr easyMonitor = createMonitor(request); - easyMonitor->connect(); - easyMonitor->start(); - return easyMonitor; -} - -EasyMonitorPtr EasyChannel::monitor(EasyMonitorRequesterPtr const & easyMonitorRequester) -{ return monitor("value,alarm,timeStamp",easyMonitorRequester); -} - -EasyMonitorPtr EasyChannel::monitor(string const & request, - EasyMonitorRequesterPtr const & easyMonitorRequester) -{ - EasyMonitorPtr easyMonitor = createMonitor(request); - easyMonitor->connect(); - easyMonitor->setRequester(easyMonitorRequester); - easyMonitor->start(); - return easyMonitor; -} - -EasyMonitorPtr EasyChannel::createMonitor() -{ - return createMonitor("value,alarm,timeStamp"); -} - -EasyMonitorPtr EasyChannel::createMonitor(string const & request) -{ - PVStructurePtr pvRequest = createRequest->createRequest(request); - if(!pvRequest) { - stringstream ss; - ss << "channel " << getChannelName(); - ss << " EasyChannel::createMonitor invalid pvRequest: " + createRequest->getMessage(); - throw std::runtime_error(ss.str()); - } - return createMonitor(pvRequest); -} - -EasyMonitorPtr EasyChannel::createMonitor(PVStructurePtr const & pvRequest) -{ - if(connectState!=connected) connect(5.0); - if(connectState!=connected) throw std::runtime_error("EasyChannel::createMonitor not connected"); - EasyPVAPtr yyy = easyPVA.lock(); - if(!yyy) throw std::runtime_error("EasyPVA was destroyed"); - return EasyMonitor::create(yyy,getPtrSelf(),channel,pvRequest); -} - - -EasyChannelPtr EasyChannel::create( - EasyPVAPtr const &easyPVA, - string const & channelName, - string const & providerName) -{ - EasyChannelPtr channel(new EasyChannel(easyPVA,channelName,providerName)); - return channel; -} - -}} diff --git a/src/easyMonitor.cpp b/src/easyMonitor.cpp deleted file mode 100644 index c862737..0000000 --- a/src/easyMonitor.cpp +++ /dev/null @@ -1,250 +0,0 @@ -/* easyMonitor.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 -#include -#include -#include - -using std::tr1::static_pointer_cast; -using namespace epics::pvData; -using namespace epics::pvAccess; -using namespace std; - -namespace epics { namespace easyPVA { - - -class ChannelMonitorRequester : public MonitorRequester -{ - EasyMonitor * easyMonitor; -public: - ChannelMonitorRequester(EasyMonitor * easyMonitor) - : easyMonitor(easyMonitor) {} - string getRequesterName() - {return easyMonitor->getRequesterName();} - void message(string const & message,MessageType messageType) - {easyMonitor->message(message,messageType);} - void monitorConnect( - const Status& status, - Monitor::shared_pointer const & monitor, - StructureConstPtr const & structure) - {easyMonitor->monitorConnect(status,monitor,structure);} - void monitorEvent(MonitorPtr const & monitor) - { - easyMonitor->monitorEvent(monitor); - } - void unlisten(MonitorPtr const & monitor) - {easyMonitor->unlisten();} -}; - -EasyMonitor::EasyMonitor( - EasyPVAPtr const &pva, - EasyChannelPtr const & easyChannel, - Channel::shared_pointer const & channel, - PVStructurePtr const &pvRequest) -: easyPVA(pva), - easyChannel(easyChannel), - channel(channel), - pvRequest(pvRequest), - isDestroyed(false), - connectState(connectIdle), - userPoll(false), - userWait(false) -{ -} - -EasyMonitor::~EasyMonitor() -{ - destroy(); -} - -void EasyMonitor::checkMonitorState() -{ - if(isDestroyed) throw std::runtime_error("easyMonitor was destroyed"); - if(connectState==connectIdle) connect(); - if(connectState==connected) start(); -} - -// from MonitorRequester -string EasyMonitor::getRequesterName() -{ - EasyPVAPtr yyy = easyPVA.lock(); - if(!yyy) throw std::runtime_error("easyPVA was destroyed"); - return yyy->getRequesterName(); -} - -void EasyMonitor::message(string const & message,MessageType messageType) -{ - if(isDestroyed) throw std::runtime_error("easyMonitor was destroyed"); - EasyPVAPtr yyy = easyPVA.lock(); - if(!yyy) throw std::runtime_error("easyPVA was destroyed"); - yyy->message(message, messageType); -} - -void EasyMonitor::monitorConnect( - const Status& status, - Monitor::shared_pointer const & monitor, - StructureConstPtr const & structure) -{ - if(isDestroyed) throw std::runtime_error("easyMonitor was destroyed"); - connectStatus = status; - this->monitor = monitor; - if(status.isOK()) { - easyData = EasyMonitorData::create(structure); - easyData->setMessagePrefix(channel->getChannelName()); - } - waitForConnect.signal(); - -} - -void EasyMonitor::monitorEvent(MonitorPtr const & monitor) -{ - EasyMonitorRequesterPtr req = easyMonitorRequester.lock(); - if(req) req->event(getPtrSelf()); - if(userWait) waitForEvent.signal(); -} - -void EasyMonitor::unlisten() -{ - destroy(); -} - -// from EasyMonitor -void EasyMonitor::destroy() -{ - { - Lock xx(mutex); - if(isDestroyed) return; - isDestroyed = true; - } - if(monitor) monitor->destroy(); - monitor.reset(); -} - -void EasyMonitor::connect() -{ - if(isDestroyed) throw std::runtime_error("easyMonitor was destroyed"); - issueConnect(); - Status status = waitConnect(); - if(status.isOK()) return; - stringstream ss; - ss << "channel " << channel->getChannelName() << " EasyMonitor::connect " << status.getMessage(); - throw std::runtime_error(ss.str()); -} - -void EasyMonitor::issueConnect() -{ - if(isDestroyed) throw std::runtime_error("easyMonitor was destroyed"); - if(connectState!=connectIdle) { - stringstream ss; - ss << "channel " << channel->getChannelName() << " easyMonitor already connected "; - throw std::runtime_error(ss.str()); - } - monitorRequester = ChannelMonitorRequester::shared_pointer(new ChannelMonitorRequester(this)); - connectState = connectActive; - monitor = channel->createMonitor(monitorRequester,pvRequest); -} - -Status EasyMonitor::waitConnect() -{ - if(isDestroyed) throw std::runtime_error("easyMonitor was destroyed"); - if(connectState!=connectActive) { - stringstream ss; - ss << "channel " << channel->getChannelName() << " easyMonitor illegal connect state "; - 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()); -} - -void EasyMonitor::setRequester(EasyMonitorRequesterPtr const & easyMonitorrRequester) -{ - this->easyMonitorRequester = easyMonitorrRequester; -} - -void EasyMonitor::start() -{ - if(isDestroyed) throw std::runtime_error("easyMonitor was destroyed"); - if(connectState==monitorStarted) return; - if(connectState==connectIdle) connect(); - if(connectState!=connected) throw std::runtime_error("EasyMonitor::start illegal state"); - connectState = monitorStarted; - monitor->start(); -} - - -void EasyMonitor::stop() -{ - if(isDestroyed) throw std::runtime_error("easyMonitor was destroyed"); - if(connectState!=monitorStarted) return; - connectState = connected; - monitor->stop(); -} - -bool EasyMonitor::poll() -{ - checkMonitorState(); - if(connectState!=monitorStarted) throw std::runtime_error("EasyMonitor::poll illegal state"); - if(userPoll) throw std::runtime_error("EasyMonitor::poll did not release last"); - monitorElement = monitor->poll(); - if(!monitorElement) return false; - userPoll = true; - easyData->setData(monitorElement); - return true; -} - -bool EasyMonitor::waitEvent(double secondsToWait) -{ - if(isDestroyed) throw std::runtime_error("easyMonitor was destroyed"); - if(connectState!=monitorStarted) throw std::runtime_error("EasyMonitor::poll illegal state"); - if(poll()) return true; - userWait = true; - if(secondsToWait==0.0) { - waitForEvent.wait(); - } else { - waitForEvent.wait(secondsToWait); - } - userWait = false; - return poll(); -} - -void EasyMonitor::releaseEvent() -{ - if(isDestroyed) throw std::runtime_error("easyMonitor was destroyed"); - if(connectState!=monitorStarted) throw std::runtime_error("EasyMonitor::poll illegal state"); - if(!userPoll) throw std::runtime_error("EasyMonitor::releaseEvent did not call poll"); - userPoll = false; - monitor->release(monitorElement); -} - -EasyMonitorDataPtr EasyMonitor::getData() -{ - checkMonitorState(); - return easyData; -} - -EasyMonitorPtr EasyMonitor::create( - EasyPVAPtr const &pva, - EasyChannelPtr const & easyChannel, - Channel::shared_pointer const & channel, - PVStructurePtr const &pvRequest) -{ - EasyMonitorPtr epv(new EasyMonitor(pva,easyChannel,channel,pvRequest)); - return epv; -} - -}} diff --git a/src/easyMultiChannel.cpp b/src/easyMultiChannel.cpp deleted file mode 100644 index a1d2f84..0000000 --- a/src/easyMultiChannel.cpp +++ /dev/null @@ -1,165 +0,0 @@ -/* easyMultiChannel.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 -#include -#include -#include -#include -#include - - -using std::tr1::static_pointer_cast; -using namespace epics::pvData; -using namespace epics::pvAccess; -using namespace std; - -namespace epics { namespace easyPVA { - - - -EasyMultiChannel::EasyMultiChannel( - EasyPVAPtr const &easyPVA, - PVStringArrayPtr const & channelName, - string const & providerName) -: easyPVA(easyPVA), - channelName(channelName), - providerName(providerName), - numChannel(channelName->getLength()), - isConnected(getPVDataCreate()->createPVScalarArray()), - isDestroyed(false) -{ -} - -EasyMultiChannel::~EasyMultiChannel() -{ - destroy(); -} - -void EasyMultiChannel::destroy() -{ - { - Lock xx(mutex); - if(isDestroyed) return; - isDestroyed = true; - } - easyChannelArray.reset(); -} - -PVStringArrayPtr EasyMultiChannel::getChannelNames() -{ - if(isDestroyed) throw std::runtime_error("easyMultiChannel was destroyed"); - return channelName; -} - -Status EasyMultiChannel::connect(double timeout,size_t maxNotConnected) -{ - if(isDestroyed) throw std::runtime_error("easyMultiChannel was destroyed"); - if(easyChannelArray) throw std::runtime_error("easyMultiChannel already connected"); - EasyPVAPtr easy = easyPVA.lock(); - if(!easy) return Status(Status::STATUSTYPE_ERROR,"easyPVA is gone"); - shared_vector easyChannel(numChannel,EasyChannelPtr()); - PVStringArray::const_svector channelNames = channelName->view(); - shared_vector isConnected(numChannel,false); - for(size_t i=0; i< numChannel; ++i) { - easyChannel[i] = easy->createChannel(channelNames[i],providerName); - easyChannel[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 = easyChannel[i]->waitConnect(timeout); - } else { - status = easyChannel[i]->waitConnect(.001); - } - if(status.isOK()) { - ++numConnected; - isConnected[i] = true; - continue; - } - if(returnStatus.isOK()) returnStatus = status; - ++numBad; - if(numBad>maxNotConnected) break; - } - easyChannelArray = EasyChannelArrayPtr(new EasyChannelArray(freeze(easyChannel))); - this->isConnected->replace(freeze(isConnected)); - return numBad>maxNotConnected ? returnStatus : Status::Ok; -} - - -bool EasyMultiChannel::allConnected() -{ - if(isDestroyed) throw std::runtime_error("easyMultiChannel was destroyed"); - if(!easyChannelArray) throw std::runtime_error("easyMultiChannel not connected"); - if(numConnected==numChannel) return true; - return (numConnected==numChannel) ? true : false; -} - -bool EasyMultiChannel::connectionChange() -{ - if(isDestroyed) throw std::runtime_error("easyMultiChannel was destroyed"); - if(!easyChannelArray) throw std::runtime_error("easyMultiChannel not connected"); - if(numConnected==numChannel) return true; - PVBooleanArray::const_svector isConnected = this->isConnected->view(); - shared_vector channels = *easyChannelArray.get(); - for(size_t i=0; igetChannel(); - Channel::ConnectionState stateNow = channel->getConnectionState(); - bool connectedNow = stateNow==Channel::CONNECTED ? true : false; - if(connectedNow!=isConnected[i]) return true; - } - return false; -} - -PVBooleanArrayPtr EasyMultiChannel::getIsConnected() -{ - if(isDestroyed) throw std::runtime_error("easyMultiChannel was destroyed"); - if(!easyChannelArray) throw std::runtime_error("easyMultiChannel not connected"); - if(!connectionChange()) return isConnected; - shared_vector isConnected(numChannel,false); - shared_vector channels = *easyChannelArray.get(); - for(size_t i=0; igetChannel(); - Channel::ConnectionState stateNow = channel->getConnectionState(); - if(stateNow==Channel::CONNECTED) isConnected[i] = true; - } - this->isConnected->replace(freeze(isConnected)); - return this->isConnected; -} - -EasyChannelArrayWPtr EasyMultiChannel::getEasyChannelArray() -{ - if(isDestroyed) throw std::runtime_error("easyMultiChannel was destroyed"); - if(!easyChannelArray) throw std::runtime_error("easyMultiChannel not connected"); - return easyChannelArray; -} - -EasyPVA::weak_pointer EasyMultiChannel::getEasyPVA() -{ - if(isDestroyed) throw std::runtime_error("easyMultiChannel was destroyed"); - return easyPVA; -} - -EasyMultiChannelPtr EasyMultiChannel::create( - EasyPVAPtr const &easyPVA, - PVStringArrayPtr const & channelNames, - string const & providerName) -{ - EasyMultiChannelPtr channel(new EasyMultiChannel(easyPVA,channelNames,providerName)); - return channel; -} - -}} diff --git a/src/easyMultiDouble.cpp b/src/easyMultiDouble.cpp deleted file mode 100644 index c7f18f3..0000000 --- a/src/easyMultiDouble.cpp +++ /dev/null @@ -1,138 +0,0 @@ -/* easyMultiDouble.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 - */ - -#include - -using std::tr1::static_pointer_cast; -using namespace epics::pvData; -using namespace epics::pvAccess; -using namespace std; - -namespace epics { namespace easyPVA { - -EasyMultiDoublePtr EasyMultiDouble::create( - EasyPVAPtr const & easyPVA, - PVStringArrayPtr const & channelName, - double timeout, - std::string const & providerName) -{ - EasyMultiChannelPtr easyMultiChannel( - EasyMultiChannel::create(easyPVA,channelName,providerName)); - Status status = easyMultiChannel->connect(timeout,0); - if(!status.isOK()) throw std::runtime_error(status.getMessage()); - return EasyMultiDoublePtr(new EasyMultiDouble(easyMultiChannel)); -} - -EasyMultiDouble::EasyMultiDouble(EasyMultiChannelPtr const &easyMultiChannel) -: - easyMultiChannel(easyMultiChannel) -{} - -EasyMultiDouble::~EasyMultiDouble() -{ -} - -void EasyMultiDouble::createGet() -{ - EasyChannelArrayPtr easyChannelArray = easyMultiChannel->getEasyChannelArray().lock(); - if(!easyChannelArray) throw std::runtime_error("easyChannelArray is gone"); - shared_vector easyChannels = *easyChannelArray; - size_t numChannel = easyChannels.size(); - easyGet = std::vector(numChannel,EasyGetPtr()); - bool allOK = true; - string message; - for(size_t i=0; icreateGet("value"); - easyGet[i]->issueConnect(); - } - for(size_t i=0; iwaitConnect(); - if(!status.isOK()) { - message = "connect status " + status.getMessage(); - allOK = false; - break; - } - } - if(!allOK) throw std::runtime_error(message); -} - -void EasyMultiDouble::createPut() -{ - EasyChannelArrayPtr easyChannelArray = easyMultiChannel->getEasyChannelArray().lock(); - if(!easyChannelArray) throw std::runtime_error("easyChannelArray is gone"); - shared_vector easyChannels = *easyChannelArray; - size_t numChannel = easyChannels.size(); - easyPut = std::vector(numChannel,EasyPutPtr()); - bool allOK = true; - string message; - for(size_t i=0; icreatePut("value"); - easyPut[i]->issueConnect(); - } - for(size_t i=0; iwaitConnect(); - if(!status.isOK()) { - message = "connect status " + status.getMessage(); - allOK = false; - break; - } - } - if(!allOK) throw std::runtime_error(message); -} - -epics::pvData::shared_vector EasyMultiDouble::get() -{ - if(easyGet.empty()) createGet(); - shared_vector channelNames = easyMultiChannel->getChannelNames()->view(); - size_t numChannel = channelNames.size(); - epics::pvData::shared_vector data(channelNames.size()); - for(size_t i=0; iissueGet(); - } - for(size_t i=0; iwaitGet(); - if(!status.isOK()) { - string message = channelNames[i] + " " + status.getMessage(); - throw std::runtime_error(message); - } - data[i] = easyGet[i]->getData()->getDouble(); - } - return data; -} - -void EasyMultiDouble::put(shared_vector const &value) -{ - if(easyPut.empty()) createPut(); - shared_vector channelNames = easyMultiChannel->getChannelNames()->view(); - size_t numChannel = channelNames.size(); - for(size_t i=0; igetData()->putDouble(value[i]); - easyPut[i]->issuePut(); - } - for(size_t i=0; iwaitPut(); - if(!status.isOK()) { - string message = channelNames[i] + " " + status.getMessage(); - throw std::runtime_error(message); - } - } -} - - -}} diff --git a/src/easyPVA.cpp b/src/easyPVA.cpp deleted file mode 100644 index a2c2dc6..0000000 --- a/src/easyPVA.cpp +++ /dev/null @@ -1,199 +0,0 @@ -/* easyPVA.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 -#include -#include -#include -#include - -using std::tr1::static_pointer_cast; -using namespace epics::pvData; -using namespace epics::pvAccess; -using namespace epics::pvAccess::ca; -using namespace std; - -namespace epics { namespace easyPVA { - -static FieldCreatePtr fieldCreate = getFieldCreate(); -static const string easyPVAName = "easyPVA"; -static const string defaultProvider = "pva"; -static UnionConstPtr variantUnion = fieldCreate->createVariantUnion(); - -namespace easyPVAPvt { - - static size_t numberEasyPVA = 0; - static bool firstTime = true; - static Mutex mutex; - - class StartStopClientFactory { - public: - static void EasyPVABeingConstructed() - { - bool saveFirst = false; - { - Lock xx(mutex); - ++numberEasyPVA; - saveFirst = firstTime; - firstTime = false; - } - if(saveFirst) { - ClientFactory::start(); - CAClientFactory::start(); - } - } - - static void EasyPVABeingDestroyed() { - size_t numLeft = 0; - { - Lock xx(mutex); - --numberEasyPVA; - numLeft = numberEasyPVA; - } - if(numLeft<=0) { - ClientFactory::stop(); - CAClientFactory::stop(); - } - } - }; - -} // namespace easyPVAPvt - -class EasyChannelCache -{ -public: - EasyChannelCache(){} - ~EasyChannelCache(){ - destroy(); - } - void destroy() { - easyChannelMap.clear(); - } - EasyChannelPtr getChannel(string const & channelName); - void addChannel(EasyChannelPtr const & easyChannel); - void removeChannel(string const & channelName); -private: - map easyChannelMap; -}; - -EasyChannelPtr EasyChannelCache::getChannel(string const & channelName) -{ - map::iterator iter = easyChannelMap.find(channelName); - if(iter!=easyChannelMap.end()) return iter->second; - return EasyChannelPtr(); -} - -void EasyChannelCache::addChannel(EasyChannelPtr const & easyChannel) -{ - easyChannelMap.insert(std::pair( - easyChannel->getChannelName(),easyChannel)); -} - -void EasyChannelCache::removeChannel(string const & channelName) -{ - map::iterator iter = easyChannelMap.find(channelName); - if(iter!=easyChannelMap.end()) easyChannelMap.erase(iter); -} - -using namespace epics::easyPVA::easyPVAPvt; - -EasyPVAPtr EasyPVA::create() -{ - EasyPVAPtr xx(new EasyPVA()); - StartStopClientFactory::EasyPVABeingConstructed(); - return xx; -} - -PVStructurePtr EasyPVA::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; -} - -EasyPVA::EasyPVA() -: easyChannelCache(new EasyChannelCache()), - isDestroyed(false) -{ -} - -EasyPVA::~EasyPVA() { - destroy(); -} - -void EasyPVA::destroy() -{ - { - Lock xx(mutex); - if(isDestroyed) return; - isDestroyed = true; - } - easyChannelCache.reset(); - channelList.clear(); - multiChannelList.clear(); - StartStopClientFactory::EasyPVABeingDestroyed(); -} - -string EasyPVA:: getRequesterName() -{ - static string name("easyPVA"); - return name; -} - -void EasyPVA::message( - string const & message, - MessageType messageType) -{ - cout << getMessageTypeName(messageType) << " " << message << endl; -} - -EasyChannelPtr EasyPVA::channel( - std::string const & channelName, - std::string const & providerName, - double timeOut) -{ - EasyChannelPtr easyChannel = easyChannelCache->getChannel(channelName); - if(easyChannel) return easyChannel; - easyChannel = createChannel(channelName,providerName); - easyChannel->connect(timeOut); - easyChannelCache->addChannel(easyChannel); - return easyChannel; -} - -EasyChannelPtr EasyPVA::createChannel(string const & channelName) -{ - return EasyChannel::create(getPtrSelf(),channelName); -} - -EasyChannelPtr EasyPVA::createChannel(string const & channelName, string const & providerName) -{ - return EasyChannel::create(getPtrSelf(),channelName,providerName); -} - -EasyMultiChannelPtr EasyPVA::createMultiChannel( - epics::pvData::PVStringArrayPtr const & channelNames) -{ - return createMultiChannel(channelNames,"pva"); -} - -EasyMultiChannelPtr EasyPVA::createMultiChannel( - epics::pvData::PVStringArrayPtr const & channelNames, - std::string const & providerName) -{ - return EasyMultiChannel::create(getPtrSelf(),channelNames,providerName); -} - -}} - diff --git a/src/pvaClient.cpp b/src/pvaClient.cpp new file mode 100644 index 0000000..c88533c --- /dev/null +++ b/src/pvaClient.cpp @@ -0,0 +1,199 @@ +/* pvaClient.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 +#include +#include +#include +#include + +using std::tr1::static_pointer_cast; +using namespace epics::pvData; +using namespace epics::pvAccess; +using namespace epics::pvAccess::ca; +using namespace std; + +namespace epics { namespace pvaClient { + +static FieldCreatePtr fieldCreate = getFieldCreate(); +static const string pvaClientName = "pvaClient"; +static const string defaultProvider = "pva"; +static UnionConstPtr variantUnion = fieldCreate->createVariantUnion(); + +namespace pvaClientPvt { + + static size_t numberPvaClient = 0; + static bool firstTime = true; + static Mutex mutex; + + class StartStopClientFactory { + public: + static void PvaClientBeingConstructed() + { + bool saveFirst = false; + { + Lock xx(mutex); + ++numberPvaClient; + saveFirst = firstTime; + firstTime = false; + } + if(saveFirst) { + ClientFactory::start(); + CAClientFactory::start(); + } + } + + static void PvaClientBeingDestroyed() { + size_t numLeft = 0; + { + Lock xx(mutex); + --numberPvaClient; + numLeft = numberPvaClient; + } + if(numLeft<=0) { + ClientFactory::stop(); + CAClientFactory::stop(); + } + } + }; + +} // namespace pvaClientPvt + +class PvaClientChannelCache +{ +public: + PvaClientChannelCache(){} + ~PvaClientChannelCache(){ + destroy(); + } + void destroy() { + pvaClientChannelMap.clear(); + } + PvaClientChannelPtr getChannel(string const & channelName); + void addChannel(PvaClientChannelPtr const & pvaClientChannel); + void removeChannel(string const & channelName); +private: + map pvaClientChannelMap; +}; + +PvaClientChannelPtr PvaClientChannelCache::getChannel(string const & channelName) +{ + map::iterator iter = pvaClientChannelMap.find(channelName); + if(iter!=pvaClientChannelMap.end()) return iter->second; + return PvaClientChannelPtr(); +} + +void PvaClientChannelCache::addChannel(PvaClientChannelPtr const & pvaClientChannel) +{ + pvaClientChannelMap.insert(std::pair( + pvaClientChannel->getChannelName(),pvaClientChannel)); +} + +void PvaClientChannelCache::removeChannel(string const & channelName) +{ + map::iterator iter = pvaClientChannelMap.find(channelName); + if(iter!=pvaClientChannelMap.end()) pvaClientChannelMap.erase(iter); +} + +using namespace epics::pvaClient::pvaClientPvt; + +PvaClientPtr PvaClient::create() +{ + PvaClientPtr xx(new PvaClient()); + StartStopClientFactory::PvaClientBeingConstructed(); + 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()), + isDestroyed(false) +{ +} + +PvaClient::~PvaClient() { + destroy(); +} + +void PvaClient::destroy() +{ + { + Lock xx(mutex); + if(isDestroyed) return; + isDestroyed = true; + } + pvaClientChannelCache.reset(); + channelList.clear(); + multiChannelList.clear(); + StartStopClientFactory::PvaClientBeingDestroyed(); +} + +string PvaClient:: getRequesterName() +{ + static string name("pvaClient"); + return name; +} + +void PvaClient::message( + string const & message, + MessageType messageType) +{ + cout << getMessageTypeName(messageType) << " " << message << endl; +} + +PvaClientChannelPtr PvaClient::channel( + std::string const & channelName, + std::string const & providerName, + double timeOut) +{ + PvaClientChannelPtr pvaClientChannel = pvaClientChannelCache->getChannel(channelName); + if(pvaClientChannel) return pvaClientChannel; + pvaClientChannel = createChannel(channelName,providerName); + pvaClientChannel->connect(timeOut); + pvaClientChannelCache->addChannel(pvaClientChannel); + return pvaClientChannel; +} + +PvaClientChannelPtr PvaClient::createChannel(string const & channelName) +{ + return PvaClientChannel::create(getPtrSelf(),channelName); +} + +PvaClientChannelPtr PvaClient::createChannel(string const & channelName, string const & providerName) +{ + return PvaClientChannel::create(getPtrSelf(),channelName,providerName); +} + +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); +} + +}} + diff --git a/src/easyPVA.h b/src/pvaClient.h similarity index 74% rename from src/easyPVA.h rename to src/pvaClient.h index 243ad1b..558fbab 100644 --- a/src/easyPVA.h +++ b/src/pvaClient.h @@ -1,4 +1,4 @@ -/* easyPVA.h */ +/* pvaClient.h */ /** * Copyright - See the COPYRIGHT that is included with this distribution. * EPICS pvData is distributed subject to a Software License Agreement found @@ -8,11 +8,11 @@ * @author mrk * @date 2015.02 */ -#ifndef EASYPVA_H -#define EASYPVA_H +#ifndef PVACLIENT_H +#define PVACLIENT_H #ifdef epicsExportSharedSymbols -# define easyPVAEpicsExportSharedSymbols +# define pvaClientEpicsExportSharedSymbols # undef epicsExportSharedSymbols #endif @@ -34,78 +34,78 @@ #include #include -#ifdef easyPVAEpicsExportSharedSymbols +#ifdef pvaClientEpicsExportSharedSymbols # define epicsExportSharedSymbols -# undef easyPVAEpicsExportSharedSymbols +# undef pvaClientEpicsExportSharedSymbols #endif #include -namespace epics { namespace easyPVA { +namespace epics { namespace pvaClient { -class EasyPVA; -typedef std::tr1::shared_ptr EasyPVAPtr; -class EasyGetData; -typedef std::tr1::shared_ptr EasyGetDataPtr; -class EasyPutData; -typedef std::tr1::shared_ptr EasyPutDataPtr; -class EasyMonitorData; -typedef std::tr1::shared_ptr EasyMonitorDataPtr; -class EasyChannel; -typedef std::tr1::shared_ptr EasyChannelPtr; -class EasyField; -typedef std::tr1::shared_ptr EasyFieldPtr; -class EasyProcess; -typedef std::tr1::shared_ptr EasyProcessPtr; -class EasyGet; -typedef std::tr1::shared_ptr EasyGetPtr; -class EasyPut; -typedef std::tr1::shared_ptr EasyPutPtr; -class EasyPutGet; -typedef std::tr1::shared_ptr EasyPutGetPtr; -class EasyMonitor; -typedef std::tr1::shared_ptr EasyMonitorPtr; -class EasyMonitorRequester; -typedef std::tr1::shared_ptr EasyMonitorRequesterPtr; -class EasyArray; -typedef std::tr1::shared_ptr EasyArrayPtr; -class EasyRPC; -typedef std::tr1::shared_ptr EasyRPCPtr; +class PvaClient; +typedef std::tr1::shared_ptr PvaClientPtr; +class PvaClientGetData; +typedef std::tr1::shared_ptr PvaClientGetDataPtr; +class PvaClientPutData; +typedef std::tr1::shared_ptr PvaClientPutDataPtr; +class PvaClientMonitorData; +typedef std::tr1::shared_ptr PvaClientMonitorDataPtr; +class PvaClientChannel; +typedef std::tr1::shared_ptr PvaClientChannelPtr; +class PvaClientField; +typedef std::tr1::shared_ptr PvaClientFieldPtr; +class PvaClientProcess; +typedef std::tr1::shared_ptr PvaClientProcessPtr; +class PvaClientGet; +typedef std::tr1::shared_ptr PvaClientGetPtr; +class PvaClientPut; +typedef std::tr1::shared_ptr PvaClientPutPtr; +class PvaClientPutGet; +typedef std::tr1::shared_ptr PvaClientPutGetPtr; +class PvaClientMonitor; +typedef std::tr1::shared_ptr PvaClientMonitorPtr; +class PvaClientMonitorRequester; +typedef std::tr1::shared_ptr PvaClientMonitorRequesterPtr; +class PvaClientArray; +typedef std::tr1::shared_ptr PvaClientArrayPtr; +class PvaClientRPC; +typedef std::tr1::shared_ptr PvaClientRPCPtr; -typedef epics::pvData::shared_vector EasyChannelArray; -typedef std::tr1::shared_ptr EasyChannelArrayPtr; -typedef std::tr1::weak_ptr EasyChannelArrayWPtr; +typedef epics::pvData::shared_vector PvaClientChannelArray; +typedef std::tr1::shared_ptr PvaClientChannelArrayPtr; +typedef std::tr1::weak_ptr PvaClientChannelArrayWPtr; -class EasyMultiChannel; -typedef std::tr1::shared_ptr EasyMultiChannelPtr; -class EasyMultiChannelGet; +class PvaClientMultiChannel; +typedef std::tr1::shared_ptr PvaClientMultiChannelPtr; +class PvaClientMultiChannelGet; -// following are private to easyPVA -class EasyChannelCache; -typedef std::tr1::shared_ptr EasyChannelCachePtr; +// following are private to pvaClient +class PvaClientChannelCache; +typedef std::tr1::shared_ptr PvaClientChannelCachePtr; /** - * @brief EasyPVA is an easy to use interface to pvAccess. + * @brief PvaClient is a synchronous interface to pvAccess plus convenience methods. * * @author mrk */ -class epicsShareClass EasyPVA : +class epicsShareClass PvaClient : public epics::pvData::Requester, - public std::tr1::enable_shared_from_this + public std::tr1::enable_shared_from_this { public: - POINTER_DEFINITIONS(EasyPVA); + POINTER_DEFINITIONS(PvaClient); /** * Destructor */ - ~EasyPVA(); + ~PvaClient(); /** - * @brief Create an instance of EasyPVA + * @brief Create an instance of PvaClient * @return shared_ptr to new instance. */ - static EasyPVAPtr create(); + static PvaClientPtr create(); /** @brief get the requester name. * @return The name. */ @@ -126,12 +126,12 @@ public: void destroy(); /** * @brief get a cached channel or create and connect to a new channel. - * The provider is pva. The timeout is 5 seconds. + * The provider is pvaClient. The timeout is 5 seconds. * If connection can not be made an exception is thrown. * @param channelName The channelName. * @return The interface. */ - EasyChannelPtr channel(std::string const & channelName) + PvaClientChannelPtr channel(std::string const & channelName) { return channel(channelName,"pva", 5.0); } /** * @brief get a cached channel or create and connect to a new channel. @@ -139,118 +139,118 @@ public: * @param channelName The channelName. * @return The interface. */ - EasyChannelPtr channel( + PvaClientChannelPtr channel( std::string const & channelName, std::string const &providerName, double timeOut); /** - * @brief Create an EasyChannel. The provider is pva. + * @brief Create an PvaClientChannel. The provider is pvaClient. * @param channelName The channelName. * @return The interface. */ - EasyChannelPtr createChannel(std::string const & channelName); + PvaClientChannelPtr createChannel(std::string const & channelName); /** - * @brief Create an EasyChannel with the specified provider. + * @brief Create an PvaClientChannel with the specified provider. * @param channelName The channelName. * @param providerName The provider. * @return The interface or null if the provider does not exist. */ - EasyChannelPtr createChannel( + PvaClientChannelPtr createChannel( std::string const & channelName, std::string const & providerName); /** - * @brief Create an EasyMultiChannel. The provider is pvAccess. + * @brief Create an PvaClientMultiChannel. The provider is pvAccess. * @param channelName The channelName array. * @return The interface. */ - EasyMultiChannelPtr createMultiChannel( + PvaClientMultiChannelPtr createMultiChannel( epics::pvData::PVStringArrayPtr const & channelNames); /** - * @brief Create an EasyMultiChannel with the specified provider. + * @brief Create an PvaClientMultiChannel with the specified provider. * @param channelName The channelName array. * @param providerName The provider. * @return The interface. */ - EasyMultiChannelPtr createMultiChannel( + PvaClientMultiChannelPtr createMultiChannel( epics::pvData::PVStringArrayPtr const & channelNames, std::string const & providerName); /** * @brief Set a requester. - * The default is for EasyPVA to handle messages by printing to System.out. + * The default is for PvaClient to handle messages by printing to System.out. * @param requester The requester. */ void setRequester(epics::pvData::RequesterPtr const & requester); /** - * @brief Clear the requester. EasyPVA will handle messages. + * @brief Clear the requester. PvaClient will handle messages. */ void clearRequester(); /** * @brief get shared pointer to this */ - EasyPVAPtr getPtrSelf() + PvaClientPtr getPtrSelf() { return shared_from_this(); } private: - EasyPVA(); - EasyChannelCachePtr easyChannelCache; + PvaClient(); + PvaClientChannelCachePtr pvaClientChannelCache; epics::pvData::PVStructurePtr createRequest(std::string const &request); - std::list channelList; - std::list multiChannelList; + std::list channelList; + std::list multiChannelList; epics::pvData::Requester::weak_pointer requester; bool isDestroyed; epics::pvData::Mutex mutex; }; -// folowing private to EasyChannel -class EasyGetCache; -typedef std::tr1::shared_ptr EasyGetCachePtr; -class EasyPutCache; -typedef std::tr1::shared_ptr EasyPutCachePtr; +// folowing private to PvaClientChannel +class PvaClientGetCache; +typedef std::tr1::shared_ptr PvaClientGetCachePtr; +class PvaClientPutCache; +typedef std::tr1::shared_ptr PvaClientPutCachePtr; class ChannelRequesterImpl; /** * @brief An easy to use alternative to directly calling the Channel methods of pvAccess. * * @author mrk */ -class epicsShareClass EasyChannel : - public std::tr1::enable_shared_from_this +class epicsShareClass PvaClientChannel : + public std::tr1::enable_shared_from_this { public: - POINTER_DEFINITIONS(EasyChannel); + POINTER_DEFINITIONS(PvaClientChannel); /** - * @brief Create a EasyChannel. - * @param easyPVA Interface to EasyPVA + * @brief Create a PvaClientChannel. + * @param pvaClient Interface to PvaClient * @param channelName The name of the channel. * @return The interface. */ - static EasyChannelPtr create( - EasyPVAPtr const &easyPVA, + static PvaClientChannelPtr create( + PvaClientPtr const &pvaClient, std::string const & channelName) - {return create(easyPVA,channelName,"pva");} + {return create(pvaClient,channelName,"pva");} /** - * @brief Create a EasyChannel. + * @brief Create a PvaClientChannel. * @param channelName The name of the channel. * @param providerName The name of the provider. - * @return The interface to the EasyPVAStructure. + * @return The interface to the PvaClientStructure. */ - static EasyChannelPtr create( - EasyPVAPtr const &easyPVA, + static PvaClientChannelPtr create( + PvaClientPtr const &pvaClient, std::string const & channelName, std::string const & providerName); - ~EasyChannel(); + ~PvaClientChannel(); /** * @brief Destroy the pvAccess connection. */ void destroy(); /** - * @brief Get the name of the channel to which EasyChannel is connected. + * @brief Get the name of the channel to which PvaClientChannel is connected. * @return The channel name. */ std::string getChannelName(); /** - * @brief Get the the channel to which EasyChannel is connected. + * @brief Get the the channel to which PvaClientChannel is connected. * @return The channel interface. */ epics::pvAccess::Channel::shared_pointer getChannel(); @@ -275,196 +275,196 @@ public: * @brief Calls the next method with subField = ""; * @return The interface. */ - EasyFieldPtr createField(); + PvaClientFieldPtr createField(); /** - * @brief Create an EasyField for the specified subField. + * @brief Create an PvaClientField for the specified subField. * @param subField The syntax for subField is defined in package org.epics.pvdata.copy * @return The interface. */ - EasyFieldPtr createField(std::string const & subField); + PvaClientFieldPtr createField(std::string const & subField); /** * @brief Calls the next method with request = ""; * @return The interface. */ - EasyProcessPtr createProcess(); + PvaClientProcessPtr createProcess(); /** * @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. */ - EasyProcessPtr createProcess(std::string const & request); + PvaClientProcessPtr createProcess(std::string const & request); /** - * @brief Creates an EasyProcess. + * @brief Creates an PvaClientProcess. * @param pvRequest The syntax of pvRequest is described in package org.epics.pvdata.copy. * @return The interface. */ - EasyProcessPtr createProcess(epics::pvData::PVStructurePtr const & pvRequest); + PvaClientProcessPtr createProcess(epics::pvData::PVStructurePtr const & pvRequest); /** * @brief Call the next method with request = "field(value,alarm,timeStamp)" * @return The interface. */ - EasyGetPtr get(); + PvaClientGetPtr get(); /** - * @brief get a cached EasyGet or create and connect to a new EasyGet. + * @brief get a cached PvaClientGet or create and connect to a new PvaClientGet. * Then call it's get method. * If connection can not be made an exception is thrown. * @param request The request as described in package org.epics.pvdata.copy * @return The interface. */ - EasyGetPtr get(std::string const & request); + PvaClientGetPtr get(std::string const & request); /** * @brief Call the next method with request = "field(value,alarm,timeStamp)" * @return The interface. */ - EasyGetPtr createGet(); + PvaClientGetPtr createGet(); /** * @brief First call createRequest as implemented by pvDataJava and then call the next method. * @param request The request as described in package org.epics.pvdata.copy * @return The interface. */ - EasyGetPtr createGet(std::string const & request); + PvaClientGetPtr createGet(std::string const & request); /** - * @brief Creates an EasyGet. + * @brief Creates an PvaClientGet. * @param pvRequest The syntax of pvRequest is described in package org.epics.pvdata.copy. * @return The interface. */ - EasyGetPtr createGet(epics::pvData::PVStructurePtr const & pvRequest); + PvaClientGetPtr createGet(epics::pvData::PVStructurePtr const & pvRequest); /** * @brief Call the next method with request = "field(value)" * @return The interface. */ - EasyPutPtr put(); + PvaClientPutPtr put(); /** - * @brief get a cached EasyPut or create and connect to a new EasyPut. + * @brief get a cached PvaClientPut or create and connect to a new PvaClientPut. * Then call it's get method. * If connection can not be made an exception is thrown. * @param request The request as described in package org.epics.pvdata.copy * @return The interface. */ - EasyPutPtr put(std::string const & request); + PvaClientPutPtr put(std::string const & request); /** * @brief Call the next method with request = "field(value)" * @return The interface. */ - EasyPutPtr createPut(); + PvaClientPutPtr createPut(); /** * @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. */ - EasyPutPtr createPut(std::string const & request); + PvaClientPutPtr createPut(std::string const & request); /** - * @brief Create an EasyPut. + * @brief Create an PvaClientPut. * @param pvRequest The syntax of pvRequest is described in package org.epics.pvdata.copy. * @return The interface. */ - EasyPutPtr createPut(epics::pvData::PVStructurePtr const & pvRequest); + PvaClientPutPtr createPut(epics::pvData::PVStructurePtr const & pvRequest); /** * @brief Call the next method with request = "record[process=true]putField(argument)getField(result)". * @return The interface. */ - EasyPutGetPtr createPutGet(); + PvaClientPutGetPtr createPutGet(); /** * @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. */ - EasyPutGetPtr createPutGet(std::string const & request); + PvaClientPutGetPtr createPutGet(std::string const & request); /** - * @brief Create an EasyPutGet. + * @brief Create an PvaClientPutGet. * @param pvRequest The syntax of pvRequest is described in package org.epics.pvdata.copy. * @return The interface. */ - EasyPutGetPtr createPutGet(epics::pvData::PVStructurePtr const & pvRequest); + PvaClientPutGetPtr createPutGet(epics::pvData::PVStructurePtr const & pvRequest); /** * @brief Call createRPC(PVStructure(null)) * @return The interface. */ - EasyRPCPtr createRPC(); + 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. */ - EasyRPCPtr createRPC(std::string const & request); + PvaClientRPCPtr createRPC(std::string const & request); /** - * @brief Create an EasyRPC. + * @brief Create an PvaClientRPC. * @param pvRequest The syntax of pvRequest is described in package org.epics.pvdata.copy. * @return The interface. */ - EasyRPCPtr createRPC(epics::pvData::PVStructurePtr const & pvRequest); + PvaClientRPCPtr createRPC(epics::pvData::PVStructurePtr const & pvRequest); /** * @brief Call the next method with request = "field(value)"; * @return The interface. */ - EasyArrayPtr createArray(); + PvaClientArrayPtr createArray(); /** * @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. */ - EasyArrayPtr createArray(std::string const & request); + PvaClientArrayPtr createArray(std::string const & request); /** - * @brief Create an EasyArray. + * @brief Create an PvaClientArray. * @param pvRequest The syntax of pvRequest is described in package org.epics.pvdata.copy. * @return The interface. */ - EasyArrayPtr createArray(epics::pvData::PVStructurePtr const & pvRequest); + PvaClientArrayPtr createArray(epics::pvData::PVStructurePtr const & pvRequest); /** * @brief Call the next method with request = "field(value,alarm,timeStamp)" * @return The interface. */ - EasyMonitorPtr monitor(); + PvaClientMonitorPtr monitor(); /** - * @brief get a cached EasyMonitor or create and connect to a new EasyMonitor. + * @brief get a cached PvaClientMonitor or create and connect to a new PvaClientMonitor. * Then call it's start method. * If connection can not be made an exception is thrown. * @param request The request as described in package org.epics.pvdata.copy * @return The interface. */ - EasyMonitorPtr monitor(std::string const & request); + PvaClientMonitorPtr monitor(std::string const & request); /** * @brief Call the next method with request = "field(value,alarm,timeStamp)" - * @param easyMonitorRequester The client callback. + * @param pvaClientMonitorRequester The client callback. * @return The interface. */ - EasyMonitorPtr monitor(EasyMonitorRequesterPtr const & easyMonitorRequester); + PvaClientMonitorPtr monitor(PvaClientMonitorRequesterPtr const & pvaClientMonitorRequester); /** - * @brief get a cached EasyMonitor or create and connect to a new EasyMonitor. + * @brief get a cached PvaClientMonitor or create and connect to a new PvaClientMonitor. * Then call it's start method. * If connection can not be made an exception is thrown. * @param request The request as described in package org.epics.pvdata.copy - * @param easyMonitorRequester The client callback. + * @param pvaClientMonitorRequester The client callback. * @return The interface. */ - EasyMonitorPtr monitor( + PvaClientMonitorPtr monitor( std::string const & request, - EasyMonitorRequesterPtr const & easyMonitorRequester); + PvaClientMonitorRequesterPtr const & pvaClientMonitorRequester); /** * @brief Call the next method with request = "field(value.alarm,timeStamp)" * @return The interface. */ - EasyMonitorPtr createMonitor(); + PvaClientMonitorPtr createMonitor(); /** * @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. */ - EasyMonitorPtr createMonitor(std::string const & request); + PvaClientMonitorPtr createMonitor(std::string const & request); /** - * @brief Create an EasyMonitor. + * @brief Create an PvaClientMonitor. * @param pvRequest The syntax of pvRequest is described in package org.epics.pvdata.copy. * @return The interface. */ - EasyMonitorPtr createMonitor(epics::pvData::PVStructurePtr const & pvRequest); - EasyChannelPtr getPtrSelf() + PvaClientMonitorPtr createMonitor(epics::pvData::PVStructurePtr const & pvRequest); + PvaClientChannelPtr getPtrSelf() { return shared_from_this(); } private: - EasyChannel( - EasyPVAPtr const &pva, + PvaClientChannel( + PvaClientPtr const &pvaClient, std::string const & channelName, std::string const & providerName); void channelCreated( @@ -480,14 +480,14 @@ private: enum ConnectState {connectIdle,connectActive,notConnected,connected}; - EasyPVA::weak_pointer easyPVA; + PvaClient::weak_pointer pvaClient; std::string channelName; std::string providerName; ConnectState connectState; bool isDestroyed; epics::pvData::CreateRequest::shared_pointer createRequest; - EasyGetCachePtr easyGetCache; - EasyPutCachePtr easyPutCache; + PvaClientGetCachePtr pvaClientGetCache; + PvaClientPutCachePtr pvaClientPutCache; epics::pvData::Status channelConnectStatus; epics::pvData::Mutex mutex; @@ -498,18 +498,18 @@ private: }; /** - * @brief This is a class that holds data returned by EasyGet or EasyPutGet + * @brief This is a class that holds data returned by PvaClientGet or PvaClientPutGet * */ -class epicsShareClass EasyGetData +class epicsShareClass PvaClientGetData { public: - POINTER_DEFINITIONS(EasyGetData); + POINTER_DEFINITIONS(PvaClientGetData); /** - * @brief Factory method for creating an instance of EasyGetData. + * @brief Factory method for creating an instance of PvaClientGetData. */ - static EasyGetDataPtr create(epics::pvData::StructureConstPtr const & structure); - ~EasyGetData() {} + static PvaClientGetDataPtr create(epics::pvData::StructureConstPtr const & structure); + ~PvaClientGetData() {} /** * @brief Set a prefix for throw messages. * @param value The prefix. @@ -618,7 +618,7 @@ public: */ epics::pvData::TimeStamp getTimeStamp(); private: - EasyGetData(epics::pvData::StructureConstPtr const & structure); + PvaClientGetData(epics::pvData::StructureConstPtr const & structure); void checkValue(); epics::pvData::StructureConstPtr structure; epics::pvData::PVStructurePtr pvStructure; @@ -630,20 +630,20 @@ private: epics::pvData::PVTimeStamp pvTimeStamp; }; -class EasyPostHandlerPvt; // private to EasyPutData +class PvaClientPostHandlerPvt; // private to PvaClientPutData /** - * @brief This is a class that holds data given to by EasyPut or EasyPutGet + * @brief This is a class that holds data given to by PvaClientPut or PvaClientPutGet * */ -class epicsShareClass EasyPutData +class epicsShareClass PvaClientPutData { public: - POINTER_DEFINITIONS(EasyPutData); + POINTER_DEFINITIONS(PvaClientPutData); /** - * @brief Factory method for creating an instance of EasyPutData. + * @brief Factory method for creating an instance of PvaClientPutData. */ - static EasyPutDataPtr create(epics::pvData::StructureConstPtr const & structure); - ~EasyPutData() {} + static PvaClientPutDataPtr create(epics::pvData::StructureConstPtr const & structure); + ~PvaClientPutData() {} /** * @brief Set a prefix for throw messages. * @param value The prefix. @@ -759,7 +759,7 @@ public: */ void putStringArray(std::vector const & value); private: - EasyPutData(epics::pvData::StructureConstPtr const &structure); + PvaClientPutData(epics::pvData::StructureConstPtr const &structure); void checkValue(); void postPut(size_t fieldNumber); @@ -767,25 +767,25 @@ private: epics::pvData::StructureConstPtr structure; epics::pvData::PVStructurePtr pvStructure; epics::pvData::BitSetPtr bitSet; - friend class EasyPostHandlerPvt; + friend class PvaClientPostHandlerPvt; std::string messagePrefix; epics::pvData::PVFieldPtr pvValue; }; /** - * @brief This is a class that holds data returned by EasyMonitor + * @brief This is a class that holds data returned by PvaClientMonitor * */ -class epicsShareClass EasyMonitorData +class epicsShareClass PvaClientMonitorData { public: - POINTER_DEFINITIONS(EasyMonitorData); + POINTER_DEFINITIONS(PvaClientMonitorData); /** - * @brief Factory method for creating an instance of EasyMonitorData. + * @brief Factory method for creating an instance of PvaClientMonitorData. */ - static EasyMonitorDataPtr create(epics::pvData::StructureConstPtr const & structure); - ~EasyMonitorData() {} + static PvaClientMonitorDataPtr create(epics::pvData::StructureConstPtr const & structure); + ~PvaClientMonitorData() {} /** * @brief Set a prefix for throw messages. * @param value The prefix. @@ -901,7 +901,7 @@ public: */ epics::pvData::TimeStamp getTimeStamp(); private: - EasyMonitorData(epics::pvData::StructureConstPtr const & structure); + PvaClientMonitorData(epics::pvData::StructureConstPtr const & structure); void checkValue(); epics::pvData::StructureConstPtr structure; @@ -915,34 +915,34 @@ private: epics::pvData::PVTimeStamp pvTimeStamp; }; -class ChannelProcessRequesterImpl; // private to EasyProcess +class ChannelProcessRequesterImpl; // private to PvaClientProcess /** * @brief An easy to use alternative to ChannelProcess. * * @author mrk */ -class epicsShareClass EasyProcess +class epicsShareClass PvaClientProcess { public: - POINTER_DEFINITIONS(EasyProcess); + POINTER_DEFINITIONS(PvaClientProcess); /** - * @brief Create a EasyProcess. - * @param &easyPVA Interface to EasyPVA - * @param easyChannel Interface to EasyChannel + * @brief 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 EasyPVAStructure. + * @return The interface to the PvaClientStructure. */ - static EasyProcessPtr create( - EasyPVAPtr const &easyPVA, - EasyChannelPtr const & easyChannel, + static PvaClientProcessPtr create( + PvaClientPtr const &pvaClient, + PvaClientChannelPtr const & pvaClientChannel, epics::pvAccess::Channel::shared_pointer const & channel, epics::pvData::PVStructurePtr const &pvRequest ); /** * @brief destructor */ - ~EasyProcess(); + ~PvaClientProcess(); /** * @brief destroy an resources used. */ @@ -977,9 +977,9 @@ public: */ epics::pvData::Status waitProcess(); private: - EasyProcess( - EasyPVAPtr const &easyPVA, - EasyChannelPtr const & easyChannel, + PvaClientProcess( + PvaClientPtr const &pvaClient, + PvaClientChannelPtr const & pvaClientChannel, epics::pvAccess::Channel::shared_pointer const & channel, epics::pvData::PVStructurePtr const &pvRequest); std::string getRequesterName(); @@ -993,8 +993,8 @@ private: void checkProcessState(); enum ProcessConnectState {connectIdle,connectActive,connected}; - EasyPVA::weak_pointer easyPVA; - EasyChannel::weak_pointer easyChannel; + PvaClient::weak_pointer pvaClient; + PvaClientChannel::weak_pointer pvaClientChannel; epics::pvAccess::Channel::shared_pointer channel; epics::pvAccess::ChannelProcessRequester::shared_pointer processRequester; epics::pvData::PVStructurePtr pvRequest; @@ -1015,34 +1015,34 @@ private: friend class ChannelProcessRequesterImpl; }; -class ChannelGetRequesterImpl; // private to EasyGet +class ChannelGetRequesterImpl; // private to PvaClientGet /** * @brief An easy to use alternative to ChannelGet. * * @author mrk */ -class epicsShareClass EasyGet +class epicsShareClass PvaClientGet { public: - POINTER_DEFINITIONS(EasyGet); + POINTER_DEFINITIONS(PvaClientGet); /** - * @brief Create a EasyGet. - * @param &easyPVA Interface to EasyPVA - * @param easyChannel Interface to EasyChannel + * @brief 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 EasyPVAStructure. + * @return The interface to the PvaClientStructure. */ - static EasyGetPtr create( - EasyPVAPtr const &easyPVA, - EasyChannelPtr const & easyChannel, + static PvaClientGetPtr create( + PvaClientPtr const &pvaClient, + PvaClientChannelPtr const & pvaClientChannel, epics::pvAccess::Channel::shared_pointer const & channel, epics::pvData::PVStructurePtr const &pvRequest ); /** * @brief destructor */ - ~EasyGet(); + ~PvaClientGet(); /** * @brief destroy an resources used. */ @@ -1080,11 +1080,11 @@ public: * @brief Get the data/ * @return The interface. */ - EasyGetDataPtr getData(); + PvaClientGetDataPtr getData(); private: - EasyGet( - EasyPVAPtr const &easyPVA, - EasyChannelPtr const & easyChannel, + PvaClientGet( + PvaClientPtr const &pvaClient, + PvaClientChannelPtr const & pvaClientChannel, epics::pvAccess::Channel::shared_pointer const & channel, epics::pvData::PVStructurePtr const &pvRequest); std::string getRequesterName(); @@ -1101,15 +1101,15 @@ private: void checkGetState(); enum GetConnectState {connectIdle,connectActive,connected}; - EasyPVA::weak_pointer easyPVA; - EasyChannel::weak_pointer easyChannel; + PvaClient::weak_pointer pvaClient; + PvaClientChannel::weak_pointer pvaClientChannel; epics::pvAccess::Channel::shared_pointer channel; epics::pvAccess::ChannelGetRequester::shared_pointer getRequester; epics::pvData::PVStructurePtr pvRequest; epics::pvData::Mutex mutex; epics::pvData::Event waitForConnect; epics::pvData::Event waitForGet; - EasyGetDataPtr easyData; + PvaClientGetDataPtr pvaClientData; std::string messagePrefix; bool isDestroyed; @@ -1124,34 +1124,34 @@ private: friend class ChannelGetRequesterImpl; }; -class ChannelPutRequesterImpl; // private to EasyPut +class ChannelPutRequesterImpl; // private to PvaClientPut /** * @brief An easy to use alternative to ChannelPut. * * @author mrk */ -class epicsShareClass EasyPut +class epicsShareClass PvaClientPut { public: - POINTER_DEFINITIONS(EasyPut); + POINTER_DEFINITIONS(PvaClientPut); /** - * @brief Create a EasyPut. - * @param &easyPVA Interface to EasyPVA - * @param easyChannel Interface to EasyChannel + * @brief 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 EasyPVAStructure. + * @return The interface to the PvaClientStructure. */ - static EasyPutPtr create( - EasyPVAPtr const &easyPVA, - EasyChannelPtr const & easyChannel, + static PvaClientPutPtr create( + PvaClientPtr const &pvaClient, + PvaClientChannelPtr const & pvaClientChannel, epics::pvAccess::Channel::shared_pointer const & channel, epics::pvData::PVStructurePtr const &pvRequest ); /** * @brief destructor */ - ~EasyPut(); + ~PvaClientPut(); /** * @brief destroy an resources used. */ @@ -1203,11 +1203,11 @@ public: * @brief Get the data/ * @return The interface. */ - EasyPutDataPtr getData(); + PvaClientPutDataPtr getData(); private : - EasyPut( - EasyPVAPtr const &easyPVA, - EasyChannelPtr const & easyChannel, + PvaClientPut( + PvaClientPtr const &pvaClient, + PvaClientChannelPtr const & pvaClientChannel, epics::pvAccess::Channel::shared_pointer const & channel, epics::pvData::PVStructurePtr const &pvRequest); std::string getRequesterName(); @@ -1227,15 +1227,15 @@ private : void checkPutState(); enum PutConnectState {connectIdle,connectActive,connected}; - EasyPVA::weak_pointer easyPVA; - EasyChannel::weak_pointer easyChannel; + PvaClient::weak_pointer pvaClient; + PvaClientChannel::weak_pointer pvaClientChannel; epics::pvAccess::Channel::shared_pointer channel; epics::pvAccess::ChannelPutRequester::shared_pointer putRequester; epics::pvData::PVStructurePtr pvRequest; epics::pvData::Mutex mutex; epics::pvData::Event waitForConnect; epics::pvData::Event waitForGetPut; - EasyPutDataPtr easyData; + PvaClientPutDataPtr pvaClientData; std::string messagePrefix; bool isDestroyed; @@ -1250,34 +1250,34 @@ private : friend class ChannelPutRequesterImpl; }; -class ChannelPutGetRequesterImpl; // private to EasyPutGet +class ChannelPutGetRequesterImpl; // private to PvaClientPutGet /** * @brief An easy to use alternative to ChannelPutGet. * * @author mrk */ -class epicsShareClass EasyPutGet +class epicsShareClass PvaClientPutGet { public: - POINTER_DEFINITIONS(EasyPutGet); + POINTER_DEFINITIONS(PvaClientPutGet); /** - * @brief Create a EasyPutGet. - * @param &easyPVA Interface to EasyPVA - * @param easyChannel Interface to EasyChannel + * @brief 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 EasyPVAStructure. + * @return The interface to the PvaClientStructure. */ - static EasyPutGetPtr create( - EasyPVAPtr const &easyPVA, - EasyChannelPtr const & easyChannel, + static PvaClientPutGetPtr create( + PvaClientPtr const &pvaClient, + PvaClientChannelPtr const & pvaClientChannel, epics::pvAccess::Channel::shared_pointer const & channel, epics::pvData::PVStructurePtr const &pvRequest ); /** * @brief destructor */ - ~EasyPutGet(); + ~PvaClientPutGet(); /** * @brief destroy an resources used. */ @@ -1346,16 +1346,16 @@ public: * @brief Get the put data. * @return The interface. */ - EasyPutDataPtr getPutData(); + PvaClientPutDataPtr getPutData(); /** * @brief Get the get data. * @return The interface. */ - EasyGetDataPtr getGetData(); + PvaClientGetDataPtr getGetData(); private : - EasyPutGet( - EasyPVAPtr const &easyPVA, - EasyChannelPtr const & easyChannel, + PvaClientPutGet( + PvaClientPtr const &pvaClient, + PvaClientChannelPtr const & pvaClientChannel, epics::pvAccess::Channel::shared_pointer const & channel, epics::pvData::PVStructurePtr const &pvRequest); std::string getRequesterName(); @@ -1383,16 +1383,16 @@ private : void checkPutGetState(); enum PutGetConnectState {connectIdle,connectActive,connected}; - EasyPVA::weak_pointer easyPVA; - EasyChannel::weak_pointer easyChannel; + PvaClient::weak_pointer pvaClient; + PvaClientChannel::weak_pointer pvaClientChannel; epics::pvAccess::Channel::shared_pointer channel; epics::pvAccess::ChannelPutGetRequester::shared_pointer putGetRequester; epics::pvData::PVStructurePtr pvRequest; epics::pvData::Mutex mutex; epics::pvData::Event waitForConnect; epics::pvData::Event waitForPutGet; - EasyGetDataPtr easyGetData; - EasyPutDataPtr easyPutData; + PvaClientGetDataPtr pvaClientGetData; + PvaClientPutDataPtr pvaClientPutData; std::string messagePrefix; bool isDestroyed; @@ -1408,53 +1408,53 @@ private : friend class ChannelPutGetRequesterImpl; }; -class ChannelMonitorRequester; // private to EasyMonitor +class ChannelMonitorRequester; // private to PvaClientMonitor /** * @brief Optional client callback. * */ -class epicsShareClass EasyMonitorRequester +class epicsShareClass PvaClientMonitorRequester { public: - POINTER_DEFINITIONS(EasyMonitorRequester); + POINTER_DEFINITIONS(PvaClientMonitorRequester); /** * @brief destructor */ - virtual ~EasyMonitorRequester(){} + virtual ~PvaClientMonitorRequester(){} /** * @brief A monitor event has occurred. - * @param monitor The EasyMonitor that received the event. + * @param monitor The PvaClientMonitor that received the event. */ - virtual void event(EasyMonitorPtr monitor) = 0; + virtual void event(PvaClientMonitorPtr monitor) = 0; }; /** * @brief An easy to use alternative to Monitor. * */ -class epicsShareClass EasyMonitor : - public std::tr1::enable_shared_from_this +class epicsShareClass PvaClientMonitor : + public std::tr1::enable_shared_from_this { public: - POINTER_DEFINITIONS(EasyMonitor); + POINTER_DEFINITIONS(PvaClientMonitor); /** - * @brief Create a EasyMonitor. - * @param &easyPVA Interface to EasyPVA - * @param easyChannel Interface to EasyChannel + * @brief 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 EasyPVAStructure. + * @return The interface to the PvaClientStructure. */ - static EasyMonitorPtr create( - EasyPVAPtr const &easyPVA, - EasyChannelPtr const & easyChannel, + static PvaClientMonitorPtr create( + PvaClientPtr const &pvaClient, + PvaClientChannelPtr const & pvaClientChannel, epics::pvAccess::Channel::shared_pointer const & channel, epics::pvData::PVStructurePtr const &pvRequest ); /** * @brief destructor */ - ~EasyMonitor(); + ~PvaClientMonitor(); /** * @brief destroy an resources used. */ @@ -1477,9 +1477,9 @@ public: epics::pvData::Status waitConnect(); /** * @brief Set a user callback. - * @param easyMonitorrRequester The requester which must be implemented by the caller. + * @param pvaClientMonitorrRequester The requester which must be implemented by the caller. */ - void setRequester(EasyMonitorRequesterPtr const & easyMonitorrRequester); + void setRequester(PvaClientMonitorRequesterPtr const & pvaClientMonitorrRequester); /** * @brief Start monitoring. */ @@ -1490,13 +1490,13 @@ public: void stop(); /** * @brief poll for a monitor event. - * The data will be in EasyData. + * The data will be in PvaClientData. * @return (false,true) means event (did not, did) occur. */ bool poll(); /** * @brief wait for a monitor event. - * The data will be in EasyData. + * The data will be in PvaClientData. * @param secondsToWait Time to wait for event. * @return (false,true) means event (did not, did) occur. */ @@ -1509,18 +1509,18 @@ public: * @brief The data in which monitor events are placed. * @return The interface. */ - EasyMonitorDataPtr getData(); + PvaClientMonitorDataPtr getData(); /** * @brief get shared pointer to this */ - EasyMonitorPtr getPtrSelf() + PvaClientMonitorPtr getPtrSelf() { return shared_from_this(); } private: - EasyMonitor( - EasyPVAPtr const &easyPVA, - EasyChannelPtr const & easyChannel, + PvaClientMonitor( + PvaClientPtr const &pvaClient, + PvaClientChannelPtr const & pvaClientChannel, epics::pvAccess::Channel::shared_pointer const & channel, epics::pvData::PVStructurePtr const &pvRequest); std::string getRequesterName(); @@ -1534,22 +1534,22 @@ private: void checkMonitorState(); enum MonitorConnectState {connectIdle,connectActive,connected,monitorStarted}; - EasyPVA::weak_pointer easyPVA; - EasyChannel::weak_pointer easyChannel; + PvaClient::weak_pointer pvaClient; + PvaClientChannel::weak_pointer pvaClientChannel; epics::pvAccess::Channel::shared_pointer channel; epics::pvData::PVStructurePtr pvRequest; epics::pvData::MonitorRequester::shared_pointer monitorRequester; epics::pvData::Mutex mutex; epics::pvData::Event waitForConnect; epics::pvData::Event waitForEvent; - EasyMonitorDataPtr easyData; + PvaClientMonitorDataPtr pvaClientData; std::string messagePrefix; bool isDestroyed; epics::pvData::Status connectStatus; epics::pvData::MonitorPtr monitor; epics::pvData::MonitorElementPtr monitorElement; - EasyMonitorRequester::weak_pointer easyMonitorRequester; + PvaClientMonitorRequester::weak_pointer pvaClientMonitorRequester; MonitorConnectState connectState; bool userPoll; @@ -1562,22 +1562,22 @@ private: * * @author mrk */ -class epicsShareClass EasyMultiChannel : - public std::tr1::enable_shared_from_this +class epicsShareClass PvaClientMultiChannel : + public std::tr1::enable_shared_from_this { public: - POINTER_DEFINITIONS(EasyMultiChannel); + POINTER_DEFINITIONS(PvaClientMultiChannel); /** - * @brief Create a EasyMultiChannel. + * @brief Create a PvaClientMultiChannel. * @param channelNames The name. of the channel.. * @param providerName The name of the provider. - * @return The interface to the EasyPVAStructure. + * @return The interface to the PvaClientStructure. */ - static EasyMultiChannelPtr create( - EasyPVAPtr const &easyPVA, + static PvaClientMultiChannelPtr create( + PvaClientPtr const &pvaClient, epics::pvData::PVStringArrayPtr const & channelNames, std::string const & providerName = "pva"); - ~EasyMultiChannel(); + ~PvaClientMultiChannel(); /** * @brief Destroy the pvAccess connection. */ @@ -1614,37 +1614,37 @@ public: */ epics::pvData::PVBooleanArrayPtr getIsConnected(); /** - * Get the easyChannelArray. + * Get the pvaClientChannelArray. * @return The weak shared pointer. */ - EasyChannelArrayWPtr getEasyChannelArray(); + PvaClientChannelArrayWPtr getPvaClientChannelArray(); /** - * Get easyPVA. + * Get pvaClient. * @return The weak shared pointer. */ - EasyPVA::weak_pointer getEasyPVA(); + PvaClient::weak_pointer getPvaClient(); /** * Get the shared pointer to self. * @return The shared pointer. */ - EasyMultiChannelPtr getPtrSelf() + PvaClientMultiChannelPtr getPtrSelf() { return shared_from_this(); } private: - EasyMultiChannel( - EasyPVAPtr const &pva, + PvaClientMultiChannel( + PvaClientPtr const &pvaClient, epics::pvData::PVStringArrayPtr const & channelName, std::string const & providerName); - EasyPVA::weak_pointer easyPVA; + PvaClient::weak_pointer pvaClient; epics::pvData::PVStringArrayPtr channelName; std::string providerName; size_t numChannel; epics::pvData::Mutex mutex; size_t numConnected; - EasyChannelArrayPtr easyChannelArray; + PvaClientChannelArrayPtr pvaClientChannelArray; epics::pvData::PVBooleanArrayPtr isConnected; bool isDestroyed; }; @@ -1652,11 +1652,11 @@ private: }} -#endif /* EASYPVA_H */ +#endif /* PVACLIENT_H */ /** @page Overview Documentation * - * overview.html + * pvaClientOverview.html * */ diff --git a/src/pvaClientChannel.cpp b/src/pvaClientChannel.cpp new file mode 100644 index 0000000..57a3328 --- /dev/null +++ b/src/pvaClientChannel.cpp @@ -0,0 +1,495 @@ +/* pvaClientChannel.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 +#include +#include +#include +#include +#include + + +using std::tr1::static_pointer_cast; +using namespace epics::pvData; +using namespace epics::pvAccess; +using namespace std; + +namespace epics { namespace pvaClient { + + +class PvaClientGetCache +{ +public: + PvaClientGetCache(){} + ~PvaClientGetCache(); + void destroy() { + pvaClientGetMap.clear(); + } + PvaClientGetPtr getGet(string const & request); + void addGet(string const & request,PvaClientGetPtr const & pvaClientGet); +private: + map pvaClientGetMap; +}; + +PvaClientGetCache::~PvaClientGetCache() +{ + destroy(); +} + +PvaClientGetPtr PvaClientGetCache::getGet(string const & request) +{ + map::iterator iter = pvaClientGetMap.find(request); + if(iter!=pvaClientGetMap.end()) return iter->second; + return PvaClientGetPtr(); +} + +void PvaClientGetCache::addGet(string const & request,PvaClientGetPtr const & pvaClientGet) +{ + pvaClientGetMap.insert(std::pair( + request,pvaClientGet)); +} + + +class PvaClientPutCache +{ +public: + PvaClientPutCache(){} + ~PvaClientPutCache(); + void destroy() { + pvaClientPutMap.clear(); + } + PvaClientPutPtr getPut(string const & request); + void addPut(string const & request,PvaClientPutPtr const & pvaClientPut); +private: + map pvaClientPutMap; +}; + +PvaClientPutCache::~PvaClientPutCache() +{ + destroy(); +} + +PvaClientPutPtr PvaClientPutCache::getPut(string const & request) +{ + map::iterator iter = pvaClientPutMap.find(request); + if(iter!=pvaClientPutMap.end()) return iter->second; + return PvaClientPutPtr(); +} + +void PvaClientPutCache::addPut(string const & request,PvaClientPutPtr const & pvaClientPut) +{ + pvaClientPutMap.insert(std::pair( + request,pvaClientPut)); +} + +class ChannelRequesterImpl : public ChannelRequester +{ + PvaClientChannel *pvaClientChannel; +public: + ChannelRequesterImpl(PvaClientChannel *pvaClientChannel) + : pvaClientChannel(pvaClientChannel) {} + void channelCreated( + const Status& status, + Channel::shared_pointer const & channel) + { pvaClientChannel->channelCreated(status,channel); } + void channelStateChange( + Channel::shared_pointer const & channel, + Channel::ConnectionState connectionState) + {pvaClientChannel->channelStateChange(channel,connectionState);} + tr1::shared_ptr getChannel() {return pvaClientChannel->getChannel();} + string getRequesterName() + {return pvaClientChannel->getRequesterName();} + void message( + string const & message, + MessageType messageType) + { pvaClientChannel->message(message,messageType); } + void destroy() {pvaClientChannel->destroy();} +}; + + +PvaClientChannel::PvaClientChannel( + PvaClientPtr const &pvaClient, + string const & channelName, + string const & providerName) +: pvaClient(pvaClient), + channelName(channelName), + providerName(providerName), + connectState(connectIdle), + isDestroyed(false), + createRequest(CreateRequest::create()), + pvaClientGetCache(new PvaClientGetCache()), + pvaClientPutCache(new PvaClientPutCache()) +{} + +PvaClientChannel::~PvaClientChannel() +{ + destroy(); +} + +void PvaClientChannel::channelCreated(const Status& status, Channel::shared_pointer const & channel) +{ + if(isDestroyed) throw std::runtime_error("pvaClientChannel was destroyed"); + if(status.isOK()) { + this->channel = channel; + return; + } + cout << "PvaClientChannel::channelCreated status " << status.getMessage() << " why??\n"; +} + +void PvaClientChannel::channelStateChange( + Channel::shared_pointer const & channel, + Channel::ConnectionState connectionState) +{ + if(isDestroyed) return; + bool waitingForConnect = false; + if(connectState==connectActive) waitingForConnect = true; + if(connectionState!=Channel::CONNECTED) { + string mess(channelName + + " connection state " + Channel::ConnectionStateNames[connectionState]); + message(mess,errorMessage); + channelConnectStatus = Status(Status::STATUSTYPE_ERROR,mess); + connectState = notConnected; + } else { + connectState = connected; + } + if(waitingForConnect) waitForConnect.signal(); +} + +string PvaClientChannel::getRequesterName() +{ + PvaClientPtr yyy = pvaClient.lock(); + if(!yyy) throw std::runtime_error("PvaClient was destroyed"); + return yyy->getRequesterName(); +} + +void PvaClientChannel::message( + string const & message, + MessageType messageType) +{ + 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); +} + +void PvaClientChannel::destroy() +{ + { + Lock xx(mutex); + if(isDestroyed) return; + isDestroyed = true; + } + if(channel) channel->destroy(); + channel.reset(); + pvaClientGetCache.reset(); + pvaClientPutCache.reset(); +} + +string PvaClientChannel::getChannelName() +{ + if(isDestroyed) throw std::runtime_error("pvaClientChannel was destroyed"); + return channelName; +} + +Channel::shared_pointer PvaClientChannel::getChannel() +{ + if(isDestroyed) throw std::runtime_error("pvaClientChannel was destroyed"); + return channel; +} + +void PvaClientChannel::connect(double timeout) +{ + if(isDestroyed) throw std::runtime_error("pvaClientChannel was destroyed"); + issueConnect(); + Status status = waitConnect(timeout); + if(status.isOK()) return; + stringstream ss; + ss << "channel " << getChannelName() << " PvaClientChannel::connect " << status.getMessage(); + throw std::runtime_error(ss.str()); +} + +void PvaClientChannel::issueConnect() +{ + if(isDestroyed) throw std::runtime_error("pvaClientChannel was destroyed"); + if(connectState!=connectIdle) { + throw std::runtime_error("pvaClientChannel already connected"); + } + channelRequester = ChannelRequester::shared_pointer(new ChannelRequesterImpl(this)); + + channelConnectStatus = Status( + Status::STATUSTYPE_ERROR, + getChannelName() + " createChannel failed"); + connectState = connectActive; + ChannelProviderRegistry::shared_pointer reg = getChannelProviderRegistry(); + ChannelProvider::shared_pointer provider = reg->getProvider(providerName); + if(!provider) { + throw std::runtime_error(getChannelName() + " provider " + providerName + " not registered"); + } + channel = provider->createChannel(channelName,channelRequester,ChannelProvider::PRIORITY_DEFAULT); + if(!channel) { + throw std::runtime_error(channelConnectStatus.getMessage()); + } +} + +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()); +} + +PvaClientFieldPtr PvaClientChannel::createField() +{ + return createField(""); +} + +PvaClientFieldPtr PvaClientChannel::createField(string const & subField) +{ + throw std::runtime_error("PvaClientChannel::createField not implemented"); +} + +PvaClientProcessPtr PvaClientChannel::createProcess() +{ + return createProcess(""); +} + +PvaClientProcessPtr PvaClientChannel::createProcess(string const & request) +{ + PVStructurePtr pvRequest = createRequest->createRequest(request); + if(!pvRequest) { + stringstream ss; + ss << "channel " << getChannelName(); + ss << " PvaClientChannel::createProcess invalid pvRequest: " + createRequest->getMessage(); + throw std::runtime_error(ss.str()); + } + return createProcess(pvRequest); +} + +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); +} + +PvaClientGetPtr PvaClientChannel::get() {return get("value,alarm,timeStamp");} + +PvaClientGetPtr PvaClientChannel::get(string const & request) +{ + PvaClientGetPtr pvaClientGet = pvaClientGetCache->getGet(request); + if(pvaClientGet) return pvaClientGet; + pvaClientGet = createGet(request); + pvaClientGet->connect(); + pvaClientGetCache->addGet(request,pvaClientGet); + return pvaClientGet; +} + +PvaClientGetPtr PvaClientChannel::createGet() +{ + return PvaClientChannel::createGet("value,alarm,timeStamp"); +} + +PvaClientGetPtr PvaClientChannel::createGet(string const & request) +{ + PVStructurePtr pvRequest = createRequest->createRequest(request); + if(!pvRequest) { + stringstream ss; + ss << "channel " << getChannelName(); + ss << " PvaClientChannel::createGet invalid pvRequest: " + createRequest->getMessage(); + throw std::runtime_error(ss.str()); + } + return createGet(pvRequest); +} + +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); +} + +PvaClientPutPtr PvaClientChannel::put() {return put("value");} + +PvaClientPutPtr PvaClientChannel::put(string const & request) +{ + PvaClientPutPtr pvaClientPut = pvaClientPutCache->getPut(request); + if(pvaClientPut) return pvaClientPut; + pvaClientPut = createPut(request); + pvaClientPut->connect(); + pvaClientPut->get(); + pvaClientPutCache->addPut(request,pvaClientPut); + return pvaClientPut; +} + +PvaClientPutPtr PvaClientChannel::createPut() +{ + return createPut("value"); +} + +PvaClientPutPtr PvaClientChannel::createPut(string const & request) +{ + PVStructurePtr pvRequest = createRequest->createRequest(request); + if(!pvRequest) { + stringstream ss; + ss << "channel " << getChannelName(); + ss << " PvaClientChannel::createPut invalid pvRequest: " + createRequest->getMessage(); + throw std::runtime_error(ss.str()); + } + return createPut(pvRequest); +} + +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); +} + +PvaClientPutGetPtr PvaClientChannel::createPutGet() +{ + return createPutGet("putField(argument)getField(result)"); +} + +PvaClientPutGetPtr PvaClientChannel::createPutGet(string const & request) +{ + PVStructurePtr pvRequest = createRequest->createRequest(request); + if(!pvRequest) { + stringstream ss; + ss << "channel " << getChannelName(); + ss << " PvaClientChannel::createPutGet invalid pvRequest: " + createRequest->getMessage(); + throw std::runtime_error(ss.str()); + } + return createPutGet(pvRequest); +} + +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); +} + +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() +{ + return createArray("value"); +} + +PvaClientArrayPtr PvaClientChannel::createArray(string const & request) +{ + PVStructurePtr pvRequest = createRequest->createRequest(request); + if(!pvRequest) { + stringstream ss; + ss << "channel " << getChannelName(); + ss << " PvaClientChannel::createArray invalid pvRequest: " + createRequest->getMessage(); + throw std::runtime_error(ss.str()); + } + return createArray(pvRequest); +} + +PvaClientArrayPtr PvaClientChannel::createArray(PVStructurePtr const & pvRequest) +{ + throw std::runtime_error("PvaClientChannel::createArray not implemented"); +} + + +PvaClientMonitorPtr PvaClientChannel::monitor() {return monitor("value,alarm,timeStamp");} + +PvaClientMonitorPtr PvaClientChannel::monitor(string const & request) +{ + PvaClientMonitorPtr pvaClientMonitor = createMonitor(request); + pvaClientMonitor->connect(); + pvaClientMonitor->start(); + return pvaClientMonitor; +} + +PvaClientMonitorPtr PvaClientChannel::monitor(PvaClientMonitorRequesterPtr const & pvaClientMonitorRequester) +{ return monitor("value,alarm,timeStamp",pvaClientMonitorRequester); +} + +PvaClientMonitorPtr PvaClientChannel::monitor(string const & request, + PvaClientMonitorRequesterPtr const & pvaClientMonitorRequester) +{ + PvaClientMonitorPtr pvaClientMonitor = createMonitor(request); + pvaClientMonitor->connect(); + pvaClientMonitor->setRequester(pvaClientMonitorRequester); + pvaClientMonitor->start(); + return pvaClientMonitor; +} + +PvaClientMonitorPtr PvaClientChannel::createMonitor() +{ + return createMonitor("value,alarm,timeStamp"); +} + +PvaClientMonitorPtr PvaClientChannel::createMonitor(string const & request) +{ + PVStructurePtr pvRequest = createRequest->createRequest(request); + if(!pvRequest) { + stringstream ss; + ss << "channel " << getChannelName(); + ss << " PvaClientChannel::createMonitor invalid pvRequest: " + createRequest->getMessage(); + throw std::runtime_error(ss.str()); + } + return createMonitor(pvRequest); +} + +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); +} + + +PvaClientChannelPtr PvaClientChannel::create( + PvaClientPtr const &pvaClient, + string const & channelName, + string const & providerName) +{ + PvaClientChannelPtr channel(new PvaClientChannel(pvaClient,channelName,providerName)); + return channel; +} + +}} diff --git a/src/easyGet.cpp b/src/pvaClientGet.cpp similarity index 53% rename from src/easyGet.cpp rename to src/pvaClientGet.cpp index 55e11aa..bc8653d 100644 --- a/src/easyGet.cpp +++ b/src/pvaClientGet.cpp @@ -1,4 +1,4 @@ -/* easyGet.cpp */ +/* pvaClientGet.cpp */ /** * Copyright - See the COPYRIGHT that is included with this distribution. * EPICS pvData is distributed subject to a Software License Agreement found @@ -12,46 +12,46 @@ #include #include -#include +#include using std::tr1::static_pointer_cast; using namespace epics::pvData; using namespace epics::pvAccess; using namespace std; -namespace epics { namespace easyPVA { +namespace epics { namespace pvaClient { class ChannelGetRequesterImpl : public ChannelGetRequester { - EasyGet * easyGet; + PvaClientGet * pvaClientGet; public: - ChannelGetRequesterImpl(EasyGet * easyGet) - : easyGet(easyGet) {} + ChannelGetRequesterImpl(PvaClientGet * pvaClientGet) + : pvaClientGet(pvaClientGet) {} string getRequesterName() - {return easyGet->getRequesterName();} + {return pvaClientGet->getRequesterName();} void message(string const & message,MessageType messageType) - {easyGet->message(message,messageType);} + {pvaClientGet->message(message,messageType);} void channelGetConnect( const Status& status, ChannelGet::shared_pointer const & channelGet, StructureConstPtr const & structure) - {easyGet->channelGetConnect(status,channelGet,structure);} + {pvaClientGet->channelGetConnect(status,channelGet,structure);} void getDone( const Status& status, ChannelGet::shared_pointer const & channelGet, PVStructurePtr const & pvStructure, BitSetPtr const & bitSet) - {easyGet->getDone(status,channelGet,pvStructure,bitSet);} + {pvaClientGet->getDone(status,channelGet,pvStructure,bitSet);} }; -EasyGet::EasyGet( - EasyPVAPtr const &pva, - EasyChannelPtr const & easyChannel, +PvaClientGet::PvaClientGet( + PvaClientPtr const &pvaClient, + PvaClientChannelPtr const & pvaClientChannel, Channel::shared_pointer const & channel, PVStructurePtr const &pvRequest) -: easyPVA(pva), - easyChannel(easyChannel), +: pvaClient(pvaClient), + pvaClientChannel(pvaClientChannel), channel(channel), pvRequest(pvRequest), isDestroyed(false), @@ -60,67 +60,67 @@ EasyGet::EasyGet( { } -EasyGet::~EasyGet() +PvaClientGet::~PvaClientGet() { destroy(); } -void EasyGet::checkGetState() +void PvaClientGet::checkGetState() { - if(isDestroyed) throw std::runtime_error("easyGet was destroyed"); + if(isDestroyed) throw std::runtime_error("pvaClientGet was destroyed"); if(connectState==connectIdle) connect(); if(getState==getIdle) get(); } // from ChannelGetRequester -string EasyGet::getRequesterName() +string PvaClientGet::getRequesterName() { - EasyPVAPtr yyy = easyPVA.lock(); - if(!yyy) throw std::runtime_error("easyPVA was destroyed"); + PvaClientPtr yyy = pvaClient.lock(); + if(!yyy) throw std::runtime_error("pvaClient was destroyed"); return yyy->getRequesterName(); } -void EasyGet::message(string const & message,MessageType messageType) +void PvaClientGet::message(string const & message,MessageType messageType) { - if(isDestroyed) throw std::runtime_error("easyGet was destroyed"); - EasyPVAPtr yyy = easyPVA.lock(); - if(!yyy) throw std::runtime_error("easyPVA was destroyed"); + if(isDestroyed) throw std::runtime_error("pvaClientGet was destroyed"); + PvaClientPtr yyy = pvaClient.lock(); + if(!yyy) throw std::runtime_error("pvaClient was destroyed"); yyy->message(message, messageType); } -void EasyGet::channelGetConnect( +void PvaClientGet::channelGetConnect( const Status& status, ChannelGet::shared_pointer const & channelGet, StructureConstPtr const & structure) { - if(isDestroyed) throw std::runtime_error("easyGet was destroyed"); + if(isDestroyed) throw std::runtime_error("pvaClientGet was destroyed"); channelGetConnectStatus = status; this->channelGet = channelGet; if(status.isOK()) { - easyData = EasyGetData::create(structure); - easyData->setMessagePrefix(channel->getChannelName()); + pvaClientData = PvaClientGetData::create(structure); + pvaClientData->setMessagePrefix(channel->getChannelName()); } waitForConnect.signal(); } -void EasyGet::getDone( +void PvaClientGet::getDone( const Status& status, ChannelGet::shared_pointer const & channelGet, PVStructurePtr const & pvStructure, BitSetPtr const & bitSet) { - if(isDestroyed) throw std::runtime_error("easyGet was destroyed"); + if(isDestroyed) throw std::runtime_error("pvaClientGet was destroyed"); channelGetStatus = status; if(status.isOK()) { - easyData->setData(pvStructure,bitSet); + pvaClientData->setData(pvStructure,bitSet); } waitForGet.signal(); } -// from EasyGet -void EasyGet::destroy() +// from PvaClientGet +void PvaClientGet::destroy() { { Lock xx(mutex); @@ -131,23 +131,23 @@ void EasyGet::destroy() channelGet.reset(); } -void EasyGet::connect() +void PvaClientGet::connect() { - if(isDestroyed) throw std::runtime_error("easyGet was destroyed"); + if(isDestroyed) throw std::runtime_error("pvaClientGet was destroyed"); issueConnect(); Status status = waitConnect(); if(status.isOK()) return; stringstream ss; - ss << "channel " << channel->getChannelName() << " EasyGet::connect " << status.getMessage(); + ss << "channel " << channel->getChannelName() << " PvaClientGet::connect " << status.getMessage(); throw std::runtime_error(ss.str()); } -void EasyGet::issueConnect() +void PvaClientGet::issueConnect() { - if(isDestroyed) throw std::runtime_error("easyGet was destroyed"); + if(isDestroyed) throw std::runtime_error("pvaClientGet was destroyed"); if(connectState!=connectIdle) { stringstream ss; - ss << "channel " << channel->getChannelName() << " easyGet already connected "; + ss << "channel " << channel->getChannelName() << " pvaClientGet already connected "; throw std::runtime_error(ss.str()); } getRequester = ChannelGetRequester::shared_pointer(new ChannelGetRequesterImpl(this)); @@ -155,12 +155,12 @@ void EasyGet::issueConnect() channelGet = channel->createChannelGet(getRequester,pvRequest); } -Status EasyGet::waitConnect() +Status PvaClientGet::waitConnect() { - if(isDestroyed) throw std::runtime_error("easyGet was destroyed"); + if(isDestroyed) throw std::runtime_error("pvaClientGet was destroyed"); if(connectState!=connectActive) { stringstream ss; - ss << "channel " << channel->getChannelName() << " easyGet illegal connect state "; + ss << "channel " << channel->getChannelName() << " pvaClientGet illegal connect state "; throw std::runtime_error(ss.str()); } waitForConnect.wait(); @@ -172,36 +172,36 @@ Status EasyGet::waitConnect() return Status(Status::STATUSTYPE_ERROR,channelGetConnectStatus.getMessage()); } -void EasyGet::get() +void PvaClientGet::get() { - if(isDestroyed) throw std::runtime_error("easyGet was destroyed"); + if(isDestroyed) throw std::runtime_error("pvaClientGet was destroyed"); issueGet(); Status status = waitGet(); if(status.isOK()) return; stringstream ss; - ss << "channel " << channel->getChannelName() << " EasyGet::get " << status.getMessage(); + ss << "channel " << channel->getChannelName() << " PvaClientGet::get " << status.getMessage(); throw std::runtime_error(ss.str()); } -void EasyGet::issueGet() +void PvaClientGet::issueGet() { - if(isDestroyed) throw std::runtime_error("easyGet was destroyed"); + if(isDestroyed) throw std::runtime_error("pvaClientGet was destroyed"); if(connectState==connectIdle) connect(); if(getState!=getIdle) { stringstream ss; - ss << "channel " << channel->getChannelName() << " EasyGet::issueGet get aleady active "; + ss << "channel " << channel->getChannelName() << " PvaClientGet::issueGet get aleady active "; throw std::runtime_error(ss.str()); } getState = getActive; channelGet->get(); } -Status EasyGet::waitGet() +Status PvaClientGet::waitGet() { - if(isDestroyed) throw std::runtime_error("easyGet was destroyed"); + if(isDestroyed) throw std::runtime_error("pvaClientGet was destroyed"); if(getState!=getActive){ stringstream ss; - ss << "channel " << channel->getChannelName() << " EasyGet::waitGet llegal get state"; + ss << "channel " << channel->getChannelName() << " PvaClientGet::waitGet llegal get state"; throw std::runtime_error(ss.str()); } waitForGet.wait(); @@ -211,19 +211,19 @@ Status EasyGet::waitGet() } return Status(Status::STATUSTYPE_ERROR,channelGetStatus.getMessage()); } -EasyGetDataPtr EasyGet::getData() +PvaClientGetDataPtr PvaClientGet::getData() { checkGetState(); - return easyData; + return pvaClientData; } -EasyGetPtr EasyGet::create( - EasyPVAPtr const &pva, - EasyChannelPtr const & easyChannel, +PvaClientGetPtr PvaClientGet::create( + PvaClientPtr const &pvaClient, + PvaClientChannelPtr const & pvaClientChannel, Channel::shared_pointer const & channel, PVStructurePtr const &pvRequest) { - EasyGetPtr epv(new EasyGet(pva,easyChannel,channel,pvRequest)); + PvaClientGetPtr epv(new PvaClientGet(pvaClient,pvaClientChannel,channel,pvRequest)); return epv; } diff --git a/src/easyGetData.cpp b/src/pvaClientGetData.cpp similarity index 64% rename from src/easyGetData.cpp rename to src/pvaClientGetData.cpp index 4c72497..85314d6 100644 --- a/src/easyGetData.cpp +++ b/src/pvaClientGetData.cpp @@ -1,4 +1,4 @@ -/* easyGetData.cpp */ +/* pvaClientGetData.cpp */ /** * Copyright - See the COPYRIGHT that is included with this distribution. * EPICS pvData is distributed subject to a Software License Agreement found @@ -13,7 +13,7 @@ #include #include -#include +#include #include #include @@ -23,7 +23,7 @@ using namespace epics::pvData; using namespace epics::pvAccess; using namespace std; -namespace epics { namespace easyPVA { +namespace epics { namespace pvaClient { typedef std::tr1::shared_ptr PVArrayPtr; @@ -36,44 +36,46 @@ static string noArray("value is not an array"); static string noScalarArray("value is not a scalarArray"); static string notDoubleArray("value is not a doubleArray"); static string notStringArray("value is not a stringArray"); +static string noAlarm("no alarm"); +static string noTimeStamp("no timeStamp"); -EasyGetDataPtr EasyGetData::create(StructureConstPtr const & structure) +PvaClientGetDataPtr PvaClientGetData::create(StructureConstPtr const & structure) { - EasyGetDataPtr epv(new EasyGetData(structure)); + PvaClientGetDataPtr epv(new PvaClientGetData(structure)); return epv; } -EasyGetData::EasyGetData(StructureConstPtr const & structure) +PvaClientGetData::PvaClientGetData(StructureConstPtr const & structure) : structure(structure) {} -void EasyGetData::checkValue() +void PvaClientGetData::checkValue() { if(pvValue) return; throw std::runtime_error(messagePrefix + noValue); } -void EasyGetData::setMessagePrefix(std::string const & value) +void PvaClientGetData::setMessagePrefix(std::string const & value) { messagePrefix = value + " "; } -StructureConstPtr EasyGetData::getStructure() +StructureConstPtr PvaClientGetData::getStructure() {return structure;} -PVStructurePtr EasyGetData::getPVStructure() +PVStructurePtr PvaClientGetData::getPVStructure() { if(pvStructure) return pvStructure; throw std::runtime_error(messagePrefix + noStructure); } -BitSetPtr EasyGetData::getBitSet() +BitSetPtr PvaClientGetData::getBitSet() { if(bitSet)return bitSet; throw std::runtime_error(messagePrefix + noStructure); } -std::ostream & EasyGetData::showChanged(std::ostream & out) +std::ostream & PvaClientGetData::showChanged(std::ostream & out) { if(!bitSet) throw std::runtime_error(messagePrefix + noStructure); size_t nextSet = bitSet->nextSetBit(0); @@ -91,7 +93,7 @@ std::ostream & EasyGetData::showChanged(std::ostream & out) return out; } -void EasyGetData::setData( +void PvaClientGetData::setData( PVStructurePtr const & pvStructureFrom, BitSetPtr const & bitSetFrom) { @@ -100,33 +102,33 @@ void EasyGetData::setData( pvValue = pvStructure->getSubField("value"); } -bool EasyGetData::hasValue() +bool PvaClientGetData::hasValue() { if(!pvValue) return false; return true; } -bool EasyGetData::isValueScalar() +bool PvaClientGetData::isValueScalar() { if(!pvValue) return false; if(pvValue->getField()->getType()==scalar) return true; return false; } -bool EasyGetData::isValueScalarArray() +bool PvaClientGetData::isValueScalarArray() { if(!pvValue) return false; if(pvValue->getField()->getType()==scalarArray) return true; return false; } -PVFieldPtr EasyGetData::getValue() +PVFieldPtr PvaClientGetData::getValue() { checkValue(); return pvValue; } -PVScalarPtr EasyGetData::getScalarValue() +PVScalarPtr PvaClientGetData::getScalarValue() { checkValue(); PVScalarPtr pv = pvStructure->getSubField("value"); @@ -136,7 +138,7 @@ PVScalarPtr EasyGetData::getScalarValue() return pv; } -PVArrayPtr EasyGetData::getArrayValue() +PVArrayPtr PvaClientGetData::getArrayValue() { checkValue(); PVArrayPtr pv = pvStructure->getSubField("value"); @@ -146,7 +148,7 @@ PVArrayPtr EasyGetData::getArrayValue() return pv; } -PVScalarArrayPtr EasyGetData::getScalarArrayValue() +PVScalarArrayPtr PvaClientGetData::getScalarArrayValue() { checkValue(); PVScalarArrayPtr pv = pvStructure->getSubField("value"); @@ -156,7 +158,7 @@ PVScalarArrayPtr EasyGetData::getScalarArrayValue() return pv; } -double EasyGetData::getDouble() +double PvaClientGetData::getDouble() { PVScalarPtr pvScalar = getScalarValue(); ScalarType scalarType = pvScalar->getScalar()->getScalarType(); @@ -170,13 +172,13 @@ double EasyGetData::getDouble() return convert->toDouble(pvScalar); } -string EasyGetData::getString() +string PvaClientGetData::getString() { PVScalarPtr pvScalar = getScalarValue(); return convert->toString(pvScalar); } -shared_vector EasyGetData::getDoubleArray() +shared_vector PvaClientGetData::getDoubleArray() { checkValue(); PVDoubleArrayPtr pv = pvStructure->getSubField("value"); @@ -186,7 +188,7 @@ shared_vector EasyGetData::getDoubleArray() return pv->view(); } -shared_vector EasyGetData::getStringArray() +shared_vector PvaClientGetData::getStringArray() { checkValue(); PVStringArrayPtr pv = pvStructure->getSubField("value"); @@ -194,7 +196,41 @@ shared_vector EasyGetData::getStringArray() throw std::runtime_error(messagePrefix + notStringArray); } return pv->view(); +} + +Alarm PvaClientGetData::getAlarm() +{ + if(!pvStructure) { + throw std::runtime_error(messagePrefix + noAlarm); + } + PVStructurePtr pvs = pvStructure->getSubField("alarm"); + if(!pvs) throw std::runtime_error(messagePrefix + noAlarm); + pvAlarm.attach(pvs); + if(pvAlarm.isAttached()) { + Alarm alarm; + pvAlarm.get(alarm); + pvAlarm.detach(); + return alarm; + } + throw std::runtime_error(messagePrefix + noAlarm); +} + +TimeStamp PvaClientGetData::getTimeStamp() +{ + if(!pvStructure) { + throw std::runtime_error(messagePrefix + noTimeStamp); + } + PVStructurePtr pvs = pvStructure->getSubField("timeStamp"); + if(!pvs) throw std::runtime_error(messagePrefix + noTimeStamp); + pvTimeStamp.attach(pvs); + if(pvTimeStamp.isAttached()) { + TimeStamp timeStamp; + pvTimeStamp.get(timeStamp); + pvTimeStamp.detach(); + return timeStamp; + } + throw std::runtime_error(messagePrefix + noTimeStamp); } }} diff --git a/src/pvaClientMonitor.cpp b/src/pvaClientMonitor.cpp new file mode 100644 index 0000000..0b3be76 --- /dev/null +++ b/src/pvaClientMonitor.cpp @@ -0,0 +1,250 @@ +/* pvaClientMonitor.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 +#include +#include +#include + +using std::tr1::static_pointer_cast; +using namespace epics::pvData; +using namespace epics::pvAccess; +using namespace std; + +namespace epics { namespace pvaClient { + + +class ChannelMonitorRequester : public MonitorRequester +{ + PvaClientMonitor * pvaClientMonitor; +public: + ChannelMonitorRequester(PvaClientMonitor * pvaClientMonitor) + : pvaClientMonitor(pvaClientMonitor) {} + string getRequesterName() + {return pvaClientMonitor->getRequesterName();} + void message(string const & message,MessageType messageType) + {pvaClientMonitor->message(message,messageType);} + void monitorConnect( + const Status& status, + Monitor::shared_pointer const & monitor, + StructureConstPtr const & structure) + {pvaClientMonitor->monitorConnect(status,monitor,structure);} + void monitorEvent(MonitorPtr const & monitor) + { + pvaClientMonitor->monitorEvent(monitor); + } + void unlisten(MonitorPtr const & monitor) + {pvaClientMonitor->unlisten();} +}; + +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), + connectState(connectIdle), + userPoll(false), + userWait(false) +{ +} + +PvaClientMonitor::~PvaClientMonitor() +{ + destroy(); +} + +void PvaClientMonitor::checkMonitorState() +{ + if(isDestroyed) throw std::runtime_error("pvaClientMonitor was destroyed"); + if(connectState==connectIdle) connect(); + if(connectState==connected) start(); +} + +// from MonitorRequester +string PvaClientMonitor::getRequesterName() +{ + PvaClientPtr yyy = pvaClient.lock(); + if(!yyy) throw std::runtime_error("pvaClient was destroyed"); + return yyy->getRequesterName(); +} + +void PvaClientMonitor::message(string const & message,MessageType messageType) +{ + if(isDestroyed) throw std::runtime_error("pvaClientMonitor was destroyed"); + PvaClientPtr yyy = pvaClient.lock(); + if(!yyy) throw std::runtime_error("pvaClient was destroyed"); + yyy->message(message, messageType); +} + +void PvaClientMonitor::monitorConnect( + const Status& status, + Monitor::shared_pointer const & monitor, + StructureConstPtr const & structure) +{ + if(isDestroyed) throw std::runtime_error("pvaClientMonitor was destroyed"); + connectStatus = status; + this->monitor = monitor; + if(status.isOK()) { + pvaClientData = PvaClientMonitorData::create(structure); + pvaClientData->setMessagePrefix(channel->getChannelName()); + } + waitForConnect.signal(); + +} + +void PvaClientMonitor::monitorEvent(MonitorPtr const & monitor) +{ + PvaClientMonitorRequesterPtr req = pvaClientMonitorRequester.lock(); + if(req) req->event(getPtrSelf()); + if(userWait) waitForEvent.signal(); +} + +void PvaClientMonitor::unlisten() +{ + destroy(); +} + +// from PvaClientMonitor +void PvaClientMonitor::destroy() +{ + { + Lock xx(mutex); + if(isDestroyed) return; + isDestroyed = true; + } + if(monitor) monitor->destroy(); + monitor.reset(); +} + +void PvaClientMonitor::connect() +{ + if(isDestroyed) throw std::runtime_error("pvaClientMonitor was destroyed"); + issueConnect(); + Status status = waitConnect(); + if(status.isOK()) return; + stringstream ss; + ss << "channel " << channel->getChannelName() << " PvaClientMonitor::connect " << status.getMessage(); + throw std::runtime_error(ss.str()); +} + +void PvaClientMonitor::issueConnect() +{ + if(isDestroyed) throw std::runtime_error("pvaClientMonitor was destroyed"); + if(connectState!=connectIdle) { + stringstream ss; + ss << "channel " << channel->getChannelName() << " pvaClientMonitor already connected "; + throw std::runtime_error(ss.str()); + } + monitorRequester = ChannelMonitorRequester::shared_pointer(new ChannelMonitorRequester(this)); + connectState = connectActive; + monitor = channel->createMonitor(monitorRequester,pvRequest); +} + +Status PvaClientMonitor::waitConnect() +{ + if(isDestroyed) throw std::runtime_error("pvaClientMonitor was destroyed"); + if(connectState!=connectActive) { + stringstream ss; + ss << "channel " << channel->getChannelName() << " pvaClientMonitor illegal connect state "; + 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()); +} + +void PvaClientMonitor::setRequester(PvaClientMonitorRequesterPtr const & pvaClientMonitorrRequester) +{ + this->pvaClientMonitorRequester = pvaClientMonitorrRequester; +} + +void PvaClientMonitor::start() +{ + if(isDestroyed) throw std::runtime_error("pvaClientMonitor was destroyed"); + if(connectState==monitorStarted) return; + if(connectState==connectIdle) connect(); + if(connectState!=connected) throw std::runtime_error("PvaClientMonitor::start illegal state"); + connectState = monitorStarted; + monitor->start(); +} + + +void PvaClientMonitor::stop() +{ + if(isDestroyed) throw std::runtime_error("pvaClientMonitor was destroyed"); + if(connectState!=monitorStarted) return; + connectState = connected; + monitor->stop(); +} + +bool PvaClientMonitor::poll() +{ + checkMonitorState(); + if(connectState!=monitorStarted) throw std::runtime_error("PvaClientMonitor::poll illegal state"); + if(userPoll) throw std::runtime_error("PvaClientMonitor::poll did not release last"); + monitorElement = monitor->poll(); + if(!monitorElement) return false; + userPoll = true; + pvaClientData->setData(monitorElement); + return true; +} + +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(poll()) return true; + userWait = true; + if(secondsToWait==0.0) { + waitForEvent.wait(); + } else { + waitForEvent.wait(secondsToWait); + } + userWait = false; + return poll(); +} + +void PvaClientMonitor::releaseEvent() +{ + if(isDestroyed) throw std::runtime_error("pvaClientMonitor was destroyed"); + if(connectState!=monitorStarted) throw std::runtime_error("PvaClientMonitor::poll illegal state"); + if(!userPoll) throw std::runtime_error("PvaClientMonitor::releaseEvent did not call poll"); + userPoll = false; + monitor->release(monitorElement); +} + +PvaClientMonitorDataPtr PvaClientMonitor::getData() +{ + checkMonitorState(); + return pvaClientData; +} + +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)); + return epv; +} + +}} diff --git a/src/easyMonitorData.cpp b/src/pvaClientMonitorData.cpp similarity index 76% rename from src/easyMonitorData.cpp rename to src/pvaClientMonitorData.cpp index 7f5d9f0..768ffad 100644 --- a/src/easyMonitorData.cpp +++ b/src/pvaClientMonitorData.cpp @@ -1,4 +1,4 @@ -/* easyMonitorData.cpp */ +/* pvaClientMonitorData.cpp */ /** * Copyright - See the COPYRIGHT that is included with this distribution. * EPICS pvData is distributed subject to a Software License Agreement found @@ -13,7 +13,7 @@ #include #include -#include +#include #include #include @@ -23,7 +23,7 @@ using namespace epics::pvData; using namespace epics::pvAccess; using namespace std; -namespace epics { namespace easyPVA { +namespace epics { namespace pvaClient { typedef std::tr1::shared_ptr PVArrayPtr; @@ -39,50 +39,50 @@ static string noScalarArray("value is not a scalarArray"); static string notDoubleArray("value is not a doubleArray"); static string notStringArray("value is not a stringArray"); -EasyMonitorDataPtr EasyMonitorData::create(StructureConstPtr const & structure) +PvaClientMonitorDataPtr PvaClientMonitorData::create(StructureConstPtr const & structure) { - EasyMonitorDataPtr epv(new EasyMonitorData(structure)); + PvaClientMonitorDataPtr epv(new PvaClientMonitorData(structure)); return epv; } -EasyMonitorData::EasyMonitorData(StructureConstPtr const & structure) +PvaClientMonitorData::PvaClientMonitorData(StructureConstPtr const & structure) : structure(structure) {} -void EasyMonitorData::checkValue() +void PvaClientMonitorData::checkValue() { if(pvValue) return; throw std::runtime_error(messagePrefix + noValue); } -void EasyMonitorData::setMessagePrefix(std::string const & value) +void PvaClientMonitorData::setMessagePrefix(std::string const & value) { messagePrefix = value + " "; } -StructureConstPtr EasyMonitorData::getStructure() +StructureConstPtr PvaClientMonitorData::getStructure() {return structure;} -PVStructurePtr EasyMonitorData::getPVStructure() +PVStructurePtr PvaClientMonitorData::getPVStructure() { if(pvStructure) return pvStructure; throw std::runtime_error(messagePrefix + noStructure); } -BitSetPtr EasyMonitorData::getChangedBitSet() +BitSetPtr PvaClientMonitorData::getChangedBitSet() { if(!changedBitSet) throw std::runtime_error(messagePrefix + noStructure); return changedBitSet; } -BitSetPtr EasyMonitorData::getOverrunBitSet() +BitSetPtr PvaClientMonitorData::getOverrunBitSet() { if(!overrunBitSet) throw std::runtime_error(messagePrefix + noStructure); return overrunBitSet; } -std::ostream & EasyMonitorData::showChanged(std::ostream & out) +std::ostream & PvaClientMonitorData::showChanged(std::ostream & out) { if(!changedBitSet) throw std::runtime_error(messagePrefix + noStructure); size_t nextSet = changedBitSet->nextSetBit(0); @@ -100,7 +100,7 @@ std::ostream & EasyMonitorData::showChanged(std::ostream & out) return out; } -std::ostream & EasyMonitorData::showOverrun(std::ostream & out) +std::ostream & PvaClientMonitorData::showOverrun(std::ostream & out) { if(!overrunBitSet) throw std::runtime_error(messagePrefix + noStructure); size_t nextSet = overrunBitSet->nextSetBit(0); @@ -118,7 +118,7 @@ std::ostream & EasyMonitorData::showOverrun(std::ostream & out) return out; } -void EasyMonitorData::setData(MonitorElementPtr const & monitorElement) +void PvaClientMonitorData::setData(MonitorElementPtr const & monitorElement) { pvStructure = monitorElement->pvStructurePtr; changedBitSet = monitorElement->changedBitSet; @@ -126,33 +126,33 @@ void EasyMonitorData::setData(MonitorElementPtr const & monitorElement) pvValue = pvStructure->getSubField("value"); } -bool EasyMonitorData::hasValue() +bool PvaClientMonitorData::hasValue() { if(!pvValue) return false; return true; } -bool EasyMonitorData::isValueScalar() +bool PvaClientMonitorData::isValueScalar() { if(!pvValue) return false; if(pvValue->getField()->getType()==scalar) return true; return false; } -bool EasyMonitorData::isValueScalarArray() +bool PvaClientMonitorData::isValueScalarArray() { if(!pvValue) return false; if(pvValue->getField()->getType()==scalarArray) return true; return false; } -PVFieldPtr EasyMonitorData::getValue() +PVFieldPtr PvaClientMonitorData::getValue() { checkValue(); return pvValue; } -PVScalarPtr EasyMonitorData::getScalarValue() +PVScalarPtr PvaClientMonitorData::getScalarValue() { checkValue(); PVScalarPtr pv = pvStructure->getSubField("value"); @@ -162,7 +162,7 @@ PVScalarPtr EasyMonitorData::getScalarValue() return pv; } -PVArrayPtr EasyMonitorData::getArrayValue() +PVArrayPtr PvaClientMonitorData::getArrayValue() { checkValue(); PVArrayPtr pv = pvStructure->getSubField("value"); @@ -172,7 +172,7 @@ PVArrayPtr EasyMonitorData::getArrayValue() return pv; } -PVScalarArrayPtr EasyMonitorData::getScalarArrayValue() +PVScalarArrayPtr PvaClientMonitorData::getScalarArrayValue() { checkValue(); PVScalarArrayPtr pv = pvStructure->getSubField("value"); @@ -182,7 +182,7 @@ PVScalarArrayPtr EasyMonitorData::getScalarArrayValue() return pv; } -double EasyMonitorData::getDouble() +double PvaClientMonitorData::getDouble() { PVScalarPtr pvScalar = getScalarValue(); ScalarType scalarType = pvScalar->getScalar()->getScalarType(); @@ -196,13 +196,13 @@ double EasyMonitorData::getDouble() return convert->toDouble(pvScalar); } -string EasyMonitorData::getString() +string PvaClientMonitorData::getString() { PVScalarPtr pvScalar = getScalarValue(); return convert->toString(pvScalar); } -shared_vector EasyMonitorData::getDoubleArray() +shared_vector PvaClientMonitorData::getDoubleArray() { checkValue(); PVDoubleArrayPtr pv = pvStructure->getSubField("value"); @@ -212,7 +212,7 @@ shared_vector EasyMonitorData::getDoubleArray() return pv->view(); } -shared_vector EasyMonitorData::getStringArray() +shared_vector PvaClientMonitorData::getStringArray() { checkValue(); PVStringArrayPtr pv = pvStructure->getSubField("value"); diff --git a/src/pvaClientMultiChannel.cpp b/src/pvaClientMultiChannel.cpp new file mode 100644 index 0000000..579a308 --- /dev/null +++ b/src/pvaClientMultiChannel.cpp @@ -0,0 +1,165 @@ +/* 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 +#include +#include +#include +#include +#include + + +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()), + 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 pvaClientChannel(numChannel,PvaClientChannelPtr()); + PVStringArray::const_svector channelNames = channelName->view(); + shared_vector 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 channels = *pvaClientChannelArray.get(); + for(size_t i=0; igetChannel(); + 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 isConnected(numChannel,false); + shared_vector channels = *pvaClientChannelArray.get(); + for(size_t i=0; igetChannel(); + 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; +} + +}} diff --git a/src/pvaClientMultiDouble.cpp b/src/pvaClientMultiDouble.cpp new file mode 100644 index 0000000..6843797 --- /dev/null +++ b/src/pvaClientMultiDouble.cpp @@ -0,0 +1,139 @@ +/* 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 + +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 pvaClientChannels = *pvaClientChannelArray; + size_t numChannel = pvaClientChannels.size(); + pvaClientGet = std::vector(numChannel,PvaClientGetPtr()); + bool allOK = true; + string message; + for(size_t i=0; icreateGet("value"); + pvaClientGet[i]->issueConnect(); + } + for(size_t i=0; iwaitConnect(); + 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 pvaClientChannels = *pvaClientChannelArray; + size_t numChannel = pvaClientChannels.size(); + pvaClientPut = std::vector(numChannel,PvaClientPutPtr()); + bool allOK = true; + string message; + for(size_t i=0; icreatePut("value"); + pvaClientPut[i]->issueConnect(); + } + for(size_t i=0; iwaitConnect(); + if(!status.isOK()) { + message = "connect status " + status.getMessage(); + allOK = false; + break; + } + } + if(!allOK) throw std::runtime_error(message); +} + +epics::pvData::shared_vector PvaClientMultiDouble::get() +{ + if(pvaClientGet.empty()) createGet(); + shared_vector channelNames = pvaClientMultiChannel->getChannelNames()->view(); + size_t numChannel = channelNames.size(); + epics::pvData::shared_vector data(channelNames.size()); + for(size_t i=0; iissueGet(); + } + for(size_t i=0; iwaitGet(); + 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 const &value) +{ + if(pvaClientPut.empty()) createPut(); + shared_vector channelNames = pvaClientMultiChannel->getChannelNames()->view(); + size_t numChannel = channelNames.size(); + for(size_t i=0; igetData()->putDouble(value[i]); + pvaClientPut[i]->issuePut(); + } + for(size_t i=0; iwaitPut(); + if(!status.isOK()) { + string message = channelNames[i] + " " + status.getMessage(); + throw std::runtime_error(message); + } + } +} + + +}} diff --git a/src/easyMultiDouble.h b/src/pvaClientMultiDouble.h similarity index 58% rename from src/easyMultiDouble.h rename to src/pvaClientMultiDouble.h index f2f05e9..028f923 100644 --- a/src/easyMultiDouble.h +++ b/src/pvaClientMultiDouble.h @@ -1,4 +1,4 @@ -/* easyMultiDouble.h */ +/* pvaClientMultiDouble.h */ /** * Copyright - See the COPYRIGHT that is included with this distribution. * EPICS pvData is distributed subject to a Software License Agreement found @@ -8,20 +8,20 @@ * @author mrk * @date 2015.02 */ -#ifndef EASYMULTIDOUBLE_H -#define EASYMULTIDOUBLE_H +#ifndef PVACLIENTMULTIDOUBLE_H +#define PVACLIENTMULTIDOUBLE_H #ifdef epicsExportSharedSymbols -# define easyPVAEpicsExportSharedSymbols +# define pvaClientEpicsExportSharedSymbols # undef epicsExportSharedSymbols #endif -#include +#include -namespace epics { namespace easyPVA { +namespace epics { namespace pvaClient { -class EasyMultiDouble; -typedef std::tr1::shared_ptr EasyMultiDoublePtr; +class PvaClientMultiDouble; +typedef std::tr1::shared_ptr PvaClientMultiDoublePtr; /** * @brief Support for multiple channels where each channel has a value field that is a scalar double. @@ -29,27 +29,27 @@ typedef std::tr1::shared_ptr EasyMultiDoublePtr; * * @author mrk */ -class epicsShareClass EasyMultiDouble +class epicsShareClass PvaClientMultiDouble { public: - POINTER_DEFINITIONS(EasyMultiDouble); + POINTER_DEFINITIONS(PvaClientMultiDouble); /** - * @brief Create a EasyMultiDouble. - * @param &easyPVA Interface to EasyPVA + * @brief 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 EasyMultiDouble. + * @return The interface to PvaClientMultiDouble. */ - static EasyMultiDoublePtr create( - EasyPVAPtr const & easyPVA, + static PvaClientMultiDoublePtr create( + PvaClientPtr const & pvaClient, epics::pvData::PVStringArrayPtr const & channelName, double timeout = 5.0, std::string const & providerName = "pva"); /** * @brief destructor */ - ~EasyMultiDouble(); + ~PvaClientMultiDouble(); /** * @brief destroy any resources used. */ @@ -64,18 +64,18 @@ public: * @param value The data. */ void put(epics::pvData::shared_vector const &value); - EasyMultiChannelPtr getEasyMultiChannel(); + PvaClientMultiChannelPtr getPvaClientMultiChannel(); private: - EasyMultiDouble( - EasyMultiChannelPtr const & channelName); + PvaClientMultiDouble( + PvaClientMultiChannelPtr const & channelName); void createGet(); void createPut(); - EasyMultiChannelPtr easyMultiChannel; - std::vector easyGet; - std::vector easyPut; + PvaClientMultiChannelPtr pvaClientMultiChannel; + std::vector pvaClientGet; + std::vector pvaClientPut; }; }} -#endif // EASYMULTIDOUBLE_H +#endif // PVACLIENTMULTIDOUBLE_H diff --git a/src/easyNTMultiChannel.cpp b/src/pvaClientNTMultiChannel.cpp similarity index 71% rename from src/easyNTMultiChannel.cpp rename to src/pvaClientNTMultiChannel.cpp index cd00755..835f33f 100644 --- a/src/easyNTMultiChannel.cpp +++ b/src/pvaClientNTMultiChannel.cpp @@ -1,4 +1,4 @@ -/* easyNTMultiChannel.cpp */ +/* pvaClientNTMultiChannel.cpp */ /** * Copyright - See the COPYRIGHT that is included with this distribution. * EPICS pvData is distributed subject to a Software License Agreement found @@ -9,7 +9,8 @@ * @date 2015.03 */ -#include +#define epicsExportSharedSymbols +#include using std::tr1::static_pointer_cast; using namespace epics::pvData; @@ -17,44 +18,44 @@ using namespace epics::pvAccess; using namespace epics::nt; using namespace std; -namespace epics { namespace easyPVA { +namespace epics { namespace pvaClient { -EasyNTMultiChannelPtr EasyNTMultiChannel::create( - EasyPVAPtr const & easyPVA, +PvaClientNTMultiChannelPtr PvaClientNTMultiChannel::create( + PvaClientPtr const & pvaClient, PVStringArrayPtr const & channelName, StructureConstPtr const &structure, double timeout, std::string const & providerName) { - EasyMultiChannelPtr easyMultiChannel( - EasyMultiChannel::create(easyPVA,channelName,providerName)); - Status status = easyMultiChannel->connect(timeout,0); + 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("channelName")-> - replace(easyMultiChannel->getChannelNames()->view()); + replace(pvaClientMultiChannel->getChannelNames()->view()); pvStructure->getSubField("isConnected")-> - replace(easyMultiChannel->getIsConnected()->view()); + replace(pvaClientMultiChannel->getIsConnected()->view()); NTMultiChannelPtr ntMultiChannel(NTMultiChannel::wrap(pvStructure)); - return EasyNTMultiChannelPtr(new EasyNTMultiChannel(easyMultiChannel,ntMultiChannel)); + return PvaClientNTMultiChannelPtr(new PvaClientNTMultiChannel(pvaClientMultiChannel,ntMultiChannel)); } -EasyNTMultiChannel::EasyNTMultiChannel( - EasyMultiChannelPtr const &easyMultiChannel, +PvaClientNTMultiChannel::PvaClientNTMultiChannel( + PvaClientMultiChannelPtr const &pvaClientMultiChannel, NTMultiChannelPtr const &ntMultiChannel) : - easyMultiChannel(easyMultiChannel), + pvaClientMultiChannel(pvaClientMultiChannel), ntMultiChannel(ntMultiChannel), pvUnionArray(ntMultiChannel->getPVStructure()->getSubField("value")), pvDataCreate(getPVDataCreate()) {} -EasyNTMultiChannel::~EasyNTMultiChannel() +PvaClientNTMultiChannel::~PvaClientNTMultiChannel() { } -void EasyNTMultiChannel::createGet() +void PvaClientNTMultiChannel::createGet() { PVStructurePtr pvStructure = ntMultiChannel->getPVStructure(); bool getAlarm = false; @@ -68,21 +69,21 @@ void EasyNTMultiChannel::createGet() string request = "value"; if(getAlarm) request += ",alarm"; if(getTimeStamp) request += ",timeStamp"; - EasyChannelArrayPtr easyChannelArray = easyMultiChannel->getEasyChannelArray().lock(); - if(!easyChannelArray) throw std::runtime_error("easyChannelArray is gone"); - shared_vector easyChannels = *easyChannelArray; - size_t numChannel = easyChannels.size(); - easyGet = std::vector(numChannel,EasyGetPtr()); + PvaClientChannelArrayPtr pvaClientChannelArray = pvaClientMultiChannel->getPvaClientChannelArray().lock(); + if(!pvaClientChannelArray) throw std::runtime_error("pvaClientChannelArray is gone"); + shared_vector pvaClientChannels = *pvaClientChannelArray; + size_t numChannel = pvaClientChannels.size(); + pvaClientGet = std::vector(numChannel,PvaClientGetPtr()); bool allOK = true; string message; for(size_t i=0; icreateGet(request); - easyGet[i]->issueConnect(); + pvaClientGet[i] = pvaClientChannels[i]->createGet(request); + pvaClientGet[i]->issueConnect(); } for(size_t i=0; iwaitConnect(); + Status status = pvaClientGet[i]->waitConnect(); if(!status.isOK()) { message = "connect status " + status.getMessage(); allOK = false; @@ -93,23 +94,23 @@ void EasyNTMultiChannel::createGet() } -void EasyNTMultiChannel::createPut() +void PvaClientNTMultiChannel::createPut() { - EasyChannelArrayPtr easyChannelArray = easyMultiChannel->getEasyChannelArray().lock(); - if(!easyChannelArray) throw std::runtime_error("easyChannelArray is gone"); - shared_vector easyChannels = *easyChannelArray; - size_t numChannel = easyChannels.size(); - easyPut = std::vector(numChannel,EasyPutPtr()); + PvaClientChannelArrayPtr pvaClientChannelArray = pvaClientMultiChannel->getPvaClientChannelArray().lock(); + if(!pvaClientChannelArray) throw std::runtime_error("pvaClientChannelArray is gone"); + shared_vector pvaClientChannels = *pvaClientChannelArray; + size_t numChannel = pvaClientChannels.size(); + pvaClientPut = std::vector(numChannel,PvaClientPutPtr()); bool allOK = true; string message; for(size_t i=0; icreatePut("value"); - easyPut[i]->issueConnect(); + pvaClientPut[i] = pvaClientChannels[i]->createPut("value"); + pvaClientPut[i]->issueConnect(); } for(size_t i=0; iwaitConnect(); + Status status = pvaClientPut[i]->waitConnect(); if(!status.isOK()) { message = "connect status " + status.getMessage(); allOK = false; @@ -119,11 +120,11 @@ void EasyNTMultiChannel::createPut() if(!allOK) throw std::runtime_error(message); } -NTMultiChannelPtr EasyNTMultiChannel::get() +NTMultiChannelPtr PvaClientNTMultiChannel::get() { - if(easyGet.empty()) createGet(); + if(pvaClientGet.empty()) createGet(); PVStructurePtr pvStructure = ntMultiChannel->getPVStructure(); - shared_vector channelNames = easyMultiChannel->getChannelNames()->view(); + shared_vector channelNames = pvaClientMultiChannel->getChannelNames()->view(); size_t numChannel = channelNames.size(); bool severityExists = false; bool statusExists = false; @@ -158,16 +159,16 @@ NTMultiChannelPtr EasyNTMultiChannel::get() shared_vector valueVector(numChannel); for(size_t i=0; iissueGet(); + pvaClientGet[i]->issueGet(); } for(size_t i=0; iwaitGet(); + Status stat = pvaClientGet[i]->waitGet(); if(!stat.isOK()) { string message = channelNames[i] + " " + stat.getMessage(); throw std::runtime_error(message); } - PVStructurePtr pvStructure = easyGet[i]->getData()->getPVStructure(); + PVStructurePtr pvStructure = pvaClientGet[i]->getData()->getPVStructure(); PVFieldPtr pvField = pvStructure->getSubField("value"); if(!pvField) { string message = channelNames[i] + " no value field"; @@ -228,10 +229,10 @@ NTMultiChannelPtr EasyNTMultiChannel::get() return ntMultiChannel; } -void EasyNTMultiChannel::put(NTMultiChannelPtr const &value) +void PvaClientNTMultiChannel::put(NTMultiChannelPtr const &value) { - if(easyPut.empty()) createPut(); - shared_vector channelNames = easyMultiChannel->getChannelNames()->view(); + if(pvaClientPut.empty()) createPut(); + shared_vector channelNames = pvaClientMultiChannel->getChannelNames()->view(); size_t numChannel = channelNames.size(); PVUnionArrayPtr pvValue = value->getPVStructure()-> getSubField("value"); @@ -240,7 +241,7 @@ void EasyNTMultiChannel::put(NTMultiChannelPtr const &value) { try { PVFieldPtr pvFrom = valueVector[i]->get(); - PVFieldPtr pvTo = easyPut[i]->getData()->getValue(); + PVFieldPtr pvTo = pvaClientPut[i]->getData()->getValue(); Type typeFrom = pvFrom->getField()->getType(); Type typeTo = pvTo->getField()->getType(); if(typeFrom==typeTo) { @@ -248,7 +249,7 @@ void EasyNTMultiChannel::put(NTMultiChannelPtr const &value) pvTo->copy(*pvFrom); } } - easyPut[i]->issuePut(); + pvaClientPut[i]->issuePut(); } catch (std::exception e) { string message = channelNames[i] + " " + e.what(); throw std::runtime_error(message); @@ -256,7 +257,7 @@ void EasyNTMultiChannel::put(NTMultiChannelPtr const &value) } for(size_t i=0; iwaitPut(); + Status status = pvaClientPut[i]->waitPut(); if(!status.isOK()) { string message = channelNames[i] + " " + status.getMessage(); throw std::runtime_error(message); diff --git a/src/easyNTMultiChannel.h b/src/pvaClientNTMultiChannel.h similarity index 68% rename from src/easyNTMultiChannel.h rename to src/pvaClientNTMultiChannel.h index ab31a3f..aee1ff0 100644 --- a/src/easyNTMultiChannel.h +++ b/src/pvaClientNTMultiChannel.h @@ -1,4 +1,4 @@ -/* easyNTMultiChannel.h */ +/* pvaClientNTMultiChannel.h */ /** * Copyright - See the COPYRIGHT that is included with this distribution. * EPICS pvData is distributed subject to a Software License Agreement found @@ -8,20 +8,20 @@ * @author mrk * @date 2015.02 */ -#ifndef EASYNTMULTIChannel_H -#define EASYNTMULTIChannel_H +#ifndef PVACLIENTNTMULTIChannel_H +#define PVACLIENTNTMULTIChannel_H #ifdef epicsExportSharedSymbols -# define easyPVAEpicsExportSharedSymbols +# define pvaClientEpicsExportSharedSymbols # undef epicsExportSharedSymbols #endif -#include +#include -namespace epics { namespace easyPVA { +namespace epics { namespace pvaClient { -class EasyNTMultiChannel; -typedef std::tr1::shared_ptr EasyNTMultiChannelPtr; +class PvaClientNTMultiChannel; +typedef std::tr1::shared_ptr PvaClientNTMultiChannelPtr; /** * @brief Support for multiple channels where each channel has a value field that @@ -31,21 +31,21 @@ typedef std::tr1::shared_ptr EasyNTMultiChannelPtr; * * @author mrk */ -class epicsShareClass EasyNTMultiChannel +class epicsShareClass PvaClientNTMultiChannel { public: - POINTER_DEFINITIONS(EasyNTMultiChannel); + POINTER_DEFINITIONS(PvaClientNTMultiChannel); /** - * @brief Create a EasyNTMultiChannel. - * @param &easyPVA Interface to EasyPVA + * @brief 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 EasyNTMultiChannel. + * @return The interface to PvaClientNTMultiChannel. */ - static EasyNTMultiChannelPtr create( - EasyPVAPtr const & easyPVA, + static PvaClientNTMultiChannelPtr create( + PvaClientPtr const & pvaClient, epics::pvData::PVStringArrayPtr const & channelName, epics::pvData::StructureConstPtr const & structure, double timeout = 5.0, @@ -53,7 +53,7 @@ public: /** * @brief destructor */ - ~EasyNTMultiChannel(); + ~PvaClientNTMultiChannel(); /** * @brief destroy any resources used. */ @@ -69,23 +69,23 @@ public: */ void put(epics::nt::NTMultiChannelPtr const &value); /** - * @brief Get the EasyMultiChannel. + * @brief Get the PvaClientMultiChannel. * @return The interface. */ - EasyMultiChannelPtr getEasyMultiChannel(); + PvaClientMultiChannelPtr getPvaClientMultiChannel(); private: - EasyNTMultiChannel( - EasyMultiChannelPtr const & channelName, + PvaClientNTMultiChannel( + PvaClientMultiChannelPtr const & channelName, epics::nt::NTMultiChannelPtr const &ntMultiChannel); void createGet(); void createPut(); - EasyMultiChannelPtr easyMultiChannel; + PvaClientMultiChannelPtr pvaClientMultiChannel; epics::nt::NTMultiChannelPtr ntMultiChannel; epics::pvData::PVUnionArrayPtr pvUnionArray; epics::pvData::PVDataCreatePtr pvDataCreate; - std::vector easyGet; - std::vector easyPut; + std::vector pvaClientGet; + std::vector pvaClientPut; epics::pvData::shared_vector severity; epics::pvData::shared_vector status; epics::pvData::shared_vector message; @@ -100,4 +100,4 @@ private: }} -#endif // EASYNTMULTIChannel_H +#endif // PVACLIENTNTMULTIChannel_H diff --git a/src/easyProcess.cpp b/src/pvaClientProcess.cpp similarity index 53% rename from src/easyProcess.cpp rename to src/pvaClientProcess.cpp index c4be166..79d54f6 100644 --- a/src/easyProcess.cpp +++ b/src/pvaClientProcess.cpp @@ -1,4 +1,4 @@ -/* easyProcess.cpp */ +/* pvaClientProcess.cpp */ /** * Copyright - See the COPYRIGHT that is included with this distribution. * EPICS pvData is distributed subject to a Software License Agreement found @@ -12,43 +12,43 @@ #include #include -#include +#include using std::tr1::static_pointer_cast; using namespace epics::pvData; using namespace epics::pvAccess; using namespace std; -namespace epics { namespace easyPVA { +namespace epics { namespace pvaClient { class ChannelProcessRequesterImpl : public ChannelProcessRequester { - EasyProcess * easyProcess; + PvaClientProcess * pvaClientProcess; public: - ChannelProcessRequesterImpl(EasyProcess * easyProcess) - : easyProcess(easyProcess) {} + ChannelProcessRequesterImpl(PvaClientProcess * pvaClientProcess) + : pvaClientProcess(pvaClientProcess) {} string getRequesterName() - {return easyProcess->getRequesterName();} + {return pvaClientProcess->getRequesterName();} void message(string const & message,MessageType messageType) - {easyProcess->message(message,messageType);} + {pvaClientProcess->message(message,messageType);} void channelProcessConnect( const Status& status, ChannelProcess::shared_pointer const & channelProcess) - {easyProcess->channelProcessConnect(status,channelProcess);} + {pvaClientProcess->channelProcessConnect(status,channelProcess);} void processDone( const Status& status, ChannelProcess::shared_pointer const & channelProcess) - {easyProcess->processDone(status,channelProcess);} + {pvaClientProcess->processDone(status,channelProcess);} }; -EasyProcess::EasyProcess( - EasyPVAPtr const &pva, - EasyChannelPtr const & easyChannel, +PvaClientProcess::PvaClientProcess( + PvaClientPtr const &pvaClient, + PvaClientChannelPtr const & pvaClientChannel, Channel::shared_pointer const & channel, PVStructurePtr const &pvRequest) -: easyPVA(pva), - easyChannel(easyChannel), +: pvaClient(pvaClient), + pvaClientChannel(pvaClientChannel), channel(channel), pvRequest(pvRequest), isDestroyed(false), @@ -57,57 +57,57 @@ EasyProcess::EasyProcess( { } -EasyProcess::~EasyProcess() +PvaClientProcess::~PvaClientProcess() { destroy(); } -void EasyProcess::checkProcessState() +void PvaClientProcess::checkProcessState() { - if(isDestroyed) throw std::runtime_error("easyProcess was destroyed"); + if(isDestroyed) throw std::runtime_error("pvaClientProcess was destroyed"); if(connectState==connectIdle) connect(); if(processState==processIdle) process(); } // from ChannelProcessRequester -string EasyProcess::getRequesterName() +string PvaClientProcess::getRequesterName() { - EasyPVAPtr yyy = easyPVA.lock(); - if(!yyy) throw std::runtime_error("easyPVA was destroyed"); + PvaClientPtr yyy = pvaClient.lock(); + if(!yyy) throw std::runtime_error("pvaClient was destroyed"); return yyy->getRequesterName(); } -void EasyProcess::message(string const & message,MessageType messageType) +void PvaClientProcess::message(string const & message,MessageType messageType) { - if(isDestroyed) throw std::runtime_error("easyProcess was destroyed"); - EasyPVAPtr yyy = easyPVA.lock(); - if(!yyy) throw std::runtime_error("easyPVA was destroyed"); + if(isDestroyed) throw std::runtime_error("pvaClientProcess was destroyed"); + PvaClientPtr yyy = pvaClient.lock(); + if(!yyy) throw std::runtime_error("pvaClient was destroyed"); yyy->message(message, messageType); } -void EasyProcess::channelProcessConnect( +void PvaClientProcess::channelProcessConnect( const Status& status, ChannelProcess::shared_pointer const & channelProcess) { - if(isDestroyed) throw std::runtime_error("easyProcess was destroyed"); + if(isDestroyed) throw std::runtime_error("pvaClientProcess was destroyed"); channelProcessConnectStatus = status; this->channelProcess = channelProcess; waitForConnect.signal(); } -void EasyProcess::processDone( +void PvaClientProcess::processDone( const Status& status, ChannelProcess::shared_pointer const & channelProcess) { - if(isDestroyed) throw std::runtime_error("easyProcess was destroyed"); + if(isDestroyed) throw std::runtime_error("pvaClientProcess was destroyed"); channelProcessStatus = status; waitForProcess.signal(); } -// from EasyProcess -void EasyProcess::destroy() +// from PvaClientProcess +void PvaClientProcess::destroy() { { Lock xx(mutex); @@ -118,23 +118,23 @@ void EasyProcess::destroy() channelProcess.reset(); } -void EasyProcess::connect() +void PvaClientProcess::connect() { - if(isDestroyed) throw std::runtime_error("easyProcess was destroyed"); + if(isDestroyed) throw std::runtime_error("pvaClientProcess was destroyed"); issueConnect(); Status status = waitConnect(); if(status.isOK()) return; stringstream ss; - ss << "channel " << channel->getChannelName() << " EasyProcess::connect " << status.getMessage(); + ss << "channel " << channel->getChannelName() << " PvaClientProcess::connect " << status.getMessage(); throw std::runtime_error(ss.str()); } -void EasyProcess::issueConnect() +void PvaClientProcess::issueConnect() { - if(isDestroyed) throw std::runtime_error("easyProcess was destroyed"); + if(isDestroyed) throw std::runtime_error("pvaClientProcess was destroyed"); if(connectState!=connectIdle) { stringstream ss; - ss << "channel " << channel->getChannelName() << " easyProcess already connected "; + ss << "channel " << channel->getChannelName() << " pvaClientProcess already connected "; throw std::runtime_error(ss.str()); } processRequester = ChannelProcessRequester::shared_pointer(new ChannelProcessRequesterImpl(this)); @@ -142,12 +142,12 @@ void EasyProcess::issueConnect() channelProcess = channel->createChannelProcess(processRequester,pvRequest); } -Status EasyProcess::waitConnect() +Status PvaClientProcess::waitConnect() { - if(isDestroyed) throw std::runtime_error("easyProcess was destroyed"); + if(isDestroyed) throw std::runtime_error("pvaClientProcess was destroyed"); if(connectState!=connectActive) { stringstream ss; - ss << "channel " << channel->getChannelName() << " easyProcess illegal connect state "; + ss << "channel " << channel->getChannelName() << " pvaClientProcess illegal connect state "; throw std::runtime_error(ss.str()); } waitForConnect.wait(); @@ -159,36 +159,36 @@ Status EasyProcess::waitConnect() return Status(Status::STATUSTYPE_ERROR,channelProcessConnectStatus.getMessage()); } -void EasyProcess::process() +void PvaClientProcess::process() { - if(isDestroyed) throw std::runtime_error("easyProcess was destroyed"); + if(isDestroyed) throw std::runtime_error("pvaClientProcess was destroyed"); issueProcess(); Status status = waitProcess(); if(status.isOK()) return; stringstream ss; - ss << "channel " << channel->getChannelName() << " EasyProcess::process " << status.getMessage(); + ss << "channel " << channel->getChannelName() << " PvaClientProcess::process " << status.getMessage(); throw std::runtime_error(ss.str()); } -void EasyProcess::issueProcess() +void PvaClientProcess::issueProcess() { - if(isDestroyed) throw std::runtime_error("easyProcess was destroyed"); + if(isDestroyed) throw std::runtime_error("pvaClientProcess was destroyed"); if(connectState==connectIdle) connect(); if(processState!=processIdle) { stringstream ss; - ss << "channel " << channel->getChannelName() << " EasyProcess::issueProcess process aleady active "; + ss << "channel " << channel->getChannelName() << " PvaClientProcess::issueProcess process aleady active "; throw std::runtime_error(ss.str()); } processState = processActive; channelProcess->process(); } -Status EasyProcess::waitProcess() +Status PvaClientProcess::waitProcess() { - if(isDestroyed) throw std::runtime_error("easyProcess was destroyed"); + if(isDestroyed) throw std::runtime_error("pvaClientProcess was destroyed"); if(processState!=processActive){ stringstream ss; - ss << "channel " << channel->getChannelName() << " EasyProcess::waitProcess llegal process state"; + ss << "channel " << channel->getChannelName() << " PvaClientProcess::waitProcess llegal process state"; throw std::runtime_error(ss.str()); } waitForProcess.wait(); @@ -199,13 +199,13 @@ Status EasyProcess::waitProcess() return Status(Status::STATUSTYPE_ERROR,channelProcessStatus.getMessage()); } -EasyProcessPtr EasyProcess::create( - EasyPVAPtr const &pva, - EasyChannelPtr const & easyChannel, +PvaClientProcessPtr PvaClientProcess::create( + PvaClientPtr const &pvaClient, + PvaClientChannelPtr const & pvaClientChannel, Channel::shared_pointer const & channel, PVStructurePtr const &pvRequest) { - EasyProcessPtr epv(new EasyProcess(pva,easyChannel,channel,pvRequest)); + PvaClientProcessPtr epv(new PvaClientProcess(pvaClient,pvaClientChannel,channel,pvRequest)); return epv; } diff --git a/src/easyPut.cpp b/src/pvaClientPut.cpp similarity index 52% rename from src/easyPut.cpp rename to src/pvaClientPut.cpp index 6ba7e9d..a09ccf0 100644 --- a/src/easyPut.cpp +++ b/src/pvaClientPut.cpp @@ -1,4 +1,4 @@ -/* easyPut.cpp */ +/* pvaClientPut.cpp */ /** * Copyright - See the COPYRIGHT that is included with this distribution. * EPICS pvData is distributed subject to a Software License Agreement found @@ -12,49 +12,49 @@ #include #include -#include +#include using std::tr1::static_pointer_cast; using namespace epics::pvData; using namespace epics::pvAccess; using namespace std; -namespace epics { namespace easyPVA { +namespace epics { namespace pvaClient { class ChannelPutRequesterImpl : public ChannelPutRequester { - EasyPut * easyPut; + PvaClientPut * pvaClientPut; public: - ChannelPutRequesterImpl(EasyPut * easyPut) - : easyPut(easyPut) {} + ChannelPutRequesterImpl(PvaClientPut * pvaClientPut) + : pvaClientPut(pvaClientPut) {} string getRequesterName() - {return easyPut->getRequesterName();} + {return pvaClientPut->getRequesterName();} void message(string const & message,MessageType messageType) - {easyPut->message(message,messageType);} + {pvaClientPut->message(message,messageType);} void channelPutConnect( const Status& status, ChannelPut::shared_pointer const & channelPut, StructureConstPtr const & structure) - {easyPut->channelPutConnect(status,channelPut,structure);} + {pvaClientPut->channelPutConnect(status,channelPut,structure);} void getDone( const Status& status, ChannelPut::shared_pointer const & channelPut, PVStructurePtr const & pvStructure, BitSetPtr const & bitSet) - {easyPut->getDone(status,channelPut,pvStructure,bitSet);} + {pvaClientPut->getDone(status,channelPut,pvStructure,bitSet);} void putDone( const Status& status, ChannelPut::shared_pointer const & channelPut) - {easyPut->putDone(status,channelPut);} + {pvaClientPut->putDone(status,channelPut);} }; -EasyPut::EasyPut( - EasyPVAPtr const &pva, - EasyChannelPtr const & easyChannel, +PvaClientPut::PvaClientPut( + PvaClientPtr const &pvaClient, + PvaClientChannelPtr const & pvaClientChannel, Channel::shared_pointer const & channel, PVStructurePtr const &pvRequest) -: easyPVA(pva), - easyChannel(easyChannel), +: pvaClient(pvaClient), + pvaClientChannel(pvaClientChannel), channel(channel), pvRequest(pvRequest), isDestroyed(false), @@ -63,14 +63,14 @@ EasyPut::EasyPut( { } -EasyPut::~EasyPut() +PvaClientPut::~PvaClientPut() { destroy(); } -void EasyPut::checkPutState() +void PvaClientPut::checkPutState() { - if(isDestroyed) throw std::runtime_error("easyPut was destroyed"); + if(isDestroyed) throw std::runtime_error("pvaClientPut was destroyed"); if(connectState==connectIdle){ connect(); get(); @@ -78,67 +78,67 @@ void EasyPut::checkPutState() } // from ChannelPutRequester -string EasyPut::getRequesterName() +string PvaClientPut::getRequesterName() { - EasyPVAPtr yyy = easyPVA.lock(); - if(!yyy) throw std::runtime_error("easyPVA was destroyed"); + PvaClientPtr yyy = pvaClient.lock(); + if(!yyy) throw std::runtime_error("pvaClient was destroyed"); return yyy->getRequesterName(); } -void EasyPut::message(string const & message,MessageType messageType) +void PvaClientPut::message(string const & message,MessageType messageType) { - if(isDestroyed) throw std::runtime_error("easyPut was destroyed"); - EasyPVAPtr yyy = easyPVA.lock(); - if(!yyy) throw std::runtime_error("easyPVA was destroyed"); + if(isDestroyed) throw std::runtime_error("pvaClientPut was destroyed"); + PvaClientPtr yyy = pvaClient.lock(); + if(!yyy) throw std::runtime_error("pvaClient was destroyed"); yyy->message(message, messageType); } -void EasyPut::channelPutConnect( +void PvaClientPut::channelPutConnect( const Status& status, ChannelPut::shared_pointer const & channelPut, StructureConstPtr const & structure) { - if(isDestroyed) throw std::runtime_error("easyPut was destroyed"); + if(isDestroyed) throw std::runtime_error("pvaClientPut was destroyed"); channelPutConnectStatus = status; this->channelPut = channelPut; if(status.isOK()) { - easyData = EasyPutData::create(structure); - easyData->setMessagePrefix(easyChannel.lock()->getChannelName()); + pvaClientData = PvaClientPutData::create(structure); + pvaClientData->setMessagePrefix(pvaClientChannel.lock()->getChannelName()); } waitForConnect.signal(); } -void EasyPut::getDone( +void PvaClientPut::getDone( const Status& status, ChannelPut::shared_pointer const & channelPut, PVStructurePtr const & pvStructure, BitSetPtr const & bitSet) { - if(isDestroyed) throw std::runtime_error("easyPut was destroyed"); + if(isDestroyed) throw std::runtime_error("pvaClientPut was destroyed"); channelGetPutStatus = status; if(status.isOK()) { - PVStructurePtr pvs = easyData->getPVStructure(); + PVStructurePtr pvs = pvaClientData->getPVStructure(); pvs->copyUnchecked(*pvStructure,*bitSet); - BitSetPtr bs = easyData->getBitSet(); + BitSetPtr bs = pvaClientData->getBitSet(); bs->clear(); *bs |= *bitSet; } waitForGetPut.signal(); } -void EasyPut::putDone( +void PvaClientPut::putDone( const Status& status, ChannelPut::shared_pointer const & channelPut) { - if(isDestroyed) throw std::runtime_error("easyPut was destroyed"); + if(isDestroyed) throw std::runtime_error("pvaClientPut was destroyed"); channelGetPutStatus = status; waitForGetPut.signal(); } -// from EasyPut -void EasyPut::destroy() +// from PvaClientPut +void PvaClientPut::destroy() { { Lock xx(mutex); @@ -149,23 +149,23 @@ void EasyPut::destroy() channelPut.reset(); } -void EasyPut::connect() +void PvaClientPut::connect() { - if(isDestroyed) throw std::runtime_error("easyPut was destroyed"); + if(isDestroyed) throw std::runtime_error("pvaClientPut was destroyed"); issueConnect(); Status status = waitConnect(); if(status.isOK()) return; stringstream ss; - ss << "channel " << channel->getChannelName() << " EasyPut::connect " << status.getMessage(); + ss << "channel " << channel->getChannelName() << " PvaClientPut::connect " << status.getMessage(); throw std::runtime_error(ss.str()); } -void EasyPut::issueConnect() +void PvaClientPut::issueConnect() { - if(isDestroyed) throw std::runtime_error("easyPut was destroyed"); + if(isDestroyed) throw std::runtime_error("pvaClientPut was destroyed"); if(connectState!=connectIdle) { stringstream ss; - ss << "channel " << channel->getChannelName() << " easyPut already connected "; + ss << "channel " << channel->getChannelName() << " pvaClientPut already connected "; throw std::runtime_error(ss.str()); } putRequester = ChannelPutRequester::shared_pointer(new ChannelPutRequesterImpl(this)); @@ -173,12 +173,12 @@ void EasyPut::issueConnect() channelPut = channel->createChannelPut(putRequester,pvRequest); } -Status EasyPut::waitConnect() +Status PvaClientPut::waitConnect() { - if(isDestroyed) throw std::runtime_error("easyPut was destroyed"); + if(isDestroyed) throw std::runtime_error("pvaClientPut was destroyed"); if(connectState!=connectActive) { stringstream ss; - ss << "channel " << channel->getChannelName() << " easyPut illegal connect state "; + ss << "channel " << channel->getChannelName() << " pvaClientPut illegal connect state "; throw std::runtime_error(ss.str()); } waitForConnect.wait(); @@ -190,37 +190,37 @@ Status EasyPut::waitConnect() return Status(Status::STATUSTYPE_ERROR,channelPutConnectStatus.getMessage()); } -void EasyPut::get() +void PvaClientPut::get() { - if(isDestroyed) throw std::runtime_error("easyPut was destroyed"); + if(isDestroyed) throw std::runtime_error("pvaClientPut was destroyed"); issueGet(); Status status = waitGet(); if(status.isOK()) return; stringstream ss; - ss << "channel " << channel->getChannelName() << " EasyPut::get " << status.getMessage(); + ss << "channel " << channel->getChannelName() << " PvaClientPut::get " << status.getMessage(); throw std::runtime_error(ss.str()); } -void EasyPut::issueGet() +void PvaClientPut::issueGet() { - if(isDestroyed) throw std::runtime_error("easyPut was destroyed"); + if(isDestroyed) throw std::runtime_error("pvaClientPut was destroyed"); if(connectState==connectIdle) connect(); if(putState!=putIdle) { stringstream ss; - ss << "channel " << channel->getChannelName() << " EasyPut::issueGet get or put aleady active "; + ss << "channel " << channel->getChannelName() << " PvaClientPut::issueGet get or put aleady active "; throw std::runtime_error(ss.str()); } putState = getActive; - easyData->getBitSet()->clear(); + pvaClientData->getBitSet()->clear(); channelPut->get(); } -Status EasyPut::waitGet() +Status PvaClientPut::waitGet() { - if(isDestroyed) throw std::runtime_error("easyPut was destroyed"); + if(isDestroyed) throw std::runtime_error("pvaClientPut was destroyed"); if(putState!=getActive){ stringstream ss; - ss << "channel " << channel->getChannelName() << " EasyPut::waitGet llegal put state"; + ss << "channel " << channel->getChannelName() << " PvaClientPut::waitGet llegal put state"; throw std::runtime_error(ss.str()); } waitForGetPut.wait(); @@ -231,60 +231,60 @@ Status EasyPut::waitGet() return Status(Status::STATUSTYPE_ERROR,channelGetPutStatus.getMessage()); } -void EasyPut::put() +void PvaClientPut::put() { - if(isDestroyed) throw std::runtime_error("easyPut was destroyed"); + if(isDestroyed) throw std::runtime_error("pvaClientPut was destroyed"); issuePut(); Status status = waitPut(); if(status.isOK()) return; stringstream ss; - ss << "channel " << channel->getChannelName() << " EasyPut::put " << status.getMessage(); + ss << "channel " << channel->getChannelName() << " PvaClientPut::put " << status.getMessage(); throw std::runtime_error(ss.str()); } -void EasyPut::issuePut() +void PvaClientPut::issuePut() { - if(isDestroyed) throw std::runtime_error("easyPut was destroyed"); + if(isDestroyed) throw std::runtime_error("pvaClientPut was destroyed"); if(connectState==connectIdle) connect(); if(putState!=putIdle) { stringstream ss; - ss << "channel " << channel->getChannelName() << " EasyPut::issueGet get or put aleady active "; + ss << "channel " << channel->getChannelName() << " PvaClientPut::issueGet get or put aleady active "; throw std::runtime_error(ss.str()); } putState = putActive; - channelPut->put(easyData->getPVStructure(),easyData->getBitSet()); + channelPut->put(pvaClientData->getPVStructure(),pvaClientData->getBitSet()); } -Status EasyPut::waitPut() +Status PvaClientPut::waitPut() { - if(isDestroyed) throw std::runtime_error("easyPut was destroyed"); + if(isDestroyed) throw std::runtime_error("pvaClientPut was destroyed"); if(putState!=putActive){ stringstream ss; - ss << "channel " << channel->getChannelName() << " EasyPut::waitPut llegal put state"; + ss << "channel " << channel->getChannelName() << " PvaClientPut::waitPut llegal put state"; throw std::runtime_error(ss.str()); } waitForGetPut.wait(); putState = putIdle; if(channelGetPutStatus.isOK()) { - easyData->getBitSet()->clear(); + pvaClientData->getBitSet()->clear(); return Status::Ok; } return Status(Status::STATUSTYPE_ERROR,channelGetPutStatus.getMessage()); } -EasyPutDataPtr EasyPut::getData() +PvaClientPutDataPtr PvaClientPut::getData() { checkPutState(); - return easyData; + return pvaClientData; } -EasyPutPtr EasyPut::create( - EasyPVAPtr const &pva, - EasyChannelPtr const & easyChannel, +PvaClientPutPtr PvaClientPut::create( + PvaClientPtr const &pvaClient, + PvaClientChannelPtr const & pvaClientChannel, Channel::shared_pointer const & channel, PVStructurePtr const &pvRequest) { - EasyPutPtr epv(new EasyPut(pva,easyChannel,channel,pvRequest)); + PvaClientPutPtr epv(new PvaClientPut(pvaClient,pvaClientChannel,channel,pvRequest)); return epv; } diff --git a/src/easyPutData.cpp b/src/pvaClientPutData.cpp similarity index 75% rename from src/easyPutData.cpp rename to src/pvaClientPutData.cpp index 3106227..0521800 100644 --- a/src/easyPutData.cpp +++ b/src/pvaClientPutData.cpp @@ -1,4 +1,4 @@ -/* easyPutData.cpp */ +/* pvaClientPutData.cpp */ /** * Copyright - See the COPYRIGHT that is included with this distribution. * EPICS pvData is distributed subject to a Software License Agreement found @@ -13,7 +13,7 @@ #include #include -#include +#include #include #include @@ -23,14 +23,14 @@ using namespace epics::pvData; using namespace epics::pvAccess; using namespace std; -namespace epics { namespace easyPVA { +namespace epics { namespace pvaClient { -class EasyPostHandlerPvt: public PostHandler +class PvaClientPostHandlerPvt: public PostHandler { - EasyPutData * easyData; + PvaClientPutData * easyData; size_t fieldNumber; public: - EasyPostHandlerPvt(EasyPutData *easyData,size_t fieldNumber) + PvaClientPostHandlerPvt(PvaClientPutData *easyData,size_t fieldNumber) : easyData(easyData),fieldNumber(fieldNumber){} void postPut() { easyData->postPut(fieldNumber);} }; @@ -46,13 +46,13 @@ static string notScalarArray("value is not a scalarArray"); static string notDoubleArray("value is not a doubleArray"); static string notStringArray("value is not a stringArray"); -EasyPutDataPtr EasyPutData::create(StructureConstPtr const & structure) +PvaClientPutDataPtr PvaClientPutData::create(StructureConstPtr const & structure) { - EasyPutDataPtr epv(new EasyPutData(structure)); + PvaClientPutDataPtr epv(new PvaClientPutData(structure)); return epv; } -EasyPutData::EasyPutData(StructureConstPtr const & structure) +PvaClientPutData::PvaClientPutData(StructureConstPtr const & structure) : structure(structure), pvStructure(getPVDataCreate()->createPVStructure(structure)), bitSet(BitSetPtr(new BitSet(pvStructure->getNumberFields()))) @@ -62,7 +62,7 @@ EasyPutData::EasyPutData(StructureConstPtr const & structure) PVFieldPtr pvField; for(size_t i =0; igetSubField("value"); } -void EasyPutData::checkValue() +void PvaClientPutData::checkValue() { if(pvValue) return; throw std::runtime_error(messagePrefix + noValue); } -void EasyPutData::postPut(size_t fieldNumber) +void PvaClientPutData::postPut(size_t fieldNumber) { bitSet->set(fieldNumber); } -void EasyPutData::setMessagePrefix(std::string const & value) +void PvaClientPutData::setMessagePrefix(std::string const & value) { messagePrefix = value + " "; } -StructureConstPtr EasyPutData::getStructure() +StructureConstPtr PvaClientPutData::getStructure() {return structure;} -PVStructurePtr EasyPutData::getPVStructure() +PVStructurePtr PvaClientPutData::getPVStructure() {return pvStructure;} -BitSetPtr EasyPutData::getBitSet() +BitSetPtr PvaClientPutData::getBitSet() {return bitSet;} -std::ostream & EasyPutData::showChanged(std::ostream & out) +std::ostream & PvaClientPutData::showChanged(std::ostream & out) { size_t nextSet = bitSet->nextSetBit(0); PVFieldPtr pvField; @@ -115,33 +115,33 @@ std::ostream & EasyPutData::showChanged(std::ostream & out) return out; } -bool EasyPutData::hasValue() +bool PvaClientPutData::hasValue() { if(!pvValue) return false; return true; } -bool EasyPutData::isValueScalar() +bool PvaClientPutData::isValueScalar() { if(!pvValue) return false; if(pvValue->getField()->getType()==scalar) return true; return false; } -bool EasyPutData::isValueScalarArray() +bool PvaClientPutData::isValueScalarArray() { if(!pvValue) return false; if(pvValue->getField()->getType()==scalarArray) return true; return false; } -PVFieldPtr EasyPutData::getValue() +PVFieldPtr PvaClientPutData::getValue() { checkValue(); return pvValue; } -PVScalarPtr EasyPutData::getScalarValue() +PVScalarPtr PvaClientPutData::getScalarValue() { checkValue(); PVScalarPtr pv = pvStructure->getSubField("value"); @@ -151,7 +151,7 @@ PVScalarPtr EasyPutData::getScalarValue() return pv; } -PVArrayPtr EasyPutData::getArrayValue() +PVArrayPtr PvaClientPutData::getArrayValue() { checkValue(); PVArrayPtr pv = pvStructure->getSubField("value"); @@ -161,7 +161,7 @@ PVArrayPtr EasyPutData::getArrayValue() return pv; } -PVScalarArrayPtr EasyPutData::getScalarArrayValue() +PVScalarArrayPtr PvaClientPutData::getScalarArrayValue() { checkValue(); PVScalarArrayPtr pv = pvStructure->getSubField("value"); @@ -171,7 +171,7 @@ PVScalarArrayPtr EasyPutData::getScalarArrayValue() return pv; } -double EasyPutData::getDouble() +double PvaClientPutData::getDouble() { PVScalarPtr pvScalar = getScalarValue(); ScalarType scalarType = pvScalar->getScalar()->getScalarType(); @@ -185,13 +185,13 @@ double EasyPutData::getDouble() return convert->toDouble(pvScalar); } -string EasyPutData::getString() +string PvaClientPutData::getString() { PVScalarPtr pvScalar = getScalarValue(); return convert->toString(pvScalar); } -shared_vector EasyPutData::getDoubleArray() +shared_vector PvaClientPutData::getDoubleArray() { checkValue(); PVDoubleArrayPtr pv = pvStructure->getSubField("value"); @@ -201,7 +201,7 @@ shared_vector EasyPutData::getDoubleArray() return pv->view(); } -shared_vector EasyPutData::getStringArray() +shared_vector PvaClientPutData::getStringArray() { checkValue(); PVStringArrayPtr pv = pvStructure->getSubField("value"); @@ -212,13 +212,14 @@ shared_vector EasyPutData::getStringArray() } -void EasyPutData::putDouble(double value) +void PvaClientPutData::putDouble(double value) { PVScalarPtr pvScalar = getScalarValue(); ScalarType scalarType = pvScalar->getScalar()->getScalarType(); if(scalarType==pvDouble) { PVDoublePtr pvDouble = static_pointer_cast(pvScalar); pvDouble->put(value); + return; } if(!ScalarTypeFunc::isNumeric(scalarType)) { throw std::runtime_error(messagePrefix + notCompatibleScalar); @@ -226,7 +227,7 @@ void EasyPutData::putDouble(double value) convert->fromDouble(pvScalar,value); } -void EasyPutData::putString(std::string const & value) +void PvaClientPutData::putString(std::string const & value) { PVScalarPtr pvScalar = getScalarValue(); convert->fromString(pvScalar,value); @@ -234,7 +235,7 @@ void EasyPutData::putString(std::string const & value) -void EasyPutData::putDoubleArray(shared_vector const & value) +void PvaClientPutData::putDoubleArray(shared_vector const & value) { checkValue(); PVDoubleArrayPtr pv = pvStructure->getSubField("value"); @@ -244,7 +245,7 @@ void EasyPutData::putDoubleArray(shared_vector const & value) pv->replace(value); } -void EasyPutData::putStringArray(shared_vector const & value) +void PvaClientPutData::putStringArray(shared_vector const & value) { checkValue(); PVStringArrayPtr pv = pvStructure->getSubField("value"); @@ -254,7 +255,7 @@ void EasyPutData::putStringArray(shared_vector const & value) pv->replace(value); } -void EasyPutData::putStringArray(std::vector const & value) +void PvaClientPutData::putStringArray(std::vector const & value) { checkValue(); PVScalarArrayPtr pv = pvStructure->getSubField("value"); diff --git a/src/easyPutGet.cpp b/src/pvaClientPutGet.cpp similarity index 54% rename from src/easyPutGet.cpp rename to src/pvaClientPutGet.cpp index 8fff9f9..1ad0f23 100644 --- a/src/easyPutGet.cpp +++ b/src/pvaClientPutGet.cpp @@ -1,4 +1,4 @@ -/* easyPutGet.cpp */ +/* pvaClientPutGet.cpp */ /** * Copyright - See the COPYRIGHT that is included with this distribution. * EPICS pvData is distributed subject to a Software License Agreement found @@ -12,32 +12,32 @@ #include #include -#include +#include using std::tr1::static_pointer_cast; using namespace epics::pvData; using namespace epics::pvAccess; using namespace std; -namespace epics { namespace easyPVA { +namespace epics { namespace pvaClient { class ChannelPutGetRequesterImpl : public ChannelPutGetRequester { - EasyPutGet * easyPutGet; + PvaClientPutGet * pvaClientPutGet; public: - ChannelPutGetRequesterImpl(EasyPutGet * easyPutGet) - : easyPutGet(easyPutGet) {} + ChannelPutGetRequesterImpl(PvaClientPutGet * pvaClientPutGet) + : pvaClientPutGet(pvaClientPutGet) {} string getRequesterName() - {return easyPutGet->getRequesterName();} + {return pvaClientPutGet->getRequesterName();} void message(string const & message,MessageType messageType) - {easyPutGet->message(message,messageType);} + {pvaClientPutGet->message(message,messageType);} void channelPutGetConnect( const epics::pvData::Status& status, epics::pvAccess::ChannelPutGet::shared_pointer const & channelPutGet, epics::pvData::StructureConstPtr const & putStructure, epics::pvData::StructureConstPtr const & getStructure) { - easyPutGet->channelPutGetConnect(status,channelPutGet,putStructure,getStructure); + pvaClientPutGet->channelPutGetConnect(status,channelPutGet,putStructure,getStructure); } void putGetDone( const epics::pvData::Status& status, @@ -45,7 +45,7 @@ public: epics::pvData::PVStructurePtr const & getPVStructure, epics::pvData::BitSetPtr const & getBitSet) { - easyPutGet->putGetDone(status,channelPutGet,getPVStructure,getBitSet); + pvaClientPutGet->putGetDone(status,channelPutGet,getPVStructure,getBitSet); } void getPutDone( const epics::pvData::Status& status, @@ -53,7 +53,7 @@ public: epics::pvData::PVStructurePtr const & putPVStructure, epics::pvData::BitSet::shared_pointer const & putBitSet) { - easyPutGet->getPutDone(status,channelPutGet,putPVStructure,putBitSet); + pvaClientPutGet->getPutDone(status,channelPutGet,putPVStructure,putBitSet); } void getGetDone( const epics::pvData::Status& status, @@ -61,17 +61,17 @@ public: epics::pvData::PVStructurePtr const & getPVStructure, epics::pvData::BitSet::shared_pointer const & getBitSet) { - easyPutGet->getGetDone(status,channelPutGet,getPVStructure,getBitSet); + pvaClientPutGet->getGetDone(status,channelPutGet,getPVStructure,getBitSet); } }; -EasyPutGet::EasyPutGet( - EasyPVAPtr const &pva, - EasyChannelPtr const & easyChannel, +PvaClientPutGet::PvaClientPutGet( + PvaClientPtr const &pvaClient, + PvaClientChannelPtr const & pvaClientChannel, Channel::shared_pointer const & channel, PVStructurePtr const &pvRequest) -: easyPVA(pva), - easyChannel(easyChannel), +: pvaClient(pvaClient), + pvaClientChannel(pvaClientChannel), channel(channel), pvRequest(pvRequest), isDestroyed(false), @@ -80,14 +80,14 @@ EasyPutGet::EasyPutGet( { } -EasyPutGet::~EasyPutGet() +PvaClientPutGet::~PvaClientPutGet() { destroy(); } -void EasyPutGet::checkPutGetState() +void PvaClientPutGet::checkPutGetState() { - if(isDestroyed) throw std::runtime_error("easyPutGet was destroyed"); + if(isDestroyed) throw std::runtime_error("pvaClientPutGet was destroyed"); if(connectState==connectIdle){ connect(); getPut(); @@ -95,90 +95,90 @@ void EasyPutGet::checkPutGetState() } // from ChannelPutGetRequester -string EasyPutGet::getRequesterName() +string PvaClientPutGet::getRequesterName() { - EasyPVAPtr yyy = easyPVA.lock(); - if(!yyy) throw std::runtime_error("easyPVA was destroyed"); + PvaClientPtr yyy = pvaClient.lock(); + if(!yyy) throw std::runtime_error("pvaClient was destroyed"); return yyy->getRequesterName(); } -void EasyPutGet::message(string const & message,MessageType messageType) +void PvaClientPutGet::message(string const & message,MessageType messageType) { - if(isDestroyed) throw std::runtime_error("easyPutGet was destroyed"); - EasyPVAPtr yyy = easyPVA.lock(); - if(!yyy) throw std::runtime_error("easyPVA was destroyed"); + if(isDestroyed) throw std::runtime_error("pvaClientPutGet was destroyed"); + PvaClientPtr yyy = pvaClient.lock(); + if(!yyy) throw std::runtime_error("pvaClient was destroyed"); yyy->message(message, messageType); } -void EasyPutGet::channelPutGetConnect( +void PvaClientPutGet::channelPutGetConnect( const Status& status, ChannelPutGet::shared_pointer const & channelPutGet, StructureConstPtr const & putStructure, StructureConstPtr const & getStructure) { - if(isDestroyed) throw std::runtime_error("easyPutGet was destroyed"); + if(isDestroyed) throw std::runtime_error("pvaClientPutGet was destroyed"); channelPutGetConnectStatus = status; this->channelPutGet = channelPutGet; if(status.isOK()) { - easyPutData = EasyPutData::create(putStructure); - easyPutData->setMessagePrefix(easyChannel.lock()->getChannelName()); - easyGetData = EasyGetData::create(getStructure); - easyGetData->setMessagePrefix(easyChannel.lock()->getChannelName()); + pvaClientPutData = PvaClientPutData::create(putStructure); + pvaClientPutData->setMessagePrefix(pvaClientChannel.lock()->getChannelName()); + pvaClientGetData = PvaClientGetData::create(getStructure); + pvaClientGetData->setMessagePrefix(pvaClientChannel.lock()->getChannelName()); } waitForConnect.signal(); } -void EasyPutGet::putGetDone( +void PvaClientPutGet::putGetDone( const Status& status, ChannelPutGet::shared_pointer const & channelPutGet, PVStructurePtr const & getPVStructure, BitSetPtr const & getBitSet) { - if(isDestroyed) throw std::runtime_error("easyPutGet was destroyed"); + if(isDestroyed) throw std::runtime_error("pvaClientPutGet was destroyed"); channelPutGetStatus = status; if(status.isOK()) { - easyGetData->setData(getPVStructure,getBitSet); + pvaClientGetData->setData(getPVStructure,getBitSet); } waitForPutGet.signal(); } -void EasyPutGet::getPutDone( +void PvaClientPutGet::getPutDone( const Status& status, ChannelPutGet::shared_pointer const & channelPutGet, PVStructurePtr const & putPVStructure, BitSetPtr const & putBitSet) { - if(isDestroyed) throw std::runtime_error("easyPutGet was destroyed"); + if(isDestroyed) throw std::runtime_error("pvaClientPutGet was destroyed"); channelGetPutGetStatus = status; if(status.isOK()) { - PVStructurePtr pvs = easyPutData->getPVStructure(); + PVStructurePtr pvs = pvaClientPutData->getPVStructure(); pvs->copyUnchecked(*putPVStructure,*putBitSet); - BitSetPtr bs = easyPutData->getBitSet(); + BitSetPtr bs = pvaClientPutData->getBitSet(); bs->clear(); *bs |= *putBitSet; } waitForPutGet.signal(); } -void EasyPutGet::getGetDone( +void PvaClientPutGet::getGetDone( const Status& status, ChannelPutGet::shared_pointer const & channelPutGet, PVStructurePtr const & getPVStructure, BitSetPtr const & getBitSet) { - if(isDestroyed) throw std::runtime_error("easyPutGet was destroyed"); + if(isDestroyed) throw std::runtime_error("pvaClientPutGet was destroyed"); channelPutGetStatus = status; if(status.isOK()) { - easyGetData->setData(getPVStructure,getBitSet); + pvaClientGetData->setData(getPVStructure,getBitSet); } waitForPutGet.signal(); } -// from EasyPutGet -void EasyPutGet::destroy() +// from PvaClientPutGet +void PvaClientPutGet::destroy() { { Lock xx(mutex); @@ -189,23 +189,23 @@ void EasyPutGet::destroy() channelPutGet.reset(); } -void EasyPutGet::connect() +void PvaClientPutGet::connect() { - if(isDestroyed) throw std::runtime_error("easyPutGet was destroyed"); + if(isDestroyed) throw std::runtime_error("pvaClientPutGet was destroyed"); issueConnect(); Status status = waitConnect(); if(status.isOK()) return; stringstream ss; - ss << "channel " << channel->getChannelName() << " EasyPutGet::connect " << status.getMessage(); + ss << "channel " << channel->getChannelName() << " PvaClientPutGet::connect " << status.getMessage(); throw std::runtime_error(ss.str()); } -void EasyPutGet::issueConnect() +void PvaClientPutGet::issueConnect() { - if(isDestroyed) throw std::runtime_error("easyPutGet was destroyed"); + if(isDestroyed) throw std::runtime_error("pvaClientPutGet was destroyed"); if(connectState!=connectIdle) { stringstream ss; - ss << "channel " << channel->getChannelName() << " easyPutGet already connected "; + ss << "channel " << channel->getChannelName() << " pvaClientPutGet already connected "; throw std::runtime_error(ss.str()); } putGetRequester = ChannelPutGetRequester::shared_pointer(new ChannelPutGetRequesterImpl(this)); @@ -213,12 +213,12 @@ void EasyPutGet::issueConnect() channelPutGet = channel->createChannelPutGet(putGetRequester,pvRequest); } -Status EasyPutGet::waitConnect() +Status PvaClientPutGet::waitConnect() { - if(isDestroyed) throw std::runtime_error("easyPutGet was destroyed"); + if(isDestroyed) throw std::runtime_error("pvaClientPutGet was destroyed"); if(connectState!=connectActive) { stringstream ss; - ss << "channel " << channel->getChannelName() << " easyPutGet illegal connect state "; + ss << "channel " << channel->getChannelName() << " pvaClientPutGet illegal connect state "; throw std::runtime_error(ss.str()); } waitForConnect.wait(); @@ -231,37 +231,37 @@ Status EasyPutGet::waitConnect() } -void EasyPutGet::putGet() +void PvaClientPutGet::putGet() { - if(isDestroyed) throw std::runtime_error("easyPutGet was destroyed"); + if(isDestroyed) throw std::runtime_error("pvaClientPutGet was destroyed"); issuePutGet(); Status status = waitPutGet(); if(status.isOK()) return; stringstream ss; - ss << "channel " << channel->getChannelName() << " EasyPutGet::putGet " << status.getMessage(); + ss << "channel " << channel->getChannelName() << " PvaClientPutGet::putGet " << status.getMessage(); throw std::runtime_error(ss.str()); } -void EasyPutGet::issuePutGet() +void PvaClientPutGet::issuePutGet() { - if(isDestroyed) throw std::runtime_error("easyPutGet was destroyed"); + if(isDestroyed) throw std::runtime_error("pvaClientPutGet was destroyed"); if(connectState==connectIdle) connect(); if(putGetState!=putGetIdle) { stringstream ss; - ss << "channel " << channel->getChannelName() << " EasyPutGet::issueGet get or put aleady active "; + ss << "channel " << channel->getChannelName() << " PvaClientPutGet::issueGet get or put aleady active "; throw std::runtime_error(ss.str()); } putGetState = putGetActive; - channelPutGet->putGet(easyPutData->getPVStructure(),easyPutData->getBitSet()); + channelPutGet->putGet(pvaClientPutData->getPVStructure(),pvaClientPutData->getBitSet()); } -Status EasyPutGet::waitPutGet() +Status PvaClientPutGet::waitPutGet() { - if(isDestroyed) throw std::runtime_error("easyPutGet was destroyed"); + if(isDestroyed) throw std::runtime_error("pvaClientPutGet was destroyed"); if(putGetState!=putGetActive){ stringstream ss; - ss << "channel " << channel->getChannelName() << " EasyPutGet::waitPutGet llegal put state"; + ss << "channel " << channel->getChannelName() << " PvaClientPutGet::waitPutGet llegal put state"; throw std::runtime_error(ss.str()); } waitForPutGet.wait(); @@ -272,36 +272,36 @@ Status EasyPutGet::waitPutGet() return Status(Status::STATUSTYPE_ERROR,channelGetPutGetStatus.getMessage()); } -void EasyPutGet::getGet() +void PvaClientPutGet::getGet() { - if(isDestroyed) throw std::runtime_error("easyPutGet was destroyed"); + if(isDestroyed) throw std::runtime_error("pvaClientPutGet was destroyed"); issueGetGet(); Status status = waitGetGet(); if(status.isOK()) return; stringstream ss; - ss << "channel " << channel->getChannelName() << " EasyPutGet::getGet " << status.getMessage(); + ss << "channel " << channel->getChannelName() << " PvaClientPutGet::getGet " << status.getMessage(); throw std::runtime_error(ss.str()); } -void EasyPutGet::issueGetGet() +void PvaClientPutGet::issueGetGet() { - if(isDestroyed) throw std::runtime_error("easyPutGet was destroyed"); + if(isDestroyed) throw std::runtime_error("pvaClientPutGet was destroyed"); if(connectState==connectIdle) connect(); if(putGetState!=putGetIdle) { stringstream ss; - ss << "channel " << channel->getChannelName() << " EasyPutGet::issueGetGet aleady active "; + ss << "channel " << channel->getChannelName() << " PvaClientPutGet::issueGetGet aleady active "; throw std::runtime_error(ss.str()); } putGetState = putGetActive; channelPutGet->getGet(); } -Status EasyPutGet::waitGetGet() +Status PvaClientPutGet::waitGetGet() { - if(isDestroyed) throw std::runtime_error("easyPutGet was destroyed"); + if(isDestroyed) throw std::runtime_error("pvaClientPutGet was destroyed"); if(putGetState!=putGetActive){ stringstream ss; - ss << "channel " << channel->getChannelName() << " EasyPutGet::waitGetGet illegal state"; + ss << "channel " << channel->getChannelName() << " PvaClientPutGet::waitGetGet illegal state"; throw std::runtime_error(ss.str()); } waitForPutGet.wait(); @@ -312,36 +312,36 @@ Status EasyPutGet::waitGetGet() return Status(Status::STATUSTYPE_ERROR,channelGetPutGetStatus.getMessage()); } -void EasyPutGet::getPut() +void PvaClientPutGet::getPut() { - if(isDestroyed) throw std::runtime_error("easyPutGet was destroyed"); + if(isDestroyed) throw std::runtime_error("pvaClientPutGet was destroyed"); issueGetPut(); Status status = waitGetPut(); if(status.isOK()) return; stringstream ss; - ss << "channel " << channel->getChannelName() << " EasyPutGet::getPut " << status.getMessage(); + ss << "channel " << channel->getChannelName() << " PvaClientPutGet::getPut " << status.getMessage(); throw std::runtime_error(ss.str()); } -void EasyPutGet::issueGetPut() +void PvaClientPutGet::issueGetPut() { - if(isDestroyed) throw std::runtime_error("easyPutGet was destroyed"); + if(isDestroyed) throw std::runtime_error("pvaClientPutGet was destroyed"); if(connectState==connectIdle) connect(); if(putGetState!=putGetIdle) { stringstream ss; - ss << "channel " << channel->getChannelName() << " EasyPutGet::issueGetPut aleady active "; + ss << "channel " << channel->getChannelName() << " PvaClientPutGet::issueGetPut aleady active "; throw std::runtime_error(ss.str()); } putGetState = putGetActive; channelPutGet->getPut(); } -Status EasyPutGet::waitGetPut() +Status PvaClientPutGet::waitGetPut() { - if(isDestroyed) throw std::runtime_error("easyPutGet was destroyed"); + if(isDestroyed) throw std::runtime_error("pvaClientPutGet was destroyed"); if(putGetState!=putGetActive){ stringstream ss; - ss << "channel " << channel->getChannelName() << " EasyPutGet::waitGetPut illegal state"; + ss << "channel " << channel->getChannelName() << " PvaClientPutGet::waitGetPut illegal state"; throw std::runtime_error(ss.str()); } waitForPutGet.wait(); @@ -352,25 +352,25 @@ Status EasyPutGet::waitGetPut() return Status(Status::STATUSTYPE_ERROR,channelGetPutGetStatus.getMessage()); } -EasyGetDataPtr EasyPutGet::getGetData() +PvaClientGetDataPtr PvaClientPutGet::getGetData() { checkPutGetState(); - return easyGetData; + return pvaClientGetData; } -EasyPutDataPtr EasyPutGet::getPutData() +PvaClientPutDataPtr PvaClientPutGet::getPutData() { checkPutGetState(); - return easyPutData; + return pvaClientPutData; } -EasyPutGetPtr EasyPutGet::create( - EasyPVAPtr const &pva, - EasyChannelPtr const & easyChannel, +PvaClientPutGetPtr PvaClientPutGet::create( + PvaClientPtr const &pvaClient, + PvaClientChannelPtr const & pvaClientChannel, Channel::shared_pointer const & channel, PVStructurePtr const &pvRequest) { - EasyPutGetPtr epv(new EasyPutGet(pva,easyChannel,channel,pvRequest)); + PvaClientPutGetPtr epv(new PvaClientPutGet(pvaClient,pvaClientChannel,channel,pvRequest)); return epv; } diff --git a/test/src/Makefile b/test/src/Makefile index 04dffde..48feea6 100644 --- a/test/src/Makefile +++ b/test/src/Makefile @@ -3,54 +3,54 @@ TOP = .. include $(TOP)/configure/CONFIG -TESTPROD_HOST += testEasyPutData -testEasyPutData_SRCS = testEasyPutData -testHarness_SRCS += testEasyPutData.cpp -TESTS += testEasyPutData +TESTPROD_HOST += pvaClientTestPutData +pvaClientTestPutData_SRCS = pvaClientTestPutData +testHarness_SRCS += pvaClientTestPutData.cpp +TESTS += pvaClientTestPutData -TESTPROD_HOST += testEasyGetData -testEasyGetData_SRCS = testEasyGetData -testHarness_SRCS += testEasyGetData.cpp -TESTS += testEasyGetData +TESTPROD_HOST += pvaClientTestGetData +pvaClientTestGetData_SRCS = pvaClientTestGetData +testHarness_SRCS += pvaClientTestGetData.cpp +TESTS += pvaClientTestGetData -TESTPROD_HOST += testEasyMonitorData -testEasyMonitorData_SRCS = testEasyMonitorData -testHarness_SRCS += testEasyMonitorData.cpp -TESTS += testEasyMonitorData +TESTPROD_HOST += pvaClientTestMonitorData +pvaClientTestMonitorData_SRCS = pvaClientTestMonitorData +testHarness_SRCS += pvaClientTestMonitorData.cpp +TESTS += pvaClientTestMonitorData -TESTPROD_HOST += testEasyPutGetMonitor -testEasyPutGetMonitor_SRCS = testEasyPutGetMonitor -testHarness_SRCS += testEasyPutGetMonitor.cpp -TESTS += testEasyPutGetMonitor +TESTPROD_HOST += pvaClientTestPutGetMonitor +pvaClientTestPutGetMonitor_SRCS = pvaClientTestPutGetMonitor +testHarness_SRCS += pvaClientTestPutGetMonitor.cpp +TESTS += pvaClientTestPutGetMonitor -TESTPROD_HOST += testEasyPutGet -testEasyPutGet_SRCS = testEasyPutGet -testHarness_SRCS += testEasyPutGet.cpp -TESTS += testEasyPutGet +TESTPROD_HOST += pvaClientTestPutGet +pvaClientTestPutGet_SRCS = pvaClientTestPutGet +testHarness_SRCS += pvaClientTestPutGet.cpp +TESTS += pvaClientTestPutGet -TESTPROD_HOST += testEasyMultiDouble -testEasyMultiDouble_SRCS = testEasyMultiDouble -testHarness_SRCS += testEasyMultiDouble.cpp -TESTS += testEasyMultiDouble +TESTPROD_HOST += pvaClientTestMultiDouble +pvaClientTestMultiDouble_SRCS = pvaClientTestMultiDouble +testHarness_SRCS += pvaClientTestMultiDouble.cpp +TESTS += pvaClientTestMultiDouble -TESTPROD_HOST += testEasyNTMultiChannel -testEasyNTMultiChannel_SRCS = testEasyNTMultiChannel -testHarness_SRCS += testEasyNTMultiChannel.cpp -TESTS += testEasyNTMultiChannel +TESTPROD_HOST += pvaClientTestNTMultiChannel +pvaClientTestNTMultiChannel_SRCS = pvaClientTestNTMultiChannel +testHarness_SRCS += pvaClientTestNTMultiChannel.cpp +TESTS += pvaClientTestNTMultiChannel -PROD_LIBS += easyPVA pvAccess pvData nt Com +PROD_LIBS += pvaClient pvAccess pvData nt Com -testHarness_SRCS += easyAllTests.c +testHarness_SRCS += pvaClientAllTests.c PROD_vxWorks = vxTestHarness vxTestHarness_SRCS += $(testHarness_SRCS) -TESTSPEC_vxWorks = vxTestHarness.$(MUNCH_SUFFIX); easyAllTests +TESTSPEC_vxWorks = vxTestHarness.$(MUNCH_SUFFIX); pvaClientAllTests PROD_RTEMS += rtemsTestHarness rtemsTestHarness_SRCS += rtemsTestHarness.c rtemsConfig.c rtemsTestHarness_SRCS += $(testHarness_SRCS) -TESTSPEC_RTEMS = rtemsTestHarness.$(MUNCH_SUFFIX); easyAllTests +TESTSPEC_RTEMS = rtemsTestHarness.$(MUNCH_SUFFIX); pvaClientAllTests TESTSCRIPTS_HOST += $(TESTS:%=%.t) diff --git a/test/src/easyAllTests.c b/test/src/easyAllTests.c deleted file mode 100644 index 810e8d9..0000000 --- a/test/src/easyAllTests.c +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Run EasyPVA tests as a batch. - * - * Do *not* include performance measurements here, they don't help to - * prove functionality (which is the point of this convenience routine). - */ - -#include -#include -#include - -int testEasyGetData(void); -int testEasyPutData(void); -int testEasyMonitorData(void); -int testEasyPutGetMonitor(void); -int testEasyPutGet(void); -int testEasyMultiDouble(void); -int testEasyNTMultiChannel(void); - -void easyAllTests(void) -{ - testHarness(); - runTest(testEasyGetData); - runTest(testEasyPutData); - runTest(testEasyMonitorData); - runTest(testEasyPutMonitor); - runTest(testEasyPut); - runTest(testEasyMultiDouble); - runTest(testEasyNTMultiChannel); -} - diff --git a/test/src/pvaClientAllTests.c b/test/src/pvaClientAllTests.c new file mode 100644 index 0000000..347da3f --- /dev/null +++ b/test/src/pvaClientAllTests.c @@ -0,0 +1,31 @@ +/* + * Run pvaClient tests as a batch. + * + * Do *not* include performance measurements here, they don't help to + * prove functionality (which is the point of this convenience routine). + */ + +#include +#include +#include + +int pvaClientTestGetData(void); +int pvaClientTestPutData(void); +int pvaClientTestMonitorData(void); +int pvaClientTestPutGetMonitor(void); +int pvaClientTestPutGet(void); +int pvaClientTestMultiDouble(void); +int pvaClientTestNTMultiChannel(void); + +void easyAllTests(void) +{ + testHarness(); + runTest(pvaClientTestGetData); + runTest(pvaClientTestPutData); + runTest(pvaClientTestMonitorData); + runTest(pvaClientTestPutMonitor); + runTest(pvaClientTestPut); + runTest(pvaClientTestMultiDouble); + runTest(pvaClientTestNTMultiChannel); +} + diff --git a/test/src/testEasyGetData.cpp b/test/src/pvaClientTestGetData.cpp similarity index 64% rename from test/src/testEasyGetData.cpp rename to test/src/pvaClientTestGetData.cpp index e0a6d10..dab4403 100644 --- a/test/src/testEasyGetData.cpp +++ b/test/src/pvaClientTestGetData.cpp @@ -1,4 +1,4 @@ -/*testEasyGetData.cpp */ +/*pvaClientTestGetData.cpp */ /** * Copyright - See the COPYRIGHT that is included with this distribution. * EPICS pvData is distributed subject to a Software License Agreement found @@ -15,15 +15,15 @@ #include #include -#include +#include #include using namespace std; using namespace epics::pvData; using namespace epics::pvAccess; -using namespace epics::easyPVA; +using namespace epics::pvaClient; -static EasyPVAPtr easyPVA = EasyPVA::create(); +static PvaClientPtr pvaClient = PvaClient::create(); static FieldCreatePtr fieldCreate = getFieldCreate(); static StandardFieldPtr standardField = getStandardField(); static PVDataCreatePtr pvDataCreate = getPVDataCreate(); @@ -39,46 +39,46 @@ void testDouble() add("value",pvDouble) -> createStructure(); - EasyGetDataPtr easyData = EasyGetData::create(structure); - PVStructurePtr pvStructure = pvDataCreate->createPVStructure(easyData->getStructure()); + PvaClientGetDataPtr pvaData = PvaClientGetData::create(structure); + PVStructurePtr pvStructure = pvDataCreate->createPVStructure(pvaData->getStructure()); BitSetPtr bitSet = BitSetPtr(new BitSet(pvStructure->getNumberFields())); - easyData->setData(pvStructure,bitSet); + pvaData->setData(pvStructure,bitSet); PVDoublePtr pvDouble = pvStructure->getSubField("value"); size_t valueOffset = pvDouble->getFieldOffset(); - BitSetPtr change = easyData->getBitSet(); + BitSetPtr change = pvaData->getBitSet(); pvDouble->put(5.0); change->set(pvDouble->getFieldOffset()); testOk(change->cardinality()==1,"num set bits 1"); testOk(change->get(valueOffset)==true,"value changed"); - testOk(easyData->hasValue()==true,"hasValue"); - testOk(easyData->isValueScalar()==true,"isValueScalar"); - testOk(easyData->isValueScalarArray()==false,"isValueScalarArray"); + testOk(pvaData->hasValue()==true,"hasValue"); + testOk(pvaData->isValueScalar()==true,"isValueScalar"); + testOk(pvaData->isValueScalarArray()==false,"isValueScalarArray"); bool result; result = false; - if(easyData->getValue()) result = true; + if(pvaData->getValue()) result = true; testOk(result==true,"getValue"); result = false; - if(easyData->getScalarValue()) result = true; + if(pvaData->getScalarValue()) result = true; testOk(result==true,"getScalarValue"); try { - easyData->getArrayValue(); + pvaData->getArrayValue(); } catch (std::runtime_error e) { cout << "getArrayValue " << e.what() << endl; } try { - easyData->getScalarArrayValue(); + pvaData->getScalarArrayValue(); } catch (std::runtime_error e) { cout << " getScalarArrayValue " << e.what() << endl; } - cout << "as double " << easyData->getDouble() << endl; - cout << "as string " << easyData->getString() << endl; + cout << "as double " << pvaData->getDouble() << endl; + cout << "as string " << pvaData->getString() << endl; try { - shared_vector value = easyData->getDoubleArray(); + shared_vector value = pvaData->getDoubleArray(); } catch (std::runtime_error e) { cout << " getDoubleArray " << e.what() << endl; } try { - shared_vector value = easyData->getStringArray(); + shared_vector value = pvaData->getStringArray(); } catch (std::runtime_error e) { cout << " getStringArray " << e.what() << endl; } @@ -94,12 +94,12 @@ void testDoubleArray() addArray("value",pvDouble) -> createStructure(); - EasyGetDataPtr easyData = EasyGetData::create(structure); - PVStructurePtr pvStructure = pvDataCreate->createPVStructure(easyData->getStructure()); + PvaClientGetDataPtr pvaData = PvaClientGetData::create(structure); + PVStructurePtr pvStructure = pvDataCreate->createPVStructure(pvaData->getStructure()); BitSetPtr bitSet = BitSetPtr(new BitSet(pvStructure->getNumberFields())); - easyData->setData(pvStructure,bitSet); - PVDoubleArrayPtr pvalue = easyData->getPVStructure()->getSubField("value"); - BitSetPtr change = easyData->getBitSet(); + pvaData->setData(pvStructure,bitSet); + PVDoubleArrayPtr pvalue = pvaData->getPVStructure()->getSubField("value"); + BitSetPtr change = pvaData->getBitSet(); size_t valueOffset = pvalue->getFieldOffset(); size_t len = 5; shared_vector value(len); @@ -108,45 +108,45 @@ void testDoubleArray() change->set(valueOffset); testOk(change->cardinality()==1,"num set bits 1"); testOk(change->get(valueOffset)==true,"value changed"); - testOk(easyData->hasValue()==true,"hasValue"); - testOk(easyData->isValueScalar()==false,"isValueScalar"); - testOk(easyData->isValueScalarArray()==true,"isValueScalarArray"); + testOk(pvaData->hasValue()==true,"hasValue"); + testOk(pvaData->isValueScalar()==false,"isValueScalar"); + testOk(pvaData->isValueScalarArray()==true,"isValueScalarArray"); bool result; result = false; - if(easyData->getValue()) result = true; + if(pvaData->getValue()) result = true; testOk(result==true,"getValue"); result = false; - if(easyData->getArrayValue()) result = true; + if(pvaData->getArrayValue()) result = true; testOk(result==true,"getArrayValue"); result = false; - if(easyData->getScalarArrayValue()) result = true; + if(pvaData->getScalarArrayValue()) result = true; testOk(result==true,"getScalarValue"); try { - easyData->getScalarValue(); + pvaData->getScalarValue(); } catch (std::runtime_error e) { cout << " getScalarValue " << e.what() << endl; } try { - cout << "as double " << easyData->getDouble() << endl; + cout << "as double " << pvaData->getDouble() << endl; } catch (std::runtime_error e) { cout << " getDouble " << e.what() << endl; } try { - string val = easyData->getString(); + string val = pvaData->getString(); } catch (std::runtime_error e) { cout << " getString " << e.what() << endl; } - cout << "as doubleArray " << easyData->getDoubleArray() << endl; + cout << "as doubleArray " << pvaData->getDoubleArray() << endl; try { - shared_vector value = easyData->getStringArray(); + shared_vector value = pvaData->getStringArray(); } catch (std::runtime_error e) { cout << " getStringArray " << e.what() << endl; } } -MAIN(testEasyGetData) +MAIN(pvaClientTestGetData) { - cout << "\nstarting testEasyGetData\n"; + cout << "\nstarting pvaClientTestGetData\n"; testPlan(15); testDouble(); testDoubleArray(); diff --git a/test/src/testEasyMonitorData.cpp b/test/src/pvaClientTestMonitorData.cpp similarity index 61% rename from test/src/testEasyMonitorData.cpp rename to test/src/pvaClientTestMonitorData.cpp index c7576c2..a299563 100644 --- a/test/src/testEasyMonitorData.cpp +++ b/test/src/pvaClientTestMonitorData.cpp @@ -1,4 +1,4 @@ -/*testEasyMonitorData.cpp */ +/*pvaClientTestMonitorData.cpp */ /** * Copyright - See the COPYRIGHT that is included with this distribution. * EPICS pvData is distributed subject to a Software License Agreement found @@ -15,15 +15,15 @@ #include #include -#include +#include #include using namespace std; using namespace epics::pvData; using namespace epics::pvAccess; -using namespace epics::easyPVA; +using namespace epics::pvaClient; -static EasyPVAPtr easyPVA = EasyPVA::create(); +static PvaClientPtr pvaClient = PvaClient::create(); static FieldCreatePtr fieldCreate = getFieldCreate(); static StandardFieldPtr standardField = getStandardField(); static PVDataCreatePtr pvDataCreate = getPVDataCreate(); @@ -39,45 +39,45 @@ void testDouble() add("value",pvDouble) -> createStructure(); - EasyMonitorDataPtr easyData = EasyMonitorData::create(structure); - MonitorElementPtr monitorElement(new MonitorElement(pvDataCreate->createPVStructure(easyData->getStructure()))); - easyData->setData(monitorElement); - PVDoublePtr pvDouble = easyData->getPVStructure()->getSubField("value"); + PvaClientMonitorDataPtr pvaData = PvaClientMonitorData::create(structure); + MonitorElementPtr monitorElement(new MonitorElement(pvDataCreate->createPVStructure(pvaData->getStructure()))); + pvaData->setData(monitorElement); + PVDoublePtr pvDouble = pvaData->getPVStructure()->getSubField("value"); size_t valueOffset = pvDouble->getFieldOffset(); - BitSetPtr change = easyData->getChangedBitSet(); + BitSetPtr change = pvaData->getChangedBitSet(); pvDouble->put(5.0); change->set(pvDouble->getFieldOffset()); testOk(change->cardinality()==1,"num set bits 1"); testOk(change->get(valueOffset)==true,"value changed"); - testOk(easyData->hasValue()==true,"hasValue"); - testOk(easyData->isValueScalar()==true,"isValueScalar"); - testOk(easyData->isValueScalarArray()==false,"isValueScalarArray"); + testOk(pvaData->hasValue()==true,"hasValue"); + testOk(pvaData->isValueScalar()==true,"isValueScalar"); + testOk(pvaData->isValueScalarArray()==false,"isValueScalarArray"); bool result; result = false; - if(easyData->getValue()) result = true; + if(pvaData->getValue()) result = true; testOk(result==true,"getValue"); result = false; - if(easyData->getScalarValue()) result = true; + if(pvaData->getScalarValue()) result = true; testOk(result==true,"getScalarValue"); try { - easyData->getArrayValue(); + pvaData->getArrayValue(); } catch (std::runtime_error e) { cout << "getArrayValue " << e.what() << endl; } try { - easyData->getScalarArrayValue(); + pvaData->getScalarArrayValue(); } catch (std::runtime_error e) { cout << " getScalarArrayValue " << e.what() << endl; } - cout << "as double " << easyData->getDouble() << endl; - cout << "as string " << easyData->getString() << endl; + cout << "as double " << pvaData->getDouble() << endl; + cout << "as string " << pvaData->getString() << endl; try { - shared_vector value = easyData->getDoubleArray(); + shared_vector value = pvaData->getDoubleArray(); } catch (std::runtime_error e) { cout << " getDoubleArray " << e.what() << endl; } try { - shared_vector value = easyData->getStringArray(); + shared_vector value = pvaData->getStringArray(); } catch (std::runtime_error e) { cout << " getStringArray " << e.what() << endl; } @@ -93,11 +93,11 @@ void testDoubleArray() addArray("value",pvDouble) -> createStructure(); - EasyMonitorDataPtr easyData = EasyMonitorData::create(structure); - MonitorElementPtr monitorElement(new MonitorElement(pvDataCreate->createPVStructure(easyData->getStructure()))); - easyData->setData(monitorElement); - PVDoubleArrayPtr pvalue = easyData->getPVStructure()->getSubField("value"); - BitSetPtr change = easyData->getChangedBitSet(); + PvaClientMonitorDataPtr pvaData = PvaClientMonitorData::create(structure); + MonitorElementPtr monitorElement(new MonitorElement(pvDataCreate->createPVStructure(pvaData->getStructure()))); + pvaData->setData(monitorElement); + PVDoubleArrayPtr pvalue = pvaData->getPVStructure()->getSubField("value"); + BitSetPtr change = pvaData->getChangedBitSet(); size_t valueOffset = pvalue->getFieldOffset(); size_t len = 5; shared_vector value(len); @@ -106,45 +106,45 @@ void testDoubleArray() change->set(valueOffset); testOk(change->cardinality()==1,"num set bits 1"); testOk(change->get(valueOffset)==true,"value changed"); - testOk(easyData->hasValue()==true,"hasValue"); - testOk(easyData->isValueScalar()==false,"isValueScalar"); - testOk(easyData->isValueScalarArray()==true,"isValueScalarArray"); + testOk(pvaData->hasValue()==true,"hasValue"); + testOk(pvaData->isValueScalar()==false,"isValueScalar"); + testOk(pvaData->isValueScalarArray()==true,"isValueScalarArray"); bool result; result = false; - if(easyData->getValue()) result = true; + if(pvaData->getValue()) result = true; testOk(result==true,"getValue"); result = false; - if(easyData->getArrayValue()) result = true; + if(pvaData->getArrayValue()) result = true; testOk(result==true,"getArrayValue"); result = false; - if(easyData->getScalarArrayValue()) result = true; + if(pvaData->getScalarArrayValue()) result = true; testOk(result==true,"getScalarValue"); try { - easyData->getScalarValue(); + pvaData->getScalarValue(); } catch (std::runtime_error e) { cout << " getScalarValue " << e.what() << endl; } try { - cout << "as double " << easyData->getDouble() << endl; + cout << "as double " << pvaData->getDouble() << endl; } catch (std::runtime_error e) { cout << " getDouble " << e.what() << endl; } try { - string val = easyData->getString(); + string val = pvaData->getString(); } catch (std::runtime_error e) { cout << " getString " << e.what() << endl; } - cout << "as doubleArray " << easyData->getDoubleArray() << endl; + cout << "as doubleArray " << pvaData->getDoubleArray() << endl; try { - shared_vector value = easyData->getStringArray(); + shared_vector value = pvaData->getStringArray(); } catch (std::runtime_error e) { cout << " getStringArray " << e.what() << endl; } } -MAIN(testEasyMonitorData) +MAIN(pvaClientTestMonitorData) { - cout << "\nstarting testEasyMonitorData\n"; + cout << "\nstarting pvaClientTestMonitorData\n"; testPlan(15); testDouble(); testDoubleArray(); diff --git a/test/src/testEasyMultiDouble.cpp b/test/src/pvaClientTestMultiDouble.cpp similarity index 78% rename from test/src/testEasyMultiDouble.cpp rename to test/src/pvaClientTestMultiDouble.cpp index e48ecd6..6735500 100644 --- a/test/src/testEasyMultiDouble.cpp +++ b/test/src/pvaClientTestMultiDouble.cpp @@ -1,4 +1,4 @@ -/*testEasyMultiDouble.cpp */ +/*pvaClientTestMultiDouble.cpp */ /** * Copyright - See the COPYRIGHT that is included with this distribution. * EPICS pvData is distributed subject to a Software License Agreement found @@ -12,22 +12,22 @@ #include -#include +#include #include #include using namespace std; using namespace epics::pvData; using namespace epics::pvAccess; -using namespace epics::easyPVA; +using namespace epics::pvaClient; -static void testGood(EasyPVAPtr const &easyPVA) +static void testGood(PvaClientPtr const &pvaClient) { bool isOk = true; cout << "\nstarting testGood\n"; try { - EasyPVAPtr easyPVA(EasyPVA::create()); + PvaClientPtr pvaClient(PvaClient::create()); size_t num = 5; shared_vector channelNames(num); channelNames[0] = "exampleDouble01"; @@ -38,7 +38,7 @@ static void testGood(EasyPVAPtr const &easyPVA) PVStringArrayPtr pvNames = getPVDataCreate()->createPVScalarArray(); pvNames->replace(freeze(channelNames)); - EasyMultiDoublePtr multiDouble(EasyMultiDouble::create(easyPVA,pvNames)); + PvaClientMultiDoublePtr multiDouble(PvaClientMultiDouble::create(pvaClient,pvNames)); shared_vector data = multiDouble->get(); cout << "initial " << data << endl; for(size_t i=0; i channelNames(num); channelNames[0] = "exampleByte"; @@ -68,7 +68,7 @@ static void testGoodMixed(EasyPVAPtr const &easyPVA) PVStringArrayPtr pvNames = getPVDataCreate()->createPVScalarArray(); pvNames->replace(freeze(channelNames)); - EasyMultiDoublePtr multiDouble(EasyMultiDouble::create(easyPVA,pvNames)); + PvaClientMultiDoublePtr multiDouble(PvaClientMultiDouble::create(pvaClient,pvNames)); shared_vector data = multiDouble->get(); cout << "initial " << data << endl; for(size_t i=0; i channelNames(num); channelNames[0] = "exampleDouble01"; @@ -98,7 +98,7 @@ static void testChannelNotExist(EasyPVAPtr const &easyPVA) PVStringArrayPtr pvNames = getPVDataCreate()->createPVScalarArray(); pvNames->replace(freeze(channelNames)); - EasyMultiDoublePtr multiDouble(EasyMultiDouble::create(easyPVA,pvNames)); + PvaClientMultiDoublePtr multiDouble(PvaClientMultiDouble::create(pvaClient,pvNames)); shared_vector data = multiDouble->get(); cout << "initial " << data << endl; for(size_t i=0; i channelNames(num); channelNames[0] = "exampleDouble01"; @@ -128,7 +128,7 @@ static void testNonNumeric(EasyPVAPtr const &easyPVA) PVStringArrayPtr pvNames = getPVDataCreate()->createPVScalarArray(); pvNames->replace(freeze(channelNames)); - EasyMultiDoublePtr multiDouble(EasyMultiDouble::create(easyPVA,pvNames)); + PvaClientMultiDoublePtr multiDouble(PvaClientMultiDouble::create(pvaClient,pvNames)); shared_vector data = multiDouble->get(); cout << "initial " << data << endl; for(size_t i=0; i -#include +#include #include #include using namespace std; using namespace epics::pvData; using namespace epics::pvAccess; -using namespace epics::easyPVA; +using namespace epics::pvaClient; using namespace epics::nt; using std::tr1::static_pointer_cast; -static void testGood(EasyPVAPtr const &easyPVA) +static void testGood(PvaClientPtr const &pvaClient) { PVDataCreatePtr pvDataCreate(getPVDataCreate()); bool isOk = true; cout << "\nstarting testGood\n"; try { - EasyPVAPtr easyPVA(EasyPVA::create()); + PvaClientPtr pvaClient(PvaClient::create()); size_t num = 5; shared_vector channelNames(num); channelNames[0] = "exampleDouble"; @@ -51,9 +51,9 @@ static void testGood(EasyPVAPtr const &easyPVA) addNanoseconds() -> addUserTag() -> createStructure(); - EasyNTMultiChannelPtr easy = EasyNTMultiChannel::create( - easyPVA,pvNames,structure); - NTMultiChannelPtr nt = easy->get(); + PvaClientNTMultiChannelPtr multi = PvaClientNTMultiChannel::create( + pvaClient,pvNames,structure); + NTMultiChannelPtr nt = multi->get(); for(size_t numtimes=0; numtimes<3; ++numtimes) { PVUnionArrayPtr pvValue = nt->getPVStructure()-> getSubField("value"); @@ -109,8 +109,8 @@ static void testGood(EasyPVAPtr const &easyPVA) } } pvValue->replace(freeze(valueVector)); - easy->put(nt); - nt = easy->get(); + multi->put(nt); + nt = multi->get(); } cout << "final\n" << nt->getPVStructure() << endl; } catch (std::runtime_error e) { @@ -121,12 +121,12 @@ static void testGood(EasyPVAPtr const &easyPVA) } -MAIN(testEasyNTMultiChannel) +MAIN(pvaClientTestNTMultiChannel) { - cout << "\nstarting testEasyNTMultiChannel\n"; + cout << "\nstarting pvaClientTestNTMultiChannel\n"; testPlan(1); - EasyPVAPtr easyPVA = EasyPVA::create(); - testGood(easyPVA); + PvaClientPtr pvaClient = PvaClient::create(); + testGood(pvaClient); cout << "done\n"; return 0; } diff --git a/test/src/testEasyPutData.cpp b/test/src/pvaClientTestPutData.cpp similarity index 69% rename from test/src/testEasyPutData.cpp rename to test/src/pvaClientTestPutData.cpp index aac091e..72d20fc 100644 --- a/test/src/testEasyPutData.cpp +++ b/test/src/pvaClientTestPutData.cpp @@ -1,4 +1,4 @@ -/*testEasyPutData.cpp */ +/*pvaClientTestPutData.cpp */ /** * Copyright - See the COPYRIGHT that is included with this distribution. * EPICS pvData is distributed subject to a Software License Agreement found @@ -15,15 +15,15 @@ #include #include -#include +#include #include using namespace std; using namespace epics::pvData; using namespace epics::pvAccess; -using namespace epics::easyPVA; +using namespace epics::pvaClient; -static EasyPVAPtr easyPVA = EasyPVA::create(); +static PvaClientPtr pvaClient = PvaClient::create(); static FieldCreatePtr fieldCreate = getFieldCreate(); static StandardFieldPtr standardField = getStandardField(); static PVDataCreatePtr pvDataCreate = getPVDataCreate(); @@ -49,9 +49,9 @@ static void testPostPut() endNested()-> createStructure(); - EasyPutDataPtr easyData = EasyPutData::create(structure); - PVStructurePtr pvStructure = easyData->getPVStructure(); - BitSetPtr change = easyData->getBitSet(); + PvaClientPutDataPtr pvaData = PvaClientPutData::create(structure); + PVStructurePtr pvStructure = pvaData->getPVStructure(); + BitSetPtr change = pvaData->getBitSet(); PVDoublePtr powerValue = pvStructure->getSubField("power.value"); PVDoublePtr voltageValue = pvStructure->getSubField("voltage.value"); PVDoublePtr currentValue = pvStructure->getSubField("current.value"); @@ -63,7 +63,7 @@ static void testPostPut() voltageValue->put(2.0); currentValue->put(.5); cout << "changed\n"; - cout << easyData->showChanged(cout) << endl; + cout << pvaData->showChanged(cout) << endl; testOk(change->cardinality()==3,"num set bits 3"); testOk(change->get(powerOffset)==true,"power changed"); testOk(change->get(voltageOffset)==true,"voltage changed"); @@ -80,52 +80,52 @@ void testDouble() add("value",pvDouble) -> createStructure(); - EasyPutDataPtr easyData = EasyPutData::create(structure); - PVDoublePtr pvDouble = easyData->getPVStructure()->getSubField("value"); + PvaClientPutDataPtr pvaData = PvaClientPutData::create(structure); + PVDoublePtr pvDouble = pvaData->getPVStructure()->getSubField("value"); pvDouble->put(5.0); - BitSetPtr change = easyData->getBitSet(); + BitSetPtr change = pvaData->getBitSet(); size_t valueOffset = pvDouble->getFieldOffset(); testOk(change->cardinality()==1,"num set bits 1"); testOk(change->get(valueOffset)==true,"value changed"); - testOk(easyData->hasValue()==true,"hasValue"); - testOk(easyData->isValueScalar()==true,"isValueScalar"); - testOk(easyData->isValueScalarArray()==false,"isValueScalarArray"); + testOk(pvaData->hasValue()==true,"hasValue"); + testOk(pvaData->isValueScalar()==true,"isValueScalar"); + testOk(pvaData->isValueScalarArray()==false,"isValueScalarArray"); bool result; result = false; - if(easyData->getValue()) result = true; + if(pvaData->getValue()) result = true; testOk(result==true,"getValue"); result = false; - if(easyData->getScalarValue()) result = true; + if(pvaData->getScalarValue()) result = true; testOk(result==true,"getScalarValue"); try { - easyData->getArrayValue(); + pvaData->getArrayValue(); } catch (std::runtime_error e) { cout << "getArrayValue " << e.what() << endl; } try { - easyData->getScalarArrayValue(); + pvaData->getScalarArrayValue(); } catch (std::runtime_error e) { cout << " getScalarArrayValue " << e.what() << endl; } - cout << "as double " << easyData->getDouble() << endl; - cout << "as string " << easyData->getString() << endl; + cout << "as double " << pvaData->getDouble() << endl; + cout << "as string " << pvaData->getString() << endl; try { - shared_vector value = easyData->getDoubleArray(); + shared_vector value = pvaData->getDoubleArray(); } catch (std::runtime_error e) { cout << " getDoubleArray " << e.what() << endl; } try { - shared_vector value = easyData->getStringArray(); + shared_vector value = pvaData->getStringArray(); } catch (std::runtime_error e) { cout << " getStringArray " << e.what() << endl; } - easyData->putDouble(5.0); - easyData->putString("1e5"); + pvaData->putDouble(5.0); + pvaData->putString("1e5"); try { size_t len = 2; shared_vector val(len); for(size_t i=0; iputDoubleArray(freeze(val)); + pvaData->putDoubleArray(freeze(val)); } catch (std::runtime_error e) { cout << " putDoubleArray " << e.what() << endl; } @@ -133,7 +133,7 @@ void testDouble() size_t len = 2; shared_vector val(len); val[0] = "one"; val[1] = "two"; - easyData->putStringArray(freeze(val)); + pvaData->putStringArray(freeze(val)); } catch (std::runtime_error e) { cout << " putStringArray " << e.what() << endl; } @@ -149,78 +149,78 @@ void testDoubleArray() addArray("value",pvDouble) -> createStructure(); - EasyPutDataPtr easyData = EasyPutData::create(structure); - PVDoubleArrayPtr pvalue = easyData->getPVStructure()->getSubField("value"); + PvaClientPutDataPtr pvaData = PvaClientPutData::create(structure); + PVDoubleArrayPtr pvalue = pvaData->getPVStructure()->getSubField("value"); size_t len = 5; shared_vector value(len); for(size_t i=0; ireplace(freeze(value)); - BitSetPtr change = easyData->getBitSet(); + BitSetPtr change = pvaData->getBitSet(); size_t valueOffset = pvalue->getFieldOffset(); testOk(change->cardinality()==1,"num set bits 1"); testOk(change->get(valueOffset)==true,"value changed"); - testOk(easyData->hasValue()==true,"hasValue"); - testOk(easyData->isValueScalar()==false,"isValueScalar"); - testOk(easyData->isValueScalarArray()==true,"isValueScalarArray"); + testOk(pvaData->hasValue()==true,"hasValue"); + testOk(pvaData->isValueScalar()==false,"isValueScalar"); + testOk(pvaData->isValueScalarArray()==true,"isValueScalarArray"); bool result; result = false; - if(easyData->getValue()) result = true; + if(pvaData->getValue()) result = true; testOk(result==true,"getValue"); result = false; - if(easyData->getArrayValue()) result = true; + if(pvaData->getArrayValue()) result = true; testOk(result==true,"getArrayValue"); result = false; - if(easyData->getScalarArrayValue()) result = true; + if(pvaData->getScalarArrayValue()) result = true; testOk(result==true,"getScalarValue"); try { - easyData->getScalarValue(); + pvaData->getScalarValue(); } catch (std::runtime_error e) { cout << " getScalarValue " << e.what() << endl; } try { - cout << "as double " << easyData->getDouble() << endl; + cout << "as double " << pvaData->getDouble() << endl; } catch (std::runtime_error e) { cout << " getDouble " << e.what() << endl; } try { - string val = easyData->getString(); + string val = pvaData->getString(); } catch (std::runtime_error e) { cout << " getString " << e.what() << endl; } - cout << "as doubleArray " << easyData->getDoubleArray() << endl; + cout << "as doubleArray " << pvaData->getDoubleArray() << endl; try { - shared_vector value = easyData->getStringArray(); + shared_vector value = pvaData->getStringArray(); } catch (std::runtime_error e) { cout << " getStringArray " << e.what() << endl; } try { - easyData->putDouble(5.0); + pvaData->putDouble(5.0); } catch (std::runtime_error e) { cout << " putDouble " << e.what() << endl; } try { - easyData->putString("1e5"); + pvaData->putString("1e5"); } catch (std::runtime_error e) { cout << " putString " << e.what() << endl; } value = shared_vector(len); for(size_t i=0; iputDoubleArray(freeze(value)); - cout << "as doubleArray " << easyData->getDoubleArray() << endl; + pvaData->putDoubleArray(freeze(value)); + cout << "as doubleArray " << pvaData->getDoubleArray() << endl; try { size_t len = 2; shared_vector val(len); val[0] = "one"; val[1] = "two"; - easyData->putStringArray(freeze(val)); + pvaData->putStringArray(freeze(val)); cout << "as stringArray " << val << endl; } catch (std::runtime_error e) { cout << " putStringArray " << e.what() << endl; } } -MAIN(testEasyPutData) +MAIN(pvaClientTestPutData) { - cout << "\nstarting testEasyPutData\n"; + cout << "\nstarting pvaClientTestPutData\n"; testPlan(19); testPostPut(); testDouble(); diff --git a/test/src/testEasyPutGet.cpp b/test/src/pvaClientTestPutGet.cpp similarity index 67% rename from test/src/testEasyPutGet.cpp rename to test/src/pvaClientTestPutGet.cpp index d3bc19b..eb08007 100644 --- a/test/src/testEasyPutGet.cpp +++ b/test/src/pvaClientTestPutGet.cpp @@ -1,4 +1,4 @@ -/*exampleEasyPutGet.cpp */ +/*pvaClientTestPutGet.cpp */ /** * Copyright - See the COPYRIGHT that is included with this distribution. * EPICS pvData is distributed subject to a Software License Agreement found @@ -12,26 +12,30 @@ #include -#include +#include #include #include using namespace std; using namespace epics::pvData; using namespace epics::pvAccess; -using namespace epics::easyPVA; +using namespace epics::pvaClient; -static void example(EasyPVAPtr const &easyPVA) +static void example(PvaClientPtr const &pvaClient) { cout << "\nstarting channelPutGet example\n"; try { - EasyChannelPtr easyChannel = easyPVA->createChannel("examplePowerSupply"); - easyChannel->connect(2.0); +cout << "calling createChannel\n"; + PvaClientChannelPtr pvaChannel = pvaClient->createChannel("examplePowerSupply"); +cout << "calling connect\n"; + pvaChannel->connect(2.0); testOk(true==true,"connected"); - EasyPutGetPtr putGet = easyChannel->createPutGet( +cout << "calling createPutGet\n"; + PvaClientPutGetPtr putGet = pvaChannel->createPutGet( "putField(power.value,voltage.value)getField()"); - EasyPutDataPtr putData = putGet->getPutData(); +cout << "calling getPutData\n"; + PvaClientPutDataPtr putData = putGet->getPutData(); testOk(true==true,"put connected"); PVStructurePtr pvStructure = putData->getPVStructure(); PVDoublePtr power = pvStructure->getSubField("power.value"); @@ -39,7 +43,7 @@ static void example(EasyPVAPtr const &easyPVA) power->put(5.0); voltage->put(5.0); putGet->putGet(); - EasyGetDataPtr getData = putGet->getGetData(); + PvaClientGetDataPtr getData = putGet->getGetData(); pvStructure = getData->getPVStructure(); BitSetPtr bitSet = getData->getBitSet(); cout << "changed " << getData->showChanged(cout) << endl; @@ -55,12 +59,12 @@ static void example(EasyPVAPtr const &easyPVA) } -MAIN(testEasyPutGet) +MAIN(pvaClientTestPutGet) { - cout << "\nstarting testEasyPutGet\n"; + cout << "\nstarting pvaClientTestPutGet\n"; testPlan(2); - EasyPVAPtr easyPVA = EasyPVA::create(); - example(easyPVA); + PvaClientPtr pvaClient = PvaClient::create(); + example(pvaClient); cout << "done\n"; return 0; } diff --git a/test/src/testEasyPutGetMonitor.cpp b/test/src/pvaClientTestPutGetMonitor.cpp similarity index 56% rename from test/src/testEasyPutGetMonitor.cpp rename to test/src/pvaClientTestPutGetMonitor.cpp index f020686..88386c6 100644 --- a/test/src/testEasyPutGetMonitor.cpp +++ b/test/src/pvaClientTestPutGetMonitor.cpp @@ -1,4 +1,4 @@ -/*testEasyPutGetMonitor.cpp */ +/*pvaClientTestPutGetMonitor.cpp */ /** * Copyright - See the COPYRIGHT that is included with this distribution. * EPICS pvData is distributed subject to a Software License Agreement found @@ -12,52 +12,52 @@ #include -#include +#include #include #include using namespace std; using namespace epics::pvData; using namespace epics::pvAccess; -using namespace epics::easyPVA; +using namespace epics::pvaClient; -class MyMonitor : public EasyMonitorRequester +class MyMonitor : public PvaClientMonitorRequester { public: MyMonitor() {} virtual ~MyMonitor() {} - virtual void event(EasyMonitorPtr monitor) + virtual void event(PvaClientMonitorPtr monitor) { while(true) { if(!monitor->poll()) return; - EasyMonitorDataPtr easyData = monitor->getData(); + PvaClientMonitorDataPtr pvaData = monitor->getData(); cout << "changed\n"; - easyData->showChanged(cout); + pvaData->showChanged(cout); cout << "overrun\n"; - easyData->showOverrun(cout); + pvaData->showOverrun(cout); monitor->releaseEvent(); } } }; -static void exampleDouble(EasyPVAPtr const &easyPVA) +static void exampleDouble(PvaClientPtr const &pvaClient) { cout << "\nstarting exampleDouble\n"; try { cout << "long way\n"; - EasyChannelPtr easyChannel = easyPVA->createChannel("exampleDouble"); - easyChannel->connect(2.0); + PvaClientChannelPtr pvaChannel = pvaClient->createChannel("exampleDouble"); + pvaChannel->connect(2.0); testOk(true==true,"connected"); - EasyPutPtr put = easyChannel->createPut(); - EasyPutDataPtr putData = put->getData(); + PvaClientPutPtr put = pvaChannel->createPut(); + PvaClientPutDataPtr putData = put->getData(); testOk(true==true,"put connected"); - EasyGetPtr get = easyChannel->createGet(); - EasyGetDataPtr getData = get->getData(); + PvaClientGetPtr get = pvaChannel->createGet(); + PvaClientGetDataPtr getData = get->getData(); testOk(true==true,"get connected"); - EasyMonitorRequesterPtr requester(new MyMonitor()); - EasyMonitorPtr monitor = easyChannel->monitor(requester); + PvaClientMonitorRequesterPtr requester(new MyMonitor()); + PvaClientMonitorPtr monitor = pvaChannel->monitor(requester); testOk(true==true,"monitor connected"); double out; double in; @@ -69,7 +69,7 @@ static void exampleDouble(EasyPVAPtr const &easyPVA) in = getData->getDouble(); cout << "out " << out << " in " << in << endl; } - EasyProcessPtr process = easyChannel->createProcess(); + PvaClientProcessPtr process = pvaChannel->createProcess(); process->connect(); process->process(); } catch (std::runtime_error e) { @@ -78,12 +78,12 @@ static void exampleDouble(EasyPVAPtr const &easyPVA) } -MAIN(testEasyPutGetMonitor) +MAIN(pvaClientTestPutGetMonitor) { - cout << "\nstarting testEasyPutGetMonitor\n"; + cout << "\nstarting pvaClientTestPutGetMonitor\n"; testPlan(4); - EasyPVAPtr easyPVA = EasyPVA::create(); - exampleDouble(easyPVA); + PvaClientPtr pvaClient = PvaClient::create(); + exampleDouble(pvaClient); cout << "done\n"; return 0; } From b1594e6b78b539b5cd65eed1e43584533d92b887 Mon Sep 17 00:00:00 2001 From: Marty Kraimer Date: Wed, 17 Jun 2015 15:28:28 -0400 Subject: [PATCH 3/3] changes to README.txt jenkins/cloudbees_build documentation --- README.txt | 6 +- configure/ExampleRELEASE.local | 2 +- .../{easyPVA.html => pvClientCPP.html} | 89 ++++------ .../{overview.html => pvaClientOverview.html} | 166 +++++++++--------- jenkins/cloudbees_build | 6 +- src/pvaClient.h | 2 +- 6 files changed, 122 insertions(+), 149 deletions(-) rename documentation/{easyPVA.html => pvClientCPP.html} (70%) rename documentation/{overview.html => pvaClientOverview.html} (62%) diff --git a/README.txt b/README.txt index b4d961e..123cdc6 100644 --- a/README.txt +++ b/README.txt @@ -1,7 +1,3 @@ -THIS MODULE IS NO LONGER SUPPORTED. -It's functionality has been moved to pvAccessCPP and renamed fro EasyPVA to Pva. - - To build do the following: cd configure @@ -10,4 +6,4 @@ edit RELEASE.local cd .. make -Now read documentation/easyPVA.html +Now read documentation/pvaClientCPP.html diff --git a/configure/ExampleRELEASE.local b/configure/ExampleRELEASE.local index 483ab6e..28a63d1 100644 --- a/configure/ExampleRELEASE.local +++ b/configure/ExampleRELEASE.local @@ -2,7 +2,7 @@ TEMPLATE_TOP=$(EPICS_BASE)/templates/makeBaseApp/top EPICS_BASE=/home/install/epics/base -V4BASE=/home/hg +V4BASE=/home/epicsv4 PVCOMMON=${V4BASE}/pvCommonCPP PVDATA=${V4BASE}/pvDataCPP NORMATIVETYPES=${V4BASE}/normativeTypesCPP diff --git a/documentation/easyPVA.html b/documentation/pvClientCPP.html similarity index 70% rename from documentation/easyPVA.html rename to documentation/pvClientCPP.html index dec0657..2050a6e 100644 --- a/documentation/easyPVA.html +++ b/documentation/pvClientCPP.html @@ -4,7 +4,7 @@ - EPICS easyPVA + EPICS pva
-

EPICS easyPVA

+

EPICS pvaClientCPP

EPICS V4 Working Group, Working Draft, -25-Mar-2015

+29-May-2015
This version:
easyPVA.html + href="pvaClientCPP.html">pvaClientCPP.html
Latest version:
+
Still under revision
+
Previous version:
easyPVA_20150609.html
-
Previous version:
-
easyPVA_20150325.html -
Editors:
Marty Kraimer, BNL
-
Matej Sekoranja, Cosylab

Abstract

-

NO LONGER SUPPPORTED: -The functionality has been moved to pvAccessCPP and EasyPva renamed to Pva. -

-

EasyPVA (Easy PVAccess) is a software library that provides to an EPICS client programmer, a friendly +

pvaClient is a software library that provides to an EPICS client programmer, a friendly client side programming interface to the data of an EPICS based control system. It is intended for such uses as rapid development of ad hoc programs by controls engineers, or to provide scientists a way to directly develop analytical applications.

-

Specifically, easyPVA provides an easy interface for pvAccess, which is the +

Specifically, pvaClient provides a synchronous interface for pvAccess, which is the software support for high speed controls network communications used in EPICS version 4. -PvAccess provides a callback based interface, which can be hard to use. -EasyPVA provides an interface that does not require callbacks even for monitors. +pvAccess provides a callback based interface, which can be hard to use. +pvaClient provides an interface that does not require callbacks even for monitors.

-

-EasyChannel provides many "convenience" methods to directly get and put +p> +pvaClientChannel provides many "convenience" methods to directly get and put scalar and scalarArray data types. Additional methods provide access to the full features of pvAccess.

-EasyMultiChannel provides access to data from multiple channels. -It can be used directly by a client or via EasyMultiDouble or EasyNTMultiChannel. -EasyMultiDouble allows the client to get and put data to multiple channels. +pvaClientMultiChannel provides access to data from multiple channels. +It can be used directly by a client or via pvaClientMultiDouble or pvaClientNTMultiChannel. +pvaClientMultiDouble allows the client to get and put data to multiple channels. But each channel must have a value field that is a numeric scalar. -EasyNTMultiChannel allows the client to get and put data to multiple channels. +pvaClientNTMultiChannel allows the client to get and put data to multiple channels. Each channel must have a value field. The data for the channels is presented via normative type NTMultiChannel.

@@ -83,9 +77,9 @@ The data for the channels is presented via normative type NTMultiChannel. -

Status of this Document and of the EasyPVA Software

+

Status of this Document and of the pvaClient Software

-

EasyPVACPP is ready for use.

+

pvaClientCPP is ready for use.

@@ -99,14 +93,14 @@ The data for the channels is presented via normative type NTMultiChannel.

Introduction

-

EasyPVA is a synchronous API for accessing PVData via PVAccess. It provides +

pvaClient is a synchronous API for accessing PVData via PVAccess. It provides an interface to many of the features provided by pvData and pvAccess.

This document describes the layout of the source files in this project.

A user overview is available via overview.html +href="./pvaClientOverview.html">pvaClientOverview.html

@@ -115,27 +109,10 @@ Doxygen documentation is available at href="./html/index.html">doxygenDoc

-

Building

-

After obtaining the source:

-
-cd configure
-cp ExampleRELEASE.local RELEASE.local
-
-

Edit RELEASE.local so that all path names are correct for you environment. -

-

-Then:

-
-cd ..
-make
-
- -

Example and Test Database

+

Example Database

The examples and tests require that an example pvAccess server is runnimg. -This distribution has a file exampleDatabaseEasyPVA.zip. +This distribution has a file exampleDatabasePvaClient.zip. When unzipped this is used to create an example IOC database. -The database has the record used by the examples are tests that come with easyPVAJava. -It uses pvDatabaseCPP to build the database.

After unzipping the file: @@ -156,17 +133,17 @@ cd iocBoot/exampleDatabase make runtests

Examples

-

Examples are in directory example/src. +

Examples are in directory pvaExample/src. An example of how to run them is:

 mrk> pwd
-/home/hg/easyPVACPP/example
-mrk> bin/linux-x86_64/exampleEasyGet 
+/home/epicsv4/pvAccessCPP/pvaExample
+mrk> bin/linux-x86_64/examplepvaClientGet 
 

The following is a brief description of each example. In order to understand each example it -helps to also bee loooking at the source for the example.

-

exampleEasyGet

+helps to also look at the source for the example.

+

examplePvaClientGet

This has a number of examples:

exampleDouble
@@ -193,7 +170,7 @@ helps to also bee loooking at the source for the example.

have a value field.
-

exampleEasyMonitor

+

examplePvaClientMonitor

This is an example of creating a monitor on a channel. It monitors a channel that models a powerSupply, i. e. it is not a "standard" record. It does not have a value field. @@ -202,21 +179,21 @@ It does not have a value field.

 pvput -r "power.value,voltage.value" examplePowerSupply 6 6
 
-

exampleEasyPut

+

examplePvaClientPut

This example gets and puts to channel exampleDouble.

-

exampleEasyProcess

+

examplePvaClientProcess

This example makes a process request to channel exampleDouble.

helloWorldPutGet

This is an example of issuing a channelPutGet.

-

exampleEasyMultiDouble

+

examplePvaClientMultiDouble

This is an example of issuing gets and puts to multiple channels where each channel has a numeric scalar value field.

-

exampleEasyNTMultiChannel

+

examplePvaClientNTMultiChannel

This is an example of using NDMultiChannel to obtain data from multiple channels.

helloWorldRPC

This is an example of issuing a channelRPC request. -It does not use easyPVA.

+It does not use pva.

diff --git a/documentation/overview.html b/documentation/pvaClientOverview.html similarity index 62% rename from documentation/overview.html rename to documentation/pvaClientOverview.html index 4e07a0d..cc6e5b7 100644 --- a/documentation/overview.html +++ b/documentation/pvaClientOverview.html @@ -4,7 +4,7 @@ - easyPVA C++ Overview + pva C++ Overview
-

easyPVA C++ Overview

+

PvaClient C++ Overview

@@ -39,135 +39,135 @@

Introduction

-

EasyPVA is a synchronous API for accessing PVData via PVAccess. -It also provides a number of convience methods. +

PvaClient is a synchronous API for accessing PVData via PVAccess. +It also provides a number of convenience methods. It allows the client to request access without checking for failure, -but throws an exception when a reuest fails. -A client can also check for failues and thus prevent failures.

+but throws an exception if a request fails. +A client can also check for failues and thus prevent exceptions.

-

The EasyPVA API has the following features:

+

The PvaClient API has the following features:

  1. Provides a synchronous API rather than the callback API provided by pvAccess.
  2. -
  3. Makes common requests easy.
  4. +
  5. Makes common requests pva.
  6. Provides full access to the pvAccess API for more demanding applications
  7. Allows efficient client side programs.
  8. Takes care of most object resource management problems.
-

Simple examples of using easyPVA:

+

Simple examples of using pva:

-// easyGet
-EasyPVAPtr easyPVA = EasyPVA::create();
-double value = easyPVA->channel("exampleDouble")->get()->getData()->getDouble();
+// pvaGet
+PvaClientPtr pva = PvaClient::create();
+double value = pva->channel("exampleDouble")->get()->getData()->getDouble();
 
-// easyPut
-EasyChannelPtr channel = easyPVA->channel("exampleDouble");
-EasyPutPtr put = channel->put();
-EasyPutDataPtr putData = put->getData();
+// pvaPut
+PvaClientChannelPtr channel = pva->channel("exampleDouble");
+PvaClientPutPtr put = channel->put();
+PvaClientPutDataPtr putData = put->getData();
 putData->putDouble(3.0); put->put();
 
-// easyMonitor
-EasyMonitorPtr monitor = easyPVA->channel("examplePowerSupply")->monitor("");
-EasyMonitorDataPtr easyData = monitor->getData();
+// pvaMonitor
+PvaClientMonitorPtr monitor = pva->channel("examplePowerSupply")->monitor("");
+PvaClientMonitorDataPtr pvaData = monitor->getData();
 while(true) {
     monitor->waitEvent();
     cout << "changed\n";
-    easyData->showChanged(cout);
+    pvaData->showChanged(cout);
     cout << "overrun\n";
-    easyData->showOverrun(cout);
+    pvaData->showOverrun(cout);
     monitor->releaseEvent();
 }
 
-// easyProcess
-EasyChannelPtr channel = easyPVA->channel("exampleDouble");
-EasyProcessPtr process = channel->createProcess();
+// pvaProcess
+PvaClientChannelPtr channel = pva->channel("exampleDouble");
+PvaClientProcessPtr process = channel->createProcess();
 process->process();
 
 
-

easyPVACPP includes a number of examples.

-

easyPVA does not provide support for:

+

pvaExample includes a number of examples.

+

pva does not provide support for:

ChannelArray
TBD
ChannelRPC
-
pvAccess itself already provides an easy to use synchronous interface. +
pvAccess itself already provides a synchronous interface. The examples include helloWorldRPC, which is an example of using channelRP.
-

EasyPVA

-

An instance of EasyPVA is obtained via the call:

+

PvaClient

+

An instance of PvaClient is obtained via the call:

-EasyPVAPtr easyPVA = EasyPVA::create();
+PvaClientPtr pva = PvaClient::create();
 
-

EasyPVA has methods to create instances of EasyChannel. +

PvaClient has methods to create instances of PvaClientChannel. The client can specify the provider name or use the default provider. -The client can manage it's own channels or can let easyPVA cache channels. +The client can manage it's own channels or can let pva cache channels. An example of using the cached method is:

-EasyChannelPtr easyChannel = easyPVA->channel("exampleDouble");
+PvaClientChannelPtr pvaChannel = pva->channel("exampleDouble");
 

This will attempt to connect to channel exampleDouble. Since the client did not specify a timeout an exception wll be thrown if the connection request fails. The client will block until the connection is made or an exception is thrown. -If the request succeeds, easyPVA caches the easyChannel so that if the +If the request succeeds, pva caches the pvaChannel so that if the client makes another request for the same channel the cached object is returned to the client.

An example of using a non cached method is:

-EasyChannelPtr easyChannel = easyPVA->createChannel("exampleDouble");
+PvaClientChannelPtr pvaChannel = pva->createChannel("exampleDouble");
 
-

This will create an EasyChannel and return it to the client. +

This will create an PvaClientChannel and return it to the client. The client must itself connect. This is useful if the client wants to connect to multiple channels in parallel.

-

EasyChannel - Wrapper For Single Channel

-

EasyChannel

+

PvaClientChannel - Wrapper For Single Channel

+

PvaClientChannel

This provides methods for connecting to a channel and for creating instances of -EasyField, EasyProcess, ..., EasyPutGet.

+PvaClientField, PvaClientProcess, ..., PvaClientPutGet.

Connection must be made before any create method is called or an exception is raised. The following is a synchronous connection request:

-easyChannel->connect(5.0); // BLOCKS AND THROWS IF NO CONNECT
+pvaChannel->connect(5.0); // BLOCKS AND THROWS IF NO CONNECT
 

This blocks until then connection is made or until timout occurs. An exception is raised if the connection request fails.

The same request can be made without blocking and without exceptions.

-easyChannel->issueConnect(); // DOES NOT BLOCK
+pvaChannel->issueConnect(); // DOES NOT BLOCK
 .....
-Status status =easyChannel->waitConnect(5.0);  // BLOCKS DOES NOT THROW
+Status status =pvaChannel->waitConnect(5.0);  // BLOCKS DOES NOT THROW
 if(!status.isOK()) {
    // failure do something
 }
 
-

Once the channel is connected other Easy objects can be created. +

Once the channel is connected other PvaClient objects can be created. For example:

-EasyGetPtr easyGet = easyChannel->get(); // DOES BLOCK
+PvaClientGetPtr pvaGet = pvaChannel->get(); // DOES BLOCK
 

This is a caching request. If the client already has made an identical request the client will receive the cached object. -If a new easyGet is created than it is connected before it is returned to the client. +If a new pvaGet is created than it is connected before it is returned to the client.

The client can also managed it's own objects:

-EasyGetPtr easyGet = easyChannel->createGet(); // DOES NOT BLOCK
+PvaClientGetPtr pvaGet = pvaChannel->createGet(); // DOES NOT BLOCK
 
-

The client must connect the easyGet.

+

The client must connect the pvaGet.

-

EasyGetData

-

This provides the data returned by easyGet and easyPutGet. +

PvaClientGetData

+

This provides the data returned by pvaGet and pvaPutGet. It is obtained via:

-EasyGetDataPtr easyData = easyGet->getData();
+PvaClientGetDataPtr pvaData = pvaGet->getData();
 

It provides methods to get everything returned by channelGet. In addition there are methods that make it easier to handle a value @@ -176,24 +176,24 @@ Also for a scalar that is a double or a scalarArray with element type double.

An example is:

-double value = easyData->getDouble();
+double value = pvaData->getDouble();
 

It also keeps a bitSet showing which fields have changed since the last channelGet or channelPutGet.

-

EasyMonitorData

-

To the client this looks identical to EasyGetData except that +

PvaClientMonitorData

+

To the client this looks identical to PvaClientGetData except that it provides two BitSets: changedBitSet and overrrunBitSet. -It is used by easyMonitor. +It is used by pvaMonitor.

-

EasyPutData

-

This is used to provided data for easyPut and easyPutGet. -It has many of the same methods as easyGetData. +

PvaClientPutData

+

This is used to provided data for pvaPut and pvaPutGet. +It has many of the same methods as pvaGetData. It does not have a bitSet. It also has put methods like:

-void easyData->putDouble(5.0);
+void pvaData->putDouble(5.0);
 
-

EasyGet

+

PvaClientGet

This provides methods to connect to channelGet and to issue get request. To connect via a single synchronous call:

@@ -201,35 +201,35 @@ eastGet->connect();  // BLOCKS AND CAN THROW
 

This can also be done in two steps:

-easyGet->issueConnect(); // DOES NOT BLOCK
+pvaGet->issueConnect(); // DOES NOT BLOCK
 ...
-Status status = easyGet->waitConnect(); // BLOCKS AND DOES NOT HROW
+Status status = pvaGet->waitConnect(); // BLOCKS AND DOES NOT HROW
 

Once connected gets are issued via either:

-void easyGet->get(); // BLOCKS AND CAN THROW
+void pvaGet->get(); // BLOCKS AND CAN THROW
 
or
-easyGet->issueGet(); // DOES NOT BLOCK
+pvaGet->issueGet(); // DOES NOT BLOCK
 ...
-Status status = easyGet->waitGet(); // BLOCKS AND DOES NOT THROW
+Status status = pvaGet->waitGet(); // BLOCKS AND DOES NOT THROW
 
-

EasyPut

-

This is similar to easyGet except that it wraps channelPut instead of channelGet. +

PvaClientPut

+

This is similar to pvaGet except that it wraps channelPut instead of channelGet.

Once connected puts are issued via either:

-void easyPut->put(); // BLOCKS AND CAN THROW
+void pvaPut->put(); // BLOCKS AND CAN THROW
 
or
-easyPut->issuePut(); // DOES NOT BLOCK
+pvaPut->issuePut(); // DOES NOT BLOCK
 ...
-Status status = easyPut->waitPut(); // BLOCKS AND DOES NOT THROW
+Status status = pvaPut->waitPut(); // BLOCKS AND DOES NOT THROW
 
-

EasyMonitor

-

Connecting is similar to easyGet and easyPut. +

PvaClientMonitor

+

Connecting is similar to pvaGet and pvaPut. The other methods are:

start
@@ -238,7 +238,7 @@ The other methods are:

Stops monitoring
poll
polls for a monitorEvent. - The data is avalable via easyMonitorData. + The data is avalable via pvaMonitorData.
releaseEvent
Release the data from the last poll. @@ -251,8 +251,8 @@ The other methods are:

setRequester
A client callback is registered to receive notice of monitorEvents.
-

EasyProcess

-

Connecting is similar to easyGet. +

PvaClientProcess

+

Connecting is similar to pvaGet. It has methods:

process
@@ -263,8 +263,8 @@ It has methods:

waitProcess
Wait for process to complete.
-

EasyPutGet

-

Connecting is similar to easyGet. +

PvaClientPutGet

+

Connecting is similar to pvaGet. It has methods:

putGet
@@ -285,29 +285,29 @@ It has methods:

Gets the data for the put part of channelPutGet.
getPutData
- Returns the EasyData for the put part of channelPutGet. + Returns the PvaClientData for the put part of channelPutGet.
getGetData
- Returns the EasyData for the get part of channelPutGet. + Returns the PvaClientData for the get part of channelPutGet.

Look at javaDoc for details.

-

EasyMultiChannel - Wrapper For Multiple Channels

-

EasyMultiChannel

+

PvaClientMultiChannel - Wrapper For Multiple Channels

+

PvaClientMultiChannel

This provides methods for connecting to multiple channels. -A client can either use EasyMultiChannel directly or use EasyMultiDouble or EasyNTMultiChannel. +A client can either use PvaClientMultiChannel directly or use PvaClientMultiDouble or PvaClientNTMultiChannel. But both impose restrictions on what can be accessed.

-

EasyMultiDouble

+

PvaClientMultiDouble

This provides support for gets and puts to the value field of multiple channels. Each channel must have a value field that is a numeric scalar. The client always sees the data as a PVDoubleArray. All channels must connect. If any problems occur an exception is thrown.

-

EasyNTMultiChannel

+

PvaClientNTMultiChannel

This provides support for gets and puts to the value field of multiple channels. Each channel must have a value field. The client always sees the data as a NTMultiChannel, which is one diff --git a/jenkins/cloudbees_build b/jenkins/cloudbees_build index 2c602a9..8d72d0e 100644 --- a/jenkins/cloudbees_build +++ b/jenkins/cloudbees_build @@ -1,4 +1,4 @@ -# easyPVA C++ implementation +# pvaClient C++ implementation # Jenkins @ Cloudbees build script # # Jenkins invokes scripts with the "-ex" option. So the build is considered a failure @@ -68,11 +68,11 @@ make runtests ########################################### # Create distribution -tar --exclude=test* -czf easyPVA.CB-dist.tar.gz lib include +tar --exclude=test* -czf pvaClient.CB-dist.tar.gz lib include ########################################### # Publish documentation if [ "${BUILD_DOCS}" ]; then - rsync -aqP --delete -e ssh documentation epics-jenkins@web.sourceforge.net:/home/project-web/epics-pvdata/htdocs/docbuild/easyPVACPP/tip + rsync -aqP --delete -e ssh documentation epics-jenkins@web.sourceforge.net:/home/project-web/epics-pvdata/htdocs/docbuild/pvaClientCPP/tip fi diff --git a/src/pvaClient.h b/src/pvaClient.h index 558fbab..b79db45 100644 --- a/src/pvaClient.h +++ b/src/pvaClient.h @@ -1656,7 +1656,7 @@ private: /** @page Overview Documentation * - * pvaClientOverview.html + * pvaClientOverview.html * */