@modular-circuit/transpiler 0.0.76 → 0.0.77
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/build/builder/graph_to_kicad/do_convert_graph_to_kicad_project.js +19 -108
- package/build/builder/graph_to_kicad/index.js +4 -59
- package/build/converter/graph_to_netlist/graph_converter.js +51 -171
- package/build/converter/kicad_sexpr/eeschema/drawing_sheet/sch_default_drawing_sheet.js +1 -1
- package/build/converter/kicad_sexpr/eeschema/printer.js +245 -290
- package/build/converter/link_to_netlist/converter.js +77 -135
- package/build/converter/link_to_netlist/links/converter_base.js +38 -131
- package/build/converter/link_to_netlist/links/converters.js +316 -554
- package/build/converter/netlist_to_kicad/calc_boxes_pos.d.ts +1 -1
- package/build/converter/netlist_to_kicad/calc_boxes_pos.d.ts.map +1 -1
- package/build/converter/netlist_to_kicad/calc_boxes_pos.js +36 -101
- package/build/converter/netlist_to_kicad/layout.js +28 -32
- package/build/converter/netlist_to_kicad/netlist_converter.d.ts +1 -1
- package/build/converter/netlist_to_kicad/netlist_converter.d.ts.map +1 -1
- package/build/converter/netlist_to_kicad/netlist_converter.js +128 -300
- package/build/kicad/constraints/index.js +1 -1
- package/build/kicad/label/net_label.js +2 -2
- package/build/kicad/label/sheet_pin.js +11 -19
- package/build/kicad/project/kicad_prl.js +3 -3
- package/build/kicad/project/kicad_pro.js +4 -4
- package/build/kicad/project/kicad_project_achieve.js +31 -45
- package/build/kicad/project/wildcards_and_files_ext.js +61 -61
- package/build/kicad/sheet/sheet.js +3 -3
- package/build/kicad/symbols/lib_symbol/gnd.js +6 -6
- package/build/kicad/symbols/lib_symbol/vcc.js +7 -7
- package/build/kicad/symbols/sch_symbol/gnd.js +9 -9
- package/build/kicad/symbols/sch_symbol/vcc.js +9 -9
- package/build/kicad/symbols/symbol_utils.js +1 -1
- package/build/kicad/wire/gen_wire.js +4 -4
- package/build/utils/collect_sub_sheets.js +37 -151
- package/build/utils/constraints.js +6 -6
- package/build/utils/filter_null_undefined.js +2 -31
- package/build/utils/string_formatter.js +23 -29
- package/package.json +5 -5
|
@@ -1,66 +1,3 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
12
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
-
function step(op) {
|
|
15
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
17
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
18
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
-
switch (op[0]) {
|
|
20
|
-
case 0: case 1: t = op; break;
|
|
21
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
-
default:
|
|
25
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
-
if (t[2]) _.ops.pop();
|
|
30
|
-
_.trys.pop(); continue;
|
|
31
|
-
}
|
|
32
|
-
op = body.call(thisArg, _);
|
|
33
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
var __values = (this && this.__values) || function(o) {
|
|
38
|
-
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
39
|
-
if (m) return m.call(o);
|
|
40
|
-
if (o && typeof o.length === "number") return {
|
|
41
|
-
next: function () {
|
|
42
|
-
if (o && i >= o.length) o = void 0;
|
|
43
|
-
return { value: o && o[i++], done: !o };
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
47
|
-
};
|
|
48
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
49
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
50
|
-
if (!m) return o;
|
|
51
|
-
var i = m.call(o), r, ar = [], e;
|
|
52
|
-
try {
|
|
53
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
54
|
-
}
|
|
55
|
-
catch (error) { e = { error: error }; }
|
|
56
|
-
finally {
|
|
57
|
-
try {
|
|
58
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
59
|
-
}
|
|
60
|
-
finally { if (e) throw e.error; }
|
|
61
|
-
}
|
|
62
|
-
return ar;
|
|
63
|
-
};
|
|
64
1
|
import { PowerShape } from '@modular-circuit/electronics-model';
|
|
65
2
|
import { MODULAR_CIRCUIT_SCH_EXT, } from '@modular-circuit/ir';
|
|
66
3
|
import { replaceAll } from '@modular-circuit/utils';
|
|
@@ -71,89 +8,36 @@ import { GENERATOR_NAME, GENERATOR_VERSION, SCH_VERSION } from '../../utils/cons
|
|
|
71
8
|
import { BLOCK_PIN_GAP, FONT_SIZE, Layout, WIRE_PADDING, get_power_pos } from './layout';
|
|
72
9
|
import { gen_wire } from '../../kicad/wire/gen_wire';
|
|
73
10
|
import { calc_boxes_pos } from './calc_boxes_pos';
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
11
|
+
export class NetListConverter {
|
|
12
|
+
ctx;
|
|
13
|
+
block_calc;
|
|
14
|
+
sheet_pwr_count = 0;
|
|
15
|
+
net_name = {};
|
|
16
|
+
wires = [];
|
|
17
|
+
constructor(ctx) {
|
|
77
18
|
this.ctx = ctx;
|
|
78
|
-
this.
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
try {
|
|
82
|
-
for (var _c = __values(this.ctx.netlist.nets), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
83
|
-
var net = _d.value;
|
|
84
|
-
try {
|
|
85
|
-
for (var _e = (e_2 = void 0, __values(net.pins)), _f = _e.next(); !_f.done; _f = _e.next()) {
|
|
86
|
-
var it_1 = _f.value;
|
|
87
|
-
this.net_name[it_1] = net.name;
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
91
|
-
finally {
|
|
92
|
-
try {
|
|
93
|
-
if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
|
|
94
|
-
}
|
|
95
|
-
finally { if (e_2) throw e_2.error; }
|
|
96
|
-
}
|
|
19
|
+
for (const net of this.ctx.netlist.nets) {
|
|
20
|
+
for (const it of net.pins) {
|
|
21
|
+
this.net_name[it] = net.name;
|
|
97
22
|
}
|
|
98
23
|
}
|
|
99
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
100
|
-
finally {
|
|
101
|
-
try {
|
|
102
|
-
if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
|
|
103
|
-
}
|
|
104
|
-
finally { if (e_1) throw e_1.error; }
|
|
105
|
-
}
|
|
106
24
|
}
|
|
107
|
-
|
|
25
|
+
pin_is_connected(id) {
|
|
108
26
|
return this.net_name[id] !== undefined;
|
|
109
|
-
}
|
|
110
|
-
|
|
27
|
+
}
|
|
28
|
+
get_pin_net_name(id) {
|
|
111
29
|
return this.net_name[id];
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
_g.trys.push([1, 6, 7, 8]);
|
|
124
|
-
_a = __values(Object.entries(this.ctx.netlist.schematics)), _b = _a.next();
|
|
125
|
-
_g.label = 2;
|
|
126
|
-
case 2:
|
|
127
|
-
if (!!_b.done) return [3 /*break*/, 5];
|
|
128
|
-
_c = __read(_b.value, 2), k = _c[0], v = _c[1];
|
|
129
|
-
this.sheet_pwr_count = 0;
|
|
130
|
-
this.block_calc = new Layout();
|
|
131
|
-
this.wires = [];
|
|
132
|
-
_d = all_sch;
|
|
133
|
-
_e = k;
|
|
134
|
-
return [4 /*yield*/, this.convert_sch(k, v)];
|
|
135
|
-
case 3:
|
|
136
|
-
_d[_e] = _g.sent();
|
|
137
|
-
_g.label = 4;
|
|
138
|
-
case 4:
|
|
139
|
-
_b = _a.next();
|
|
140
|
-
return [3 /*break*/, 2];
|
|
141
|
-
case 5: return [3 /*break*/, 8];
|
|
142
|
-
case 6:
|
|
143
|
-
e_3_1 = _g.sent();
|
|
144
|
-
e_3 = { error: e_3_1 };
|
|
145
|
-
return [3 /*break*/, 8];
|
|
146
|
-
case 7:
|
|
147
|
-
try {
|
|
148
|
-
if (_b && !_b.done && (_f = _a.return)) _f.call(_a);
|
|
149
|
-
}
|
|
150
|
-
finally { if (e_3) throw e_3.error; }
|
|
151
|
-
return [7 /*endfinally*/];
|
|
152
|
-
case 8: return [2 /*return*/, all_sch];
|
|
153
|
-
}
|
|
154
|
-
});
|
|
155
|
-
});
|
|
156
|
-
};
|
|
30
|
+
}
|
|
31
|
+
convert_to_kicad() {
|
|
32
|
+
const all_sch = {};
|
|
33
|
+
for (const [k, v] of Object.entries(this.ctx.netlist.schematics)) {
|
|
34
|
+
this.sheet_pwr_count = 0;
|
|
35
|
+
this.block_calc = new Layout();
|
|
36
|
+
this.wires = [];
|
|
37
|
+
all_sch[k] = this.convert_sch(k, v);
|
|
38
|
+
}
|
|
39
|
+
return all_sch;
|
|
40
|
+
}
|
|
157
41
|
/**
|
|
158
42
|
* Convert a schematic to a kicad schematic
|
|
159
43
|
* @param name The name of the graph ,also the file name of the converted schematic
|
|
@@ -161,145 +45,92 @@ var NetListConverter = /** @class */ (function () {
|
|
|
161
45
|
* no need to handle them before the other types of label are introduced, e.g. global or hierarchical
|
|
162
46
|
* @returns
|
|
163
47
|
*/
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
it_2 = _b.value;
|
|
201
|
-
if (!powers.has(it_2.value)) {
|
|
202
|
-
switch (it_2.shape) {
|
|
203
|
-
case PowerShape.VCC:
|
|
204
|
-
(_j = sch.lib_symbols) === null || _j === void 0 ? void 0 : _j.symbols.push(gen_lib_vcc(it_2.value));
|
|
205
|
-
break;
|
|
206
|
-
case PowerShape.GND:
|
|
207
|
-
(_k = sch.lib_symbols) === null || _k === void 0 ? void 0 : _k.symbols.push(gen_lib_gnd(it_2.value));
|
|
208
|
-
break;
|
|
209
|
-
}
|
|
210
|
-
powers.add(it_2.value);
|
|
211
|
-
this.convert_pwr_symbol(it_2, get_power_pos(this.sheet_pwr_count++), sch);
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
216
|
-
finally {
|
|
217
|
-
try {
|
|
218
|
-
if (_b && !_b.done && (_e = _a.return)) _e.call(_a);
|
|
219
|
-
}
|
|
220
|
-
finally { if (e_4) throw e_4.error; }
|
|
221
|
-
}
|
|
222
|
-
sheet_names_count = new Map();
|
|
223
|
-
ordered_sheets = schematic.sheet_symbols.sort(function (a, b) {
|
|
224
|
-
return b.pins.length - a.pins.length;
|
|
225
|
-
});
|
|
226
|
-
sheet_bounding_boxes = {};
|
|
227
|
-
sheet_size = {};
|
|
228
|
-
try {
|
|
229
|
-
for (ordered_sheets_1 = __values(ordered_sheets), ordered_sheets_1_1 = ordered_sheets_1.next(); !ordered_sheets_1_1.done; ordered_sheets_1_1 = ordered_sheets_1.next()) {
|
|
230
|
-
it_3 = ordered_sheets_1_1.value;
|
|
231
|
-
sheet_padding = this.get_sheet_symbol_lb_padding(it_3);
|
|
232
|
-
block_geo = this.block_calc.get_block_geometry(sheet_padding);
|
|
233
|
-
sheet_bounding_boxes[it_3.uuid] = block_geo.bounding_box.size;
|
|
234
|
-
sheet_size[it_3.uuid] = block_geo.box.size;
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
|
238
|
-
finally {
|
|
239
|
-
try {
|
|
240
|
-
if (ordered_sheets_1_1 && !ordered_sheets_1_1.done && (_f = ordered_sheets_1.return)) _f.call(ordered_sheets_1);
|
|
241
|
-
}
|
|
242
|
-
finally { if (e_5) throw e_5.error; }
|
|
243
|
-
}
|
|
244
|
-
return [4 /*yield*/, calc_boxes_pos(sheet_bounding_boxes)];
|
|
245
|
-
case 1:
|
|
246
|
-
sheet_pos = _l.sent();
|
|
247
|
-
try {
|
|
248
|
-
for (ordered_sheets_2 = __values(ordered_sheets), ordered_sheets_2_1 = ordered_sheets_2.next(); !ordered_sheets_2_1.done; ordered_sheets_2_1 = ordered_sheets_2.next()) {
|
|
249
|
-
it_4 = ordered_sheets_2_1.value;
|
|
250
|
-
this.convert_sheet_symbol(it_4, {
|
|
251
|
-
pos: sheet_pos[it_4.uuid],
|
|
252
|
-
size: sheet_size[it_4.uuid],
|
|
253
|
-
}, sch, sheet_names_count);
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
catch (e_6_1) { e_6 = { error: e_6_1 }; }
|
|
257
|
-
finally {
|
|
258
|
-
try {
|
|
259
|
-
if (ordered_sheets_2_1 && !ordered_sheets_2_1.done && (_g = ordered_sheets_2.return)) _g.call(ordered_sheets_2);
|
|
260
|
-
}
|
|
261
|
-
finally { if (e_6) throw e_6.error; }
|
|
262
|
-
}
|
|
263
|
-
try {
|
|
264
|
-
for (_c = __values(schematic.hiera_labels), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
265
|
-
it_5 = _d.value;
|
|
266
|
-
this.convert_hierarchical_label(it_5, sch);
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
catch (e_7_1) { e_7 = { error: e_7_1 }; }
|
|
270
|
-
finally {
|
|
271
|
-
try {
|
|
272
|
-
if (_d && !_d.done && (_h = _c.return)) _h.call(_c);
|
|
273
|
-
}
|
|
274
|
-
finally { if (e_7) throw e_7.error; }
|
|
275
|
-
}
|
|
276
|
-
sch.wires = this.wires;
|
|
277
|
-
return [2 /*return*/, sch];
|
|
48
|
+
convert_sch(name, schematic) {
|
|
49
|
+
const powers = new Set();
|
|
50
|
+
const sch = {
|
|
51
|
+
version: SCH_VERSION,
|
|
52
|
+
generator: GENERATOR_NAME,
|
|
53
|
+
generator_version: GENERATOR_VERSION,
|
|
54
|
+
paper: {
|
|
55
|
+
size: 'A4',
|
|
56
|
+
},
|
|
57
|
+
title_block: {
|
|
58
|
+
title: name.replace(`.${MODULAR_CIRCUIT_SCH_EXT}`, ''),
|
|
59
|
+
date: replaceAll(new Date().toISOString().slice(0, 10), '-', '/'),
|
|
60
|
+
rev: '1.0',
|
|
61
|
+
comment: {
|
|
62
|
+
1: 'https://www.eda.cn',
|
|
63
|
+
2: this.ctx.project.author,
|
|
64
|
+
3: this.ctx.project.name,
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
lib_symbols: {
|
|
68
|
+
symbols: [],
|
|
69
|
+
},
|
|
70
|
+
uuid: schematic.uuid,
|
|
71
|
+
symbols: [],
|
|
72
|
+
labels: [],
|
|
73
|
+
sheets: [],
|
|
74
|
+
};
|
|
75
|
+
for (const it of schematic.powers) {
|
|
76
|
+
if (!powers.has(it.value)) {
|
|
77
|
+
switch (it.shape) {
|
|
78
|
+
case PowerShape.VCC:
|
|
79
|
+
sch.lib_symbols?.symbols.push(gen_lib_vcc(it.value));
|
|
80
|
+
break;
|
|
81
|
+
case PowerShape.GND:
|
|
82
|
+
sch.lib_symbols?.symbols.push(gen_lib_gnd(it.value));
|
|
83
|
+
break;
|
|
278
84
|
}
|
|
279
|
-
|
|
85
|
+
powers.add(it.value);
|
|
86
|
+
this.convert_pwr_symbol(it, get_power_pos(this.sheet_pwr_count++), sch);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
const sheet_names_count = new Map();
|
|
90
|
+
const ordered_sheets = schematic.sheet_symbols.sort((a, b) => {
|
|
91
|
+
return b.pins.length - a.pins.length;
|
|
280
92
|
});
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
93
|
+
const sheet_bounding_boxes = {};
|
|
94
|
+
const sheet_size = {};
|
|
95
|
+
for (const it of ordered_sheets) {
|
|
96
|
+
const sheet_padding = this.get_sheet_symbol_lb_padding(it);
|
|
97
|
+
const block_geo = this.block_calc.get_block_geometry(sheet_padding);
|
|
98
|
+
sheet_bounding_boxes[it.uuid] = block_geo.bounding_box.size;
|
|
99
|
+
sheet_size[it.uuid] = block_geo.box.size;
|
|
100
|
+
}
|
|
101
|
+
const sheet_pos = calc_boxes_pos(sheet_bounding_boxes);
|
|
102
|
+
for (const it of ordered_sheets) {
|
|
103
|
+
this.convert_sheet_symbol(it, {
|
|
104
|
+
pos: sheet_pos[it.uuid],
|
|
105
|
+
size: sheet_size[it.uuid],
|
|
106
|
+
}, sch, sheet_names_count);
|
|
107
|
+
}
|
|
108
|
+
for (const it of schematic.hiera_labels) {
|
|
109
|
+
this.convert_hierarchical_label(it, sch);
|
|
110
|
+
}
|
|
111
|
+
sch.wires = this.wires;
|
|
112
|
+
return sch;
|
|
113
|
+
}
|
|
114
|
+
convert_hierarchical_label(pin, sch) {
|
|
284
115
|
// FIXME: layout them in the Yoga layout
|
|
285
|
-
|
|
116
|
+
const pin_pos = this.block_calc.get_block_geometry({
|
|
286
117
|
internal: { l_side: 0, r_side: 0 },
|
|
287
118
|
outer: { l_side: 0, r_side: 0 },
|
|
288
119
|
total_pin_num: 1,
|
|
289
120
|
}).box.pos;
|
|
290
|
-
|
|
291
|
-
}
|
|
292
|
-
|
|
121
|
+
sch.labels?.push(gen_hierarchical_label(pin.name, pin_pos, { horizontal: 'left', vertical: 'bottom' }, 0, pin.shape));
|
|
122
|
+
}
|
|
123
|
+
convert_pwr_symbol(pwr, at, sch) {
|
|
293
124
|
// NOTE : The power uuid is used as the uuid of its pin ,cause all power symbols have only one pin
|
|
294
|
-
|
|
295
|
-
|
|
125
|
+
const pin_id = pwr.uuid;
|
|
126
|
+
const sch_pwr_symbol = pwr.shape === PowerShape.VCC
|
|
296
127
|
? gen_sch_vcc(pwr.value, this.sheet_pwr_count, pin_id, at)
|
|
297
128
|
: gen_sch_gnd(pwr.value, this.sheet_pwr_count, pin_id, at);
|
|
298
129
|
sch.symbols.push(sch_pwr_symbol);
|
|
299
130
|
this.convert_net_label(pwr.value, at, sch);
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
|
|
131
|
+
}
|
|
132
|
+
get_sheet_symbol_lb_padding(sheet_sym) {
|
|
133
|
+
const factor = {
|
|
303
134
|
internal: {
|
|
304
135
|
l_side: 0,
|
|
305
136
|
r_side: 0,
|
|
@@ -310,10 +141,10 @@ var NetListConverter = /** @class */ (function () {
|
|
|
310
141
|
},
|
|
311
142
|
total_pin_num: sheet_sym.pins.length,
|
|
312
143
|
};
|
|
313
|
-
|
|
314
|
-
for (
|
|
315
|
-
|
|
316
|
-
|
|
144
|
+
const port_count = sheet_sym.pins.length;
|
|
145
|
+
for (let i = 0; i < port_count; i++) {
|
|
146
|
+
const is_left = i < port_count / 2;
|
|
147
|
+
const cur_pin = sheet_sym.pins[i];
|
|
317
148
|
if (is_left) {
|
|
318
149
|
factor.internal.l_side = Math.max(factor.internal.l_side, cur_pin.name.length);
|
|
319
150
|
}
|
|
@@ -321,7 +152,7 @@ var NetListConverter = /** @class */ (function () {
|
|
|
321
152
|
factor.internal.r_side = Math.max(factor.internal.r_side, cur_pin.name.length);
|
|
322
153
|
}
|
|
323
154
|
if (this.pin_is_connected(cur_pin.uuid)) {
|
|
324
|
-
|
|
155
|
+
const net_name = this.get_pin_net_name(cur_pin.uuid);
|
|
325
156
|
if (is_left) {
|
|
326
157
|
factor.outer.l_side = Math.max(factor.outer.l_side, net_name.length);
|
|
327
158
|
}
|
|
@@ -341,22 +172,22 @@ var NetListConverter = /** @class */ (function () {
|
|
|
341
172
|
},
|
|
342
173
|
total_pin_num: sheet_sym.pins.length,
|
|
343
174
|
};
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
for (
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
pins.push(this.convert_sheet_pin(sheet_sym.pins[i], { x
|
|
175
|
+
}
|
|
176
|
+
convert_sheet_symbol(sheet_sym, rect, sch, sheet_names_count) {
|
|
177
|
+
const port_count = sheet_sym.pins.length;
|
|
178
|
+
const pins = [];
|
|
179
|
+
for (let i = 0; i < port_count; i++) {
|
|
180
|
+
const is_left = i < port_count / 2;
|
|
181
|
+
const x = is_left ? rect.pos.x : rect.pos.x + rect.size.x;
|
|
182
|
+
const y = rect.pos.y + BLOCK_PIN_GAP * ((i < port_count / 2 ? i : i - port_count / 2) + 1);
|
|
183
|
+
const justify = is_left ? 'left' : 'right';
|
|
184
|
+
const rotation = is_left ? 180 : 0;
|
|
185
|
+
pins.push(this.convert_sheet_pin(sheet_sym.pins[i], { x, y }, sch, justify, rotation, is_left));
|
|
355
186
|
}
|
|
356
|
-
|
|
187
|
+
let sheet_name = sheet_sym.sheet_name;
|
|
357
188
|
if (sheet_names_count.has(sheet_name)) {
|
|
358
|
-
|
|
359
|
-
sheet_name +=
|
|
189
|
+
const count = sheet_names_count.get(sheet_name);
|
|
190
|
+
sheet_name += `_${count}`;
|
|
360
191
|
sheet_names_count.set(sheet_name, count + 1);
|
|
361
192
|
}
|
|
362
193
|
else {
|
|
@@ -366,27 +197,24 @@ var NetListConverter = /** @class */ (function () {
|
|
|
366
197
|
Sheetfile: sheet_sym.sheet_file_name,
|
|
367
198
|
Sheetname: sheet_name,
|
|
368
199
|
}));
|
|
369
|
-
}
|
|
370
|
-
|
|
200
|
+
}
|
|
201
|
+
convert_sheet_pin(pin, pin_pos, sch, horizontal, rotation, is_left) {
|
|
371
202
|
if (this.pin_is_connected(pin.uuid)) {
|
|
372
|
-
|
|
203
|
+
const nt_name = this.get_pin_net_name(pin.uuid);
|
|
373
204
|
this.convert_net_label(nt_name, {
|
|
374
205
|
x: pin_pos.x + (is_left ? -WIRE_PADDING : WIRE_PADDING),
|
|
375
206
|
y: pin_pos.y,
|
|
376
207
|
}, sch, horizontal === 'left' ? 'right' : 'left');
|
|
377
|
-
|
|
378
|
-
|
|
208
|
+
const lb_txt_len = nt_name.length * FONT_SIZE;
|
|
209
|
+
const wire_padding = lb_txt_len + 2 * WIRE_PADDING;
|
|
379
210
|
this.wires.push(gen_wire(pin_pos, {
|
|
380
211
|
x: pin_pos.x + (is_left ? -wire_padding : wire_padding),
|
|
381
212
|
y: pin_pos.y,
|
|
382
213
|
}));
|
|
383
214
|
}
|
|
384
|
-
return gen_sheet_pin(pin.name, pin_pos, { horizontal
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
return NetListConverter;
|
|
391
|
-
}());
|
|
392
|
-
export { NetListConverter };
|
|
215
|
+
return gen_sheet_pin(pin.name, pin_pos, { horizontal, vertical: 'bottom' }, rotation, pin.shape);
|
|
216
|
+
}
|
|
217
|
+
convert_net_label(net_name, pin_pos, sch, horizontal = 'right') {
|
|
218
|
+
sch.labels.push(gen_net_label(net_name, pin_pos, { horizontal, vertical: 'bottom' }));
|
|
219
|
+
}
|
|
220
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { gen_uuid } from '@modular-circuit/utils';
|
|
2
2
|
import { DEFAULT_FONT_SIZE } from '../constraints';
|
|
3
|
-
export
|
|
3
|
+
export const gen_net_label = (name, at, justify) => ({
|
|
4
4
|
label_type: 'label',
|
|
5
5
|
text: name,
|
|
6
6
|
fields: [],
|
|
@@ -11,4 +11,4 @@ export var gen_net_label = function (name, at, justify) { return ({
|
|
|
11
11
|
justify: justify,
|
|
12
12
|
},
|
|
13
13
|
uuid: gen_uuid(),
|
|
14
|
-
});
|
|
14
|
+
});
|
|
@@ -1,25 +1,17 @@
|
|
|
1
|
-
var __assign = (this && this.__assign) || function () {
|
|
2
|
-
__assign = Object.assign || function(t) {
|
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
-
s = arguments[i];
|
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
-
t[p] = s[p];
|
|
7
|
-
}
|
|
8
|
-
return t;
|
|
9
|
-
};
|
|
10
|
-
return __assign.apply(this, arguments);
|
|
11
|
-
};
|
|
12
1
|
import { gen_uuid } from '@modular-circuit/utils';
|
|
13
2
|
import { DEFAULT_FONT_SIZE } from '../constraints';
|
|
14
|
-
|
|
15
|
-
shape
|
|
3
|
+
const gen_base_hierarchical_label = (text, at, justify, rotation, shape) => ({
|
|
4
|
+
shape,
|
|
16
5
|
effects: {
|
|
17
6
|
font: { size: DEFAULT_FONT_SIZE },
|
|
18
|
-
justify
|
|
7
|
+
justify,
|
|
19
8
|
},
|
|
20
|
-
text
|
|
21
|
-
at: { position: at, rotation
|
|
9
|
+
text,
|
|
10
|
+
at: { position: at, rotation },
|
|
22
11
|
uuid: gen_uuid(),
|
|
23
|
-
});
|
|
24
|
-
export
|
|
25
|
-
|
|
12
|
+
});
|
|
13
|
+
export const gen_sheet_pin = (text, at, justify, rotation, shape) => ({
|
|
14
|
+
label_type: 'hierarchical_label',
|
|
15
|
+
...gen_base_hierarchical_label(text, at, justify, rotation, shape),
|
|
16
|
+
});
|
|
17
|
+
export const gen_hierarchical_label = gen_sheet_pin;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export
|
|
1
|
+
export const kicad_prl = (prj_name) => ({
|
|
2
2
|
board: {
|
|
3
3
|
active_layer: 0,
|
|
4
4
|
active_layer_preset: '',
|
|
@@ -41,10 +41,10 @@ export var kicad_prl = function (prj_name) { return ({
|
|
|
41
41
|
ssh_key: '',
|
|
42
42
|
},
|
|
43
43
|
meta: {
|
|
44
|
-
filename:
|
|
44
|
+
filename: `${prj_name}.kicad_prl`,
|
|
45
45
|
version: 3,
|
|
46
46
|
},
|
|
47
47
|
project: {
|
|
48
48
|
files: [],
|
|
49
49
|
},
|
|
50
|
-
});
|
|
50
|
+
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DrawingSheetFileExtension } from './wildcards_and_files_ext';
|
|
2
|
-
export
|
|
2
|
+
export const kicad_pro = (project_name) => ({
|
|
3
3
|
board: {
|
|
4
4
|
'3dviewports': [],
|
|
5
5
|
ipc2581: {
|
|
@@ -76,7 +76,7 @@ export var kicad_pro = function (project_name) { return ({
|
|
|
76
76
|
pinned_symbol_libs: [],
|
|
77
77
|
},
|
|
78
78
|
meta: {
|
|
79
|
-
filename:
|
|
79
|
+
filename: `${project_name}.kicad_pro`,
|
|
80
80
|
version: 1,
|
|
81
81
|
},
|
|
82
82
|
net_settings: {
|
|
@@ -208,7 +208,7 @@ export var kicad_pro = function (project_name) { return ({
|
|
|
208
208
|
version: 1,
|
|
209
209
|
},
|
|
210
210
|
net_format_name: '',
|
|
211
|
-
page_layout_descr_file:
|
|
211
|
+
page_layout_descr_file: `${project_name}.${DrawingSheetFileExtension}`,
|
|
212
212
|
plot_directory: '',
|
|
213
213
|
spice_current_sheet_as_root: false,
|
|
214
214
|
spice_external_command: 'spice "%I"',
|
|
@@ -221,4 +221,4 @@ export var kicad_pro = function (project_name) { return ({
|
|
|
221
221
|
},
|
|
222
222
|
sheets: [],
|
|
223
223
|
text_variables: {},
|
|
224
|
-
});
|
|
224
|
+
});
|