This commit is contained in:
2026-08-22 11:34:52 +08:00
parent 945e8287d4
commit 049516bf3b
7 changed files with 576 additions and 223 deletions
+4 -7
View File
@@ -168,9 +168,7 @@ struct Prop_Write {
Plot::Json_Handler handler;
};
struct Data_Generation {
std::size_t count{};
double minimum{};
double maximum{};
nlohmann::json input;
Plot::Json_Handler handler;
};
using Plot_Input = std::variant<Frame_Submission, Schema_Query, Prop_Write, Data_Generation>;
@@ -385,8 +383,7 @@ void Plot::ensure_started() {
continue;
}
if (auto* generation = std::get_if<Data_Generation>(&input)) {
generation->handler(self->d->view->generate_data(
generation->count, generation->minimum, generation->maximum));
generation->handler(self->d->view->generate_data(generation->input));
continue;
}
auto submission = std::get<Frame_Submission>(input);
@@ -428,10 +425,10 @@ void Plot::async_write_prop(std::string component, std::string key, nlohmann::js
}))
throw std::runtime_error("plot input queue is unavailable");
}
void Plot::async_generate_data(std::size_t count, double minimum, double maximum, Json_Handler handler) {
void Plot::async_generate_data(nlohmann::json input, Json_Handler handler) {
ensure_started();
if (!d->inputs.try_send(asio::error_code{}, Plot_Input{
Data_Generation{count, minimum, maximum, std::move(handler)}
Data_Generation{std::move(input), std::move(handler)}
}))
throw std::runtime_error("plot input queue is unavailable");
}