The shortest possible PVA monitor() example.
#include <iostream>
#if !defined(_WIN32)
#include <signal.h>
#define USE_SIGNAL
#endif
#include <epicsEvent.h>
#include <pva/client.h>
static volatile bool done;
#ifdef USE_SIGNAL
static
void handler(int num)
{
(void)num;
done = true;
if(mon)
}
#endif
int main(int argc, char *argv[])
{
try {
if(argc<=1) {
std::cerr<<"Usage: "<<argv[0]<<" <pvname>\n";
return 1;
}
#ifdef USE_SIGNAL
subscription = &mon;
signal(SIGINT, handler);
signal(SIGTERM, handler);
signal(SIGQUIT, handler);
#endif
int ret = 0;
while(!done) {
continue;
switch(mon.
event.event) {
ret = 1;
done = true;
break;
std::cout<<mon.
name()<<
" <Cancel>\n";
done = true;
break;
std::cout<<mon.
name()<<
" <Disconnect>\n";
break;
}
done = true;
std::cout<<mon.
name()<<
" : <Complete>\n";
}
break;
}
}
#ifdef USE_SIGNAL
signal(SIGINT, SIG_DFL);
signal(SIGTERM, SIG_DFL);
signal(SIGQUIT, SIG_DFL);
subscription = 0;
#endif
return ret;
}catch(std::exception& e){
std::cerr<<"Error: "<<e.what()<<"\n";
return 1;
}
}