KiCad PCB EDA Suite
SPICE_SIMULATOR Class Referenceabstract

#include <spice_simulator.h>

Inheritance diagram for SPICE_SIMULATOR:
NGSPICE

Public Member Functions

 SPICE_SIMULATOR ()
 
virtual ~SPICE_SIMULATOR ()
 
virtual void Init ()=0
 

Intializes the simulator

More...
 
virtual bool LoadNetlist (const std::string &aNetlist)=0
 
virtual bool Run ()=0
 Executes the simulation with currently loaded netlist. More...
 
virtual bool Stop ()=0
 Halts the simulation. More...
 
virtual bool IsRunning ()=0
 Checks if simulation is running at the moment. More...
 
virtual bool Command (const std::string &aCmd)=0
 Executes a Spice command as if it was typed into console. More...
 
virtual std::string GetXAxis (SIM_TYPE aType) const =0
 

Returns X axis name for a given simulation type

More...
 
virtual void SetReporter (SPICE_REPORTER *aReporter)
 

Sets a SPICE_REPORTER object to receive the simulation log.

More...
 
virtual std::vector< COMPLEXGetPlot (const std::string &aName, int aMaxLen=-1)=0
 Returns a requested vector with complex values. More...
 
virtual std::vector< double > GetRealPlot (const std::string &aName, int aMaxLen=-1)=0
 Returns a requested vector with real values. More...
 
virtual std::vector< double > GetImagPlot (const std::string &aName, int aMaxLen=-1)=0
 Returns a requested vector with imaginary values. More...
 
virtual std::vector< double > GetMagPlot (const std::string &aName, int aMaxLen=-1)=0
 Returns a requested vector with magnitude values. More...
 
virtual std::vector< double > GetPhasePlot (const std::string &aName, int aMaxLen=-1)=0
 Returns a requested vector with phase values. More...
 

Static Public Member Functions

static SPICE_SIMULATORCreateInstance (const std::string &aName)
 

Creates a simulator instance of particular type (currently only ngspice is handled)

More...
 

Protected Attributes

SPICE_REPORTERm_reporter
 

Reporter object to receive simulation log

More...
 

Detailed Description

Definition at line 38 of file spice_simulator.h.

Constructor & Destructor Documentation

SPICE_SIMULATOR::SPICE_SIMULATOR ( )
inline

Definition at line 41 of file spice_simulator.h.

41 : m_reporter( NULL ) {}
SPICE_REPORTER * m_reporter
Reporter object to receive simulation log
virtual SPICE_SIMULATOR::~SPICE_SIMULATOR ( )
inlinevirtual

Definition at line 42 of file spice_simulator.h.

42 {}

Member Function Documentation

virtual bool SPICE_SIMULATOR::Command ( const std::string &  aCmd)
pure virtual

Executes a Spice command as if it was typed into console.

Parameters
aCmdis the command to be issued.

Implemented in NGSPICE.

Referenced by SIM_PLOT_FRAME::applyTuners(), SIM_PLOT_FRAME::onSimFinished(), and SIM_PLOT_FRAME::updatePlot().

SPICE_SIMULATOR * SPICE_SIMULATOR::CreateInstance ( const std::string &  aName)
static

Creates a simulator instance of particular type (currently only ngspice is handled)

Definition at line 29 of file spice_simulator.cpp.

References DisplayError().

Referenced by SIM_PLOT_FRAME::SIM_PLOT_FRAME().

30 {
31  try
32  {
33  static NGSPICE* ngspiceInstance = nullptr;
34 
35  if( !ngspiceInstance )
36  ngspiceInstance = new NGSPICE;
37 
38  return ngspiceInstance;
39  }
40  catch( std::exception& e )
41  {
42  DisplayError( NULL, e.what() );
43  }
44 
45  return NULL;
46 }
void DisplayError(wxWindow *parent, const wxString &text, int displaytime)
Function DisplayError displays an error or warning message box with aMessage.
Definition: confirm.cpp:71
virtual std::vector<double> SPICE_SIMULATOR::GetImagPlot ( const std::string &  aName,
int  aMaxLen = -1 
)
pure virtual

Returns a requested vector with imaginary values.

If the vector is complex, then the imaginary part is returned. If the vector is reql, then only zeroes are returned.

Parameters
aNameis the vector named in Spice convention (e.g. V(3), I(R1)).
aMaxLenis max count of returned values. if -1 (default) all available values are returned.
Returns
Requested vector. It might be empty if there is no vector with requested name.

Implemented in NGSPICE.

virtual std::vector<double> SPICE_SIMULATOR::GetMagPlot ( const std::string &  aName,
int  aMaxLen = -1 
)
pure virtual

Returns a requested vector with magnitude values.

Parameters
aNameis the vector named in Spice convention (e.g. V(3), I(R1)).
aMaxLenis max count of returned values. if -1 (default) all available values are returned.
Returns
Requested vector. It might be empty if there is no vector with requested name.

Implemented in NGSPICE.

Referenced by SIM_PLOT_FRAME::updatePlot().

virtual std::vector<double> SPICE_SIMULATOR::GetPhasePlot ( const std::string &  aName,
int  aMaxLen = -1 
)
pure virtual

Returns a requested vector with phase values.

Parameters
aNameis the vector named in Spice convention (e.g. V(3), I(R1)).
aMaxLenis max count of returned values. if -1 (default) all available values are returned.
Returns
Requested vector. It might be empty if there is no vector with requested name.

Implemented in NGSPICE.

Referenced by SIM_PLOT_FRAME::updatePlot().

virtual std::vector<COMPLEX> SPICE_SIMULATOR::GetPlot ( const std::string &  aName,
int  aMaxLen = -1 
)
pure virtual

Returns a requested vector with complex values.

If the vector is real, then the imaginary part is set to 0 in all values.

Parameters
aNameis the vector named in Spice convention (e.g. V(3), I(R1)).
aMaxLenis max count of returned values. if -1 (default) all available values are returned.
Returns
Requested vector. It might be empty if there is no vector with requested name.

Implemented in NGSPICE.

virtual std::vector<double> SPICE_SIMULATOR::GetRealPlot ( const std::string &  aName,
int  aMaxLen = -1 
)
pure virtual

Returns a requested vector with real values.

If the vector is complex, then the real part is returned.

Parameters
aNameis the vector named in Spice convention (e.g. V(3), I(R1)).
aMaxLenis max count of returned values. if -1 (default) all available values are returned.
Returns
Requested vector. It might be empty if there is no vector with requested name.

Implemented in NGSPICE.

virtual std::string SPICE_SIMULATOR::GetXAxis ( SIM_TYPE  aType) const
pure virtual

Returns X axis name for a given simulation type

Implemented in NGSPICE.

Referenced by SIM_PLOT_FRAME::updatePlot().

virtual void SPICE_SIMULATOR::Init ( )
pure virtual

Intializes the simulator

Implemented in NGSPICE.

Referenced by SIM_PLOT_FRAME::SIM_PLOT_FRAME().

virtual bool SPICE_SIMULATOR::IsRunning ( )
pure virtual

Checks if simulation is running at the moment.

Returns
True if simulation is currently executed.

Implemented in NGSPICE.

Referenced by SIM_PLOT_FRAME::IsSimulationRunning().

virtual bool SPICE_SIMULATOR::LoadNetlist ( const std::string &  aNetlist)
pure virtual

Implemented in NGSPICE.

Referenced by SIM_PLOT_FRAME::StartSimulation().

virtual bool SPICE_SIMULATOR::Run ( )
pure virtual

Executes the simulation with currently loaded netlist.

Returns
True in case of success, false otherwise.

Implemented in NGSPICE.

Referenced by SIM_PLOT_FRAME::onSimUpdate(), and SIM_PLOT_FRAME::StartSimulation().

virtual void SPICE_SIMULATOR::SetReporter ( SPICE_REPORTER aReporter)
inlinevirtual

Sets a SPICE_REPORTER object to receive the simulation log.

Definition at line 84 of file spice_simulator.h.

References m_reporter.

Referenced by SIM_PLOT_FRAME::SIM_PLOT_FRAME(), and SIM_PLOT_FRAME::~SIM_PLOT_FRAME().

85  {
86  m_reporter = aReporter;
87  }
SPICE_REPORTER * m_reporter
Reporter object to receive simulation log
virtual bool SPICE_SIMULATOR::Stop ( )
pure virtual

Halts the simulation.

Returns
True in case of success, false otherwise.

Implemented in NGSPICE.

Referenced by SIM_PLOT_FRAME::onClose(), and SIM_PLOT_FRAME::StopSimulation().

Member Data Documentation

SPICE_REPORTER* SPICE_SIMULATOR::m_reporter
protected

Reporter object to receive simulation log

Definition at line 139 of file spice_simulator.h.

Referenced by NGSPICE::cbBGThreadRunning(), NGSPICE::cbSendChar(), and SetReporter().


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