CADSTAR Schematic Archive Importer: Load pin types

Default to passive if undefined
This commit is contained in:
Roberto Fernandez Bautista 2021-02-02 15:37:10 +00:00 committed by Wayne Stambaugh
parent f530b12c31
commit 914ae001b5
2 changed files with 30 additions and 3 deletions

View File

@ -1083,6 +1083,7 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadSymDefIntoLibrary( const SYMDEF_ID& aSymdef
TERMINAL term = termPair.second; TERMINAL term = termPair.second;
wxString pinNum = wxString::Format( "%ld", term.ID ); wxString pinNum = wxString::Format( "%ld", term.ID );
wxString pinName = wxEmptyString; wxString pinName = wxEmptyString;
LIB_PIN* pin = new LIB_PIN( aPart );
if( aCadstarPart ) if( aCadstarPart )
{ {
@ -1100,16 +1101,20 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadSymDefIntoLibrary( const SYMDEF_ID& aSymdef
else else
pinNum = wxString::Format( "%ld", csPin.ID ); pinNum = wxString::Format( "%ld", csPin.ID );
} }
}
LIB_PIN* pin = new LIB_PIN( aPart ); pin->SetType( getKiCadPinType( csPin.Type ) );
}
else
{
// If no part is defined, we don't know the pin type. Assume passive pin
pin->SetType( ELECTRICAL_PINTYPE::PT_PASSIVE );
}
pin->SetPosition( getKiCadLibraryPoint( term.Position, symbol.Origin ) ); pin->SetPosition( getKiCadLibraryPoint( term.Position, symbol.Origin ) );
pin->SetLength( 0 ); //CADSTAR Pins are just a point (have no length) pin->SetLength( 0 ); //CADSTAR Pins are just a point (have no length)
pin->SetShape( GRAPHIC_PINSHAPE::LINE ); pin->SetShape( GRAPHIC_PINSHAPE::LINE );
pin->SetUnit( gateNumber ); pin->SetUnit( gateNumber );
pin->SetNumber( pinNum ); pin->SetNumber( pinNum );
pin->SetName( pinName ); pin->SetName( pinName );
int oDeg = (int) NormalizeAngle180( getAngleTenthDegree( term.OrientAngle ) ); int oDeg = (int) NormalizeAngle180( getAngleTenthDegree( term.OrientAngle ) );
@ -2094,6 +2099,25 @@ CADSTAR_SCH_ARCHIVE_LOADER::PART::DEFINITION::PIN CADSTAR_SCH_ARCHIVE_LOADER::ge
} }
ELECTRICAL_PINTYPE CADSTAR_SCH_ARCHIVE_LOADER::getKiCadPinType( const PART::PIN_TYPE& aPinType )
{
switch( aPinType )
{
case PART::PIN_TYPE::UNCOMMITTED: return ELECTRICAL_PINTYPE::PT_PASSIVE;
case PART::PIN_TYPE::INPUT: return ELECTRICAL_PINTYPE::PT_INPUT;
case PART::PIN_TYPE::OUTPUT_OR: return ELECTRICAL_PINTYPE::PT_OPENCOLLECTOR;
case PART::PIN_TYPE::OUTPUT_NOT_OR: return ELECTRICAL_PINTYPE::PT_OUTPUT;
case PART::PIN_TYPE::OUTPUT_NOT_NORM_OR: return ELECTRICAL_PINTYPE::PT_OUTPUT;
case PART::PIN_TYPE::POWER: return ELECTRICAL_PINTYPE::PT_POWER_IN;
case PART::PIN_TYPE::GROUND: return ELECTRICAL_PINTYPE::PT_POWER_IN;
case PART::PIN_TYPE::TRISTATE_BIDIR: return ELECTRICAL_PINTYPE::PT_BIDI;
case PART::PIN_TYPE::TRISTATE_INPUT: return ELECTRICAL_PINTYPE::PT_INPUT;
case PART::PIN_TYPE::TRISTATE_DRIVER: return ELECTRICAL_PINTYPE::PT_OUTPUT;
}
return ELECTRICAL_PINTYPE::PT_UNSPECIFIED;
}
int CADSTAR_SCH_ARCHIVE_LOADER::getKiCadUnitNumberFromGate( const GATE_ID& aCadstarGateID ) int CADSTAR_SCH_ARCHIVE_LOADER::getKiCadUnitNumberFromGate( const GATE_ID& aCadstarGateID )
{ {
if( aCadstarGateID.IsEmpty() ) if( aCadstarGateID.IsEmpty() )

View File

@ -30,6 +30,7 @@
#include <layers_id_colors_and_visibility.h> // SCH_LAYER_ID #include <layers_id_colors_and_visibility.h> // SCH_LAYER_ID
#include <plotter.h> // PLOT_DASH_TYPE #include <plotter.h> // PLOT_DASH_TYPE
#include <pin_type.h> // ELECTRICAL_PINTYPE
#include <sch_io_mgr.h> #include <sch_io_mgr.h>
#include <wx/filename.h> #include <wx/filename.h>
@ -189,6 +190,8 @@ private:
const PART& aCadstarPart, const GATE_ID& aGateID, const TERMINAL_ID& aTerminalID ); const PART& aCadstarPart, const GATE_ID& aGateID, const TERMINAL_ID& aTerminalID );
//Helper Functions for obtaining individual elements as KiCad elements: //Helper Functions for obtaining individual elements as KiCad elements:
ELECTRICAL_PINTYPE getKiCadPinType( const PART::PIN_TYPE& aPinType );
int getKiCadUnitNumberFromGate( const GATE_ID& aCadstarGateID ); int getKiCadUnitNumberFromGate( const GATE_ID& aCadstarGateID );
LABEL_SPIN_STYLE getSpinStyle( const long long& aCadstarOrientation, bool aMirror ); LABEL_SPIN_STYLE getSpinStyle( const long long& aCadstarOrientation, bool aMirror );
LABEL_SPIN_STYLE getSpinStyleDeciDeg( const double& aOrientationDeciDeg ); LABEL_SPIN_STYLE getSpinStyleDeciDeg( const double& aOrientationDeciDeg );