CADSTAR Schematic Archive Importer: Parse all elements

This commit is contained in:
Roberto Fernandez Bautista 2020-09-13 22:42:17 +01:00
parent 721cba32d5
commit 646a733556
7 changed files with 1372 additions and 65 deletions

View File

@ -63,16 +63,6 @@ void CADSTAR_ARCHIVE_PARSER::HEADER::Parse( XNODE* aNode )
if( nodeName == wxT( "FORMAT" ) )
{
Format.Parse( cNode );
if( Format.Type != wxT( "LAYOUT" ) )
if( Format.Type == wxT( "LIBRARY" ) )
THROW_IO_ERROR(
"The selected file is a CADSTAR Library file (as opposed to a Layout "
"file). CADSTAR libraries cannot yet be imported into KiCad." );
else
THROW_IO_ERROR(
"The selected file is an unknown CADSTAR format so cannot be "
"imported into KiCad." );
}
else if( nodeName == wxT( "JOBFILE" ) )
JobFile = GetXmlAttributeIDString( cNode, 0 );
@ -267,10 +257,9 @@ void CADSTAR_ARCHIVE_PARSER::ROUTECODE::Parse( XNODE* aNode )
{
wxASSERT( aNode->GetName() == wxT( "ROUTECODE" ) );
ID = GetXmlAttributeIDString( aNode, 0 );
Name = GetXmlAttributeIDString( aNode, 1 );
OptimalWidth = GetXmlAttributeIDLong( aNode, 2 );
ID = GetXmlAttributeIDString( aNode, 0 );
Name = GetXmlAttributeIDString( aNode, 1 );
OptimalWidth = GetXmlAttributeIDLong( aNode, 2, false );
XNODE* cNode = aNode->GetChildren();
@ -280,6 +269,8 @@ void CADSTAR_ARCHIVE_PARSER::ROUTECODE::Parse( XNODE* aNode )
if( cNodeName == wxT( "NECKWIDTH" ) )
NeckedWidth = GetXmlAttributeIDLong( cNode, 0 );
else if( cNodeName == wxT( "SROUTEWIDTH" ) )
OptimalWidth = GetXmlAttributeIDLong( cNode, 0 );
else if( cNodeName == wxT( "MINWIDTH" ) )
MinWidth = GetXmlAttributeIDLong( cNode, 0 );
else if( cNodeName == wxT( "MAXWIDTH" ) )
@ -691,38 +682,55 @@ CADSTAR_ARCHIVE_PARSER::READABILITY CADSTAR_ARCHIVE_PARSER::ParseReadability( XN
}
void CADSTAR_ARCHIVE_PARSER::ATTRIBUTE_LOCATION::ParseIdentifiers( XNODE* aNode )
{
TextCodeID = GetXmlAttributeIDString( aNode, 0 );
LayerID = GetXmlAttributeIDString( aNode, 1 );
}
bool CADSTAR_ARCHIVE_PARSER::ATTRIBUTE_LOCATION::ParseSubNode( XNODE* aChildNode )
{
wxString cNodeName = aChildNode->GetName();
if( cNodeName == wxT( "PT" ) )
Position.Parse( aChildNode );
else if( cNodeName == wxT( "ORIENT" ) )
OrientAngle = GetXmlAttributeIDLong( aChildNode, 0 );
else if( cNodeName == wxT( "MIRROR" ) )
Mirror = true;
else if( cNodeName == wxT( "FIX" ) )
Fixed = true;
else if( cNodeName == wxT( "ALIGN" ) )
Alignment = ParseAlignment( aChildNode );
else if( cNodeName == wxT( "JUSTIFICATION" ) )
Justification = ParseJustification( aChildNode );
else
return false;
return true;
}
void CADSTAR_ARCHIVE_PARSER::ATTRIBUTE_LOCATION::Parse( XNODE* aNode )
{
wxASSERT( aNode->GetName() == wxT( "ATTRLOC" ) );
TextCodeID = GetXmlAttributeIDString( aNode, 0 );
LayerID = GetXmlAttributeIDString( aNode, 1 );
ParseIdentifiers( aNode );
//Parse child nodes
XNODE* cNode = aNode->GetChildren();
if( !cNode )
THROW_MISSING_NODE_IO_ERROR( wxT( "PT" ), wxT( "ATTRLOC" ) );
for( ; cNode; cNode = cNode->GetNext() )
{
wxString cNodeName = cNode->GetName();
if( cNodeName == wxT( "PT" ) )
Position.Parse( cNode );
else if( cNodeName == wxT( "ORIENT" ) )
OrientAngle = GetXmlAttributeIDLong( cNode, 0 );
else if( cNodeName == wxT( "MIRROR" ) )
Mirror = true;
else if( cNodeName == wxT( "FIX" ) )
Fixed = true;
else if( cNodeName == wxT( "ALIGN" ) )
Alignment = ParseAlignment( cNode );
else if( cNodeName == wxT( "JUSTIFICATION" ) )
Justification = ParseJustification( cNode );
if( ParseSubNode( cNode ) )
continue;
else
THROW_UNKNOWN_NODE_IO_ERROR( cNodeName, wxT( "ATTRLOC" ) );
THROW_UNKNOWN_NODE_IO_ERROR( cNode->GetName(), wxT( "ATTRLOC" ) );
}
if( !Position.IsFullySpecified() )
THROW_MISSING_NODE_IO_ERROR( wxT( "PT" ), wxT( "ATTRLOC" ) );
}
@ -792,6 +800,8 @@ void CADSTAR_ARCHIVE_PARSER::ATTRNAME::Parse( XNODE* aNode )
AttributeOwner = ATTROWNER::PART_DEFINITION;
else if( attOwnerVal == wxT( "PIN" ) )
AttributeOwner = ATTROWNER::PIN;
else if( attOwnerVal == wxT( "SYMBOL" ) )
AttributeOwner = ATTROWNER::SYMBOL;
else if( attOwnerVal == wxT( "SYMDEF" ) )
AttributeOwner = ATTROWNER::SYMDEF;
else if( attOwnerVal == wxT( "TEMPLATE" ) )
@ -886,6 +896,21 @@ void CADSTAR_ARCHIVE_PARSER::TEXT_LOCATION::Parse( XNODE* aNode )
AttributeID = COMPONENT_NAME_2_ATTRID;
attributeIDisSet = true;
}
else if( attributeStr == wxT( "SYMBOL_NAME" ) )
{
AttributeID = SYMBOL_NAME_ATTRID;
attributeIDisSet = true;
}
else if( attributeStr == wxT( "LINK_ORIGIN" ) )
{
AttributeID = LINK_ORIGIN_ATTRID;
attributeIDisSet = true;
}
else if( attributeStr == wxT( "SIGNALNAME_ORIGIN" ) )
{
AttributeID = SIGNALNAME_ORIGIN_ATTRID;
attributeIDisSet = true;
}
else if( attributeStr == wxT( "ATTRREF" ) )
{
//We will initialise when we parse all child nodes
@ -896,21 +921,17 @@ void CADSTAR_ARCHIVE_PARSER::TEXT_LOCATION::Parse( XNODE* aNode )
THROW_UNKNOWN_PARAMETER_IO_ERROR( attributeStr, wxT( "TEXTLOC" ) );
}
TextCodeID = GetXmlAttributeIDString( aNode, 1 );
LayerID = GetXmlAttributeIDString( aNode, 2 );
ParseIdentifiers( aNode );
//Parse child nodes
XNODE* cNode = aNode->GetChildren();
if( !cNode )
THROW_MISSING_NODE_IO_ERROR( wxT( "PT" ), wxT( "TEXTLOC" ) );
for( ; cNode; cNode = cNode->GetNext() )
{
wxString cNodeName = cNode->GetName();
if( cNodeName == wxT( "PT" ) )
Position.Parse( cNode );
if( ParseSubNode( cNode ) )
continue;
else if( !attributeIDisSet && cNodeName == wxT( "ATTRREF" ) )
{
AttributeID = GetXmlAttributeIDString( cNode, 0 );
@ -929,6 +950,9 @@ void CADSTAR_ARCHIVE_PARSER::TEXT_LOCATION::Parse( XNODE* aNode )
else
THROW_UNKNOWN_NODE_IO_ERROR( cNodeName, wxT( "TEXTLOC" ) );
}
if( !Position.IsFullySpecified() )
THROW_MISSING_NODE_IO_ERROR( wxT( "PT" ), wxT( "TEXTLOC" ) );
}
@ -1096,6 +1120,8 @@ void CADSTAR_ARCHIVE_PARSER::GROUP::Parse( XNODE* aNode )
if( cNodeName == wxT( "FIX" ) )
Fixed = true;
else if( cNodeName == wxT( "TRANSFER" ) )
Transfer = true;
else if( cNodeName == wxT( "GROUPREF" ) )
GroupID = GetXmlAttributeIDString( cNode, 0 );
else if( cNodeName == wxT( "REUSEBLOCKREF" ) )
@ -1824,25 +1850,34 @@ bool CADSTAR_ARCHIVE_PARSER::IsValidAttribute( wxXmlAttribute* aAttribute )
}
wxString CADSTAR_ARCHIVE_PARSER::GetXmlAttributeIDString( XNODE* aNode, unsigned int aID )
wxString CADSTAR_ARCHIVE_PARSER::GetXmlAttributeIDString(
XNODE* aNode, unsigned int aID, bool aIsRequired )
{
wxString attrName, retVal;
attrName = "attr";
attrName << aID;
if( !aNode->GetAttribute( attrName, &retVal ) )
THROW_MISSING_PARAMETER_IO_ERROR( std::to_string( aID ), aNode->GetName() );
if( aIsRequired )
THROW_MISSING_PARAMETER_IO_ERROR( std::to_string( aID ), aNode->GetName() );
else
return wxEmptyString;
return retVal;
}
long CADSTAR_ARCHIVE_PARSER::GetXmlAttributeIDLong( XNODE* aNode, unsigned int aID )
long CADSTAR_ARCHIVE_PARSER::GetXmlAttributeIDLong(
XNODE* aNode, unsigned int aID, bool aIsRequired )
{
long retVal;
bool success = GetXmlAttributeIDString( aNode, aID, aIsRequired ).ToLong( &retVal );
if( !GetXmlAttributeIDString( aNode, aID ).ToLong( &retVal ) )
THROW_PARSING_IO_ERROR( std::to_string( aID ), aNode->GetName() );
if( !success )
if( aIsRequired )
THROW_PARSING_IO_ERROR( std::to_string( aID ), aNode->GetName() );
else
return UNDEFINED_VALUE;
return retVal;
}

View File

@ -66,6 +66,13 @@
* placement drawings.
*/
#define COMPONENT_NAME_2_ATTRID ( ATTRIBUTE_ID ) wxT( "__COMPONENT_NAME_2__" )
/**
* Symbol Name attribute ID - used for placement of designators on the schematic
*/
#define SYMBOL_NAME_ATTRID ( ATTRIBUTE_ID ) wxT( "__SYMBOL_NAME__" )
#define LINK_ORIGIN_ATTRID ( ATTRIBUTE_ID ) wxT( "__LINK_ORIGIN__" )
#define SIGNALNAME_ORIGIN_ATTRID ( ATTRIBUTE_ID ) wxT( "__SIGNALNAME_ORIGIN__" )
#define PART_NAME_ATTRID ( ATTRIBUTE_ID ) wxT( "__PART_NAME__" )
@ -516,6 +523,7 @@ public:
PART, ///< Only library Attributes
PART_DEFINITION, ///< Only library Attributes
PIN,
SYMBOL,
SYMDEF,
TEMPLATE,
TESTPOINT
@ -537,6 +545,7 @@ public:
///< with the design itself (i.e. not inherited from the library)
};
struct ATTRIBUTE_LOCATION
{
TEXTCODE_ID TextCodeID;
@ -553,7 +562,9 @@ public:
///< Note that this is different from BOTTOM_LEFT (which is bottom
///< left of the whole text block)
void Parse( XNODE* aNode );
void ParseIdentifiers( XNODE* aNode );
bool ParseSubNode( XNODE* aChildNode );
virtual void Parse( XNODE* aNode );
};
@ -630,7 +641,7 @@ public:
}
ATTRIBUTE_ID AttributeID;
void Parse( XNODE* aNode );
void Parse( XNODE* aNode ) override;
};
@ -721,6 +732,7 @@ public:
GROUP_ID ID;
wxString Name;
bool Fixed = false;
bool Transfer = false; ///< If true, the group is transferred to PCB
GROUP_ID GroupID = wxEmptyString; ///< If not empty, this GROUP
///< is part of another GROUP
REUSEBLOCKREF ReuseBlockRef;
@ -1117,19 +1129,21 @@ public:
* @brief
* @param aNode
* @param aID
* @param aIsRequired Prevents exception throwing if false.
* @return returns the value (wxString) of attribute "attrX" in aNode where 'X' is aID
* @throws IO_ERROR if attribute does not exist
*/
static wxString GetXmlAttributeIDString( XNODE* aNode, unsigned int aID );
static wxString GetXmlAttributeIDString( XNODE* aNode, unsigned int aID, bool aIsRequired = true );
/**
* @brief
* @param aNode
* @param aID
* @param aIsRequired Prevents exception throwing if false.
* @return returns the value (long) of attribute "attrX" in aNode where 'X' is aID
* @throws IO_ERROR if attribute does not exist
*/
static long GetXmlAttributeIDLong( XNODE* aNode, unsigned int aID );
static long GetXmlAttributeIDLong( XNODE* aNode, unsigned int aID, bool aIsRequired = true );
/**
* @brief

View File

@ -28,13 +28,13 @@
void CADSTAR_SCH_ARCHIVE_PARSER::Parse()
{
XNODE* fileRootNode = LoadArchiveFile( Filename, wxT( "CADSTARSCH" ) );
XNODE* fileRootNode = LoadArchiveFile( Filename, wxT( "CADSTARSCM" ) );
XNODE* cNode = fileRootNode->GetChildren();
if( !cNode )
THROW_MISSING_NODE_IO_ERROR( wxT( "HEADER" ), wxT( "CADSTARSCH" ) );
/*
THROW_MISSING_NODE_IO_ERROR( wxT( "HEADER" ), wxT( "CADSTARSCM" ) );
for( ; cNode; cNode = cNode->GetNext() )
{
if( cNode->GetName() == wxT( "HEADER" ) )
@ -44,7 +44,7 @@ void CADSTAR_SCH_ARCHIVE_PARSER::Parse()
switch( Header.Resolution )
{
case RESOLUTION::HUNDREDTH_MICRON:
KiCadUnitMultiplier = 10;
KiCadUnitMultiplier = 100;
break;
default:
@ -64,8 +64,10 @@ void CADSTAR_SCH_ARCHIVE_PARSER::Parse()
}
else if( cNode->GetName() == wxT( "PARTS" ) )
Parts.Parse( cNode );
else if( cNode->GetName() == wxT( "LAYOUT" ) )
Layout.Parse( cNode );
else if( cNode->GetName() == wxT( "SHEETS" ) )
Sheets.Parse( cNode );
else if( cNode->GetName() == wxT( "SCHEMATIC" ) )
Schematic.Parse( cNode );
else if( cNode->GetName() == wxT( "DISPLAY" ) )
{
// No design information here (no need to parse)
@ -77,7 +79,900 @@ void CADSTAR_SCH_ARCHIVE_PARSER::Parse()
THROW_UNKNOWN_NODE_IO_ERROR( cNode->GetName(), wxT( "[root]" ) );
}
}
*/
delete fileRootNode;
}
CADSTAR_SCH_ARCHIVE_PARSER::TERMINAL_SHAPE_TYPE CADSTAR_SCH_ARCHIVE_PARSER::ParseTermShapeType(
const wxString& aShapeStr )
{
if( aShapeStr == wxT( "ANNULUS" ) )
return TERMINAL_SHAPE_TYPE::ANNULUS;
else if( aShapeStr == wxT( "BOX" ) )
return TERMINAL_SHAPE_TYPE::BOX;
else if( aShapeStr == wxT( "BULLET" ) )
return TERMINAL_SHAPE_TYPE::BULLET;
else if( aShapeStr == wxT( "ROUND" ) )
return TERMINAL_SHAPE_TYPE::CIRCLE;
else if( aShapeStr == wxT( "CROSS" ) )
return TERMINAL_SHAPE_TYPE::CROSS;
else if( aShapeStr == wxT( "DIAMOND" ) )
return TERMINAL_SHAPE_TYPE::DIAMOND;
else if( aShapeStr == wxT( "FINGER" ) )
return TERMINAL_SHAPE_TYPE::FINGER;
else if( aShapeStr == wxT( "OCTAGON" ) )
return TERMINAL_SHAPE_TYPE::OCTAGON;
else if( aShapeStr == wxT( "PLUS" ) )
return TERMINAL_SHAPE_TYPE::PLUS;
else if( aShapeStr == wxT( "POINTER" ) )
return TERMINAL_SHAPE_TYPE::POINTER;
else if( aShapeStr == wxT( "RECTANGLE" ) )
return TERMINAL_SHAPE_TYPE::RECTANGLE;
else if( aShapeStr == wxT( "ROUNDED" ) )
return TERMINAL_SHAPE_TYPE::ROUNDED_RECT;
else if( aShapeStr == wxT( "SQUARE" ) )
return TERMINAL_SHAPE_TYPE::SQUARE;
else if( aShapeStr == wxT( "STAR" ) )
return TERMINAL_SHAPE_TYPE::STAR;
else if( aShapeStr == wxT( "TRIANGLE" ) )
return TERMINAL_SHAPE_TYPE::TRIANGLE;
else
return TERMINAL_SHAPE_TYPE::UNDEFINED;
}
bool CADSTAR_SCH_ARCHIVE_PARSER::TERMINAL_SHAPE::IsTermShape( XNODE* aNode )
{
return ParseTermShapeType( aNode->GetName() ) != TERMINAL_SHAPE_TYPE::UNDEFINED;
}
void CADSTAR_SCH_ARCHIVE_PARSER::TERMINAL_SHAPE::Parse( XNODE* aNode )
{
wxCHECK( IsTermShape( aNode ), );
ShapeType = ParseTermShapeType( aNode->GetName() );
Size = GetXmlAttributeIDLong( aNode, 0 );
switch( ShapeType )
{
case TERMINAL_SHAPE_TYPE::ANNULUS:
case TERMINAL_SHAPE_TYPE::BOX:
case TERMINAL_SHAPE_TYPE::CROSS:
case TERMINAL_SHAPE_TYPE::PLUS:
case TERMINAL_SHAPE_TYPE::STAR:
InternalFeature = GetXmlAttributeIDLong( aNode, 1 );
break;
case TERMINAL_SHAPE_TYPE::ROUNDED_RECT:
InternalFeature = GetXmlAttributeIDLong( aNode, 3 );
//Fall through
case TERMINAL_SHAPE_TYPE::BULLET:
case TERMINAL_SHAPE_TYPE::FINGER:
case TERMINAL_SHAPE_TYPE::POINTER:
case TERMINAL_SHAPE_TYPE::RECTANGLE:
case TERMINAL_SHAPE_TYPE::TRIANGLE:
RightLength = GetXmlAttributeIDLong( aNode, 2 );
LeftLength = GetXmlAttributeIDLong( aNode, 1 );
break;
}
if( aNode->GetChildren() )
{
if( aNode->GetChildren()->GetName() == wxT( "ORIENT" ) )
{
OrientAngle = GetXmlAttributeIDLong( aNode->GetChildren(), 0 );
}
else
THROW_UNKNOWN_NODE_IO_ERROR( aNode->GetChildren()->GetName(), aNode->GetName() );
CheckNoNextNodes( aNode->GetChildren() );
}
}
void CADSTAR_SCH_ARCHIVE_PARSER::TERMINALCODE::Parse( XNODE* aNode )
{
wxCHECK( aNode->GetName() == wxT( "TERMINALCODE" ), );
ID = GetXmlAttributeIDString( aNode, 0 );
Name = GetXmlAttributeIDString( aNode, 1 );
XNODE* cNode = aNode->GetChildren();
wxString location = wxString::Format( "TERMINALCODE -> %s", Name );
for( ; cNode; cNode = cNode->GetNext() )
{
wxString cNodeName = cNode->GetName();
if( TERMINAL_SHAPE::IsTermShape( cNode ) )
Shape.Parse( cNode );
else if( cNodeName == wxT( "FILLED" ) )
Filled = true;
else
THROW_UNKNOWN_NODE_IO_ERROR( cNodeName, location );
}
}
void CADSTAR_SCH_ARCHIVE_PARSER::CODEDEFS_SCM::Parse( XNODE* aNode )
{
wxCHECK( aNode->GetName() == wxT( "CODEDEFS" ), );
XNODE* cNode = aNode->GetChildren();
for( ; cNode; cNode = cNode->GetNext() )
{
wxString nodeName = cNode->GetName();
if( ParseSubNode( cNode ) ) // in CADSTAR_ARCHIVE_PARSER::CODEDEFS
{
continue;
}
else if( nodeName == wxT( "TERMINALCODE" ) )
{
TERMINALCODE termcode;
termcode.Parse( cNode );
TerminalCodes.insert( std::make_pair( termcode.ID, termcode ) );
}
else
{
THROW_UNKNOWN_NODE_IO_ERROR( nodeName, aNode->GetName() );
}
}
}
void CADSTAR_SCH_ARCHIVE_PARSER::ASSIGNMENTS_SCM::Parse( XNODE* aNode )
{
wxCHECK( aNode->GetName() == wxT( "ASSIGNMENTS" ), );
XNODE* cNode = aNode->GetChildren();
bool settingsParsed = false;
for( ; cNode; cNode = cNode->GetNext() )
{
if( cNode->GetName() == wxT( "CODEDEFS" ) )
Codedefs.Parse( cNode );
else if( cNode->GetName() == wxT( "SETTINGS" ) )
{
settingsParsed = true;
Settings.Parse( cNode );
}
else if( cNode->GetName() == wxT( "GRIDS" ) )
Grids.Parse( cNode );
else if( cNode->GetName() == wxT( "NETCLASSEDITATTRIBSETTINGS" ) )
NetclassEditAttributeSettings = true;
else if( cNode->GetName() == wxT( "SPCCLASSEDITATTRIBSETTINGS" ) )
SpacingclassEditAttributeSettings = true;
else
THROW_UNKNOWN_NODE_IO_ERROR( cNode->GetName(), aNode->GetName() );
}
if( !settingsParsed )
THROW_MISSING_NODE_IO_ERROR( wxT( "SETTINGS" ), wxT( "ASSIGNMENTS" ) );
}
void CADSTAR_SCH_ARCHIVE_PARSER::TERMINAL::Parse( XNODE* aNode )
{
wxCHECK( aNode->GetName() == wxT( "TERMINAL" ), );
ID = GetXmlAttributeIDLong( aNode, 0 );
TerminalCodeID = GetXmlAttributeIDString( aNode, 1 );
XNODE* cNode = aNode->GetChildren();
wxString location = wxString::Format( "TERMINAL %d", ID );
if( !cNode )
THROW_MISSING_NODE_IO_ERROR( wxT( "PT" ), location );
for( ; cNode; cNode = cNode->GetNext() )
{
wxString cNodeName = cNode->GetName();
if( cNodeName == wxT( "ORIENT" ) )
OrientAngle = GetXmlAttributeIDLong( cNode, 0 );
else if( cNodeName == wxT( "PT" ) )
Position.Parse( cNode );
else
THROW_UNKNOWN_NODE_IO_ERROR( cNodeName, location );
}
}
void CADSTAR_SCH_ARCHIVE_PARSER::PIN_NUM_LABEL_LOC::Parse( XNODE* aNode )
{
wxCHECK( aNode->GetName() == wxT( "PINLABELLOC" )
|| aNode->GetName() == wxT( "PINNUMNAMELOC" ), );
TerminalID = GetXmlAttributeIDLong( aNode, 0 );
TextCodeID = GetXmlAttributeIDString( aNode, 1 );
//Parse child nodes
XNODE* cNode = aNode->GetChildren();
for( ; cNode; cNode = cNode->GetNext() )
{
if( ParseSubNode( cNode ) )
continue;
else
THROW_UNKNOWN_NODE_IO_ERROR( cNode->GetName(), aNode->GetName() );
}
if( !Position.IsFullySpecified() )
THROW_MISSING_NODE_IO_ERROR( wxT( "PT" ), aNode->GetName() );
}
void CADSTAR_SCH_ARCHIVE_PARSER::SYMDEF_SCM::Parse( XNODE* aNode )
{
wxCHECK( aNode->GetName() == wxT( "SYMDEF" ), );
ParseIdentifiers( aNode );
XNODE* cNode = aNode->GetChildren();
for( ; cNode; cNode = cNode->GetNext() )
{
wxString cNodeName = cNode->GetName();
if( ParseSubNode( cNode ) )
continue;
else if( cNodeName == wxT( "TERMINAL" ) )
{
TERMINAL term;
term.Parse( cNode );
Terminals.insert( std::make_pair( term.ID, term ) );
}
else if( cNodeName == wxT( "PINLABELLOC" ) )
{
PIN_NUM_LABEL_LOC loc;
loc.Parse( cNode );
PinLabelLocations.insert( std::make_pair( loc.TerminalID, loc ) );
}
else if( cNodeName == wxT( "PINNUMNAMELOC" ) )
{
PIN_NUM_LABEL_LOC loc;
loc.Parse( cNode );
PinNumberLocations.insert( std::make_pair( loc.TerminalID, loc ) );
}
else
{
THROW_UNKNOWN_NODE_IO_ERROR( cNodeName, aNode->GetName() );
}
}
if( !Stub && !Origin.IsFullySpecified() )
THROW_MISSING_PARAMETER_IO_ERROR( wxT( "PT" ), aNode->GetName() );
}
void CADSTAR_SCH_ARCHIVE_PARSER::LIBRARY_SCM::Parse( XNODE* aNode )
{
wxCHECK( aNode->GetName() == wxT( "LIBRARY" ), );
XNODE* cNode = aNode->GetChildren();
for( ; cNode; cNode = cNode->GetNext() )
{
wxString cNodeName = cNode->GetName();
if( cNodeName == wxT( "SYMDEF" ) )
{
SYMDEF_SCM symdef;
symdef.Parse( cNode );
SymbolDefinitions.insert( std::make_pair( symdef.ID, symdef ) );
}
else
{
THROW_UNKNOWN_NODE_IO_ERROR( cNodeName, aNode->GetName() );
}
}
}
void CADSTAR_SCH_ARCHIVE_PARSER::SHEETS::Parse( XNODE* aNode )
{
wxCHECK( aNode->GetName() == wxT( "SHEETS" ), );
XNODE* cNode = aNode->GetChildren();
for( ; cNode; cNode = cNode->GetNext() )
{
if( cNode->GetName() == wxT( "SHEET" ) )
{
LAYER_ID id = GetXmlAttributeIDString( cNode, 0 );
SHEET_NAME name = GetXmlAttributeIDString( cNode, 1 );
Sheets.insert( std::make_pair( id, name ) );
}
else
{
THROW_UNKNOWN_NODE_IO_ERROR( cNode->GetName(), aNode->GetName() );
}
}
}
void CADSTAR_SCH_ARCHIVE_PARSER::COMP::Parse( XNODE* aNode )
{
wxCHECK( aNode->GetName() == wxT( "COMP" ), );
Designator = GetXmlAttributeIDString( aNode, 0 );
XNODE* cNode = aNode->GetChildren();
for( ; cNode; cNode = cNode->GetNext() )
{
if( cNode->GetName() == wxT( "READONLY" ) )
ReadOnly = true;
else if( cNode->GetName() == wxT( "ATTRLOC" ) )
{
AttrLoc.Parse( cNode );
HasLocation = true;
}
else
THROW_UNKNOWN_NODE_IO_ERROR( cNode->GetName(), wxT( "ATTR" ) );
}
}
void CADSTAR_SCH_ARCHIVE_PARSER::PARTREF::Parse( XNODE* aNode )
{
wxCHECK( aNode->GetName() == wxT( "PARTREF" ), );
RefID = GetXmlAttributeIDString( aNode, 0 );
XNODE* cNode = aNode->GetChildren();
for( ; cNode; cNode = cNode->GetNext() )
{
if( cNode->GetName() == wxT( "READONLY" ) )
ReadOnly = true;
else if( cNode->GetName() == wxT( "ATTRLOC" ) )
{
AttrLoc.Parse( cNode );
HasLocation = true;
}
else
THROW_UNKNOWN_NODE_IO_ERROR( cNode->GetName(), wxT( "ATTR" ) );
}
}
void CADSTAR_SCH_ARCHIVE_PARSER::SYMPINNAME_LABEL::Parse( XNODE* aNode )
{
wxCHECK( aNode->GetName() == wxT( "SYMPINNAME" ) || aNode->GetName() == wxT( "SYMPINLABEL" ), );
TerminalID = GetXmlAttributeIDLong( aNode, 0 );
NameOrLabel = GetXmlAttributeIDString( aNode, 1 );
XNODE* cNode = aNode->GetChildren();
for( ; cNode; cNode = cNode->GetNext() )
{
if( cNode->GetName() == wxT( "ATTRLOC" ) )
{
AttrLoc.Parse( cNode );
HasLocation = true;
}
else
THROW_UNKNOWN_NODE_IO_ERROR( cNode->GetName(), wxT( "ATTR" ) );
}
}
void CADSTAR_SCH_ARCHIVE_PARSER::SYMBOLVARIANT::Parse( XNODE* aNode )
{
wxCHECK( aNode->GetName() == wxT( "SYMBOLVARIANT" ), );
XNODE* cNode = aNode->GetChildren();
for( ; cNode; cNode = cNode->GetNext() )
{
wxString cNodeName = cNode->GetName();
if( cNodeName == wxT( "SIGNALREF" ) )
{
Type = TYPE::SIGNALREF;
CheckNoNextNodes( cNode );
}
else if( cNodeName == wxT( "GLOBALSIGNAL" ) )
{
Type = TYPE::GLOBALSIGNAL;
Reference = GetXmlAttributeIDString( cNode, 0 );
}
else
THROW_UNKNOWN_NODE_IO_ERROR( cNodeName, aNode->GetName() );
}
}
void CADSTAR_SCH_ARCHIVE_PARSER::SIGNALREFERENCELINK::Parse( XNODE* aNode )
{
wxCHECK( aNode->GetName() == wxT( "SIGNALREFERENCELINK" ), );
TextCodeID = GetXmlAttributeIDString( aNode, 0 );
LayerID = GetXmlAttributeIDString( aNode, 2 );
//Parse child nodes
XNODE* cNode = aNode->GetChildren();
for( ; cNode; cNode = cNode->GetNext() )
{
if( ParseSubNode( cNode ) )
continue;
else if( cNode->GetName() == wxT( "SIGREFTEXT" ) )
Text = GetXmlAttributeIDString( aNode, 0 );
else
THROW_UNKNOWN_NODE_IO_ERROR( cNode->GetName(), aNode->GetName() );
}
if( !Position.IsFullySpecified() )
THROW_MISSING_NODE_IO_ERROR( wxT( "PT" ), aNode->GetName() );
}
void CADSTAR_SCH_ARCHIVE_PARSER::SYMBOL::Parse( XNODE* aNode )
{
wxCHECK( aNode->GetName() == wxT( "SYMBOL" ), );
ID = GetXmlAttributeIDString( aNode, 0 );
SymdefID = GetXmlAttributeIDString( aNode, 1 );
LayerID = GetXmlAttributeIDString( aNode, 2 );
XNODE* cNode = aNode->GetChildren();
bool originParsed = false;
wxString location = wxString::Format( "SYMBOL -> %s", ID );
for( ; cNode; cNode = cNode->GetNext() )
{
wxString cNodeName = cNode->GetName();
if( !originParsed && cNodeName == wxT( "PT" ) )
{
Origin.Parse( cNode );
originParsed = true;
}
else if( cNodeName == wxT( "COMP" ) )
{
ComponentRef.Parse( cNode );
IsComponent = true;
}
else if( cNodeName == wxT( "PARTREF" ) )
{
PartRef.Parse( cNode );
HasPartRef = true;
}
else if( cNodeName == wxT( "PARTNAMENOTVISIBLE" ) )
PartNameVisible = false;
else if( cNodeName == wxT( "VSYMMASTER" ) )
{
VariantParentSymbolID = GetXmlAttributeIDString( aNode, 0 );
VariantID = GetXmlAttributeIDString( aNode, 1 );
}
else if( cNodeName == wxT( "GROUPREF" ) )
GroupID = GetXmlAttributeIDString( cNode, 0 );
else if( cNodeName == wxT( "REUSEBLOCKREF" ) )
ReuseBlockRef.Parse( cNode );
else if( cNodeName == wxT( "SIGNALREFERENCELINK" ) )
SigRefLink.Parse( cNode );
else if( cNodeName == wxT( "ORIENT" ) )
{
OrientAngle = GetXmlAttributeIDLong( cNode, 0 );
}
else if( cNodeName == wxT( "MIRROR" ) )
Mirror = true;
else if( cNodeName == wxT( "FIX" ) )
Fixed = true;
else if( cNodeName == wxT( "READABILITY" ) )
{
Readability = ParseReadability( cNode );
}
else if( cNodeName == wxT( "GATE" ) )
GateID = GetXmlAttributeIDString( cNode, 0 );
else if( cNodeName == wxT( "SYMBOLVARIANT" ) )
{
IsSymbolVariant = true;
SymbolVariant.Parse( cNode );
}
else if( cNodeName == wxT( "SYMPINLABEL" ) )
{
SYMPINNAME_LABEL sympinname;
sympinname.Parse( cNode );
PinLabels.insert( std::make_pair( sympinname.TerminalID, sympinname ) );
}
else if( cNodeName == wxT( "SYMPINNAME" ) )
{
SYMPINNAME_LABEL sympinname;
sympinname.Parse( cNode );
PinNames.insert( std::make_pair( sympinname.TerminalID, sympinname ) );
}
else if( cNodeName == wxT( "ATTR" ) )
{
ATTRIBUTE_VALUE attrVal;
attrVal.Parse( cNode );
AttributeValues.insert( std::make_pair( attrVal.AttributeID, attrVal ) );
}
else
{
THROW_UNKNOWN_NODE_IO_ERROR( cNodeName, location );
}
}
if( !originParsed )
THROW_MISSING_PARAMETER_IO_ERROR( wxT( "PT" ), aNode->GetName() );
}
void CADSTAR_SCH_ARCHIVE_PARSER::SIGLOC::Parse( XNODE* aNode )
{
wxCHECK( aNode->GetName() == wxT( "SIGLOC" ), );
TextCodeID = GetXmlAttributeIDString( aNode, 0 );
//Parse child nodes
XNODE* cNode = aNode->GetChildren();
for( ; cNode; cNode = cNode->GetNext() )
{
if( ParseSubNode( cNode ) )
continue;
else
THROW_UNKNOWN_NODE_IO_ERROR( cNode->GetName(), aNode->GetName() );
}
if( !Position.IsFullySpecified() )
THROW_MISSING_NODE_IO_ERROR( wxT( "PT" ), aNode->GetName() );
}
void CADSTAR_SCH_ARCHIVE_PARSER::BUS::Parse( XNODE* aNode )
{
wxCHECK( aNode->GetName() == wxT( "BUS" ), );
ID = GetXmlAttributeIDString( aNode, 0 );
LineCodeID = GetXmlAttributeIDString( aNode, 1 );
LayerID = GetXmlAttributeIDString( aNode, 2 );
XNODE* cNode = aNode->GetChildren();
for( ; cNode; cNode = cNode->GetNext() )
{
wxString cNodeName = cNode->GetName();
if( SHAPE::IsShape( cNode ) )
{
Shape.Parse( cNode );
}
else if( cNodeName == wxT( "BUSNAME" ) )
{
Name = GetXmlAttributeIDString( cNode, 0 );
XNODE* subNode = cNode->GetChildren();
if( subNode )
{
if(subNode->GetName() == wxT("SIGLOC"))
{
BusLabel.Parse( subNode );
HasBusLabel = true;
}
else
THROW_UNKNOWN_NODE_IO_ERROR( subNode->GetName(), cNode->GetName() );
}
}
else
THROW_UNKNOWN_NODE_IO_ERROR( cNodeName, aNode->GetName() );
}
}
void CADSTAR_SCH_ARCHIVE_PARSER::BLOCK::Parse( XNODE* aNode )
{
wxCHECK( aNode->GetName() == wxT( "BLOCK" ), );
ID = GetXmlAttributeIDString( aNode, 0 );
LayerID = GetXmlAttributeIDString( aNode, 2 );
XNODE* cNode = aNode->GetChildren();
for( ; cNode; cNode = cNode->GetNext() )
{
wxString cNodeName = cNode->GetName();
if( cNodeName == wxT( "CLONE" ) )
Type = TYPE::CLONE;
else if( cNodeName == wxT( "PARENT" ) )
{
Type = TYPE::PARENT;
AssocLayerID = GetXmlAttributeIDString( cNode, 0 );
}
else if( cNodeName == wxT( "CHILD" ) )
{
Type = TYPE::CHILD;
AssocLayerID = GetXmlAttributeIDString( cNode, 0 );
}
else if( cNodeName == wxT( "BLOCKNAME" ) )
{
Name = GetXmlAttributeIDString( cNode, 0 );
XNODE* subNode = cNode->GetChildren();
if( subNode )
{
if( subNode->GetName() == wxT( "ATTRLOC" ) )
{
BlockLabel.Parse( subNode );
HasBlockLabel = true;
}
else
THROW_UNKNOWN_NODE_IO_ERROR( subNode->GetName(), cNode->GetName() );
}
}
else if( cNodeName == wxT( "TERMINAL" ) )
{
TERMINAL term;
term.Parse( cNode );
Terminals.insert( std::make_pair( term.ID, term ) );
}
else if( cNodeName == wxT( "FIGURE" ) )
{
FIGURE figure;
figure.Parse( cNode );
Figures.insert( std::make_pair( figure.ID, figure ) );
}
else
THROW_UNKNOWN_NODE_IO_ERROR( cNodeName, aNode->GetName() );
}
}
void CADSTAR_SCH_ARCHIVE_PARSER::NET_SCH::SYM_TERM::Parse( XNODE* aNode )
{
wxASSERT( aNode->GetName() == wxT( "TERM" ) );
ID = GetXmlAttributeIDString( aNode, 0 );
SymbolID = GetXmlAttributeIDString( aNode, 1 );
TerminalID = GetXmlAttributeIDLong( aNode, 2 );
XNODE* cNode = aNode->GetChildren();
for( ; cNode; cNode = cNode->GetNext() )
{
wxString cNodeName = cNode->GetName();
if( cNodeName == wxT( "SIGLOC" ) )
{
NetLabel.Parse( cNode );
HasNetLabel = true;
}
else
THROW_UNKNOWN_NODE_IO_ERROR( cNodeName, aNode->GetName() );
}
}
void CADSTAR_SCH_ARCHIVE_PARSER::NET_SCH::BUS_TERM::Parse( XNODE* aNode )
{
wxASSERT( aNode->GetName() == wxT( "BUSTERM" ) );
ID = GetXmlAttributeIDString( aNode, 0 );
BusID = GetXmlAttributeIDString( aNode, 1 );
XNODE* cNode = aNode->GetChildren();
bool firstPointParsed = false;
bool secondPointParsed = false;
for( ; cNode; cNode = cNode->GetNext() )
{
wxString cNodeName = cNode->GetName();
if( cNodeName == wxT( "SIGLOC" ) )
{
NetLabel.Parse( cNode );
HasNetLabel = true;
}
else if( cNodeName == wxT( "PT" ) )
{
if( !firstPointParsed )
{
FirstPoint.Parse( cNode );
firstPointParsed = true;
}
else if( !secondPointParsed )
{
FirstPoint.Parse( cNode );
secondPointParsed = true;
}
else
THROW_UNKNOWN_NODE_IO_ERROR( cNodeName, aNode->GetName() );
}
else
THROW_UNKNOWN_NODE_IO_ERROR( cNodeName, aNode->GetName() );
}
if( !firstPointParsed || !secondPointParsed )
THROW_MISSING_NODE_IO_ERROR( wxT( "PT" ), aNode->GetName() );
}
void CADSTAR_SCH_ARCHIVE_PARSER::NET_SCH::BLOCK_TERM::Parse( XNODE* aNode )
{
wxASSERT( aNode->GetName() == wxT( "BLOCKTERM" ) );
ID = GetXmlAttributeIDString( aNode, 0 );
BlockID = GetXmlAttributeIDString( aNode, 1 );
TerminalID = GetXmlAttributeIDLong( aNode, 2 );
XNODE* cNode = aNode->GetChildren();
for( ; cNode; cNode = cNode->GetNext() )
{
wxString cNodeName = cNode->GetName();
if( cNodeName == wxT( "SIGLOC" ) )
{
NetLabel.Parse( cNode );
HasNetLabel = true;
}
else
THROW_UNKNOWN_NODE_IO_ERROR( cNodeName, aNode->GetName() );
}
}
void CADSTAR_SCH_ARCHIVE_PARSER::NET_SCH::CONNECTION_SCH::Parse( XNODE* aNode )
{
ParseIdentifiers( aNode );
LayerID = GetXmlAttributeIDString( aNode, 3 );
XNODE* cNode = aNode->GetChildren();
for( ; cNode; cNode = cNode->GetNext() )
{
wxString cNodeName = cNode->GetName();
if( ParseSubNode( cNode ) )
continue;
else if( cNodeName == wxT( "PATH" ) )
{
Path = ParseAllChildPoints( cNode, true );
}
else if( cNodeName == wxT( "GROUPREF" ) )
GroupID = GetXmlAttributeIDString( cNode, 0 );
else if( cNodeName == wxT( "REUSEBLOCKREF" ) )
ReuseBlockRef.Parse( cNode );
else if( cNodeName == wxT( "CONLINECODE" ) )
ConnectionLineCode = GetXmlAttributeIDString( cNode, 0 );
else
THROW_UNKNOWN_NODE_IO_ERROR( cNodeName, wxT( "CONN" ) );
}
}
void CADSTAR_SCH_ARCHIVE_PARSER::NET_SCH::Parse( XNODE* aNode )
{
ParseIdentifiers( aNode );
//Parse child nodes
XNODE* cNode = aNode->GetChildren();
for( ; cNode; cNode = cNode->GetNext() )
{
wxString cNodeName = cNode->GetName();
if( ParseSubNode( cNode ) )
{
continue;
}
else if( cNodeName == wxT( "TERM" ) )
{
SYM_TERM pin;
pin.Parse( cNode );
Terminals.insert( std::make_pair( pin.ID, pin ) );
}
else if( cNodeName == wxT( "BUSTERM" ) )
{
BUS_TERM bt;
bt.Parse( cNode );
BusTerminals.insert( std::make_pair( bt.ID, bt ) );
}
else if( cNodeName == wxT( "BLOCKTERM" ) )
{
BLOCK_TERM bt;
bt.Parse( cNode );
BlockTerminals.insert( std::make_pair( bt.ID, bt ) );
}
else if( cNodeName == wxT( "CONN" ) )
{
CONNECTION_SCH conn;
conn.Parse( cNode );
Connections.push_back( conn );
}
else
THROW_UNKNOWN_NODE_IO_ERROR( cNodeName, wxT( "NET" ) );
}
}
void CADSTAR_SCH_ARCHIVE_PARSER::SCHEMATIC::Parse( XNODE* aNode )
{
wxCHECK( aNode->GetName() == wxT( "SCHEMATIC" ), );
XNODE* cNode = aNode->GetChildren();
bool netSynchParsed = false;
bool dimensionsParsed = false;
for( ; cNode; cNode = cNode->GetNext() )
{
wxString cNodeName = cNode->GetName();
if( cNodeName == wxT( "GROUP" ) )
{
GROUP group;
group.Parse( cNode );
Groups.insert( std::make_pair( group.ID, group ) );
}
else if( cNodeName == wxT( "REUSEBLOCK" ) )
{
REUSEBLOCK reuseblock;
reuseblock.Parse( cNode );
ReuseBlocks.insert( std::make_pair( reuseblock.ID, reuseblock ) );
}
else if( cNodeName == wxT( "FIGURE" ) )
{
FIGURE figure;
figure.Parse( cNode );
Figures.insert( std::make_pair( figure.ID, figure ) );
}
else if( cNodeName == wxT( "SYMBOL" ) )
{
SYMBOL sym;
sym.Parse( cNode );
Symbols.insert( std::make_pair( sym.ID, sym ) );
}
else if( cNodeName == wxT( "BUS" ) )
{
BUS bus;
bus.Parse( cNode );
Buses.insert( std::make_pair( bus.ID, bus ) );
}
else if( cNodeName == wxT( "BLOCK" ) )
{
BLOCK block;
block.Parse( cNode );
Blocks.insert( std::make_pair( block.ID, block ) );
}
else if( cNodeName == wxT( "NET" ) )
{
NET_SCH net;
net.Parse( cNode );
Nets.insert( std::make_pair( net.ID, net ) );
}
else if( cNodeName == wxT( "TEXT" ) )
{
TEXT txt;
txt.Parse( cNode );
Texts.insert( std::make_pair( txt.ID, txt ) );
}
else if( cNodeName == wxT( "DOCSYMBOL" ) )
{
DOCUMENTATION_SYMBOL docsym;
docsym.Parse( cNode );
DocumentationSymbols.insert( std::make_pair( docsym.ID, docsym ) );
}
else if( cNodeName == wxT( "VHIERARCHY" ) )
{
VariantHierarchy.Parse( cNode );
}
else
{
THROW_UNKNOWN_NODE_IO_ERROR( cNodeName, aNode->GetName() );
}
}
}

View File

@ -48,7 +48,353 @@ public:
*/
void Parse();
wxString Filename;
typedef wxString TERMINALCODE_ID;
typedef wxString SYMBOL_ID;
typedef wxString BUS_ID;
typedef wxString BLOCK_ID;
typedef wxString SHEET_NAME;
enum class TERMINAL_SHAPE_TYPE
{
ANNULUS,
BOX,
BULLET,
CIRCLE, ///< Keyword "ROUND"
CROSS,
DIAMOND,
FINGER,
OCTAGON,
PLUS,
POINTER,
RECTANGLE,
ROUNDED_RECT, ///< Keyword "ROUNDED"
SQUARE,
STAR,
TRIANGLE,
UNDEFINED ///< Only used for error checking (not a real shape)
};
static TERMINAL_SHAPE_TYPE ParseTermShapeType( const wxString& aShapeStr );
struct TERMINAL_SHAPE
{
TERMINAL_SHAPE_TYPE ShapeType;
long Size = UNDEFINED_VALUE;
long LeftLength = UNDEFINED_VALUE;
long RightLength = UNDEFINED_VALUE;
long InternalFeature = UNDEFINED_VALUE;
long OrientAngle = 0; ///< 1/1000 of a Degree
static bool IsTermShape( XNODE* aNode );
void Parse( XNODE* aNode );
};
struct TERMINALCODE
{
TERMINALCODE_ID ID;
wxString Name;
TERMINAL_SHAPE Shape;
bool Filled = false;
void Parse( XNODE* aNode );
};
struct CODEDEFS_SCM : CADSTAR_ARCHIVE_PARSER::CODEDEFS
{
std::map<TERMINALCODE_ID, TERMINALCODE> TerminalCodes;
void Parse( XNODE* aNode ) override;
};
struct ASSIGNMENTS_SCM
{
CODEDEFS_SCM Codedefs;
GRIDS Grids;
SETTINGS Settings;
bool NetclassEditAttributeSettings = false; //< Unclear what this does
bool SpacingclassEditAttributeSettings = false; //< Unclear what this does
void Parse( XNODE* aNode );
};
struct TERMINAL
{
TERMINAL_ID ID;
TERMINALCODE_ID TerminalCodeID;
POINT Position; ///< Pad position within the component's coordinate frame.
long OrientAngle = 0;
void Parse( XNODE* aNode );
};
struct PIN_NUM_LABEL_LOC : CADSTAR_ARCHIVE_PARSER::ATTRIBUTE_LOCATION
{
TERMINAL_ID TerminalID;
void Parse( XNODE* aNode ) override;
};
struct SYMDEF_SCM : CADSTAR_ARCHIVE_PARSER::SYMDEF
{
std::map<TERMINAL_ID, TERMINAL> Terminals;
std::map<TERMINAL_ID, PIN_NUM_LABEL_LOC> PinLabelLocations;
std::map<TERMINAL_ID, PIN_NUM_LABEL_LOC> PinNumberLocations;
void Parse( XNODE* aNode ) override;
};
struct LIBRARY_SCM
{
std::map<SYMDEF_ID, SYMDEF_SCM> SymbolDefinitions;
void Parse( XNODE* aNode );
};
struct SHEETS
{
std::map<LAYER_ID, SHEET_NAME> Sheets;
void Parse( XNODE* aNode );
};
struct COMP
{
wxString Designator = wxEmptyString;
bool ReadOnly = false;
bool HasLocation = false;
ATTRIBUTE_LOCATION AttrLoc;
void Parse( XNODE* aNode );
};
struct PARTREF
{
PART_ID RefID = wxEmptyString;
bool ReadOnly = false;
bool HasLocation = false;
ATTRIBUTE_LOCATION AttrLoc;
void Parse( XNODE* aNode );
};
struct SYMPINNAME_LABEL
{
TERMINAL_ID TerminalID;
wxString NameOrLabel;
bool HasLocation = false;
ATTRIBUTE_LOCATION AttrLoc;
void Parse( XNODE* aNode );
};
struct SYMBOLVARIANT
{
enum class TYPE
{
GLOBALSIGNAL,
SIGNALREF
//TODO: there might be others
};
TYPE Type;
wxString Reference;
void Parse( XNODE* aNode );
};
struct SIGNALREFERENCELINK : CADSTAR_ARCHIVE_PARSER::ATTRIBUTE_LOCATION
{
wxString Text; ///< This contains the numbers of the other sheets where the
///< signal reference is present separated by commas
void Parse( XNODE* aNode );
};
struct SYMBOL
{
SYMBOL_ID ID;
SYMDEF_ID SymdefID;
LAYER_ID LayerID; ///< Sheet on which symbol is located
POINT Origin;
GROUP_ID GroupID = wxEmptyString; ///< If not empty, this symbol is part of a group
REUSEBLOCKREF ReuseBlockRef;
long OrientAngle = 0;
bool Mirror = false;
bool Fixed = false;
READABILITY Readability = READABILITY::BOTTOM_TO_TOP;
bool IsComponent = false;
COMP ComponentRef;
bool HasPartRef = false;
PARTREF PartRef;
bool PartNameVisible = true;
GATE_ID GateID; ///< The gate this symbol represents within the associated Part
bool IsSymbolVariant = false;
SYMBOLVARIANT SymbolVariant;
SIGNALREFERENCELINK SigRefLink; ///< Signal References (a special form of global signal)
///< have annotations showing the location of all the
///< other sheets where the signal is present
SYMBOL_ID VariantParentSymbolID = wxEmptyString;
VARIANT_ID VariantID = wxEmptyString;
std::map<TERMINAL_ID, SYMPINNAME_LABEL> PinLabels;
std::map<TERMINAL_ID, SYMPINNAME_LABEL> PinNames;
std::map<ATTRIBUTE_ID, ATTRIBUTE_VALUE> AttributeValues;
void Parse( XNODE* aNode );
};
/**
* @brief Net name or bus name label
*/
struct SIGLOC : CADSTAR_ARCHIVE_PARSER::ATTRIBUTE_LOCATION
{
void Parse( XNODE* aNode );
};
struct BUS
{
BUS_ID ID;
LINECODE_ID LineCodeID;
LAYER_ID LayerID; ///< Sheet on which bus is located
SHAPE Shape;
wxString Name = wxEmptyString;
bool HasBusLabel = false;
SIGLOC BusLabel;
void Parse( XNODE* aNode );
};
struct BLOCK
{
enum class TYPE
{
CLONE,
PARENT,
CHILD
};
BLOCK_ID ID;
TYPE Type;
LAYER_ID LayerID = wxEmptyString; ///< The sheet block is on (TODO: verify this is true)
LAYER_ID AssocLayerID = wxEmptyString; ///< Parent or Child linked sheet
wxString Name = wxEmptyString;
bool HasBlockLabel = false;
ATTRIBUTE_LOCATION BlockLabel;
std::map<TERMINAL_ID, TERMINAL> Terminals;
std::map<FIGURE_ID, FIGURE> Figures;
void Parse( XNODE* aNode );
};
struct NET_SCH : CADSTAR_ARCHIVE_PARSER::NET
{
struct SYM_TERM ///< "TERM" nodename (represents a pin in a SCH symbol)
{
NETELEMENT_ID ID; ///< First character is "P"
SYMBOL_ID SymbolID;
TERMINAL_ID TerminalID;
bool HasNetLabel = false;
SIGLOC NetLabel;
void Parse( XNODE* aNode );
};
struct BUS_TERM ///< "BUSTERM" nodename (represents a connetion to a bus)
{
NETELEMENT_ID ID; ///< First two characters "BT"
BUS_ID BusID;
POINT FirstPoint; ///< Point on the bus itself
POINT SecondPoint; ///< Start point for any wires
bool HasNetLabel = false;
SIGLOC NetLabel;
void Parse( XNODE* aNode );
};
struct BLOCK_TERM ///< "BLOCKTERM" nodename (represents a connetion to a block)
{
NETELEMENT_ID ID; ///< First four characters "BLKT"
BLOCK_ID BlockID;
TERMINAL_ID TerminalID;
bool HasNetLabel = false;
SIGLOC NetLabel;
void Parse( XNODE* aNode );
};
struct CONNECTION_SCH : CADSTAR_ARCHIVE_PARSER::NET::CONNECTION ///< "CONN" nodename
{
LAYER_ID LayerID; ///< Sheet on which the connection is drawn
std::vector<POINT> Path;
GROUP_ID GroupID = wxEmptyString;
REUSEBLOCKREF ReuseBlockRef;
LINECODE_ID ConnectionLineCode;
void Parse( XNODE* aNode ) override;
};
std::map<NETELEMENT_ID, SYM_TERM> Terminals;
std::map<NETELEMENT_ID, BUS_TERM> BusTerminals;
std::map<NETELEMENT_ID, BLOCK_TERM> BlockTerminals;
std::vector<CONNECTION_SCH> Connections;
void Parse( XNODE* aNode );
};
struct SCHEMATIC
{
std::map<GROUP_ID, GROUP> Groups;
std::map<REUSEBLOCK_ID, REUSEBLOCK> ReuseBlocks;
std::map<FIGURE_ID, FIGURE> Figures;
std::map<SYMBOL_ID, SYMBOL> Symbols;
std::map<BUS_ID, BUS> Buses;
std::map<BLOCK_ID, BLOCK> Blocks;
std::map<NET_ID, NET_SCH> Nets;
std::map<TEXT_ID, TEXT> Texts;
std::map<DOCUMENTATION_SYMBOL_ID, DOCUMENTATION_SYMBOL> DocumentationSymbols;
VARIANT_HIERARCHY VariantHierarchy;
std::map<ATTRIBUTE_ID, ATTRIBUTE_VALUE> AttributeValues;
void Parse( XNODE* aNode );
};
wxString Filename;
HEADER Header;
ASSIGNMENTS_SCM Assignments;
LIBRARY_SCM Library;
PARTS Parts;
SHEETS Sheets;
SCHEMATIC Schematic;
int KiCadUnitMultiplier; ///<Use this value to convert units in this CSA file to KiCad units
}; //CADSTAR_SCH_ARCHIVE_PARSER

View File

@ -86,6 +86,12 @@ SCH_SHEET* CADSTAR_SCH_ARCHIVE_PLUGIN::Load( const wxString& aFileName, SCHEMATI
mRootSheet->SetScreen( screen );
}
//TEMP TESTING CODE - REMOVE
CADSTAR_SCH_ARCHIVE_PARSER parser( aFileName );
parser.Parse();
//TEMP TESTING CODE - REMOVE
return mRootSheet;
}

View File

@ -52,6 +52,17 @@ void CADSTAR_PCB_ARCHIVE_PARSER::Parse()
wxASSERT_MSG( true, wxT( "Unknown File Resolution" ) );
break;
}
if( Header.Format.Type != wxT( "LAYOUT" ) )
if( Header.Format.Type == wxT( "LIBRARY" ) )
THROW_IO_ERROR(
"The selected file is a CADSTAR Library file (as opposed to a Layout "
"file). CADSTAR libraries cannot yet be imported into KiCad." );
else
THROW_IO_ERROR(
"The selected file is an unknown CADSTAR format so cannot be "
"imported into KiCad." );
}
else if( cNode->GetName() == wxT( "ASSIGNMENTS" ) )
{
@ -1537,7 +1548,7 @@ void CADSTAR_PCB_ARCHIVE_PARSER::SYMDEF_PCB::Parse( XNODE* aNode )
}
}
if( !Origin.IsFullySpecified() )
if( !Stub && !Origin.IsFullySpecified() )
THROW_MISSING_PARAMETER_IO_ERROR( wxT( "PT" ), aNode->GetName() );
}
@ -2188,7 +2199,7 @@ void CADSTAR_PCB_ARCHIVE_PARSER::TEMPLATE::Parse( XNODE* aNode )
}
void CADSTAR_PCB_ARCHIVE_PARSER::COPPER::NETREF::TERMINAL::Parse( XNODE* aNode )
void CADSTAR_PCB_ARCHIVE_PARSER::COPPER::NETREF::COPPER_TERM::Parse( XNODE* aNode )
{
wxASSERT( aNode->GetName() == wxT( "TERM" ) );
@ -2232,7 +2243,7 @@ void CADSTAR_PCB_ARCHIVE_PARSER::COPPER::NETREF::Parse( XNODE* aNode )
if( cNodeName == wxT( "TERM" ) )
{
TERMINAL term;
COPPER_TERM term;
term.Parse( cNode );
CopperTerminals.insert( std::make_pair( term.ID, term ) );
}

View File

@ -898,7 +898,7 @@ public:
GROUP_ID GroupID = wxEmptyString; ///< If not empty, this component is part of a group
REUSEBLOCKREF ReuseBlockRef;
COMPONENT_ID VariantParentComponentID = wxEmptyString;
VARIANT_ID VariantID = wxEmptyString; ///< TODO: find out what this represents
VARIANT_ID VariantID = wxEmptyString;
long OrientAngle = 0;
bool TestPoint = false; ///< Indicates whether this component should be treated
///< as a testpoint. See SYMDEF_TYPE::TESTPOINT
@ -984,7 +984,7 @@ public:
LAYER_ID UnrouteLayerID = wxEmptyString; ///< See Unrouted member variable.
void Parse( XNODE* aNode );
void Parse( XNODE* aNode ) override;
};
std::map<NETELEMENT_ID, PIN> Pins;
@ -1089,7 +1089,7 @@ public:
{
struct NETREF
{
struct TERMINAL
struct COPPER_TERM
{
COPPER_TERM_ID ID;
POINT Location;
@ -1099,7 +1099,7 @@ public:
};
NET_ID NetID = wxEmptyString;
std::map<COPPER_TERM_ID, TERMINAL> CopperTerminals;
std::map<COPPER_TERM_ID, COPPER_TERM> CopperTerminals;
bool Fixed = false;
void Parse( XNODE* aNode );