Add scanning for coupled inductor declarations to SPICE directives.

Fixes https://gitlab.com/kicad/code/kicad/issues/13431
This commit is contained in:
Jeff Young 2023-01-13 19:10:09 +00:00
parent ea4c3a267b
commit 453f1f393e
1 changed files with 67 additions and 39 deletions

View File

@ -389,6 +389,8 @@ void NETLIST_EXPORTER_SPICE::ReadDirectives( unsigned aNetlistOptions )
{
wxString line = tokenizer.GetNextToken().Upper();
if( line.StartsWith( wxT( "." ) ) )
{
if( line.StartsWith( wxT( ".AC" ) )
|| line.StartsWith( wxT( ".CONTROL" ) )
|| line.StartsWith( wxT( ".CSPARAM" ) )
@ -431,6 +433,32 @@ void NETLIST_EXPORTER_SPICE::ReadDirectives( unsigned aNetlistOptions )
break;
}
}
else if( line.StartsWith( wxT( "K" ) ) )
{
// Check for mutual inductor declaration
wxStringTokenizer line_t( line, wxT( " \t" ), wxTOKEN_STRTOK );
// Coupling ID
if( !line_t.HasMoreTokens() || !line_t.GetNextToken().StartsWith( wxT( "K" ) ) )
continue;
// Inductor 1 ID
if( !line_t.HasMoreTokens() || !line_t.GetNextToken().StartsWith( wxT( "L" ) ) )
continue;
// Inductor 2 ID
if( !line_t.HasMoreTokens() || !line_t.GetNextToken().StartsWith( wxT( "L" ) ) )
continue;
// That's probably distinctive enough not to bother trying to parse the
// coupling value. If there's anything else, assume it's the value.
if( line_t.HasMoreTokens() )
{
foundDirective = true;
break;
}
}
}
if( foundDirective )
m_directives.emplace_back( text );