#pragma once
// control_handler.hpp
// 运控处理器虚基类。
// 子类覆盖各方法后即可接入真实运控驱动；默认实现返回 stub 成功响应。

#include <chrono>
#include "data_types.hpp"

namespace vaw
{

class ControlHandler
{
public:
    virtual ~ControlHandler() = default;

    // 查询运控就绪状态
    virtual ControlReadinessResponse get_readiness(const nlohmann::json& req)
    {
        (void)req;
        ControlReadinessResponse rsp;
        rsp.success                   = true;
        rsp.error_code                = ErrorCode::OK;
        rsp.message                   = "运控就绪（stub）";
        rsp.agent_ready               = true;
        rsp.trajectory_executor_ready = true;
        rsp.vehicle_feedback_ready    = true;
        rsp.control_output_ready      = true;
        rsp.estop_released            = true;
        rsp.vehicle_safe_to_move      = true;
        rsp.checked_timestamp_us      = std::chrono::duration_cast<std::chrono::microseconds>(
            std::chrono::system_clock::now().time_since_epoch()).count();
        return rsp;
    }

    // 执行控制评估任务
    // req: 已解析的 ControllerEvaluationRequest
    virtual ControlJobResult execute_evaluation(const ControllerEvaluationRequest& req)
    {
        (void)req;
        ControlJobResult result;
        result.success              = true;
        result.error_code           = ErrorCode::OK;
        result.message              = "控制评估完成（stub）";
        result.job_id               = req.test_case_id;
        result.data_quality_passed  = true;
        result.suitable_for_commit  = true;
        result.validation_summary.auto_acceptance_passed = true;
        return result;
    }
};

}  // namespace vaw
