From 012f1418064fc87fb232dc6aa709a1f38001db57 Mon Sep 17 00:00:00 2001 From: Piotr Jarosik Date: Sat, 9 Oct 2021 21:53:38 +0200 Subject: [PATCH] ref-US4R-40: Removed TBB dependency, added FPGATemperature getter, fixed jenkins file. (#236) --- CMakeLists.txt | 3 +- Jenkinsfile | 5 ++- arrus/core/api/devices/us4r/Us4OEM.h | 2 ++ arrus/core/api/devices/us4r/Us4R.h | 2 ++ arrus/core/devices/us4r/Us4RImpl.cpp | 4 +++ arrus/core/devices/us4r/Us4RImpl.h | 1 + .../external/ius4oem/IUs4OEMInitializerImpl.h | 33 ++++++------------- .../ius4oem/IUs4OEMInitializerImplTest.cpp | 27 +++++++-------- .../probeadapter/ProbeAdapterImplTest.cpp | 1 + arrus/core/devices/us4r/us4oem/Us4OEMImpl.cpp | 4 ++- arrus/core/devices/us4r/us4oem/Us4OEMImpl.h | 1 + 11 files changed, 41 insertions(+), 42 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c0e71b1ff..4a3f1dc67 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -101,8 +101,7 @@ find_package(Eigen3 REQUIRED) if("${ARRUS_BUILD_PLATFORM}" STREQUAL "windows") set(ARRUS_OS_DEPS "") else("${ARRUS_BUILD_PLATFORM}" STREQUAL "linux") - find_package(TBB REQUIRED) - set(ARRUS_OS_DEPS tbb) + set(ARRUS_OS_DEPS "") endif() ################################################################################ # Sub-projects diff --git a/Jenkinsfile b/Jenkinsfile index 0973d104f..9805c6860 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -135,12 +135,11 @@ def getBranchName() { } def isDevelopOnOff() { - return "ON"; - // return env.BRANCH_NAME == "develop" ? "ON" : "OFF"; + return env.BRANCH_NAME == "develop" ? "ON" : "OFF"; } def getBuildName(build) { wrap([$class: 'BuildUser']) { return "#${build.id} (${env.BUILD_USER_ID})"; } -} \ No newline at end of file +} diff --git a/arrus/core/api/devices/us4r/Us4OEM.h b/arrus/core/api/devices/us4r/Us4OEM.h index 66df7a319..2120a6498 100644 --- a/arrus/core/api/devices/us4r/Us4OEM.h +++ b/arrus/core/api/devices/us4r/Us4OEM.h @@ -17,6 +17,8 @@ class Us4OEM : public Device, public TriggerGenerator { virtual double getSamplingFrequency() = 0; + virtual float getFPGATemperature() = 0; + Us4OEM(Us4OEM const&) = delete; Us4OEM(Us4OEM const&&) = delete; void operator=(Us4OEM const&) = delete; diff --git a/arrus/core/api/devices/us4r/Us4R.h b/arrus/core/api/devices/us4r/Us4R.h index 869133638..8f6546863 100644 --- a/arrus/core/api/devices/us4r/Us4R.h +++ b/arrus/core/api/devices/us4r/Us4R.h @@ -138,6 +138,8 @@ class Us4R : public DeviceWithComponents { virtual void start() = 0; virtual void stop() = 0; + virtual uint8_t getNumberOfUs4OEMs() = 0; + Us4R(Us4R const&) = delete; Us4R(Us4R const&&) = delete; void operator=(Us4R const&) = delete; diff --git a/arrus/core/devices/us4r/Us4RImpl.cpp b/arrus/core/devices/us4r/Us4RImpl.cpp index f5035ebc2..89a320796 100644 --- a/arrus/core/devices/us4r/Us4RImpl.cpp +++ b/arrus/core/devices/us4r/Us4RImpl.cpp @@ -270,4 +270,8 @@ void Us4RImpl::setActiveTermination(std::optional value) { setRxSettings(newRxSettings); } +uint8_t Us4RImpl::getNumberOfUs4OEMs() { + return us4oems.size(); +} + } \ No newline at end of file diff --git a/arrus/core/devices/us4r/Us4RImpl.h b/arrus/core/devices/us4r/Us4RImpl.h index ea815b16d..48ff74599 100644 --- a/arrus/core/devices/us4r/Us4RImpl.h +++ b/arrus/core/devices/us4r/Us4RImpl.h @@ -120,6 +120,7 @@ class Us4RImpl : public Us4R { void setLpfCutoff(uint32 value) override; void setDtgcAttenuation(std::optional value) override; void setActiveTermination(std::optional value) override; + uint8_t getNumberOfUs4OEMs() override; private: UltrasoundDevice *getDefaultComponent(); diff --git a/arrus/core/devices/us4r/external/ius4oem/IUs4OEMInitializerImpl.h b/arrus/core/devices/us4r/external/ius4oem/IUs4OEMInitializerImpl.h index 65df8095b..44e9dc3ac 100644 --- a/arrus/core/devices/us4r/external/ius4oem/IUs4OEMInitializerImpl.h +++ b/arrus/core/devices/us4r/external/ius4oem/IUs4OEMInitializerImpl.h @@ -2,9 +2,9 @@ #define ARRUS_CORE_DEVICES_US4R_EXTERNAL_IUS4OEM_IUS4OEMINITIALIZERIMPL_H #include -#include #include #include +#include #include "IUs4OEMInitializer.h" @@ -32,30 +32,17 @@ class IUs4OEMInitializerImpl : public IUs4OEMInitializer { // Us4OEMs are initialized here. } private: + void initializeUs4oems(std::vector &ius4oems, int level) { - std::vector exceptions; - std::mutex exceptions_mutex; + std::vector> results; - std::for_each( - std::execution::par_unseq, std::begin(ius4oems), std::end(ius4oems), - [&](IUs4OEMHandle &u) { - try { - u->Initialize(level); - } - catch(const std::exception &e) { - std::lock_guard guard(exceptions_mutex); - exceptions.push_back(e); - } - catch(...) { - std::lock_guard guard(exceptions_mutex); - exceptions.push_back(std::runtime_error("Unknown exception during Us4OEM initialization.")); - } - } - ); - if(!exceptions.empty()) { - // TODO create a complete list of error messages - // now throw any of the exception - throw exceptions.front(); + for(IUs4OEMHandle &ius4oem : ius4oems) { + std::future result = std::async(std::launch::async, [&ius4oem, level]() {ius4oem->Initialize(level);}); + results.push_back(std::move(result)); + } + for(auto &result: results) { + result.wait(); + result.get(); // wait and throw exception if necessary. } } }; diff --git a/arrus/core/devices/us4r/external/ius4oem/IUs4OEMInitializerImplTest.cpp b/arrus/core/devices/us4r/external/ius4oem/IUs4OEMInitializerImplTest.cpp index 3cbf9e34a..01e044334 100644 --- a/arrus/core/devices/us4r/external/ius4oem/IUs4OEMInitializerImplTest.cpp +++ b/arrus/core/devices/us4r/external/ius4oem/IUs4OEMInitializerImplTest.cpp @@ -10,6 +10,7 @@ namespace { using namespace arrus::devices; using ::testing::Return; using ::testing::InSequence; +using ::testing::Sequence; // Test if the input array is approprietaly sorted TEST(IUs4OEMInitializerImplTest, Us4OEMsSortedApproprietaly) { @@ -45,24 +46,24 @@ TEST(IUs4OEMInitializerImplTest, Us4OEMsInitializedProperly) { ON_CALL(GET_MOCK_PTR(ius4oems[1]), GetID) .WillByDefault(Return(0)); - // The actual order: 1, 0 { - InSequence seq; + Sequence us4oem0Seq; + Sequence us4oem1Seq; - EXPECT_CALL(GET_MOCK_PTR(ius4oems[1]), Initialize(1)); - EXPECT_CALL(GET_MOCK_PTR(ius4oems[0]), Initialize(1)); + EXPECT_CALL(GET_MOCK_PTR(ius4oems[1]), Initialize(1)).InSequence(us4oem1Seq); + EXPECT_CALL(GET_MOCK_PTR(ius4oems[0]), Initialize(1)).InSequence(us4oem0Seq); - EXPECT_CALL(GET_MOCK_PTR(ius4oems[1]), Synchronize()); - EXPECT_CALL(GET_MOCK_PTR(ius4oems[1]), Initialize(2)); - EXPECT_CALL(GET_MOCK_PTR(ius4oems[0]), Initialize(2)); + EXPECT_CALL(GET_MOCK_PTR(ius4oems[1]), Synchronize()).InSequence(us4oem1Seq, us4oem0Seq); + EXPECT_CALL(GET_MOCK_PTR(ius4oems[1]), Initialize(2)).InSequence(us4oem1Seq); + EXPECT_CALL(GET_MOCK_PTR(ius4oems[0]), Initialize(2)).InSequence(us4oem0Seq); - EXPECT_CALL(GET_MOCK_PTR(ius4oems[1]), Synchronize()); - EXPECT_CALL(GET_MOCK_PTR(ius4oems[1]), Initialize(3)); - EXPECT_CALL(GET_MOCK_PTR(ius4oems[0]), Initialize(3)); + EXPECT_CALL(GET_MOCK_PTR(ius4oems[1]), Synchronize()).InSequence(us4oem1Seq, us4oem0Seq); + EXPECT_CALL(GET_MOCK_PTR(ius4oems[1]), Initialize(3)).InSequence(us4oem1Seq); + EXPECT_CALL(GET_MOCK_PTR(ius4oems[0]), Initialize(3)).InSequence(us4oem0Seq); - EXPECT_CALL(GET_MOCK_PTR(ius4oems[1]), Synchronize()); - EXPECT_CALL(GET_MOCK_PTR(ius4oems[1]), Initialize(4)); - EXPECT_CALL(GET_MOCK_PTR(ius4oems[0]), Initialize(4)); + EXPECT_CALL(GET_MOCK_PTR(ius4oems[1]), Synchronize()).InSequence(us4oem1Seq, us4oem0Seq); + EXPECT_CALL(GET_MOCK_PTR(ius4oems[1]), Initialize(4)).InSequence(us4oem1Seq); + EXPECT_CALL(GET_MOCK_PTR(ius4oems[0]), Initialize(4)).InSequence(us4oem0Seq); } IUs4OEMInitializerImpl initializer; diff --git a/arrus/core/devices/us4r/probeadapter/ProbeAdapterImplTest.cpp b/arrus/core/devices/us4r/probeadapter/ProbeAdapterImplTest.cpp index e7f94d599..83fcfcdb0 100644 --- a/arrus/core/devices/us4r/probeadapter/ProbeAdapterImplTest.cpp +++ b/arrus/core/devices/us4r/probeadapter/ProbeAdapterImplTest.cpp @@ -104,6 +104,7 @@ class MockUs4OEM : public Us4OEMImplBase { MOCK_METHOD(Ius4OEMRawHandle, getIUs4oem, (), (override)); MOCK_METHOD(void, enableSequencer, (), (override)); MOCK_METHOD(std::vector, getChannelMapping, (), (override)); + MOCK_METHOD(float, getFPGATemperature, (), (override)); }; class AbstractProbeAdapterImplTest : public ::testing::Test { diff --git a/arrus/core/devices/us4r/us4oem/Us4OEMImpl.cpp b/arrus/core/devices/us4r/us4oem/Us4OEMImpl.cpp index c8e364889..e12ecc4ad 100644 --- a/arrus/core/devices/us4r/us4oem/Us4OEMImpl.cpp +++ b/arrus/core/devices/us4r/us4oem/Us4OEMImpl.cpp @@ -639,6 +639,8 @@ inline void Us4OEMImpl::setActiveTerminationAfe(std::optional param, boo } } - +float Us4OEMImpl::getFPGATemperature() { + return ius4oem->GetFPGATemp(); +} } diff --git a/arrus/core/devices/us4r/us4oem/Us4OEMImpl.h b/arrus/core/devices/us4r/us4oem/Us4OEMImpl.h index 1aed34bfa..39eadfd56 100644 --- a/arrus/core/devices/us4r/us4oem/Us4OEMImpl.h +++ b/arrus/core/devices/us4r/us4oem/Us4OEMImpl.h @@ -117,6 +117,7 @@ class Us4OEMImpl : public Us4OEMImplBase { std::vector getChannelMapping() override; void setRxSettings(const RxSettings &newSettings) override; + float getFPGATemperature() override; private: using Us4OEMBitMask = std::bitset;