-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #83 from tscircuit/feat/fix-subcircuit-id
fix: update the source_trace name to save more info for later stage
- Loading branch information
Showing
7 changed files
with
559 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import type { | ||
AnyCircuitElement, | ||
SourceComponentBase, | ||
SourcePort, | ||
} from "circuit-json" | ||
|
||
interface SourcePortInfo { | ||
displayName: string | ||
} | ||
|
||
export function getCombinedSourcePortName( | ||
circuitElements: AnyCircuitElement[], | ||
connectedSourcePortIds: string[], | ||
): string { | ||
const portInfos: SourcePortInfo[] = [] | ||
|
||
for (const portId of connectedSourcePortIds) { | ||
// Find the source port | ||
const sourcePort = circuitElements.find( | ||
(el) => el.type === "source_port" && el.source_port_id === portId, | ||
) as SourcePort | undefined | ||
|
||
if (!sourcePort) continue | ||
|
||
// Find the associated component | ||
const sourceComponent = circuitElements.find( | ||
(el) => | ||
el.type === "source_component" && | ||
el.source_component_id === sourcePort.source_component_id, | ||
) as SourceComponentBase | ||
|
||
if (!sourceComponent) continue | ||
|
||
// Construct display name combining component name and port name | ||
const componentName = | ||
sourceComponent.name || sourceComponent.source_component_id | ||
const portName = | ||
sourcePort.name || sourcePort.pin_number?.toString() || portId | ||
|
||
portInfos.push({ | ||
displayName: `Pad${portName.replace("pin", "")}_${componentName}_${sourcePort.source_component_id}`, | ||
}) | ||
} | ||
|
||
return portInfos.map((p) => p.displayName).join("--") | ||
} |
Oops, something went wrong.