/* * Copyright information and license terms for this software can be * found in the file LICENSE that is included with the distribution */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "pvutils.h" namespace pvd = epics::pvData; namespace pva = epics::pvAccess; namespace { void usage (void) { fprintf (stderr, "\nUsage: pvinfo [options] ...\n\n" "\noptions:\n" " -h: Help: Print this message\n" " -V: Print version and exit\n" " -w : Wait time, specifies timeout, default is %f second(s)\n" " -p : Set default provider name, default is '%s'\n" " -d: Enable debug output\n" " -c: Wait for clean shutdown and report used instance count (for expert users)" "\nExample: pvinfo double01\n\n" , timeout, defaultProvider.c_str()); } int haderror; struct GetInfo : public pvac::ClientChannel::InfoCallback, public pvac::ClientChannel::ConnectCallback, public Tracker { pvac::ClientChannel chan; pvac::Operation op; std::string peerName; explicit GetInfo(pvac::ClientChannel& chan) :chan(chan) { chan.addConnectListener(this); } virtual ~GetInfo() { chan.removeConnectListener(this); } virtual void connectEvent(const pvac::ConnectEvent& evt) OVERRIDE FINAL { if(evt.connected) { Guard G(doneLock); peerName = evt.peerName; } } virtual void infoDone(const pvac::InfoEvent& evt) OVERRIDE FINAL { std::string pname; { Guard G(doneLock); pname = peerName; } switch(evt.event) { case pvac::InfoEvent::Cancel: break; case pvac::InfoEvent::Fail: std::cerr< > infos; pva::ca::CAClientFactory::start(); { pvac::ClientProvider prov(defaultProvider); for(int i = optind; i info(new GetInfo(chan)); info->op = chan.info(info.get()); infos.push_back(info); } Tracker::prepare(); // install signal handler { Guard G(Tracker::doneLock); while(Tracker::inprog.size() && !Tracker::abort) { UnGuard U(G); if(timeout<=0) Tracker::doneEvt.wait(); else if(!Tracker::doneEvt.wait(timeout)) { haderror = 1; std::cerr<<"Timeout\n"; break; } } } } return haderror ? 1 : 0; }