Remove GUI calls from netlisting.
This commit is contained in:
parent
c409646aad
commit
e09e521162
|
@ -36,6 +36,7 @@
|
|||
#include <pgm_base.h>
|
||||
#include <kiface_base.h>
|
||||
#include <gestfich.h>
|
||||
#include <widgets/wx_html_report_panel.h>
|
||||
#include <sch_edit_frame.h>
|
||||
#include <general.h>
|
||||
#include <netlist.h>
|
||||
|
@ -322,7 +323,9 @@ void NETLIST_DIALOG::OnRunExternSpiceCommand( wxCommandEvent& event )
|
|||
|
||||
if( m_Parent->ReadyToNetlist( _( "Simulator requires a fully annotated schematic." ) ) )
|
||||
{
|
||||
m_Parent->WriteNetListFile( NET_TYPE_SPICE, fn.GetFullPath(), netlist_opt, nullptr );
|
||||
m_Parent->WriteNetListFile( NET_TYPE_SPICE, fn.GetFullPath(), netlist_opt,
|
||||
&m_MessagesBox->Reporter() );
|
||||
|
||||
commandLine.Trim( true ).Trim( false );
|
||||
|
||||
if( !commandLine.IsEmpty() )
|
||||
|
@ -562,7 +565,10 @@ bool NETLIST_DIALOG::TransferDataFromWindow()
|
|||
m_Parent->SetNetListerCommand( wxEmptyString );
|
||||
|
||||
if( m_Parent->ReadyToNetlist( _( "Exporting netlist requires a fully annotated schematic." ) ) )
|
||||
m_Parent->WriteNetListFile( currPage->m_IdNetType, fullpath, netlist_opt, nullptr );
|
||||
{
|
||||
m_Parent->WriteNetListFile( currPage->m_IdNetType, fullpath, netlist_opt,
|
||||
&m_MessagesBox->Reporter() );
|
||||
}
|
||||
|
||||
WriteCurrentNetlistSetup();
|
||||
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
///////////////////////////////////////////////////////////////////////////
|
||||
// C++ code generated with wxFormBuilder (version 3.9.0 Jun 18 2020)
|
||||
// C++ code generated with wxFormBuilder (version 3.10.1-0-g8feb16b)
|
||||
// http://www.wxformbuilder.org/
|
||||
//
|
||||
// PLEASE DO *NOT* EDIT THIS FILE!
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "widgets/wx_html_report_panel.h"
|
||||
|
||||
#include "dialog_netlist_base.h"
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
@ -29,7 +31,18 @@ NETLIST_DIALOG_BASE::NETLIST_DIALOG_BASE( wxWindow* parent, wxWindowID id, const
|
|||
m_NoteBook->SetMinSize( wxSize( 540,-1 ) );
|
||||
|
||||
|
||||
bUpperSizer->Add( m_NoteBook, 1, wxEXPAND | wxALL, 5 );
|
||||
bUpperSizer->Add( m_NoteBook, 0, wxEXPAND | wxALL, 5 );
|
||||
|
||||
wxBoxSizer* bSizerMsgPanel;
|
||||
bSizerMsgPanel = new wxBoxSizer( wxVERTICAL );
|
||||
|
||||
m_MessagesBox = new WX_HTML_REPORT_PANEL( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
|
||||
m_MessagesBox->SetMinSize( wxSize( 300,150 ) );
|
||||
|
||||
bSizerMsgPanel->Add( m_MessagesBox, 1, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 );
|
||||
|
||||
|
||||
bUpperSizer->Add( bSizerMsgPanel, 1, wxEXPAND, 5 );
|
||||
|
||||
|
||||
bMainSizer->Add( bUpperSizer, 1, wxEXPAND, 5 );
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
|
||||
<wxFormBuilder_Project>
|
||||
<FileVersion major="1" minor="15" />
|
||||
<FileVersion major="1" minor="16" />
|
||||
<object class="Project" expanded="1">
|
||||
<property name="class_decoration"></property>
|
||||
<property name="code_generation">C++</property>
|
||||
|
@ -52,6 +52,7 @@
|
|||
<property name="subclass">DIALOG_SHIM; dialog_shim.h</property>
|
||||
<property name="title">Export Netlist</property>
|
||||
<property name="tooltip"></property>
|
||||
<property name="two_step_creation">0</property>
|
||||
<property name="window_extra_style"></property>
|
||||
<property name="window_name"></property>
|
||||
<property name="window_style"></property>
|
||||
|
@ -72,7 +73,7 @@
|
|||
<object class="sizeritem" expanded="0">
|
||||
<property name="border">5</property>
|
||||
<property name="flag">wxEXPAND | wxALL</property>
|
||||
<property name="proportion">1</property>
|
||||
<property name="proportion">0</property>
|
||||
<object class="wxNotebook" expanded="0">
|
||||
<property name="BottomDockable">1</property>
|
||||
<property name="LeftDockable">1</property>
|
||||
|
@ -129,6 +130,74 @@
|
|||
<event name="OnNotebookPageChanged">OnNetlistTypeSelection</event>
|
||||
</object>
|
||||
</object>
|
||||
<object class="sizeritem" expanded="1">
|
||||
<property name="border">5</property>
|
||||
<property name="flag">wxEXPAND</property>
|
||||
<property name="proportion">1</property>
|
||||
<object class="wxBoxSizer" expanded="1">
|
||||
<property name="minimum_size"></property>
|
||||
<property name="name">bSizerMsgPanel</property>
|
||||
<property name="orient">wxVERTICAL</property>
|
||||
<property name="permission">none</property>
|
||||
<object class="sizeritem" expanded="1">
|
||||
<property name="border">5</property>
|
||||
<property name="flag">wxEXPAND|wxTOP|wxRIGHT|wxLEFT</property>
|
||||
<property name="proportion">1</property>
|
||||
<object class="wxPanel" expanded="1">
|
||||
<property name="BottomDockable">1</property>
|
||||
<property name="LeftDockable">1</property>
|
||||
<property name="RightDockable">1</property>
|
||||
<property name="TopDockable">1</property>
|
||||
<property name="aui_layer"></property>
|
||||
<property name="aui_name"></property>
|
||||
<property name="aui_position"></property>
|
||||
<property name="aui_row"></property>
|
||||
<property name="best_size"></property>
|
||||
<property name="bg"></property>
|
||||
<property name="caption"></property>
|
||||
<property name="caption_visible">1</property>
|
||||
<property name="center_pane">0</property>
|
||||
<property name="close_button">1</property>
|
||||
<property name="context_help"></property>
|
||||
<property name="context_menu">1</property>
|
||||
<property name="default_pane">0</property>
|
||||
<property name="dock">Dock</property>
|
||||
<property name="dock_fixed">0</property>
|
||||
<property name="docking">Left</property>
|
||||
<property name="enabled">1</property>
|
||||
<property name="fg"></property>
|
||||
<property name="floatable">1</property>
|
||||
<property name="font"></property>
|
||||
<property name="gripper">0</property>
|
||||
<property name="hidden">0</property>
|
||||
<property name="id">wxID_ANY</property>
|
||||
<property name="max_size"></property>
|
||||
<property name="maximize_button">0</property>
|
||||
<property name="maximum_size"></property>
|
||||
<property name="min_size"></property>
|
||||
<property name="minimize_button">0</property>
|
||||
<property name="minimum_size">300,150</property>
|
||||
<property name="moveable">1</property>
|
||||
<property name="name">m_MessagesBox</property>
|
||||
<property name="pane_border">1</property>
|
||||
<property name="pane_position"></property>
|
||||
<property name="pane_size"></property>
|
||||
<property name="permission">protected</property>
|
||||
<property name="pin_button">1</property>
|
||||
<property name="pos"></property>
|
||||
<property name="resize">Resizable</property>
|
||||
<property name="show">1</property>
|
||||
<property name="size"></property>
|
||||
<property name="subclass">WX_HTML_REPORT_PANEL; widgets/wx_html_report_panel.h; forward_declare</property>
|
||||
<property name="toolbar_pane">0</property>
|
||||
<property name="tooltip"></property>
|
||||
<property name="window_extra_style"></property>
|
||||
<property name="window_name"></property>
|
||||
<property name="window_style">wxTAB_TRAVERSAL</property>
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
<object class="sizeritem" expanded="1">
|
||||
|
@ -333,6 +402,7 @@
|
|||
<property name="subclass">DIALOG_SHIM; dialog_shim.h</property>
|
||||
<property name="title">Script Generator Properties</property>
|
||||
<property name="tooltip"></property>
|
||||
<property name="two_step_creation">0</property>
|
||||
<property name="window_extra_style"></property>
|
||||
<property name="window_name"></property>
|
||||
<property name="window_style"></property>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
///////////////////////////////////////////////////////////////////////////
|
||||
// C++ code generated with wxFormBuilder (version 3.9.0 Jun 18 2020)
|
||||
// C++ code generated with wxFormBuilder (version 3.10.1-0-g8feb16b)
|
||||
// http://www.wxformbuilder.org/
|
||||
//
|
||||
// PLEASE DO *NOT* EDIT THIS FILE!
|
||||
|
@ -10,6 +10,8 @@
|
|||
#include <wx/artprov.h>
|
||||
#include <wx/xrc/xmlres.h>
|
||||
#include <wx/intl.h>
|
||||
class WX_HTML_REPORT_PANEL;
|
||||
|
||||
#include "dialog_shim.h"
|
||||
#include <wx/gdicmn.h>
|
||||
#include <wx/notebook.h>
|
||||
|
@ -17,6 +19,7 @@
|
|||
#include <wx/colour.h>
|
||||
#include <wx/settings.h>
|
||||
#include <wx/string.h>
|
||||
#include <wx/panel.h>
|
||||
#include <wx/sizer.h>
|
||||
#include <wx/button.h>
|
||||
#include <wx/bitmap.h>
|
||||
|
@ -51,6 +54,7 @@ class NETLIST_DIALOG_BASE : public DIALOG_SHIM
|
|||
};
|
||||
|
||||
wxNotebook* m_NoteBook;
|
||||
WX_HTML_REPORT_PANEL* m_MessagesBox;
|
||||
wxBoxSizer* m_buttonSizer;
|
||||
wxButton* m_buttonAddGenerator;
|
||||
wxButton* m_buttonDelGenerator;
|
||||
|
@ -58,7 +62,7 @@ class NETLIST_DIALOG_BASE : public DIALOG_SHIM
|
|||
wxButton* m_sdbSizer2OK;
|
||||
wxButton* m_sdbSizer2Cancel;
|
||||
|
||||
// Virtual event handlers, overide them in your derived class
|
||||
// Virtual event handlers, override them in your derived class
|
||||
virtual void OnNetlistTypeSelection( wxNotebookEvent& event ) { event.Skip(); }
|
||||
virtual void OnAddGenerator( wxCommandEvent& event ) { event.Skip(); }
|
||||
virtual void OnDelGenerator( wxCommandEvent& event ) { event.Skip(); }
|
||||
|
@ -67,6 +71,7 @@ class NETLIST_DIALOG_BASE : public DIALOG_SHIM
|
|||
public:
|
||||
|
||||
NETLIST_DIALOG_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Export Netlist"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
|
||||
|
||||
~NETLIST_DIALOG_BASE();
|
||||
|
||||
};
|
||||
|
@ -98,13 +103,14 @@ class NETLIST_DIALOG_ADD_GENERATOR_BASE : public DIALOG_SHIM
|
|||
wxButton* m_sdbSizerOK;
|
||||
wxButton* m_sdbSizerCancel;
|
||||
|
||||
// Virtual event handlers, overide them in your derived class
|
||||
// Virtual event handlers, override them in your derived class
|
||||
virtual void OnBrowseGenerators( wxCommandEvent& event ) { event.Skip(); }
|
||||
|
||||
|
||||
public:
|
||||
|
||||
NETLIST_DIALOG_ADD_GENERATOR_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Script Generator Properties"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
|
||||
|
||||
~NETLIST_DIALOG_ADD_GENERATOR_BASE();
|
||||
|
||||
};
|
||||
|
|
|
@ -76,6 +76,17 @@ void EESCHEMA_JOBS_HANDLER::InitRenderSettings( KIGFX::SCH_RENDER_SETTINGS* aRen
|
|||
}
|
||||
|
||||
|
||||
REPORTER& EESCHEMA_JOBS_HANDLER::Report( const wxString& aText, SEVERITY aSeverity )
|
||||
{
|
||||
if( aSeverity == RPT_SEVERITY_ERROR )
|
||||
wxFprintf( stderr, aText );
|
||||
else
|
||||
wxPrintf( aText );
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
int EESCHEMA_JOBS_HANDLER::JobExportPdf( JOB* aJob )
|
||||
{
|
||||
JOB_EXPORT_SCH_PDF* aPdfJob = dynamic_cast<JOB_EXPORT_SCH_PDF*>( aJob );
|
||||
|
@ -224,7 +235,7 @@ int EESCHEMA_JOBS_HANDLER::JobExportNetlist( JOB* aJob )
|
|||
aNetJob->m_outputFile = fn.GetFullName();
|
||||
}
|
||||
|
||||
bool res = helper->WriteNetlist( aNetJob->m_outputFile, 0 );
|
||||
bool res = helper->WriteNetlist( aNetJob->m_outputFile, 0, *this );
|
||||
|
||||
if(!res)
|
||||
{
|
||||
|
@ -287,7 +298,7 @@ int EESCHEMA_JOBS_HANDLER::JobExportBom( JOB* aJob )
|
|||
aNetJob->m_outputFile = fn.GetFullName();
|
||||
}
|
||||
|
||||
bool res = xmlNetlist->WriteNetlist( aNetJob->m_outputFile, GNL_OPT_BOM );
|
||||
bool res = xmlNetlist->WriteNetlist( aNetJob->m_outputFile, GNL_OPT_BOM, *this );
|
||||
|
||||
if( !res )
|
||||
{
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
|
||||
#include <jobs/job_dispatcher.h>
|
||||
#include <wx/string.h>
|
||||
#include <reporter.h>
|
||||
|
||||
namespace KIGFX
|
||||
{
|
||||
|
@ -34,7 +35,7 @@ class SCHEMATIC;
|
|||
/**
|
||||
* Handles eeschema job dispatches
|
||||
*/
|
||||
class EESCHEMA_JOBS_HANDLER : public JOB_DISPATCHER
|
||||
class EESCHEMA_JOBS_HANDLER : public JOB_DISPATCHER, REPORTER
|
||||
{
|
||||
public:
|
||||
EESCHEMA_JOBS_HANDLER();
|
||||
|
@ -54,6 +55,17 @@ public:
|
|||
*/
|
||||
void InitRenderSettings( KIGFX::SCH_RENDER_SETTINGS* aRenderSettings, const wxString& aTheme,
|
||||
SCHEMATIC* aSch );
|
||||
|
||||
/*
|
||||
* REPORTER INTERFACE
|
||||
*/
|
||||
REPORTER& Report( const wxString& aText, SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED ) override;
|
||||
|
||||
bool HasMessage() const override
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#endif
|
|
@ -106,7 +106,8 @@ public:
|
|||
/**
|
||||
* Write to specified output file.
|
||||
*/
|
||||
virtual bool WriteNetlist( const wxString& aOutFileName, unsigned aNetlistOptions )
|
||||
virtual bool WriteNetlist( const wxString& aOutFileName, unsigned aNetlistOptions,
|
||||
REPORTER& aReporter )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -37,16 +37,16 @@
|
|||
static wxString StartLine( wxT( "." ) );
|
||||
|
||||
bool NETLIST_EXPORTER_CADSTAR::WriteNetlist( const wxString& aOutFileName,
|
||||
unsigned /* aNetlistOptions */ )
|
||||
unsigned /* aNetlistOptions */,
|
||||
REPORTER& aReporter )
|
||||
{
|
||||
int ret = 0;
|
||||
FILE* f = nullptr;
|
||||
|
||||
if( ( f = wxFopen( aOutFileName, wxT( "wt" ) ) ) == nullptr )
|
||||
{
|
||||
wxString msg;
|
||||
msg.Printf( _( "Failed to create file '%s'." ), aOutFileName );
|
||||
DisplayError( nullptr, msg );
|
||||
wxString msg = wxString::Format( _( "Failed to create file '%s'." ), aOutFileName );
|
||||
aReporter.Report( msg, RPT_SEVERITY_ERROR );
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -43,7 +43,8 @@ public:
|
|||
/**
|
||||
* Write to specified output file.
|
||||
*/
|
||||
bool WriteNetlist( const wxString& aOutFileName, unsigned aNetlistOptions ) override;
|
||||
bool WriteNetlist( const wxString& aOutFileName, unsigned aNetlistOptions,
|
||||
REPORTER& aReporter ) override;
|
||||
|
||||
private:
|
||||
/**
|
||||
|
|
|
@ -32,7 +32,8 @@
|
|||
#include "netlist_exporter_kicad.h"
|
||||
|
||||
|
||||
bool NETLIST_EXPORTER_KICAD::WriteNetlist( const wxString& aOutFileName, unsigned aNetlistOptions )
|
||||
bool NETLIST_EXPORTER_KICAD::WriteNetlist( const wxString& aOutFileName, unsigned aNetlistOptions,
|
||||
REPORTER& aReporter )
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -42,7 +43,7 @@ bool NETLIST_EXPORTER_KICAD::WriteNetlist( const wxString& aOutFileName, unsigne
|
|||
|
||||
catch( const IO_ERROR& ioe )
|
||||
{
|
||||
DisplayError( nullptr, ioe.What() );
|
||||
aReporter.Report( ioe.What(), RPT_SEVERITY_ERROR );
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -47,7 +47,8 @@ public:
|
|||
* Generate the KiCad netlist format supported by Pcbnew. It is basically the XML netlist
|
||||
* just formatted slightly different.
|
||||
*/
|
||||
bool WriteNetlist( const wxString& aOutFileName, unsigned aNetlistOptions ) override;
|
||||
bool WriteNetlist( const wxString& aOutFileName, unsigned aNetlistOptions,
|
||||
REPORTER& aReporter ) override;
|
||||
|
||||
/**
|
||||
* Output this s-expression netlist into @a aOutputFormatter.
|
||||
|
|
|
@ -37,7 +37,8 @@
|
|||
|
||||
|
||||
bool NETLIST_EXPORTER_ORCADPCB2::WriteNetlist( const wxString& aOutFileName,
|
||||
unsigned /* aNetlistOptions */ )
|
||||
unsigned /* aNetlistOptions */,
|
||||
REPORTER& aReporter )
|
||||
{
|
||||
FILE* f = nullptr;
|
||||
wxString field;
|
||||
|
@ -48,9 +49,8 @@ bool NETLIST_EXPORTER_ORCADPCB2::WriteNetlist( const wxString& aOutFileName,
|
|||
|
||||
if( ( f = wxFopen( aOutFileName, wxT( "wt" ) ) ) == nullptr )
|
||||
{
|
||||
wxString msg;
|
||||
msg.Printf( _( "Failed to create file '%s'." ), aOutFileName );
|
||||
DisplayError( nullptr, msg );
|
||||
wxString msg = wxString::Format( _( "Failed to create file '%s'." ), aOutFileName );
|
||||
aReporter.Report( msg, RPT_SEVERITY_ERROR );
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -39,7 +39,8 @@ public:
|
|||
{
|
||||
}
|
||||
|
||||
bool WriteNetlist( const wxString& aOutFileName, unsigned aNetlistOptions ) override;
|
||||
bool WriteNetlist( const wxString& aOutFileName, unsigned aNetlistOptions,
|
||||
REPORTER& aReporter ) override;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -101,14 +101,16 @@ NETLIST_EXPORTER_SPICE::NETLIST_EXPORTER_SPICE( SCHEMATIC_IFACE* aSchematic ) :
|
|||
}
|
||||
|
||||
|
||||
bool NETLIST_EXPORTER_SPICE::WriteNetlist( const wxString& aOutFileName, unsigned aNetlistOptions )
|
||||
bool NETLIST_EXPORTER_SPICE::WriteNetlist( const wxString& aOutFileName, unsigned aNetlistOptions,
|
||||
REPORTER& aReporter )
|
||||
{
|
||||
FILE_OUTPUTFORMATTER formatter( aOutFileName, wxT( "wt" ), '\'' );
|
||||
return DoWriteNetlist( formatter, aNetlistOptions );
|
||||
return DoWriteNetlist( formatter, aNetlistOptions, aReporter );
|
||||
}
|
||||
|
||||
|
||||
bool NETLIST_EXPORTER_SPICE::DoWriteNetlist( OUTPUTFORMATTER& aFormatter, unsigned aNetlistOptions )
|
||||
bool NETLIST_EXPORTER_SPICE::DoWriteNetlist( OUTPUTFORMATTER& aFormatter, unsigned aNetlistOptions,
|
||||
REPORTER& aReporter )
|
||||
{
|
||||
LOCALE_IO dummy;
|
||||
|
||||
|
@ -118,7 +120,7 @@ bool NETLIST_EXPORTER_SPICE::DoWriteNetlist( OUTPUTFORMATTER& aFormatter, unsign
|
|||
// Default title.
|
||||
m_title = "KiCad schematic";
|
||||
|
||||
if( !ReadSchematicAndLibraries( aNetlistOptions ) )
|
||||
if( !ReadSchematicAndLibraries( aNetlistOptions, aReporter ) )
|
||||
return false;
|
||||
|
||||
WriteHead( aFormatter, aNetlistOptions );
|
||||
|
@ -146,13 +148,14 @@ void NETLIST_EXPORTER_SPICE::WriteTail( OUTPUTFORMATTER& aFormatter, unsigned aN
|
|||
}
|
||||
|
||||
|
||||
bool NETLIST_EXPORTER_SPICE::ReadSchematicAndLibraries( unsigned aNetlistOptions )
|
||||
bool NETLIST_EXPORTER_SPICE::ReadSchematicAndLibraries( unsigned aNetlistOptions,
|
||||
REPORTER& aReporter )
|
||||
{
|
||||
wxArrayString error_msgs;
|
||||
wxString msg;
|
||||
std::set<std::string> refNames; // Set of reference names to check for duplication.
|
||||
int ncCounter = 1;
|
||||
|
||||
ReadDirectives( aNetlistOptions, error_msgs );
|
||||
ReadDirectives( aNetlistOptions, aReporter );
|
||||
|
||||
m_nets.clear();
|
||||
m_items.clear();
|
||||
|
@ -232,23 +235,15 @@ bool NETLIST_EXPORTER_SPICE::ReadSchematicAndLibraries( unsigned aNetlistOptions
|
|||
}
|
||||
catch( const IO_ERROR& e )
|
||||
{
|
||||
error_msgs.Add( wxString::Format( _( "Error reading simulation model from symbol "
|
||||
"'%s':\n%s" ),
|
||||
msg.Printf( _( "Error reading simulation model from symbol '%s':\n%s" ),
|
||||
symbol->GetRef( &sheet ),
|
||||
e.What() ) );
|
||||
e.What() );
|
||||
aReporter.Report( msg, RPT_SEVERITY_ERROR );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( error_msgs.GetCount() )
|
||||
{
|
||||
HTML_MESSAGE_BOX dlg( nullptr, _( "Errors" ) );
|
||||
|
||||
dlg.ListSet( error_msgs );
|
||||
dlg.ShowModal();
|
||||
}
|
||||
|
||||
return true;
|
||||
return !aReporter.HasMessage();
|
||||
}
|
||||
|
||||
|
||||
|
@ -288,16 +283,17 @@ const SPICE_ITEM* NETLIST_EXPORTER_SPICE::FindItem( const std::string& aRefName
|
|||
}
|
||||
|
||||
|
||||
void NETLIST_EXPORTER_SPICE::ReadDirectives( unsigned aNetlistOptions, wxArrayString& aErrors )
|
||||
void NETLIST_EXPORTER_SPICE::ReadDirectives( unsigned aNetlistOptions, REPORTER& aReporter )
|
||||
{
|
||||
wxString msg;
|
||||
wxString text;
|
||||
|
||||
m_directives.clear();
|
||||
|
||||
for( const SCH_SHEET_PATH& sheet : GetSheets( aNetlistOptions ) )
|
||||
{
|
||||
for( SCH_ITEM* item : sheet.LastScreen()->Items() )
|
||||
{
|
||||
wxString text;
|
||||
|
||||
if( item->Type() == SCH_TEXT_T )
|
||||
text = static_cast<SCH_TEXT*>( item )->GetShownText();
|
||||
else if( item->Type() == SCH_TEXTBOX_T )
|
||||
|
@ -339,10 +335,10 @@ void NETLIST_EXPORTER_SPICE::ReadDirectives( unsigned aNetlistOptions, wxArraySt
|
|||
}
|
||||
catch( const IO_ERROR& e )
|
||||
{
|
||||
aErrors.Add( wxString::Format( _( "Error reading simulation model library "
|
||||
"'%s':\n%s" ),
|
||||
msg.Printf( _( "Error reading simulation model library '%s':\n%s" ),
|
||||
path,
|
||||
e.What() ) );
|
||||
e.What() );
|
||||
aReporter.Report( msg, RPT_SEVERITY_ERROR );
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
|
@ -64,12 +64,14 @@ public:
|
|||
/**
|
||||
* Write to specified output file.
|
||||
*/
|
||||
bool WriteNetlist( const wxString& aOutFileName, unsigned aNetlistOptions ) override;
|
||||
bool WriteNetlist( const wxString& aOutFileName, unsigned aNetlistOptions,
|
||||
REPORTER& aReporter ) override;
|
||||
|
||||
/**
|
||||
* Write the netlist in aFormatter.
|
||||
*/
|
||||
bool DoWriteNetlist( OUTPUTFORMATTER& aFormatter, unsigned aNetlistOptions );
|
||||
bool DoWriteNetlist( OUTPUTFORMATTER& aFormatter, unsigned aNetlistOptions,
|
||||
REPORTER& aReporter );
|
||||
|
||||
/**
|
||||
* Write the netlist head (title and so on).
|
||||
|
@ -87,7 +89,7 @@ public:
|
|||
* if only net mapping and the list of SPICE_ITEMs are required.
|
||||
* @return True if successful.
|
||||
*/
|
||||
virtual bool ReadSchematicAndLibraries( unsigned aNetlistOptions );
|
||||
virtual bool ReadSchematicAndLibraries( unsigned aNetlistOptions, REPORTER& aReporter );
|
||||
|
||||
/**
|
||||
* Replace illegal spice net name characters with underscores.
|
||||
|
@ -123,7 +125,7 @@ public:
|
|||
const std::vector<std::string>& GetDirectives() { return m_directives; }
|
||||
|
||||
protected:
|
||||
void ReadDirectives( unsigned aNetlistOptions, wxArrayString& aErrors );
|
||||
void ReadDirectives( unsigned aNetlistOptions, REPORTER& aReporter );
|
||||
virtual void WriteDirectives( OUTPUTFORMATTER& aFormatter, unsigned aNetlistOptions ) const;
|
||||
|
||||
virtual std::string GenerateItemPinNetName( const std::string& aNetName, int& aNcCounter ) const;
|
||||
|
|
|
@ -64,11 +64,12 @@ void NETLIST_EXPORTER_SPICE_MODEL::WriteTail( OUTPUTFORMATTER& aFormatter,
|
|||
}
|
||||
|
||||
|
||||
bool NETLIST_EXPORTER_SPICE_MODEL::ReadSchematicAndLibraries( unsigned aNetlistOptions )
|
||||
bool NETLIST_EXPORTER_SPICE_MODEL::ReadSchematicAndLibraries( unsigned aNetlistOptions,
|
||||
REPORTER& aReporter )
|
||||
{
|
||||
readPorts( aNetlistOptions );
|
||||
|
||||
return NETLIST_EXPORTER_SPICE::ReadSchematicAndLibraries( aNetlistOptions );
|
||||
return NETLIST_EXPORTER_SPICE::ReadSchematicAndLibraries( aNetlistOptions, aReporter );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ public:
|
|||
|
||||
void WriteHead( OUTPUTFORMATTER& aFormatter, unsigned aNetlistOptions ) override;
|
||||
void WriteTail( OUTPUTFORMATTER& aFormatter, unsigned aNetlistOptions ) override;
|
||||
bool ReadSchematicAndLibraries( unsigned aNetlistOptions ) override;
|
||||
bool ReadSchematicAndLibraries( unsigned aNetlistOptions, REPORTER& aReporter ) override;
|
||||
|
||||
protected:
|
||||
std::string GenerateItemPinNetName( const std::string& aNetName, int& aNcCounter ) const override;
|
||||
|
|
|
@ -41,7 +41,8 @@
|
|||
|
||||
static bool sortPinsByNumber( LIB_PIN* aPin1, LIB_PIN* aPin2 );
|
||||
|
||||
bool NETLIST_EXPORTER_XML::WriteNetlist( const wxString& aOutFileName, unsigned aNetlistOptions )
|
||||
bool NETLIST_EXPORTER_XML::WriteNetlist( const wxString& aOutFileName, unsigned aNetlistOptions,
|
||||
REPORTER& aReporter )
|
||||
{
|
||||
// output the XML format netlist.
|
||||
|
||||
|
@ -55,6 +56,7 @@ bool NETLIST_EXPORTER_XML::WriteNetlist( const wxString& aOutFileName, unsigned
|
|||
wxXmlDocument xdoc;
|
||||
|
||||
unsigned aCtl = aNetlistOptions;
|
||||
|
||||
if( aNetlistOptions & GNL_OPT_BOM )
|
||||
aCtl |= ( GNL_SYMBOLS | GNL_HEADER );
|
||||
else
|
||||
|
|
|
@ -75,7 +75,8 @@ public:
|
|||
*
|
||||
* @return true if the netlist was written successfully.
|
||||
*/
|
||||
bool WriteNetlist( const wxString& aOutFileName, unsigned aNetlistOptions ) override;
|
||||
bool WriteNetlist( const wxString& aOutFileName, unsigned aNetlistOptions,
|
||||
REPORTER& aReporter ) override;
|
||||
|
||||
#define GNL_ALL ( GNL_LIBRARIES | GNL_SYMBOLS | GNL_PARTS | GNL_HEADER | GNL_NETS )
|
||||
|
||||
|
|
|
@ -107,7 +107,13 @@ bool SCH_EDIT_FRAME::WriteNetListFile( int aFormat, const wxString& aFullFileNam
|
|||
break;
|
||||
}
|
||||
|
||||
res = helper->WriteNetlist( fileName, aNetlistOptions );
|
||||
NULL_REPORTER devnull;
|
||||
|
||||
if( aReporter )
|
||||
res = helper->WriteNetlist( fileName, aNetlistOptions, *aReporter );
|
||||
else
|
||||
res = helper->WriteNetlist( fileName, aNetlistOptions, devnull );
|
||||
|
||||
delete helper;
|
||||
|
||||
// If user provided a plugin command line, execute it.
|
||||
|
|
|
@ -253,14 +253,14 @@ vector<double> NGSPICE::GetPhasePlot( const string& aName, int aMaxLen )
|
|||
}
|
||||
|
||||
|
||||
bool NGSPICE::Attach( const std::shared_ptr<SIMULATION_MODEL>& aModel )
|
||||
bool NGSPICE::Attach( const std::shared_ptr<SIMULATION_MODEL>& aModel, REPORTER& aReporter )
|
||||
{
|
||||
NGSPICE_CIRCUIT_MODEL* model = dynamic_cast<NGSPICE_CIRCUIT_MODEL*>( aModel.get() );
|
||||
STRING_FORMATTER formatter;
|
||||
|
||||
if( model && model->GetNetlist( &formatter ) )
|
||||
if( model && model->GetNetlist( &formatter, aReporter ) )
|
||||
{
|
||||
SIMULATOR::Attach( aModel );
|
||||
SIMULATOR::Attach( aModel, aReporter );
|
||||
|
||||
LoadNetlist( formatter.GetString() );
|
||||
|
||||
|
@ -268,7 +268,7 @@ bool NGSPICE::Attach( const std::shared_ptr<SIMULATION_MODEL>& aModel )
|
|||
}
|
||||
else
|
||||
{
|
||||
SIMULATOR::Attach( nullptr );
|
||||
SIMULATOR::Attach( nullptr, aReporter );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -59,7 +59,8 @@ public:
|
|||
void Init( const SPICE_SIMULATOR_SETTINGS* aSettings = nullptr ) override final;
|
||||
|
||||
///< @copydoc SPICE_SIMULATOR::Attach()
|
||||
bool Attach( const std::shared_ptr<SIMULATION_MODEL>& aModel ) override final;
|
||||
bool Attach( const std::shared_ptr<SIMULATION_MODEL>& aModel,
|
||||
REPORTER& aReporter ) override final;
|
||||
|
||||
///< Load a netlist for the simulation
|
||||
bool LoadNetlist( const std::string& aNetlist ) override final;
|
||||
|
|
|
@ -68,10 +68,10 @@ SIM_PLOT_TYPE NGSPICE_CIRCUIT_MODEL::VectorToSignal( const std::string& aVector,
|
|||
|
||||
wxString NGSPICE_CIRCUIT_MODEL::GetSheetSimCommand()
|
||||
{
|
||||
wxArrayString error_msgs;
|
||||
NULL_REPORTER devnull;
|
||||
wxString simCmd;
|
||||
|
||||
ReadDirectives( 0, error_msgs );
|
||||
ReadDirectives( 0, devnull );
|
||||
|
||||
for( const std::string& directive : GetDirectives() )
|
||||
{
|
||||
|
|
|
@ -69,9 +69,9 @@ public:
|
|||
m_options = aOptions;
|
||||
}
|
||||
|
||||
bool GetNetlist( OUTPUTFORMATTER* aFormatter )
|
||||
bool GetNetlist( OUTPUTFORMATTER* aFormatter, REPORTER& aReporter )
|
||||
{
|
||||
return NGSPICE_CIRCUIT_MODEL::DoWriteNetlist( *aFormatter, m_options );
|
||||
return NGSPICE_CIRCUIT_MODEL::DoWriteNetlist( *aFormatter, m_options, aReporter );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -243,7 +243,9 @@ SIM_PLOT_FRAME::SIM_PLOT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
|
|||
|
||||
SIM_PLOT_FRAME::~SIM_PLOT_FRAME()
|
||||
{
|
||||
m_simulator->Attach( nullptr );
|
||||
NULL_REPORTER devnull;
|
||||
|
||||
m_simulator->Attach( nullptr, devnull );
|
||||
m_simulator->SetReporter( nullptr );
|
||||
delete m_reporter;
|
||||
delete m_signalsIconColorList;
|
||||
|
@ -478,10 +480,14 @@ void SIM_PLOT_FRAME::StartSimulation( const wxString& aSimCommand )
|
|||
| NETLIST_EXPORTER_SPICE::OPTION_SAVE_ALL_VOLTAGES
|
||||
| NETLIST_EXPORTER_SPICE::OPTION_SAVE_ALL_CURRENTS );
|
||||
|
||||
wxString errors;
|
||||
WX_STRING_REPORTER reporter( &errors );
|
||||
|
||||
if( !m_schematicFrame->ReadyToNetlist( _( "Simulator requires a fully annotated schematic." ) )
|
||||
|| !m_simulator->Attach( m_circuitModel ) )
|
||||
|| !m_simulator->Attach( m_circuitModel, reporter ) )
|
||||
{
|
||||
DisplayErrorMessage( this, _( "Errors during netlist generation; simulation aborted." ) );
|
||||
DisplayErrorMessage( this, _( "Errors during netlist generation; simulation aborted.\n\n" )
|
||||
+ errors );
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1474,9 +1480,14 @@ void SIM_PLOT_FRAME::onSettings( wxCommandEvent& event )
|
|||
if( !m_settingsDlg )
|
||||
m_settingsDlg = new DIALOG_SIM_SETTINGS( this, m_circuitModel, m_simulator->Settings() );
|
||||
|
||||
if( !m_circuitModel->ReadSchematicAndLibraries( NETLIST_EXPORTER_SPICE::OPTION_DEFAULT_FLAGS ) )
|
||||
wxString errors;
|
||||
WX_STRING_REPORTER reporter( &errors );
|
||||
|
||||
if( !m_circuitModel->ReadSchematicAndLibraries( NETLIST_EXPORTER_SPICE::OPTION_DEFAULT_FLAGS,
|
||||
reporter ) )
|
||||
{
|
||||
DisplayErrorMessage( this, _( "There were errors during netlist export, aborted." ) );
|
||||
DisplayErrorMessage( this, _( "Errors during netlist generation; simulation aborted.\n\n" )
|
||||
+ errors );
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1625,10 +1636,12 @@ void SIM_PLOT_FRAME::onShowNetlist( wxCommandEvent& event )
|
|||
if( m_schematicFrame == nullptr || m_simulator == nullptr )
|
||||
return;
|
||||
|
||||
wxString errors;
|
||||
WX_STRING_REPORTER reporter( &errors );
|
||||
STRING_FORMATTER formatter;
|
||||
m_circuitModel->GetNetlist( &formatter );
|
||||
m_circuitModel->GetNetlist( &formatter, reporter );
|
||||
|
||||
NETLIST_VIEW_DIALOG dlg( this, formatter.GetString() );
|
||||
NETLIST_VIEW_DIALOG dlg( this, errors.IsEmpty() ? formatter.GetString() : errors );
|
||||
dlg.ShowModal();
|
||||
}
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include <memory>
|
||||
|
||||
class SPICE_SIMULATOR;
|
||||
class REPORTER;
|
||||
|
||||
class SIMULATION_MODEL
|
||||
{
|
||||
|
@ -70,7 +71,7 @@ public:
|
|||
*
|
||||
* @return True in case of success, false otherwise.
|
||||
*/
|
||||
virtual bool Attach( const std::shared_ptr<SIMULATION_MODEL>& aModel )
|
||||
virtual bool Attach( const std::shared_ptr<SIMULATION_MODEL>& aModel, REPORTER& aReporter )
|
||||
{
|
||||
m_simModel = aModel;
|
||||
return true;
|
||||
|
|
|
@ -142,9 +142,13 @@ void TEST_NETLIST_EXPORTER_FIXTURE<Exporter>::WriteNetlist()
|
|||
if( wxFileExists( GetNetlistPath( true ) ) )
|
||||
wxRemoveFile( GetNetlistPath( true ) );
|
||||
|
||||
auto exporter = std::make_unique<Exporter>( &m_schematic );
|
||||
BOOST_REQUIRE_EQUAL( exporter->WriteNetlist( GetNetlistPath( true ), GetNetlistOptions() ),
|
||||
true );
|
||||
wxString errors;
|
||||
WX_STRING_REPORTER reporter( &errors );
|
||||
std::unique_ptr<Exporter> exporter = std::make_unique<Exporter>( &m_schematic );
|
||||
|
||||
bool success = exporter->WriteNetlist( GetNetlistPath( true ), GetNetlistOptions(), reporter );
|
||||
|
||||
BOOST_REQUIRE( success && errors.IsEmpty() );
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue