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
32std::shared_ptr<SPICE_SIMULATOR> SIMULATOR::CreateInstance( const std::string& )
33{
34 try
35 {
36 static std::shared_ptr<SPICE_SIMULATOR> ngspiceInstance;
37
38 if( !ngspiceInstance )
39 ngspiceInstance = std::make_shared<NGSPICE>();
40
41 return ngspiceInstance;
42 }
43 catch( std::exception& e )
44 {
45 DisplayError( nullptr, e.what() );
46 }
47
48 return nullptr;
49}
50
51
52wxString SPICE_SIMULATOR::TypeToName( SIM_TYPE aType, bool aShortName )
53{
54 switch( aType )
55 {
56 case ST_OP:
57 return aShortName ? wxString( wxT( "OP" ) )
58 : _( "Operating Point" );
59
60 case ST_AC:
61 return "AC";
62
63 case ST_DC:
64 return aShortName ? wxString( wxT( "DC" ) )
65 : _( "DC Sweep" );
66
67 case ST_TRANSIENT:
68 return aShortName ? wxString( wxT( "TRAN" ) )
69 : _( "Transient" );
70
71 case ST_DISTORTION:
72 return aShortName ? wxString( wxT( "DISTO" ) )
73 : _( "Distortion" );
74
75 case ST_NOISE:
76 return aShortName ? wxString( wxT( "NOISE" ) )
77 : _( "Noise" );
78
79 case ST_POLE_ZERO:
80 return aShortName ? wxString( wxT( "PZ" ) )
81 : _( "Pole-zero" );
82
83 case ST_SENSITIVITY:
84 return aShortName ? wxString( wxT( "SENS" ) )
85 : _( "Sensitivity" );
86
87 case ST_TRANS_FUNC:
88 return aShortName ? wxString( wxT( "TF" ) )
89 : _( "Transfer function" );
90
91 default:
92 case ST_UNKNOWN:
93 return aShortName ? _( "UNKNOWN!" ) : _( "Unknown" );
94 }
95}
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:283
This file is part of the common library.
#define _(s)
SIM_TYPE
< Possible simulation types
Definition: sim_types.h:32
@ ST_TRANS_FUNC
Definition: sim_types.h:41
@ ST_TRANSIENT
Definition: sim_types.h:42
@ ST_DISTORTION
Definition: sim_types.h:36
@ ST_UNKNOWN
Definition: sim_types.h:33
@ ST_NOISE
Definition: sim_types.h:37
@ ST_AC
Definition: sim_types.h:34
@ ST_POLE_ZERO
Definition: sim_types.h:39
@ ST_DC
Definition: sim_types.h:35
@ ST_OP
Definition: sim_types.h:38
@ ST_SENSITIVITY
Definition: sim_types.h:40