// 测试步骤数据结构定义

export interface StepParameter {
  name: string;        // 属性名
  description: string; // 说明
  value: string;       // 属性值
}

export interface StepCategory {
  title: string;              // 二级标题（如：直流电源、信号源）
  parameters: StepParameter[];
}

export interface TestStep {
  id: number;
  name: string;           // 步骤名称
  purpose: string;        // 目的
  categories: StepCategory[];
}

// 从意图编制提取的步骤（用于动态生成）
export interface ExtractedStep {
  id: number;
  name: string;           // 步骤名称（如：上电测试_电源初始化）
  purpose: string;        // 步骤目的
  // 按设备分类的参数，key为设备类别（如"程控电源参数"、"频谱分析仪参数"）
  deviceParams: {
    [deviceCategory: string]: {
      [paramName: string]: string;  // 参数名 -> 参数值
    };
  };
}

// 提取步骤的API响应
export interface ExtractStepsResponse {
  success: boolean;
  steps: ExtractedStep[];
  error?: string;
}

// 空的初始步骤列表
export const emptySteps: ExtractedStep[] = [];

// 示例测试步骤数据（基于用户提供的意图编制）
export const testSteps: TestStep[] = [
  {
    id: 1,
    name: "上电测试_电源初始化",
    purpose: "初始化直流电源并验证OCP/OVP保护逻辑",
    categories: [
      {
        title: "直流电源",
        parameters: [
          { name: "输出电压", description: "直流输出电压设置", value: "28V" },
          { name: "输出电流", description: "直流输出电流限制", value: "6A" },
          { name: "OCP阈值", description: "过流保护阈值", value: "6.1A" },
          { name: "OVP阈值", description: "过压保护阈值", value: "31V" },
        ],
      },
      {
        title: "信号源",
        parameters: [
          { name: "射频输出", description: "RF输出开关状态", value: "OFF" },
          { name: "远程控制", description: "远程控制模式", value: "ON" },
        ],
      },
      {
        title: "频谱仪",
        parameters: [
          { name: "远程控制", description: "远程控制模式", value: "ON" },
        ],
      },
      {
        title: "开关矩阵",
        parameters: [
          { name: "远程控制", description: "远程控制模式", value: "ON" },
          { name: "路径状态", description: "输出路径配置", value: "阻断所有路径" },
        ],
      },
    ],
  },
  {
    id: 2,
    name: "镜频测试_SC频段_通道切换",
    purpose: "验证SC频段信号通道的镜像抑制比",
    categories: [
      {
        title: "信号源",
        parameters: [
          { name: "RF Power", description: "射频功率输出", value: "-25dBm" },
          { name: "输出模式", description: "信号输出模式", value: "CW模式" },
          { name: "频率", description: "输出信号频率", value: "2.7GHz" },
        ],
      },
      {
        title: "频谱仪",
        parameters: [
          { name: "Span", description: "频率跨度", value: "500MHz" },
          { name: "中心频率", description: "频谱仪中心频率", value: "自动调整" },
          { name: "MAXH", description: "最大保持模式", value: "ON" },
        ],
      },
      {
        title: "开关矩阵",
        parameters: [
          { name: "路径选择", description: "信号通道选择", value: "SC边" },
        ],
      },
    ],
  },
  {
    id: 3,
    name: "镜频测试_SC2.7GHz_P1测量",
    purpose: "测量SC频段2.7GHz主频信号功率P1",
    categories: [
      {
        title: "信号源",
        parameters: [
          { name: "RF Power", description: "射频功率输出", value: "-25dBm" },
          { name: "频率", description: "输出信号频率", value: "2.7GHz" },
          { name: "RF输出", description: "射频输出开关", value: "ON" },
        ],
      },
      {
        title: "频谱仪",
        parameters: [
          { name: "中心频率", description: "频谱仪中心频率", value: "2.7GHz" },
          { name: "Span", description: "频率跨度", value: "500MHz" },
          { name: "MAXH", description: "最大保持模式", value: "ON" },
          { name: "Detector", description: "检测器类型", value: "Peak" },
          { name: "Sweeptime", description: "扫描时间", value: "1ms" },
        ],
      },
      {
        title: "数据采集",
        parameters: [
          { name: "读取项", description: "采集数据类型", value: "Max Peak功率(P1)" },
          { name: "计算逻辑", description: "数据处理公式", value: "P1=FreqSpan[0].PowerValue" },
        ],
      },
    ],
  },
  {
    id: 4,
    name: "镜频测试_SC2.7GHz_P2测量",
    purpose: "测量SC频段3.88GHz镜像频信号功率P2",
    categories: [
      {
        title: "信号源",
        parameters: [
          { name: "RF Power", description: "射频功率输出", value: "-25dBm" },
          { name: "频率", description: "输出信号频率（保持）", value: "2.7GHz" },
        ],
      },
      {
        title: "频谱仪",
        parameters: [
          { name: "中心频率", description: "频谱仪中心频率", value: "3.88GHz" },
          { name: "Span", description: "频率跨度", value: "500MHz" },
          { name: "MAXH", description: "最大保持模式", value: "ON" },
          { name: "Detector", description: "检测器类型", value: "Peak" },
          { name: "Sweeptime", description: "扫描时间", value: "1ms" },
        ],
      },
      {
        title: "数据采集",
        parameters: [
          { name: "读取项", description: "采集数据类型", value: "Max Peak功率(P2)" },
          { name: "计算逻辑", description: "数据处理公式", value: "P2=FreqSpan[1].PowerValue" },
          { name: "判定标准", description: "合格判定条件", value: "镜频抑制比(P1-P2) > 7dB" },
        ],
      },
    ],
  },
  {
    id: 5,
    name: "镜频测试_SC6.2GHz_P1测量",
    purpose: "测量SC频段6.2GHz主频信号功率P1",
    categories: [
      {
        title: "信号源",
        parameters: [
          { name: "RF Power", description: "射频功率输出", value: "-25dBm" },
          { name: "频率", description: "输出信号频率", value: "6.2GHz" },
        ],
      },
      {
        title: "频谱仪",
        parameters: [
          { name: "中心频率", description: "频谱仪中心频率", value: "6.2GHz" },
          { name: "Span", description: "频率跨度", value: "500MHz" },
          { name: "MAXH", description: "最大保持模式", value: "ON" },
        ],
      },
      {
        title: "数据采集",
        parameters: [
          { name: "读取项", description: "采集数据类型", value: "Max Peak功率(P1)" },
        ],
      },
    ],
  },
  {
    id: 6,
    name: "镜频测试_SC6.2GHz_P2测量",
    purpose: "测量SC频段5.88GHz镜像频信号功率P2",
    categories: [
      {
        title: "频谱仪",
        parameters: [
          { name: "中心频率", description: "频谱仪中心频率", value: "5.88GHz" },
          { name: "Span", description: "频率跨度", value: "500MHz" },
          { name: "MAXH", description: "最大保持模式", value: "ON" },
        ],
      },
      {
        title: "数据采集",
        parameters: [
          { name: "读取项", description: "采集数据类型", value: "Max Peak功率(P2)" },
          { name: "判断逻辑", description: "数据处理", value: "镜频抑制比=P1-P2" },
        ],
      },
    ],
  },
  {
    id: 7,
    name: "镜频测试_X频段_通道切换",
    purpose: "验证X频段信号通道的镜像抑制比",
    categories: [
      {
        title: "信号源",
        parameters: [
          { name: "RF Power", description: "射频功率输出", value: "-40dBm" },
        ],
      },
      {
        title: "开关矩阵",
        parameters: [
          { name: "路径选择", description: "信号通道选择", value: "X边" },
        ],
      },
    ],
  },
  {
    id: 8,
    name: "镜频测试_X8GHz_P1测量",
    purpose: "测量X频段8GHz主频信号功率P1",
    categories: [
      {
        title: "信号源",
        parameters: [
          { name: "RF Power", description: "射频功率输出", value: "-40dBm" },
          { name: "频率", description: "输出信号频率", value: "8GHz" },
        ],
      },
      {
        title: "频谱仪",
        parameters: [
          { name: "中心频率", description: "频谱仪中心频率", value: "8GHz" },
          { name: "Span", description: "频率跨度", value: "500MHz" },
          { name: "MAXH", description: "最大保持模式", value: "ON" },
        ],
      },
      {
        title: "数据采集",
        parameters: [
          { name: "读取项", description: "采集数据类型", value: "Max Peak功率(P1)" },
        ],
      },
    ],
  },
  {
    id: 9,
    name: "镜频测试_X8GHz_P2测量",
    purpose: "测量X频段11GHz镜像频信号功率P2",
    categories: [
      {
        title: "信号源",
        parameters: [
          { name: "RF Power", description: "射频功率输出", value: "-40dBm" },
          { name: "频率", description: "输出信号频率（保持）", value: "8GHz" },
        ],
      },
      {
        title: "频谱仪",
        parameters: [
          { name: "中心频率", description: "频谱仪中心频率", value: "11GHz" },
          { name: "Span", description: "频率跨度", value: "500MHz" },
          { name: "MAXH", description: "最大保持模式", value: "ON" },
        ],
      },
      {
        title: "数据采集",
        parameters: [
          { name: "读取项", description: "采集数据类型", value: "Max Peak功率(P2)" },
          { name: "判断逻辑", description: "数据处理", value: "镜频抑制比=P1-P2" },
        ],
      },
    ],
  },
  {
    id: 10,
    name: "镜频测试_X12GHz_P1测量",
    purpose: "测量X频段12GHz主频信号功率P1",
    categories: [
      {
        title: "信号源",
        parameters: [
          { name: "RF Power", description: "射频功率输出", value: "-40dBm" },
          { name: "频率", description: "输出信号频率", value: "12GHz" },
        ],
      },
      {
        title: "频谱仪",
        parameters: [
          { name: "中心频率", description: "频谱仪中心频率", value: "12GHz" },
          { name: "Span", description: "频率跨度", value: "500MHz" },
          { name: "MAXH", description: "最大保持模式", value: "ON" },
        ],
      },
      {
        title: "数据采集",
        parameters: [
          { name: "读取项", description: "采集数据类型", value: "Max Peak功率(P1)" },
        ],
      },
    ],
  },
  {
    id: 11,
    name: "镜频测试_X12GHz_P2测量",
    purpose: "测量X频段15GHz镜像频信号功率P2",
    categories: [
      {
        title: "频谱仪",
        parameters: [
          { name: "中心频率", description: "频谱仪中心频率", value: "15GHz" },
          { name: "Span", description: "频率跨度", value: "500MHz" },
          { name: "MAXH", description: "最大保持模式", value: "ON" },
        ],
      },
      {
        title: "数据采集",
        parameters: [
          { name: "读取项", description: "采集数据类型", value: "Max Peak功率(P2)" },
          { name: "判断逻辑", description: "数据处理", value: "镜频抑制比=P1-P2" },
        ],
      },
    ],
  },
  {
    id: 12,
    name: "断电测试_仪器资源回收",
    purpose: "断开所有设备供电并释放资源",
    categories: [
      {
        title: "信号源",
        parameters: [
          { name: "射频输出", description: "RF输出开关状态", value: "OFF" },
          { name: "远程控制", description: "远程控制模式", value: "OFF" },
        ],
      },
      {
        title: "频谱仪",
        parameters: [
          { name: "远程控制", description: "远程控制模式", value: "OFF" },
        ],
      },
      {
        title: "开关矩阵",
        parameters: [
          { name: "路径状态", description: "输出路径配置", value: "阻断所有路径" },
          { name: "远程控制", description: "远程控制模式", value: "OFF" },
        ],
      },
      {
        title: "直流电源",
        parameters: [
          { name: "输出状态", description: "电源输出开关", value: "关闭" },
          { name: "降压速率", description: "电压下降速度限制", value: "≤5V/s" },
        ],
      },
    ],
  },
];
