Copy of old lessons from afs webpage
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
#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;
|
||||
}
|
||||
Reference in New Issue
Block a user