2014-05-14 13:53:54 +00:00
|
|
|
/*
|
|
|
|
* KiRouter - a push-and-(sometimes-)shove PCB router
|
|
|
|
*
|
|
|
|
* Copyright (C) 2013-2014 CERN
|
2023-03-02 14:04:37 +00:00
|
|
|
* Copyright (C) 2016-2023 KiCad Developers, see AUTHORS.txt for contributors.
|
2014-05-14 13:53:54 +00:00
|
|
|
* Author: Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
|
|
|
|
*
|
|
|
|
* 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 3 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, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "pns_logger.h"
|
|
|
|
#include "pns_item.h"
|
|
|
|
#include "pns_via.h"
|
|
|
|
|
2021-06-01 05:17:57 +00:00
|
|
|
#include <wx/log.h>
|
|
|
|
|
2016-08-29 14:38:11 +00:00
|
|
|
namespace PNS {
|
|
|
|
|
2016-08-29 17:31:13 +00:00
|
|
|
LOGGER::LOGGER( )
|
2014-05-14 13:53:54 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-08-29 17:31:13 +00:00
|
|
|
LOGGER::~LOGGER()
|
2014-05-14 13:53:54 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2014-05-16 11:37:31 +00:00
|
|
|
|
2016-08-29 17:31:13 +00:00
|
|
|
void LOGGER::Clear()
|
2014-05-14 13:53:54 +00:00
|
|
|
{
|
2020-04-16 22:29:28 +00:00
|
|
|
m_events.clear();
|
2014-05-14 13:53:54 +00:00
|
|
|
}
|
|
|
|
|
2014-05-16 11:37:31 +00:00
|
|
|
|
2023-03-02 14:04:37 +00:00
|
|
|
void LOGGER::Log( LOGGER::EVENT_TYPE evt, const VECTOR2I& pos, const ITEM* item,
|
|
|
|
const SIZES_SETTINGS* sizes )
|
2014-05-14 13:53:54 +00:00
|
|
|
{
|
2020-04-16 22:29:28 +00:00
|
|
|
LOGGER::EVENT_ENTRY ent;
|
2015-10-05 16:28:41 +00:00
|
|
|
|
2020-04-16 22:29:28 +00:00
|
|
|
ent.type = evt;
|
|
|
|
ent.p = pos;
|
2023-03-02 14:04:37 +00:00
|
|
|
ent.uuid = KIID( 0 );
|
2015-10-05 16:28:41 +00:00
|
|
|
|
2022-10-23 22:34:42 +00:00
|
|
|
if( sizes )
|
|
|
|
{
|
|
|
|
ent.sizes = *sizes;
|
|
|
|
}
|
2015-10-05 16:28:41 +00:00
|
|
|
|
2021-06-03 20:32:20 +00:00
|
|
|
if( item && item->Parent() )
|
2022-02-03 18:34:14 +00:00
|
|
|
ent.uuid = item->Parent()->m_Uuid;
|
2021-06-03 20:32:20 +00:00
|
|
|
|
|
|
|
m_events.push_back( ent );
|
2014-05-14 13:53:54 +00:00
|
|
|
}
|
2016-08-29 14:38:11 +00:00
|
|
|
|
2023-08-08 21:33:26 +00:00
|
|
|
|
|
|
|
wxString LOGGER::FormatLogFileAsString( int aMode,
|
|
|
|
const std::vector<ITEM*>& aAddedItems,
|
|
|
|
const std::set<KIID>& aRemovedItems,
|
|
|
|
const std::vector<ITEM*>& aHeads,
|
|
|
|
const std::vector<LOGGER::EVENT_ENTRY>& aEvents )
|
|
|
|
{
|
|
|
|
wxString result = wxString::Format( "mode %d\n", aMode );
|
|
|
|
|
|
|
|
for( const EVENT_ENTRY& evt : aEvents )
|
|
|
|
result += PNS::LOGGER::FormatEvent( evt );
|
|
|
|
|
|
|
|
for( const KIID& uuid : aRemovedItems )
|
|
|
|
result += wxString::Format( "removed %s\n", uuid.AsString().c_str() );
|
|
|
|
|
|
|
|
for( ITEM* item : aAddedItems )
|
|
|
|
result += wxString::Format( "added %s\n", item->Format().c_str() );
|
|
|
|
|
|
|
|
for( ITEM* item : aHeads )
|
|
|
|
result += wxString::Format( "head %s\n", item->Format().c_str() );
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
wxString LOGGER::FormatEvent( const LOGGER::EVENT_ENTRY& aEvent )
|
|
|
|
{
|
|
|
|
return wxString::Format(
|
|
|
|
"event %d %d %d %s %d %d %d %d %d %d %d\n", aEvent.p.x, aEvent.p.y, aEvent.type,
|
|
|
|
static_cast<const char*>( aEvent.uuid.AsString().c_str() ), aEvent.sizes.TrackWidth(),
|
|
|
|
aEvent.sizes.ViaDiameter(), aEvent.sizes.ViaDrill(),
|
|
|
|
aEvent.sizes.TrackWidthIsExplicit() ? 1 : 0, aEvent.sizes.GetLayerBottom(),
|
|
|
|
aEvent.sizes.GetLayerTop(), static_cast<int>( aEvent.sizes.ViaType() ) );
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LOGGER::EVENT_ENTRY LOGGER::ParseEvent( const wxString& aLine )
|
|
|
|
{
|
|
|
|
wxStringTokenizer tokens( aLine );
|
|
|
|
wxString cmd = tokens.GetNextToken();
|
|
|
|
|
|
|
|
wxCHECK_MSG( cmd == wxT( "event" ), EVENT_ENTRY(), "Line doesn't contain an event!" );
|
|
|
|
|
|
|
|
EVENT_ENTRY evt;
|
|
|
|
evt.p.x = wxAtoi( tokens.GetNextToken() );
|
|
|
|
evt.p.y = wxAtoi( tokens.GetNextToken() );
|
|
|
|
evt.type = (PNS::LOGGER::EVENT_TYPE) wxAtoi( tokens.GetNextToken() );
|
|
|
|
evt.uuid = KIID( tokens.GetNextToken() );
|
|
|
|
|
|
|
|
return evt;
|
|
|
|
}
|
|
|
|
|
2016-08-29 14:38:11 +00:00
|
|
|
}
|