The shortest possible PVA monitor() example.
#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;
done = true;
break;
break;
}
done = true;
}
break;
}
}
#ifdef USE_SIGNAL
signal(SIGINT, SIG_DFL);
signal(SIGTERM, SIG_DFL);
signal(SIGQUIT, SIG_DFL);
subscription = 0;
#endif
return ret;
return 1;
}
}
virtual const char * what() const noexcept
Represents a single channel.
@ Fail
subscription ends in an error
@ Cancel
subscription ends in cancellation
@ Data
Data queue not empty. Call Monitor::poll()
@ Disconnect
subscription interrupted due to loss of communication
std::string message
set for event=Fail
bool complete() const
true if all events received.
bool poll()
updates root, changed, overrun
std::string name() const
Channel name.
epics::pvData::PVStructure::const_shared_pointer root
Monitor update data.
Subscription usable w/o callbacks.
bool wait()
wait for new event
void wake()
Abort one call to wait(), either concurrent or future.
MonitorEvent event
most recent event updated only during wait() or poll()