40#include <../../tests/common/console_log.h>
48 if( item->m_Uuid == evt.
uuid )
61 fgets( str,
sizeof( str ) - 1, f );
62 return wxString( str );
67 m_mode(
PNS::ROUTER_MODE::PNS_MODE_ROUTE_SINGLE )
77 if( type == SHAPE_TYPE::SH_SEGMENT )
81 a.
x = wxAtoi( aTokens.GetNextToken() );
82 a.
y = wxAtoi( aTokens.GetNextToken() );
83 b.
x = wxAtoi( aTokens.GetNextToken() );
84 b.
y = wxAtoi( aTokens.GetNextToken() );
85 int width = wxAtoi( aTokens.GetNextToken() );
86 sh->SetSeg(
SEG( a, b ));
87 sh->SetWidth( width );
90 else if( type == SHAPE_TYPE::SH_CIRCLE )
94 a.
x = wxAtoi( aTokens.GetNextToken() );
95 a.
y = wxAtoi( aTokens.GetNextToken() );
96 int radius = wxAtoi( aTokens.GetNextToken() );
98 sh->SetRadius( radius );
106 wxStringTokenizer& aTokens )
108 if( cmd == wxS(
"net" ) )
110 aItem->
SetNet(
m_board->FindNet( wxAtoi( aTokens.GetNextToken() ) ) );
113 else if( cmd == wxS(
"layers" ) )
115 int start = wxAtoi( aTokens.GetNextToken() );
116 int end = wxAtoi( aTokens.GetNextToken() );
125 std::unique_ptr<PNS::SEGMENT> seg(
new PNS::SEGMENT() );
127 while( aTokens.CountTokens() )
129 wxString cmd = aTokens.GetNextToken();
133 if( cmd == wxS(
"shape" ) )
153 while( aTokens.CountTokens() )
155 wxString cmd = aTokens.GetNextToken();
159 if( cmd == wxS(
"shape" ) )
171 else if( cmd == wxS(
"drill" ) )
173 via->SetDrill( wxAtoi( aTokens.GetNextToken() ) );
184 wxString type = aTokens.GetNextToken();
186 if( type == wxS(
"segment" ) )
188 else if( type == wxS(
"via" ) )
199 if( a->
Net() != b->
Net() )
216 if( va->
Pos() != vb->
Pos() )
225 if( sa->
Seg() != sb->
Seg() )
236const std::set<PNS::ITEM*>
deduplicate(
const std::vector<PNS::ITEM*>& items )
238 std::set<PNS::ITEM*> rv;
242 bool isDuplicate =
false;
285 chkAddedItems.erase( chk );
293 if( chkAddedItems.empty() && check.
m_removedIds.empty() )
302 FILE* log_f = wxFopen( logFileName.GetFullPath(),
"wb" );
307 fprintf( log_f,
"%s\n", logString.c_str().AsChar() );
316 wxFileName fname_log( logFileName );
317 fname_log.SetExt( wxT(
"log" ) );
319 wxFileName fname_dump( logFileName );
320 fname_dump.SetExt( wxT(
"dump" ) );
322 wxFileName fname_project( logFileName );
323 fname_project.SetExt( wxT(
"kicad_pro" ) );
324 fname_project.MakeAbsolute();
326 wxFileName fname_settings( logFileName );
327 fname_settings.SetExt( wxT(
"settings" ) );
329 aRpt->
Report( wxString::Format( wxT(
"Loading router settings from '%s'" ),
330 fname_settings.GetFullPath() ) );
332 bool ok =
m_routerSettings->LoadFromRawFile( fname_settings.GetFullPath() );
336 aRpt->
Report( wxT(
"Failed to load routing settings. Using defaults." ),
340 aRpt->
Report( wxString::Format( wxT(
"Loading project settings from '%s'" ),
341 fname_settings.GetFullPath() ) );
351 aRpt->
Report( wxString::Format( wxT(
"Loading board snapshot from '%s'"),
352 fname_dump.GetFullPath() ) );
354 m_board.reset( io.
LoadBoard( fname_dump.GetFullPath(),
nullptr,
nullptr ) );
357 std::shared_ptr<DRC_ENGINE> drcEngine(
new DRC_ENGINE );
364 m_board->SynchronizeNetsAndNetClasses(
true );
366 drcEngine->SetBoard(
m_board.get() );
367 drcEngine->SetDesignSettings( &bds );
368 drcEngine->SetLogReporter( aRpt );
369 drcEngine->InitEngine( wxFileName() );
373 aRpt->
Report( wxString::Format(
"parse error : %s (%s)\n",
375 parse_error.
What() ),
381 FILE* f = fopen( fname_log.GetFullPath().c_str(),
"rb" );
383 aRpt->
Report( wxString::Format(
"Loading log from '%s'", fname_log.GetFullPath() ) );
394 wxStringTokenizer tokens( line );
396 if( !tokens.CountTokens() )
399 wxString cmd = tokens.GetNextToken();
401 if( cmd == wxT(
"mode" ) )
405 else if( cmd == wxT(
"event" ) )
409 else if ( cmd == wxT(
"added" ) )
414 else if ( cmd == wxT(
"removed" ) )
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
bool m_UseConnectedTrackWidth
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?
A #PLUGIN derivation for saving and loading Pcbnew s-expression formatted files.
BOARD * LoadBoard(const wxString &aFileName, BOARD *aAppendToMe, const std::map< std::string, UTF8 > *aProperties=nullptr, PROJECT *aProject=nullptr) override
Load information from some input file format that this PCB_IO implementation knows about into either ...
Base class for PNS router board items.
void SetLayers(const PNS_LAYER_RANGE &aLayers)
const PNS_LAYER_RANGE & Layers() const
virtual NET_HANDLE Net() const
PnsKind Kind() const
Return the type (kind) of the item.
void SetNet(NET_HANDLE aNet)
static wxString FormatLogFileAsString(int aMode, const std::vector< ITEM * > &aAddedItems, const std::set< KIID > &aRemovedItems, const std::vector< ITEM * > &aHeads, const std::vector< EVENT_ENTRY > &aEvents)
static EVENT_ENTRY ParseEvent(const wxString &aLine)
Contain all persistent settings of the router, such as the mode, optimization effort,...
int Width() const override
const VECTOR2I & Pos() const
Represent a contiguous set of PCB layers.
BOARD_CONNECTED_ITEM * ItemById(const PNS::LOGGER::EVENT_ENTRY &evt)
bool Load(const wxFileName &logFileName, REPORTER *aRpt)
bool SaveLog(const wxFileName &logFileName, REPORTER *aRpt)
std::unique_ptr< PNS::SEGMENT > parsePnsSegmentFromString(wxStringTokenizer &aTokens)
std::shared_ptr< BOARD > m_board
std::shared_ptr< SETTINGS_MANAGER > m_settingsMgr
std::shared_ptr< SHAPE > parseShape(SHAPE_TYPE expectedType, wxStringTokenizer &aTokens)
std::vector< std::unique_ptr< PNS::ITEM > > m_parsed_items
std::unique_ptr< PNS::ITEM > parseItemFromString(wxStringTokenizer &aTokens)
std::unique_ptr< PNS::VIA > parsePnsViaFromString(wxStringTokenizer &aTokens)
bool parseCommonPnsProps(PNS::ITEM *aItem, const wxString &cmd, wxStringTokenizer &aTokens)
COMMIT_STATE m_commitState
std::vector< PNS::LOGGER::EVENT_ENTRY > m_events
std::unique_ptr< PNS::ROUTING_SETTINGS > m_routerSettings
Container for project specific data.
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.
const VECTOR2I GetCenter() const
Push and Shove diff pair dimensions (gap) settings dialog.
bool comparePnsItems(const PNS::ITEM *a, const PNS::ITEM *b)
static const wxString readLine(FILE *f)
const std::set< PNS::ITEM * > deduplicate(const std::vector< PNS::ITEM * > &items)
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
bool Compare(const COMMIT_STATE &aOther)
std::vector< PNS::ITEM * > m_addedItems
std::vector< PNS::ITEM * > m_heads