61 wxFileName tempDir = MakeTempDir();
62 wxFileName boardFile( tempDir.GetFullPath(), wxT(
"backdrill_board.kicad_pcb" ) );
74 via->SetSecondaryDrillStartLayer(
F_Cu );
79 via->SetFrontPostMachiningAngle( 900 );
87 wxFileName excellonFile( tempDir.GetFullPath(), wxT(
"backdrill_board_Backdrills_Drill_1_4.drl" ) );
90 wxFFile excellonStream( excellonFile.GetFullPath(), wxT(
"rb" ) );
91 wxString excellonContents;
93 BOOST_CHECK( excellonContents.Contains( wxT(
"TF.FileFunction,NonPlated,1,4,Blind" ) ) );
94 BOOST_CHECK( excellonContents.Contains( wxT(
"; Backdrill" ) ) );
95 BOOST_CHECK( excellonContents.Contains( wxT(
"post-machining" ) ) );
97 wxFileName layerPairFile( tempDir.GetFullPath(), wxT(
"backdrill_board-front-in3-backdrill.drl" ) );
100 wxFFile layerPairStream( layerPairFile.GetFullPath(), wxT(
"rb" ) );
101 wxString layerPairContents;
102 BOOST_REQUIRE( layerPairStream.ReadAll( &layerPairContents ) );
103 BOOST_CHECK( layerPairContents.Contains( wxT(
"; backdrill" ) ) );
105 wxFileName pthFile( tempDir.GetFullPath(), wxT(
"backdrill_board-PTH.drl" ) );
108 wxFFile pthStream( pthFile.GetFullPath(), wxT(
"rb" ) );
109 wxString pthContents;
111 BOOST_CHECK( pthContents.Contains( wxT(
"; Post-machining front countersink dia 0.600mm depth 0.150mm angle 90deg" ) ) );
118 wxFileName gerberFile( tempDir.GetFullPath(), wxT(
"backdrill_board_Backdrills_Drill_1_4-drl.gbr" ) );
121 wxFFile gerberStream( gerberFile.GetFullPath(), wxT(
"rb" ) );
122 wxString gerberContents;
124 BOOST_CHECK( gerberContents.Contains( wxT(
"%TA.AperFunction,BackDrill*%" ) ) );
125 BOOST_CHECK( gerberContents.Contains( wxT(
"%TF.FileFunction,NonPlated,1,4,Blind,Drill*%" ) ) );
127 wxFileName gerberLayerPairFile( tempDir.GetFullPath(),
128 wxT(
"backdrill_board-front-in3-backdrill-drl.gbr" ) );
131 wxFFile gerberLayerPairStream( gerberLayerPairFile.GetFullPath(), wxT(
"rb" ) );
132 wxString gerberLayerPairContents;
133 BOOST_REQUIRE( gerberLayerPairStream.ReadAll( &gerberLayerPairContents ) );
134 BOOST_CHECK( gerberLayerPairContents.Contains( wxT(
"%TF.FileFunction,NonPlated,1,4,Blind,Drill*%" ) ) );
135 BOOST_CHECK( gerberLayerPairContents.Contains( wxT(
"%TA.AperFunction,BackDrill*%" ) ) );
137 wxFileName odbRoot( tempDir.GetFullPath(), wxEmptyString );
138 odbRoot.AppendDir( wxT(
"odb_out" ) );
139 BOOST_REQUIRE( odbRoot.Mkdir( wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL ) );
142 std::map<std::string, UTF8> props;
143 props[
"units"] =
"mm";
144 props[
"sigfig"] =
"4";
145 BOOST_REQUIRE_NO_THROW( odbExporter.
SaveBoard( odbRoot.GetFullPath(), &board, &props ) );
147 wxFileName drill1Dir( odbRoot.GetFullPath(), wxEmptyString );
148 drill1Dir.AppendDir( wxT(
"steps" ) );
149 drill1Dir.AppendDir( wxT(
"pcb" ) );
150 drill1Dir.AppendDir( wxT(
"layers" ) );
151 drill1Dir.AppendDir( wxT(
"drill1" ) );
154 wxFileName toolsFile( drill1Dir.GetFullPath(), wxT(
"tools" ) );
157 wxFFile toolsStream( toolsFile.GetFullPath(), wxT(
"rb" ) );
158 wxString toolsContents;
160 BOOST_CHECK( toolsContents.Contains( wxT(
"TYPE=NON_PLATED" ) ) );
161 BOOST_CHECK( toolsContents.Contains( wxT(
"TYPE2=BLIND" ) ) );
163 wxFileName matrixFile( odbRoot.GetFullPath(), wxEmptyString );
164 matrixFile.AppendDir( wxT(
"matrix" ) );
165 matrixFile.SetFullName( wxT(
"matrix" ) );
168 wxFFile matrixStream( matrixFile.GetFullPath(), wxT(
"rb" ) );
169 wxString matrixContents;
171 BOOST_CHECK( matrixContents.Contains( wxT(
"ADD_TYPE=BACKDRILL" ) ) );
173 matrixStream.Close();
175 gerberStream.Close();
176 gerberLayerPairStream.Close();
177 excellonStream.Close();
178 layerPairStream.Close();
181 wxFileName::Rmdir( odbRoot.GetFullPath(), wxPATH_RMDIR_RECURSIVE );
182 wxFileName::Rmdir( tempDir.GetFullPath(), wxPATH_RMDIR_RECURSIVE );
191 wxFileName tempDir = MakeTempDir();
192 wxFileName boardFile( tempDir.GetFullPath(), wxT(
"backdrill_pair_board.kicad_pcb" ) );
198 auto topVia =
new PCB_VIA( &board );
199 topVia->SetPosition(
VECTOR2I( 0, 0 ) );
201 topVia->SetDrill(
pcbIUScale.mmToIU( 0.30 ) );
202 topVia->SetWidth(
pcbIUScale.mmToIU( 0.60 ) );
203 topVia->SetSecondaryDrillSize(
pcbIUScale.mmToIU( 0.40 ) );
204 topVia->SetSecondaryDrillStartLayer(
F_Cu );
205 topVia->SetSecondaryDrillEndLayer(
In1_Cu );
208 auto bottomVia =
new PCB_VIA( &board );
210 bottomVia->SetLayerPair(
F_Cu,
B_Cu );
211 bottomVia->SetDrill(
pcbIUScale.mmToIU( 0.30 ) );
212 bottomVia->SetWidth(
pcbIUScale.mmToIU( 0.60 ) );
213 bottomVia->SetTertiaryDrillSize(
pcbIUScale.mmToIU( 0.40 ) );
214 bottomVia->SetTertiaryDrillStartLayer(
B_Cu );
215 bottomVia->SetTertiaryDrillEndLayer(
In3_Cu );
216 board.
Add( bottomVia );
224 wxFileName topBackdrillFile( tempDir.GetFullPath(),
225 wxT(
"backdrill_pair_board_Backdrills_Drill_1_2.drl" ) );
227 "Front-side backdrill drill file should be produced" );
230 wxFileName bottomBackdrillFile( tempDir.GetFullPath(),
231 wxT(
"backdrill_pair_board_Backdrills_Drill_6_4.drl" ) );
233 "Back-side (tertiary) backdrill drill file should be produced" );
235 if( bottomBackdrillFile.FileExists() )
237 wxFFile stream( bottomBackdrillFile.GetFullPath(), wxT(
"rb" ) );
240 BOOST_CHECK( contents.Contains( wxT(
"; Backdrill" ) ) );
244 wxFileName::Rmdir( tempDir.GetFullPath(), wxPATH_RMDIR_RECURSIVE );
253 wxFileName tempDir = MakeTempDir();
254 wxFileName boardFile( tempDir.GetFullPath(), wxT(
"dual_backdrill_board.kicad_pcb" ) );
266 via->SetSecondaryDrillStartLayer(
F_Cu );
267 via->SetSecondaryDrillEndLayer(
In1_Cu );
269 via->SetTertiaryDrillStartLayer(
B_Cu );
279 wxFileName topBackdrillFile( tempDir.GetFullPath(),
280 wxT(
"dual_backdrill_board_Backdrills_Drill_1_2.drl" ) );
281 BOOST_CHECK( topBackdrillFile.FileExists() );
283 wxFileName bottomBackdrillFile( tempDir.GetFullPath(),
284 wxT(
"dual_backdrill_board_Backdrills_Drill_6_4.drl" ) );
285 BOOST_CHECK( bottomBackdrillFile.FileExists() );
287 wxFileName::Rmdir( tempDir.GetFullPath(), wxPATH_RMDIR_RECURSIVE );
295 wxFileName tempDir = MakeTempDir();
296 wxFileName boardFile( tempDir.GetFullPath(), wxT(
"precision_board.kicad_pcb" ) );
315 wxFileName gerberFile5( tempDir.GetFullPath(), wxT(
"precision_board-PTH-drl.gbr" ) );
318 wxFFile gerberStream5( gerberFile5.GetFullPath(), wxT(
"rb" ) );
319 wxString gerberContents5;
322 "Expected 'Fmt 4.5' in gerber header with precision=5" );
323 BOOST_CHECK( !gerberContents5.Contains( wxT(
"Fmt 4.6" ) ) );
324 gerberStream5.Close();
332 wxFFile gerberStream6( gerberFile5.GetFullPath(), wxT(
"rb" ) );
333 wxString gerberContents6;
336 "Expected 'Fmt 4.6' in gerber header with precision=6" );
337 BOOST_CHECK( !gerberContents6.Contains( wxT(
"Fmt 4.5" ) ) );
338 gerberStream6.Close();
340 wxFileName::Rmdir( tempDir.GetFullPath(), wxPATH_RMDIR_RECURSIVE );
381 wxFileName tempDir = MakeTempDir();
382 wxFileName boardFile( tempDir.GetFullPath(), wxT(
"test_board_with_drills.kicad_pcb" ) );
395 wxFileName reportFile( tempDir.GetFullPath(), wxT(
"test_board_with_drills-drl.rpt" ) );
401 BOOST_CHECK( reportFile.FileExists() );
403 wxFFile reportStream( reportFile.GetFullPath(), wxT(
"rb" ) );
404 wxString reportContents;
406 BOOST_CHECK( reportContents.Contains( wxT(
"T1" ) ) );
407 BOOST_CHECK( reportContents.Contains( wxT(
"0.300mm" ) ) );
408 reportStream.Close();
410 wxFileName::Rmdir( tempDir.GetFullPath(), wxPATH_RMDIR_RECURSIVE );
422 wxFileName tempDir = MakeTempDir();
423 wxFileName boardFile( tempDir.GetFullPath(), wxT(
"silk_rect_board.kicad_pcb" ) );
438 wxFileName odbRoot( tempDir.GetFullPath(), wxEmptyString );
439 odbRoot.AppendDir( wxT(
"odb_out" ) );
440 BOOST_REQUIRE( odbRoot.Mkdir( wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL ) );
443 std::map<std::string, UTF8> props;
444 props[
"units"] =
"mm";
445 props[
"sigfig"] =
"4";
446 BOOST_REQUIRE_NO_THROW( odbExporter.
SaveBoard( odbRoot.GetFullPath(), &board, &props ) );
448 wxFileName silkFeatures( odbRoot.GetFullPath(), wxT(
"features" ) );
449 silkFeatures.AppendDir( wxT(
"steps" ) );
450 silkFeatures.AppendDir( wxT(
"pcb" ) );
451 silkFeatures.AppendDir( wxT(
"layers" ) );
452 silkFeatures.AppendDir( wxT(
"f.silkscreen" ) );
455 wxFFile silkStream( silkFeatures.GetFullPath(), wxT(
"rb" ) );
456 wxString silkContents;
462 wxStringTokenizer lines( silkContents, wxT(
"\n" ) );
464 while( lines.HasMoreTokens() )
466 if( lines.GetNextToken().StartsWith( wxT(
"L " ) ) )
473 BOOST_CHECK( !silkContents.Contains( wxT(
"donut_rc" ) ) );
475 wxFileName::Rmdir( odbRoot.GetFullPath(), wxPATH_RMDIR_RECURSIVE );
476 wxFileName::Rmdir( tempDir.GetFullPath(), wxPATH_RMDIR_RECURSIVE );
BOOST_CHECK_EQUAL(result, "25.4")