Line data Source code
1 : /**
2 : * @file test_stdin_app.cxx Test application for using
3 : * the std::cin based CommandFacility implementation
4 : *
5 : * This is part of the DUNE DAQ Application Framework, copyright 2020.
6 : * Licensing/copyright details are in the COPYING file that you should have
7 : * received with this code.
8 : */
9 : #include "DummyCommandedObject.hpp"
10 : #include "cmdlib/CommandFacility.hpp"
11 : #include "logging/Logging.hpp"
12 :
13 : #include <string>
14 : #include <csignal>
15 :
16 : using namespace dunedaq::cmdlib;
17 :
18 : // Signal carrier
19 : volatile int global_signal;
20 :
21 : // Run marker
22 : std::atomic<bool> run_marker{true};
23 :
24 : // SIG handler
25 0 : static void sig_handler(int signal) {
26 0 : TLOG() << "Signal received: " << signal;
27 0 : global_signal = signal;
28 0 : run_marker.store(false);
29 0 : }
30 :
31 : // Test application for standard input
32 : int
33 0 : main(int /*argc*/, char** /*argv[]*/)
34 : {
35 : // Setup signals
36 0 : std::signal(SIGKILL, sig_handler);
37 0 : std::signal(SIGABRT, sig_handler);
38 0 : std::signal(SIGQUIT, sig_handler);
39 :
40 : // Setup facility
41 0 : DummyCommandedObject obj;
42 0 : auto fac = make_command_facility(std::string("stdin://my_minidaq_config.json")); // TODO parametrize command file
43 0 : fac->set_commanded(obj, "pippo");
44 0 : fac->run(run_marker);
45 0 : return 0;
46 0 : }
|