Add fixups for legacy syntax used during 7.0 development.

This commit is contained in:
Jeff Young 2022-12-06 15:29:32 +00:00
parent 39ad7c8205
commit 3836ec481f
2 changed files with 57 additions and 7 deletions

View File

@ -61,6 +61,7 @@
// TODO(JE) Debugging only // TODO(JE) Debugging only
#include <profile.h> #include <profile.h>
#include "sch_bus_entry.h" #include "sch_bus_entry.h"
#include "sim/sim_model_ideal.h"
SCH_SCREEN::SCH_SCREEN( EDA_ITEM* aParent ) : SCH_SCREEN::SCH_SCREEN( EDA_ITEM* aParent ) :
BASE_SCREEN( aParent, SCH_SCREEN_T ), BASE_SCREEN( aParent, SCH_SCREEN_T ),
@ -1950,6 +1951,53 @@ void SCH_SCREEN::migrateSimModel( SCH_SYMBOL& aSymbol )
} }
else else
{ {
// Auto convert some legacy fields used in the middle of 7.0 development...
if( SCH_FIELD* legacyDevice = aSymbol.FindField( wxT( "Sim_Type" ) ) )
{
legacyDevice->SetName( SIM_MODEL::TYPE_FIELD );
}
if( SCH_FIELD* legacyDevice = aSymbol.FindField( wxT( "Sim_Device" ) ) )
{
legacyDevice->SetName( SIM_MODEL::DEVICE_TYPE_FIELD );
}
if( SCH_FIELD* legacyPins = aSymbol.FindField( wxT( "Sim_Pins" ) ) )
{
// Migrate pins from array of indexes to name-value-pairs
wxArrayString pinIndexes;
wxString pins;
wxStringSplit( legacyPins->GetText(), pinIndexes, ' ' );
if( SIM_MODEL_IDEAL::InferSimParams( prefix, value ).length() )
{
if( pinIndexes[0] == wxT( "2" ) )
pins = "1=- 2=+";
else
pins = "1=+ 2=-";
}
else
{
for( unsigned ii = 0; ii < pinIndexes.size(); ++ii )
{
if( ii > 0 )
pins.Append( wxS( " " ) );
pins.Append( wxString::Format( wxT( "%u=%s" ), ii + 1, pinIndexes[ ii ] ) );
}
}
legacyPins->SetName( SIM_MODEL::PINS_FIELD );
legacyPins->SetText( pins );
}
if( SCH_FIELD* legacyPins = aSymbol.FindField( wxT( "Sim_Params" ) ) )
{
legacyPins->SetName( SIM_MODEL::PARAMS_FIELD );
}
return; return;
} }
@ -1979,12 +2027,12 @@ void SCH_SCREEN::migrateSimModel( SCH_SYMBOL& aSymbol )
{ {
wxString pins; wxString pins;
for( unsigned i = 0; i < aSymbol.GetLibPins().size(); ++i ) for( unsigned ii = 0; ii < aSymbol.GetLibPins().size(); ++ii )
{ {
if( i != 0 ) if( ii > 0 )
pins.Append( " " ); pins.Append( wxS( " " ) );
pins.Append( wxString::Format( "%u=%u", i + 1, i + 1 ) ); pins.Append( wxString::Format( wxT( "%u=%u" ), ii + 1, ii + 1 ) );
} }
SCH_FIELD pinsField( VECTOR2I( 0, 0 ), aSymbol.GetFieldCount(), &aSymbol, SCH_FIELD pinsField( VECTOR2I( 0, 0 ), aSymbol.GetFieldCount(), &aSymbol,

View File

@ -77,7 +77,9 @@ wxString SIM_MODEL_IDEAL::InferSimParams( const wxString& aPrefix, const wxStrin
{ {
wxString spiceModel; wxString spiceModel;
if( aPrefix == wxT( "R" ) || aPrefix == wxT( "L" ) || aPrefix == wxT( "C" ) ) if( aPrefix.StartsWith( wxT( "R" ) )
|| aPrefix.StartsWith( wxT( "L" ) )
|| aPrefix.StartsWith( wxT( "C" ) ) )
{ {
wxRegEx passiveVal( wxRegEx passiveVal(
wxT( "^([0-9\\. ]+)([fFpPnNuUmMkKgGtTμµ𝛍𝜇𝝁 ]|M(e|E)(g|G))?([fFhHΩΩ𝛀𝛺𝝮]|ohm)?([-1-9 ]*)$" ) ); wxT( "^([0-9\\. ]+)([fFpPnNuUmMkKgGtTμµ𝛍𝜇𝝁 ]|M(e|E)(g|G))?([fFhHΩΩ𝛀𝛺𝝮]|ohm)?([-1-9 ]*)$" ) );
@ -88,8 +90,8 @@ wxString SIM_MODEL_IDEAL::InferSimParams( const wxString& aPrefix, const wxStrin
wxString valueUnits( passiveVal.GetMatch( aValue, 2 ) ); wxString valueUnits( passiveVal.GetMatch( aValue, 2 ) );
wxString valueSuffix( passiveVal.GetMatch( aValue, 6 ) ); wxString valueSuffix( passiveVal.GetMatch( aValue, 6 ) );
if( valueUnits == "M" ) if( valueUnits == wxT( "M" ) )
valueUnits = "Meg"; valueUnits = wxT( "Meg" );
spiceModel = valuePrefix + valueUnits; spiceModel = valuePrefix + valueUnits;
} }