@tscircuit/schematic-trace-solver 0.0.194 → 0.0.195
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +19 -6
- package/lib/solvers/UnroutedTraceRecoverySolver/UnroutedTraceRecoverySolver.ts +22 -4
- package/package.json +1 -1
- package/tests/examples/__snapshots__/example46.snap.svg +21 -12
- package/tests/repros/__snapshots__/repro-ina237-current-monitor.snap.svg +17 -17
- package/tests/repros/__snapshots__/repro-pmp11282-isolated-dcdc.snap.svg +91 -82
- package/tests/repros/__snapshots__/section-autolayout-mcu.snap.svg +139 -0
- package/tests/repros/repro-pmp11282-isolated-dcdc.test.ts +4 -4
- package/tests/repros/section-autolayout-mcu.test.ts +374 -0
|
@@ -0,0 +1,374 @@
|
|
|
1
|
+
import { expect, test } from "bun:test"
|
|
2
|
+
import { SchematicTracePipelineSolver } from "lib/solvers/SchematicTracePipelineSolver/SchematicTracePipelineSolver"
|
|
3
|
+
import type { InputProblem } from "lib/types/InputProblem"
|
|
4
|
+
import "tests/fixtures/matcher"
|
|
5
|
+
|
|
6
|
+
// Captured from core's schematic-section-autolayout.test.tsx at 87d04cc,
|
|
7
|
+
// retaining the MCU components and neighboring R1, which blocks the outer detour:
|
|
8
|
+
// <capacitor name="C3" capacitance="100nF" schSectionName="mcu"
|
|
9
|
+
// connections={{ pin1: "net.VCC_3V3", pin2: "net.GND" }} />
|
|
10
|
+
// <resistor name="R2" resistance="10k" schSectionName="mcu"
|
|
11
|
+
// connections={{ pin1: "net.VCC_3V3", pin2: "net.SCL" }} />
|
|
12
|
+
// <resistor name="R3" resistance="10k" schSectionName="mcu"
|
|
13
|
+
// connections={{ pin1: "net.VCC_3V3", pin2: "net.SDA" }} />
|
|
14
|
+
// <chip name="U2" schSectionName="mcu" connections={{
|
|
15
|
+
// VCC: "net.VCC_3V3", GND: "net.GND", SCL: "net.SCL", SDA: "net.SDA"
|
|
16
|
+
// }} />
|
|
17
|
+
test("section autolayout labels blocked stacked upper terminals", () => {
|
|
18
|
+
const problem: InputProblem = {
|
|
19
|
+
chips: [
|
|
20
|
+
{
|
|
21
|
+
chipId: "schematic_component_3",
|
|
22
|
+
center: {
|
|
23
|
+
x: -5.100000000000001,
|
|
24
|
+
y: -2.958750000000001,
|
|
25
|
+
},
|
|
26
|
+
width: 1.085,
|
|
27
|
+
height: 0.5999999999999996,
|
|
28
|
+
pins: [
|
|
29
|
+
{
|
|
30
|
+
pinId: "schematic_port_11",
|
|
31
|
+
displayName: "anode",
|
|
32
|
+
x: -5.317500000000002,
|
|
33
|
+
y: -2.6587500000000013,
|
|
34
|
+
_facingDirection: "y+",
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
pinId: "schematic_port_12",
|
|
38
|
+
displayName: "cathode",
|
|
39
|
+
x: -5.317500000000002,
|
|
40
|
+
y: -3.258750000000001,
|
|
41
|
+
_facingDirection: "y-",
|
|
42
|
+
},
|
|
43
|
+
],
|
|
44
|
+
sectionId: "power",
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
chipId: "schematic_component_4",
|
|
48
|
+
center: {
|
|
49
|
+
x: 2.157499999999999,
|
|
50
|
+
y: -4.21,
|
|
51
|
+
},
|
|
52
|
+
width: 2.4000000000000004,
|
|
53
|
+
height: 1.7999999999999994,
|
|
54
|
+
pins: [
|
|
55
|
+
{
|
|
56
|
+
pinId: "schematic_port_13",
|
|
57
|
+
displayName: "VCC",
|
|
58
|
+
x: 0.9574999999999987,
|
|
59
|
+
y: -3.51,
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
pinId: "schematic_port_14",
|
|
63
|
+
displayName: "GND",
|
|
64
|
+
x: 0.9574999999999987,
|
|
65
|
+
y: -3.71,
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
pinId: "schematic_port_15",
|
|
69
|
+
displayName: "PB0",
|
|
70
|
+
x: 0.9574999999999987,
|
|
71
|
+
y: -3.91,
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
pinId: "schematic_port_16",
|
|
75
|
+
displayName: "PB1",
|
|
76
|
+
x: 0.9574999999999987,
|
|
77
|
+
y: -4.11,
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
pinId: "schematic_port_17",
|
|
81
|
+
displayName: "PB2",
|
|
82
|
+
x: 0.9574999999999987,
|
|
83
|
+
y: -4.3100000000000005,
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
pinId: "schematic_port_18",
|
|
87
|
+
displayName: "PB3",
|
|
88
|
+
x: 0.9574999999999987,
|
|
89
|
+
y: -4.51,
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
pinId: "schematic_port_19",
|
|
93
|
+
displayName: "SDA",
|
|
94
|
+
x: 0.9574999999999987,
|
|
95
|
+
y: -4.71,
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
pinId: "schematic_port_20",
|
|
99
|
+
displayName: "SCL",
|
|
100
|
+
x: 0.9574999999999987,
|
|
101
|
+
y: -4.91,
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
pinId: "schematic_port_21",
|
|
105
|
+
displayName: "TX",
|
|
106
|
+
x: 3.357499999999999,
|
|
107
|
+
y: -3.51,
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
pinId: "schematic_port_22",
|
|
111
|
+
displayName: "RX",
|
|
112
|
+
x: 3.357499999999999,
|
|
113
|
+
y: -3.71,
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
pinId: "schematic_port_23",
|
|
117
|
+
displayName: "ADC0",
|
|
118
|
+
x: 3.357499999999999,
|
|
119
|
+
y: -3.91,
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
pinId: "schematic_port_24",
|
|
123
|
+
displayName: "ADC1",
|
|
124
|
+
x: 3.357499999999999,
|
|
125
|
+
y: -4.109999999999999,
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
pinId: "schematic_port_25",
|
|
129
|
+
displayName: "LED",
|
|
130
|
+
x: 3.357499999999999,
|
|
131
|
+
y: -4.31,
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
pinId: "schematic_port_26",
|
|
135
|
+
displayName: "RST",
|
|
136
|
+
x: 3.357499999999999,
|
|
137
|
+
y: -4.51,
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
pinId: "schematic_port_27",
|
|
141
|
+
displayName: "XTAL1",
|
|
142
|
+
x: 3.357499999999999,
|
|
143
|
+
y: -4.71,
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
pinId: "schematic_port_28",
|
|
147
|
+
displayName: "XTAL2",
|
|
148
|
+
x: 3.357499999999999,
|
|
149
|
+
y: -4.91,
|
|
150
|
+
},
|
|
151
|
+
],
|
|
152
|
+
sectionId: "mcu",
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
chipId: "schematic_component_5",
|
|
156
|
+
center: {
|
|
157
|
+
x: -0.4725000000000013,
|
|
158
|
+
y: -3.6099999999999994,
|
|
159
|
+
},
|
|
160
|
+
width: 1.04,
|
|
161
|
+
height: 0.7600000000000007,
|
|
162
|
+
pins: [
|
|
163
|
+
{
|
|
164
|
+
pinId: "schematic_port_29",
|
|
165
|
+
displayName: "pos",
|
|
166
|
+
x: -0.6675000000000013,
|
|
167
|
+
y: -3.229999999999999,
|
|
168
|
+
_facingDirection: "y+",
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
pinId: "schematic_port_30",
|
|
172
|
+
displayName: "neg",
|
|
173
|
+
x: -0.6675000000000013,
|
|
174
|
+
y: -3.9899999999999998,
|
|
175
|
+
_facingDirection: "y-",
|
|
176
|
+
},
|
|
177
|
+
],
|
|
178
|
+
sectionId: "mcu",
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
chipId: "schematic_component_6",
|
|
182
|
+
center: {
|
|
183
|
+
x: -0.4300000000000012,
|
|
184
|
+
y: -5.419999999999999,
|
|
185
|
+
},
|
|
186
|
+
width: 0.965,
|
|
187
|
+
height: 0.5999999999999996,
|
|
188
|
+
pins: [
|
|
189
|
+
{
|
|
190
|
+
pinId: "schematic_port_31",
|
|
191
|
+
displayName: "anode",
|
|
192
|
+
x: -0.5875000000000012,
|
|
193
|
+
y: -5.119999999999999,
|
|
194
|
+
_facingDirection: "y+",
|
|
195
|
+
},
|
|
196
|
+
{
|
|
197
|
+
pinId: "schematic_port_32",
|
|
198
|
+
displayName: "cathode",
|
|
199
|
+
x: -0.5875000000000012,
|
|
200
|
+
y: -5.719999999999999,
|
|
201
|
+
_facingDirection: "y-",
|
|
202
|
+
},
|
|
203
|
+
],
|
|
204
|
+
sectionId: "mcu",
|
|
205
|
+
},
|
|
206
|
+
{
|
|
207
|
+
chipId: "schematic_component_7",
|
|
208
|
+
center: {
|
|
209
|
+
x: -0.025000000000000966,
|
|
210
|
+
y: -1.7999999999999998,
|
|
211
|
+
},
|
|
212
|
+
width: 0.965,
|
|
213
|
+
height: 0.5999999999999999,
|
|
214
|
+
pins: [
|
|
215
|
+
{
|
|
216
|
+
pinId: "schematic_port_33",
|
|
217
|
+
displayName: "anode",
|
|
218
|
+
x: -0.182500000000001,
|
|
219
|
+
y: -1.5,
|
|
220
|
+
_facingDirection: "y+",
|
|
221
|
+
},
|
|
222
|
+
{
|
|
223
|
+
pinId: "schematic_port_34",
|
|
224
|
+
displayName: "cathode",
|
|
225
|
+
x: -0.182500000000001,
|
|
226
|
+
y: -2.0999999999999996,
|
|
227
|
+
_facingDirection: "y-",
|
|
228
|
+
},
|
|
229
|
+
],
|
|
230
|
+
sectionId: "mcu",
|
|
231
|
+
},
|
|
232
|
+
],
|
|
233
|
+
directConnections: [],
|
|
234
|
+
netConnections: [
|
|
235
|
+
{
|
|
236
|
+
netId: "GND",
|
|
237
|
+
isGround: true,
|
|
238
|
+
netLabelWidth: 0.42,
|
|
239
|
+
netLabelHeight: 0.48,
|
|
240
|
+
pinIds: ["schematic_port_14", "schematic_port_30"],
|
|
241
|
+
},
|
|
242
|
+
{
|
|
243
|
+
netId: "VCC_3V3",
|
|
244
|
+
isGround: false,
|
|
245
|
+
netLabelWidth: 0.42,
|
|
246
|
+
netLabelHeight: 0.96,
|
|
247
|
+
pinIds: [
|
|
248
|
+
"schematic_port_11",
|
|
249
|
+
"schematic_port_13",
|
|
250
|
+
"schematic_port_29",
|
|
251
|
+
"schematic_port_31",
|
|
252
|
+
"schematic_port_33",
|
|
253
|
+
],
|
|
254
|
+
},
|
|
255
|
+
{
|
|
256
|
+
netId: "ADC_IN",
|
|
257
|
+
isGround: false,
|
|
258
|
+
netLabelWidth: 0.84,
|
|
259
|
+
anchoredNetLabelWidth: 0.84,
|
|
260
|
+
allowInlineNetLabel: true,
|
|
261
|
+
inlineNetLabelHeight: 0.12,
|
|
262
|
+
inlineNetLabelWidth: 0.56,
|
|
263
|
+
pinIds: ["schematic_port_12", "schematic_port_23"],
|
|
264
|
+
},
|
|
265
|
+
{
|
|
266
|
+
netId: "SDA",
|
|
267
|
+
isGround: false,
|
|
268
|
+
netLabelWidth: 0.48,
|
|
269
|
+
anchoredNetLabelWidth: 0.48,
|
|
270
|
+
allowInlineNetLabel: true,
|
|
271
|
+
inlineNetLabelHeight: 0.12,
|
|
272
|
+
inlineNetLabelWidth: 0.32,
|
|
273
|
+
pinIds: ["schematic_port_19", "schematic_port_34"],
|
|
274
|
+
},
|
|
275
|
+
{
|
|
276
|
+
netId: "SCL",
|
|
277
|
+
isGround: false,
|
|
278
|
+
netLabelWidth: 0.48,
|
|
279
|
+
anchoredNetLabelWidth: 0.48,
|
|
280
|
+
allowInlineNetLabel: true,
|
|
281
|
+
inlineNetLabelHeight: 0.12,
|
|
282
|
+
inlineNetLabelWidth: 0.32,
|
|
283
|
+
pinIds: ["schematic_port_20", "schematic_port_32"],
|
|
284
|
+
},
|
|
285
|
+
{
|
|
286
|
+
netId: "TX",
|
|
287
|
+
isGround: false,
|
|
288
|
+
netLabelWidth: 0.36,
|
|
289
|
+
anchoredNetLabelWidth: 0.36,
|
|
290
|
+
allowInlineNetLabel: true,
|
|
291
|
+
inlineNetLabelHeight: 0.12,
|
|
292
|
+
inlineNetLabelWidth: 0.24,
|
|
293
|
+
pinIds: ["schematic_port_21"],
|
|
294
|
+
},
|
|
295
|
+
{
|
|
296
|
+
netId: "RX",
|
|
297
|
+
isGround: false,
|
|
298
|
+
netLabelWidth: 0.36,
|
|
299
|
+
anchoredNetLabelWidth: 0.36,
|
|
300
|
+
allowInlineNetLabel: true,
|
|
301
|
+
inlineNetLabelHeight: 0.12,
|
|
302
|
+
inlineNetLabelWidth: 0.24,
|
|
303
|
+
pinIds: ["schematic_port_22"],
|
|
304
|
+
},
|
|
305
|
+
{
|
|
306
|
+
netId: "LED_OUT",
|
|
307
|
+
isGround: false,
|
|
308
|
+
netLabelWidth: 0.96,
|
|
309
|
+
anchoredNetLabelWidth: 0.96,
|
|
310
|
+
allowInlineNetLabel: true,
|
|
311
|
+
inlineNetLabelHeight: 0.12,
|
|
312
|
+
inlineNetLabelWidth: 0.64,
|
|
313
|
+
pinIds: ["schematic_port_25"],
|
|
314
|
+
},
|
|
315
|
+
],
|
|
316
|
+
textBoxes: [
|
|
317
|
+
{
|
|
318
|
+
chipId: "schematic_component_4",
|
|
319
|
+
center: {
|
|
320
|
+
x: 1.4774999999999987,
|
|
321
|
+
y: -3.1950000000000003,
|
|
322
|
+
},
|
|
323
|
+
width: 0.3600000000000001,
|
|
324
|
+
height: 0.24999999999999956,
|
|
325
|
+
text: "U2",
|
|
326
|
+
},
|
|
327
|
+
],
|
|
328
|
+
availableNetLabelOrientations: {
|
|
329
|
+
VCC: ["y+"],
|
|
330
|
+
GND: ["y-"],
|
|
331
|
+
VCC_3V3: ["y+"],
|
|
332
|
+
SDA: ["x-", "x+"],
|
|
333
|
+
SCL: ["x-", "x+"],
|
|
334
|
+
TX: ["x-", "x+"],
|
|
335
|
+
RX: ["x-", "x+"],
|
|
336
|
+
LED_OUT: ["x-", "x+"],
|
|
337
|
+
ADC_IN: ["x-", "x+"],
|
|
338
|
+
},
|
|
339
|
+
maxMspPairDistance: 2.4,
|
|
340
|
+
_hideRatsNet: false,
|
|
341
|
+
}
|
|
342
|
+
const solver = new SchematicTracePipelineSolver(problem)
|
|
343
|
+
solver.solve()
|
|
344
|
+
|
|
345
|
+
const stackedConnection =
|
|
346
|
+
solver.schematicTraceLinesSolver!.failedConnectionPairs.find(
|
|
347
|
+
(pair) =>
|
|
348
|
+
pair.pins.some((pin) => pin.pinId === "schematic_port_31") &&
|
|
349
|
+
pair.pins.some((pin) => pin.pinId === "schematic_port_29"),
|
|
350
|
+
)!
|
|
351
|
+
expect(stackedConnection).toBeDefined()
|
|
352
|
+
expect(stackedConnection.pins.map((pin) => pin._facingDirection)).toEqual([
|
|
353
|
+
"y+",
|
|
354
|
+
"y+",
|
|
355
|
+
])
|
|
356
|
+
const recoveredTraces = solver
|
|
357
|
+
.unroutedTraceRecoverySolver!.getOutput()
|
|
358
|
+
.newTraces.filter(
|
|
359
|
+
(trace) => trace.mspPairId === stackedConnection.mspPairId,
|
|
360
|
+
)
|
|
361
|
+
expect(recoveredTraces).toHaveLength(0)
|
|
362
|
+
const finalOutput = solver.inlineNetLabelSolver!.getOutput()
|
|
363
|
+
expect(
|
|
364
|
+
finalOutput.traces.some((trace) =>
|
|
365
|
+
trace.mspConnectionPairIds.includes(stackedConnection.mspPairId),
|
|
366
|
+
),
|
|
367
|
+
).toBe(false)
|
|
368
|
+
expect(
|
|
369
|
+
finalOutput.netLabelPlacements.some((label) =>
|
|
370
|
+
label.pinIds.includes("schematic_port_31"),
|
|
371
|
+
),
|
|
372
|
+
).toBe(true)
|
|
373
|
+
expect(solver).toMatchSolverSnapshot(import.meta.path)
|
|
374
|
+
})
|