import WaveformDisplay from "./WaveformDisplay.vue";

export type LogicDataType = {
  x: number[];
  y: {
    enabled: boolean;
    type: "logic" | "number";
    name: string;
    color: string;
    value: number[];
    base: "bin" | "dec" | "hex";
  }[];
  xUnit: "s" | "ms" | "us" | "ns";
};

// 生成4路测试数据的函数
export function generateTestData(): LogicDataType {
  // 生成时间轴数据 (0-100ns，每1ns一个采样点)
  const timePoints = Array.from({ length: 101 }, (_, i) => i);

  return {
    x: timePoints,
    y: [
      {
        enabled: true,
        type: "logic",
        name: "CLK",
        color: "#ff0000",
        value: timePoints.map((t) => t % 2), // 时钟信号，每1ns翻转
        base: "bin",
      },
      {
        enabled: true,
        type: "logic",
        name: "RESET",
        color: "#00ff00",
        value: timePoints.map((t) => (t < 10 ? 1 : 0)), // 复位信号，前10ns为高电平
        base: "bin",
      },
      {
        enabled: true,
        type: "number",
        name: "DATA",
        color: "#0000ff",
        value: timePoints.map((t) => Math.floor(t / 4) % 16), // 计数器，每4ns递增
        base: "hex",
      },
      {
        enabled: true,
        type: "logic",
        name: "ENABLE",
        color: "#ff8800",
        value: timePoints.map((t) => (t >= 20 && t < 80 ? 1 : 0)), // 使能信号，20-80ns为高电平
        base: "bin",
      },
    ],
    xUnit: "ns",
  };
}

export { WaveformDisplay };
