/** * 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. */ #include #include #include #include #include #include #include #include #include #include "utilpvt.h" #include "evhelper.h" using namespace pvxs; namespace { DEFINE_LOGGER(app, "app"); void usage(const char* argv0) { std::cerr<<"Usage: "< [pvname ...]\n" "\n" " -h Show this message.\n" " -V Print version and exit.\n" " -r pvRequest condition.\n" " -v Make more noise.\n" " -d Shorthand for $PVXS_LOG=\"pvxs.*=DEBUG\". Make a lot of noise.\n" " -# Maximum number of elements to print for each array field.\n" " Set to zero 0 for unlimited.\n" " Default: 20\n" " -F Output format mode: delta, tree\n" ; } } int main(int argc, char *argv[]) { try { logger_config_env(); // from $PVXS_LOG bool verbose = false; std::string request; Value::Fmt::format_t format = Value::Fmt::Delta; auto arrLimit = uint64_t(-1); { int opt; while ((opt = getopt(argc, argv, "hVvdr:#:F:")) != -1) { switch(opt) { case 'h': usage(argv[0]); return 0; case 'V': std::cout<(optarg); break; case 'F': if(std::strcmp(optarg, "tree")==0) { format = Value::Fmt::Tree; } else if(std::strcmp(optarg, "delta")==0) { format = Value::Fmt::Delta; } else { std::cerr<<"Warning: ignoring unknown format '"<> workqueue(argc-optind+1); std::list ops; int remaining = argc-optind; std::atomic interrupt{false}; for(auto n : range(optind, argc)) { ops.push_back(ctxt.monitor(argv[n]) .pvRequest(request) .maskConnected(false) .maskDisconnected(false) .event([&workqueue](client::Subscription& mon) { workqueue.push(mon.shared_from_this()); }) .exec()); } // expedite search after starting all requests ctxt.hurryUp(); SigInt sig([&interrupt, &workqueue]() { interrupt = true; workqueue.push(nullptr); }); while(auto mon = workqueue.pop()) { if(remaining==0u || interrupt.load()) break; auto& name = mon->name(); try { auto update = mon->pop(); if(!update) { // event queue empty log_info_printf(app, "%s POP empty\n", name.c_str()); continue; } log_info_printf(app, "%s POP empty\n", name.c_str()); std::cout<stats(stats); std::cerr<