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 <csignal>
14 : #include <string>
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 : static void
26 0 : sig_handler(int signal)
27 : {
28 0 : TLOG() << "Signal received: " << signal;
29 0 : global_signal = signal;
30 0 : run_marker.store(false);
31 0 : }
32 :
33 : // Test application for standard input
34 : int
35 0 : main(int /*argc*/, char** /*argv[]*/)
36 : {
37 : // Setup signals
38 0 : std::signal(SIGKILL, sig_handler);
39 0 : std::signal(SIGABRT, sig_handler);
40 0 : std::signal(SIGQUIT, sig_handler);
41 :
42 : // Setup facility
43 0 : DummyCommandedObject obj;
44 0 : auto fac = make_command_facility(std::string("stdin://my_minidaq_config.json")); // TODO parametrize command file
45 0 : fac->set_commanded(obj, "pippo");
46 0 : fac->run(run_marker);
47 0 : return 0;
48 0 : }
|