artdaq  v3_01_00
DataLoggerApp.cc
1 #include "artdaq/Application/DataLoggerApp.hh"
2 #include "artdaq/Application/DataLoggerCore.hh"
3 #include "artdaq-core/Utilities/ExceptionHandler.hh"
4 
5 #include <iostream>
6 
8 {
9 }
10 
11 // *******************************************************************
12 // *** The following methods implement the state machine operations.
13 // *******************************************************************
14 
15 bool artdaq::DataLoggerApp::do_initialize(fhicl::ParameterSet const& pset, uint64_t, uint64_t)
16 {
17  report_string_ = "";
18 
19  //DataLogger_ptr_.reset(nullptr);
20  if (DataLogger_ptr_.get() == 0)
21  {
22  DataLogger_ptr_.reset(new DataLoggerCore());
23  }
24  external_request_status_ = DataLogger_ptr_->initialize(pset);
25  if (!external_request_status_)
26  {
27  report_string_ = "Error initializing ";
28  report_string_.append(app_name + " ");
29  report_string_.append("with ParameterSet = \"" + pset.to_string() + "\".");
30  }
31 
32  return external_request_status_;
33 }
34 
35 bool artdaq::DataLoggerApp::do_start(art::RunID id, uint64_t, uint64_t)
36 {
37  report_string_ = "";
38  external_request_status_ = DataLogger_ptr_->start(id);
39  if (!external_request_status_)
40  {
41  report_string_ = "Error starting ";
42  report_string_.append(app_name + " ");
43  report_string_.append("for run number ");
44  report_string_.append(boost::lexical_cast<std::string>(id.run()));
45  report_string_.append(".");
46  }
47 
48  return external_request_status_;
49 }
50 
51 bool artdaq::DataLoggerApp::do_stop(uint64_t, uint64_t)
52 {
53  report_string_ = "";
54  external_request_status_ = DataLogger_ptr_->stop();
55  if (!external_request_status_)
56  {
57  report_string_ = "Error stopping ";
58  report_string_.append(app_name + ".");
59  }
60 
61  return external_request_status_;
62 }
63 
64 bool artdaq::DataLoggerApp::do_pause(uint64_t, uint64_t)
65 {
66  report_string_ = "";
67  external_request_status_ = DataLogger_ptr_->pause();
68  if (!external_request_status_)
69  {
70  report_string_ = "Error pausing ";
71  report_string_.append(app_name + ".");
72  }
73 
74  return external_request_status_;
75 }
76 
77 bool artdaq::DataLoggerApp::do_resume(uint64_t, uint64_t)
78 {
79  report_string_ = "";
80  external_request_status_ = DataLogger_ptr_->resume();
81  if (!external_request_status_)
82  {
83  report_string_ = "Error resuming ";
84  report_string_.append(app_name + ".");
85  }
86 
87  return external_request_status_;
88 }
89 
91 {
92  report_string_ = "";
93  external_request_status_ = DataLogger_ptr_->shutdown();
94  if (!external_request_status_)
95  {
96  report_string_ = "Error shutting down ";
97  report_string_.append(app_name + ".");
98  }
99 
100  return external_request_status_;
101 }
102 
103 bool artdaq::DataLoggerApp::do_soft_initialize(fhicl::ParameterSet const&, uint64_t, uint64_t)
104 {
105  return true;
106 }
107 
108 bool artdaq::DataLoggerApp::do_reinitialize(fhicl::ParameterSet const&, uint64_t, uint64_t)
109 {
110  return true;
111 }
112 
113 std::string artdaq::DataLoggerApp::report(std::string const& which) const
114 {
115  std::string resultString;
116 
117  // if all that is requested is the latest state change result, return it
118  if (which == "transition_status")
119  {
120  if (report_string_.length() > 0) { return report_string_; }
121  else { return "Success"; }
122  }
123 
126  //if (report_string_.length() > 0) {
127  // resultString.append("*** Overall status message:\r\n");
128  // resultString.append(report_string_ + "\r\n");
129  // resultString.append("*** Requested report response:\r\n");
130  //}
131 
132  // pass the request to the DataLoggerCore instance, if it's available
133  if (DataLogger_ptr_.get() != 0)
134  {
135  resultString.append(DataLogger_ptr_->report(which));
136  }
137  else
138  {
139  resultString.append("This DataLogger has not yet been initialized and ");
140  resultString.append("therefore can not provide reporting.");
141  }
142 
143  return resultString;
144 }
bool do_initialize(fhicl::ParameterSet const &pset, uint64_t, uint64_t) override
Initialize the DataLoggerCore.
DataLoggerApp()
DataLoggerApp Constructor.
Definition: DataLoggerApp.cc:7
bool do_shutdown(uint64_t) override
Shutdown the DataLoggerCore.
bool do_soft_initialize(fhicl::ParameterSet const &, uint64_t, uint64_t) override
Soft-initialize the DataLoggerCore. No-Op.
bool do_resume(uint64_t, uint64_t) override
Resume the DataLoggerCore.
bool do_pause(uint64_t, uint64_t) override
Pause the DataLoggerCore.
std::string report(std::string const &which) const override
If which is &quot;transition_status&quot;, report the status of the last transition. Otherwise pass through to ...
bool do_reinitialize(fhicl::ParameterSet const &, uint64_t, uint64_t) override
Reinitialize the DataLoggerCore. No-Op.
bool do_start(art::RunID id, uint64_t, uint64_t) override
Start the DataLoggerCore.
bool do_stop(uint64_t, uint64_t) override
Stop the DataLoggerCore.
DataLoggerCore implements the state machine for the DataLogger artdaq application. DataLoggerCore processes incoming events in one of three roles: Data Logger, Online Monitor, or Dispatcher.