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