Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: subcircuit with same name #78

Merged
merged 3 commits into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ export function processComponentsAndPads(
const componentEntry = {
name: footprintName,
places: components.map((component) => ({
refdes: component.componentName,
refdes: `${component.componentName}_${component.sourceComponent?.source_component_id}`,
x: component.coordinates.x,
y: component.coordinates.y,
side: "front" as const,
Expand Down
4 changes: 2 additions & 2 deletions lib/dsn-pcb/circuit-json-to-dsn-json/process-nets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export function processNets(circuitElements: AnyCircuitElement[], pcb: DsnPcb) {
)

padsBySourcePortId.set(sourcePort.source_port_id, {
componentName,
componentName: `${componentName}_${sourcePort.source_component_id}`,
pinNumber,
sourcePortId: sourcePort.source_port_id,
})
Expand Down Expand Up @@ -119,7 +119,7 @@ export function processNets(circuitElements: AnyCircuitElement[], pcb: DsnPcb) {
// Add source nets (GND, VCC, etc.)
for (const element of circuitElements) {
if (element.type === "source_net") {
const netName = element.name
const netName = `${element.name}_${element.source_net_id}`
if (!netMap.has(netName)) {
netMap.set(netName, new Set())
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,27 @@ export function convertDsnSessionToCircuitJson(
// Find corresponding source trace for this net
const sourceTrace = existingSourceTraces.find((st) => {
const sourceNetIds = (st as any).connected_source_net_ids || []
const sourceNet = inputPcbElms.find(
(elm) =>
elm.type === "source_net" &&
elm.name === net.name &&
sourceNetIds.includes(elm.source_net_id),
)
const sourceNet = inputPcbElms.find((elm) => {
if (elm.type === "source_net") {
if (elm.name.startsWith("Net")) {
// For connected nets (Net-1, Net-2, etc.)
const modifiedName = elm.name.replace(/_source_component_.+?-/, "-")
return (
elm.type === "source_net" &&
modifiedName === net.name &&
sourceNetIds.includes(elm.source_net_id)
)
} else {
// For GND,VCC etc
const modifiedName = elm.name.split("_")[0]
return (
elm.type === "source_net" &&
modifiedName === net.name &&
sourceNetIds.includes(elm.source_net_id)
)
}
}
})
return sourceNet !== undefined
})

Expand Down
Loading
Loading