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 The 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, see <https://www.gnu.org/licenses/>.
20 */
21
22#include <confirm.h>
23
24// Include simulator headers after wxWidgets headers to avoid conflicts with Windows headers
25// (especially on msys2 + wxWidgets 3.0.x)
26#include "ngspice.h"
27#include "macros.h"
28
29std::shared_ptr<SPICE_SIMULATOR> SIMULATOR::CreateInstance( const std::string& )
30{
31 try
32 {
33 static std::shared_ptr<SPICE_SIMULATOR> ngspiceInstance;
34
35 if( !ngspiceInstance )
36 ngspiceInstance = std::make_shared<NGSPICE>();
37
38 return ngspiceInstance;
39 }
40 catch( std::exception& e )
41 {
42 DisplayError( nullptr, e.what() );
43 }
44
45 return nullptr;
46}
47
48
49wxString SPICE_SIMULATOR::TypeToName( SIM_TYPE aType, bool aShortName )
50{
51 switch( aType )
52 {
53 case ST_OP: return aShortName ? wxString( wxT( "OP" ) ) : _( "DC Operating Point" );
54 case ST_AC: return aShortName ? wxString( wxT( "AC" ) ) : _( "Small-Signal Analysis" );
55 case ST_DC: return aShortName ? wxString( wxT( "DC" ) ) : _( "DC Sweep Analysis" );
56 case ST_TRAN: return aShortName ? wxString( wxT( "TRAN" ) ) : _( "Transient Analysis" );
57 case ST_DISTO: return aShortName ? wxString( wxT( "DISTO" ) ) : _( "Small-Signal Distortion Analysis" );
58 case ST_NOISE: return aShortName ? wxString( wxT( "NOISE" ) ) : _( "Noise Analysis" );
59 case ST_PZ: return aShortName ? wxString( wxT( "PZ" ) ) : _( "Pole-Zero Analysis" );
60 case ST_SENS: return aShortName ? wxString( wxT( "SENS" ) ) : _( "Sensitivity Analysis" );
61 case ST_TF: return aShortName ? wxString( wxT( "TF" ) ) : _( "Transfer Function Analysis" );
62 case ST_SP: return aShortName ? wxString( wxT( "SP" ) ) : _( "S-Parameter Analysis" );
63 case ST_FFT: return aShortName ? wxString( wxT( "FFT" ) ) : _( "Frequency Content Analysis" );
64 default:
65 case ST_UNKNOWN: return aShortName ? wxString( wxT( "Custom" ) ) : _( "Custom" );
66 }
67}
68
69
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)
Display an error or warning message box with aMessage.
Definition confirm.cpp:192
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:28
@ ST_SP
Definition sim_types.h:39
@ ST_TRAN
Definition sim_types.h:38
@ ST_UNKNOWN
Definition sim_types.h:29
@ ST_NOISE
Definition sim_types.h:33
@ ST_AC
Definition sim_types.h:30
@ ST_DISTO
Definition sim_types.h:32
@ ST_TF
Definition sim_types.h:37
@ ST_SENS
Definition sim_types.h:36
@ ST_DC
Definition sim_types.h:31
@ ST_OP
Definition sim_types.h:34
@ ST_FFT
Definition sim_types.h:40
@ ST_PZ
Definition sim_types.h:35