Skip to content

Commit

Permalink
ref-US4R-40: Removed TBB dependency, added FPGATemperature getter, fi…
Browse files Browse the repository at this point in the history
…xed jenkins file. (#236)
  • Loading branch information
pjarosik authored Oct 9, 2021
1 parent 52bb50e commit 012f141
Show file tree
Hide file tree
Showing 11 changed files with 41 additions and 42 deletions.
3 changes: 1 addition & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 2 additions & 3 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -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})";
}
}
}
2 changes: 2 additions & 0 deletions arrus/core/api/devices/us4r/Us4OEM.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions arrus/core/api/devices/us4r/Us4R.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 4 additions & 0 deletions arrus/core/devices/us4r/Us4RImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -270,4 +270,8 @@ void Us4RImpl::setActiveTermination(std::optional<uint16> value) {
setRxSettings(newRxSettings);
}

uint8_t Us4RImpl::getNumberOfUs4OEMs() {
return us4oems.size();
}

}
1 change: 1 addition & 0 deletions arrus/core/devices/us4r/Us4RImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ class Us4RImpl : public Us4R {
void setLpfCutoff(uint32 value) override;
void setDtgcAttenuation(std::optional<uint16> value) override;
void setActiveTermination(std::optional<uint16> value) override;
uint8_t getNumberOfUs4OEMs() override;

private:
UltrasoundDevice *getDefaultComponent();
Expand Down
33 changes: 10 additions & 23 deletions arrus/core/devices/us4r/external/ius4oem/IUs4OEMInitializerImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
#define ARRUS_CORE_DEVICES_US4R_EXTERNAL_IUS4OEM_IUS4OEMINITIALIZERIMPL_H

#include <algorithm>
#include <execution>
#include <mutex>
#include <iostream>
#include <future>

#include "IUs4OEMInitializer.h"

Expand Down Expand Up @@ -32,30 +32,17 @@ class IUs4OEMInitializerImpl : public IUs4OEMInitializer {
// Us4OEMs are initialized here.
}
private:

void initializeUs4oems(std::vector<IUs4OEMHandle> &ius4oems, int level) {
std::vector<std::exception> exceptions;
std::mutex exceptions_mutex;
std::vector<std::future<void>> 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<void> 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.
}
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ class MockUs4OEM : public Us4OEMImplBase {
MOCK_METHOD(Ius4OEMRawHandle, getIUs4oem, (), (override));
MOCK_METHOD(void, enableSequencer, (), (override));
MOCK_METHOD(std::vector<uint8_t>, getChannelMapping, (), (override));
MOCK_METHOD(float, getFPGATemperature, (), (override));
};

class AbstractProbeAdapterImplTest : public ::testing::Test {
Expand Down
4 changes: 3 additions & 1 deletion arrus/core/devices/us4r/us4oem/Us4OEMImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -639,6 +639,8 @@ inline void Us4OEMImpl::setActiveTerminationAfe(std::optional<uint16> param, boo
}
}


float Us4OEMImpl::getFPGATemperature() {
return ius4oem->GetFPGATemp();
}

}
1 change: 1 addition & 0 deletions arrus/core/devices/us4r/us4oem/Us4OEMImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ class Us4OEMImpl : public Us4OEMImplBase {

std::vector<uint8_t> getChannelMapping() override;
void setRxSettings(const RxSettings &newSettings) override;
float getFPGATemperature() override;

private:
using Us4OEMBitMask = std::bitset<Us4OEMImpl::N_ADDR_CHANNELS>;
Expand Down

0 comments on commit 012f141

Please sign in to comment.