2022-02-26 01:47:14 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2023-08-30 10:18:54 +00:00
|
|
|
* Copyright (C) 2020-2023 KiCad Developers.
|
2022-02-26 01:47:14 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
// WARNING - this Tom's crappy PNS hack tool code. Please don't complain about its quality
|
|
|
|
// (unless you want to improve it).
|
|
|
|
|
|
|
|
#include "pns_log_file.h"
|
|
|
|
|
2022-10-23 22:15:32 +00:00
|
|
|
#include <router/pns_segment.h>
|
|
|
|
|
2022-02-26 01:47:14 +00:00
|
|
|
#include <board_design_settings.h>
|
|
|
|
|
|
|
|
#include <pcbnew/plugins/kicad/pcb_plugin.h>
|
|
|
|
#include <pcbnew/drc/drc_engine.h>
|
|
|
|
|
2023-08-06 20:05:28 +00:00
|
|
|
#include <project.h>
|
|
|
|
#include <project/project_local_settings.h>
|
|
|
|
|
2023-04-24 22:40:57 +00:00
|
|
|
#include <../../tests/common/console_log.h>
|
2022-02-26 01:47:14 +00:00
|
|
|
|
2023-08-08 21:33:26 +00:00
|
|
|
BOARD_CONNECTED_ITEM* PNS_LOG_FILE::ItemById( const PNS::LOGGER::EVENT_ENTRY& evt )
|
2022-02-26 01:47:14 +00:00
|
|
|
{
|
|
|
|
BOARD_CONNECTED_ITEM* parent = nullptr;
|
|
|
|
|
2023-08-30 10:18:54 +00:00
|
|
|
for( BOARD_CONNECTED_ITEM* item : m_board->AllConnectedItems() )
|
2022-02-26 01:47:14 +00:00
|
|
|
{
|
|
|
|
if( item->m_Uuid == evt.uuid )
|
|
|
|
{
|
|
|
|
parent = item;
|
|
|
|
break;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
return parent;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const wxString readLine( FILE* f )
|
|
|
|
{
|
|
|
|
char str[16384];
|
|
|
|
fgets( str, sizeof( str ) - 1, f );
|
|
|
|
return wxString( str );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-04-24 22:40:57 +00:00
|
|
|
PNS_LOG_FILE::PNS_LOG_FILE() :
|
2022-10-23 22:15:32 +00:00
|
|
|
m_mode( PNS::ROUTER_MODE::PNS_MODE_ROUTE_SINGLE )
|
2022-02-26 01:47:14 +00:00
|
|
|
{
|
|
|
|
m_routerSettings.reset( new PNS::ROUTING_SETTINGS( nullptr, "" ) );
|
|
|
|
}
|
|
|
|
|
2023-08-29 16:28:37 +00:00
|
|
|
std::shared_ptr<SHAPE> parseShape( SHAPE_TYPE expectedType, wxStringTokenizer& aTokens )
|
2022-10-23 22:15:32 +00:00
|
|
|
{
|
|
|
|
SHAPE_TYPE type = static_cast<SHAPE_TYPE> ( wxAtoi( aTokens.GetNextToken() ) );
|
|
|
|
|
|
|
|
if( type == SHAPE_TYPE::SH_SEGMENT )
|
|
|
|
{
|
2023-08-30 10:18:54 +00:00
|
|
|
std::shared_ptr<SHAPE_SEGMENT> sh( new SHAPE_SEGMENT );
|
|
|
|
VECTOR2I a, b;
|
2022-10-23 22:15:32 +00:00
|
|
|
a.x = wxAtoi( aTokens.GetNextToken() );
|
|
|
|
a.y = wxAtoi( aTokens.GetNextToken() );
|
|
|
|
b.x = wxAtoi( aTokens.GetNextToken() );
|
|
|
|
b.y = wxAtoi( aTokens.GetNextToken() );
|
|
|
|
int width = wxAtoi( aTokens.GetNextToken() );
|
|
|
|
sh->SetSeg( SEG( a, b ));
|
|
|
|
sh->SetWidth( width );
|
|
|
|
return sh;
|
|
|
|
}
|
2023-08-30 10:18:54 +00:00
|
|
|
else if( type == SHAPE_TYPE::SH_CIRCLE )
|
2022-10-23 22:15:32 +00:00
|
|
|
{
|
2023-08-30 10:18:54 +00:00
|
|
|
std::shared_ptr<SHAPE_CIRCLE> sh( new SHAPE_CIRCLE );
|
2022-10-23 22:15:32 +00:00
|
|
|
VECTOR2I a;
|
|
|
|
a.x = wxAtoi( aTokens.GetNextToken() );
|
|
|
|
a.y = wxAtoi( aTokens.GetNextToken() );
|
|
|
|
int radius = wxAtoi( aTokens.GetNextToken() );
|
|
|
|
sh->SetCenter( a );
|
|
|
|
sh->SetRadius( radius );
|
|
|
|
return sh;
|
|
|
|
}
|
|
|
|
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2023-08-29 16:28:37 +00:00
|
|
|
bool PNS_LOG_FILE::parseCommonPnsProps( PNS::ITEM* aItem, const wxString& cmd,
|
|
|
|
wxStringTokenizer& aTokens )
|
2022-10-23 22:15:32 +00:00
|
|
|
{
|
2023-08-30 10:18:54 +00:00
|
|
|
if( cmd == wxS( "net" ) )
|
2023-08-23 15:50:08 +00:00
|
|
|
{
|
2023-08-31 14:05:29 +00:00
|
|
|
aItem->SetNet( m_board->FindNet( aTokens.GetNextToken() ) );
|
|
|
|
return true;
|
2023-08-23 15:50:08 +00:00
|
|
|
}
|
2023-08-30 10:18:54 +00:00
|
|
|
else if( cmd == wxS( "layers" ) )
|
2023-08-23 15:50:08 +00:00
|
|
|
{
|
|
|
|
int start = wxAtoi( aTokens.GetNextToken() );
|
|
|
|
int end = wxAtoi( aTokens.GetNextToken() );
|
|
|
|
aItem->SetLayers( LAYER_RANGE( start, end ) );
|
|
|
|
return true;
|
|
|
|
}
|
2023-08-22 21:10:14 +00:00
|
|
|
return false;
|
2022-10-23 22:15:32 +00:00
|
|
|
}
|
|
|
|
|
2023-08-31 14:03:03 +00:00
|
|
|
PNS::SEGMENT* PNS_LOG_FILE::parsePnsSegmentFromString( wxStringTokenizer& aTokens )
|
2022-10-23 22:15:32 +00:00
|
|
|
{
|
2023-08-30 10:18:54 +00:00
|
|
|
PNS::SEGMENT* seg = new PNS::SEGMENT();
|
2022-10-23 22:15:32 +00:00
|
|
|
|
|
|
|
while( aTokens.CountTokens() )
|
|
|
|
{
|
2023-08-30 10:18:54 +00:00
|
|
|
wxString cmd = aTokens.GetNextToken();
|
|
|
|
|
|
|
|
if( !parseCommonPnsProps( seg, cmd, aTokens ) )
|
|
|
|
{
|
|
|
|
if( cmd == wxS( "shape" ) )
|
2022-10-23 22:15:32 +00:00
|
|
|
{
|
2023-08-30 10:18:54 +00:00
|
|
|
std::shared_ptr<SHAPE> sh = parseShape( SH_SEGMENT, aTokens );
|
2023-04-24 22:40:57 +00:00
|
|
|
|
2023-08-30 10:18:54 +00:00
|
|
|
if( !sh )
|
|
|
|
return nullptr;
|
2023-04-24 22:40:57 +00:00
|
|
|
|
2023-08-30 22:38:18 +00:00
|
|
|
seg->SetShape( *static_cast<SHAPE_SEGMENT*>( sh.get() ) );
|
2023-04-24 22:40:57 +00:00
|
|
|
|
2022-10-23 22:15:32 +00:00
|
|
|
}
|
2023-08-30 10:18:54 +00:00
|
|
|
}
|
2022-10-23 22:15:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return seg;
|
|
|
|
}
|
|
|
|
|
2023-08-31 14:03:03 +00:00
|
|
|
PNS::VIA* PNS_LOG_FILE::parsePnsViaFromString( wxStringTokenizer& aTokens )
|
2022-10-23 22:15:32 +00:00
|
|
|
{
|
2023-08-30 10:18:54 +00:00
|
|
|
PNS::VIA* via = new PNS::VIA();
|
2022-10-23 22:15:32 +00:00
|
|
|
|
|
|
|
while( aTokens.CountTokens() )
|
|
|
|
{
|
2023-08-30 10:18:54 +00:00
|
|
|
wxString cmd = aTokens.GetNextToken();
|
|
|
|
|
|
|
|
if( !parseCommonPnsProps( via, cmd, aTokens ) )
|
|
|
|
{
|
|
|
|
if( cmd == wxS( "shape" ) )
|
2022-10-23 22:15:32 +00:00
|
|
|
{
|
2023-08-30 10:18:54 +00:00
|
|
|
std::shared_ptr<SHAPE> sh = parseShape( SH_CIRCLE, aTokens );
|
|
|
|
|
|
|
|
if( !sh )
|
|
|
|
return nullptr;
|
|
|
|
|
|
|
|
SHAPE_CIRCLE* sc = static_cast<SHAPE_CIRCLE*>( sh.get() );
|
|
|
|
|
|
|
|
via->SetPos( sc->GetCenter() );
|
|
|
|
via->SetDiameter( 2 * sc->GetRadius() );
|
2022-10-23 22:15:32 +00:00
|
|
|
}
|
2023-08-30 10:18:54 +00:00
|
|
|
else if( cmd == wxS( "drill" ) )
|
|
|
|
{
|
|
|
|
via->SetDrill( wxAtoi( aTokens.GetNextToken() ) );
|
|
|
|
}
|
|
|
|
}
|
2022-10-23 22:15:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return via;
|
|
|
|
}
|
|
|
|
|
2022-02-26 01:47:14 +00:00
|
|
|
|
2023-08-29 16:28:37 +00:00
|
|
|
PNS::ITEM* PNS_LOG_FILE::parseItemFromString( wxStringTokenizer& aTokens )
|
2022-10-23 22:15:32 +00:00
|
|
|
{
|
|
|
|
wxString type = aTokens.GetNextToken();
|
|
|
|
|
2023-08-30 10:18:54 +00:00
|
|
|
if( type == wxS( "segment" ) )
|
2023-08-31 14:03:03 +00:00
|
|
|
return parsePnsSegmentFromString( aTokens );
|
2023-08-30 10:18:54 +00:00
|
|
|
else if( type == wxS( "via" ) )
|
2023-08-31 14:03:03 +00:00
|
|
|
return parsePnsViaFromString( aTokens );
|
2022-10-23 22:15:32 +00:00
|
|
|
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2023-08-30 10:18:54 +00:00
|
|
|
bool comparePnsItems( const PNS::ITEM* a , const PNS::ITEM* b )
|
2022-10-23 22:15:32 +00:00
|
|
|
{
|
|
|
|
if( a->Kind() != b->Kind() )
|
|
|
|
return false;
|
2023-04-24 22:40:57 +00:00
|
|
|
|
2022-10-23 22:15:32 +00:00
|
|
|
if( a->Net() != b->Net() )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if( a->Layers() != b->Layers() )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if( a->Kind() == PNS::ITEM::VIA_T )
|
|
|
|
{
|
2023-08-30 10:18:54 +00:00
|
|
|
const PNS::VIA* va = static_cast<const PNS::VIA*>(a);
|
|
|
|
const PNS::VIA* vb = static_cast<const PNS::VIA*>(b);
|
2022-10-23 22:15:32 +00:00
|
|
|
|
|
|
|
if( va->Diameter() != vb->Diameter() )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if( va->Drill() != vb->Drill() )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if( va->Pos() != vb->Pos() )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
else if ( a->Kind() == PNS::ITEM::SEGMENT_T )
|
|
|
|
{
|
2023-08-30 10:18:54 +00:00
|
|
|
const PNS::SEGMENT* sa = static_cast<const PNS::SEGMENT*>(a);
|
|
|
|
const PNS::SEGMENT* sb = static_cast<const PNS::SEGMENT*>(b);
|
2022-10-23 22:15:32 +00:00
|
|
|
|
|
|
|
if( sa->Seg() != sb->Seg() )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if( sa->Width() != sb->Width() )
|
|
|
|
return false;
|
|
|
|
}
|
2023-04-24 22:40:57 +00:00
|
|
|
|
2022-10-23 22:15:32 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-08-08 21:33:26 +00:00
|
|
|
const std::set<PNS::ITEM*> deduplicate( const std::vector<PNS::ITEM*>& items )
|
2023-05-31 14:40:27 +00:00
|
|
|
{
|
|
|
|
std::set<PNS::ITEM*> rv;
|
|
|
|
|
2023-08-30 10:18:54 +00:00
|
|
|
for( PNS::ITEM* item : items )
|
2023-05-31 14:40:27 +00:00
|
|
|
{
|
|
|
|
bool isDuplicate = false;
|
2023-08-30 10:18:54 +00:00
|
|
|
|
|
|
|
for( PNS::ITEM* ritem : rv )
|
2023-05-31 14:40:27 +00:00
|
|
|
{
|
|
|
|
if( comparePnsItems( ritem, item) )
|
|
|
|
{
|
|
|
|
isDuplicate = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( !isDuplicate )
|
|
|
|
rv.insert( item );
|
|
|
|
}
|
|
|
|
}
|
2023-08-08 18:43:42 +00:00
|
|
|
|
2023-05-31 14:40:27 +00:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-10-23 22:15:32 +00:00
|
|
|
bool PNS_LOG_FILE::COMMIT_STATE::Compare( const PNS_LOG_FILE::COMMIT_STATE& aOther )
|
|
|
|
{
|
|
|
|
COMMIT_STATE check( aOther );
|
|
|
|
|
|
|
|
//printf("pre-compare: %d/%d\n", check.m_addedItems.size(), check.m_removedIds.size() );
|
|
|
|
//printf("pre-compare (log): %d/%d\n", m_addedItems.size(), m_removedIds.size() );
|
|
|
|
|
2023-08-08 21:33:26 +00:00
|
|
|
for( const KIID& uuid : m_removedIds )
|
2022-10-23 22:15:32 +00:00
|
|
|
{
|
|
|
|
if( check.m_removedIds.find( uuid ) != check.m_removedIds.end() )
|
|
|
|
check.m_removedIds.erase( uuid );
|
|
|
|
else
|
|
|
|
return false; // removed twice? wtf
|
|
|
|
}
|
|
|
|
|
2023-08-30 10:18:54 +00:00
|
|
|
std::set<PNS::ITEM*> addedItems = deduplicate( m_addedItems );
|
|
|
|
std::set<PNS::ITEM*> chkAddedItems = deduplicate( check.m_addedItems );
|
2023-05-31 14:40:27 +00:00
|
|
|
|
2023-08-30 10:18:54 +00:00
|
|
|
for( PNS::ITEM* item : addedItems )
|
2022-10-23 22:15:32 +00:00
|
|
|
{
|
2023-08-30 10:18:54 +00:00
|
|
|
for( PNS::ITEM* chk : chkAddedItems )
|
2022-10-23 22:15:32 +00:00
|
|
|
{
|
|
|
|
if( comparePnsItems( item, chk ) )
|
|
|
|
{
|
2023-05-31 14:40:27 +00:00
|
|
|
chkAddedItems.erase( chk );
|
2022-10-23 22:15:32 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-05-31 14:40:27 +00:00
|
|
|
//printf("post-compare: %d/%d\n", chkAddedItems.size(), check.m_removedIds.size() );
|
2022-10-23 22:15:32 +00:00
|
|
|
|
2023-08-30 23:25:01 +00:00
|
|
|
if( chkAddedItems.empty() && check.m_removedIds.empty() )
|
|
|
|
return true;
|
|
|
|
else
|
|
|
|
return false; // Set breakpoint here to trap failing tests
|
2022-10-23 22:15:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-08-08 18:43:42 +00:00
|
|
|
bool PNS_LOG_FILE::SaveLog( const wxFileName& logFileName, REPORTER* aRpt )
|
|
|
|
{
|
|
|
|
std::vector<PNS::ITEM*> dummyHeads; // todo - save heads when we support it in QA
|
|
|
|
|
|
|
|
FILE* log_f = wxFopen( logFileName.GetFullPath(), "wb" );
|
|
|
|
wxString logString = PNS::LOGGER::FormatLogFileAsString( m_mode, m_commitState.m_addedItems,
|
|
|
|
m_commitState.m_removedIds, dummyHeads,
|
|
|
|
m_events );
|
|
|
|
fprintf( log_f, "%s\n", logString.c_str().AsChar() );
|
|
|
|
fclose( log_f );
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-10-23 22:15:32 +00:00
|
|
|
bool PNS_LOG_FILE::Load( const wxFileName& logFileName, REPORTER* aRpt )
|
2022-02-26 01:47:14 +00:00
|
|
|
{
|
2022-06-03 21:24:59 +00:00
|
|
|
wxFileName fname_log( logFileName );
|
|
|
|
fname_log.SetExt( wxT( "log" ) );
|
|
|
|
|
|
|
|
wxFileName fname_dump( logFileName );
|
|
|
|
fname_dump.SetExt( wxT( "dump" ) );
|
|
|
|
|
|
|
|
wxFileName fname_project( logFileName );
|
|
|
|
fname_project.SetExt( wxT( "kicad_pro" ) );
|
|
|
|
fname_project.MakeAbsolute();
|
|
|
|
|
2022-10-23 22:15:32 +00:00
|
|
|
wxFileName fname_settings( logFileName );
|
|
|
|
fname_settings.SetExt( wxT( "settings" ) );
|
|
|
|
|
2023-08-30 10:18:54 +00:00
|
|
|
aRpt->Report( wxString::Format( wxT( "Loading router settings from '%s'" ),
|
|
|
|
fname_settings.GetFullPath() ) );
|
2023-04-24 22:40:57 +00:00
|
|
|
|
2022-10-23 22:15:32 +00:00
|
|
|
bool ok = m_routerSettings->LoadFromRawFile( fname_settings.GetFullPath() );
|
|
|
|
|
|
|
|
if( !ok )
|
|
|
|
{
|
2023-08-30 22:38:18 +00:00
|
|
|
aRpt->Report( wxT( "Failed to load routing settings. Using defaults." ),
|
2023-08-30 10:18:54 +00:00
|
|
|
RPT_SEVERITY_WARNING );
|
2022-10-23 22:15:32 +00:00
|
|
|
}
|
|
|
|
|
2023-08-30 10:18:54 +00:00
|
|
|
aRpt->Report( wxString::Format( wxT( "Loading project settings from '%s'" ),
|
|
|
|
fname_settings.GetFullPath() ) );
|
2023-04-24 22:40:57 +00:00
|
|
|
|
2022-06-03 21:24:59 +00:00
|
|
|
m_settingsMgr.reset( new SETTINGS_MANAGER ( true ) );
|
|
|
|
m_settingsMgr->LoadProject( fname_project.GetFullPath() );
|
2023-08-07 22:28:50 +00:00
|
|
|
PROJECT* project = m_settingsMgr->GetProject( fname_project.GetFullPath() );
|
|
|
|
project->SetReadOnly();
|
2022-06-03 21:24:59 +00:00
|
|
|
|
2022-02-26 01:47:14 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
PCB_PLUGIN io;
|
2023-08-30 22:38:18 +00:00
|
|
|
aRpt->Report( wxString::Format( wxT("Loading board snapshot from '%s'"),
|
|
|
|
fname_dump.GetFullPath() ) );
|
2022-10-23 22:15:32 +00:00
|
|
|
|
2023-08-15 03:55:32 +00:00
|
|
|
m_board.reset( io.LoadBoard( fname_dump.GetFullPath(), nullptr, nullptr ) );
|
2023-08-07 22:28:50 +00:00
|
|
|
m_board->SetProject( project );
|
2022-02-26 01:47:14 +00:00
|
|
|
|
|
|
|
std::shared_ptr<DRC_ENGINE> drcEngine( new DRC_ENGINE );
|
|
|
|
|
|
|
|
CONSOLE_LOG consoleLog;
|
|
|
|
BOARD_DESIGN_SETTINGS& bds = m_board->GetDesignSettings();
|
|
|
|
|
|
|
|
bds.m_DRCEngine = drcEngine;
|
2023-08-07 22:28:50 +00:00
|
|
|
bds.m_UseConnectedTrackWidth = project->GetLocalSettings().m_AutoTrackWidth;
|
2022-02-26 01:47:14 +00:00
|
|
|
|
2022-11-22 17:24:44 +00:00
|
|
|
m_board->SynchronizeNetsAndNetClasses( true );
|
2022-06-03 21:24:59 +00:00
|
|
|
|
2022-02-26 01:47:14 +00:00
|
|
|
drcEngine->SetBoard( m_board.get() );
|
|
|
|
drcEngine->SetDesignSettings( &bds );
|
|
|
|
drcEngine->SetLogReporter( new CONSOLE_MSG_REPORTER( &consoleLog ) );
|
|
|
|
drcEngine->InitEngine( wxFileName() );
|
|
|
|
}
|
|
|
|
catch( const PARSE_ERROR& parse_error )
|
|
|
|
{
|
2023-08-30 22:38:18 +00:00
|
|
|
aRpt->Report( wxString::Format( "parse error : %s (%s)\n",
|
|
|
|
parse_error.Problem(),
|
|
|
|
parse_error.What() ),
|
|
|
|
RPT_SEVERITY_ERROR );
|
2022-02-26 01:47:14 +00:00
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2023-08-29 16:28:37 +00:00
|
|
|
FILE* f = fopen( fname_log.GetFullPath().c_str(), "rb" );
|
|
|
|
|
|
|
|
aRpt->Report( wxString::Format( "Loading log from '%s'", fname_log.GetFullPath() ) );
|
|
|
|
|
|
|
|
if( !f )
|
|
|
|
{
|
|
|
|
aRpt->Report( wxT( "Failed to load log" ), RPT_SEVERITY_ERROR );
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
while( !feof( f ) )
|
|
|
|
{
|
|
|
|
wxString line = readLine( f );
|
|
|
|
wxStringTokenizer tokens( line );
|
|
|
|
|
|
|
|
if( !tokens.CountTokens() )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
wxString cmd = tokens.GetNextToken();
|
|
|
|
|
2023-08-30 10:18:54 +00:00
|
|
|
if( cmd == wxT( "mode" ) )
|
2023-08-29 16:28:37 +00:00
|
|
|
{
|
|
|
|
m_mode = static_cast<PNS::ROUTER_MODE>( wxAtoi( tokens.GetNextToken() ) );
|
|
|
|
}
|
2023-08-30 10:18:54 +00:00
|
|
|
else if( cmd == wxT( "event" ) )
|
2023-08-29 16:28:37 +00:00
|
|
|
{
|
|
|
|
m_events.push_back( PNS::LOGGER::ParseEvent( line ) );
|
|
|
|
}
|
2023-08-30 10:18:54 +00:00
|
|
|
else if ( cmd == wxT( "added" ) )
|
2023-08-29 16:28:37 +00:00
|
|
|
{
|
2023-08-30 10:18:54 +00:00
|
|
|
PNS::ITEM* item = parseItemFromString( tokens );
|
2023-08-29 16:28:37 +00:00
|
|
|
m_commitState.m_addedItems.push_back( item );
|
|
|
|
}
|
2023-08-30 10:18:54 +00:00
|
|
|
else if ( cmd == wxT( "removed" ) )
|
2023-08-29 16:28:37 +00:00
|
|
|
{
|
|
|
|
m_commitState.m_removedIds.insert( KIID( tokens.GetNextToken() ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fclose( f );
|
|
|
|
|
2022-02-26 01:47:14 +00:00
|
|
|
return true;
|
|
|
|
}
|