00001 #include "artdaq/Application/DataLoggerApp.hh"
00002 #include "artdaq/Application/DataLoggerCore.hh"
00003 #include "artdaq-core/Utilities/ExceptionHandler.hh"
00004
00005 #include <iostream>
00006
00007 artdaq::DataLoggerApp::DataLoggerApp()
00008 {
00009 }
00010
00011
00012
00013
00014
00015 bool artdaq::DataLoggerApp::do_initialize(fhicl::ParameterSet const& pset, uint64_t, uint64_t)
00016 {
00017 report_string_ = "";
00018
00019
00020 if (DataLogger_ptr_.get() == 0)
00021 {
00022 DataLogger_ptr_.reset(new DataLoggerCore());
00023 }
00024 external_request_status_ = DataLogger_ptr_->initialize(pset);
00025 if (!external_request_status_)
00026 {
00027 report_string_ = "Error initializing ";
00028 report_string_.append(app_name + " ");
00029 report_string_.append("with ParameterSet = \"" + pset.to_string() + "\".");
00030 }
00031
00032 return external_request_status_;
00033 }
00034
00035 bool artdaq::DataLoggerApp::do_start(art::RunID id, uint64_t, uint64_t)
00036 {
00037 report_string_ = "";
00038 external_request_status_ = DataLogger_ptr_->start(id);
00039 if (!external_request_status_)
00040 {
00041 report_string_ = "Error starting ";
00042 report_string_.append(app_name + " ");
00043 report_string_.append("for run number ");
00044 report_string_.append(boost::lexical_cast<std::string>(id.run()));
00045 report_string_.append(".");
00046 }
00047
00048 return external_request_status_;
00049 }
00050
00051 bool artdaq::DataLoggerApp::do_stop(uint64_t, uint64_t)
00052 {
00053 report_string_ = "";
00054 external_request_status_ = DataLogger_ptr_->stop();
00055 if (!external_request_status_)
00056 {
00057 report_string_ = "Error stopping ";
00058 report_string_.append(app_name + ".");
00059 }
00060
00061 return external_request_status_;
00062 }
00063
00064 bool artdaq::DataLoggerApp::do_pause(uint64_t, uint64_t)
00065 {
00066 report_string_ = "";
00067 external_request_status_ = DataLogger_ptr_->pause();
00068 if (!external_request_status_)
00069 {
00070 report_string_ = "Error pausing ";
00071 report_string_.append(app_name + ".");
00072 }
00073
00074 return external_request_status_;
00075 }
00076
00077 bool artdaq::DataLoggerApp::do_resume(uint64_t, uint64_t)
00078 {
00079 report_string_ = "";
00080 external_request_status_ = DataLogger_ptr_->resume();
00081 if (!external_request_status_)
00082 {
00083 report_string_ = "Error resuming ";
00084 report_string_.append(app_name + ".");
00085 }
00086
00087 return external_request_status_;
00088 }
00089
00090 bool artdaq::DataLoggerApp::do_shutdown(uint64_t)
00091 {
00092 report_string_ = "";
00093 external_request_status_ = DataLogger_ptr_->shutdown();
00094 if (!external_request_status_)
00095 {
00096 report_string_ = "Error shutting down ";
00097 report_string_.append(app_name + ".");
00098 }
00099
00100 return external_request_status_;
00101 }
00102
00103 bool artdaq::DataLoggerApp::do_soft_initialize(fhicl::ParameterSet const&, uint64_t, uint64_t)
00104 {
00105 return true;
00106 }
00107
00108 bool artdaq::DataLoggerApp::do_reinitialize(fhicl::ParameterSet const&, uint64_t, uint64_t)
00109 {
00110 return true;
00111 }
00112
00113 std::string artdaq::DataLoggerApp::report(std::string const& which) const
00114 {
00115 std::string resultString;
00116
00117
00118 if (which == "transition_status")
00119 {
00120 if (report_string_.length() > 0) { return report_string_; }
00121 else { return "Success"; }
00122 }
00123
00126
00127
00128
00129
00130
00131
00132
00133 if (DataLogger_ptr_.get() != 0)
00134 {
00135 resultString.append(DataLogger_ptr_->report(which));
00136 }
00137 else
00138 {
00139 resultString.append("This DataLogger has not yet been initialized and ");
00140 resultString.append("therefore can not provide reporting.");
00141 }
00142
00143 return resultString;
00144 }