Extract CADSTAR PIN_TYPE and PIN::POSITION into a separate header
This commit is contained in:
parent
379e3b2fbb
commit
e2a4d58e8f
|
@ -0,0 +1,57 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2023 Roberto Fernandez Bautista <roberto.fer.bau@gmail.com>
|
||||
* Copyright (C) 2023 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or (at your
|
||||
* option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* file: cadstar_archive_objects.h
|
||||
* Contains common object definitions
|
||||
*/
|
||||
|
||||
#ifndef CADSTAR_ARCHIVE_OBJECTS_H_
|
||||
#define CADSTAR_ARCHIVE_OBJECTS_H_
|
||||
|
||||
|
||||
enum class CADSTAR_PIN_TYPE
|
||||
{
|
||||
UNCOMMITTED, ///< Uncommitted pin (default)
|
||||
INPUT, ///< Input pin
|
||||
OUTPUT_OR, ///< Output pin OR tieable
|
||||
OUTPUT_NOT_OR, ///< Output pin not OR tieable
|
||||
OUTPUT_NOT_NORM_OR, ///< Output pin not normally OR tieable
|
||||
POWER, ///< Power pin
|
||||
GROUND, ///< Ground pin
|
||||
TRISTATE_BIDIR, ///< Tristate bi-directional driver pin
|
||||
TRISTATE_INPUT, ///< Tristate input pin
|
||||
TRISTATE_DRIVER ///< Tristate output pin
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @brief Positioning of pin names can be in one of four quadrants
|
||||
*/
|
||||
enum class CADSTAR_PIN_POSITION
|
||||
{
|
||||
TOP_RIGHT = 0, ///< Default
|
||||
TOP_LEFT = 1,
|
||||
BOTTOM_LEFT = 2,
|
||||
BOTTOM_RIGHT = 3
|
||||
};
|
||||
|
||||
|
||||
#endif // CADSTAR_ARCHIVE_OBJECTS_H_
|
|
@ -1768,20 +1768,22 @@ void CADSTAR_ARCHIVE_PARSER::PART::DEFINITION::GATE::Parse( XNODE* aNode, PARSER
|
|||
}
|
||||
|
||||
|
||||
CADSTAR_ARCHIVE_PARSER::PART::PIN_TYPE CADSTAR_ARCHIVE_PARSER::PART::GetPinType( XNODE* aNode )
|
||||
CADSTAR_PIN_TYPE CADSTAR_ARCHIVE_PARSER::PART::GetPinType( XNODE* aNode )
|
||||
{
|
||||
wxASSERT( aNode->GetName() == wxT( "PINTYPE" ) );
|
||||
|
||||
wxString pinTypeStr = GetXmlAttributeIDString( aNode, 0 );
|
||||
|
||||
std::map<wxString, PIN_TYPE> pinTypeMap = { { wxT( "INPUT" ), PIN_TYPE::INPUT },
|
||||
{ wxT( "OUTPUT_OR" ), PIN_TYPE::OUTPUT_OR },
|
||||
{ wxT( "OUTPUT_NOT_OR" ), PIN_TYPE::OUTPUT_NOT_OR },
|
||||
{ wxT( "OUTPUT_NOT_NORM_OR" ), PIN_TYPE::OUTPUT_NOT_NORM_OR },
|
||||
{ wxT( "POWER" ), PIN_TYPE::POWER }, { wxT( "GROUND" ), PIN_TYPE::GROUND },
|
||||
{ wxT( "TRISTATE_BIDIR" ), PIN_TYPE::TRISTATE_BIDIR },
|
||||
{ wxT( "TRISTATE_INPUT" ), PIN_TYPE::TRISTATE_INPUT },
|
||||
{ wxT( "TRISTATE_DRIVER" ), PIN_TYPE::TRISTATE_DRIVER } };
|
||||
std::map<wxString, CADSTAR_PIN_TYPE> pinTypeMap = {
|
||||
{ wxT( "INPUT" ), CADSTAR_PIN_TYPE::INPUT },
|
||||
{ wxT( "OUTPUT_OR" ), CADSTAR_PIN_TYPE::OUTPUT_OR },
|
||||
{ wxT( "OUTPUT_NOT_OR" ), CADSTAR_PIN_TYPE::OUTPUT_NOT_OR },
|
||||
{ wxT( "OUTPUT_NOT_NORM_OR" ), CADSTAR_PIN_TYPE::OUTPUT_NOT_NORM_OR },
|
||||
{ wxT( "POWER" ), CADSTAR_PIN_TYPE::POWER },
|
||||
{ wxT( "GROUND" ), CADSTAR_PIN_TYPE::GROUND },
|
||||
{ wxT( "TRISTATE_BIDIR" ), CADSTAR_PIN_TYPE::TRISTATE_BIDIR },
|
||||
{ wxT( "TRISTATE_INPUT" ), CADSTAR_PIN_TYPE::TRISTATE_INPUT },
|
||||
{ wxT( "TRISTATE_DRIVER" ), CADSTAR_PIN_TYPE::TRISTATE_DRIVER } };
|
||||
|
||||
if( pinTypeMap.find( pinTypeStr ) == pinTypeMap.end() )
|
||||
THROW_UNKNOWN_PARAMETER_IO_ERROR( pinTypeStr, aNode->GetName() );
|
||||
|
@ -1829,7 +1831,7 @@ void CADSTAR_ARCHIVE_PARSER::PART::DEFINITION::PIN::Parse( XNODE* aNode, PARSER_
|
|||
}
|
||||
else if( cNodeName == wxT( "PINPOSITION" ) )
|
||||
{
|
||||
Position = (POSITION) GetXmlAttributeIDLong( cNode, 0 );
|
||||
Position = CADSTAR_PIN_POSITION( GetXmlAttributeIDLong( cNode, 0 ) );
|
||||
}
|
||||
else if( cNodeName == wxT( "PINIDENTIFIER" ) )
|
||||
{
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
#include <xnode.h>
|
||||
|
||||
#include <math/vector2d.h>
|
||||
#include <plugins/cadstar/cadstar_archive_objects.h>
|
||||
|
||||
// THROW_IO_ERROR definitions to ensure consistent wording is used in the error messages
|
||||
|
||||
|
@ -968,23 +969,7 @@ public:
|
|||
|
||||
struct PART : PARSER
|
||||
{
|
||||
enum class PIN_TYPE
|
||||
{
|
||||
UNCOMMITTED, ///< Uncommitted pin (default)
|
||||
INPUT, ///< Input pin
|
||||
OUTPUT_OR, ///< Output pin OR tieable
|
||||
OUTPUT_NOT_OR, ///< Output pin not OR tieable
|
||||
OUTPUT_NOT_NORM_OR, ///< Output pin not normally OR tieable
|
||||
POWER, ///< Power pin
|
||||
GROUND, ///< Ground pin
|
||||
TRISTATE_BIDIR, ///< Tristate bi-directional driver pin
|
||||
TRISTATE_INPUT, ///< Tristate input pin
|
||||
TRISTATE_DRIVER ///< Tristate output pin
|
||||
};
|
||||
|
||||
|
||||
static PIN_TYPE GetPinType( XNODE* aNode );
|
||||
|
||||
static CADSTAR_PIN_TYPE GetPinType( XNODE* aNode );
|
||||
|
||||
struct DEFINITION : PARSER ///< "PARTDEFINITION" node name
|
||||
{
|
||||
|
@ -1001,17 +986,6 @@ public:
|
|||
|
||||
struct PIN : PARSER ///< "PARTDEFINITIONPIN" node name
|
||||
{
|
||||
/**
|
||||
* @brief Positioning of pin names can be in one of four quadrants
|
||||
*/
|
||||
enum class POSITION
|
||||
{
|
||||
TOP_RIGHT = 0, ///< Default
|
||||
TOP_LEFT = 1,
|
||||
BOTTOM_LEFT = 2,
|
||||
BOTTOM_RIGHT = 3
|
||||
};
|
||||
|
||||
PART_DEFINITION_PIN_ID ID = UNDEFINED_VALUE;
|
||||
|
||||
wxString Identifier = wxEmptyString; ///< This should match a pad identifier
|
||||
|
@ -1043,14 +1017,17 @@ public:
|
|||
///< (subnode="PINSIGNAL")
|
||||
GATE_ID TerminalGate; ///< (subnode="PINTERM", param0)
|
||||
TERMINAL_ID TerminalPin; ///< (subnode="PINTERM", param1)
|
||||
PIN_TYPE Type = PIN_TYPE::UNCOMMITTED; ///< subnode="PINTYPE"
|
||||
|
||||
CADSTAR_PIN_TYPE Type = CADSTAR_PIN_TYPE::UNCOMMITTED; ///< subnode="PINTYPE"
|
||||
|
||||
long Load = UNDEFINED_VALUE; ///< The electrical current expected on
|
||||
///< the pin (It is unclear what the units
|
||||
///< are, but only accepted values are
|
||||
///< integers) subnode ="PINLOAD"
|
||||
POSITION Position =
|
||||
POSITION::TOP_RIGHT; ///< The pin names will use these positions when
|
||||
///< the symbol is added to a schematic design
|
||||
///
|
||||
CADSTAR_PIN_POSITION Position =
|
||||
CADSTAR_PIN_POSITION::TOP_RIGHT; ///< The pin names will use these positions
|
||||
///< when the symbol is added to a design
|
||||
///< subnode="PINPOSITION"
|
||||
|
||||
void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
|
||||
|
@ -1132,7 +1109,7 @@ public:
|
|||
{
|
||||
PART_PIN_ID ID;
|
||||
wxString Name = wxEmptyString;
|
||||
PIN_TYPE Type = PIN_TYPE::UNCOMMITTED;
|
||||
CADSTAR_PIN_TYPE Type = CADSTAR_PIN_TYPE::UNCOMMITTED;
|
||||
wxString Identifier = wxEmptyString;
|
||||
|
||||
void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
|
||||
|
|
|
@ -2491,20 +2491,20 @@ CADSTAR_SCH_ARCHIVE_LOADER::getPartDefinitionPin( const PART& aCadstarPart, cons
|
|||
}
|
||||
|
||||
|
||||
ELECTRICAL_PINTYPE CADSTAR_SCH_ARCHIVE_LOADER::getKiCadPinType( const PART::PIN_TYPE& aPinType )
|
||||
ELECTRICAL_PINTYPE CADSTAR_SCH_ARCHIVE_LOADER::getKiCadPinType( const CADSTAR_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;
|
||||
case CADSTAR_PIN_TYPE::UNCOMMITTED: return ELECTRICAL_PINTYPE::PT_PASSIVE;
|
||||
case CADSTAR_PIN_TYPE::INPUT: return ELECTRICAL_PINTYPE::PT_INPUT;
|
||||
case CADSTAR_PIN_TYPE::OUTPUT_OR: return ELECTRICAL_PINTYPE::PT_OPENCOLLECTOR;
|
||||
case CADSTAR_PIN_TYPE::OUTPUT_NOT_OR: return ELECTRICAL_PINTYPE::PT_OUTPUT;
|
||||
case CADSTAR_PIN_TYPE::OUTPUT_NOT_NORM_OR: return ELECTRICAL_PINTYPE::PT_OUTPUT;
|
||||
case CADSTAR_PIN_TYPE::POWER: return ELECTRICAL_PINTYPE::PT_POWER_IN;
|
||||
case CADSTAR_PIN_TYPE::GROUND: return ELECTRICAL_PINTYPE::PT_POWER_IN;
|
||||
case CADSTAR_PIN_TYPE::TRISTATE_BIDIR: return ELECTRICAL_PINTYPE::PT_BIDI;
|
||||
case CADSTAR_PIN_TYPE::TRISTATE_INPUT: return ELECTRICAL_PINTYPE::PT_INPUT;
|
||||
case CADSTAR_PIN_TYPE::TRISTATE_DRIVER: return ELECTRICAL_PINTYPE::PT_OUTPUT;
|
||||
}
|
||||
|
||||
return ELECTRICAL_PINTYPE::PT_UNSPECIFIED;
|
||||
|
|
|
@ -206,7 +206,7 @@ private:
|
|||
const TERMINAL_ID& aTerminalID );
|
||||
|
||||
//Helper Functions for obtaining individual elements as KiCad elements:
|
||||
ELECTRICAL_PINTYPE getKiCadPinType( const PART::PIN_TYPE& aPinType );
|
||||
ELECTRICAL_PINTYPE getKiCadPinType( const CADSTAR_PIN_TYPE& aPinType );
|
||||
|
||||
int getKiCadUnitNumberFromGate( const GATE_ID& aCadstarGateID );
|
||||
TEXT_SPIN_STYLE getSpinStyle( const long long& aCadstarOrientation, bool aMirror );
|
||||
|
|
Loading…
Reference in New Issue