Skip to content

Commit 0b8ccc6

Browse files
authored
Merge pull request #46 from mrkraimer/master
Changes because of enhancements to pvDatabaseCPP and pvaClientCPP
2 parents de8423f + d255887 commit 0b8ccc6

39 files changed

+1601
-6
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ EMBEDDED_TOPS += $(TOP)/helloPutGet
1111
EMBEDDED_TOPS += $(TOP)/helloRPC
1212
EMBEDDED_TOPS += $(TOP)/pvDatabaseRPC
1313
EMBEDDED_TOPS += $(TOP)/arrayPerformance
14+
EMBEDDED_TOPS += $(TOP)/testClient
1415

1516
DIRS := configure
1617

documentation/RELEASE_NOTES.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
EPICS 7.0.2.2 April 2019
2+
====================
3+
4+
Changes include examples and tests that for changes to **pvaClientCPP** and **pvDatabaseCPP**.
5+
This means that this release is not compatible with previous versions of **EPICS 7**.
6+
7+
* helloRPC now uses NTURI for communication between client and server.
8+
* testClient is new. See testClient/scripts/README.md
9+
110

211
GITHUB Main
312
===========

exampleClient/src/Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ PROD_HOST += examplePvaClientNTMulti
6464
examplePvaClientNTMulti_SRCS += examplePvaClientNTMulti.cpp
6565
examplePvaClientNTMulti_LIBS += $(EPICS_BASE_PVA_CORE_LIBS)
6666

67+
PROD_HOST += examplePvaClientNTMultiGet
68+
examplePvaClientNTMultiGet_SRCS += examplePvaClientNTMultiGet.cpp
69+
examplePvaClientNTMultiGet_LIBS += $(EPICS_BASE_PVA_CORE_LIBS)
70+
6771

6872
PROD_HOST += helloWorldRPC
6973
helloWorldRPC_SRCS += helloWorldRPC.cpp

exampleClient/src/examplePvaClientGet.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ static void exampleDouble(PvaClientPtr const &pva,string const & channelName,str
2222
{
2323
cout << "__exampleDouble__ channelName " << channelName << " providerName " << providerName << endl;
2424
double value;
25+
cout << "shortest way\n";
26+
value = pva->channel(channelName,providerName)->getDouble();
2527
cout << "short way\n";
2628
value = pva->channel(channelName,providerName,2.0)->get()->getData()->getDouble();
2729
cout << "as double " << value << endl;
@@ -50,6 +52,8 @@ static void exampleDoubleArray(PvaClientPtr const &pva,string const & channelNam
5052
<< " providerName "
5153
<< providerName << endl;
5254
shared_vector<const double> value;
55+
cout << "shortest way\n";
56+
value = pva->channel(channelName,providerName)->getDoubleArray();
5357
cout << "short way\n";
5458
value = pva->channel(channelName,providerName,2.0)->get()->getData()->getDoubleArray();
5559
cout << "as doubleArray " << value << endl;
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
/*
2+
* Copyright information and license terms for this software can be
3+
* found in the file LICENSE that is included with the distribution
4+
*/
5+
6+
/**
7+
* @author mrk
8+
*/
9+
10+
/* Author: Marty Kraimer */
11+
12+
#include <iostream>
13+
14+
#include <pv/pvaClientMultiChannel.h>
15+
#include <pv/convert.h>
16+
17+
using std::tr1::static_pointer_cast;
18+
using namespace std;
19+
using namespace epics::pvData;
20+
using namespace epics::pvAccess;
21+
using namespace epics::pvaClient;
22+
23+
24+
static void example(
25+
PvaClientPtr const &pva,
26+
string provider,
27+
shared_vector<const string> const &channelNames)
28+
{
29+
cout << "_example provider " << provider << " channels " << channelNames << "_\n";
30+
size_t num = channelNames.size();
31+
PvaClientMultiChannelPtr multiChannel(
32+
PvaClientMultiChannel::create(pva,channelNames,provider));
33+
Status status = multiChannel->connect();
34+
if(!status.isSuccess()) {
35+
cout << "Did not connect: ";
36+
shared_vector<epics::pvData::boolean> isConnected = multiChannel->getIsConnected();
37+
for(size_t i=0; i<num; ++i) {
38+
if(!isConnected[i]) cout << channelNames[i] << " ";
39+
}
40+
cout << endl;
41+
return;
42+
}
43+
PvaClientNTMultiGetPtr multiGet(multiChannel->createNTGet());
44+
multiGet->get();
45+
PvaClientNTMultiDataPtr multiData = multiGet->getData();
46+
PVStructurePtr pvStructure = multiData->getNTMultiChannel()->getPVStructure();
47+
PVUnionArrayPtr pvUnionArray = static_pointer_cast<PVUnionArray>(pvStructure->getSubField("value"));
48+
shared_vector<const PVUnionPtr> values = pvUnionArray->view();
49+
for(size_t ind=0; ind < values.size(); ++ind)
50+
{
51+
PVUnionPtr pvUnion = values[ind];
52+
PVFieldPtr pvField = pvUnion->get();
53+
cout << channelNames[ind] << " = " << pvField << "\n";
54+
}
55+
}
56+
57+
int main(int argc,char *argv[])
58+
{
59+
cout << "_____examplePvaClientNTMultiGet starting_______\n";
60+
try {
61+
PvaClientPtr pva = PvaClient::get("pva ca");
62+
size_t num = 4;
63+
shared_vector<string> channelNames(num);
64+
channelNames[0] = "PVRdouble";
65+
channelNames[1] = "PVRstring";
66+
channelNames[2] = "PVRdoubleArray";
67+
channelNames[3] = "PVRstringArray";
68+
shared_vector<const string> names(freeze(channelNames));
69+
example(pva,"pva",names);
70+
cout << "_____examplePvaClientNTMultiGet done_______\n";
71+
} catch (std::exception& e) {
72+
cout << "exception " << e.what() << endl;
73+
return 1;
74+
}
75+
return 0;
76+
}

exampleClient/src/examplePvaClientPut.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ static ConvertPtr convert = getConvert();
2626
static void exampleDouble(PvaClientPtr const &pva,string const & channelName,string const & providerName)
2727
{
2828
cout << "__exampleDouble__ channelName " << channelName << " providerName " << providerName << endl;
29+
cout << "shortest way\n";
30+
pva->channel(channelName,providerName)->putDouble(1.0);
31+
cout << "longer way\n";
2932
PvaClientChannelPtr channel = pva->channel(channelName,providerName,2.0);
3033
PvaClientPutPtr put = channel->put();
3134
PvaClientPutDataPtr putData = put->getData();
@@ -48,14 +51,19 @@ static void exampleDouble(PvaClientPtr const &pva,string const & channelName,str
4851
static void exampleDoubleArray(PvaClientPtr const &pva,string const & channelName,string const & providerName)
4952
{
5053
cout << "__exampleDoubleArray__ channelName " << channelName << " providerName " << providerName << endl;
54+
cout << "shortest way\n";
55+
size_t num = 5;
56+
shared_vector<double> data(num,0);
57+
for(size_t i=0; i<num; ++i) data[i] = i;
58+
pva->channel(channelName,providerName)->putDoubleArray(freeze(data));
59+
cout << "longer way\n";
60+
data = shared_vector<double>(num,0);
61+
for(size_t i=0; i<num; ++i) data[i] = .1*i;
5162
PvaClientChannelPtr channel = pva->channel(channelName,providerName,2.0);
5263
PvaClientPutPtr put = channel->put();
5364
PvaClientPutDataPtr putData = put->getData();
5465
PvaClientMonitorPtr monitor = pva->channel(channelName,providerName,2.0)->monitor("value");
5566
PvaClientMonitorDataPtr monitorData = monitor->getData();
56-
size_t num = 5;
57-
shared_vector<double> data(num,0);
58-
for(size_t i=0; i<num; ++i) data[i] = .1*i;
5967
putData->putDoubleArray(freeze(data)); put->put();
6068
channel->get("field(value)")->getData()->showChanged(cout) << endl;
6169
data = shared_vector<double>(num,0);

test/pvaClientTestGetData.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,9 @@ static void testDoubleArray()
181181
}
182182
try {
183183
shared_vector<const string> value = pvaData->getStringArray();
184+
testPass("getStringArray");
184185
} catch (std::exception& e) {
185-
testPass("getStringArray exception '%s'", e.what());
186+
testFail("getStringArray exception '%s'", e.what());
186187
}
187188
}
188189

test/pvaClientTestMonitorData.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,9 @@ static void testDoubleArray()
178178
}
179179
try {
180180
shared_vector<const string> value = pvaData->getStringArray();
181+
testPass("getStringArray");
181182
} catch (std::exception& e) {
182-
testPass("getStringArray exception '%s'", e.what());
183+
testFail("getStringArray exception '%s'", e.what());
183184
}
184185
}
185186

test/pvaClientTestPutData.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,8 +244,9 @@ static void testDoubleArray()
244244
}
245245
try {
246246
shared_vector<const string> value = pvaData->getStringArray();
247+
testPass("getStringArray");
247248
} catch (std::exception& e) {
248-
testPass("getStringArray exception '%s'", e.what());
249+
testFail("getStringArray exception '%s'", e.what());
249250
}
250251

251252
try {

testClient/Makefile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Makefile at top of application tree
2+
3+
TOP = .
4+
include $(TOP)/configure/CONFIG
5+
6+
DIRS += configure
7+
8+
DIRS += src
9+
src_DEPEND_DIRS = configure
10+
11+
include $(TOP)/configure/RULES_TOP
12+
13+

0 commit comments

Comments
 (0)