Files
caClientLessons/caLesson6/caClientWrapperC++/testPV.cc
T

55 lines
1.2 KiB
C++

#include "epicsPV.h"
#include <stdexcept>
using namespace std;
class myPV : public epicsPV
{
public:
myPV(const char* channelName=NULL, caDatatype preferredDatatype=caTypeNative)
: epicsPV(channelName, preferredDatatype) {}
void connectionUpEvent();
void connectionDownEvent();
};
void myPV::connectionUpEvent()
{
cout << name() << " connected, datatype = " << datatype() << endl;
}
void myPV::connectionDownEvent()
{
cout << name() << " disconnected" << endl;
}
int main (int argc, const char** argv)
{
try {
myPV pv(argv[1]);
cout << "before get: " << pv.name() << " = " << pv <<
" " << pv.alarmSeverity() <<
" " << pv.alarmStatus() << endl;
caget(pv);
cout << "after get: " << pv.name() << " = " << pv <<
" " << pv.alarmSeverity() <<
" " << pv.alarmStatus() << endl;
double val = pv;
cout << pv.name() << " = " << val << endl;
unsigned int ival = pv;
cout << pv.name() << " = " << ival << endl;
if (argc == 3)
{
pv.put(argv[2]);
}
}
catch (exception& e)
{
cout << endl << e.what() << endl;
}
return 0;
}