fix: DDS couldn't apply
This commit is contained in:
parent
c39f688115
commit
9b2ee8ad46
|
@ -12,6 +12,7 @@ clean:
|
|||
rm -rf "server.test/bin"
|
||||
rm -rf "server.test/obj"
|
||||
rm -rf "dist"
|
||||
rm -rf "wwwroot"
|
||||
|
||||
update:
|
||||
npm install
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -253,7 +253,7 @@ const waveformSlots = ref<
|
|||
{ name: "正弦波", type: "sine", data: null },
|
||||
{ name: "方波", type: "square", 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,
|
||||
0,
|
||||
currentWaveformIndex.value,
|
||||
frequency.value * Math.pow(2, 32 - 20),
|
||||
toInteger( frequency.value * Math.pow(2, 32 - 20) / 10 ),
|
||||
);
|
||||
if (!ret) {
|
||||
dialog.error("应用失败");
|
||||
|
|
|
@ -34,6 +34,9 @@ const eqps = useEquipments();
|
|||
const bitstreamFile = ref<File | null>();
|
||||
|
||||
watchEffect(() => {
|
||||
console.log(
|
||||
`board监听改动: ${props.size} ${props.boardAddr}:${props.boardPort}`,
|
||||
);
|
||||
eqps.setAddr(props.boardAddr);
|
||||
eqps.setPort(props.boardPort);
|
||||
});
|
||||
|
@ -64,14 +67,12 @@ defineExpose({
|
|||
</script>
|
||||
|
||||
<script lang="tsx">
|
||||
const eqps = useEquipments();
|
||||
// 添加一个静态方法来获取默认props
|
||||
export function getDefaultProps(): MotherBoardProps {
|
||||
console.log(`board监听改动: ${eqps.boardAddr}:${eqps.boardPort}`);
|
||||
return {
|
||||
size: 1,
|
||||
boardAddr: eqps.boardAddr,
|
||||
boardPort: eqps.boardPort.toString(),
|
||||
boardAddr: "127.0.0.1",
|
||||
boardPort: "1234",
|
||||
};
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -410,36 +410,58 @@ async function handleComponentSelected(componentData: DiagramPart | null) {
|
|||
|
||||
if (moduleRef) {
|
||||
try {
|
||||
// 使用组件配置工具创建配置项
|
||||
// 创建属性配置数组
|
||||
const propConfigs: PropertyConfig[] = [];
|
||||
|
||||
// 1. 自动获取组件属性信息 - 利用DiagramPart接口结构
|
||||
const directPropConfigs = generatePropertyConfigs(componentData);
|
||||
propConfigs.push(...directPropConfigs);
|
||||
// 创建一个映射来跟踪已添加的属性名
|
||||
const addedProps = new Set<string>();
|
||||
|
||||
// 2. 尝试使用组件导出的getDefaultProps方法获取配置
|
||||
// 1. 首先从getDefaultProps方法获取默认配置
|
||||
if (typeof moduleRef.getDefaultProps === "function") {
|
||||
// 从getDefaultProps方法构建配置
|
||||
const defaultProps = moduleRef.getDefaultProps();
|
||||
const defaultPropConfigs = generatePropsFromDefault(defaultProps);
|
||||
propConfigs.push(...defaultPropConfigs);
|
||||
|
||||
selectedComponentConfig.value = { props: propConfigs };
|
||||
console.log(
|
||||
`Built config for ${componentData.type} from getDefaultProps:`,
|
||||
selectedComponentConfig.value,
|
||||
);
|
||||
} 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 };
|
||||
// 添加默认配置并记录属性名
|
||||
defaultPropConfigs.forEach((config) => {
|
||||
propConfigs.push(config);
|
||||
addedProps.add(config.name);
|
||||
});
|
||||
}
|
||||
|
||||
// 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) {
|
||||
console.error(
|
||||
`Error building config for ${componentData.type}:`,
|
||||
|
|
Loading…
Reference in New Issue