28 #include <wx/tokenzr.h> 31 const wxString& aName,
SIM_PLOT_TYPE aType,
const wxString& aParam )
const 55 wxString param = aParam.Lower();
57 if( device.length() > 0 && device[0] ==
'x' )
59 return "current probe of .subckt not yet implemented";
65 param.IsEmpty() ?
"i" : param );
74 const std::string& aVector, wxString& aSignal )
const 79 wxRegEx internalDevParameter(
"^@(\\w*[\\.\\w+]*)\\[(\\w*)\\]$", wxRE_ADVANCED );
80 wxString vector( aVector );
82 if( !internalDevParameter.Matches( vector ) )
85 aSignal =
"V(" + aVector +
")";
90 wxString paramType = internalDevParameter.GetMatch( vector, 2 );
92 if( paramType.Lower()[0] ==
'i' )
96 aSignal = paramType +
"(";
97 aSignal += internalDevParameter.GetMatch( vector, 1 ).Upper() +
")";
110 static const std::vector<wxString> passive = {
"I" };
111 static const std::vector<wxString> diode = {
"Id" };
112 static const std::vector<wxString> bjt = {
"Ib",
"Ic",
"Ie" };
113 static const std::vector<wxString> mos = {
"Ig",
"Id",
"Is" };
114 static const std::vector<wxString>
empty;
169 const std::vector<std::pair<wxString, SIM_TYPE>> simCmds = {
170 {
"^.ac\\M.*",
ST_AC },
171 {
"^.dc\\M.*",
ST_DC },
173 {
"^.op\\M.*",
ST_OP },
181 for(
const auto& c : simCmds )
183 simCmd.Compile( c.first, wxRE_ADVANCED | wxRE_NOSUB | wxRE_ICASE );
185 if( simCmd.Matches( aCmd ) )
196 if( !aCmd.Lower().StartsWith(
".dc" ) )
199 wxString cmd = aCmd.Mid( 3 ).Trim().Trim(
false );
201 wxStringTokenizer tokens( cmd );
203 size_t num = tokens.CountTokens();
205 if( num != 4 && num != 8 )
208 aSource1->
m_source = tokens.GetNextToken();
215 aSource2->
m_source = tokens.GetNextToken();
232 for(
const auto& current :
235 if( !item.m_enabled )
239 aFormatter->
Print( 0,
".save %s\n",
252 if( netname ==
"V(0)" || netname ==
"V(GND)" )
255 aFormatter->
Print( 0,
".save %s\n", (
const char*) netname.c_str() );
269 aFormatter->
Print( 0,
"%s\n", (
const char*) dir.c_str() );
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
Return name of Spice dataset for a specific plot.
const SPICE_ITEM_LIST & GetSpiceItems() const
Return list of items representing schematic components in the Spice world.
wxString GetUsedSimCommand()
Return the command directive that is in use (either from the sheet or from m_simCommand.
const std::vector< wxString > GetDirectives() const
Return a vector of Spice directives found in the schematics.
SIM_PLOT_TYPE VectorToSignal(const std::string &aVector, wxString &aSignal) const
Return name of Spice dataset for a specific plot.
static bool IsSimCommand(const wxString &aCmd)
Determine if a directive is a simulation command.
static SIM_TYPE CommandToSimType(const wxString &aCmd)
Return simulation type basing on a simulation command directive.
void writeDirectives(OUTPUTFORMATTER *aFormatter, unsigned aCtl) const override
Save the Spice directives.
static const std::vector< wxString > & GetCurrents(SPICE_PRIMITIVE aPrimitive)
Return a list of currents that can be probed in a Spice primitive.
wxString GetSheetSimCommand()
Return simulation command directives placed in schematic sheets (if any).
< Helper class to handle Spice way of expressing values (e.g. 10.5 Meg) Helper class to recognize Spi...
SIM_TYPE
< Possible simulation types
virtual void writeDirectives(OUTPUTFORMATTER *aFormatter, unsigned aCtl) const
Save the Spice directives.
void UpdateDirectives(unsigned aCtl)
Update the vector of Spice directives placed in the schematics.
const NET_INDEX_MAP & GetNetIndexMap() const
Return a map of circuit nodes to net names.
static void ReplaceForbiddenChars(wxString &aNetName)
Replace illegal spice net name characters with an underscore.
bool ParseDCCommand(const wxString &aCmd, SPICE_DC_PARAMS *aSource1, SPICE_DC_PARAMS *aSource2)
Parse a two-source .dc command directive into its components.
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
wxString UnescapeString(const wxString &aSource)
static bool empty(const wxTextEntryBase *aCtrl)
wxString GetSpiceDevice(const wxString &aComponent) const
Return name of Spice device corresponding to a schematic component.
SIM_TYPE GetSimType()
Return simulation type basing on the simulation command directives.