router: extend dump format to support automatic regressions tests of interactive routing scenarios
This commit is contained in:
parent
f25d449d5f
commit
65507e7186
|
@ -215,4 +215,13 @@ ITEM::~ITEM()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const std::string ITEM::Format() const
|
||||||
|
{
|
||||||
|
std::stringstream ss;
|
||||||
|
ss << KindStr() << " ";
|
||||||
|
ss << "net " << m_net << " ";
|
||||||
|
ss << "layers " << m_layers.Start() << " " << m_layers.End();
|
||||||
|
return ss.str();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -245,6 +245,8 @@ public:
|
||||||
void SetIsCompoundShapePrimitive() { m_isCompoundShapePrimitive = true; }
|
void SetIsCompoundShapePrimitive() { m_isCompoundShapePrimitive = true; }
|
||||||
bool IsCompoundShapePrimitive() const { return m_isCompoundShapePrimitive; }
|
bool IsCompoundShapePrimitive() const { return m_isCompoundShapePrimitive; }
|
||||||
|
|
||||||
|
virtual const std::string Format() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool collideSimple( const ITEM* aOther, const NODE* aNode, bool aDifferentNetsOnly, int aOverrideClearance ) const;
|
bool collideSimple( const ITEM* aOther, const NODE* aNode, bool aDifferentNetsOnly, int aOverrideClearance ) const;
|
||||||
|
|
||||||
|
|
|
@ -1225,6 +1225,7 @@ bool LINE::HasLockedSegments() const
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void LINE::Clear()
|
void LINE::Clear()
|
||||||
{
|
{
|
||||||
m_hasVia = false;
|
m_hasVia = false;
|
||||||
|
@ -1232,5 +1233,13 @@ void LINE::Clear()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const std::string SEGMENT::Format( ) const
|
||||||
|
{
|
||||||
|
std::stringstream ss;
|
||||||
|
ss << ITEM::Format() << " ";
|
||||||
|
ss << m_seg.Format( false );
|
||||||
|
return ss.str();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -61,7 +61,7 @@ void LOGGER::Save( const std::string& aFilename )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void LOGGER::Log( LOGGER::EVENT_TYPE evt, const VECTOR2I& pos, const ITEM* item )
|
void LOGGER::Log( LOGGER::EVENT_TYPE evt, const VECTOR2I& pos, const ITEM* item, const SIZES_SETTINGS* sizes )
|
||||||
{
|
{
|
||||||
LOGGER::EVENT_ENTRY ent;
|
LOGGER::EVENT_ENTRY ent;
|
||||||
|
|
||||||
|
@ -69,6 +69,10 @@ void LOGGER::Log( LOGGER::EVENT_TYPE evt, const VECTOR2I& pos, const ITEM* item
|
||||||
ent.p = pos;
|
ent.p = pos;
|
||||||
ent.uuid = KIID(0);
|
ent.uuid = KIID(0);
|
||||||
|
|
||||||
|
if( sizes )
|
||||||
|
{
|
||||||
|
ent.sizes = *sizes;
|
||||||
|
}
|
||||||
|
|
||||||
if( item && item->Parent() )
|
if( item && item->Parent() )
|
||||||
ent.uuid = item->Parent()->m_Uuid;
|
ent.uuid = item->Parent()->m_Uuid;
|
||||||
|
|
|
@ -30,6 +30,8 @@
|
||||||
#include <math/vector2d.h>
|
#include <math/vector2d.h>
|
||||||
#include <kiid.h>
|
#include <kiid.h>
|
||||||
|
|
||||||
|
#include "pns_sizes_settings.h"
|
||||||
|
|
||||||
class SHAPE_LINE_CHAIN;
|
class SHAPE_LINE_CHAIN;
|
||||||
class SHAPE;
|
class SHAPE;
|
||||||
|
|
||||||
|
@ -54,6 +56,7 @@ public:
|
||||||
VECTOR2I p;
|
VECTOR2I p;
|
||||||
EVENT_TYPE type;
|
EVENT_TYPE type;
|
||||||
KIID uuid;
|
KIID uuid;
|
||||||
|
SIZES_SETTINGS sizes;
|
||||||
};
|
};
|
||||||
|
|
||||||
LOGGER();
|
LOGGER();
|
||||||
|
@ -61,7 +64,7 @@ public:
|
||||||
|
|
||||||
void Save( const std::string& aFilename );
|
void Save( const std::string& aFilename );
|
||||||
void Clear();
|
void Clear();
|
||||||
void Log( EVENT_TYPE evt, const VECTOR2I& pos = VECTOR2I(), const ITEM* item = nullptr );
|
void Log( EVENT_TYPE evt, const VECTOR2I& pos = VECTOR2I(), const ITEM* item = nullptr, const SIZES_SETTINGS* sizes = nullptr );
|
||||||
|
|
||||||
const std::vector<EVENT_ENTRY>& GetEvents()
|
const std::vector<EVENT_ENTRY>& GetEvents()
|
||||||
{
|
{
|
||||||
|
|
|
@ -422,9 +422,10 @@ public:
|
||||||
return m_collisionQueryScope;
|
return m_collisionQueryScope;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
|
||||||
void Add( std::unique_ptr< ITEM > aItem, bool aAllowRedundant = false );
|
void Add( std::unique_ptr< ITEM > aItem, bool aAllowRedundant = false );
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
/// nodes are not copyable
|
/// nodes are not copyable
|
||||||
NODE( const NODE& aB );
|
NODE( const NODE& aB );
|
||||||
NODE& operator=( const NODE& aB );
|
NODE& operator=( const NODE& aB );
|
||||||
|
|
|
@ -432,15 +432,16 @@ bool ROUTER::StartRouting( const VECTOR2I& aP, ITEM* aStartItem, int aLayer )
|
||||||
m_placer->SetDebugDecorator( m_iface->GetDebugDecorator() );
|
m_placer->SetDebugDecorator( m_iface->GetDebugDecorator() );
|
||||||
m_placer->SetLogger( m_logger );
|
m_placer->SetLogger( m_logger );
|
||||||
|
|
||||||
if( m_logger )
|
|
||||||
{
|
|
||||||
m_logger->Clear();
|
|
||||||
m_logger->Log( LOGGER::EVT_START_ROUTE, aP, aStartItem );
|
|
||||||
}
|
|
||||||
|
|
||||||
if( m_placer->Start( aP, aStartItem ) )
|
if( m_placer->Start( aP, aStartItem ) )
|
||||||
{
|
{
|
||||||
m_state = ROUTE_TRACK;
|
m_state = ROUTE_TRACK;
|
||||||
|
|
||||||
|
if( m_logger )
|
||||||
|
{
|
||||||
|
m_logger->Clear();
|
||||||
|
m_logger->Log( LOGGER::EVT_START_ROUTE, aP, aStartItem, &m_sizes );
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -755,6 +756,36 @@ bool ROUTER::movePlacing( const VECTOR2I& aP, ITEM* aEndItem )
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ROUTER::GetUpdatedItems( std::vector<PNS::ITEM*>& aRemoved, std::vector<PNS::ITEM*>& aAdded )
|
||||||
|
{
|
||||||
|
NODE *node;
|
||||||
|
ITEM_SET current;
|
||||||
|
|
||||||
|
if( m_state == ROUTE_TRACK )
|
||||||
|
{
|
||||||
|
node = m_placer->CurrentNode( true );
|
||||||
|
current = m_placer->Traces();
|
||||||
|
}
|
||||||
|
else if ( m_state == DRAG_SEGMENT )
|
||||||
|
{
|
||||||
|
node = m_dragger->CurrentNode();
|
||||||
|
current = m_dragger->Traces();
|
||||||
|
}
|
||||||
|
|
||||||
|
std::unique_ptr<NODE> tmpNode( node->Branch() );
|
||||||
|
|
||||||
|
for( auto item : current )
|
||||||
|
{
|
||||||
|
std::unique_ptr<ITEM> ip( item.item->Clone() );
|
||||||
|
tmpNode->Add( std::move( ip ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
tmpNode->GetUpdatedItems( aRemoved, aAdded );
|
||||||
|
|
||||||
|
//printf("added %d removed %d\n", aRemoved.size(), aAdded.size() );
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void ROUTER::CommitRouting( NODE* aNode )
|
void ROUTER::CommitRouting( NODE* aNode )
|
||||||
{
|
{
|
||||||
|
@ -918,7 +949,7 @@ void ROUTER::ToggleViaPlacement()
|
||||||
|
|
||||||
if( m_logger )
|
if( m_logger )
|
||||||
{
|
{
|
||||||
m_logger->Log( LOGGER::EVT_TOGGLE_VIA );
|
m_logger->Log( LOGGER::EVT_TOGGLE_VIA, VECTOR2I(), nullptr, &m_sizes );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -150,6 +150,7 @@ public:
|
||||||
|
|
||||||
void UndoLastSegment();
|
void UndoLastSegment();
|
||||||
void CommitRouting();
|
void CommitRouting();
|
||||||
|
bool GetUpdatedItems( std::vector<PNS::ITEM*>& aRemoved, std::vector<PNS::ITEM*>& aAdded );
|
||||||
void StopRouting();
|
void StopRouting();
|
||||||
void ClearViewDecorations();
|
void ClearViewDecorations();
|
||||||
|
|
||||||
|
|
|
@ -117,6 +117,13 @@ public:
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual const std::string Format() const override;
|
||||||
|
|
||||||
|
void SetShape( const SHAPE_SEGMENT& aShape )
|
||||||
|
{
|
||||||
|
m_seg = aShape;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SHAPE_SEGMENT m_seg;
|
SHAPE_SEGMENT m_seg;
|
||||||
};
|
};
|
||||||
|
|
|
@ -166,6 +166,7 @@ OPT_BOX2I VIA::ChangedArea( const VIA* aOther ) const
|
||||||
return OPT_BOX2I();
|
return OPT_BOX2I();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const VIA_HANDLE VIA::MakeHandle() const
|
const VIA_HANDLE VIA::MakeHandle() const
|
||||||
{
|
{
|
||||||
VIA_HANDLE h;
|
VIA_HANDLE h;
|
||||||
|
@ -176,4 +177,13 @@ const VIA_HANDLE VIA::MakeHandle() const
|
||||||
return h;
|
return h;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const std::string VIA::Format( ) const
|
||||||
|
{
|
||||||
|
std::stringstream ss;
|
||||||
|
ss << ITEM::Format() << " drill " << m_drill << " ";
|
||||||
|
ss << m_shape.Format( false );
|
||||||
|
return ss.str();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -160,6 +160,8 @@ public:
|
||||||
|
|
||||||
const VIA_HANDLE MakeHandle() const;
|
const VIA_HANDLE MakeHandle() const;
|
||||||
|
|
||||||
|
virtual const std::string Format() const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int m_diameter;
|
int m_diameter;
|
||||||
int m_drill;
|
int m_drill;
|
||||||
|
|
|
@ -24,6 +24,10 @@
|
||||||
#include <advanced_config.h>
|
#include <advanced_config.h>
|
||||||
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
#include <iomanip>
|
||||||
|
#include <utility>
|
||||||
|
#include <sstream>
|
||||||
|
|
||||||
using namespace std::placeholders;
|
using namespace std::placeholders;
|
||||||
#include <board.h>
|
#include <board.h>
|
||||||
#include <board_design_settings.h>
|
#include <board_design_settings.h>
|
||||||
|
@ -557,6 +561,10 @@ void ROUTER_TOOL::saveRouterDebugLog()
|
||||||
fname_dump.SetPath( cwd );
|
fname_dump.SetPath( cwd );
|
||||||
fname_dump.SetName( "pns.dump" );
|
fname_dump.SetName( "pns.dump" );
|
||||||
|
|
||||||
|
wxFileName fname_settings( cwd );
|
||||||
|
fname_settings.SetPath( cwd );
|
||||||
|
fname_settings.SetName( "pns.settings" );
|
||||||
|
|
||||||
wxString msg = wxString::Format( _( "Event file: %s\nBoard dump: %s" ), fname_log.GetFullPath(), fname_log.GetFullPath() );
|
wxString msg = wxString::Format( _( "Event file: %s\nBoard dump: %s" ), fname_log.GetFullPath(), fname_log.GetFullPath() );
|
||||||
|
|
||||||
int rv = OKOrCancelDialog( nullptr, _("Save router log"), _("Would you like to save the router\nevent log for debugging purposes?"), msg, _("OK"), _("Cancel") );
|
int rv = OKOrCancelDialog( nullptr, _("Save router log"), _("Would you like to save the router\nevent log for debugging purposes?"), msg, _("OK"), _("Cancel") );
|
||||||
|
@ -564,26 +572,30 @@ void ROUTER_TOOL::saveRouterDebugLog()
|
||||||
if( !rv )
|
if( !rv )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
FILE *f = fopen( fname_log.GetFullPath().c_str(), "wb" );
|
FILE *f = fopen( fname_settings.GetFullPath().c_str(), "wb" );
|
||||||
|
std::string settingsStr = m_router->Settings().FormatAsString();
|
||||||
|
fprintf(f,"%s\n", settingsStr.c_str( ) );
|
||||||
|
fclose(f);
|
||||||
|
|
||||||
// save base router configuration (mode, etc.)
|
f = fopen( fname_log.GetFullPath().c_str(), "wb" );
|
||||||
fprintf(f, "config %d %d %d %d\n",
|
|
||||||
m_router->Settings().Mode(),
|
fprintf(f, "mode %d\n", m_router->Mode() );
|
||||||
m_router->Settings().RemoveLoops() ? 1 : 0,
|
|
||||||
m_router->Settings().GetFixAllSegments() ? 1 : 0,
|
|
||||||
static_cast<int>( m_router->Settings().GetCornerMode() )
|
|
||||||
);
|
|
||||||
|
|
||||||
const auto& events = logger->GetEvents();
|
const auto& events = logger->GetEvents();
|
||||||
|
|
||||||
for( const auto& evt : events)
|
for( const auto& evt : events)
|
||||||
{
|
{
|
||||||
fprintf( f, "event %d %d %d %s\n", evt.p.x, evt.p.y, evt.type,
|
fprintf( f, "event %d %d %d %s %d %d %d %d %d %d %d\n", evt.p.x, evt.p.y, evt.type,
|
||||||
static_cast<const char*>( evt.uuid.AsString().c_str() ) );
|
static_cast<const char*>( evt.uuid.AsString().c_str() ),
|
||||||
|
evt.sizes.TrackWidth(),
|
||||||
|
evt.sizes.ViaDiameter(),
|
||||||
|
evt.sizes.ViaDrill(),
|
||||||
|
evt.sizes.TrackWidthIsExplicit() ? 1: 0,
|
||||||
|
evt.sizes.GetLayerBottom(),
|
||||||
|
evt.sizes.GetLayerTop(),
|
||||||
|
evt.sizes.ViaType() );
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose( f );
|
|
||||||
|
|
||||||
// Export as *.kicad_pcb format, using a strategy which is specifically chosen
|
// Export as *.kicad_pcb format, using a strategy which is specifically chosen
|
||||||
// as an example on how it could also be used to send it to the system clipboard.
|
// as an example on how it could also be used to send it to the system clipboard.
|
||||||
|
|
||||||
|
@ -593,6 +605,26 @@ void ROUTER_TOOL::saveRouterDebugLog()
|
||||||
|
|
||||||
PROJECT* prj = m_iface->GetBoard()->GetProject();
|
PROJECT* prj = m_iface->GetBoard()->GetProject();
|
||||||
prj->GetProjectFile().SaveAs( cwd, "pns" );
|
prj->GetProjectFile().SaveAs( cwd, "pns" );
|
||||||
|
|
||||||
|
std::vector<PNS::ITEM*> added, removed;
|
||||||
|
|
||||||
|
if( !m_router->GetUpdatedItems( removed, added ) )
|
||||||
|
{
|
||||||
|
fclose( f );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for( auto item : removed )
|
||||||
|
{
|
||||||
|
fprintf(f, "removed %s\n", item->Parent()->m_Uuid.AsString().c_str().AsChar() );
|
||||||
|
}
|
||||||
|
|
||||||
|
for( auto item : added )
|
||||||
|
{
|
||||||
|
fprintf(f, "added %s\n", item->Format().c_str() );
|
||||||
|
}
|
||||||
|
|
||||||
|
fclose( f );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue