eeschema,sim: refactor NETLIST_EXPORTER_PSPICE_SIM creation
This commit is contained in:
parent
9a342458fa
commit
53ccd8bd67
|
@ -57,9 +57,10 @@ static wxString getStringSelection( const wxChoice* aCtrl )
|
|||
|
||||
|
||||
DIALOG_SIM_SETTINGS::DIALOG_SIM_SETTINGS( wxWindow* aParent,
|
||||
std::shared_ptr<NETLIST_EXPORTER_PSPICE_SIM> aExporter,
|
||||
std::shared_ptr<SPICE_SIMULATOR_SETTINGS>& aSettings ) :
|
||||
DIALOG_SIM_SETTINGS_BASE( aParent ),
|
||||
m_exporter( nullptr ),
|
||||
m_exporter( aExporter ),
|
||||
m_settings( aSettings ),
|
||||
m_spiceEmptyValidator( true )
|
||||
{
|
||||
|
|
|
@ -39,7 +39,8 @@ class SPICE_SIMULATOR_SETTINGS;
|
|||
class DIALOG_SIM_SETTINGS : public DIALOG_SIM_SETTINGS_BASE
|
||||
{
|
||||
public:
|
||||
DIALOG_SIM_SETTINGS( wxWindow* aParent, std::shared_ptr<SPICE_SIMULATOR_SETTINGS>& aSettings );
|
||||
DIALOG_SIM_SETTINGS( wxWindow* aParent, std::shared_ptr<NETLIST_EXPORTER_PSPICE_SIM> aExporter,
|
||||
std::shared_ptr<SPICE_SIMULATOR_SETTINGS>& aSettings );
|
||||
|
||||
const wxString& GetSimCommand() const
|
||||
{
|
||||
|
@ -61,10 +62,6 @@ public:
|
|||
return m_netlistOpts;
|
||||
}
|
||||
|
||||
void SetNetlistExporter( NETLIST_EXPORTER_PSPICE_SIM* aExporter )
|
||||
{
|
||||
m_exporter = aExporter;
|
||||
}
|
||||
|
||||
bool TransferDataFromWindow() override;
|
||||
bool TransferDataToWindow() override;
|
||||
|
@ -181,7 +178,7 @@ private:
|
|||
|
||||
wxString m_simCommand;
|
||||
int m_netlistOpts;
|
||||
NETLIST_EXPORTER_PSPICE_SIM* m_exporter;
|
||||
std::shared_ptr<NETLIST_EXPORTER_PSPICE_SIM> m_exporter;
|
||||
std::shared_ptr<SPICE_SIMULATOR_SETTINGS> m_settings;
|
||||
SPICE_VALIDATOR m_spiceValidator;
|
||||
SPICE_VALIDATOR m_spiceEmptyValidator;
|
||||
|
|
|
@ -318,6 +318,7 @@ bool NETLIST_EXPORTER_PSPICE::ProcessNetlist( unsigned aCtl )
|
|||
std::set<wxString> refNames; // Set of reference names, to check for duplication
|
||||
|
||||
m_netMap.clear();
|
||||
m_spiceItems.clear();
|
||||
|
||||
int refNet = 0;
|
||||
const char* refNetString = "0";
|
||||
|
|
|
@ -157,7 +157,7 @@ SIM_PLOT_FRAME::SIM_PLOT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
|
|||
// instead of being behind the dialog frame (as it does)
|
||||
m_settingsDlg = nullptr;
|
||||
|
||||
updateNetlistExporter();
|
||||
m_exporter.reset( new NETLIST_EXPORTER_PSPICE_SIM( &m_schematicFrame->Schematic() ) );
|
||||
|
||||
Bind( EVT_SIM_UPDATE, &SIM_PLOT_FRAME::onSimUpdate, this );
|
||||
Bind( EVT_SIM_REPORT, &SIM_PLOT_FRAME::onSimReport, this );
|
||||
|
@ -459,10 +459,9 @@ void SIM_PLOT_FRAME::StartSimulation( const wxString& aSimCommand )
|
|||
STRING_FORMATTER formatter;
|
||||
|
||||
if( !m_settingsDlg )
|
||||
m_settingsDlg = new DIALOG_SIM_SETTINGS( this, m_simulator->Settings() );
|
||||
m_settingsDlg = new DIALOG_SIM_SETTINGS( this, m_exporter, m_simulator->Settings() );
|
||||
|
||||
m_simConsole->Clear();
|
||||
updateNetlistExporter();
|
||||
|
||||
if( aSimCommand.IsEmpty() )
|
||||
m_exporter->SetSimCommand( getCurrentSimCommand() );
|
||||
|
@ -490,12 +489,6 @@ void SIM_PLOT_FRAME::StartSimulation( const wxString& aSimCommand )
|
|||
}
|
||||
|
||||
|
||||
void SIM_PLOT_FRAME::StopSimulation()
|
||||
{
|
||||
m_simulator->Stop();
|
||||
}
|
||||
|
||||
|
||||
SIM_PANEL_BASE* SIM_PLOT_FRAME::NewPlotPanel( wxString aSimCommand )
|
||||
{
|
||||
SIM_PANEL_BASE* plotPanel = nullptr;
|
||||
|
@ -708,15 +701,6 @@ void SIM_PLOT_FRAME::removePlot( const wxString& aPlotName )
|
|||
}
|
||||
|
||||
|
||||
void SIM_PLOT_FRAME::updateNetlistExporter()
|
||||
{
|
||||
m_exporter.reset( new NETLIST_EXPORTER_PSPICE_SIM( &m_schematicFrame->Schematic() ) );
|
||||
|
||||
if( m_settingsDlg )
|
||||
m_settingsDlg->SetNetlistExporter( m_exporter.get() );
|
||||
}
|
||||
|
||||
|
||||
bool SIM_PLOT_FRAME::updatePlot( const wxString& aName, SIM_PLOT_TYPE aType, const wxString& aParam,
|
||||
SIM_PLOT_PANEL* aPlotPanel )
|
||||
{
|
||||
|
@ -1457,7 +1441,7 @@ void SIM_PLOT_FRAME::onWorkbookClrModified( wxCommandEvent& event )
|
|||
void SIM_PLOT_FRAME::onSimulate( wxCommandEvent& event )
|
||||
{
|
||||
if( m_simulator->IsRunning() )
|
||||
StopSimulation();
|
||||
m_simulator->Stop();
|
||||
else
|
||||
StartSimulation();
|
||||
}
|
||||
|
@ -1468,10 +1452,7 @@ void SIM_PLOT_FRAME::onSettings( wxCommandEvent& event )
|
|||
SIM_PANEL_BASE* plotPanelWindow = getCurrentPlotWindow();
|
||||
|
||||
if( !m_settingsDlg )
|
||||
m_settingsDlg = new DIALOG_SIM_SETTINGS( this, m_simulator->Settings() );
|
||||
|
||||
// Initial processing is required to e.g. display a list of power sources
|
||||
updateNetlistExporter();
|
||||
m_settingsDlg = new DIALOG_SIM_SETTINGS( this, m_exporter, m_simulator->Settings() );
|
||||
|
||||
if( !m_exporter->ProcessNetlist( NET_ALL_FLAGS ) )
|
||||
{
|
||||
|
@ -1805,7 +1786,7 @@ void SIM_PLOT_FRAME::onSimFinished( wxCommandEvent& aEvent )
|
|||
void SIM_PLOT_FRAME::onSimUpdate( wxCommandEvent& aEvent )
|
||||
{
|
||||
if( m_simulator->IsRunning() )
|
||||
StopSimulation();
|
||||
m_simulator->Stop();
|
||||
|
||||
if( GetCurrentPlot() != m_lastSimPlot )
|
||||
{
|
||||
|
|
|
@ -70,7 +70,6 @@ public:
|
|||
~SIM_PLOT_FRAME();
|
||||
|
||||
void StartSimulation( const wxString& aSimCommand = wxEmptyString );
|
||||
void StopSimulation();
|
||||
|
||||
/**
|
||||
* Create a new plot panel for a given simulation type and adds it to the main notebook.
|
||||
|
@ -179,11 +178,6 @@ private:
|
|||
*/
|
||||
void removePlot( const wxString& aPlotName );
|
||||
|
||||
/**
|
||||
* Reload the current schematic for the netlist exporter.
|
||||
*/
|
||||
void updateNetlistExporter();
|
||||
|
||||
/**
|
||||
* Update plot in a particular SIM_PLOT_PANEL. If the panel does not contain
|
||||
* the plot, it will be added.
|
||||
|
@ -339,7 +333,7 @@ private:
|
|||
wxToolBarToolBase* m_toolSettings;
|
||||
|
||||
SCH_EDIT_FRAME* m_schematicFrame;
|
||||
std::unique_ptr<NETLIST_EXPORTER_PSPICE_SIM> m_exporter;
|
||||
std::shared_ptr<NETLIST_EXPORTER_PSPICE_SIM> m_exporter;
|
||||
std::shared_ptr<SPICE_SIMULATOR> m_simulator;
|
||||
SIM_THREAD_REPORTER* m_reporter;
|
||||
|
||||
|
|
Loading…
Reference in New Issue