Rename StimulusBuffer=>StimulusProducer
Next we'll split the StimulusBuffer-related stuff into a new class StimulusBuffer.
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
add_library(attachmentSupport SHARED
|
add_library(attachmentSupport SHARED
|
||||||
stimulusBuffer.cpp
|
stimulusProducer.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
target_include_directories(attachmentSupport PUBLIC
|
target_include_directories(attachmentSupport PUBLIC
|
||||||
|
|||||||
+7
-7
@@ -8,12 +8,12 @@
|
|||||||
#include <opts.h>
|
#include <opts.h>
|
||||||
#include <componentThread.h>
|
#include <componentThread.h>
|
||||||
#include <spinLock.h>
|
#include <spinLock.h>
|
||||||
#include <user/stimulusBuffer.h>
|
#include <user/stimulusProducer.h>
|
||||||
|
|
||||||
namespace smo {
|
namespace smo {
|
||||||
namespace stim_buff {
|
namespace stim_buff {
|
||||||
|
|
||||||
void StimulusBuffer::stop()
|
void StimulusProducer::stop()
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
SpinLock::Guard lock(shouldContinueLock);
|
SpinLock::Guard lock(shouldContinueLock);
|
||||||
@@ -23,11 +23,11 @@ void StimulusBuffer::stop()
|
|||||||
// Cancel timer immediately
|
// Cancel timer immediately
|
||||||
timer.cancel();
|
timer.cancel();
|
||||||
|
|
||||||
std::cout << __func__ << ": Stopped stimulus buffer for device "
|
std::cout << __func__ << ": Stopped stimulus producer for device "
|
||||||
<< deviceAttachmentSpec->deviceSelector << std::endl;
|
<< deviceAttachmentSpec->deviceSelector << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void StimulusBuffer::scheduleNextTimeout(int delayMs)
|
void StimulusProducer::scheduleNextTimeout(int delayMs)
|
||||||
{
|
{
|
||||||
if (!shouldContinue)
|
if (!shouldContinue)
|
||||||
{ return; }
|
{ return; }
|
||||||
@@ -38,10 +38,10 @@ void StimulusBuffer::scheduleNextTimeout(int delayMs)
|
|||||||
|
|
||||||
timer.async_wait(
|
timer.async_wait(
|
||||||
std::bind(
|
std::bind(
|
||||||
&StimulusBuffer::onTimeout, this, std::placeholders::_1));
|
&StimulusProducer::onTimeout, this, std::placeholders::_1));
|
||||||
}
|
}
|
||||||
|
|
||||||
void StimulusBuffer::onTimeout(const boost::system::error_code& error)
|
void StimulusProducer::onTimeout(const boost::system::error_code& error)
|
||||||
{
|
{
|
||||||
// Timer was cancelled, which is expected when stopping
|
// Timer was cancelled, which is expected when stopping
|
||||||
if (error == boost::asio::error::operation_aborted) {
|
if (error == boost::asio::error::operation_aborted) {
|
||||||
@@ -50,7 +50,7 @@ void StimulusBuffer::onTimeout(const boost::system::error_code& error)
|
|||||||
|
|
||||||
if (error)
|
if (error)
|
||||||
{
|
{
|
||||||
std::cerr << "StimulusBuffer: Timer error: " << error.message()
|
std::cerr << "StimulusProducer: Timer error: " << error.message()
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
#ifndef _STIMULUS_BUFFER_H
|
#ifndef _STIMULUS_PRODUCER_H
|
||||||
#define _STIMULUS_BUFFER_H
|
#define _STIMULUS_PRODUCER_H
|
||||||
|
|
||||||
#include <boostAsioLinkageFix.h>
|
#include <boostAsioLinkageFix.h>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
@@ -22,16 +22,16 @@ namespace smo {
|
|||||||
namespace stim_buff {
|
namespace stim_buff {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* StimulusBuffer manages a collection of stimulus frames with simultaneity stamps.
|
* StimulusProducer manages a collection of stimulus frames with simultaneity stamps.
|
||||||
*
|
*
|
||||||
* This buffer is designed to hold stimulus frames that have been assembled
|
* This producer is designed to hold stimulus frames that have been assembled
|
||||||
* from raw sensor data (e.g., Livox Avia point cloud data) and are ready
|
* from raw sensor data (e.g., Livox Avia point cloud data) and are ready
|
||||||
* for processing by the mind layer.
|
* for processing by the mind layer.
|
||||||
*
|
*
|
||||||
* The buffer provides thread-safe operations for adding frames, retrieving
|
* The producer provides thread-safe operations for adding frames, retrieving
|
||||||
* frames, and managing the buffer state.
|
* frames, and managing the producer state.
|
||||||
*/
|
*/
|
||||||
class StimulusBuffer
|
class StimulusProducer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
class PcloudFormatDesc
|
class PcloudFormatDesc
|
||||||
@@ -48,7 +48,7 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit StimulusBuffer(
|
explicit StimulusProducer(
|
||||||
const std::shared_ptr<device::DeviceAttachmentSpec>
|
const std::shared_ptr<device::DeviceAttachmentSpec>
|
||||||
&deviceAttachmentSpec,
|
&deviceAttachmentSpec,
|
||||||
size_t nSlots,
|
size_t nSlots,
|
||||||
@@ -61,18 +61,18 @@ public:
|
|||||||
nDeferrals(0)
|
nDeferrals(0)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
virtual ~StimulusBuffer() = default;
|
virtual ~StimulusProducer() = default;
|
||||||
|
|
||||||
// Non-copyable, movable
|
// Non-copyable, movable
|
||||||
StimulusBuffer(const StimulusBuffer&) = delete;
|
StimulusProducer(const StimulusProducer&) = delete;
|
||||||
StimulusBuffer& operator=(const StimulusBuffer&) = delete;
|
StimulusProducer& operator=(const StimulusProducer&) = delete;
|
||||||
StimulusBuffer(StimulusBuffer&&) = default;
|
StimulusProducer(StimulusProducer&&) = default;
|
||||||
StimulusBuffer& operator=(StimulusBuffer&&) = default;
|
StimulusProducer& operator=(StimulusProducer&&) = default;
|
||||||
|
|
||||||
// Control methods
|
// Control methods
|
||||||
virtual void start()
|
virtual void start()
|
||||||
{
|
{
|
||||||
std::cout << __func__ << ": Starting stimulus buffer for device "
|
std::cout << __func__ << ": Starting stimulus producer for device "
|
||||||
<< deviceAttachmentSpec->deviceSelector << std::endl;
|
<< deviceAttachmentSpec->deviceSelector << std::endl;
|
||||||
|
|
||||||
shouldContinue = true;
|
shouldContinue = true;
|
||||||
@@ -121,4 +121,4 @@ private:
|
|||||||
} // namespace stim_buff
|
} // namespace stim_buff
|
||||||
} // namespace smo
|
} // namespace smo
|
||||||
|
|
||||||
#endif // _STIMULUS_BUFFER_H
|
#endif // _STIMULUS_PRODUCER_H
|
||||||
@@ -28,10 +28,10 @@ const SmoCallbacks* smoHooksPtr = nullptr;
|
|||||||
static SmoThreadingModelDesc smoThreadingModelDesc;
|
static SmoThreadingModelDesc smoThreadingModelDesc;
|
||||||
|
|
||||||
// Local collection of stimulus producers
|
// Local collection of stimulus producers
|
||||||
static std::vector<std::shared_ptr<StimulusBuffer>> attachedDataProducers;
|
static std::vector<std::shared_ptr<StimulusProducer>> attachedDataProducers;
|
||||||
|
|
||||||
// Get stimulus producer by device attachment spec
|
// Get stimulus producer by device attachment spec
|
||||||
static std::shared_ptr<StimulusBuffer>
|
static std::shared_ptr<StimulusProducer>
|
||||||
getDataProducer(const std::shared_ptr<smo::device::DeviceAttachmentSpec>& spec)
|
getDataProducer(const std::shared_ptr<smo::device::DeviceAttachmentSpec>& spec)
|
||||||
{
|
{
|
||||||
for (const auto& dataProducer : attachedDataProducers)
|
for (const auto& dataProducer : attachedDataProducers)
|
||||||
@@ -194,8 +194,8 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create and add PcloudDataProducer to collection now that device is ready
|
// Create and add PcloudDataProducer to collection now that device is ready
|
||||||
StimulusBuffer::PcloudFormatDesc formatDesc;
|
StimulusProducer::PcloudFormatDesc formatDesc;
|
||||||
formatDesc.format = StimulusBuffer::PcloudFormatDesc::Format::XYZI;
|
formatDesc.format = StimulusProducer::PcloudFormatDesc::Format::XYZI;
|
||||||
auto pcloudDataProducer = std::make_shared<PcloudDataProducer>(
|
auto pcloudDataProducer = std::make_shared<PcloudDataProducer>(
|
||||||
context->spec, context->deviceTmp, formatDesc, histbuffMs, 30);
|
context->spec, context->deviceTmp, formatDesc, histbuffMs, 30);
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ PcloudDataProducer::PcloudDataProducer(
|
|||||||
const PcloudFormatDesc& formatDesc,
|
const PcloudFormatDesc& formatDesc,
|
||||||
int histbuffMs,
|
int histbuffMs,
|
||||||
size_t nDgramsPerStagingBufferFrame)
|
size_t nDgramsPerStagingBufferFrame)
|
||||||
: StimulusBuffer(
|
: StimulusProducer(
|
||||||
deviceAttachmentSpec,
|
deviceAttachmentSpec,
|
||||||
static_cast<size_t>(histbuffMs / CONFIG_STIMBUFF_FRAME_PERIOD_MS),
|
static_cast<size_t>(histbuffMs / CONFIG_STIMBUFF_FRAME_PERIOD_MS),
|
||||||
openClInputConstraints,
|
openClInputConstraints,
|
||||||
@@ -87,13 +87,13 @@ void PcloudDataProducer::start()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Call base class start() as the final step
|
// Call base class start() as the final step
|
||||||
StimulusBuffer::start();
|
StimulusProducer::start();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PcloudDataProducer::stop()
|
void PcloudDataProducer::stop()
|
||||||
{
|
{
|
||||||
// Call base class stop() as the first step
|
// Call base class stop() as the first step
|
||||||
StimulusBuffer::stop();
|
StimulusProducer::stop();
|
||||||
// Call ioUringAssemblyEngine stop() as the final step
|
// Call ioUringAssemblyEngine stop() as the final step
|
||||||
openClCollatingAndMeshingEngine.finalize();
|
openClCollatingAndMeshingEngine.finalize();
|
||||||
ioUringAssemblyEngine.finalize();
|
ioUringAssemblyEngine.finalize();
|
||||||
@@ -211,9 +211,9 @@ void PcloudDataProducer::produceFrameReq(
|
|||||||
smo::Callback<produceFrameReqCbFn> callback)
|
smo::Callback<produceFrameReqCbFn> callback)
|
||||||
{
|
{
|
||||||
/** EXPLANATION:
|
/** EXPLANATION:
|
||||||
* We shouldn't acquire the StimulusBuffer::shouldContinueLock here because
|
* We shouldn't acquire the StimulusProducer::shouldContinueLock here because
|
||||||
* this function is called from
|
* this function is called from
|
||||||
* StimulusBuffer::stimFrameProductionTimesliceInd(), which is already
|
* StimulusProducer::stimFrameProductionTimesliceInd(), which is already
|
||||||
* holding the lock.
|
* holding the lock.
|
||||||
*/
|
*/
|
||||||
auto caller = smoHooksPtr->ComponentThread_getSelf();
|
auto caller = smoHooksPtr->ComponentThread_getSelf();
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
#include <user/stimulusBuffer.h>
|
#include <user/stimulusProducer.h>
|
||||||
#include <livoxProto1/device.h>
|
#include <livoxProto1/device.h>
|
||||||
#include <asynchronousContinuation.h>
|
#include <asynchronousContinuation.h>
|
||||||
#include <callback.h>
|
#include <callback.h>
|
||||||
@@ -15,15 +15,15 @@ namespace smo {
|
|||||||
namespace stim_buff {
|
namespace stim_buff {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PcloudDataProducer is a specialized StimulusBuffer for point cloud data.
|
* PcloudDataProducer is a specialized StimulusProducer for point cloud data.
|
||||||
*
|
*
|
||||||
* This class extends StimulusBuffer to handle point cloud-specific stimulus
|
* This class extends StimulusProducer to handle point cloud-specific stimulus
|
||||||
* frames, particularly those generated from LiDAR point cloud data. It
|
* frames, particularly those generated from LiDAR point cloud data. It
|
||||||
* provides additional functionality for managing point cloud frame metadata
|
* provides additional functionality for managing point cloud frame metadata
|
||||||
* and processing.
|
* and processing.
|
||||||
*/
|
*/
|
||||||
class PcloudDataProducer
|
class PcloudDataProducer
|
||||||
: public StimulusBuffer
|
: public StimulusProducer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit PcloudDataProducer(
|
explicit PcloudDataProducer(
|
||||||
|
|||||||
Reference in New Issue
Block a user