25#include <boost/test/unit_test.hpp>
71 BOOST_CHECK( parser.
IsValid() );
77 BOOST_CHECK(
header.description.find(
"DESIGN EXPORT FILE" ) != std::string::npos );
86 std::string testFile =
96 std::string testFile =
102 BOOST_CHECK( parser.
IsValid() );
119 BOOST_CHECK( parser.
IsValid() );
236 BOOST_CHECK( parser.
IsValid() );
245 BOOST_REQUIRE_EQUAL( symbols.size(), 1 );
256 BOOST_REQUIRE_EQUAL( pinb->
attrs.size(), 4 );
263 BOOST_REQUIRE_EQUAL( pinb->
graphics.size(), 2 );
265 const auto& openLine = pinb->
graphics[0];
268 BOOST_REQUIRE_EQUAL( openLine.points.size(), 2 );
282 BOOST_CHECK( pinb->
font1.empty() );
283 BOOST_CHECK( pinb->
font2.empty() );
319 const auto&
pin1 =
res->pins[0];
325 const auto& pin2 =
res->pins[1];
336 const auto& gate = ptIt->second.gates[0];
337 BOOST_REQUIRE_GE( gate.pins.size(), 2u );
379 auto ptIt = parser.
GetPartTypes().find(
"IC_QUAD_NAND" );
395 auto ptIt = parser.
GetPartTypes().find(
"IC_QUAD_NAND" );
399 const auto& pins = ptIt->second.gates[0].pins;
400 BOOST_REQUIRE_GE( pins.size(), 14u );
429 const auto& rect =
res->graphics[0];
449 BOOST_CHECK( notFound ==
nullptr );
462 BOOST_CHECK( symbols.empty() );
545 bool foundRefDes =
false;
546 bool foundValue =
false;
550 if( attr.name ==
"Ref.Des." )
553 BOOST_CHECK( attr.visible );
556 else if( attr.name ==
"Value" )
559 BOOST_CHECK( attr.visible );
564 BOOST_CHECK( foundRefDes );
565 BOOST_CHECK( foundValue );
583 if( attr.name ==
"Value" )
585 BOOST_CHECK( !attr.visible );
633 BOOST_CHECK( notFound ==
nullptr );
646 BOOST_CHECK( parts.empty() );
716 const auto& wire1 = vcc->
wires[0];
724 const auto& wire2 = vcc->
wires[1];
775 BOOST_CHECK( notFound ==
nullptr );
788 BOOST_CHECK( signals.empty() );
897 if(
pin->GetNumber() ==
"1" )
926 BOOST_CHECK( !builder.
HasSymbol(
"RES_0805" ) );
930 BOOST_CHECK( builder.
HasSymbol(
"RES_0805" ) );
1025 BOOST_CHECK( !notPower.has_value() );
1028 BOOST_CHECK( !notPower2.has_value() );
1071 BOOST_CHECK( gnd->IsPower() );
1077 BOOST_CHECK( vcc->IsPower() );
1083 BOOST_CHECK( vee->IsPower() );
1088 BOOST_CHECK( gndd->IsPower() );
1093 BOOST_CHECK( earth->IsPower() );
1098 BOOST_CHECK( pwrBar->IsPower() );
1103 BOOST_CHECK( pwrTri->IsPower() );
1121 BOOST_CHECK_EQUAL( PADS_SCH_SYMBOL_BUILDER::GetPowerStyleFromVariant(
"GND",
"G" ),
"GND" );
1122 BOOST_CHECK_EQUAL( PADS_SCH_SYMBOL_BUILDER::GetPowerStyleFromVariant(
"AGND",
"G" ),
"GND" );
1123 BOOST_CHECK_EQUAL( PADS_SCH_SYMBOL_BUILDER::GetPowerStyleFromVariant(
"CHGND",
"G" ),
"Chassis" );
1126 BOOST_CHECK_EQUAL( PADS_SCH_SYMBOL_BUILDER::GetPowerStyleFromVariant(
"+RAIL",
"P" ),
"PWR_BAR" );
1127 BOOST_CHECK_EQUAL( PADS_SCH_SYMBOL_BUILDER::GetPowerStyleFromVariant(
"-RAIL",
"P" ),
"GNDD" );
1130 BOOST_CHECK_EQUAL( PADS_SCH_SYMBOL_BUILDER::GetPowerStyleFromVariant(
"+ARROW",
"P" ),
"PWR_TRIANGLE" );
1131 BOOST_CHECK_EQUAL( PADS_SCH_SYMBOL_BUILDER::GetPowerStyleFromVariant(
"-ARROW",
"P" ),
"VEE" );
1134 BOOST_CHECK_EQUAL( PADS_SCH_SYMBOL_BUILDER::GetPowerStyleFromVariant(
"+BUBBLE",
"P" ),
"VCC" );
1135 BOOST_CHECK_EQUAL( PADS_SCH_SYMBOL_BUILDER::GetPowerStyleFromVariant(
"-BUBBLE",
"P" ),
"VEE" );
1159 BOOST_CHECK( sheets.count( 1 ) > 0 );
1170 std::vector<PADS_SCH::PART_PLACEMENT> partsOnSheet1 = parser.
GetPartsOnSheet( 1 );
1184 std::vector<PADS_SCH::SCH_SIGNAL> signalsOnSheet1 = parser.
GetSignalsOnSheet( 1 );
1187 BOOST_CHECK( signalsOnSheet1.size() > 0 );
1198 BOOST_CHECK( parser.
IsValid() );
1203 auto it = partTypes.find(
"RES0805" );
1208 BOOST_REQUIRE_EQUAL(
res.gates.size(), 1 );
1216 BOOST_REQUIRE_EQUAL( resGate.
decal_names.size(), 4 );
1223 BOOST_REQUIRE_EQUAL( resGate.
pins.size(), 2 );
1242 auto it = partTypes.find(
"PS2802-4-A" );
1247 BOOST_REQUIRE_EQUAL( ps.
gates.size(), 4 );
1250 for(
int g = 0; g < 4; g++ )
1253 BOOST_REQUIRE_GE( ps.
gates[g].decal_names.size(), 1 );
1258 BOOST_REQUIRE_EQUAL( ps.
gates[0].pins.size(), 4 );
1280 auto it = partTypes.find(
"43650-0400" );
1286 BOOST_REQUIRE_EQUAL( conn.
gates.size(), 1 );
1288 BOOST_REQUIRE_EQUAL( conn.
gates[0].pins.size(), 4 );
1291 for(
int p = 0; p < 4; p++ )
1309 auto gndIt = partTypes.find(
"$GND_SYMS" );
1321 BOOST_REQUIRE_EQUAL( gnd.
sigpins.size(), 2 );
1328 auto pwrIt = partTypes.find(
"$PWR_SYMS" );
1338 BOOST_REQUIRE_EQUAL( pwr.
sigpins.size(), 2 );
1354 auto it = partTypes.find(
"MMSZ5260BT1" );
1359 BOOST_REQUIRE_EQUAL( diode.
gates.size(), 1 );
1360 BOOST_REQUIRE_EQUAL( diode.
gates[0].decal_names.size(), 1 );
1363 BOOST_REQUIRE_EQUAL( diode.
gates[0].pins.size(), 2 );
1375 connPt.
name =
"TEST_CONN";
1387 connPt.
gates.push_back( gate );
1390 symDef.
name =
"EXTIN";
1398 symDef.
pins.push_back( symPin );
1404 auto pins15 = sym15->
GetPins();
1405 BOOST_REQUIRE_EQUAL( pins15.size(), 1u );
1413 BOOST_REQUIRE_EQUAL( pins1.size(), 1u );
1417 BOOST_CHECK_NE( sym15, sym1 );
1432 connPt.
name =
"TEST_MULTICONN";
1440 for(
int i = 1; i <= 4; i++ )
1443 pin.pin_id = std::to_string( i );
1448 connPt.
gates.push_back( gate );
1451 symDef.
name =
"EXTIN";
1459 symDef.
pins.push_back( symPin );
1461 std::vector<std::string> pinNumbers = {
"1",
"2",
"3",
"4" };
1462 std::string cacheKey =
"TEST_MULTICONN:conn:J1";
1470 for(
int unit = 1; unit <= 4; unit++ )
1472 std::vector<SCH_PIN*> unitPins;
1476 if(
pin->GetUnit() == unit )
1477 unitPins.push_back(
pin );
1480 BOOST_REQUIRE_EQUAL( unitPins.size(), 1u );
1492 BOOST_CHECK_NE( multiSym, other );
1498 std::string testFile =
"/home/seth/Downloads/ATS-501 Tape Template (1).txt";
1500 if( !wxFileExists( wxString::FromUTF8( testFile ) ) )
1510 auto ptIt = partTypes.find(
"TL082" );
1513 const auto& tl082 = ptIt->second;
1514 BOOST_REQUIRE_EQUAL( tl082.gates.size(), 2u );
1527 int unit1Pins = 0, unit2Pins = 0;
1531 if(
pin->GetUnit() == 1 )
1533 else if(
pin->GetUnit() == 2 )
1548#include <sch_io/pads/pads_sch_schematic_builder.h>
1574 wire.
end.
x = 3000.0;
1575 wire.
end.
y = 2000.0;
1598 int expectedWires = 0;
1600 for(
const auto& signal : parser.
GetSignals() )
1601 expectedWires +=
static_cast<int>( signal.wires.size() );
1603 BOOST_CHECK( expectedWires > 0 );
1617 signal.
name =
"VCC";
1622 wire.
end.
x = 3000.0;
1623 wire.
end.
y = 2000.0;
1624 signal.
wires.push_back( wire );
1646 signal.
name =
"NET 1";
1702 wire.
end.
x = 3000.0;
1703 wire.
end.
y = 2000.0;
1734 LIB_ID libId( wxS(
"test" ), wxS(
"TEST" ) );
1741 wxString ref = symbol->
GetRef( &schematic.CurrentSheet() );
1765 footprintAttr.
name =
"PCB DECAL";
1766 footprintAttr.
value =
"CAP_0805";
1767 footprintAttr.
visible =
false;
1768 placement.
attributes.push_back( footprintAttr );
1776 LIB_ID libId( wxS(
"test" ), wxS(
"CAP" ) );
1803 valueAttr.
name =
"VALUE";
1804 valueAttr.
value =
"74HC00";
1810 refAttr.
name =
"REFDES";
1811 refAttr.
value =
"U1";
1821 LIB_ID libId( wxS(
"test" ), wxS(
"74HC00" ) );
1851 BOOST_CHECK(
true );
1868 mfrAttr.
name =
"Manufacturer";
1869 mfrAttr.
value =
"Texas Instruments";
1875 mpnAttr.
name =
"MPN";
1876 mpnAttr.
value =
"SN74HC00N";
1886 LIB_ID libId( wxS(
"test" ), wxS(
"74HC00" ) );
1923 refAttr.
name =
"Ref.Des.";
1924 refAttr.
value =
"R1";
1928 valAttr.
name =
"Part Type";
1929 valAttr.
value =
"10K";
1934 customAttr.
name =
"Tolerance";
1935 customAttr.
value =
"5%";
1937 placement.
attributes.push_back( customAttr );
1945 LIB_ID libId( wxS(
"test" ), wxS(
"RES" ) );
1976 emptyAttr.
name =
"SerialNumber";
1977 emptyAttr.
value =
"";
1982 validAttr.
name =
"Revision";
1983 validAttr.
value =
"A";
1993 LIB_ID libId( wxS(
"test" ), wxS(
"IC" ) );
2009 BOOST_CHECK( snField ==
nullptr );
2020 params.
fields[
"Title"] =
"Test Design";
2021 params.
fields[
"DATE"] =
"2025-01-12";
2022 params.
fields[
"Revision"] =
"A";
2023 params.
fields[
"Company Name"] =
"Test Company";
2075 BOOST_CHECK( tb.
GetTitle().IsEmpty() );
2076 BOOST_CHECK( tb.
GetDate().IsEmpty() );
2085 params.
fields[
"Title"] =
"Test";
2092 BOOST_CHECK(
true );
2100#include <sch_sheet.h>
2119 BOOST_CHECK( size.
x > 0 );
2120 BOOST_CHECK( size.
y > 0 );
2136 BOOST_CHECK( pos.
x > 0 );
2137 BOOST_CHECK( pos.
y > 0 );
2165 BOOST_CHECK( pos1.
x > pos0.
x );
2166 BOOST_CHECK( pos2.
y > pos0.
y );
2188 BOOST_CHECK( sheet->
GetScreen() !=
nullptr );
2192 BOOST_CHECK( pos.
x >= 0 );
2193 BOOST_CHECK( pos.
y >= 0 );
2197 BOOST_CHECK( size.
x > 0 );
2198 BOOST_CHECK( size.
y > 0 );
2223 BOOST_CHECK( filename.Contains( wxT(
"my_design" ) ) );
2224 BOOST_CHECK( filename.Contains( wxT(
"sheet2" ) ) );
2225 BOOST_CHECK( filename.EndsWith( wxT(
".kicad_sch" ) ) );
2250 BOOST_CHECK(
name.Contains( wxT(
"3" ) ) );
2268 BOOST_CHECK( sheet ==
nullptr );
2329 BOOST_CHECK(
pin ==
nullptr );
2352 BOOST_CHECK( screen.
Items().
size() > 0 );
2359 std::set<int> singleSheet = { 1 };
2373 std::set<int> multiSheet = { 1, 2, 3 };
2383 std::set<int> singleSheet = { 1 };
2396 std::string testFile =
2405 bool foundValue =
false;
2409 if( attr.name ==
"Value" )
2412 BOOST_CHECK( attr.visible );
2418 BOOST_CHECK( foundValue );
2426 std::string testFile =
2432 auto ptIt = parser.
GetPartTypes().find(
"91-HDSKT10DH" );
2434 BOOST_CHECK( ptIt->second.is_connector );
2437 auto resIt = parser.
GetPartTypes().find(
"71=B2002.2" );
2439 BOOST_CHECK( !resIt->second.is_connector );
2447 std::string testFile =
2453 auto ptIt = parser.
GetPartTypes().find(
"91-HDSKT10DH" );
2465 auto resIt = parser.
GetPartTypes().find(
"71=B2002.2" );
2511 std::string testFile =
2525 if( nn.anchor_ref ==
"@@@O14" )
2527 else if( nn.anchor_ref ==
"@@@O22" )
2543 bool foundRef =
false;
2544 bool foundPartType =
false;
2548 if( attr.name ==
"REF-DES" )
2556 else if( attr.name ==
"PART-TYPE" )
2558 foundPartType =
true;
2566 BOOST_CHECK( foundRef );
2567 BOOST_CHECK( foundPartType );
virtual const wxString & GetText() const
Return the string associated with the text object.
virtual bool IsVisible() const
size_t size() const
Return the number of items in the tree.
A logical library item identifier and consists of various portions much like a URI.
Define a library symbol object.
LIB_ITEMS_CONTAINER & GetDrawItems()
Return a reference to the draw item list.
wxString GetName() const override
std::vector< SCH_PIN * > GetPins() const override
int GetUnitCount() const override
Parser for PADS Logic schematic design export files.
bool Parse(const std::string &aFileName)
const std::vector< NETNAME_LABEL > & GetNetNameLabels() const
const std::vector< SCH_SIGNAL > & GetSignals() const
const FILE_HEADER & GetHeader() const
std::vector< SCH_SIGNAL > GetSignalsOnSheet(int aSheetNumber) const
std::set< int > GetSheetNumbers() const
static bool CheckFileHeader(const std::string &aFileName)
const std::vector< SYMBOL_DEF > & GetSymbolDefs() const
const std::vector< PART_PLACEMENT > & GetPartPlacements() const
const std::map< std::string, PARTTYPE_DEF > & GetPartTypes() const
std::vector< PART_PLACEMENT > GetPartsOnSheet(int aSheetNumber) const
const SCH_SIGNAL * GetSignal(const std::string &aName) const
const SYMBOL_DEF * GetSymbolDef(const std::string &aName) const
const PARAMETERS & GetParameters() const
const PART_PLACEMENT * GetPartPlacement(const std::string &aReference) const
std::string GetVersion() const
int GetSheetCount() const
Builder class to create KiCad schematic elements from parsed PADS data.
SCH_LINE * CreateWire(const WIRE_SEGMENT &aWire)
Create a single wire segment.
SCH_SHEET_PIN * CreateSheetPin(SCH_SHEET *aSheet, const std::string &aSignalName, int aPinIndex)
Create hierarchical sheet pin on a sheet symbol.
void ApplyPartAttributes(SCH_SYMBOL *aSymbol, const PART_PLACEMENT &aPlacement)
Apply part attributes to a symbol instance.
void CreateTitleBlock(SCH_SCREEN *aScreen)
Create title block from parsed PADS parameters.
VECTOR2I CalculateSheetPosition(int aSheetIndex, int aTotalSheets) const
Calculate position for a sheet symbol on the parent sheet.
int CreateCustomFields(SCH_SYMBOL *aSymbol, const PART_PLACEMENT &aPlacement)
Create custom fields from non-standard PADS attributes.
SCH_LINE * CreateBusWire(const WIRE_SEGMENT &aWire)
Create a single bus wire segment.
SCH_HIERLABEL * CreateHierLabel(const std::string &aSignalName, const VECTOR2I &aPosition, SCH_SCREEN *aScreen)
Create hierarchical label in a sub-schematic.
SCH_GLOBALLABEL * CreateNetLabel(const SCH_SIGNAL &aSignal, const VECTOR2I &aPosition, SPIN_STYLE aOrientation=SPIN_STYLE::RIGHT)
Create a global net label for a signal.
static bool IsGlobalSignal(const std::string &aSignalName, const std::set< int > &aSheetNumbers)
Check if a signal name represents a global signal.
SCH_SHEET * CreateHierarchicalSheet(int aSheetNumber, int aTotalSheets, SCH_SHEET *aParentSheet, const wxString &aBaseFilename)
Create hierarchical sheet for a sub-schematic page.
VECTOR2I GetDefaultSheetSize() const
Get standard sheet size for a given sheet number.
static bool IsBusSignal(const std::string &aName)
Check if a signal name indicates a bus.
Builder class to convert PADS symbol definitions to KiCad LIB_SYMBOL objects.
LIB_SYMBOL * BuildMultiUnitSymbol(const PARTTYPE_DEF &aPartType, const std::vector< SYMBOL_DEF > &aSymbolDefs)
Build a composite multi-unit LIB_SYMBOL from a multi-gate PARTTYPE.
bool HasSymbol(const std::string &aName) const
Check if a symbol with the given name already exists.
static std::optional< LIB_ID > GetKiCadPowerSymbolId(const std::string &aPadsName)
Get KiCad power library symbol ID for a PADS power symbol.
LIB_SYMBOL * BuildKiCadPowerSymbol(const std::string &aKiCadName)
Build a power symbol using hard-coded KiCad-standard graphics.
static bool IsPowerSymbol(const std::string &aName)
Check if a symbol name indicates a power symbol.
LIB_SYMBOL * GetOrCreateSymbol(const SYMBOL_DEF &aSymbolDef)
Get or create a symbol for the given definition.
LIB_SYMBOL * GetOrCreateConnectorPinSymbol(const PARTTYPE_DEF &aPartType, const SYMBOL_DEF &aSymbolDef, const std::string &aPinNumber)
Get or create a single-pin connector symbol with a specific pin number.
LIB_SYMBOL * GetOrCreateMultiUnitConnectorSymbol(const PARTTYPE_DEF &aPartType, const SYMBOL_DEF &aSymbolDef, const std::vector< std::string > &aPinNumbers, const std::string &aCacheKey)
Get or create a multi-unit connector symbol, cached by base reference.
LIB_SYMBOL * BuildSymbol(const SYMBOL_DEF &aSymbolDef)
Build a KiCad LIB_SYMBOL from a PADS symbol definition.
LIB_SYMBOL * GetOrCreatePartTypeSymbol(const PARTTYPE_DEF &aPartType, const SYMBOL_DEF &aSymbolDef)
Get or create a single-gate symbol with PARTTYPE-specific pin remapping.
Holds all the data relating to one schematic.
virtual const wxString & GetText() const override
Return the string associated with the text object.
Base class for any item which can be embedded within the SCHEMATIC container class,...
SCH_LAYER_ID GetLayer() const
Return the layer this item is on.
Segment description base class to describe items which have 2 end points (track, wire,...
VECTOR2I GetEndPoint() const
VECTOR2I GetStartPoint() const
EE_RTREE & Items()
Get the full RTree, usually for iterating.
TITLE_BLOCK & GetTitleBlock()
Define a sheet pin (label) used in sheets to create hierarchical schematics.
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
void SetSize(const VECTOR2I &aSize)
SCH_FIELD * GetField(FIELD_T aFieldType)
Return a mandatory field in this sheet.
void SetPosition(const VECTOR2I &aPosition) override
SCH_SCREEN * GetScreen() const
VECTOR2I GetPosition() const override
void SetScreen(SCH_SCREEN *aScreen)
Set the SCH_SCREEN associated with this sheet to aScreen.
const wxString GetRef(const SCH_SHEET_PATH *aSheet, bool aIncludeUnit=false) const override
SCH_FIELD * GetField(FIELD_T aFieldType)
Return a mandatory field in this symbol.
virtual bool GetShowPinNumbers() const
Hold the information shown in the lower right corner of a plot, printout, or editing view.
const wxString & GetCompany() const
const wxString & GetRevision() const
const wxString & GetDate() const
const wxString & GetTitle() const
std::string GetEeschemaTestDataDir()
Get the configured location of Eeschema test data.
void DecodeJustification(int aJustification, GR_TEXT_H_ALIGN_T &aHJustify, GR_TEXT_V_ALIGN_T &aVJustify)
Decode a PADS text justification code into KiCad horizontal and vertical alignment.
Common utilities and types for parsing PADS file formats.
@ PT_UNSPECIFIED
unknown electrical properties: creates always a warning when connected
Definition of the SCH_SHEET_PATH and SCH_SHEET_LIST classes for Eeschema.
Gate definition within a PARTTYPE.
std::vector< std::string > decal_names
std::vector< PARTTYPE_PIN > pins
Net name label from NETNAMES section.
General schematic parameters from SCH and FIELDS sections.
std::map< std::string, std::string > fields
Part type definition from PARTTYPE section.
std::vector< GATE_DEF > gates
std::vector< SPECIAL_VARIANT > special_variants
std::vector< SIGPIN > sigpins
std::string special_keyword
Pin definition within a PARTTYPE GATE.
Part instance from PART section.
std::vector< PART_ATTRIBUTE > attributes
Signal (net) definition from CONNECTION and SIGNAL sections.
std::vector< PIN_CONNECTION > connections
std::vector< WIRE_SEGMENT > wires
Symbol definition from CAEDECAL section.
std::vector< SYMBOL_GRAPHIC > graphics
std::vector< SYMBOL_PIN > pins
std::vector< CAEDECAL_ATTR > attrs
Pin T/P line pair from CAEDECAL.
Wire segment connecting two endpoints through coordinate vertices.
@ FOOTPRINT
Field Name Module PCB, i.e. "16DIP300".
@ REFERENCE
Field Reference of part, i.e. "IC21".
@ VALUE
Field Value of part, i.e. "3.3K".
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
BOOST_REQUIRE(intersection.has_value()==c.ExpectedIntersection.has_value())
BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_CASE(CheckFileHeader_ValidLogicFile)
std::vector< std::string > header
BOOST_TEST_MESSAGE("\n=== Real-World Polygon PIP Benchmark ===\n"<< formatTable(table))
SHAPE_CIRCLE circle(c.m_circle_center, c.m_circle_radius)
BOOST_CHECK_EQUAL(result, "25.4")
GR_TEXT_H_ALIGN_T
This is API surface mapped to common.types.HorizontalAlignment.
GR_TEXT_V_ALIGN_T
This is API surface mapped to common.types.VertialAlignment.
VECTOR2< int32_t > VECTOR2I