25#include <boost/test/unit_test.hpp>
70 BOOST_CHECK( parser.
IsValid() );
76 BOOST_CHECK( header.description.find(
"DESIGN EXPORT FILE" ) != std::string::npos );
87 BOOST_CHECK( parser.
IsValid() );
204 BOOST_CHECK( parser.
IsValid() );
213 BOOST_REQUIRE_EQUAL( symbols.size(), 1 );
224 BOOST_REQUIRE_EQUAL( pinb->
attrs.size(), 4 );
231 BOOST_REQUIRE_EQUAL( pinb->
graphics.size(), 2 );
233 const auto& openLine = pinb->
graphics[0];
236 BOOST_REQUIRE_EQUAL( openLine.points.size(), 2 );
250 BOOST_CHECK( pinb->
font1.empty() );
251 BOOST_CHECK( pinb->
font2.empty() );
287 const auto& pin1 =
res->pins[0];
293 const auto& pin2 =
res->pins[1];
304 const auto& gate = ptIt->second.gates[0];
305 BOOST_REQUIRE_GE( gate.pins.size(), 2u );
347 auto ptIt = parser.
GetPartTypes().find(
"IC_QUAD_NAND" );
363 auto ptIt = parser.
GetPartTypes().find(
"IC_QUAD_NAND" );
367 const auto& pins = ptIt->second.gates[0].pins;
368 BOOST_REQUIRE_GE( pins.size(), 14u );
397 const auto& rect =
res->graphics[0];
417 BOOST_CHECK( notFound ==
nullptr );
430 BOOST_CHECK( symbols.empty() );
513 bool foundRefDes =
false;
514 bool foundValue =
false;
518 if( attr.name ==
"Ref.Des." )
521 BOOST_CHECK( attr.visible );
524 else if( attr.name ==
"Value" )
527 BOOST_CHECK( attr.visible );
532 BOOST_CHECK( foundRefDes );
533 BOOST_CHECK( foundValue );
551 if( attr.name ==
"Value" )
553 BOOST_CHECK( !attr.visible );
601 BOOST_CHECK( notFound ==
nullptr );
614 BOOST_CHECK( parts.empty() );
684 const auto& wire1 = vcc->
wires[0];
692 const auto& wire2 = vcc->
wires[1];
743 BOOST_CHECK( notFound ==
nullptr );
756 BOOST_CHECK( signals.empty() );
865 if(
pin->GetNumber() ==
"1" )
894 BOOST_CHECK( !builder.
HasSymbol(
"RES_0805" ) );
898 BOOST_CHECK( builder.
HasSymbol(
"RES_0805" ) );
993 BOOST_CHECK( !notPower.has_value() );
996 BOOST_CHECK( !notPower2.has_value() );
1039 BOOST_CHECK( gnd->IsPower() );
1045 BOOST_CHECK( vcc->IsPower() );
1051 BOOST_CHECK( vee->IsPower() );
1056 BOOST_CHECK( gndd->IsPower() );
1061 BOOST_CHECK( earth->IsPower() );
1066 BOOST_CHECK( pwrBar->IsPower() );
1071 BOOST_CHECK( pwrTri->IsPower() );
1089 BOOST_CHECK_EQUAL( PADS_SCH_SYMBOL_BUILDER::GetPowerStyleFromVariant(
"GND",
"G" ),
"GND" );
1090 BOOST_CHECK_EQUAL( PADS_SCH_SYMBOL_BUILDER::GetPowerStyleFromVariant(
"AGND",
"G" ),
"GND" );
1091 BOOST_CHECK_EQUAL( PADS_SCH_SYMBOL_BUILDER::GetPowerStyleFromVariant(
"CHGND",
"G" ),
"Chassis" );
1094 BOOST_CHECK_EQUAL( PADS_SCH_SYMBOL_BUILDER::GetPowerStyleFromVariant(
"+RAIL",
"P" ),
"PWR_BAR" );
1095 BOOST_CHECK_EQUAL( PADS_SCH_SYMBOL_BUILDER::GetPowerStyleFromVariant(
"-RAIL",
"P" ),
"GNDD" );
1098 BOOST_CHECK_EQUAL( PADS_SCH_SYMBOL_BUILDER::GetPowerStyleFromVariant(
"+ARROW",
"P" ),
"PWR_TRIANGLE" );
1099 BOOST_CHECK_EQUAL( PADS_SCH_SYMBOL_BUILDER::GetPowerStyleFromVariant(
"-ARROW",
"P" ),
"VEE" );
1102 BOOST_CHECK_EQUAL( PADS_SCH_SYMBOL_BUILDER::GetPowerStyleFromVariant(
"+BUBBLE",
"P" ),
"VCC" );
1103 BOOST_CHECK_EQUAL( PADS_SCH_SYMBOL_BUILDER::GetPowerStyleFromVariant(
"-BUBBLE",
"P" ),
"VEE" );
1127 BOOST_CHECK( sheets.count( 1 ) > 0 );
1138 std::vector<PADS_SCH::PART_PLACEMENT> partsOnSheet1 = parser.
GetPartsOnSheet( 1 );
1152 std::vector<PADS_SCH::SCH_SIGNAL> signalsOnSheet1 = parser.
GetSignalsOnSheet( 1 );
1155 BOOST_CHECK( signalsOnSheet1.size() > 0 );
1166 BOOST_CHECK( parser.
IsValid() );
1171 auto it = partTypes.find(
"RES0805" );
1176 BOOST_REQUIRE_EQUAL(
res.gates.size(), 1 );
1184 BOOST_REQUIRE_EQUAL( resGate.
decal_names.size(), 4 );
1191 BOOST_REQUIRE_EQUAL( resGate.
pins.size(), 2 );
1210 auto it = partTypes.find(
"PS2802-4-A" );
1215 BOOST_REQUIRE_EQUAL( ps.
gates.size(), 4 );
1218 for(
int g = 0; g < 4; g++ )
1221 BOOST_REQUIRE_GE( ps.
gates[g].decal_names.size(), 1 );
1226 BOOST_REQUIRE_EQUAL( ps.
gates[0].pins.size(), 4 );
1248 auto it = partTypes.find(
"43650-0400" );
1254 BOOST_REQUIRE_EQUAL( conn.
gates.size(), 1 );
1256 BOOST_REQUIRE_EQUAL( conn.
gates[0].pins.size(), 4 );
1259 for(
int p = 0; p < 4; p++ )
1277 auto gndIt = partTypes.find(
"$GND_SYMS" );
1289 BOOST_REQUIRE_EQUAL( gnd.
sigpins.size(), 2 );
1296 auto pwrIt = partTypes.find(
"$PWR_SYMS" );
1306 BOOST_REQUIRE_EQUAL( pwr.
sigpins.size(), 2 );
1322 auto it = partTypes.find(
"MMSZ5260BT1" );
1327 BOOST_REQUIRE_EQUAL( diode.
gates.size(), 1 );
1328 BOOST_REQUIRE_EQUAL( diode.
gates[0].decal_names.size(), 1 );
1331 BOOST_REQUIRE_EQUAL( diode.
gates[0].pins.size(), 2 );
1343 connPt.
name =
"TEST_CONN";
1355 connPt.
gates.push_back( gate );
1358 symDef.
name =
"EXTIN";
1366 symDef.
pins.push_back( symPin );
1372 auto pins15 = sym15->
GetPins();
1373 BOOST_REQUIRE_EQUAL( pins15.size(), 1u );
1381 BOOST_REQUIRE_EQUAL( pins1.size(), 1u );
1385 BOOST_CHECK_NE( sym15, sym1 );
1400 connPt.
name =
"TEST_MULTICONN";
1408 for(
int i = 1; i <= 4; i++ )
1411 pin.pin_id = std::to_string( i );
1416 connPt.
gates.push_back( gate );
1419 symDef.
name =
"EXTIN";
1427 symDef.
pins.push_back( symPin );
1429 std::vector<std::string> pinNumbers = {
"1",
"2",
"3",
"4" };
1430 std::string cacheKey =
"TEST_MULTICONN:conn:J1";
1438 for(
int unit = 1; unit <= 4; unit++ )
1440 std::vector<SCH_PIN*> unitPins;
1444 if(
pin->GetUnit() == unit )
1445 unitPins.push_back(
pin );
1448 BOOST_REQUIRE_EQUAL( unitPins.size(), 1u );
1460 BOOST_CHECK_NE( multiSym, other );
1466 std::string testFile =
"/home/seth/Downloads/ATS-501 Tape Template (1).txt";
1468 if( !wxFileExists( wxString::FromUTF8( testFile ) ) )
1478 auto ptIt = partTypes.find(
"TL082" );
1481 const auto& tl082 = ptIt->second;
1482 BOOST_REQUIRE_EQUAL( tl082.gates.size(), 2u );
1495 int unit1Pins = 0, unit2Pins = 0;
1499 if(
pin->GetUnit() == 1 )
1501 else if(
pin->GetUnit() == 2 )
1516#include <sch_io/pads/pads_sch_schematic_builder.h>
1542 wire.
end.
x = 3000.0;
1543 wire.
end.
y = 2000.0;
1566 int expectedWires = 0;
1568 for(
const auto& signal : parser.
GetSignals() )
1569 expectedWires +=
static_cast<int>( signal.wires.size() );
1571 BOOST_CHECK( expectedWires > 0 );
1585 signal.
name =
"VCC";
1590 wire.
end.
x = 3000.0;
1591 wire.
end.
y = 2000.0;
1592 signal.
wires.push_back( wire );
1614 signal.
name =
"NET 1";
1670 wire.
end.
x = 3000.0;
1671 wire.
end.
y = 2000.0;
1702 LIB_ID libId( wxS(
"test" ), wxS(
"TEST" ) );
1733 footprintAttr.
name =
"PCB DECAL";
1734 footprintAttr.
value =
"CAP_0805";
1735 footprintAttr.
visible =
false;
1736 placement.
attributes.push_back( footprintAttr );
1744 LIB_ID libId( wxS(
"test" ), wxS(
"CAP" ) );
1771 valueAttr.
name =
"VALUE";
1772 valueAttr.
value =
"74HC00";
1778 refAttr.
name =
"REFDES";
1779 refAttr.
value =
"U1";
1789 LIB_ID libId( wxS(
"test" ), wxS(
"74HC00" ) );
1819 BOOST_CHECK(
true );
1836 mfrAttr.
name =
"Manufacturer";
1837 mfrAttr.
value =
"Texas Instruments";
1843 mpnAttr.
name =
"MPN";
1844 mpnAttr.
value =
"SN74HC00N";
1854 LIB_ID libId( wxS(
"test" ), wxS(
"74HC00" ) );
1891 refAttr.
name =
"Ref.Des.";
1892 refAttr.
value =
"R1";
1896 valAttr.
name =
"Part Type";
1897 valAttr.
value =
"10K";
1902 customAttr.
name =
"Tolerance";
1903 customAttr.
value =
"5%";
1905 placement.
attributes.push_back( customAttr );
1913 LIB_ID libId( wxS(
"test" ), wxS(
"RES" ) );
1944 emptyAttr.
name =
"SerialNumber";
1945 emptyAttr.
value =
"";
1950 validAttr.
name =
"Revision";
1951 validAttr.
value =
"A";
1961 LIB_ID libId( wxS(
"test" ), wxS(
"IC" ) );
1977 BOOST_CHECK( snField ==
nullptr );
1988 params.
fields[
"Title"] =
"Test Design";
1989 params.
fields[
"DATE"] =
"2025-01-12";
1990 params.
fields[
"Revision"] =
"A";
1991 params.
fields[
"Company Name"] =
"Test Company";
2043 BOOST_CHECK( tb.
GetTitle().IsEmpty() );
2044 BOOST_CHECK( tb.
GetDate().IsEmpty() );
2053 params.
fields[
"Title"] =
"Test";
2060 BOOST_CHECK(
true );
2068#include <sch_sheet.h>
2087 BOOST_CHECK( size.
x > 0 );
2088 BOOST_CHECK( size.
y > 0 );
2104 BOOST_CHECK( pos.
x > 0 );
2105 BOOST_CHECK( pos.
y > 0 );
2133 BOOST_CHECK( pos1.
x > pos0.
x );
2134 BOOST_CHECK( pos2.
y > pos0.
y );
2156 BOOST_CHECK( sheet->
GetScreen() !=
nullptr );
2160 BOOST_CHECK( pos.
x >= 0 );
2161 BOOST_CHECK( pos.
y >= 0 );
2165 BOOST_CHECK( size.
x > 0 );
2166 BOOST_CHECK( size.
y > 0 );
2191 BOOST_CHECK( filename.Contains( wxT(
"my_design" ) ) );
2192 BOOST_CHECK( filename.Contains( wxT(
"sheet2" ) ) );
2193 BOOST_CHECK( filename.EndsWith( wxT(
".kicad_sch" ) ) );
2218 BOOST_CHECK(
name.Contains( wxT(
"3" ) ) );
2236 BOOST_CHECK( sheet ==
nullptr );
2297 BOOST_CHECK(
pin ==
nullptr );
2320 BOOST_CHECK( screen.
Items().
size() > 0 );
2327 std::set<int> singleSheet = { 1 };
2341 std::set<int> multiSheet = { 1, 2, 3 };
2351 std::set<int> singleSheet = { 1 };
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< 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.
Holds all the data relating to one schematic.
void Reset()
Initialize this schematic to a blank one, unloading anything existing.
SCH_SHEET_PATH & CurrentSheet() const
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
const wxString & GetNumber() const
ELECTRICAL_PINTYPE GetType() const
EE_RTREE & Items()
Get the full RTree, usually for iterating.
const TITLE_BLOCK & GetTitleBlock() const
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.
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.
@ 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
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)
SHAPE_CIRCLE circle(c.m_circle_center, c.m_circle_radius)
BOOST_TEST_MESSAGE("Polyline has "<< chain.PointCount()<< " points")
BOOST_CHECK_EQUAL(result, "25.4")
VECTOR2< int32_t > VECTOR2I