KiCad PCB EDA Suite
Loading...
Searching...
No Matches
ngspice_circuit_model.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-2022 CERN
5 * Copyright (C) 2017-2023 KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * @author Maciej Suminski <[email protected]>
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 3
12 * of the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, you may find one here:
21 * https://www.gnu.org/licenses/gpl-3.0.html
22 * or you may search the http://www.gnu.org website for the version 3 license,
23 * or you may write to the Free Software Foundation, Inc.,
24 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
25 */
26
27#ifndef NGSPICE_CIRCUIT_MODEL_H
28#define NGSPICE_CIRCUIT_MODEL_H
29
31#include <vector>
32
33#include "sim_types.h"
34#include "spice_simulator.h"
35#include "spice_value.h"
36
37
39{
40 wxString m_source;
44};
45
48{
49public:
50 NGSPICE_CIRCUIT_MODEL( SCHEMATIC_IFACE* aSchematic, wxWindow* aDialogParent = nullptr ) :
51 NETLIST_EXPORTER_SPICE( aSchematic, aDialogParent ),
53 {}
54
56
65 SIM_TRACE_TYPE VectorToSignal( const std::string& aVector, wxString& aSignal ) const;
66
67 void SetSimOptions( int aOptions ) { m_options = aOptions; }
68 int GetSimOptions() const { return m_options; }
69
70 bool GetNetlist( OUTPUTFORMATTER* aFormatter, REPORTER& aReporter )
71 {
72 return NGSPICE_CIRCUIT_MODEL::DoWriteNetlist( *aFormatter, m_options, aReporter );
73 }
74
78 void SetSimCommandOverride( const wxString& aCmd )
79 {
80 if( aCmd != m_simCommand )
81 {
83 m_simCommand = aCmd;
84 }
85 }
86
91 wxString GetSimCommand()
92 {
93 return m_simCommand.IsEmpty() ? GetSchTextSimCommand() : m_simCommand;
94 }
95
99 wxString GetSimCommandOverride() const { return m_simCommand; }
100
108
112 wxString GetSchTextSimCommand();
113
120
127 bool ParseDCCommand( const wxString& aCmd, SPICE_DC_PARAMS* aSource1,
128 SPICE_DC_PARAMS* aSource2 );
129
133 static bool IsSimCommand( const wxString& aCmd )
134 {
135 return CommandToSimType( aCmd ) != ST_UNKNOWN;
136 }
137
141 static SIM_TYPE CommandToSimType( const wxString& aCmd );
142
143protected:
144 void WriteDirectives( OUTPUTFORMATTER& aFormatter, unsigned aNetlistOptions ) const override;
145
146private:
148 wxString m_simCommand;
149
152
154};
155
156#endif /* NGSPICE_CIRCUIT_MODEL_H */
bool DoWriteNetlist(OUTPUTFORMATTER &aFormatter, unsigned aNetlistOptions, REPORTER &aReporter)
Write the netlist in aFormatter.
Special netlist exporter flavor that allows one to override simulation commands.
NGSPICE_CIRCUIT_MODEL(SCHEMATIC_IFACE *aSchematic, wxWindow *aDialogParent=nullptr)
SIM_TRACE_TYPE VectorToSignal(const std::string &aVector, wxString &aSignal) const
Return name of Spice dataset for a specific trace.
SIM_TYPE GetSimType()
Return simulation type basing on the simulation command directives.
static SIM_TYPE CommandToSimType(const wxString &aCmd)
Return simulation type basing on a simulation command directive.
bool ParseDCCommand(const wxString &aCmd, SPICE_DC_PARAMS *aSource1, SPICE_DC_PARAMS *aSource2)
Parse a two-source .dc command directive into its symbols.
bool GetNetlist(OUTPUTFORMATTER *aFormatter, REPORTER &aReporter)
void WriteDirectives(OUTPUTFORMATTER &aFormatter, unsigned aNetlistOptions) const override
wxString GetSimCommandOverride() const
Return the simulation command directive if stored separately (not as a sheet directive).
wxString GetSchTextSimCommand()
Return simulation command directives placed in schematic sheets (if any).
static bool IsSimCommand(const wxString &aCmd)
Determine if a directive is a simulation command.
void SetSimCommandOverride(const wxString &aCmd)
Override the simulation command directive.
wxString GetLastSchTextSimCommand() const
Return the sim command present as a sheet directive when the sim command override was last updated.
void SetSimOptions(int aOptions)
wxString GetSimCommand()
Return the command directive that is in use (either from the sheet or from m_simCommand)
wxString m_simCommand
< Custom simulation command (has priority over the schematic sheet simulation commands)
An interface used to output 8 bit text in a convenient way.
Definition: richio.h:322
A pure virtual class used to derive REPORTER objects from.
Definition: reporter.h:71
Helper class to recognize Spice formatted values.
Definition: spice_value.h:56
SIM_TRACE_TYPE
Definition: sim_types.h:47
SIM_TYPE
< Possible simulation types
Definition: sim_types.h:32
@ ST_UNKNOWN
Definition: sim_types.h:33