added support for privider ca; many minor changes; note exampleDatabaseEasyPVA.zip changed

This commit is contained in:
Marty Kraimer
2015-03-25 10:38:22 -04:00
parent 6a351cb5a2
commit 6b6f4bd2a9
15 changed files with 575 additions and 29 deletions

View File

@@ -48,6 +48,22 @@ exampleEasyNTMultiChannel_LIBS += nt
exampleEasyNTMultiChannel_LIBS += pvData
exampleEasyNTMultiChannel_LIBS += Com
PROD_HOST += helloWorldRPC
helloWorldRPC_SRCS += helloWorldRPC.cpp
helloWorldRPC_LIBS += easyPVA
helloWorldRPC_LIBS += pvAccess
helloWorldRPC_LIBS += nt
helloWorldRPC_LIBS += pvData
helloWorldRPC_LIBS += Com
PROD_HOST += helloWorldPutGet
helloWorldPutGet_SRCS += helloWorldPutGet.cpp
helloWorldPutGet_LIBS += easyPVA
helloWorldPutGet_LIBS += pvAccess
helloWorldPutGet_LIBS += nt
helloWorldPutGet_LIBS += pvData
helloWorldPutGet_LIBS += Com
#===========================
include $(TOP)/configure/RULES

View File

@@ -84,12 +84,63 @@ static void examplePowerSupply(EasyPVAPtr const &easyPVA)
}
static void exampleCADouble(EasyPVAPtr const &easyPVA)
{
cout << "example double scalar\n";
double value;
try {
cout << "short way\n";
value = easyPVA->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);
if(!status.isOK()) {cout << " connect failed\n"; return;}
EasyGetPtr easyGet = easyChannel->createGet();
easyGet->issueConnect();
status = easyGet->waitConnect();
if(!status.isOK()) {cout << " createGet failed\n"; return;}
EasyGetDataPtr easyData = easyGet->getData();
value = easyData->getDouble();
cout << "as double " << value << endl;
}
static void exampleCADoubleArray(EasyPVAPtr const &easyPVA)
{
cout << "example double array\n";
shared_vector<const double> value;
try {
cout << "short way\n";
value = easyPVA->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();
cout << "as doubleArray " << value << endl;
} catch (std::runtime_error e) {
cout << "exception " << e.what() << endl;
}
}
int main(int argc,char *argv[])
{
EasyPVAPtr easyPVA = EasyPVA::create();
exampleDouble(easyPVA);
exampleDoubleArray(easyPVA);
examplePowerSupply(easyPVA);
exampleCADouble(easyPVA);
exampleCADoubleArray(easyPVA);
cout << "done\n";
return 0;
}

View File

@@ -47,10 +47,38 @@ static void example(EasyPVAPtr const &easyPVA)
}
static void exampleCA(EasyPVAPtr const &easyPVA)
{
cout << "example multiDouble\n";
size_t num = 5;
shared_vector<string> channelNames(num);
channelNames[0] = "double01";
channelNames[1] = "double02";
channelNames[2] = "double03";
channelNames[3] = "double04";
channelNames[4] = "double05";
PVStringArrayPtr pvNames =
getPVDataCreate()->createPVScalarArray<PVStringArray>();
pvNames->replace(freeze(channelNames));
EasyMultiDoublePtr multiDouble(EasyMultiDouble::create(easyPVA,pvNames,5.0,"ca"));
try {
shared_vector<double> data = multiDouble->get();
cout << "initial " << data << endl;
for(size_t i=0; i<num; ++i) data[i] = data[i] + 1.1;
multiDouble->put(data);
data = multiDouble->get();
cout << "final " << data << endl;
} catch (std::runtime_error e) {
cout << "exception " << e.what() << endl;
}
}
int main(int argc,char *argv[])
{
EasyPVAPtr easyPVA = EasyPVA::create();
example(easyPVA);
exampleCA(easyPVA);
return 0;
}

View File

@@ -56,10 +56,46 @@ static void example(EasyPVAPtr const &easyPVA)
}
static void exampleCA(EasyPVAPtr const &easyPVA)
{
cout << "example ntMultiChannel\n";
size_t num = 5;
shared_vector<string> channelNames(num);
channelNames[0] = "double00";
channelNames[1] = "doubleArray";
channelNames[2] = "string00";
channelNames[3] = "mbbiwierd";
channelNames[4] = "enum01";
PVStringArrayPtr pvNames =
getPVDataCreate()->createPVScalarArray<PVStringArray>();
pvNames->replace(freeze(channelNames));
NTMultiChannelBuilderPtr builder = NTMultiChannel::createBuilder();
StructureConstPtr structure = builder->
addTimeStamp()->
addSeverity() ->
addStatus() ->
addMessage() ->
addSecondsPastEpoch() ->
addNanoseconds() ->
addUserTag() ->
createStructure();
EasyNTMultiChannelPtr easy = EasyNTMultiChannel::create(
easyPVA,pvNames,structure,5.0,"ca");
try {
NTMultiChannelPtr nt = easy->get();
cout << "initial\n" << nt->getPVStructure() << endl;
} catch (std::runtime_error e) {
cout << "exception " << e.what() << endl;
}
}
int main(int argc,char *argv[])
{
EasyPVAPtr easyPVA = EasyPVA::create();
example(easyPVA);
exampleCA(easyPVA);
return 0;
}

View File

@@ -0,0 +1,48 @@
/*helloWorldPutGet.cpp */
/**
* Copyright - See the COPYRIGHT that is included with this distribution.
* EPICS pvData is distributed subject to a Software License Agreement found
* in file LICENSE that is included with this distribution.
*/
/**
* @author mrk
*/
/* Author: Marty Kraimer */
#include <iostream>
#include <pv/easyPVA.h>
using namespace std;
using namespace epics::pvData;
using namespace epics::pvAccess;
using namespace epics::easyPVA;
static void example(EasyPVAPtr const &easyPVA)
{
cout << "helloWorldPutGet\n";
try {
EasyChannelPtr channel = easyPVA->channel("exampleHello");
EasyPutGetPtr putGet = channel->createPutGet();
putGet->connect();
EasyPutDataPtr putData = putGet->getPutData();
PVStructurePtr arg = putData->getPVStructure();
PVStringPtr pvValue = arg->getSubField<PVString>("argument.value");
pvValue->put("World");
putGet->putGet();
EasyGetDataPtr getData = putGet->getGetData();
cout << getData->getPVStructure() << endl;
} catch (std::runtime_error e) {
cout << "exception " << e.what() << endl;
}
}
int main(int argc,char *argv[])
{
EasyPVAPtr easyPVA = EasyPVA::create();
example(easyPVA);
return 0;
}

View File

@@ -0,0 +1,77 @@
/*exampleChannelRPC.cpp */
/**
* Copyright - See the COPYRIGHT that is included with this distribution.
* EPICS pvData is distributed subject to a Software License Agreement found
* in file LICENSE that is included with this distribution.
*/
/**
* @author mrk
*/
/* Author: Marty Kraimer */
#include <iostream>
#include <pv/pvData.h>
#include <pv/pvAccess.h>
#include <pv/rpcClient.h>
using namespace std;
using namespace epics::pvData;
using namespace epics::pvAccess;
static FieldCreatePtr fieldCreate = getFieldCreate();
static PVDataCreatePtr pvDataCreate = getPVDataCreate();
static void exampleSimple()
{
StructureConstPtr topStructure = fieldCreate->createFieldBuilder()->
add("value",pvString)->
createStructure();
PVStructurePtr pvRequest = pvDataCreate->createPVStructure(topStructure);
PVStringPtr pvArgument = pvRequest->getSubField<PVString>("value");
pvArgument->put("World");
cout << "example channeRPC simple\n";
try {
PVStructurePtr pvResult =
RPCClient::sendRequest("exampleHelloRPC", pvRequest);
cout << "result\n" << pvResult << endl;
} catch (RPCRequestException &e) {
cout << e.what() << endl;
}
}
void exampleMore()
{
StructureConstPtr topStructure = fieldCreate->createFieldBuilder()->
add("value",pvString)->
createStructure();
PVStructurePtr pvRequest = pvDataCreate->createPVStructure(topStructure);
PVStringPtr pvArgument = pvRequest->getSubField<PVString>("value");
pvArgument->put("World");
cout << "example channeRPC more\n";
try {
RPCClient::shared_pointer client = RPCClient::create("exampleHelloRPC");
client->issueConnect();
if (client->waitConnect())
{
client->issueRequest(pvRequest);
PVStructure::shared_pointer result = client->waitResponse();
std::cout << *result << std::endl;
}
else {
cout << "waitConnect timeout\n";
return;
}
} catch (RPCRequestException &e) {
cout << e.what() << endl;
}
}
int main(int argc,char *argv[])
{
exampleSimple();
exampleMore();
return 0;
}