KiCad PCB EDA Suite
Loading...
Searching...
No Matches
spice_simulator.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2016 CERN
5 * Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors.
6 * @author Tomasz Wlostowski <[email protected]>
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 3
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, you may find one here:
20 * https://www.gnu.org/licenses/gpl-3.0.html
21 * or you may search the http://www.gnu.org website for the version 3 license,
22 * or you may write to the Free Software Foundation, Inc.,
23 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24 */
25
26#include <confirm.h>
27
28// Include simulator headers after wxWidgets headers to avoid conflicts with Windows headers
29// (especially on msys2 + wxWidgets 3.0.x)
30#include "ngspice.h"
31#include "macros.h"
32
33std::shared_ptr<SPICE_SIMULATOR> SIMULATOR::CreateInstance( const std::string& )
34{
35 try
36 {
37 static std::shared_ptr<SPICE_SIMULATOR> ngspiceInstance;
38
39 if( !ngspiceInstance )
40 ngspiceInstance = std::make_shared<NGSPICE>();
41
42 return ngspiceInstance;
43 }
44 catch( std::exception& e )
45 {
46 DisplayError( nullptr, e.what() );
47 }
48
49 return nullptr;
50}
51
52
53wxString SPICE_SIMULATOR::TypeToName( SIM_TYPE aType, bool aShortName )
54{
55 switch( aType )
56 {
57 case ST_OP: return aShortName ? wxString( wxT( "OP" ) ) : _( "DC Operating Point" );
58 case ST_AC: return aShortName ? wxString( wxT( "AC" ) ) : _( "Small-Signal Analysis" );
59 case ST_DC: return aShortName ? wxString( wxT( "DC" ) ) : _( "DC Sweep Analysis" );
60 case ST_TRAN: return aShortName ? wxString( wxT( "TRAN" ) ) : _( "Transient Analysis" );
61 case ST_DISTO: return aShortName ? wxString( wxT( "DISTO" ) ) : _( "Small-Signal Distortion Analysis" );
62 case ST_NOISE: return aShortName ? wxString( wxT( "NOISE" ) ) : _( "Noise Analysis" );
63 case ST_PZ: return aShortName ? wxString( wxT( "PZ" ) ) : _( "Pole-Zero Analysis" );
64 case ST_SENS: return aShortName ? wxString( wxT( "SENS" ) ) : _( "Sensitivity Analysis" );
65 case ST_TF: return aShortName ? wxString( wxT( "TF" ) ) : _( "Transfer Function Analysis" );
66 case ST_SP: return aShortName ? wxString( wxT( "SP" ) ) : _( "S-Parameter Analysis" );
67 case ST_FFT: return aShortName ? wxString( wxT( "FFT" ) ) : _( "Frequency Content Analysis" );
68 default:
69 case ST_UNKNOWN: return aShortName ? wxString( wxT( "??" ) ) : _( "Unknown" );
70 }
71}
72
73
static std::shared_ptr< SPICE_SIMULATOR > CreateInstance(const std::string &aName)
static wxString TypeToName(SIM_TYPE aType, bool aShortName)
Return a string with simulation name based on enum.
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:170
This file is part of the common library.
#define _(s)
This file contains miscellaneous commonly used macros and functions.
SIM_TYPE
< Possible simulation types
Definition: sim_types.h:32
@ ST_SP
Definition: sim_types.h:43
@ ST_TRAN
Definition: sim_types.h:42
@ ST_UNKNOWN
Definition: sim_types.h:33
@ ST_NOISE
Definition: sim_types.h:37
@ ST_AC
Definition: sim_types.h:34
@ ST_DISTO
Definition: sim_types.h:36
@ ST_TF
Definition: sim_types.h:41
@ ST_SENS
Definition: sim_types.h:40
@ ST_DC
Definition: sim_types.h:35
@ ST_OP
Definition: sim_types.h:38
@ ST_FFT
Definition: sim_types.h:44
@ ST_PZ
Definition: sim_types.h:39