加所有权之前
This commit is contained in:
@@ -1,34 +1,17 @@
|
||||
#include "Control_Service.hpp"
|
||||
#include "Control_Service.ipp"
|
||||
#include "Control_Requests.hpp"
|
||||
#include "Protocol_Type.hpp"
|
||||
#include "runtime/Gallery_Plots.hpp"
|
||||
#include <render_common.hpp>
|
||||
#include <array>
|
||||
#include <chrono>
|
||||
#include <stdexcept>
|
||||
#include <utility>
|
||||
|
||||
namespace aethera::mcp {
|
||||
namespace {
|
||||
|
||||
struct Empty_Request {};
|
||||
struct Plot_Request {
|
||||
std::string plot; /* Gallery Plot 稳定标识。 */
|
||||
};
|
||||
struct Component_Request {
|
||||
std::string plot; /* Gallery Plot 稳定标识。 */
|
||||
std::string component; /* Renderable 业务组件标识。 */
|
||||
};
|
||||
struct Write_Property_Request {
|
||||
std::string plot; /* Gallery Plot 稳定标识。 */
|
||||
std::string component; /* Renderable 业务组件标识。 */
|
||||
std::string property; /* 待修改属性键。 */
|
||||
nlohmann::json value; /* 属性协议值。 */
|
||||
};
|
||||
struct Generate_Data_Request {
|
||||
std::string plot; /* Gallery Plot 稳定标识。 */
|
||||
nlohmann::json input; /* Plot 数据生成器输入。 */
|
||||
};
|
||||
|
||||
using Invoke = Tool_Call_Output (*)(Control_Service&, const nlohmann::json&);
|
||||
using Schema = nlohmann::json (*)();
|
||||
|
||||
@@ -128,6 +111,77 @@ template <typename Request, typename Callback>
|
||||
});
|
||||
}
|
||||
|
||||
[[nodiscard]] Tool_Call_Output submit_plot_input(
|
||||
Control_Service& service, const nlohmann::json& arguments) {
|
||||
return decode_and_call<Plot_Input_Request>(
|
||||
arguments, [&service](auto request) {
|
||||
const auto plot = service.find_plot(request.plot);
|
||||
if (!plot)
|
||||
return Tool_Call_Output{
|
||||
Tool_Call_Result::unknown_plot, {}, "unknown plot"};
|
||||
const auto time_milliseconds = request.event.time_milliseconds;
|
||||
plot->submit_input(std::move(request.event));
|
||||
return Tool_Call_Output{
|
||||
Tool_Call_Result::ok,
|
||||
{{"accepted", true},
|
||||
{"plot", request.plot},
|
||||
{"time_milliseconds", time_milliseconds}}, {}};
|
||||
});
|
||||
}
|
||||
|
||||
[[nodiscard]] Tool_Call_Output render_plot_at(
|
||||
Control_Service& service, const nlohmann::json& arguments) {
|
||||
return decode_and_call<Plot_Render_Request>(
|
||||
arguments, [&service](const auto& request) {
|
||||
const auto plot = service.find_plot(request.plot);
|
||||
if (!plot)
|
||||
return Tool_Call_Output{
|
||||
Tool_Call_Result::unknown_plot, {}, "unknown plot"};
|
||||
plot->schedule_render(web::Plot_Render_Tick{
|
||||
.issued_at = std::chrono::steady_clock::now(),
|
||||
.time_milliseconds = request.time_milliseconds,
|
||||
.width = request.width,
|
||||
.height = request.height,
|
||||
.source = Frame_Request_Source::immediate});
|
||||
return Tool_Call_Output{
|
||||
Tool_Call_Result::ok,
|
||||
{{"accepted", true},
|
||||
{"plot", request.plot},
|
||||
{"time_milliseconds", request.time_milliseconds},
|
||||
{"width", request.width}, {"height", request.height}}, {}};
|
||||
});
|
||||
}
|
||||
|
||||
[[nodiscard]] Tool_Call_Output begin_frame_trace(
|
||||
Control_Service& service, const nlohmann::json& arguments) {
|
||||
return decode_and_call<Frame_Trace_Request>(
|
||||
arguments, [&service](const auto& request) {
|
||||
const auto plot = service.find_plot(request.plot);
|
||||
if (!plot)
|
||||
return Tool_Call_Output{
|
||||
Tool_Call_Result::unknown_plot, {}, "unknown plot"};
|
||||
plot->request_taskflow_trace(request.frame_count);
|
||||
return Tool_Call_Output{
|
||||
Tool_Call_Result::ok,
|
||||
{{"accepted", true}, {"plot", request.plot},
|
||||
{"frame_count", request.frame_count},
|
||||
{"status_tool", "aethera_frame_trace_read"}}, {}};
|
||||
});
|
||||
}
|
||||
|
||||
[[nodiscard]] Tool_Call_Output read_frame_trace(
|
||||
Control_Service& service, const nlohmann::json& arguments) {
|
||||
return decode_and_call<Plot_Request>(
|
||||
arguments, [&service](const auto& request) {
|
||||
const auto plot = service.find_plot(request.plot);
|
||||
if (!plot)
|
||||
return Tool_Call_Output{
|
||||
Tool_Call_Result::unknown_plot, {}, "unknown plot"};
|
||||
return Tool_Call_Output{
|
||||
Tool_Call_Result::ok, plot->taskflow_trace(), {}};
|
||||
});
|
||||
}
|
||||
|
||||
[[nodiscard]] Tool_Call_Output begin_benchmark(
|
||||
Control_Service& service, const nlohmann::json& arguments) {
|
||||
return decode_and_call<Plot_Request>(arguments, [&service](const auto& request) {
|
||||
@@ -221,6 +275,14 @@ constexpr std::array operations{
|
||||
&request_schema<Write_Property_Request>, &write_property},
|
||||
Operation{"aethera_data_generate", "Generate input data for a gallery plot.",
|
||||
&request_schema<Generate_Data_Request>, &generate_data},
|
||||
Operation{"aethera_plot_input", "Submit one timestamped input event without waiting for rendering.",
|
||||
&request_schema<Plot_Input_Request>, &submit_plot_input},
|
||||
Operation{"aethera_plot_render_at", "Request one diagnostic frame at a caller-owned timeline time.",
|
||||
&request_schema<Plot_Render_Request>, &render_plot_at},
|
||||
Operation{"aethera_frame_trace_begin", "Capture existing per-frame Taskflow and Datoviz observations.",
|
||||
&request_schema<Frame_Trace_Request>, &begin_frame_trace},
|
||||
Operation{"aethera_frame_trace_read", "Read the current physical-frame trace capture.",
|
||||
&request_schema<Plot_Request>, &read_frame_trace},
|
||||
Operation{"aethera_benchmark_begin", "Reset diagnostics and asynchronously start rendering a plot.",
|
||||
&request_schema<Plot_Request>, &begin_benchmark},
|
||||
Operation{"aethera_benchmark_read", "Read benchmark results from the plot's current diagnostics.",
|
||||
|
||||
Reference in New Issue
Block a user