KiCad PCB EDA Suite
ngspice.h
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  * @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 3
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, you may find one here:
19  * https://www.gnu.org/licenses/gpl-3.0.html
20  * or you may search the http://www.gnu.org website for the version 3 license,
21  * or you may write to the Free Software Foundation, Inc.,
22  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23  */
24 
25 #ifndef NGSPICE_H
26 #define NGSPICE_H
27 
28 #include "spice_simulator.h"
29 
30 #include <ngspice/sharedspice.h>
31 
32 class wxDynamicLibrary;
33 
34 class NGSPICE : public SPICE_SIMULATOR {
35 
36 public:
37  NGSPICE();
38  virtual ~NGSPICE();
39 
41  void Init() override;
42 
44  bool LoadNetlist( const std::string& aNetlist ) override;
45 
47  bool Run() override;
48 
50  bool Stop() override;
51 
53  bool IsRunning() override;
54 
56  bool Command( const std::string& aCmd ) override;
57 
59  std::string GetXAxis( SIM_TYPE aType ) const override;
60 
62  std::vector<COMPLEX> GetPlot( const std::string& aName, int aMaxLen = -1 ) override;
63 
65  std::vector<double> GetRealPlot( const std::string& aName, int aMaxLen = -1 ) override;
66 
68  std::vector<double> GetImagPlot( const std::string& aName, int aMaxLen = -1 ) override;
69 
71  std::vector<double> GetMagPlot( const std::string& aName, int aMaxLen = -1 ) override;
72 
74  std::vector<double> GetPhasePlot( const std::string& aName, int aMaxLen = -1 ) override;
75 
76 private:
77  void init();
78 
80  bool loadSpinit( const std::string& aFileName );
81 
84  std::string findCmPath() const;
85 
87  bool loadCodemodels( const std::string& aPath );
88 
89  // Callback functions
90  static int cbSendChar( char* what, int id, void* user );
91  static int cbSendStat( char* what, int id, void* user );
92  static int cbBGThreadRunning( bool is_running, int id, void* user );
93  static int cbControlledExit( int status, bool immediate, bool exit_upon_quit, int id, void* user );
94 
95  void dump();
96 
98  static bool m_initialized;
99 };
100 
101 #endif /* NGSPICE_H */
virtual ~NGSPICE()
Definition: ngspice.cpp:43
bool Run() override
>
Definition: ngspice.cpp:215
static int cbBGThreadRunning(bool is_running, int id, void *user)
Definition: ngspice.cpp:411
std::vector< double > GetRealPlot(const std::string &aName, int aMaxLen=-1) override
>
Definition: ngspice.cpp:81
static int cbControlledExit(int status, bool immediate, bool exit_upon_quit, int id, void *user)
Definition: ngspice.cpp:423
static int cbSendChar(char *what, int id, void *user)
Definition: ngspice.cpp:383
bool loadCodemodels(const std::string &aPath)
Loads codemodel files from a directory
Definition: ngspice.cpp:371
std::vector< double > GetImagPlot(const std::string &aName, int aMaxLen=-1) override
>
Definition: ngspice.cpp:113
std::vector< double > GetMagPlot(const std::string &aName, int aMaxLen=-1) override
>
Definition: ngspice.cpp:137
static bool m_initialized
NGspice should be initialized only once
Definition: ngspice.h:98
void Init() override
>
Definition: ngspice.cpp:48
NGSPICE()
Definition: ngspice.cpp:37
SIM_TYPE
Possible simulation types
Definition: sim_types.h:29
std::vector< COMPLEX > GetPlot(const std::string &aName, int aMaxLen=-1) override
>
Definition: ngspice.cpp:54
bool Stop() override
>
Definition: ngspice.cpp:222
std::string findCmPath() const
Checks a few different locations for codemodel files and returns one if it exists ...
Definition: ngspice.cpp:348
std::string GetXAxis(SIM_TYPE aType) const override
>
Definition: ngspice.cpp:245
std::vector< double > GetPhasePlot(const std::string &aName, int aMaxLen=-1) override
>
Definition: ngspice.cpp:164
void init()
Definition: ngspice.cpp:270
bool LoadNetlist(const std::string &aNetlist) override
>
Definition: ngspice.cpp:191
bool Command(const std::string &aCmd) override
>
Definition: ngspice.cpp:236
bool IsRunning() override
>
Definition: ngspice.cpp:229
bool loadSpinit(const std::string &aFileName)
Executes commands from a file
Definition: ngspice.cpp:331
static int cbSendStat(char *what, int id, void *user)
Definition: ngspice.cpp:401
void dump()