Move/RN computeNSlotsPerDgram to Device::getNSlotsPerDgram
This commit is contained in:
@@ -4,11 +4,13 @@
|
||||
#include <boostAsioLinkageFix.h>
|
||||
#include <string>
|
||||
#include <cstdint>
|
||||
#include <cstddef>
|
||||
#include <memory>
|
||||
#include <atomic>
|
||||
#include <optional>
|
||||
#include <functional>
|
||||
#include <unordered_map>
|
||||
#include <stdexcept>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
@@ -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<int>(ReturnMode::SingleFirst):
|
||||
case static_cast<int>(ReturnMode::SingleStrongest):
|
||||
case static_cast<int>(ReturnMode::Dual):
|
||||
return 96u;
|
||||
case static_cast<int>(ReturnMode::Triple):
|
||||
return 90u;
|
||||
default:
|
||||
throw std::runtime_error(
|
||||
std::string(__func__) + ": Unknown returnMode "
|
||||
+ std::to_string(returnMode));
|
||||
}
|
||||
}
|
||||
|
||||
// Utility methods
|
||||
std::optional<std::string> getSmoIp(const std::string& deviceIP);
|
||||
|
||||
|
||||
@@ -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<int>(livoxProto1::Device::ReturnMode::SingleFirst):
|
||||
case static_cast<int>(livoxProto1::Device::ReturnMode::SingleStrongest):
|
||||
case static_cast<int>(livoxProto1::Device::ReturnMode::Dual):
|
||||
return 96u;
|
||||
case static_cast<int>(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
|
||||
|
||||
@@ -40,9 +40,8 @@ public:
|
||||
void assembleFrameReq(Callback<assembleFrameReqCbFn> 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; }
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include <asynchronousLoop.h>
|
||||
#include <componentThread.h>
|
||||
#include <user/stimulusFrame.h>
|
||||
#include <livoxProto1/device.h>
|
||||
#include "livoxGen1.h"
|
||||
#include "openClCollatingAndMeshingEngine.h"
|
||||
#include "pcloudStimulusProducer.h"
|
||||
@@ -645,7 +646,7 @@ bool OpenClCollatingAndMeshingEngine::setupCollateDgramsArgs(
|
||||
}
|
||||
int returnMode = static_cast<int>(parent.device->currentReturnMode);
|
||||
uint32_t nPointsPerSlot = static_cast<uint32_t>(
|
||||
IoUringAssemblyEngine::computePointsPerDgram(returnMode));
|
||||
livoxProto1::Device::getNPointsPerDgram(returnMode));
|
||||
uint32_t nDgramsPerFrame = static_cast<uint32_t>(
|
||||
frameAssemblyDesc->numSlots);
|
||||
|
||||
@@ -1030,7 +1031,9 @@ public:
|
||||
}
|
||||
|
||||
int returnMode = static_cast<int>(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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user