37#include <../../tests/common/console_log.h>
43 for(
auto item :
m_board->AllConnectedItems() )
45 if( item->m_Uuid == evt.
uuid )
58 fgets( str,
sizeof( str ) - 1, f );
59 return wxString( str );
64 m_mode(
PNS::ROUTER_MODE::PNS_MODE_ROUTE_SINGLE )
77 a.
x = wxAtoi( aTokens.GetNextToken() );
78 a.
y = wxAtoi( aTokens.GetNextToken() );
79 b.
x = wxAtoi( aTokens.GetNextToken() );
80 b.
y = wxAtoi( aTokens.GetNextToken() );
81 int width = wxAtoi( aTokens.GetNextToken() );
82 sh->SetSeg(
SEG( a, b ));
83 sh->SetWidth( width );
91 a.
x = wxAtoi( aTokens.GetNextToken() );
92 a.
y = wxAtoi( aTokens.GetNextToken() );
93 int radius = wxAtoi( aTokens.GetNextToken() );
95 sh->SetRadius( radius );
106 aItem->
SetNet( wxAtoi( aTokens.GetNextToken() ) );
108 }
else if ( cmd ==
"layers" )
110 int start = wxAtoi( aTokens.GetNextToken() );
111 int end = wxAtoi( aTokens.GetNextToken() );
123 while( aTokens.CountTokens() )
125 wxString cmd = aTokens.GetNextToken();
128 if ( cmd ==
"shape" )
148 while( aTokens.CountTokens() )
150 wxString cmd = aTokens.GetNextToken();
153 if ( cmd ==
"shape" )
162 via->SetPos( sc->GetCenter() );
163 via->SetDiameter( 2 * sc->GetRadius() );
165 else if ( cmd ==
"drill" )
167 via->SetDrill( wxAtoi( aTokens.GetNextToken() ) );
178 wxString type = aTokens.GetNextToken();
180 if( type ==
"segment" )
185 else if( type ==
"via" )
199 if( a->
Net() != b->
Net() )
207 auto va =
static_cast<const PNS::VIA*
>(a);
208 auto vb =
static_cast<const PNS::VIA*
>(b);
210 if( va->Diameter() != vb->Diameter() )
213 if( va->Drill() != vb->Drill() )
216 if( va->Pos() != vb->Pos() )
225 if( sa->Seg() != sb->Seg() )
228 if( sa->Width() != sb->Width() )
236const std::set<PNS::ITEM*>
deduplicate(
const std::set<PNS::ITEM*>& items )
238 std::set<PNS::ITEM*> rv;
240 for(
auto item : items )
242 bool isDuplicate =
false;
243 for (
auto ritem : rv )
282 for(
auto item : addedItems )
284 for(
auto chk : chkAddedItems )
288 chkAddedItems.erase( chk );
296 return chkAddedItems.empty() && check.
m_removedIds.empty();
302 wxFileName fname_log( logFileName );
303 fname_log.SetExt( wxT(
"log" ) );
305 wxFileName fname_dump( logFileName );
306 fname_dump.SetExt( wxT(
"dump" ) );
308 wxFileName fname_project( logFileName );
309 fname_project.SetExt( wxT(
"kicad_pro" ) );
310 fname_project.MakeAbsolute();
312 wxFileName fname_settings( logFileName );
313 fname_settings.SetExt( wxT(
"settings" ) );
316 FILE* f = fopen( fname_log.GetFullPath().c_str(),
"rb" );
318 aRpt->
Report( wxString::Format(
"Loading log from '%s'", fname_log.GetFullPath() ) );
325 wxStringTokenizer tokens(
readLine( f ) );
327 if( !tokens.CountTokens() )
330 wxString cmd = tokens.GetNextToken();
332 if( cmd == wxT(
"mode") )
336 else if( cmd == wxT(
"event") )
339 evt.
p.
x = wxAtoi( tokens.GetNextToken() );
340 evt.
p.
y = wxAtoi( tokens.GetNextToken() );
342 evt.
uuid =
KIID( tokens.GetNextToken() );
345 else if ( cmd == wxT(
"added") )
350 else if ( cmd == wxT(
"removed") )
358 aRpt->
Report( wxString::Format( wxT(
"Loading router settings from '%s'"), fname_settings.GetFullPath() ) );
360 bool ok =
m_routerSettings->LoadFromRawFile( fname_settings.GetFullPath() );
367 aRpt->
Report( wxString::Format( wxT(
"Loading project settings from '%s'"), fname_settings.GetFullPath() ) );
375 aRpt->
Report( wxString::Format( wxT(
"Loading board snapshot from '%s'"), fname_dump.GetFullPath() ) );
377 m_board.reset( io.
Load( fname_dump.GetFullPath(),
nullptr,
nullptr ) );
380 std::shared_ptr<DRC_ENGINE> drcEngine(
new DRC_ENGINE );
387 m_board->SynchronizeNetsAndNetClasses(
true );
389 drcEngine->SetBoard(
m_board.get() );
390 drcEngine->SetDesignSettings( &bds );
392 drcEngine->InitEngine( wxFileName() );
396 aRpt->
Report( wxString::Format(
"parse error : %s (%s)\n", parse_error.
Problem(),
A base class derived from BOARD_ITEM for items that can be connected and have a net,...
Container for design settings for a BOARD object.
std::shared_ptr< DRC_ENGINE > m_DRCEngine
Design Rule Checker object that performs all the DRC tests.
virtual const wxString What() const
A composite of Problem() and Where()
virtual const wxString Problem() const
what was the problem?
Represent a contiguous set of PCB layers.
A PLUGIN derivation for saving and loading Pcbnew s-expression formatted files.
BOARD * Load(const wxString &aFileName, BOARD *aAppendToMe, const STRING_UTF8_MAP *aProperties=nullptr, PROJECT *aProject=nullptr, PROGRESS_REPORTER *aProgressReporter=nullptr) override
Load information from some input file format that this PLUGIN implementation knows about into either ...
Base class for PNS router board items.
void SetLayers(const LAYER_RANGE &aLayers)
PnsKind Kind() const
Return the type (kind) of the item.
const LAYER_RANGE & Layers() const
Contain all persistent settings of the router, such as the mode, optimization effort,...
void SetShape(const SHAPE_SEGMENT &aShape)
bool Load(const wxFileName &logFileName, REPORTER *aRpt)
std::shared_ptr< BOARD > m_board
std::shared_ptr< SETTINGS_MANAGER > m_settingsMgr
BOARD_CONNECTED_ITEM * ItemById(const EVENT_ENTRY &evt)
COMMIT_STATE m_commitState
std::vector< EVENT_ENTRY > m_events
std::unique_ptr< PNS::ROUTING_SETTINGS > m_routerSettings
A pure virtual class used to derive REPORTER objects from.
virtual REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)=0
Report a string with a given severity.
Push and Shove diff pair dimensions (gap) settings dialog.
static PNS::VIA * parsePnsViaFromString(PNS::VIA *aSeg, wxStringTokenizer &aTokens)
static std::shared_ptr< SHAPE > parseShape(SHAPE_TYPE expectedType, wxStringTokenizer &aTokens)
const std::set< PNS::ITEM * > deduplicate(const std::set< PNS::ITEM * > &items)
bool parseCommonPnsProps(PNS::ITEM *aItem, const wxString &cmd, wxStringTokenizer &aTokens)
static PNS::ITEM * parseItemFromString(wxStringTokenizer &aTokens)
bool comparePnsItems(const PNS::ITEM *a, const PNS::ITEM *b)
static const wxString readLine(FILE *f)
static PNS::SEGMENT * parsePnsSegmentFromString(PNS::SEGMENT *aSeg, wxStringTokenizer &aTokens)
SHAPE_TYPE
Lists all supported shapes.
A filename or source description, a problem input line, a line number, a byte offset,...
std::set< KIID > m_removedIds
std::set< PNS::ITEM * > m_addedItems
bool Compare(const COMMIT_STATE &aOther)
PNS::LOGGER::EVENT_TYPE type