Skip to content

Commit 07cfbe1

Browse files
Resolve "Update add_property api calls"
Closes #18
1 parent e52d569 commit 07cfbe1

File tree

16 files changed

+172
-99
lines changed

16 files changed

+172
-99
lines changed

docker/Dockerfile.rocky9

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ WORKDIR /opt
2323

2424
RUN set -ex; \
2525
. /opt/rh/gcc-toolset-13/enable; \
26-
git clone --branch v0.1.0 https://github.com/geontech/composite.git; \
26+
git clone --branch 11-add-rest-server-for-command-and-control https://github.com/geontech/composite.git; \
2727
cd composite; \
2828
cmake -B docker-build \
2929
-DCMAKE_INSTALL_PREFIX=/usr/local \

examples/write.json

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,43 @@
11
{
22
"name" : "Write raw data",
3+
"properties" : [
4+
{
5+
"name" : "msg_size",
6+
"value" : "1032"
7+
}
8+
],
39
"components" : [
410
{
511
"name" : "udp_source",
612
"properties" : [
713
{
8-
"type" : "uint32",
9-
"name" : "msg_size",
10-
"value" : 1032
11-
},
12-
{
13-
"type" : "uint32",
1414
"name" : "num_msgs",
15-
"value" : 64
15+
"value" : "64"
1616
},
1717
{
18-
"type" : "string",
1918
"name" : "ip_addr",
2019
"value" : "127.0.0.1"
2120
},
2221
{
23-
"type" : "uint32",
2422
"name" : "port",
25-
"value" : 9999
23+
"value" : "9999"
2624
}
2725
]
2826
},
2927
{
30-
"name" : "file_writer",
28+
"name" : "histogram",
3129
"properties" : [
3230
{
33-
"type" : "string",
34-
"name" : "filename",
35-
"value" : "example.dat"
31+
"name" : "transport",
32+
"value" : "vita49"
33+
},
34+
{
35+
"name" : "sample_rate",
36+
"value" : "32768"
3637
},
3738
{
38-
"type" : "uint64",
39-
"name" : "num_bytes",
40-
"value" : 100000000
39+
"name" : "adc_bits",
40+
"value" : "16"
4141
}
4242
]
4343
}
@@ -49,7 +49,7 @@
4949
"port" : "data_out"
5050
},
5151
"input" : {
52-
"component" : "file_writer",
52+
"component" : "histogram",
5353
"port" : "data_in"
5454
}
5555
}

src/components/aligned_mem_writer/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ target_include_directories(aligned_mem_writer
4545
target_link_libraries(aligned_mem_writer
4646
PRIVATE
4747
composite::composite
48+
spdlog::spdlog_header_only
4849
)
4950
# Install
5051
install(TARGETS aligned_mem_writer

src/components/aligned_mem_writer/component.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class aligned_mem_writer : public composite::component {
3232
aligned_mem_writer() : composite::component("aligned_mem_writer") {
3333
add_port(m_in_port.get());
3434
add_property("filename", &m_filename);
35-
add_property("num_bytes", &m_num_bytes);
35+
add_property("num_bytes", &m_num_bytes).units("bytes");
3636
}
3737

3838
~aligned_mem_writer() override {

src/components/exp_smooth/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ target_include_directories(exp_smooth
4848
target_link_libraries(exp_smooth
4949
PRIVATE
5050
composite::composite
51+
spdlog::spdlog_header_only
5152
)
5253
# Install
5354
install(TARGETS exp_smooth

src/components/exp_smooth/component.hpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,22 +29,23 @@ class exp_smooth : public composite::component {
2929
using input_t = aligned::aligned_mem<T>;
3030
using input_port_t = composite::input_port<std::unique_ptr<input_t>>;
3131
using output_port_t = composite::output_port<std::unique_ptr<input_t>>;
32+
using enum composite::config_type;
3233
public:
3334
exp_smooth() : composite::component("exp_smooth") {
3435
add_port(m_in_port.get());
3536
add_port(m_out_port.get());
36-
add_property("num_averages", &m_num_averages);
37+
add_property("num_averages", &m_num_averages).configurability(RUNTIME).change_listener([this]() {
38+
if (m_num_averages > 0) {
39+
m_alpha = T{1} - std::pow(T{10}, (std::log10(1 - .98) / m_num_averages));
40+
}
41+
m_work = std::make_unique<work<T>>(m_alpha);
42+
m_prev_psd.reset();
43+
return true;
44+
});
3745
}
3846

3947
~exp_smooth() override = default;
4048

41-
auto initialize() -> void override {
42-
if (m_num_averages > 0) {
43-
m_alpha -= std::pow(T{10}, (std::log10(1 - .98) / m_num_averages));
44-
}
45-
m_work = std::make_unique<work<T>>(m_alpha);
46-
}
47-
4849
auto process() -> composite::retval override {
4950
using enum composite::retval;
5051
auto [data, ts] = m_in_port->get_data();

src/components/fft/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ target_include_directories(fft
4848
target_link_libraries(fft
4949
PRIVATE
5050
composite::composite
51+
spdlog::spdlog_header_only
5152
fftw3f
5253
fftw3f_threads
5354
fftw3

src/components/fft/component.hpp

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include "overlay.hpp"
2424
#include "windows.hpp"
2525

26+
#include <bit>
2627
#include <composite/component.hpp>
2728
#include <complex>
2829
#include <fftw3.h>
@@ -36,26 +37,32 @@ class fft : public composite::component {
3637
using window_t = aligned::aligned_mem<T>;
3738
using input_port_t = composite::input_port<std::unique_ptr<fft_t>>;
3839
using output_port_t = composite::output_port<std::unique_ptr<fft_t>>;
40+
using enum composite::config_type;
3941
public:
4042
fft() : composite::component("fft") {
4143
add_port(m_in_port.get());
4244
add_port(m_out_port.get());
43-
add_property("window", &m_window_type);
44-
add_property("fft_size", &m_fft_size);
45+
add_property("window", &m_window_type).change_listener([this]() {
46+
if ((m_window_type == "BLACKMAN_HARRIS") || (m_window_type == "HAMMING")) {
47+
return true;
48+
}
49+
return false;
50+
});
51+
add_property("fft_size", &m_fft_size).configurability(RUNTIME).change_listener([this]() {
52+
return std::has_single_bit(m_fft_size);
53+
});
4554
add_property("fftw_threads", &m_fftw_threads);
46-
add_property("shift", &m_shift);
55+
add_property("shift", &m_shift).configurability(RUNTIME);
4756
}
4857

4958
~fft() override = default;
5059

51-
auto initialize() -> void override {
52-
// Init window
60+
auto property_change_handler() -> void override {
5361
if (m_window_type == "BLACKMAN_HARRIS") {
5462
m_window = windows::blackman_harris<T>(m_fft_size);
5563
} else if (m_window_type == "HAMMING") {
5664
m_window = windows::hamming<T>(m_fft_size);
5765
}
58-
// Init fftw
5966
m_fft_plan = std::make_unique<plan_t>(m_fft_size, m_fftw_threads, m_shift);
6067
}
6168

src/components/histogram/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ target_include_directories(histogram
4545
target_link_libraries(histogram
4646
PRIVATE
4747
composite::composite
48+
spdlog::spdlog_header_only
4849
)
4950
# Install
5051
install(TARGETS histogram

src/components/histogram/component.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ histogram::histogram() : composite::component("histogram") {
2525
add_port(m_in_port.get());
2626
add_port(m_out_port.get());
2727
add_property("transport", &m_transport);
28-
add_property("msg_size", &m_msg_size);
28+
add_property("msg_size", &m_msg_size).units("bytes");
2929
add_property("byteswap", &m_byteswap);
30-
add_property("adc_bits", &m_adc_bits);
31-
add_property("sample_rate", &m_sample_rate);
30+
add_property("adc_bits", &m_adc_bits).units("bits");
31+
add_property("sample_rate", &m_sample_rate).units("sps");
3232
add_property("display_as_bits", &m_display_as_bits);
3333
}
3434

0 commit comments

Comments
 (0)