$treeview $search $mathjax $extrastylesheet
otsdaq
v2_03_00
$projectbrief
|
$projectbrief
|
$searchbox |
00001 #include "otsdaq-core/GatewaySupervisor/ARTDAQCommandable.h" 00002 #include "artdaq/ExternalComms/MakeCommanderPlugin.hh" 00003 #include "otsdaq-core/GatewaySupervisor/GatewaySupervisor.h" 00004 00005 ots::ARTDAQCommandable::ARTDAQCommandable(GatewaySupervisor* super) 00006 : artdaq::Commandable(), theSupervisor_(super), theCommander_(nullptr) 00007 { 00008 } 00009 00010 ots::ARTDAQCommandable::~ARTDAQCommandable() 00011 { 00012 if(theCommander_ != nullptr) 00013 { 00014 theCommander_->send_shutdown(0); 00015 if(commanderThread_.joinable()) 00016 commanderThread_.join(); 00017 } 00018 } 00019 00020 void ots::ARTDAQCommandable::init(int commanderId, std::string commanderType) 00021 { 00022 fhicl::ParameterSet ps; 00023 ps.put<int>("id", commanderId); 00024 ps.put<std::string>("commanderPluginType", commanderType); 00025 00026 theCommander_ = artdaq::MakeCommanderPlugin(ps, *this); 00027 boost::thread::attributes attrs; 00028 attrs.set_stack_size(4096 * 2000); // 8 MB 00029 commanderThread_ = boost::thread( 00030 attrs, boost::bind(&artdaq::CommanderInterface::run_server, theCommander_.get())); 00031 } 00032 00033 bool ots::ARTDAQCommandable::do_initialize(fhicl::ParameterSet const& ps, 00034 uint64_t, 00035 uint64_t) 00036 { 00037 std::vector<std::string> parameters; 00038 parameters.push_back(ps.get<std::string>("config_name")); 00039 00040 auto ret = theSupervisor_->attemptStateMachineTransition( 00041 nullptr, 00042 nullptr, 00043 "Initialize", 00044 theSupervisor_->activeStateMachineName_, 00045 theSupervisor_->activeStateMachineWindowName_, 00046 "ARTDAQCommandable", 00047 parameters); 00048 if(ret == "") 00049 ret = theSupervisor_->attemptStateMachineTransition( 00050 nullptr, 00051 nullptr, 00052 "Configure", 00053 theSupervisor_->activeStateMachineName_, 00054 theSupervisor_->activeStateMachineWindowName_, 00055 "ARTDAQCommandable", 00056 parameters); 00057 report_string_ = ret; 00058 return ret == ""; 00059 } 00060 00061 bool ots::ARTDAQCommandable::do_start(art::RunID, uint64_t, uint64_t) 00062 { 00063 std::vector<std::string> parameters; 00064 auto ret = theSupervisor_->attemptStateMachineTransition( 00065 nullptr, 00066 nullptr, 00067 "Start", 00068 theSupervisor_->activeStateMachineName_, 00069 theSupervisor_->activeStateMachineWindowName_, 00070 "ARTDAQCommandable", 00071 parameters); 00072 report_string_ = ret; 00073 return ret == ""; 00074 } 00075 00076 bool ots::ARTDAQCommandable::do_stop(uint64_t, uint64_t) 00077 { 00078 std::vector<std::string> parameters; 00079 auto ret = theSupervisor_->attemptStateMachineTransition( 00080 nullptr, 00081 nullptr, 00082 "Stop", 00083 theSupervisor_->activeStateMachineName_, 00084 theSupervisor_->activeStateMachineWindowName_, 00085 "ARTDAQCommandable", 00086 parameters); 00087 report_string_ = ret; 00088 return ret == ""; 00089 } 00090 00091 bool ots::ARTDAQCommandable::do_pause(uint64_t, uint64_t) 00092 { 00093 std::vector<std::string> parameters; 00094 auto ret = theSupervisor_->attemptStateMachineTransition( 00095 nullptr, 00096 nullptr, 00097 "Pause", 00098 theSupervisor_->activeStateMachineName_, 00099 theSupervisor_->activeStateMachineWindowName_, 00100 "ARTDAQCommandable", 00101 parameters); 00102 report_string_ = ret; 00103 return ret == ""; 00104 } 00105 00106 bool ots::ARTDAQCommandable::do_resume(uint64_t, uint64_t) 00107 { 00108 std::vector<std::string> parameters; 00109 auto ret = theSupervisor_->attemptStateMachineTransition( 00110 nullptr, 00111 nullptr, 00112 "Resume", 00113 theSupervisor_->activeStateMachineName_, 00114 theSupervisor_->activeStateMachineWindowName_, 00115 "ARTDAQCommandable", 00116 parameters); 00117 report_string_ = ret; 00118 return ret == ""; 00119 } 00120 00121 bool ots::ARTDAQCommandable::do_shutdown(uint64_t) 00122 { 00123 std::vector<std::string> parameters; 00124 auto ret = theSupervisor_->attemptStateMachineTransition( 00125 nullptr, 00126 nullptr, 00127 "Halt", 00128 theSupervisor_->activeStateMachineName_, 00129 theSupervisor_->activeStateMachineWindowName_, 00130 "ARTDAQCommandable", 00131 parameters); 00132 if(ret == "") 00133 ret = theSupervisor_->attemptStateMachineTransition( 00134 nullptr, 00135 nullptr, 00136 "Shutdown", 00137 theSupervisor_->activeStateMachineName_, 00138 theSupervisor_->activeStateMachineWindowName_, 00139 "ARTDAQCommandable", 00140 parameters); 00141 report_string_ = ret; 00142 return ret == ""; 00143 } 00144 00145 bool ots::ARTDAQCommandable::do_meta_command(std::string const& command, 00146 std::string const& args) 00147 { 00148 std::vector<std::string> parameters; 00149 parameters.push_back(args); 00150 auto ret = theSupervisor_->attemptStateMachineTransition( 00151 nullptr, 00152 nullptr, 00153 command, 00154 theSupervisor_->activeStateMachineName_, 00155 theSupervisor_->activeStateMachineWindowName_, 00156 "ARTDAQCommandable", 00157 parameters); 00158 report_string_ = ret; 00159 return ret == ""; 00160 }