KiCad PCB EDA Suite
netlist_exporter_pspice_sim.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 KiCad Developers, see AUTHORS.txt for contributors.
6  *
7  * @author Maciej Suminski <maciej.suminski@cern.ch>
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_value.h"
35 
36 
38 {
39  wxString m_source;
43 };
44 
47 {
48 public:
50  NETLIST_EXPORTER_PSPICE( aSchematic )
51  {
52  }
53 
63  wxString ComponentToVector( const wxString& aName, SIM_PLOT_TYPE aType,
64  const wxString& aParam = wxEmptyString ) const;
65 
73  SIM_PLOT_TYPE VectorToSignal( const std::string& aVector, wxString& aSignal ) const;
74 
78  static const std::vector<wxString>& GetCurrents( SPICE_PRIMITIVE aPrimitive );
79 
83  void SetSimCommand( const wxString& aCmd )
84  {
85  m_simCommand = aCmd;
86  }
87 
91  const wxString& GetSimCommand() const
92  {
93  return m_simCommand;
94  }
95 
100  {
101  m_simCommand.Clear();
102  }
103 
108  wxString GetUsedSimCommand();
109 
116 
120  wxString GetSheetSimCommand();
121 
128  bool ParseDCCommand( const wxString& aCmd, SPICE_DC_PARAMS* aSource1,
129  SPICE_DC_PARAMS* aSource2 );
130 
134  static bool IsSimCommand( const wxString& aCmd )
135  {
136  return CommandToSimType( aCmd ) != ST_UNKNOWN;
137  }
138 
142  static SIM_TYPE CommandToSimType( const wxString& aCmd );
143 
144 protected:
145  void writeDirectives( OUTPUTFORMATTER* aFormatter, unsigned aCtl ) const override;
146 
147 private:
148 
150  wxString m_simCommand;
151 };
152 
153 #endif /* NETLIST_EXPORTER_PSPICE_SIM_H */
wxString m_simCommand
Custom simulation command (has priority over the schematic sheet simulation commands)
wxString ComponentToVector(const wxString &aName, SIM_PLOT_TYPE aType, const wxString &aParam=wxEmptyString) const
Returns name of Spice dataset for a specific plot.
wxString GetUsedSimCommand()
Returns the command directive that is in use (either from the sheet or from m_simCommand.
Holds all the data relating to one schematic A schematic may consist of one or more sheets (and one r...
Definition: schematic.h:42
OUTPUTFORMATTER is an important interface (abstract class) used to output 8 bit text in a convenient ...
Definition: richio.h:327
SIM_PLOT_TYPE VectorToSignal(const std::string &aVector, wxString &aSignal) const
Returns name of Spice dataset for a specific plot.
static bool IsSimCommand(const wxString &aCmd)
Determines if a directive is a simulation command.
static SIM_TYPE CommandToSimType(const wxString &aCmd)
Returns simulation type basing on a simulation command directive.
void writeDirectives(OUTPUTFORMATTER *aFormatter, unsigned aCtl) const override
Saves the Spice directives.
static const std::vector< wxString > & GetCurrents(SPICE_PRIMITIVE aPrimitive)
Returns a list of currents that can be probed in a Spice primitive.
wxString GetSheetSimCommand()
Returns simulation command directives placed in schematic sheets (if any).
Helper class to handle Spice way of expressing values (e.g. 10.5 Meg)
Definition: spice_value.h:32
SIM_TYPE
Possible simulation types
Definition: sim_types.h:29
void SetSimCommand(const wxString &aCmd)
Overrides the simulation command directive.
void ClearSimCommand()
Clears the simulation command directive.
bool ParseDCCommand(const wxString &aCmd, SPICE_DC_PARAMS *aSource1, SPICE_DC_PARAMS *aSource2)
Parses a two-source .dc command directive into its components.
const wxString & GetSimCommand() const
Returns the simulation command directive.
SPICE_PRIMITIVE
Basic Spice component primitives
NETLIST_EXPORTER_PSPICE generates a PSPICE compatible netlist.
SIM_PLOT_TYPE
Possible plot types
Definition: sim_types.h:44
NETLIST_EXPORTER_PSPICE_SIM(SCHEMATIC *aSchematic)
SIM_TYPE GetSimType()
Returns simulation type basing on the simulation command directives.
Special netlist exporter flavor that allows one to override simulation commands.