$treeview $search $mathjax $extrastylesheet
artdaq_mfextensions
v1_03_03
$projectbrief
|
$projectbrief
|
$searchbox |
00001 #include "messagefacility/MessageLogger/MessageLogger.h" 00002 #include "messagefacility/Utilities/ErrorObj.h" 00003 00004 #include <boost/bind.hpp> 00005 #include <boost/program_options.hpp> 00006 00007 #include <iostream> 00008 #include <string> 00009 #include "fhiclcpp/make_ParameterSet.h" 00010 #include "mfextensions/Binaries/ReceiverManager.hh" 00011 00012 namespace po = boost::program_options; 00013 00014 bool cmdline = false; 00015 int z = 0; 00016 00017 int main(int argc, char* argv[]) { 00018 // checking options 00019 std::string filename; 00020 std::string configFile; 00021 00022 try { 00023 po::options_description cmdopt("Allowed options"); 00024 cmdopt.add_options()("help,h", "display help message")("config,c", 00025 po::value<std::string>(&configFile)->default_value(""), 00026 "Specify the FHiCL configuration file to use")( 00027 "filename,f", po::value<std::string>(&filename)->default_value("msg_archive"), 00028 "specify the message archive file name"); 00029 00030 po::options_description desc; 00031 desc.add(cmdopt); 00032 00033 po::variables_map vm; 00034 po::store(po::command_line_parser(argc, argv).options(desc).run(), vm); 00035 po::notify(vm); 00036 00037 if (vm.count("help")) { 00038 std::cout << "Usage: msglogger [options] <message text>\n"; 00039 std::cout << cmdopt; 00040 return 0; 00041 } 00042 } catch (std::exception& e) { 00043 std::cerr << "error: " << e.what() << "\n"; 00044 return 1; 00045 } catch (...) { 00046 std::cerr << "Exception of unknown type!\n"; 00047 return 1; 00048 } 00049 00050 // Start MessageFacility Service 00051 std::ostringstream descstr; 00052 descstr << ""; 00053 fhicl::ParameterSet main_pset; 00054 mf::StartMessageFacility(main_pset); 00055 00056 fhicl::ParameterSet pset; 00057 auto maker = cet::filepath_maker(); 00058 fhicl::make_ParameterSet(configFile, maker, pset); 00059 mfviewer::ReceiverManager rm(pset); 00060 00061 // Welcome message 00062 std::cout << "Message Facility MsgServer is up and listening to configured Receivers" << std::endl; 00063 00064 // Command line message loop 00065 std::string cmd; 00066 00067 while (true) { 00068 if (cmdline) std::cout << "> "; 00069 getline(std::cin, cmd); 00070 00071 if (cmd.empty()) { 00072 cmdline = true; 00073 } else if (cmdline && (cmd == "r" || cmd == "resume")) { 00074 cmdline = false; 00075 ; 00076 } else if (cmdline && (cmd == "q" || cmd == "quit")) { 00077 // dds.stop(); 00078 return 0; 00079 } else if (cmdline && (cmd == "h" || cmd == "help")) { 00080 std::cout << "MessageFacility DDS server available commands:\n" 00081 << " (h)elp display this help message\n" 00082 << " (s)tat summary of received messages\n" 00083 << " (r)esume resume to message listening mode\n" 00084 //<< " (p)artition listen to a new partition\n" 00085 << " (q)uit exit MessageFacility DDS server\n" 00086 << " ... more interactive commands on the way.\n"; 00087 } else if (cmdline && (cmd == "s" || cmd == "stat")) { 00088 std::cout << "Currently listening, " << z << " messages have been received." << std::endl; 00089 } else if (cmdline) { 00090 std::cout << "Command " << cmd << " not found. " 00091 << "Type \"help\" or \"h\" for a list of available commands.\n"; 00092 } 00093 } // end of command line message loop 00094 00095 return 0; 00096 }