tdaq-develop-2025-02-12
ARTDAQProducerImpl.cc
1 
2 // #include "artdaq/Application/Commandable.hh"
3 // #include "fhiclcpp/make_ParameterSet.h"
4 // #include "otsdaq/DataManager/DataManager.h"
5 // #include "otsdaq/DataManager/DataManagerSingleton.h"
6 #include "otsdaq/DataProcessorPlugins/ARTDAQProducer.h"
7 // #include "otsdaq/Macros/CoutMacros.h"
8 // #include "otsdaq/MessageFacility/MessageFacility.h"
9 //
10 // #include <cstdint>
11 // #include <fstream>
12 // #include <iostream>
13 // #include <set>
14 
15 using namespace ots;
20 //==============================================================================
21 ARTDAQProducer::ARTDAQProducer(std::string supervisorApplicationUID,
22  std::string bufferUID,
23  std::string processorUID,
24  const ConfigurationTree& theXDAQContextConfigTree,
25  const std::string& configurationPath)
26  : WorkLoop(processorUID)
27  , DataProducer(supervisorApplicationUID, bufferUID, processorUID)
28  , ARTDAQReaderProcessorBase(supervisorApplicationUID,
29  bufferUID,
30  processorUID,
31  theXDAQContextConfigTree,
32  configurationPath)
39 {
40  // Tell me why this printout does not happen
41  __COUT__ << "ARTDAQ Producer constructed." << __E__;
42  // //__COUT__ << "Configuration string:-" <<
43  // //
44  // theXDAQContextConfigTree.getNode(configurationPath).getNode("ConfigurationString").getValue<std::string>()
45  // //<< "-" << __E__;
46  //
47  // std::string filename = ARTDAQ_FCL_PATH + ARTDAQ_FILE_PREAMBLE + "-";
48  // std::string uid =
49  // theXDAQContextConfigTree.getNode(configurationPath).getValue();
50  //
51  // __COUT__ << "uid: " << uid << __E__;
52  // for(unsigned int i = 0; i < uid.size(); ++i)
53  // if((uid[i] >= 'a' && uid[i] <= 'z') || (uid[i] >= 'A' && uid[i] <= 'Z') ||
54  // (uid[i] >= '0' && uid[i] <= '9')) // only allow alpha numeric in file name
55  // filename += uid[i];
56  // filename += ".fcl";
57  //
58  // __COUT__ << __E__;
59  // __COUT__ << __E__;
60  // __COUT__ << "filename: " << filename << __E__;
61  //
62  // std::string fileFclString;
63  // {
64  // std::ifstream in(filename, std::ios::in | std::ios::binary);
65  // if(in)
66  // {
67  // std::string contents;
68  // in.seekg(0, std::ios::end);
69  // fileFclString.resize(in.tellg());
70  // in.seekg(0, std::ios::beg);
71  // in.read(&fileFclString[0], fileFclString.size());
72  // in.close();
73  // }
74  // }
75  // //__COUT__ << fileFclString << __E__;
76  //
77  // // find fragment_receiver {
78  // // and insert e.g.,
79  // // SupervisorApplicationUID:"ARTDataManager0"
80  // // BufferUID:"ART_S0_DM0_DataBuffer0"
81  // // ProcessorUID:"ART_S0_DM0_DB0_ARTConsumer0"
82  // size_t fcli =
83  // fileFclString.find("fragment_receiver: {") + +strlen("fragment_receiver: {");
84  // if(fcli == std::string::npos)
85  // {
86  // __SS__ << "Could not find 'fragment_receiver: {' in Board Reader fcl string!"
87  // << __E__;
88  // __COUT__ << "\n" << ss.str();
89  // __SS_THROW__;
90  // }
91  //
92  // // get the parent IDs from configurationPath
93  // __COUT__ << "configurationPath " << configurationPath << __E__;
94  //
95  // std::string consumerID, bufferID, appID;
96  // unsigned int backSteps; // at 2, 4, and 7 are the important parent IDs
97  // size_t backi = -1, backj;
98  // backSteps = 7;
99  // for(unsigned int i = 0; i < backSteps; i++)
100  // {
101  // //__COUT__ << "backsteps: " << i+1 << __E__;
102  //
103  // backj = backi;
104  // backi = configurationPath.rfind('/', backi - 1);
105  //
106  // //__COUT__ << "backi:" << backi << " backj:" << backj << __E__;
107  // //__COUT__ << "substr: " << configurationPath.substr(backi+1,backj-backi-1) <<
108  // // __E__;
109  //
110  // if(i + 1 == 2)
111  // consumerID = configurationPath.substr(backi + 1, backj - backi - 1);
112  // else if(i + 1 == 4)
113  // bufferID = configurationPath.substr(backi + 1, backj - backi - 1);
114  // else if(i + 1 == 7)
115  // appID = configurationPath.substr(backi + 1, backj - backi - 1);
116  // }
117  //
118  // // insert parent IDs into fcl string
119  // fileFclString = fileFclString.substr(0, fcli) + "\n\t\t" +
120  // "SupervisorApplicationUID: \"" + appID + "\"\n\t\t" +
121  // "BufferUID: \"" + bufferID + "\"\n\t\t" + "ProcessorUID: \"" +
122  // consumerID + "\"\n" + fileFclString.substr(fcli);
123  //
124  // __COUT__ << fileFclString << __E__;
125  //
126  // fhicl::make_ParameterSet(fileFclString, fhiclConfiguration_);
127  //
128  // //
129  // fhicl::make_ParameterSet(theXDAQContextConfigTree.getNode(configurationPath).getNode("ConfigurationString").getValue<std::string>(),
130  // // fhiclConfiguration_);
131 }
132 
133 //==============================================================================
137 //{}
138 
139 //==============================================================================
141 {
142  halt();
143  __COUT__ << "Destructor." << __E__;
144 }
148 //{
149 // name_ = "BoardReader_" + DataProducer::processorUID_;
150 // configure(rank);
151 //}
152 //
153 // #define ARTDAQ_FCL_PATH std::string(__ENV__("USER_DATA")) + "/" +
158 //{
159 // __COUT__ << "\tConfigure" << __E__;
160 //
161 // report_string_ = "";
162 // external_request_status_ = true;
163 //
164 // // in the following block, we first destroy the existing BoardReader
165 // // instance, then create a new one. Doing it in one step does not
166 // // produce the desired result since that creates a new instance and
167 // // then deletes the old one, and we need the opposite order.
168 // fragment_receiver_ptr_.reset(nullptr);
169 // __COUT__ << "\tNew core" << __E__;
170 // my_rank = rank;
171 // app_name = name_;
172 // fragment_receiver_ptr_.reset(new artdaq::BoardReaderApp());
173 // // FIXME These are passed as parameters
174 // uint64_t timeout = 45;
175 // // uint64_t timestamp = 184467440737095516;
176 // uint64_t timestamp = 184467440737095516;
177 // __COUT__ << "\tInitialize: "
178 // << __E__; //<< fhiclConfiguration_.to_string() << __E__;
179 // external_request_status_ =
180 // fragment_receiver_ptr_->initialize(fhiclConfiguration_, timeout, timestamp);
181 // __COUT__ << "\tDone Initialize" << __E__;
182 // if(!external_request_status_)
183 // {
184 // report_string_ = "Error initializing ";
185 // report_string_.append(name_ + " ");
186 // report_string_.append("with ParameterSet = \"" + fhiclConfiguration_.to_string() +
187 // "\".");
188 // }
189 // __COUT__ << "\tDone Configure" << __E__;
190 //}
191 //
194 //{
195 // __COUT__ << "\tHalt" << __E__;
196 // // FIXME These are passed as parameters
197 // uint64_t timeout = 45;
198 // // uint64_t timestamp = 184467440737095516;
199 // report_string_ = "";
200 // external_request_status_ = fragment_receiver_ptr_->shutdown(timeout);
201 // if(!external_request_status_)
202 // {
203 // report_string_ = "Error shutting down ";
204 // report_string_.append(name_ + ".");
205 // }
206 //}
207 //
208 //==============================================================================
209 void ARTDAQProducer::pauseProcessingData(void) { ARTDAQReaderProcessorBase::pause(); }
223 //==============================================================================
224 void ARTDAQProducer::resumeProcessingData(void) { ARTDAQReaderProcessorBase::resume(); }
238 //==============================================================================
239 void ARTDAQProducer::startProcessingData(std::string runNumber)
240 {
241  ARTDAQReaderProcessorBase::start(runNumber);
242 }
269 //==============================================================================
270 void ARTDAQProducer::stopProcessingData(void) { ARTDAQReaderProcessorBase::stop(); }
289 //
void startProcessingData(std::string runNumber) override
virtual ~ARTDAQProducer(void)
ARTDAQProducer(std::string supervisorApplicationUID, std::string bufferUID, std::string processorUID, const ConfigurationTree &theXDAQContextConfigTree, const std::string &configurationPath)
void stopProcessingData(void) override
void pauseProcessingData(void) override
void resumeProcessingData(void) override