/** * Copyright - See the COPYRIGHT that is included with this distribution. * pvAccessCPP is distributed subject to a Software License Agreement found * in file LICENSE that is included with this distribution. */ #include #include #include #include #if !defined(_WIN32) #include #define USE_SIGNAL #endif #include #include #include #include #include #include #include #include namespace pvd = epics::pvData; namespace pva = epics::pvAccess; namespace { epicsEvent done; #ifdef USE_SIGNAL void alldone(int num) { (void)num; done.signal(); } #endif struct Getter : public pvac::ClientChannel::GetCallback, public pvac::ClientChannel::ConnectCallback { POINTER_DEFINITIONS(Getter); const std::string name; pvac::ClientChannel channel; pvac::Operation op; Getter(pvac::ClientProvider& provider, const std::string& name) :name(name) ,channel(provider.connect(name)) { channel.addConnectListener(this); } virtual ~Getter() { channel.removeConnectListener(this); op.cancel(); } virtual void getDone(const pvac::GetEvent& event) OVERRIDE FINAL { switch(event.event) { case pvac::GetEvent::Fail: std::cout<<"Error "<getSubField("value")); if(!valfld) valfld = event.value; std::cout< pvs_t; pvs_t pvs; int opt; while((opt = getopt(argc, argv, "hRp:w:")) != -1) { switch(opt) { case 'R': refmon.start(5.0); break; case 'p': providerName = optarg; break; case 'w': waitTime = pvd::castUnsafe(optarg); break; case 'h': std::cout<<"Usage: "<] [-w ] [-R] ...\n"; return 0; default: std::cerr<<"Unknown argument: "<<(int)opt<<"\n"; return -1; } } for(int i=optind; i gets_t; gets_t gets; for(pvs_t::const_iterator it=pvs.begin(); it!=pvs.end(); ++it) { const std::string& pv = *it; Getter::shared_pointer get(new Getter(provider, pv)); // addConnectListener() always invokes connectEvent() with current state gets.insert(get); } if(waitTime<0.0) done.wait(); else done.wait(waitTime); if(refmon.running()) { refmon.stop(); // drop refs to operations, but keep ref to ClientProvider gets.clear(); // show final counts refmon.current(); } } catch(std::exception& e){ std::cerr<<"Error: "<