完善AMESim组件界面与仿真求解稳定性

This commit is contained in:
ljz committed 2026-08-02 00:57:48 +08:00
1 parent e7177ab03e
commit 410ef535e8
34 files changed
+3340 -251

No files matched your search

+59 -52
View File
@@ -1,39 +1,43 @@
import type { ReactNode } from "react";
import { AmesimPnpl01Symbol } from "./componentSymbols/boundary";
import {
AmesimF000Symbol,
AmesimForcSymbol,
AmesimLmechn1Symbol,
AmesimLstp00aSymbol,
AmesimMecmas21Symbol,
} from "./componentSymbols/mechanical";
import {
AmesimHeliumMediumSymbol,
AmesimIdealAirMediumSymbol,
} from "./componentSymbols/media";
import {
AmesimPn3Node2Symbol,
AmesimP4Node2Symbol,
AmesimPnl0001Symbol,
AmesimPnl0002Symbol,
AmesimPnl0003Symbol,
AmesimPnl00rSymbol,
AmesimPnor001Symbol,
AmesimPnvo001FixedSymbol,
AmesimPnvo001SignalSymbol,
} from "./componentSymbols/pneumatic";
import { SymbolSvg } from "./componentSymbols/primitives";
import { AmesimStep0Symbol, AmesimUd00Symbol } from "./componentSymbols/signals";
import { AmesimPnch012Symbol, AmesimPnch023Symbol } from "./componentSymbols/storage";
import type {
ComponentSymbolPresentation,
SymbolDefinition,
} from "./componentSymbols/types";
export type { ComponentSymbolPresentation } from "./componentSymbols/types";
export type ComponentSymbolSurface = "palette" | "canvas";
export type ComponentSymbolPresentation = "framed" | "bare";
type ComponentSymbolProps = {
symbol: string;
surface: ComponentSymbolSurface;
className?: string;
};
type SymbolDefinition = {
presentation: ComponentSymbolPresentation;
render: () => ReactNode;
};
type SymbolSvgProps = {
children: ReactNode;
className?: string;
};
function SymbolSvg({ children, className }: SymbolSvgProps) {
return (
<svg
aria-hidden="true"
className={["component-symbol-svg", className].filter(Boolean).join(" ")}
fill="none"
focusable="false"
viewBox="0 0 64 48"
xmlns="http://www.w3.org/2000/svg"
>
{children}
</svg>
);
}
function CylinderSymbol() {
return (
<SymbolSvg>
@@ -145,28 +149,6 @@ function JunctionSymbol() {
);
}
function MediumSymbol({ label }: { label: "Air" | "He" }) {
return (
<SymbolSvg className="component-symbol-medium-svg">
<circle cx="32" cy="24" fill="#ffffff" r="22" stroke="#c026d3" strokeWidth="2" />
<text
className="component-symbol-medium-label"
data-symbol-label={label}
dominantBaseline="central"
fill="#a21caf"
fontFamily="Arial, sans-serif"
fontSize={label === "Air" ? 12 : 16}
fontWeight="500"
textAnchor="middle"
x="32"
y="24"
>
{label}
</text>
</SymbolSvg>
);
}
const symbolRegistry = {
cylinder: { presentation: "framed", render: CylinderSymbol },
tank: { presentation: "framed", render: TankSymbol },
@@ -176,13 +158,38 @@ const symbolRegistry = {
generic: { presentation: "framed", render: GenericSymbol },
signal: { presentation: "framed", render: SignalSymbol },
junction: { presentation: "framed", render: JunctionSymbol },
amesim_pnpl01: { presentation: "framed", render: AmesimPnpl01Symbol },
amesim_pnch023: { presentation: "framed", render: AmesimPnch023Symbol },
amesim_pnch012: { presentation: "framed", render: AmesimPnch012Symbol },
amesim_pnor001: { presentation: "framed", render: AmesimPnor001Symbol },
amesim_pnvo001_fixed: {
presentation: "framed",
render: AmesimPnvo001FixedSymbol,
},
amesim_pnvo001: {
presentation: "framed",
render: AmesimPnvo001SignalSymbol,
},
amesim_pnl00r: { presentation: "framed", render: AmesimPnl00rSymbol },
amesim_pnl0001: { presentation: "framed", render: AmesimPnl0001Symbol },
amesim_pnl0002: { presentation: "framed", render: AmesimPnl0002Symbol },
amesim_pnl0003: { presentation: "framed", render: AmesimPnl0003Symbol },
amesim_pn3node2: { presentation: "framed", render: AmesimPn3Node2Symbol },
amesim_p4node2: { presentation: "framed", render: AmesimP4Node2Symbol },
amesim_step0: { presentation: "framed", render: AmesimStep0Symbol },
amesim_ud00: { presentation: "framed", render: AmesimUd00Symbol },
amesim_f000: { presentation: "framed", render: AmesimF000Symbol },
amesim_forc: { presentation: "framed", render: AmesimForcSymbol },
amesim_mecmas21: { presentation: "framed", render: AmesimMecmas21Symbol },
amesim_lstp00a: { presentation: "framed", render: AmesimLstp00aSymbol },
amesim_lmechn1: { presentation: "framed", render: AmesimLmechn1Symbol },
amesim_ideal_air_medium: {
presentation: "bare",
render: () => <MediumSymbol label="Air" />,
render: AmesimIdealAirMediumSymbol,
},
amesim_helium_medium: {
presentation: "bare",
render: () => <MediumSymbol label="He" />,
render: AmesimHeliumMediumSymbol,
},
} satisfies Record<string, SymbolDefinition>;