Skip to content

Commit

Permalink
Implemented methods for us4OEM diagnostic.
Browse files Browse the repository at this point in the history
- to check Us4OEM state
- to getFPGA temperature
  • Loading branch information
pjarosik committed Jan 12, 2022
1 parent 3a48688 commit 30a1b64
Show file tree
Hide file tree
Showing 9 changed files with 88 additions and 0 deletions.
33 changes: 33 additions & 0 deletions arrus/core/api/devices/us4r/Us4OEM.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,43 @@ class Us4OEM : public Device, public TriggerGenerator {

~Us4OEM() override = default;

/**
* Returns nominal sampling frequency on the us4OEM device.
*/
virtual double getSamplingFrequency() = 0;

/**
* Returns temperature measured by Us4OEM's FPGA [Celsius].
*/
virtual float getFPGATemperature() = 0;

/**
* Checks if the firmware version on the Us4OEM module is correct.
*
* @throws ::arrus::IllegalStateException when the incorrect version was detected.
*/
virtual void checkFirmwareVersion() = 0;

/**
* Checks if the us4OEM is in the correct state (as seen by host PC).
*
* Note: currently only the firmware version is checked (to verify if the us4OEM module
* memory space is still available for the us4OEM module).
*
* @throws arrus::IllegalStateException when the incorrect version was detected.
*/
virtual void checkState() = 0;

/**
* Returns firmware version installed on the us4OEM module.
*/
virtual uint32 getFirmwareVersion() = 0;

/**
* Returns Tx component firmware version installed on this us4OEM module.
*/
virtual uint32 getTxFirmwareVersion() = 0;

Us4OEM(Us4OEM const&) = delete;
Us4OEM(Us4OEM const&&) = delete;
void operator=(Us4OEM const&) = delete;
Expand Down
8 changes: 8 additions & 0 deletions arrus/core/api/devices/us4r/Us4R.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,14 @@ class Us4R : public DeviceWithComponents {
*/
virtual float getSamplingFrequency() const = 0;

/**
* Checks state of the Us4R device. Currently checks if each us4OEM module is in
* the correct state.
*
* @throws arrus::IllegalStateException when some inconsistent state was detected
*/
virtual void checkState() const = 0;

virtual void start() = 0;
virtual void stop() = 0;

Expand Down
6 changes: 6 additions & 0 deletions arrus/core/devices/us4r/Us4RImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -284,4 +284,10 @@ float Us4RImpl::getSamplingFrequency() const {
return us4oems[0]->getSamplingFrequency();
}

void Us4RImpl::checkState() const {
for(auto &us4oem: us4oems) {
us4oem->checkState();
}
}

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

private:
UltrasoundDevice *getDefaultComponent();
Expand Down
4 changes: 4 additions & 0 deletions arrus/core/devices/us4r/probeadapter/ProbeAdapterImplTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,10 @@ class MockUs4OEM : public Us4OEMImplBase {
MOCK_METHOD(Ius4OEMRawHandle, getIUs4oem, (), (override));
MOCK_METHOD(void, enableSequencer, (), (override));
MOCK_METHOD(std::vector<uint8_t>, getChannelMapping, (), (override));
MOCK_METHOD(void, checkFirmwareVersion, (), (override));
MOCK_METHOD(void, checkState, (), (override));
MOCK_METHOD(uint32, getFirmwareVersion, (), (override));
MOCK_METHOD(uint32, getTxFirmwareVersion, (), (override));
};

class AbstractProbeAdapterImplTest : public ::testing::Test {
Expand Down
1 change: 1 addition & 0 deletions arrus/core/devices/us4r/tests/MockIUs4OEM.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class MockIUs4OEM : public IUs4OEM {
MOCK_METHOD(unsigned int, GetID, (), (override));
MOCK_METHOD(uint32_t, GetFirmwareVersion, (), (override));
MOCK_METHOD(uint32_t, GetTxFirmwareVersion, (), (override));
MOCK_METHOD(void, CheckFirmwareVersion, (), (override));
MOCK_METHOD(bool, IsPowereddown, (), (override));
MOCK_METHOD(void, Initialize, (int), (override));
MOCK_METHOD(void, Synchronize, (), (override));
Expand Down
22 changes: 22 additions & 0 deletions arrus/core/devices/us4r/us4oem/Us4OEMImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -643,4 +643,26 @@ float Us4OEMImpl::getFPGATemperature() {
return ius4oem->GetFPGATemp();
}

void Us4OEMImpl::checkFirmwareVersion() {
try {
ius4oem->CheckFirmwareVersion();
} catch(const std::runtime_error &e) {
throw arrus::IllegalStateException(e.what());
} catch(...) {
throw arrus::IllegalStateException("Unknown exception while check firmware version.");
}
}

uint32 Us4OEMImpl::getFirmwareVersion() {
return ius4oem->GetFirmwareVersion();
}

uint32 Us4OEMImpl::getTxFirmwareVersion() {
return ius4oem->GetTxFirmwareVersion();
}

void Us4OEMImpl::checkState() {
this->checkFirmwareVersion();
}

}
4 changes: 4 additions & 0 deletions arrus/core/devices/us4r/us4oem/Us4OEMImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,10 @@ class Us4OEMImpl : public Us4OEMImplBase {
std::vector<uint8_t> getChannelMapping() override;
void setRxSettings(const RxSettings &newSettings) override;
float getFPGATemperature() override;
void checkFirmwareVersion() override;
uint32 getFirmwareVersion() override;
void checkState() override;
uint32 getTxFirmwareVersion() override;

private:
using Us4OEMBitMask = std::bitset<Us4OEMImpl::N_ADDR_CHANNELS>;
Expand Down
9 changes: 9 additions & 0 deletions docs/content/misc/release_notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,15 @@ Release notes
-----


0.6.6
.....

- core (C++):
- implemented Us4R::checkState and Us4OEM::checkState methods to verify if the us4OEM module is still available (currently by checking us4OEM module firmware version)
- implemented Us4OEM::getFirmwareVersion and Us4OEM::getTxFirmwareVersion() to get us4OEM device firmware version
- implemented Us4OEM::getFPGATemperature() to get the temperature measured by Us4OEM's FPGA


0.6.5
.....

Expand Down

0 comments on commit 30a1b64

Please sign in to comment.