Skip to content

Commit 864cd59

Browse files
committed
refactor: migrate RingBuffer implementation to lpl::container and update usage in OpenBciSource
test: add parity tests for lpl::container::RingBuffer semantics build: update xmake configuration for new RingBuffer location
1 parent 1638f8d commit 864cd59

10 files changed

Lines changed: 227 additions & 280 deletions

File tree

bci/include/lpl/bci/dsp/RingBuffer.hpp

Lines changed: 0 additions & 106 deletions
This file was deleted.

bci/include/lpl/bci/dsp/RingBuffer.inl

Lines changed: 0 additions & 74 deletions
This file was deleted.

bci/include/lpl/bci/source/OpenBciSource.hpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@
1515

1616
#include "ISource.hpp"
1717
#include "lpl/bci/core/Constants.hpp"
18-
#include "lpl/bci/dsp/RingBuffer.hpp"
1918
#include "serial/SerialPort.hpp"
2019

20+
#include <lpl/container/RingBuffer.hpp>
21+
2122
#include <stop_token>
2223
#include <thread>
2324

@@ -57,7 +58,7 @@ class OpenBciSource final : public ISource {
5758

5859
OpenBciConfig _config;
5960
SerialPort _serial;
60-
dsp::RingBuffer<Sample, kCytonRingSlots> _ring;
61+
lpl::container::RingBuffer<Sample, kCytonRingSlots> _ring;
6162
std::jthread _worker;
6263
bool _started = false;
6364
};

bci/src/source/OpenBciSource.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
#include <array>
1010
#include <cstring>
11+
#include <utility>
1112

1213
namespace lpl::bci::source {
1314

@@ -126,7 +127,7 @@ void OpenBciSource::workerLoop(std::stop_token stopToken)
126127
sample.channels[ch] = parseChannel(&buffer[2 + ch * 3]);
127128
}
128129

129-
_ring.push(sample);
130+
_ring.push(std::move(sample));
130131
}
131132
}
132133

bci/tests/TestRingBuffer.cpp

Lines changed: 0 additions & 67 deletions
This file was deleted.

bci/xmake.lua

Lines changed: 48 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,57 @@
11
-- /////////////////////////////////////////////////////////////////////////////
2-
-- bci/ build configuration — Brain-Computer Interface bridge
3-
-- Merged: src/bci adapter + plugins/bci pipeline (DSP, metrics, sources)
2+
-- bci/ build configuration — Brain-Computer Interface bridge (hosted-only)
3+
--
4+
-- The acquisition and analysis backends pull in host-only third-party
5+
-- libraries:
6+
-- * Eigen — covariance / Riemannian geometry (math, metrics)
7+
-- * liblsl — Lab Streaming Layer source and outlet
8+
-- * BrainFlow (opt.) — OpenBCI / BrainFlow acquisition backend
9+
--
10+
-- The DSP acquisition ring buffer uses the engine's own SPSC lpl-container
11+
-- RingBuffer (no Boost dependency — see container/RingBuffer.hpp).
12+
--
13+
-- This module is hosted-only: the freestanding kernel build does not compile
14+
-- it, so these dependencies never reach the kernel target.
415
-- /////////////////////////////////////////////////////////////////////////////
16+
17+
add_repositories("laplace-xmake-repo https://github.com/MasterLaplace/xmake-repo.git feat/brainflow-liblsl")
18+
19+
add_requires("eigen")
20+
add_requires("liblsl")
21+
add_requires("brainflow", { optional = true })
22+
23+
option("with_brainflow")
24+
set_default(true)
25+
set_showmenu(true)
26+
set_description("Enable the BrainFlow acquisition backend in lpl-bci")
27+
option_end()
28+
529
target("lpl-bci")
630
set_kind("static")
731
set_group("modules")
8-
add_deps("lpl-core", "lpl-math", "lpl-input")
32+
set_warnings("all", "error")
33+
add_deps("lpl-core", "lpl-math", "lpl-input", "lpl-container")
934
add_includedirs("include", { public = true })
1035
add_files("src/**.cpp")
1136
add_headerfiles("include/(lpl/bci/**.hpp)")
12-
add_headerfiles("include/(lpl/bci/**.inl)")
13-
14-
-- Exclude files requiring external dependencies not yet installed
15-
-- These will be re-enabled when Eigen, Boost, liblsl, BrainFlow are added
16-
remove_files("src/math/Covariance.cpp")
17-
remove_files("src/math/Riemannian.cpp")
18-
remove_files("src/metric/StabilityMetric.cpp")
19-
remove_files("src/openvibe/StabilityMonitorBox.cpp")
20-
remove_files("src/source/BrainFlowSource.cpp")
21-
remove_files("src/source/OpenBciSource.cpp")
22-
remove_files("src/source/LslSource.cpp")
23-
remove_files("src/source/SourceFactory.cpp")
24-
remove_files("src/stream/LslOutlet.cpp")
25-
remove_files("src/source/serial/**.cpp")
37+
38+
if is_plat("windows") then
39+
remove_files("src/source/serial/SerialPortPosix.cpp")
40+
else
41+
remove_files("src/source/serial/SerialPortWin32.cpp")
42+
end
43+
44+
add_cxxflags("-fexceptions", { force = true })
45+
46+
add_packages("eigen", "liblsl", { public = true })
47+
48+
if has_config("with_brainflow") then
49+
add_packages("brainflow", { public = true })
50+
end
51+
52+
on_config(function (target)
53+
if target:pkg("brainflow") then
54+
target:add("defines", "LPL_HAS_BRAINFLOW", { public = true })
55+
end
56+
end)
2657
target_end()

0 commit comments

Comments
 (0)