Line data Source code
1 : /**
2 : * @file test_dummy_app.cxx Test application for using the
3 : * dummyCommandFacility with a DummyCommandedObject.
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 :
12 : #include "logging/Logging.hpp"
13 :
14 : #include <chrono>
15 : #include <csignal>
16 : #include <string>
17 :
18 : using namespace dunedaq::cmdlib;
19 :
20 : // Signal carrier
21 : volatile int global_signal;
22 :
23 : // Run marker
24 : std::atomic<bool> run_marker{ true };
25 :
26 : // SIG handler
27 : static void
28 0 : sig_handler(int signal)
29 : {
30 0 : TLOG() << "Signal received: " << signal;
31 0 : global_signal = signal;
32 0 : run_marker.store(false);
33 0 : }
34 :
35 : // Test application to showcase basic functionality
36 : int
37 0 : main(int /*argc*/, char** /*argv[]*/)
38 : {
39 : // Setup signals
40 0 : std::signal(SIGKILL, sig_handler);
41 0 : std::signal(SIGABRT, sig_handler);
42 0 : std::signal(SIGQUIT, sig_handler);
43 :
44 : // Setup facility
45 0 : DummyCommandedObject obj;
46 0 : auto fac = make_command_facility(std::string("dummy://"), 30);
47 0 : fac->set_commanded(obj, "pippo");
48 0 : fac->run(run_marker);
49 0 : return 0;
50 0 : }
|