Files
pvxs/example/simpleget.cpp
T
Michael Davidsaver 6267202fd4 doc
2021-05-13 08:16:44 -07:00

32 lines
844 B
C++

/**
* Copyright - See the COPYRIGHT that is included with this distribution.
* pvxs is distributed subject to a Software License Agreement found
* in file LICENSE that is included with this distribution.
*/
/** The short example of a client GET operation.
*/
#include <iostream>
#include <pvxs/client.h>
#include <pvxs/log.h>
int main(int argc, char* argv[]) {
using namespace pvxs;
// (Optional) configuring logging using $PVXS_LOG
logger_config_env();
// Configure client using $EPICS_PVA_*
client::Context ctxt(client::Config::fromEnv().build());
// fetch PV "some:pv:name" and wait up to 5 seconds for a reply.
// (throws an exception on error, including timeout)
Value reply = ctxt.get("some:pv:name").exec()->wait(5.0);
// Reply is printed to stdout.
std::cout<<reply;
return 0;
}