优化求解器重试并校正AMESim机械端口

This commit is contained in:
huojiarong committed 2026-08-03 09:54:46 +00:00
1 parent 971e8f2336
commit 18d9802f03
15 files changed
+383 -166

No files matched your search

+16 -1
View File
@@ -5967,7 +5967,7 @@ function normalizeLoadedPorts(
return definition?.ports.map((port) => ({ ...port })) ?? [];
}
return rawPorts.flatMap((rawPort, index) => {
const loadedPorts = rawPorts.flatMap((rawPort, index) => {
const record =
rawPort !== null && typeof rawPort === "object"
? (rawPort as Record<string, unknown>)
@@ -6004,6 +6004,21 @@ function normalizeLoadedPorts(
},
];
});
if (!definition) {
return loadedPorts;
}
const loadedByName = new Map(loadedPorts.map((port) => [port.name, port]));
const registeredNames = new Set(definition.ports.map((port) => port.name));
return [
...definition.ports.map((registered) => ({
...(loadedByName.get(registered.name) ?? registered),
// Port placement is versioned catalog metadata, just like the symbol.
// Prefer it so projects saved with an incorrect display order are upgraded.
side: registered.side,
})),
...loadedPorts.filter((port) => !registeredNames.has(port.name)),
];
}
function isPortNominalRole(value: unknown): value is PortNominalRole {