/** * 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 //! [Headers] #include #include #include #include //! [Headers] namespace pvd = epics::pvData; namespace pva = epics::pvAccess; namespace { epicsEvent done; #ifdef USE_SIGNAL void alldone(int num) { (void)num; done.signal(); } #endif struct GetReq : public pva::ChannelGetRequester { POINTER_DEFINITIONS(GetReq); const std::string name; // we hold strong ref to ChannelGet // which should only hold weak ref to us operation_type::shared_pointer op; GetReq(const std::string& name) :name(name) {} virtual ~GetReq() {} virtual std::string getRequesterName() { return "GetReq"; } virtual void channelGetConnect( const epics::pvData::Status& status, pva::ChannelGet::shared_pointer const & channelGet, pvd::Structure::const_shared_pointer const & structure) { // Called each time get operation becomes "ready" (channel connected) if(status.isSuccess()) { std::cout<<"Get execute "<get(); } else { std::cout<<"Oops GetConnect: "<getSubField("value")); if(!valfld) valfld = pvStructure; std::cout< pvs_t; pvs_t pvs; for(int i=1; i(argv[++i]); } else { std::cerr << "--timeout requires value\n"; return 1; } } else { std::cerr<<"Unknown argument: "<createProvider(providerName, conf)); if(!provider) throw std::logic_error("pva provider not registered"); // need to store references to keep get (and channel) from being closed typedef std::set gets_t; gets_t gets; for(pvs_t::const_iterator it=pvs.begin(); it!=pvs.end(); ++it) { const std::string& pv = *it; GetReq::shared_pointer getreq(new GetReq(pv)); pva::Channel::shared_pointer chan(provider->createChannel(pv)); assert(chan); // no need to wait for connection getreq->op = chan->createChannelGet(getreq, pvReq); // if !op then channelGetConnect() called with error status if(!getreq->op) continue; gets.insert(getreq); // drop our explicit Channel reference, ChannelGet holds an additional reference } if(waitTime<0.0) done.wait(); else done.wait(waitTime); } catch(std::exception& e){ std::cerr<<"Error: "<