KiCad PCB EDA Suite
PNS_LOG_FILE Class Reference

#include <pns_log.h>

Classes

struct  EVENT_ENTRY
 

Public Member Functions

 PNS_LOG_FILE ()
 
 ~PNS_LOG_FILE ()
 
bool Load (const std::string &logName, const std::string boardName)
 
BOARD_CONNECTED_ITEMItemById (const EVENT_ENTRY &evt)
 
std::vector< EVENT_ENTRY > & Events ()
 
std::shared_ptr< BOARDGetBoard () const
 
void SetBoard (std::shared_ptr< BOARD > brd)
 
PNS::ROUTING_SETTINGSGetRoutingSettings () const
 

Private Attributes

std::unique_ptr< PNS::ROUTING_SETTINGSm_routerSettings
 
std::vector< EVENT_ENTRYm_events
 
std::shared_ptr< BOARDm_board
 

Detailed Description

Definition at line 60 of file pns_log.h.

Constructor & Destructor Documentation

◆ PNS_LOG_FILE()

PNS_LOG_FILE::PNS_LOG_FILE ( )

Definition at line 39 of file pns_log.cpp.

40 {
41  m_routerSettings.reset( new PNS::ROUTING_SETTINGS( nullptr, "" ) );
42 }
Contain all persistent settings of the router, such as the mode, optimization effort,...
std::unique_ptr< PNS::ROUTING_SETTINGS > m_routerSettings
Definition: pns_log.h:102

◆ ~PNS_LOG_FILE()

PNS_LOG_FILE::~PNS_LOG_FILE ( )
inline

Definition at line 64 of file pns_log.h.

64 {}

Member Function Documentation

◆ Events()

std::vector<EVENT_ENTRY>& PNS_LOG_FILE::Events ( )
inline

Definition at line 93 of file pns_log.h.

93 { return m_events; }
std::vector< EVENT_ENTRY > m_events
Definition: pns_log.h:103

References m_events.

Referenced by PNS_TEST_ENVIRONMENT::ReplayLog().

◆ GetBoard()

std::shared_ptr<BOARD> PNS_LOG_FILE::GetBoard ( ) const
inline

Definition at line 95 of file pns_log.h.

95 { return m_board; }
std::shared_ptr< BOARD > m_board
Definition: pns_log.h:104

References m_board.

Referenced by PNS_TEST_FRAME::LoadLogFile(), and PNS_TEST_ENVIRONMENT::ReplayLog().

◆ GetRoutingSettings()

PNS::ROUTING_SETTINGS* PNS_LOG_FILE::GetRoutingSettings ( ) const
inline

Definition at line 99 of file pns_log.h.

99 { return m_routerSettings.get(); }
std::unique_ptr< PNS::ROUTING_SETTINGS > m_routerSettings
Definition: pns_log.h:102

References m_routerSettings.

Referenced by PNS_TEST_ENVIRONMENT::ReplayLog().

◆ ItemById()

BOARD_CONNECTED_ITEM* PNS_LOG_FILE::ItemById ( const EVENT_ENTRY evt)
inline

Definition at line 77 of file pns_log.h.

78  {
79  BOARD_CONNECTED_ITEM* parent = nullptr;
80 
81  for( auto item : m_board->AllConnectedItems() )
82  {
83  if( item->m_Uuid == evt.uuid )
84  {
85  parent = item;
86  break;
87  };
88  }
89 
90  return parent;
91  }
A base class derived from BOARD_ITEM for items that can be connected and have a net,...
std::shared_ptr< BOARD > m_board
Definition: pns_log.h:104

References m_board, and PNS_LOG_FILE::EVENT_ENTRY::uuid.

Referenced by PNS_TEST_ENVIRONMENT::ReplayLog().

◆ Load()

bool PNS_LOG_FILE::Load ( const std::string &  logName,
const std::string  boardName 
)

Definition at line 45 of file pns_log.cpp.

46 {
47  FILE* f = fopen( logName.c_str(), "rb" );
48 
49  if (!f)
50  return false;
51 
52  while( !feof( f ) )
53  {
54  wxStringTokenizer tokens( readLine( f ) );
55  if( !tokens.CountTokens() )
56  continue;
57 
58  wxString cmd = tokens.GetNextToken();
59 
60  if (cmd == "event")
61  {
62  EVENT_ENTRY evt;
63  evt.p.x = wxAtoi( tokens.GetNextToken() );
64  evt.p.y = wxAtoi( tokens.GetNextToken() );
65  evt.type = (PNS::LOGGER::EVENT_TYPE) wxAtoi( tokens.GetNextToken() );
66  evt.uuid = KIID( tokens.GetNextToken() );
67  m_events.push_back(evt);
68  }
69  else if (cmd == "config")
70  {
71  m_routerSettings->SetMode( (PNS::PNS_MODE) wxAtoi( tokens.GetNextToken() ) );
72  m_routerSettings->SetRemoveLoops( wxAtoi( tokens.GetNextToken() ) );
73  m_routerSettings->SetFixAllSegments( wxAtoi( tokens.GetNextToken() ) );
74  }
75  }
76 
77  fclose( f );
78 
79  try {
80  PCB_IO io;
81  m_board.reset( io.Load( boardName.c_str(), nullptr, nullptr ) );
82 
83  std::shared_ptr<DRC_ENGINE> drcEngine( new DRC_ENGINE );
84 
85  CONSOLE_LOG consoleLog;
86  BOARD_DESIGN_SETTINGS& bds = m_board->GetDesignSettings();
87 
88  bds.m_DRCEngine = drcEngine;
89 
90  drcEngine->SetBoard( m_board.get() );
91  drcEngine->SetDesignSettings( &bds );
92  drcEngine->SetLogReporter( new CONSOLE_MSG_REPORTER ( &consoleLog ) );
93  drcEngine->InitEngine(wxFileName());
94 
95  } catch ( const PARSE_ERROR& parse_error ) {
96  printf("parse error : %s (%s)\n",
97  (const char *) parse_error.Problem().c_str(),
98  (const char *) parse_error.What().c_str() );
99 
100  return false;
101  }
102 
103  return true;
104 }
Design Rule Checker object that performs all the DRC tests.
Definition: drc_engine.h:80
std::unique_ptr< PNS::ROUTING_SETTINGS > m_routerSettings
Definition: pns_log.h:102
A PLUGIN derivation for saving and loading Pcbnew s-expression formatted files.
static const wxString readLine(FILE *f)
Definition: pns_log.cpp:32
BOARD * Load(const wxString &aFileName, BOARD *aAppendToMe, const PROPERTIES *aProperties=nullptr, PROJECT *aProject=nullptr) override
Load information from some input file format that this PLUGIN implementation knows about into either ...
PNS_MODE
< Routing modes
virtual const wxString Problem() const
what was the problem?
Definition: exceptions.cpp:45
std::vector< EVENT_ENTRY > m_events
Definition: pns_log.h:103
Definition: kiid.h:44
std::shared_ptr< BOARD > m_board
Definition: pns_log.h:104
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:29
A filename or source description, a problem input line, a line number, a byte offset,...
Definition: ki_exception.h:118
std::shared_ptr< DRC_ENGINE > m_DRCEngine
Container for design settings for a BOARD object.

References PCB_IO::Load(), BOARD_DESIGN_SETTINGS::m_DRCEngine, PNS_LOG_FILE::EVENT_ENTRY::p, IO_ERROR::Problem(), readLine(), PNS_LOG_FILE::EVENT_ENTRY::type, PNS_LOG_FILE::EVENT_ENTRY::uuid, IO_ERROR::What(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by PNS_TEST_FRAME::LoadLogFile(), and replay_main_func().

◆ SetBoard()

void PNS_LOG_FILE::SetBoard ( std::shared_ptr< BOARD brd)
inline

Definition at line 97 of file pns_log.h.

97 { m_board = brd; }
std::shared_ptr< BOARD > m_board
Definition: pns_log.h:104

References m_board.

Member Data Documentation

◆ m_board

std::shared_ptr<BOARD> PNS_LOG_FILE::m_board
private

Definition at line 104 of file pns_log.h.

Referenced by GetBoard(), ItemById(), and SetBoard().

◆ m_events

std::vector<EVENT_ENTRY> PNS_LOG_FILE::m_events
private

Definition at line 103 of file pns_log.h.

Referenced by Events().

◆ m_routerSettings

std::unique_ptr<PNS::ROUTING_SETTINGS> PNS_LOG_FILE::m_routerSettings
private

Definition at line 102 of file pns_log.h.

Referenced by GetRoutingSettings().


The documentation for this class was generated from the following files: