Skip to content

Commit

Permalink
ecs: start all configuration in initTask
Browse files Browse the repository at this point in the history
  • Loading branch information
ironMann committed Mar 31, 2021
1 parent c75456f commit 6983dc9
Show file tree
Hide file tree
Showing 7 changed files with 159 additions and 131 deletions.
19 changes: 7 additions & 12 deletions src/StfBuilder/StfBuilderDevice.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@ void StfBuilderDevice::InitTask()
std::this_thread::sleep_for(1s); exit(-1);
}

I().mRunning = true;

// make sure we have detector if not using files
if (!I().mFileSource->enabled()) {
if ((ReadoutDataUtils::sRdhVersion < ReadoutDataUtils::RdhVersion::eRdhVer6) &&
Expand Down Expand Up @@ -223,7 +225,7 @@ void StfBuilderDevice::InitTask()
// info thread
I().mInfoThread = create_thread_member("stfb_info", &StfBuilderDevice::InfoThread, this);

IDDLOG("PreRun() done... ");
IDDLOG("InitTask() done... ");
}

void StfBuilderDevice::ResetTask()
Expand Down Expand Up @@ -268,9 +270,6 @@ void StfBuilderDevice::ResetTask()

void StfBuilderDevice::StfOutputThread()
{
// wait for the device to go into RUNNING state
WaitForRunningState();

std::unique_ptr<InterleavedHdrDataSerializer> lStfSerializer;
std::unique_ptr<StfToDplAdapter> lStfDplAdapter;

Expand All @@ -286,13 +285,14 @@ void StfBuilderDevice::StfOutputThread()
}
}

while (IsReadyOrRunningState()) {
while (I().mRunning) {
using hres_clock = std::chrono::high_resolution_clock;

// Get a STF ready for sending
std::unique_ptr<SubTimeFrame> lStf = dequeue(eStfSendIn);
if (!lStf)
if (!lStf) {
break;
}

// decrement the stf counter
I().mNumStfs--;
Expand Down Expand Up @@ -382,10 +382,7 @@ void StfBuilderDevice::StfOutputThread()

void StfBuilderDevice::InfoThread()
{
// wait for the device to go into RUNNING state
WaitForRunningState();

while (IsReadyOrRunningState()) {
while (I().mRunning) {

std::this_thread::sleep_for(2s);

Expand Down Expand Up @@ -450,8 +447,6 @@ bpo::options_description StfBuilderDevice::getStfBuildingProgramOptions() {
return lStfBuildingOptions;
}



o2::header::DataOrigin StfBuilderDevice::getDataOriginFromOption(const std::string pArg)
{
const auto lDetStr = boost::to_upper_copy<std::string>(pArg);
Expand Down
6 changes: 5 additions & 1 deletion src/StfBuilder/StfBuilderDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,17 @@ class StfBuilderDevice : public DataDistDevice,
IDDLOG("Restarting file source.");
}
I().mRestartRateCounter = true;

IDDLOG("Entering running state. RunNumber: {}", DataDistLogger::sRunNumberStr);
}
virtual void PostRun() override final {
I().mPaused = true;
if (I().mFileSource) {
I().mFileSource->pause();
IDDLOG("Pausing file source.");
}

IDDLOG("Exiting running state. RunNumber: {}", DataDistLogger::sRunNumberStr);
}

bool tryPopOldestStfs()
Expand Down Expand Up @@ -207,7 +211,7 @@ class StfBuilderDevice : public DataDistDevice,

/// Internal threads
std::thread mOutputThread;
std::atomic_bool mRunning = true;
std::atomic_bool mRunning = false;
std::atomic_bool mPaused = false;

/// File sink
Expand Down
Loading

0 comments on commit 6983dc9

Please sign in to comment.