fix: DDS couldn't apply

This commit is contained in:
2025-05-17 13:10:00 +08:00
parent c39f688115
commit 9b2ee8ad46
5 changed files with 512 additions and 390 deletions

View File

@@ -12,6 +12,7 @@ clean:
rm -rf "server.test/bin" rm -rf "server.test/bin"
rm -rf "server.test/obj" rm -rf "server.test/obj"
rm -rf "dist" rm -rf "dist"
rm -rf "wwwroot"
update: update:
npm install npm install

File diff suppressed because it is too large Load Diff

View File

@@ -253,7 +253,7 @@ const waveformSlots = ref<
{ name: "正弦波", type: "sine", data: null }, { name: "正弦波", type: "sine", data: null },
{ name: "方波", type: "square", data: null }, { name: "方波", type: "square", data: null },
{ name: "三角波", type: "triangle", data: null }, { name: "三角波", type: "triangle", data: null },
{ name: "", type: "", data: null }, { name: "锯齿波", type: "sawtooth", data: null },
]); ]);
// 绘图相关 // 绘图相关
@@ -408,7 +408,7 @@ async function applyOutputWave() {
eqps.boardPort, eqps.boardPort,
0, 0,
currentWaveformIndex.value, currentWaveformIndex.value,
frequency.value * Math.pow(2, 32 - 20), toInteger( frequency.value * Math.pow(2, 32 - 20) / 10 ),
); );
if (!ret) { if (!ret) {
dialog.error("应用失败"); dialog.error("应用失败");

View File

@@ -34,6 +34,9 @@ const eqps = useEquipments();
const bitstreamFile = ref<File | null>(); const bitstreamFile = ref<File | null>();
watchEffect(() => { watchEffect(() => {
console.log(
`board监听改动: ${props.size} ${props.boardAddr}:${props.boardPort}`,
);
eqps.setAddr(props.boardAddr); eqps.setAddr(props.boardAddr);
eqps.setPort(props.boardPort); eqps.setPort(props.boardPort);
}); });
@@ -64,14 +67,12 @@ defineExpose({
</script> </script>
<script lang="tsx"> <script lang="tsx">
const eqps = useEquipments();
// 添加一个静态方法来获取默认props // 添加一个静态方法来获取默认props
export function getDefaultProps(): MotherBoardProps { export function getDefaultProps(): MotherBoardProps {
console.log(`board监听改动: ${eqps.boardAddr}:${eqps.boardPort}`);
return { return {
size: 1, size: 1,
boardAddr: eqps.boardAddr, boardAddr: "127.0.0.1",
boardPort: eqps.boardPort.toString(), boardPort: "1234",
}; };
} }
</script> </script>

View File

@@ -410,36 +410,58 @@ async function handleComponentSelected(componentData: DiagramPart | null) {
if (moduleRef) { if (moduleRef) {
try { try {
// 使用组件配置工具创建配置项 // 创建属性配置数组
const propConfigs: PropertyConfig[] = []; const propConfigs: PropertyConfig[] = [];
// 1. 自动获取组件属性信息 - 利用DiagramPart接口结构 // 创建一个映射来跟踪已添加的属性名
const directPropConfigs = generatePropertyConfigs(componentData); const addedProps = new Set<string>();
propConfigs.push(...directPropConfigs);
// 2. 尝试使用组件导出的getDefaultProps方法获取配置 // 1. 首先从getDefaultProps方法获取默认配置
if (typeof moduleRef.getDefaultProps === "function") { if (typeof moduleRef.getDefaultProps === "function") {
// 从getDefaultProps方法构建配置
const defaultProps = moduleRef.getDefaultProps(); const defaultProps = moduleRef.getDefaultProps();
const defaultPropConfigs = generatePropsFromDefault(defaultProps); const defaultPropConfigs = generatePropsFromDefault(defaultProps);
propConfigs.push(...defaultPropConfigs);
selectedComponentConfig.value = { props: propConfigs }; // 添加默认配置并记录属性名
console.log( defaultPropConfigs.forEach((config) => {
`Built config for ${componentData.type} from getDefaultProps:`, propConfigs.push(config);
selectedComponentConfig.value, addedProps.add(config.name);
); });
} else {
console.warn(
`Component ${componentData.type} does not export getDefaultProps method.`,
);
// 创建一个空配置,只显示组件提供的属性
const attrs = componentData.attrs || {};
const attrPropConfigs = generatePropsFromAttrs(attrs);
propConfigs.push(...attrPropConfigs);
selectedComponentConfig.value = { props: propConfigs };
} }
// 2. 添加组件直接属性,这些属性会覆盖默认配置
const directPropConfigs = generatePropertyConfigs(componentData);
// 过滤掉已经添加过的属性名
const newDirectProps = directPropConfigs.filter(
(config) => !addedProps.has(config.name),
);
propConfigs.push(...newDirectProps);
// 3. 最后添加attrs中的属性
if (componentData.attrs) {
const attrs = componentData.attrs;
const attrPropConfigs = generatePropsFromAttrs(attrs);
// 更新已存在的属性值,或添加新属性
attrPropConfigs.forEach((attrConfig) => {
const existingIndex = propConfigs.findIndex(
(p) => p.name === attrConfig.name,
);
if (existingIndex >= 0) {
// 更新已存在的属性值
propConfigs[existingIndex] = attrConfig;
} else {
// 添加新属性
propConfigs.push(attrConfig);
}
});
}
selectedComponentConfig.value = { props: propConfigs };
console.log(
`Built config for ${componentData.type}:`,
selectedComponentConfig.value,
);
} catch (error) { } catch (error) {
console.error( console.error(
`Error building config for ${componentData.type}:`, `Error building config for ${componentData.type}:`,