work in progress; simple easyGet worked!!!
This commit is contained in:
27
example/src/Makefile
Normal file
27
example/src/Makefile
Normal file
@@ -0,0 +1,27 @@
|
||||
TOP=..
|
||||
|
||||
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
|
||||
exampleEasyGet_LIBS += pvAccess
|
||||
exampleEasyGet_LIBS += pvData
|
||||
exampleEasyGet_LIBS += Com
|
||||
|
||||
#===========================
|
||||
|
||||
include $(TOP)/configure/RULES
|
||||
#----------------------------------------
|
||||
# ADD RULES AFTER THIS LINE
|
||||
|
||||
49
example/src/exampleEasyGet.cpp
Normal file
49
example/src/exampleEasyGet.cpp
Normal file
@@ -0,0 +1,49 @@
|
||||
/*exampleEasyGet.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>
|
||||
#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();
|
||||
|
||||
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();
|
||||
cout << "as double " << value << endl;
|
||||
} catch (std::runtime_error e) {
|
||||
cout << "exception " << e.what() << endl;
|
||||
}
|
||||
cout << "done\n";
|
||||
ClientFactory::stop();
|
||||
return 0;
|
||||
}
|
||||
69
example/src/exampleEasyPVStructure.cpp
Normal file
69
example/src/exampleEasyPVStructure.cpp
Normal file
@@ -0,0 +1,69 @@
|
||||
/*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;
|
||||
}
|
||||
Reference in New Issue
Block a user