From faf049f607dfbcbbc8ab389081d0f03ef9f7b869 Mon Sep 17 00:00:00 2001 From: Piotr Jarosik Date: Sat, 9 Apr 2022 16:08:26 +0200 Subject: [PATCH] Exposed us4OEM main firmware and tx firmware version. --- api/python/arrus/devices/us4oem.py | 20 ++++++++++++++++++++ api/python/arrus/devices/us4r.py | 19 +++++++++++++++++++ api/python/wrappers/core.i | 6 +++--- arrus/core/api/devices/us4r/Us4R.h | 2 +- 4 files changed, 43 insertions(+), 4 deletions(-) create mode 100644 api/python/arrus/devices/us4oem.py diff --git a/api/python/arrus/devices/us4oem.py b/api/python/arrus/devices/us4oem.py new file mode 100644 index 000000000..9b7f5e6f2 --- /dev/null +++ b/api/python/arrus/devices/us4oem.py @@ -0,0 +1,20 @@ +from arrus.devices.device import Device, DeviceId, DeviceType + +DEVICE_TYPE = DeviceType("Us4OEM") + + +class Us4OEM(Device): + + def __init__(self, handle): + self._handle = handle + self._device_id = DeviceId(DEVICE_TYPE, + self._handle.getDeviceId().getOrdinal()) + + def get_device_id(self) -> DeviceId: + return self._device_id + + def get_firmware_version(self) -> int: + return self._handle.getFirmwareVersion() + + def get_tx_firmware_version(self) -> int: + return self._handle.getTxFirmwareVersion() \ No newline at end of file diff --git a/api/python/arrus/devices/us4r.py b/api/python/arrus/devices/us4r.py index 317e6b7a6..4f40c5f4b 100644 --- a/api/python/arrus/devices/us4r.py +++ b/api/python/arrus/devices/us4r.py @@ -7,6 +7,7 @@ from arrus.devices.device import Device, DeviceId, DeviceType import arrus.exceptions import arrus.devices.probe +from arrus.devices.us4oem import Us4OEM import arrus.metadata import arrus.kernels import arrus.kernels.kernel @@ -105,6 +106,24 @@ def sampling_frequency(self): def n_us4oems(self): return self._handle.getNumberOfUs4OEMs() + def get_us4oem(self, ordinal: int): + return Us4OEM(self._handle.getUs4OEM(ordinal)) + + @property + def firmware_version(self): + result = {} + # Us4OEMs + us4oem_ver = [] + for i in range(self.n_us4oems): + dev = self.get_us4oem(i) + ver = { + "main": dev.get_firmware_version(), + "tx": dev.get_tx_firmware_version() + } + us4oem_ver.append(ver) + result["Us4OEM"] = us4oem_ver + return result + def set_kernel_context(self, kernel_context): self._current_sequence_context = kernel_context diff --git a/api/python/wrappers/core.i b/api/python/wrappers/core.i index 6d212698c..885eb0e60 100644 --- a/api/python/wrappers/core.i +++ b/api/python/wrappers/core.i @@ -63,6 +63,7 @@ namespace std { #include "arrus/core/api/io/settings.h" #include "arrus/core/api/session/Session.h" #include "arrus/core/api/common/logging.h" +#include "arrus/core/api/devices/us4r/Us4OEM.h" #include "arrus/core/api/devices/us4r/Us4R.h" #include "arrus/core/api/ops/us4r/TxRxSequence.h" @@ -225,6 +226,7 @@ std::shared_ptr getFifoLockFreeBuffer(arrus::sessi #include "arrus/core/api/devices/DeviceId.h" #include "arrus/core/api/devices/Device.h" #include "arrus/core/api/devices/DeviceWithComponents.h" +#include "arrus/core/api/devices/us4r/Us4OEM.h" #include "arrus/core/api/devices/us4r/Us4R.h" #include "arrus/core/api/devices/probe/ProbeModelId.h" #include "arrus/core/api/devices/probe/Probe.h" @@ -244,8 +246,6 @@ using namespace arrus::devices; %include "arrus/core/api/devices/probe/Probe.h" - - %inline %{ arrus::devices::Us4R *castToUs4r(arrus::devices::Device *device) { auto ptr = dynamic_cast(device); @@ -254,7 +254,7 @@ arrus::devices::Us4R *castToUs4r(arrus::devices::Device *device) { } return ptr; } -// TODO(pjarosik) remote the bellow functions when possible +// TODO(pjarosik) remove the bellow functions when possible unsigned short getNumberOfElements(const arrus::devices::ProbeModel &probe) { const auto &nElements = probe.getNumberOfElements(); diff --git a/arrus/core/api/devices/us4r/Us4R.h b/arrus/core/api/devices/us4r/Us4R.h index 569e4690d..12b35b95d 100644 --- a/arrus/core/api/devices/us4r/Us4R.h +++ b/arrus/core/api/devices/us4r/Us4R.h @@ -35,7 +35,7 @@ class Us4R : public DeviceWithComponents { * @param ordinal ordinal number of the us4oem to get * @return a handle to the us4oem module */ - virtual Us4OEM::RawHandle getUs4OEM(Ordinal ordinal) = 0; + virtual Us4OEM* getUs4OEM(Ordinal ordinal) = 0; /** * Returns a handle to an adapter identified by given ordinal number.