修复展示数据

This commit is contained in:
2026-08-17 17:21:51 +08:00
parent 5e976b27dd
commit 3881beea69
5 changed files with 103 additions and 22 deletions
+30 -9
View File
@@ -19,6 +19,7 @@
#include <chrono>
#include <cmath>
#include <memory>
#include <numbers>
#include <span>
#include <string>
#include <vector>
@@ -35,6 +36,8 @@ struct Observer_Pfr_Adapter<Render_Scene_2D::Observer> {
Render_Scene_2D::Observer, Render_Scene_2D::Observer_Fields>;
};
namespace {
constexpr std::size_t sweep_bins_per_block = 64;
constexpr std::size_t sweep_block_count = 8;
std::shared_ptr<Frame_Control_Strategy_Base> make_strategy(
Gallery_Frame_Mode mode) {
switch (mode) {
@@ -349,8 +352,8 @@ private:
} else if (case_id_ == "sweep_spectrum") {
Sweep_Spectrum::State state;
state.frequency_range = {0.0, 300.0};
state.bins_per_block = 64;
state.block_count = 8;
state.bins_per_block = static_cast<int>(sweep_bins_per_block);
state.block_count = static_cast<int>(sweep_block_count);
Sweep_Spectrum::Builder builder{state, &attach};
sweep_ = build<Sweep_Spectrum>(
builder, root, domain_axis_, value_axis_);
@@ -382,9 +385,16 @@ private:
}
void update_samples() {
const std::size_t count = waterfall_ ? 256U : afterglow_ ? 192U : 512U;
const std::size_t count =
waterfall_ ? 256U :
afterglow_ ? 192U :
sweep_ ? sweep_bins_per_block * sweep_block_count : 512U;
std::vector<double> values(count);
const double time = static_cast<double>(sample_sequence_++) * 0.075;
const std::uint64_t sample_sequence = sample_sequence_++;
const std::uint64_t time_sequence = sweep_
? sample_sequence / sweep_block_count * sweep_block_count
: sample_sequence;
const double time = static_cast<double>(time_sequence) * 0.075;
for (std::size_t index = 0; index < count; ++index) {
const double x = static_cast<double>(index) / (count - 1);
const auto gaussian = [](double value, double center, double width) {
@@ -402,15 +412,26 @@ private:
if (waterfall_) waterfall_->append_row(current_time_of_day(), values);
if (afterglow_) afterglow_->append_spectrum(values);
if (sweep_) {
values.resize(64);
sweep_->append_block(values);
const std::size_t block_index = static_cast<std::size_t>(
sample_sequence % sweep_block_count);
const std::size_t first = block_index * sweep_bins_per_block;
sweep_->append_block(std::span<const double>(
values.data() + first, sweep_bins_per_block));
}
if (trace_) trace_->append_sample(current_time_of_day(), std::sin(time));
if (constellation_) {
const double phase = time * 1.7;
constexpr std::size_t symbol_count =
static_cast<std::size_t>(Constellation_Diagram_Type::Psk8);
const std::size_t symbol_index = sample_sequence % symbol_count;
const double phase = 2.0 * std::numbers::pi *
static_cast<double>(symbol_index) /
static_cast<double>(symbol_count);
const double i_noise =
std::sin(time * 17.0 + static_cast<double>(symbol_index) * 0.73) * 0.04;
const double q_noise =
std::cos(time * 19.0 + static_cast<double>(symbol_index) * 1.11) * 0.04;
constellation_->append_point(
{std::cos(phase) + std::sin(time * 9.0) * 0.08,
std::sin(phase) + std::cos(time * 7.0) * 0.08});
{std::cos(phase) + i_noise, std::sin(phase) + q_noise});
}
}