KiCad PCB EDA Suite
ngspice_helpers.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 * Copyright (C) 2017-2021 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 NETLIST_EXPORTER_PSPICE_SIM_H
28#define NETLIST_EXPORTER_PSPICE_SIM_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:
51 NETLIST_EXPORTER_SPICE( aSchematic ),
52 m_options( 0 )
53 {
54 }
56
65 SIM_PLOT_TYPE VectorToSignal( const std::string& aVector, wxString& aSignal ) const;
66
67 void SetOptions( int aOptions )
68 {
69 m_options = aOptions;
70 }
71
72 bool GetNetlist( OUTPUTFORMATTER* aFormatter )
73 {
75 }
76
80 void SetSimCommand( const wxString& aCmd )
81 {
82 m_simCommand = aCmd;
83 }
84
89 wxString GetSimCommand()
90 {
91 return m_simCommand.IsEmpty() ? GetSheetSimCommand() : m_simCommand;
92 }
93
97 wxString GetUnderlyingSimCommand() const { return m_simCommand; }
98
103 {
104 m_simCommand.Clear();
105 }
106
114
118 wxString GetSheetSimCommand();
119
126 bool ParseDCCommand( const wxString& aCmd, SPICE_DC_PARAMS* aSource1,
127 SPICE_DC_PARAMS* aSource2 );
128
132 static bool IsSimCommand( const wxString& aCmd )
133 {
134 return CommandToSimType( aCmd ) != ST_UNKNOWN;
135 }
136
140 static SIM_TYPE CommandToSimType( const wxString& aCmd );
141
142protected:
143 void WriteDirectives( OUTPUTFORMATTER& aFormatter, unsigned aNetlistOptions ) const override;
144
145private:
147 wxString m_simCommand;
149};
150
151#endif /* NETLIST_EXPORTER_PSPICE_SIM_H */
bool DoWriteNetlist(OUTPUTFORMATTER &aFormatter, unsigned aNetlistOptions)
Write the netlist in aFormatter.
Special netlist exporter flavor that allows one to override simulation commands.
virtual ~NGSPICE_CIRCUIT_MODEL()
void SetOptions(int aOptions)
wxString GetUnderlyingSimCommand() const
Return the simulation command directive if stored separately (not as a sheet directive).
void ClearSimCommand()
Clear the simulation command directive.
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 GetNetlist(OUTPUTFORMATTER *aFormatter)
bool ParseDCCommand(const wxString &aCmd, SPICE_DC_PARAMS *aSource1, SPICE_DC_PARAMS *aSource2)
Parse a two-source .dc command directive into its symbols.
void WriteDirectives(OUTPUTFORMATTER &aFormatter, unsigned aNetlistOptions) const override
wxString GetSheetSimCommand()
Return simulation command directives placed in schematic sheets (if any).
void SetSimCommand(const wxString &aCmd)
Override the simulation command directive.
NGSPICE_CIRCUIT_MODEL(SCHEMATIC_IFACE *aSchematic)
static bool IsSimCommand(const wxString &aCmd)
Determine if a directive is a simulation command.
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)
SIM_PLOT_TYPE VectorToSignal(const std::string &aVector, wxString &aSignal) const
Return name of Spice dataset for a specific plot.
An interface used to output 8 bit text in a convenient way.
Definition: richio.h:310
< Helper class to handle Spice way of expressing values (e.g. 10.5 Meg) Helper class to recognize Spi...
Definition: spice_value.h:35
SIM_PLOT_TYPE
Definition: sim_types.h:47
SIM_TYPE
< Possible simulation types
Definition: sim_types.h:32
@ ST_UNKNOWN
Definition: sim_types.h:33
SPICE_VALUE m_vstart
SPICE_VALUE m_vincrement
SPICE_VALUE m_vend