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