Added `drill` output configuration

This commit is contained in:
Salvador E. Tropea 2020-07-12 17:43:15 -03:00
parent b8b1277f5f
commit 36eedc9fce
7 changed files with 50 additions and 34 deletions

View File

@ -14,12 +14,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `regexp` -> `regex`
- `gerber.gerber_job_file` option to control the gerber job file name.
- `output` option to control the file name to all plot output formats.
- `drill.map` file names can be configured.
- `drill` and `drill.map` file names can be configured.
### Changed
- Default file names for:
- pdf_pcb_print: includes the used layers
- drill maps: uses drill instead of drl
- dril: uses drill instead of drl, used in gbr and drl.
## [0.5.0] - 2020-07-11
### Changed

View File

@ -40,6 +40,8 @@ class AnyDrill(BaseOptions):
self.map = DrillMap
""" [dict|string] [hpgl,ps,gerber,dxf,svg,pdf] format for a graphical drill map.
Not generated unless a format is specified """
self.output = '%f-%i.%x'
""" name for the drill file, KiCad defaults if empty (%i='PTH_drill') """
self.report = DrillReport
""" [dict|string] name of the drill report. Not generated unless a name is specified """ # pragma: no cover
# Mappings to KiCad values
@ -78,7 +80,7 @@ class AnyDrill(BaseOptions):
offset = board.GetAuxOrigin()
else:
offset = wxPoint(0, 0)
drill_writer = self._configure_writer(board, offset)
drill_writer, ext = self._configure_writer(board, offset)
logger.debug("Generating drill files in "+output_dir)
gen_map = self.map is not None
@ -88,16 +90,21 @@ class AnyDrill(BaseOptions):
# We always generate the drill file
drill_writer.CreateDrillandMapFilesSet(output_dir, True, gen_map)
# Rename the files
if gen_map and self.map_output:
id = 'PTH_drill_map'
k_file = self.expand_filename(output_dir, '%f-PTH-drl_map.%x', '', self.map_ext)
file = self.expand_filename(output_dir, self.map_output, id, self.map_ext)
os.rename(k_file, file)
id = 'N'+id
k_file = self.expand_filename(output_dir, '%f-NPTH-drl_map.%x', '', self.map_ext)
file = self.expand_filename(output_dir, self.map_output, id, self.map_ext)
os.rename(k_file, file)
for d in ['', 'N']:
if self.output:
id = 'PTH_drill'
if ext == 'drl':
k_file = self.expand_filename(output_dir, '%f-'+d+'PTH.%x', '', ext)
else: # gbr
k_file = self.expand_filename(output_dir, '%f-'+d+'PTH-drl.%x', '', ext)
file = self.expand_filename(output_dir, self.output, d+id, ext)
os.rename(k_file, file)
if gen_map and self.map_output:
id = 'PTH_drill_map'
k_file = self.expand_filename(output_dir, '%f-'+d+'PTH-drl_map.%x', '', self.map_ext)
file = self.expand_filename(output_dir, self.map_output, d+id, self.map_ext)
os.rename(k_file, file)
# Generate the report
if self.report:
drill_report_file = self.expand_filename(output_dir, self.report, 'drill_report', 'txt')
logger.debug("Generating drill report: "+drill_report_file)

View File

@ -20,7 +20,7 @@ class ExcellonOptions(AnyDrill):
drill_writer = EXCELLON_WRITER(board)
drill_writer.SetOptions(self.mirror_y_axis, self.minimal_header, offset, self.pth_and_npth_single_file)
drill_writer.SetFormat(self.metric_units, EXCELLON_WRITER.DECIMAL_FORMAT)
return drill_writer
return drill_writer, 'drl'
@output_class

View File

@ -12,7 +12,7 @@ class Gerb_DrillOptions(AnyDrill):
# hard coded in UI?
drill_writer.SetFormat(5)
drill_writer.SetOptions(offset)
return drill_writer
return drill_writer, 'gbr'
@output_class

View File

@ -23,19 +23,34 @@ DRILL_DIR = 'Drill'
positions = {'R1': (105, 35, 'top'), 'R2': (110, 35, 'bottom'), 'R3': (110, 45, 'top')}
def do_3Rs(conf, dir, report):
def do_3Rs(conf, dir, modern):
ctx = context.TestContext(dir, '3Rs', conf, DRILL_DIR)
ctx.run()
# Check all outputs are there
ctx.expect_out_file(os.path.join(DRILL_DIR, report))
pth_drl = ctx.get_pth_drl_filename()
ctx.expect_out_file(pth_drl)
npth_drl = ctx.get_npth_drl_filename()
ctx.expect_out_file(npth_drl)
pth_gbr_drl = ctx.get_pth_gbr_drl_filename()
ctx.expect_out_file(pth_gbr_drl)
npth_gbr_drl = ctx.get_npth_gbr_drl_filename()
pth_pdf_drl = ctx.get_pth_pdf_drl_filename()
npth_pdf_drl = ctx.get_npth_pdf_drl_filename()
report = 'report.rpt'
if modern:
pth_drl = pth_drl.replace('PTH', 'PTH_drill')
npth_drl = npth_drl.replace('PTH', 'PTH_drill')
pth_gbr_drl = pth_gbr_drl.replace('-drl', '_drill')
npth_gbr_drl = npth_gbr_drl.replace('-drl', '_drill')
pth_pdf_drl = pth_pdf_drl.replace('-drl', '_drill')
npth_pdf_drl = npth_pdf_drl.replace('-drl', '_drill')
report = '3Rs-drill_report.txt'
ctx.expect_out_file(os.path.join(DRILL_DIR, report))
ctx.expect_out_file(pth_drl)
ctx.expect_out_file(npth_drl)
ctx.expect_out_file(pth_gbr_drl)
ctx.expect_out_file(npth_gbr_drl)
ctx.expect_out_file(pth_pdf_drl)
ctx.expect_out_file(npth_pdf_drl)
# We have R3 at (110, 45) length is 9 mm on X, drill 1 mm
ctx.search_in_file(pth_drl, ['X110.0Y-45.0', 'X119.0Y-45.0'])
ctx.expect_gerber_flash_at(pth_gbr_drl, 6, (110, -45))
@ -44,22 +59,13 @@ def do_3Rs(conf, dir, report):
ctx.search_in_file(npth_drl, ['X120.0Y-29.0', 'T1C2.100'])
ctx.expect_gerber_flash_at(npth_gbr_drl, 6, (120, -29))
ctx.expect_gerber_has_apertures(npth_gbr_drl, ['C,2.100000'])
return ctx
ctx.clean_up()
def test_drill_3Rs():
ctx = do_3Rs('drill', 'Drill_3Rs', 'report.rpt')
pth_pdf_drl = ctx.get_pth_pdf_drl_filename()
ctx.expect_out_file(pth_pdf_drl.replace('-drl', '_drill'))
npth_pdf_drl = ctx.get_npth_pdf_drl_filename()
ctx.expect_out_file(npth_pdf_drl.replace('-drl', '_drill'))
ctx.clean_up()
ctx = do_3Rs('drill', 'Drill_3Rs', True)
def test_drill_legacy_3Rs():
ctx = do_3Rs('drill_legacy', 'DrillLegacy_3Rs', '3Rs-drill_report.txt')
pth_pdf_drl = ctx.get_pth_pdf_drl_filename()
ctx.expect_out_file(pth_pdf_drl)
npth_pdf_drl = ctx.get_npth_pdf_drl_filename()
ctx.expect_out_file(npth_pdf_drl)
ctx.clean_up()
ctx = do_3Rs('drill_legacy', 'DrillLegacy_3Rs', False)

View File

@ -14,7 +14,7 @@ outputs:
use_aux_axis_as_origin: false
minimal_header: false
mirror_y_axis: false
report: 'report.rpt'
report: '%f-%i.%x'
map: 'pdf'
- name: gerber_drills

View File

@ -14,8 +14,9 @@ outputs:
use_aux_axis_as_origin: true
minimal_header: false
mirror_y_axis: false
output: ''
report:
filename: '%f-%i.%x'
filename: 'report.rpt'
map:
output: ''
type: 'pdf'
@ -25,5 +26,6 @@ outputs:
type: gerb_drill
dir: Drill
options:
output: ''
use_aux_axis_as_origin: false