C内核流量计算方法优化,前端文件名称读取优化
This commit is contained in:
1 parent
5d5a2e1843
commit
808c484f5b
94 files changed
+20163
-4418
No files matched your search
@@ -1,4 +1,5 @@
|
||||
import { expect, test, type Locator, type Page } from "@playwright/test";
|
||||
import { readFileSync } from "node:fs";
|
||||
|
||||
import { expandSimulationConsole } from "./fixtures";
|
||||
|
||||
@@ -2439,8 +2440,8 @@ test("PN3NODE2 与 P4NODE2 使用参考图直线汇流结构且粗线对应 port
|
||||
anchors: [
|
||||
{ portName: "port_1", x: 32, y: 11.2 },
|
||||
{ portName: "port_2", x: 19.2, y: 24 },
|
||||
{ portName: "port_3", x: 44.8, y: 24 },
|
||||
{ portName: "port_4", x: 32, y: 36.8 },
|
||||
{ portName: "port_3", x: 32, y: 36.8 },
|
||||
{ portName: "port_4", x: 44.8, y: 24 },
|
||||
],
|
||||
center: { x: 32, y: 24 },
|
||||
finePath: "M32 11.2V36.8M32 24H44.8M19.2 24H22.1",
|
||||
@@ -2448,8 +2449,8 @@ test("PN3NODE2 与 P4NODE2 使用参考图直线汇流结构且粗线对应 port
|
||||
positions: {
|
||||
port_1: "top",
|
||||
port_2: "left",
|
||||
port_3: "right",
|
||||
port_4: "bottom",
|
||||
port_3: "bottom",
|
||||
port_4: "right",
|
||||
},
|
||||
thickPath: "M22.1 24H32",
|
||||
},
|
||||
@@ -2505,6 +2506,57 @@ test("PN3NODE2 与 P4NODE2 使用参考图直线汇流结构且粗线对应 port
|
||||
}
|
||||
});
|
||||
|
||||
test("P4NODE2 的真实 Handle 在 180° 时匹配 AME 四口方位,镜像后参考粗线仍指向 port_2", async ({ page }) => {
|
||||
const source = JSON.parse(readFileSync(new URL(
|
||||
"../../../tests/model_audit/p4node2-ame-geometry.json", import.meta.url,
|
||||
), "utf8")) as {
|
||||
components: Array<{ geometry: number; ports: Record<string, { x: number; y: number }> }>;
|
||||
};
|
||||
// Independent AME COMP_PORT/PORT_POS coordinates, rather than frontend anchors.
|
||||
const amePorts = source.components[0].ports;
|
||||
for (const component of source.components) {
|
||||
expect(component.geometry).toBe(1);
|
||||
expect(component.ports).toEqual(amePorts);
|
||||
}
|
||||
const ameCenter = Object.values(amePorts).reduce(
|
||||
(sum, port) => ({ x: sum.x + port.x / 4, y: sum.y + port.y / 4 }),
|
||||
{ x: 0, y: 0 },
|
||||
);
|
||||
await page.goto("/");
|
||||
const node = await dragSymbolToCanvas(page, "amesim_p4node2", { x: 460, y: 320 });
|
||||
const rotate = page.getByRole("button", { name: "顺时针旋转 90° (Ctrl+R)", exact: true });
|
||||
await rotate.click();
|
||||
await rotate.click();
|
||||
const svg = node.locator('[data-component-symbol="amesim_p4node2"] svg');
|
||||
const getDirection = async (portName: string) => {
|
||||
const center = await locatorCenter(svg.locator('[data-junction-part="center"]'));
|
||||
const handle = await locatorCenter(node.locator(`.port-handle[data-port-name="${portName}"]`));
|
||||
const length = Math.hypot(handle.x - center.x, handle.y - center.y);
|
||||
expect(length).toBeGreaterThan(1);
|
||||
return { x: (handle.x - center.x) / length, y: (handle.y - center.y) / length };
|
||||
};
|
||||
for (const [portName, coordinate] of Object.entries(amePorts)) {
|
||||
const length = Math.hypot(coordinate.x - ameCenter.x, coordinate.y - ameCenter.y);
|
||||
await expect.poll(async () => {
|
||||
const actual = await getDirection(portName);
|
||||
return Math.hypot(actual.x - (coordinate.x - ameCenter.x) / length,
|
||||
actual.y - (coordinate.y - ameCenter.y) / length);
|
||||
}).toBeLessThan(0.02);
|
||||
}
|
||||
const expectReferenceStroke = async () => {
|
||||
const center = await locatorCenter(svg.locator('[data-junction-part="center"]'));
|
||||
const stroke = await locatorCenter(svg.locator('[data-junction-part="collector-branch"]'));
|
||||
const reference = await getDirection("port_2");
|
||||
const length = Math.hypot(stroke.x - center.x, stroke.y - center.y);
|
||||
expect((stroke.x - center.x) * reference.x + (stroke.y - center.y) * reference.y).toBeGreaterThan(0);
|
||||
expect(Math.abs((stroke.x - center.x) * reference.y - (stroke.y - center.y) * reference.x) / length).toBeLessThan(0.02);
|
||||
};
|
||||
await expectReferenceStroke();
|
||||
await page.getByRole("button", { name: "水平镜像 (Shift+H)", exact: true }).click();
|
||||
await expect.poll(async () => (await getDirection("port_2")).x).toBeLessThan(-0.99);
|
||||
await expectReferenceStroke();
|
||||
});
|
||||
|
||||
test("PNL00R 与 PNL0001-0003 使用 standard 画布和 60% 工作区占比", async ({
|
||||
page,
|
||||
}) => {
|
||||
|
||||
Reference in new issue
Block a user