7 #include <boost/program_options.hpp>
12 namespace po = boost::program_options;
14 #include <boost/asio.hpp>
15 #include <boost/lexical_cast.hpp>
17 #define cool_print(a) { std::cout << #a" = " << a << std::endl; }
22 if (filename.empty()) {
29 std::ifstream config(filename.c_str());
34 range.push_back(dom_id);
41 int main(
int argc,
char* argv[])
44 unsigned int hit_rate = 10;
51 unsigned int deltaTS = 100;
53 unsigned int MTU = 1500;
55 unsigned int run_number = 24;
57 po::options_description desc(
"Options");
59 (
"help,h",
"Print this help and exit.")
61 po::value<int>(&dq_port)->required(),
62 "Set the port to send data trough.")
64 po::value<std::string>(&dq_address)->required(),
65 "Set the IP address to send data to.")
67 po::value<unsigned int>(&deltaTS)->default_value(deltaTS),
68 "Set the value of the time slice duration in milliseconds.")
70 po::value<unsigned int>(&hit_rate)->default_value(hit_rate),
71 "Set the desired hit rate in kHz.")
73 po::value<unsigned int>(&run_number)->default_value(run_number),
74 "Set the run number.")
76 po::value<unsigned int>(&MTU)->default_value(MTU),
77 "Set the Maximum Transfer Unit (MTU), i.e. the maximum UDP packet size.")
79 po::value<std::string>(&configuration_filename)->default_value(configuration_filename),
80 "Provide a file with the set of DOM ID to simulate. It must be in the form \"1 2 3 5 6 11\".");
85 po::command_line_parser(argc, argv).
options(desc).run(),
88 if (vm.count(
"help")) {
89 std::cout << desc << std::endl;
94 }
catch (
const po::error& e) {
95 std::cerr <<
"CLBsimu: Error: " << e.what() <<
'\n'
98 }
catch (
const std::runtime_error& e) {
99 std::cerr <<
"CLBsimu: Error: " << e.what() <<
'\n'
100 << desc << std::endl;
107 std::cerr <<
"FATAL: No DOM ID range available. Exiting\n";
111 std::cout <<
"Program UP!\n";
112 std::cout <<
"here is the configuration:\n";
120 std::cout <<
"DOM IDs:\n";
122 for (
unsigned int i = 0;
i < range.size(); ++
i) {
123 std::cout << range[
i] <<
' ';
127 FrameGenerator generator(range, deltaTS, run_number, MTU, hit_rate);
131 boost::asio::io_service service;
133 boost::asio::ip::udp::socket sock(service, boost::asio::ip::udp::udp::v4());
135 boost::asio::ip::udp::udp::resolver resolver(service);
137 boost::asio::ip::udp::udp::resolver::query query(
138 boost::asio::ip::udp::udp::v4(),
140 boost::lexical_cast<std::string>(dq_port));
142 boost::asio::ip::udp::udp::endpoint
const destination = *resolver.resolve(query);
145 for (
unsigned int i = 0;
i < range.size();
i++) {
148 sock.send_to(boost::asio::buffer(data), destination);
int main(int argc, char *argv[])
then usage $script[port]< option > nPossible options
void store(const std::string &file_name, const JDetector &detector)
Store detector to output file.
void getNext(raw_data_t &target)
z range($ZMAX-$ZMIN)< $MINIMAL_DZ." fi fi typeset -Z 4 STRING typeset -Z 2 FLOOR JPlot1D -f $
DOMRange_t createDOMRange(const std::string &filename="")