From 78a6896ae94e6b06605b0f3da81e5959f07d538a Mon Sep 17 00:00:00 2001 From: Erik Frojdh Date: Thu, 23 Jul 2020 11:07:42 +0200 Subject: [PATCH] replaced usleep with sleep_for --- slsDetectorSoftware/src/Detector.cpp | 4 +++- slsDetectorSoftware/src/Module.cpp | 4 +++- slsReceiverSoftware/src/Implementation.cpp | 9 ++++++--- slsSupportLib/src/ZmqSocket.cpp | 7 ++++--- 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/slsDetectorSoftware/src/Detector.cpp b/slsDetectorSoftware/src/Detector.cpp index 9f90e9ee8..d8c520911 100644 --- a/slsDetectorSoftware/src/Detector.cpp +++ b/slsDetectorSoftware/src/Detector.cpp @@ -10,6 +10,8 @@ #include "versionAPI.h" #include +#include +#include namespace sls { @@ -399,7 +401,7 @@ void Detector::setPowerChip(bool on, Positions pos) { if ((pos.empty() || pos[0] == -1) && on && pimpl->size() > 3) { for (int i = 0; i != pimpl->size(); ++i) { pimpl->Parallel(&Module::setPowerChip, {i}, on); - usleep(1000 * 1000); + std::this_thread::sleep_for(std::chrono::seconds(1)); } } else { pimpl->Parallel(&Module::setPowerChip, pos, on); diff --git a/slsDetectorSoftware/src/Module.cpp b/slsDetectorSoftware/src/Module.cpp index 326daf0c4..8501db0bf 100644 --- a/slsDetectorSoftware/src/Module.cpp +++ b/slsDetectorSoftware/src/Module.cpp @@ -15,6 +15,8 @@ #include #include #include +#include +#include #include #include #include @@ -3160,7 +3162,7 @@ void Module::programFPGAviaBlackfin(std::vector buffer) { const int ERASE_TIME = 65; int count = ERASE_TIME + 1; while (count > 0) { - usleep(1 * 1000 * 1000); + std::this_thread::sleep_for(std::chrono::seconds(1)); --count; printf( "%d%%\r", diff --git a/slsReceiverSoftware/src/Implementation.cpp b/slsReceiverSoftware/src/Implementation.cpp index 09eb56364..fde293d00 100644 --- a/slsReceiverSoftware/src/Implementation.cpp +++ b/slsReceiverSoftware/src/Implementation.cpp @@ -13,6 +13,8 @@ #include #include //strcpy #include +#include +#include #include #include // stat #include @@ -739,7 +741,7 @@ void Implementation::stopReceiver() { for (const auto &it : dataProcessor) if (it->IsRunning()) running = true; - usleep(5000); + std::this_thread::sleep_for(std::chrono::milliseconds(5)); } // create virtual file @@ -763,7 +765,7 @@ void Implementation::stopReceiver() { for (const auto &it : dataStreamer) if (it->IsRunning()) running = true; - usleep(5000); + std::this_thread::sleep_for(std::chrono::milliseconds(5)); } status = RUN_FINISHED; @@ -821,7 +823,8 @@ void Implementation::startReadout() { << "waiting for all packets, previousValue:" << previousValue << " totalPacketsReceived: " << totalPacketsReceived; - usleep(5 * 1000); /* TODO! Need to find optimal time **/ + /* TODO! Need to find optimal time **/ + std::this_thread::sleep_for(std::chrono::milliseconds(5)); previousValue = totalPacketsReceived; totalPacketsReceived = 0; for (const auto &it : listener) diff --git a/slsSupportLib/src/ZmqSocket.cpp b/slsSupportLib/src/ZmqSocket.cpp index 47c989e5f..d937b8462 100644 --- a/slsSupportLib/src/ZmqSocket.cpp +++ b/slsSupportLib/src/ZmqSocket.cpp @@ -3,7 +3,8 @@ #include #include #include -#include //usleep in some machines +#include +#include #include #include #include @@ -76,8 +77,8 @@ ZmqSocket::ZmqSocket(const uint32_t portnumber, const char *ethip) PrintError(); throw sls::ZmqSocketError("Could not bind socket"); } - // sleep for a few milliseconds to allow a slow-joiner - usleep(200 * 1000); + // sleep to allow a slow-joiner + std::this_thread::sleep_for(std::chrono::milliseconds(200)); }; int ZmqSocket::Connect() {