diff --git a/commonLibs/livoxProto1/device.h b/commonLibs/livoxProto1/device.h index 2e5659e..04c7acd 100644 --- a/commonLibs/livoxProto1/device.h +++ b/commonLibs/livoxProto1/device.h @@ -4,11 +4,13 @@ #include #include #include +#include #include #include #include #include #include +#include #include #include #include @@ -113,6 +115,34 @@ public: Triple = 0x03 }; + /** + * Get the number of points per datagram based on return mode + * @param returnMode The return mode (0=SingleFirst, 1=SingleStrongest, 2=Dual, 3=Triple) + * @return Number of points per datagram + */ + static inline size_t getNPointsPerDgram(int returnMode) + { + /* + * Map modes to points per datagram based on Livox docs + * 1: first, 2: strongest -> 96 samples => 96 points + * 3: dual -> 48 samples * 2 points = 96 + * 4: triple -> 30 samples * 3 points = 90 + */ + switch (returnMode) + { + case static_cast(ReturnMode::SingleFirst): + case static_cast(ReturnMode::SingleStrongest): + case static_cast(ReturnMode::Dual): + return 96u; + case static_cast(ReturnMode::Triple): + return 90u; + default: + throw std::runtime_error( + std::string(__func__) + ": Unknown returnMode " + + std::to_string(returnMode)); + } + } + // Utility methods std::optional getSmoIp(const std::string& deviceIP); diff --git a/stimBuffApis/livoxGen1/ioUringAssemblyEngine.cpp b/stimBuffApis/livoxGen1/ioUringAssemblyEngine.cpp index c586bde..a174426 100644 --- a/stimBuffApis/livoxGen1/ioUringAssemblyEngine.cpp +++ b/stimBuffApis/livoxGen1/ioUringAssemblyEngine.cpp @@ -851,28 +851,5 @@ void IoUringAssemblyEngine::printSlotBytes(size_t slotIndex, size_t nBytes) } } -size_t IoUringAssemblyEngine::computePointsPerDgram(int returnMode) -{ - /* - * Map modes to points per datagram based on Livox docs - * 1: first, 2: strongest -> 96 samples => 96 points - * 3: dual -> 48 samples * 2 points = 96 - * 4: triple -> 30 samples * 3 points = 90 - */ - switch (returnMode) - { - case static_cast(livoxProto1::Device::ReturnMode::SingleFirst): - case static_cast(livoxProto1::Device::ReturnMode::SingleStrongest): - case static_cast(livoxProto1::Device::ReturnMode::Dual): - return 96u; - case static_cast(livoxProto1::Device::ReturnMode::Triple): - return 90u; - default: - throw std::runtime_error( - std::string(__func__) + ": Unknown returnMode " - + std::to_string(returnMode)); - } -} - } // namespace stim_buff } // namespace smo diff --git a/stimBuffApis/livoxGen1/ioUringAssemblyEngine.h b/stimBuffApis/livoxGen1/ioUringAssemblyEngine.h index a38b4d2..97ccc55 100644 --- a/stimBuffApis/livoxGen1/ioUringAssemblyEngine.h +++ b/stimBuffApis/livoxGen1/ioUringAssemblyEngine.h @@ -40,9 +40,8 @@ public: void assembleFrameReq(Callback cb); // Telemetry helpers - static size_t computePointsPerDgram(int returnMode); static size_t computePointsPerFrame(int returnMode, size_t nDgramsPerFrame) - { return computePointsPerDgram(returnMode) * nDgramsPerFrame; } + { return livoxProto1::Device::getNPointsPerDgram(returnMode) * nDgramsPerFrame; } static bool compactionIsNeeded(uint32_t nSucceeded, uint32_t nTotal) { return nSucceeded != 0 && nTotal != 0 && nSucceeded != nTotal; } diff --git a/stimBuffApis/livoxGen1/openClCollatingAndMeshingEngine.cpp b/stimBuffApis/livoxGen1/openClCollatingAndMeshingEngine.cpp index 1f447ee..c7b2500 100644 --- a/stimBuffApis/livoxGen1/openClCollatingAndMeshingEngine.cpp +++ b/stimBuffApis/livoxGen1/openClCollatingAndMeshingEngine.cpp @@ -11,6 +11,7 @@ #include #include #include +#include #include "livoxGen1.h" #include "openClCollatingAndMeshingEngine.h" #include "pcloudStimulusProducer.h" @@ -645,7 +646,7 @@ bool OpenClCollatingAndMeshingEngine::setupCollateDgramsArgs( } int returnMode = static_cast(parent.device->currentReturnMode); uint32_t nPointsPerSlot = static_cast( - IoUringAssemblyEngine::computePointsPerDgram(returnMode)); + livoxProto1::Device::getNPointsPerDgram(returnMode)); uint32_t nDgramsPerFrame = static_cast( frameAssemblyDesc->numSlots); @@ -1030,7 +1031,9 @@ public: } int returnMode = static_cast(engine.parent.device->currentReturnMode); - size_t pointsPerDgram = IoUringAssemblyEngine::computePointsPerDgram(returnMode); + size_t pointsPerDgram = livoxProto1::Device::getNPointsPerDgram( + returnMode); + uint32_t nSucceeded = context->frameAssemblyResult.nSucceeded.load(); size_t totalPoints = nSucceeded * pointsPerDgram;