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