29#include <wx/tokenzr.h> 
   36                                                    wxString& aSignal )
 const 
   38    static wxString BRANCH( wxS( 
"#branch" ) );
 
   39    static wxString 
POWER( wxS( 
":power" ) );
 
   42    static wxRegEx internalDevParameter( wxS( 
"^@(\\w*[\\.\\w+]*)\\[(\\w*)\\]$" ), wxRE_ADVANCED );
 
   44    wxString vector( aVector );
 
   46    if( !internalDevParameter.Matches( vector ) )
 
   48        if( vector.EndsWith( BRANCH ) )
 
   50            aSignal = wxT( 
"I(" ) + vector.Left( vector.Length() - BRANCH.Length() ) + wxT( 
")" );
 
   53        else if( vector.EndsWith( 
POWER ) )
 
   55            aSignal = wxT( 
"P(" ) + vector.Left( vector.Length() - 
POWER.Length() ) + wxT( 
")" );
 
   60            aSignal = wxT( 
"V(" ) + vector + wxT( 
")" );
 
   66        wxString paramType = internalDevParameter.GetMatch( vector, 2 );
 
   68        if( paramType.Lower()[0] == 
'i' )
 
   72            aSignal      = paramType + wxT( 
"(" );
 
   73            aSignal += internalDevParameter.GetMatch( vector, 1 ).Upper() + wxT( 
")" );
 
 
   93            simCmd += wxString::Format( wxT( 
"%s\r\n" ), directive );
 
 
  102    wxString cmd = aCmd.Lower().Trim();
 
  104    if( cmd == wxT( 
".op" ) )                    
return ST_OP;
 
  105    else if( cmd.StartsWith( wxT( 
".ac" ) ) )    
return ST_AC;
 
  106    else if( cmd.StartsWith( wxT( 
".dc" ) ) )    
return ST_DC;
 
  107    else if( cmd.StartsWith( wxT( 
".tran" ) ) )  
return ST_TRAN;
 
  108    else if( cmd.StartsWith( wxT( 
".disto" ) ) ) 
return ST_DISTO;
 
  109    else if( cmd.StartsWith( wxT( 
".noise" ) ) ) 
return ST_NOISE;
 
  110    else if( cmd.StartsWith( wxT( 
".pz" ) ) )    
return ST_PZ;
 
  111    else if( cmd.StartsWith( wxT( 
".sens" ) ) )  
return ST_SENS;
 
  112    else if( cmd.StartsWith( wxT( 
".sp" ) ) )    
return ST_SP;
 
  113    else if( cmd.StartsWith( wxT( 
".tf" ) ) )    
return ST_TF;
 
  115    else if( cmd.StartsWith( wxT( 
"fft" ) ) || cmd.Contains( wxT( 
"\nfft" ) ) )
 
 
  125    if( !aCmd.Lower().StartsWith( 
".dc" ) )
 
  128    wxString          cmd = aCmd.Mid( 3 );
 
  129    wxStringTokenizer tokens( cmd, 
" \t", wxTOKEN_STRTOK );
 
  131    aSource1->
m_source = tokens.GetNextToken();
 
  136    if( tokens.HasMoreTokens() )
 
  138        aSource2->
m_source = tokens.GetNextToken();
 
 
  149                                          wxString* input, wxString* inputRef, wxString* output,
 
  152    if( !aCmd.Lower().StartsWith( wxS( 
".pz" ) ) )
 
  155    *transferFunction = 
"vol";
 
  159    wxStringTokenizer tokens( aCmd.Mid( 3 ), 
" \t", wxTOKEN_STRTOK );
 
  161    if( tokens.HasMoreTokens() )
 
  162        *input = tokens.GetNextToken();
 
  164    if( tokens.HasMoreTokens() )
 
  165        *inputRef = tokens.GetNextToken();
 
  167    if( tokens.HasMoreTokens() )
 
  168        *output = tokens.GetNextToken();
 
  170    if( tokens.HasMoreTokens() )
 
  171        *outputRef = tokens.GetNextToken();
 
  173    if( tokens.HasMoreTokens() )
 
  174        *transferFunction = tokens.GetNextToken();
 
  176    if( tokens.HasMoreTokens() )
 
  178        wxString token = tokens.GetNextToken().Lower();
 
  180        if( token == wxS( 
"pol" ) )
 
  182        else if( token == wxS( 
"zer" ) )
 
 
  190                                             wxString* aRef, wxString* aSource, wxString* aScale,
 
  194    if( !aCmd.Lower().StartsWith( wxS( 
".noise" ) ) )
 
  197    wxString cmd = aCmd.Mid( 6 );
 
  201    if( !cmd.Lower().StartsWith( wxS( 
"v(" ) ) )
 
  206    wxString function = cmd.Before( 
')' );
 
  207    wxString params = cmd.After( 
')' );
 
  209    wxStringTokenizer func_tokens( function, 
" ,\t", wxTOKEN_STRTOK );
 
  211    *aOutput = func_tokens.GetNextToken();
 
  212    *aRef = func_tokens.GetNextToken();
 
  214    wxStringTokenizer tokens( params, 
" \t", wxTOKEN_STRTOK );
 
  215    wxString          token = tokens.GetNextToken();
 
  217    if( !token.IsEmpty() )
 
  220        token = tokens.GetNextToken();
 
  223    if( token.Lower() == 
"dec" || token.Lower() == 
"oct" || token.Lower() == 
"lin" )
 
  226        token = tokens.GetNextToken();
 
  229    if( !token.IsEmpty() )
 
  232        token = tokens.GetNextToken();
 
  235    if( !token.IsEmpty() )
 
  238        token = tokens.GetNextToken();
 
  241    if( !token.IsEmpty() )
 
  244        token = tokens.GetNextToken();
 
  247    if( !token.IsEmpty() )
 
 
  257    if( aSimCommand.IsEmpty() )
 
  262    if( !aSimCommand.IsEmpty() )
 
 
void ReadDirectives(unsigned aNetlistOptions)
 
const std::vector< wxString > & GetDirectives()
 
virtual void WriteDirectives(const wxString &aSimCommand, unsigned aSimOptions, OUTPUTFORMATTER &candidate) const
 
bool ParsePZCommand(const wxString &aCmd, wxString *transferFunction, wxString *input, wxString *inputRef, wxString *output, wxString *outputRef, SPICE_PZ_ANALYSES *analyses)
 
static bool IsSimCommand(const wxString &aCmd)
Determine if a directive is a simulation command.
 
bool ParseDCCommand(const wxString &aCmd, SPICE_DC_PARAMS *aSource1, SPICE_DC_PARAMS *aSource2)
Parse a two-source .dc command directive into its symbols.
 
static SIM_TYPE CommandToSimType(const wxString &aCmd)
Return simulation type basing on a simulation command directive.
 
bool ParseNoiseCommand(const wxString &aCmd, wxString *aOutput, wxString *aRef, wxString *aSource, wxString *aScale, SPICE_VALUE *aPts, SPICE_VALUE *aFStart, SPICE_VALUE *aFStop, bool *aSaveAll)
 
void WriteDirectives(const wxString &aSimCommand, unsigned aSimOptions, OUTPUTFORMATTER &aFormatter) const override
 
wxString GetSchTextSimCommand()
Return simulation command directives placed in schematic sheets (if any).
 
SIM_TRACE_TYPE VectorToSignal(const std::string &aVector, wxString &aSignal) const
Return name of Spice dataset for a specific trace.
 
Helper class to recognize Spice formatted values.
 
SIM_TYPE
< Possible simulation types
 
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.