67 #include "TRestRealTimeAddInputFileProcess.h"
77 thread* TRestRealTimeAddInputFileProcess::fMonitorThread =
nullptr;
78 int TRestRealTimeAddInputFileProcess::fMonitorFlag = 0;
80 TRestRealTimeAddInputFileProcess::TRestRealTimeAddInputFileProcess() { Initialize(); }
82 TRestRealTimeAddInputFileProcess::~TRestRealTimeAddInputFileProcess() {}
85 SetSectionName(this->ClassName());
93 fMessenger = GetMetadata<TRestMessenger>();
95 if (fMessenger ==
nullptr) {
96 RESTError <<
"messenger not found!" << RESTendl;
100 if (fMonitorThread ==
nullptr) {
101 fRunInfo->HangUpEndFile();
104 fMonitorThread =
new thread(&TRestRealTimeAddInputFileProcess::FileNotificationFunc,
this);
105 fMonitorThread->detach();
118 void TRestRealTimeAddInputFileProcess::FileNotificationFunc() {
119 while (fMonitorFlag == 1) {
120 string message = fMessenger->ConsumeMessage();
122 RESTEssential <<
"Recieveing message: " << message << RESTendl;
126 auto runid_filename =
Split(message,
"->");
127 if (runid_filename.size() == 2) {
128 int runid = atoi(runid_filename[0].c_str());
129 if (runid == fRunInfo->GetRunNumber()) {
130 string msgContent = runid_filename[1];
132 RESTEssential <<
"Adding file... " << RESTendl;
133 fRunInfo->AddInputFileExternal(msgContent);
134 }
else if (msgContent ==
"finish") {
135 fRunInfo->ReleaseEndFile();
137 RESTWarning <<
"illegal message!" << RESTendl;
142 fMessenger->SendMessage(message);
145 RESTWarning <<
"illegal message!" << RESTendl;
154 if (fMonitorThread !=
nullptr) {
158 delete fMonitorThread;
159 fMonitorThread =
nullptr;
virtual void InitFromConfigFile() override
To make settings from rml file. This method must be implemented in the derived class.
A base class for any REST event.
std::vector< std::string > Split(std::string in, std::string separator, bool allowBlankString=false, bool removeWhiteSpaces=false, int startPos=-1)
Split the input string according to the given separator. Returning a vector of fragments.