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