This repository has been archived on 2025-10-29. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
FPGA_WebLab/src/components/LabCanvas/index.ts
2025-07-12 21:55:58 +08:00

111 lines
2.9 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import motherboardSvg from "@/components/equipments/svg/motherboard.svg";
import buttonSvg from "@/components/equipments/svg/button.svg";
// 元器件配置接口
export interface ComponentConfig {
type: string;
name: string;
previewSize?: number;
}
// 虚拟外设配置接口
export interface VirtualDeviceConfig {
type: string;
name: string;
previewSize?: number;
}
// 模板配置接口
export interface TemplateConfig {
name: string;
id: string;
description: string;
path: string;
thumbnailUrl: string;
capsPage?: string;
}
// 预览尺寸配置
export const previewSizes: Record<string, number> = {
MechanicalButton: 0.4,
Switch: 0.35,
Pin: 0.8,
SMT_LED: 0.7,
SevenSegmentDisplay: 0.4,
HDMI: 0.5,
DDR: 0.5,
ETH: 0.5,
SD: 0.6,
SFP: 0.4,
SMA: 0.7,
MotherBoard: 0.13,
PG2L100H_FBG676: 0.2,
BaseBoard: 0.15,
DDS: 0.3,
};
// 可用元器件列表
export const availableComponents: ComponentConfig[] = [
{ type: "MechanicalButton", name: "机械按钮" },
{ type: "Switch", name: "开关" },
{ type: "Pin", name: "引脚" },
{ type: "SMT_LED", name: "贴片LED" },
{ type: "SevenSegmentDisplay", name: "数码管" },
{ type: "HDMI", name: "HDMI接口" },
{ type: "DDR", name: "DDR内存" },
{ type: "ETH", name: "以太网接口" },
{ type: "SD", name: "SD卡插槽" },
{ type: "SFP", name: "SFP光纤模块" },
{ type: "SMA", name: "SMA连接器" },
{ type: "MotherBoard", name: "主板" },
{ type: "PG2L100H_FBG676", name: "PG2L100H FBG676芯片" },
{ type: "BaseBoard", name: "通用底板" },
];
// 可用虚拟外设列表
export const availableVirtualDevices: VirtualDeviceConfig[] = [
{ type: "DDS", name: "信号发生器" },
];
// 可用模板列表
export const availableTemplates: TemplateConfig[] = [
{
name: "PG2L100H 基础开发板",
id: "PG2L100H_Pango100pro",
description: "包含主板和两个LED的基本设置",
path: "/EquipmentTemplates/PG2L100H_Pango100pro.json",
thumbnailUrl: motherboardSvg,
},
{
name: "矩阵键盘",
id: "MatrixKey",
description: "包含4x4共16个按键的矩阵键盘",
path: "/EquipmentTemplates/MatrixKey.json",
thumbnailUrl: buttonSvg,
},
];
// 获取组件预览尺寸的工具函数
export function getPreviewSize(componentType: string): number {
return previewSizes[componentType] || 0.5;
}
// 获取所有组件类型(用于预加载)
export function getAllComponentTypes(): string[] {
const componentTypes = availableComponents.map((c) => c.type);
const virtualDeviceTypes = availableVirtualDevices.map((d) => d.type);
return [...componentTypes, ...virtualDeviceTypes];
}
// 导出组件管理器服务
export {
useProvideComponentManager,
useComponentManager,
} from "./composable/componentManager";
// 导出图表管理器
export type { DiagramData, DiagramPart } from "./composable/diagramManager";
// 导出连线管理器
export type { WireItem } from "./composable/wireManager";