From 7931f315b13a65c8e4d74283a00f8208cc6bb465 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Sun, 26 Mar 2023 10:59:31 +0100 Subject: [PATCH] Manually cherry-pick some fixes back from master. Fixes https://gitlab.com/kicad/code/kicad/issues/14424 --- eeschema/sim/ngspice_circuit_model.cpp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/eeschema/sim/ngspice_circuit_model.cpp b/eeschema/sim/ngspice_circuit_model.cpp index 398f16859b..1fa84e2a5f 100644 --- a/eeschema/sim/ngspice_circuit_model.cpp +++ b/eeschema/sim/ngspice_circuit_model.cpp @@ -33,17 +33,24 @@ SIM_PLOT_TYPE NGSPICE_CIRCUIT_MODEL::VectorToSignal( const std::string& aVector, wxString& aSignal ) const { - using namespace std; - + static wxString BRANCH( wxS( "#branch" ) ); // See ngspice manual chapt. 31.1 "Accessing internal device parameters" - wxRegEx internalDevParameter( "^@(\\w*[\\.\\w+]*)\\[(\\w*)\\]$", wxRE_ADVANCED ); + static wxRegEx internalDevParameter( wxS( "^@(\\w*[\\.\\w+]*)\\[(\\w*)\\]$" ), wxRE_ADVANCED ); + wxString vector( aVector ); if( !internalDevParameter.Matches( vector ) ) { - // any text is a node name, which returns voltage - aSignal = wxT( "V(" ) + aVector + wxT( ")" ); - return SPT_VOLTAGE; + if( vector.EndsWith( BRANCH ) ) + { + aSignal = wxT( "I(" ) + vector.Left( vector.Length() - BRANCH.Length() ) + wxT( ")" ); + return SPT_CURRENT; + } + else + { + aSignal = wxT( "V(" ) + vector + wxT( ")" ); + return SPT_VOLTAGE; + } } else {