addded caching of EasyChannel and EasyGet; more work on lifecycle; EasyPut next

This commit is contained in:
Marty Kraimer
2015-03-03 15:26:02 -05:00
parent be69a74094
commit 5dc5e746f4
21 changed files with 547 additions and 107 deletions

View File

@@ -5,13 +5,6 @@ include $(TOP)/configure/CONFIG
# ADD MACRO DEFINITIONS AFTER THIS LINE
PROD_HOST += exampleEasyPVStructure
exampleEasyPVStructure_SRCS += exampleEasyPVStructure.cpp
exampleEasyPVStructure_LIBS += easyPVA
exampleEasyPVStructure_LIBS += pvAccess
exampleEasyPVStructure_LIBS += pvData
exampleEasyPVStructure_LIBS += Com
PROD_HOST += exampleEasyGet
exampleEasyGet_SRCS += exampleEasyGet.cpp
exampleEasyGet_LIBS += easyPVA

View File

@@ -19,32 +19,32 @@ using namespace epics::pvData;
using namespace epics::pvAccess;
using namespace epics::easyPVA;
static EasyPVAPtr easyPVA;
static void exampleDouble()
static void exampleDouble(EasyPVAPtr const &easyPVA)
{
cout << "example double scalar\n";
double value;
try {
cout << "short way\n";
value = easyPVA->createChannel("exampleDouble")->createGet()->getDouble();
cout << "as double " << value << endl;
} catch (std::runtime_error e) {
cout << "exception " << e.what() << endl;
}
try {
cout << "long way\n";
EasyChannelPtr easyChannel = easyPVA->createChannel("exampleDouble");
easyChannel->connect(2.0);
EasyGetPtr easyGet = easyChannel->createGet();
value = easyGet->getDouble();
value = easyPVA->channel("exampleDouble")->get()->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);
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;}
value = easyGet->getDouble();
cout << "as double " << value << endl;
}
static void exampleDoubleArray()
static void exampleDoubleArray(EasyPVAPtr const &easyPVA)
{
cout << "example double array\n";
shared_vector<double> value;
@@ -67,7 +67,7 @@ static void exampleDoubleArray()
}
}
static void examplePowerSupply()
static void examplePowerSupply(EasyPVAPtr const &easyPVA)
{
cout << "example powerSupply\n";
PVStructurePtr pvStructure;
@@ -83,11 +83,10 @@ static void examplePowerSupply()
int main(int argc,char *argv[])
{
easyPVA = EasyPVA::create();
exampleDouble();
exampleDoubleArray();
examplePowerSupply();
EasyPVAPtr easyPVA = EasyPVA::create();
exampleDouble(easyPVA);
exampleDoubleArray(easyPVA);
examplePowerSupply(easyPVA);
cout << "done\n";
easyPVA->destroy();
return 0;
}

View File

@@ -1,69 +0,0 @@
/*exampleEasyPVStructure.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;
int main(int argc,char *argv[])
{
EasyPVAPtr easyPVA = EasyPVA::create();
StandardPVFieldPtr standardPVField = getStandardPVField();
EasyPVStructurePtr easyStruct = easyPVA->createEasyPVStructure();
PVStructurePtr pvStructure = standardPVField->scalar(pvDouble,"alarm,timeStamp");
easyStruct->setPVStructure(pvStructure);
cout << easyStruct->getPVStructure() << endl;
cout << "as double " << easyStruct->getDouble() << endl;
cout << "as float " << easyStruct->getFloat() << endl;
try {
cout << "as ubyte " << easyStruct->getUByte() << endl;
} catch (std::runtime_error e) {
cout << "exception " << e.what() << endl;
}
pvStructure = standardPVField->scalar(pvInt,"alarm,timeStamp");
easyStruct->setPVStructure(pvStructure);
cout << easyStruct->getPVStructure() << endl;
cout << "as double " << easyStruct->getDouble() << endl;
cout << "as float " << easyStruct->getFloat() << endl;
cout << "as int " << easyStruct->getInt() << endl;
cout << "as uint " << easyStruct->getUInt() << endl;
cout << "as long " << easyStruct->getLong() << endl;
cout << "as ulong " << easyStruct->getULong() << endl;
try {
cout << "as byte " << easyStruct->getByte() << endl;
} catch (std::runtime_error e) {
cout << "exception " << e.what() << endl;
}
try {
cout << "as ubyte " << easyStruct->getUByte() << endl;
} catch (std::runtime_error e) {
cout << "exception " << e.what() << endl;
}
try {
cout << "as short " << easyStruct->getShort() << endl;
} catch (std::runtime_error e) {
cout << "exception " << e.what() << endl;
}
try {
cout << "as ushort " << easyStruct->getUShort() << endl;
} catch (std::runtime_error e) {
cout << "exception " << e.what() << endl;
}
return 0;
}