KiCad PCB EDA Suite
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 "ngspice.h"
27
28#include <confirm.h>
29
30std::shared_ptr<SPICE_SIMULATOR> SIMULATOR::CreateInstance( const std::string& )
31{
32 try
33 {
34 static std::shared_ptr<SPICE_SIMULATOR> ngspiceInstance;
35
36 if( !ngspiceInstance )
37 ngspiceInstance = std::make_shared<NGSPICE>();
38
39 return ngspiceInstance;
40 }
41 catch( std::exception& e )
42 {
43 DisplayError( nullptr, e.what() );
44 }
45
46 return nullptr;
47}
48
49
50wxString SPICE_SIMULATOR::TypeToName( SIM_TYPE aType, bool aShortName )
51{
52 switch( aType )
53 {
54 case ST_OP:
55 return aShortName ? wxT( "OP" ) : _( "Operating Point" );
56
57 case ST_AC:
58 return "AC";
59
60 case ST_DC:
61 return aShortName ? wxT( "DC" ) : _( "DC Sweep" );
62
63 case ST_TRANSIENT:
64 return aShortName ? wxT( "TRAN" ) : _( "Transient" );
65
66 case ST_DISTORTION:
67 return aShortName ? wxT( "DISTO" ) : _( "Distortion" );
68
69 case ST_NOISE:
70 return aShortName ? wxT( "NOISE" ) : _( "Noise" );
71
72 case ST_POLE_ZERO:
73 return aShortName ? wxT( "PZ" ) : _( "Pole-zero" );
74
75 case ST_SENSITIVITY:
76 return aShortName ? wxT( "SENS" ) : _( "Sensitivity" );
77
78 case ST_TRANS_FUNC:
79 return aShortName ? wxT( "TF" ) : _( "Transfer function" );
80
81 default:
82 case ST_UNKNOWN:
83 return aShortName ? _( "UNKNOWN!" ) : _( "Unknown" );
84 }
85}
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:280
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