diff options
author | Hamilton Kibbe <hamilton.kibbe@gmail.com> | 2015-02-20 22:24:34 -0500 |
---|---|---|
committer | Hamilton Kibbe <hamilton.kibbe@gmail.com> | 2015-02-20 22:24:34 -0500 |
commit | b3e0ceb5c3ec755b09d2f005b8e3dcbed22d45a1 (patch) | |
tree | 6609c493fbfa7557ebaef0c43f46c61a8b83cf87 /gerber/tests | |
parent | b3e816466c9cd514854efd42803cb4258e4956b2 (diff) | |
download | gerbonara-b3e0ceb5c3ec755b09d2f005b8e3dcbed22d45a1.tar.gz gerbonara-b3e0ceb5c3ec755b09d2f005b8e3dcbed22d45a1.tar.bz2 gerbonara-b3e0ceb5c3ec755b09d2f005b8e3dcbed22d45a1.zip |
Add IPC-D-356 Netlist Parsing
Diffstat (limited to 'gerber/tests')
-rw-r--r-- | gerber/tests/resources/ipc-d-356.ipc | 114 | ||||
-rw-r--r-- | gerber/tests/test_ipc356.py | 116 |
2 files changed, 230 insertions, 0 deletions
diff --git a/gerber/tests/resources/ipc-d-356.ipc b/gerber/tests/resources/ipc-d-356.ipc new file mode 100644 index 0000000..b0086c9 --- /dev/null +++ b/gerber/tests/resources/ipc-d-356.ipc @@ -0,0 +1,114 @@ +C IPC-D-356 generated by EAGLE Version 7.1.0 Copyright (c) 1988-2014 CadSoft +C Database /Some/Path/To/File +C +P JOB EAGLE 7.1 NETLIST, DATE: 2/20/15 12:00 AM +P UNITS CUST 0 +P DIM N +P NNAME1 A_REALLY_LONG_NET_NAME +317GND VIA D 24PA00X 14900Y 1450X 396Y 396 +317GND VIA D 24PA00X 3850Y 8500X 396Y 396 +317GND VIA D 24PA00X 6200Y 10650X 396Y 396 +317GND VIA D 24PA00X 8950Y 1000X 396Y 396 +317GND VIA D 24PA00X 11800Y 2250X 396Y 396 +317GND VIA D 24PA00X 15350Y 3200X 396Y 396 +317GND VIA D 24PA00X 13200Y 3800X 396Y 396 +317GND VIA D 24PA00X 9700Y 12050X 396Y 396 +317GND VIA D 24PA00X 13950Y 11900X 396Y 396 +317GND VIA D 24PA00X 13050Y 7050X 396Y 396 +317GND VIA D 24PA00X 13000Y 8400X 396Y 396 +317N$3 VIA D 24PA00X 11350Y 10100X 396Y 396 +317N$3 VIA D 24PA00X 13250Y 5700X 396Y 396 +317VCC VIA D 24PA00X 15550Y 6850X 396Y 396 +327N$3 C1 -+ A01X 9700Y 10402X1575Y 630R270 +327GND C1 -- A01X 9700Y 13198X1575Y 630R270 +327VCC C2 -+ A01X 13950Y 9677X1535Y 630R270 +327GND C2 -- A01X 13950Y 13023X1535Y 630R270 +327VCC C3 -1 A01X 3850Y 9924X 512Y 591R270 +327GND C3 -2 A01X 3850Y 9176X 512Y 591R270 +327VCC C4 -1 A01X 10374Y 1000X 512Y 591R180 +327GND C4 -2 A01X 9626Y 1000X 512Y 591R180 +327VCC C5 -1 A01X 14700Y 3924X 512Y 591R270 +327GND C5 -2 A01X 14700Y 3176X 512Y 591R270 +317DMX+ DMX -1 D 40PA00X 5050Y 13900X 600Y1200R 90 +317DMX- DMX -2 D 40PA00X 6050Y 13900X 600Y1200R 90 +317GND DMX -3 D 40PA00X 7050Y 13900X 600Y1200R 90 +317PIC_MCLR J1 -1 D 35PA00X 16900Y 6400X 554Y 554R 90 +317VCC J1 -2 D 35PA00X 17900Y 6900X 554Y 554R 90 +317GND J1 -3 D 35PA00X 16900Y 7400X 554Y 554R 90 +317PIC_PGD J1 -4 D 35PA00X 17900Y 7900X 554Y 554R 90 +317PIC_PGC J1 -5 D 35PA00X 16900Y 8400X 554Y 554R 90 +317 J1 -6 D 35PA00X 17900Y 8900X 554Y 554R 90 +327N$4 L1 -1 A01X 13950Y 6382X 748Y1339R 90 +327VCC L1 -2 A01X 13950Y 7918X 748Y1339R 90 +327N$5 LED1 -A A01X 16313Y 1450X 472Y 472R 0 +327GND LED1 -C A01X 15487Y 1450X 472Y 472R 0 +317 MIDI -1 D 40PA00X 1200Y 9500X 600Y1200R 0 +317 MIDI -2 D 40PA00X 1200Y 8500X 600Y1200R 0 +317 MIDI -3 D 40PA00X 1200Y 7500X 600Y1200R 0 +317N$9 MIDI -4 D 40PA00X 1200Y 6500X 600Y1200R 0 +317N$10 MIDI -5 D 40PA00X 1200Y 5500X 600Y1200R 0 +317N$3 PWR -1 D 40PA00X 17050Y 13750X 600Y1200R 90 +317GND PWR -2 D 40PA00X 18050Y 13750X 600Y1200R 90 +327DMX+ R1 -1 A01X 5076Y 11500X 512Y 591R 0 +327DMX- R1 -2 A01X 5824Y 11500X 512Y 591R 0 +327VCC R2 -1 A01X 14376Y 5300X 512Y 591R 0 +327PIC_MCLR R2 -2 A01X 15124Y 5300X 512Y 591R 0 +327N$9 R3 -1 A01X 3126Y 6500X 512Y 591R 0 +327N$6 R3 -2 A01X 3874Y 6500X 512Y 591R 0 +327PIC_RX R4 -1 A01X 9600Y 2624X 512Y 591R270 +327VCC R4 -2 A01X 9600Y 1876X 512Y 591R270 +327VCC R5 -1 A01X 17974Y 1450X 512Y 591R180 +327N$5 R5 -2 A01X 17226Y 1450X 512Y 591R180 +327N$3 U1 -1 A01X 12330Y 5710X 420Y 850R 90 +327N$4 U1 -2 A01X 12330Y 6380X 420Y 850R 90 +327GND U1 -3 A01X 12330Y 7050X 420Y 850R 90 +327VCC U1 -4 A01X 12330Y 7720X 420Y 850R 90 +327GND U1 -5 A01X 12330Y 8390X 420Y 850R 90 +327 U1 -6 A01X 9050Y 7050X4252Y4098R 90 +327PIC_MCLR U2 -1 A01X 11123Y 4063X 157Y 591R270 +327 U2 -2 A01X 11123Y 3807X 157Y 591R270 +327 U2 -3 A01X 11123Y 3552X 157Y 591R270 +327N$1 U2 -4 A01X 11123Y 3296X 157Y 591R270 +327N$2 U2 -5 A01X 11123Y 3040X 157Y 591R270 +327PIC_RX U2 -6 A01X 11123Y 2784X 157Y 591R270 +327 U2 -7 A01X 11123Y 2528X 157Y 591R270 +327GND U2 -8 A01X 11123Y 2272X 157Y 591R270 +327 U2 -9 A01X 11123Y 2016X 157Y 591R270 +327 U2 -10 A01X 11123Y 1760X 157Y 591R270 +327 U2 -11 A01X 11123Y 1504X 157Y 591R270 +327 U2 -12 A01X 11123Y 1248X 157Y 591R270 +327VCC U2 -13 A01X 11123Y 993X 157Y 591R270 +327 U2 -14 A01X 11123Y 737X 157Y 591R270 +327 U2 -15 A01X 13977Y 737X 157Y 591R270 +327 U2 -16 A01X 13977Y 993X 157Y 591R270 +327 U2 -17 A01X 13977Y 1248X 157Y 591R270 +327 U2 -18 A01X 13977Y 1504X 157Y 591R270 +327 U2 -19 A01X 13977Y 1760X 157Y 591R270 +327 U2 -20 A01X 13977Y 2016X 157Y 591R270 +327PIC_PGD U2 -21 A01X 13977Y 2272X 157Y 591R270 +327PIC_PGC U2 -22 A01X 13977Y 2528X 157Y 591R270 +327 U2 -23 A01X 13977Y 2784X 157Y 591R270 +327 U2 -24 A01X 13977Y 3040X 157Y 591R270 +327 U2 -25 A01X 13977Y 3296X 157Y 591R270 +327 U2 -26 A01X 13977Y 3552X 157Y 591R270 +327GND U2 -27 A01X 13977Y 3807X 157Y 591R270 +327VCC U2 -28 A01X 13977Y 4063X 157Y 591R270 +327N$2 U3 -1 A01X 4700Y 7540X 260Y 800R 0 +327VCC U3 -2 A01X 5200Y 7540X 260Y 800R 0 +327VCC U3 -3 A01X 5700Y 7540X 260Y 800R 0 +327N$1 U3 -4 A01X 6200Y 7540X 260Y 800R 0 +327GND U3 -5 A01X 6200Y 9960X 260Y 800R 0 +327DMX- U3 -6 A01X 5700Y 9960X 260Y 800R 0 +327DMX+ U3 -7 A01X 5200Y 9960X 260Y 800R 0 +327VCC U3 -8 A01X 4700Y 9960X 260Y 800R 0 +327 U4 -1 A01X 4704Y 3850X 394Y 500R 0 +327N$6 U4 -2 A01X 4704Y 2800X 394Y 500R 0 +327N$10 U4 -3 A01X 4704Y 1800X 394Y 500R 0 +327 U4 -4 A01X 4704Y 750X 394Y 500R 0 +327GND U4 -5 A01X 8396Y 750X 394Y 500R 0 +327PIC_RX U4 -6 A01X 8396Y 1800X 394Y 500R 0 +327 U4 -7 A01X 8396Y 2800X 394Y 500R 0 +327VCC U4 -8 A01X 8396Y 3850X 394Y 500R 0 +327NNAME1 NA -69 A01X 8396Y 3850X 394Y 500R 0 +389BOARD_EDGE X0Y0 X22500 Y15000 X0 +999 diff --git a/gerber/tests/test_ipc356.py b/gerber/tests/test_ipc356.py new file mode 100644 index 0000000..760608c --- /dev/null +++ b/gerber/tests/test_ipc356.py @@ -0,0 +1,116 @@ +#! /usr/bin/env python +# -*- coding: utf-8 -*- + +# Author: Hamilton Kibbe <ham@hamiltonkib.be> +from ..ipc356 import * +from ..cam import FileSettings +from .tests import * + +import os + +IPC_D_356_FILE = os.path.join(os.path.dirname(__file__), + 'resources/ipc-d-356.ipc') +def test_read(): + ipcfile = read(IPC_D_356_FILE) + assert(isinstance(ipcfile, IPC_D_356)) + +def test_parser(): + ipcfile = read(IPC_D_356_FILE) + assert_equal(ipcfile.settings.units, 'inch') + assert_equal(ipcfile.settings.angle_units, 'degrees') + assert_equal(len(ipcfile.comments), 3) + assert_equal(len(ipcfile.parameters), 4) + assert_equal(len(ipcfile.test_records), 105) + assert_equal(len(ipcfile.components), 21) + assert_equal(len(ipcfile.vias), 14) + assert_equal(ipcfile.test_records[-1].net_name, 'A_REALLY_LONG_NET_NAME') + assert_equal(set(ipcfile.board_outline), + {(0., 0.), (2.25, 0.), (2.25, 1.5), (0., 1.5)}) + +def test_comment(): + c = IPC356_Comment('Layer Stackup:') + assert_equal(c.comment, 'Layer Stackup:') + c = IPC356_Comment.from_line('C Layer Stackup: ') + assert_equal(c.comment, 'Layer Stackup:') + assert_raises(ValueError, IPC356_Comment.from_line, 'P JOB') + assert_equal(str(c), '<IPC-D-356 Comment: Layer Stackup:>') + +def test_parameter(): + p = IPC356_Parameter('VER', 'IPC-D-356A') + assert_equal(p.parameter, 'VER') + assert_equal(p.value, 'IPC-D-356A') + p = IPC356_Parameter.from_line('P VER IPC-D-356A ') + assert_equal(p.parameter, 'VER') + assert_equal(p.value, 'IPC-D-356A') + assert_raises(ValueError, IPC356_Parameter.from_line, 'C Layer Stackup: ') + assert_equal(str(p), '<IPC-D-356 Parameter: VER=IPC-D-356A>') + +def test_eof(): + e = IPC356_EndOfFile() + assert_equal(e.to_netlist(), '999') + assert_equal(str(e), '<IPC-D-356 EOF>') + +def test_board_edge(): + points = [(0.01, 0.01), (2., 2.), (4., 2.), (4., 6.)] + b = IPC356_BoardEdge(points) + assert_equal(b.points, points) + b = IPC356_BoardEdge.from_line('389BOARD_EDGE X100Y100 X20000Y20000' + ' X40000 Y60000', FileSettings(units='inch')) + assert_equal(b.points, points) + +def test_test_record(): + assert_raises(ValueError, IPC356_TestRecord.from_line, 'P JOB', FileSettings()) + record_string = '317+5VDC VIA - D0150PA00X 006647Y 012900X0000 S3' + r = IPC356_TestRecord.from_line(record_string, FileSettings(units='inch')) + assert_equal(r.feature_type, 'through-hole') + assert_equal(r.net_name, '+5VDC') + assert_equal(r.id, 'VIA') + assert_almost_equal(r.hole_diameter, 0.015) + assert_true(r.plated) + assert_equal(r.access, 'both') + assert_almost_equal(r.x_coord, 0.6647) + assert_almost_equal(r.y_coord, 1.29) + assert_equal(r.rect_x, 0.) + assert_equal(r.soldermask_info, '3') + r = IPC356_TestRecord.from_line(record_string, FileSettings(units='metric')) + assert_almost_equal(r.hole_diameter, 0.15) + assert_almost_equal(r.x_coord, 6.647) + assert_almost_equal(r.y_coord, 12.9) + assert_equal(r.rect_x, 0.) + assert_equal(str(r), + '<IPC-D-356 Test Record: Net: +5VDC Type: through-hole>') + + record_string = '327+3.3VDC R40 -1 PA01X 032100Y 007124X0236Y0315R180 S0' + r = IPC356_TestRecord.from_line(record_string, FileSettings(units='inch')) + assert_equal(r.feature_type, 'smt') + assert_equal(r.net_name, '+3.3VDC') + assert_equal(r.id, 'R40') + assert_equal(r.pin, '1') + assert_true(r.plated) + assert_equal(r.access, 'top') + assert_almost_equal(r.x_coord, 3.21) + assert_almost_equal(r.y_coord, 0.7124) + assert_almost_equal(r.rect_x, 0.0236) + assert_almost_equal(r.rect_y, 0.0315) + assert_equal(r.rect_rotation, 180) + assert_equal(r.soldermask_info, '0') + r = IPC356_TestRecord.from_line(record_string, FileSettings(units='metric')) + assert_almost_equal(r.x_coord, 32.1) + assert_almost_equal(r.y_coord, 7.124) + assert_almost_equal(r.rect_x, 0.236) + assert_almost_equal(r.rect_y, 0.315) + + + record_string = '317 J4 -M2 D0330PA00X 012447Y 008030X0000 S0' + r = IPC356_TestRecord.from_line(record_string, FileSettings(units='inch')) + assert_equal(r.feature_type, 'through-hole') + assert_equal(r.id, 'J4') + assert_equal(r.pin, 'M2') + assert_almost_equal(r.hole_diameter, 0.033) + assert_true(r.plated) + assert_equal(r.access, 'both') + assert_almost_equal(r.x_coord, 1.2447) + assert_almost_equal(r.y_coord, 0.8030) + assert_almost_equal(r.rect_x, 0.) + assert_equal(r.soldermask_info, '0') + |