more work on EasyGet and conneection management; still work in progress

This commit is contained in:
Marty Kraimer
2015-03-02 15:09:24 -05:00
parent f677e1a091
commit be69a74094
6 changed files with 175 additions and 134 deletions

View File

@@ -13,18 +13,17 @@
#include <iostream>
#include <pv/easyPVA.h>
#include <pv/clientFactory.h>
using namespace std;
using namespace epics::pvData;
using namespace epics::pvAccess;
using namespace epics::easyPVA;
int main(int argc,char *argv[])
{
ClientFactory::start();
EasyPVAPtr easyPVA = EasyPVA::create();
static EasyPVAPtr easyPVA;
static void exampleDouble()
{
cout << "example double scalar\n";
double value;
try {
cout << "short way\n";
@@ -43,7 +42,52 @@ int main(int argc,char *argv[])
} catch (std::runtime_error e) {
cout << "exception " << e.what() << endl;
}
}
static void exampleDoubleArray()
{
cout << "example double array\n";
shared_vector<double> value;
try {
cout << "short way\n";
value = easyPVA->createChannel("exampleDoubleArray")->createGet()->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();
value = easyGet->getDoubleArray();
cout << "as doubleArray " << value << endl;
} catch (std::runtime_error e) {
cout << "exception " << e.what() << endl;
}
}
static void examplePowerSupply()
{
cout << "example powerSupply\n";
PVStructurePtr pvStructure;
try {
cout << "short way\n";
pvStructure = easyPVA->createChannel("examplePowerSupply")->createGet("field()")->getPVStructure();
cout << pvStructure << endl;
} catch (std::runtime_error e) {
cout << "exception " << e.what() << endl;
}
}
int main(int argc,char *argv[])
{
easyPVA = EasyPVA::create();
exampleDouble();
exampleDoubleArray();
examplePowerSupply();
cout << "done\n";
ClientFactory::stop();
easyPVA->destroy();
return 0;
}