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 <string>
15 : #include <chrono>
16 : #include <csignal>
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 0 : static void sig_handler(int signal) {
28 0 : TLOG() <<"Signal received: " << signal;
29 0 : global_signal = signal;
30 0 : run_marker.store(false);
31 0 : }
32 :
33 : // Test application to showcase basic functionality
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("dummy://"), 30);
45 0 : fac->set_commanded(obj, "pippo");
46 0 : fac->run(run_marker);
47 0 : return 0;
48 0 : }
|