25#include <boost/test/unit_test.hpp>
63 const auto& buses = parser.
GetBuses();
64 BOOST_REQUIRE_EQUAL( buses.size(), 1 );
68 BOOST_REQUIRE_EQUAL( buses[0].
path.size(), 3 );
71 BOOST_REQUIRE_EQUAL( buses[0].entries.size(), 3 );
75 BOOST_CHECK_EQUAL( buses[0].member_nets, ( std::vector<std::string>{
"DATA0",
"DATA1",
"DATA2" } ) );
84 BOOST_REQUIRE_EQUAL( parser.
GetBuses().size(), 1 );
86 BOOST_CHECK( parser.
GetBuses().empty() );
98 for(
const std::string fixture : {
"buses_bad_header.txt",
"buses_bad_point.txt",
99 "buses_negative_count.txt",
"buses_excessive_count.txt" } )
105 BOOST_CHECK( parser.
Parse( root + fixture ) );
106 BOOST_CHECK( parser.
GetBuses().empty() );
112 BOOST_CHECK( truncated.
Parse( root +
"buses_truncated.txt" ) );
113 BOOST_REQUIRE_EQUAL( truncated.
GetBuses().size(), 1 );
120 BOOST_CHECK( recovered.
Parse( root +
"buses_bad_point_recovers.txt" ) );
121 BOOST_REQUIRE_EQUAL( recovered.
GetBuses().size(), 1 );
141 BOOST_CHECK( parser.
IsValid() );
147 BOOST_CHECK( header.description.find(
"DESIGN EXPORT FILE" ) != std::string::npos );
170 BOOST_CHECK( parser.
IsValid() );
187 BOOST_CHECK( parser.
IsValid() );
304 BOOST_CHECK( parser.
IsValid() );
313 BOOST_REQUIRE_EQUAL( symbols.size(), 1 );
324 BOOST_REQUIRE_EQUAL( pinb->
attrs.size(), 4 );
331 BOOST_REQUIRE_EQUAL( pinb->
graphics.size(), 2 );
333 const auto& openLine = pinb->
graphics[0];
336 BOOST_REQUIRE_EQUAL( openLine.points.size(), 2 );
350 BOOST_CHECK( pinb->
font1.empty() );
351 BOOST_CHECK( pinb->
font2.empty() );
387 const auto&
pin1 =
res->pins[0];
393 const auto& pin2 =
res->pins[1];
404 const auto& gate = ptIt->second.gates[0];
405 BOOST_REQUIRE_GE( gate.pins.size(), 2u );
447 auto ptIt = parser.
GetPartTypes().find(
"IC_QUAD_NAND" );
463 auto ptIt = parser.
GetPartTypes().find(
"IC_QUAD_NAND" );
467 const auto& pins = ptIt->second.gates[0].pins;
468 BOOST_REQUIRE_GE( pins.size(), 14u );
497 const auto& rect =
res->graphics[0];
517 BOOST_CHECK( notFound ==
nullptr );
530 BOOST_CHECK( symbols.empty() );
613 bool foundRefDes =
false;
614 bool foundValue =
false;
618 if( attr.name ==
"Ref.Des." )
621 BOOST_CHECK( attr.visible );
624 else if( attr.name ==
"Value" )
627 BOOST_CHECK( attr.visible );
632 BOOST_CHECK( foundRefDes );
633 BOOST_CHECK( foundValue );
651 if( attr.name ==
"Value" )
653 BOOST_CHECK( !attr.visible );
701 BOOST_CHECK( notFound ==
nullptr );
714 BOOST_CHECK( parts.empty() );
784 const auto& wire1 = vcc->
wires[0];
792 const auto& wire2 = vcc->
wires[1];
843 BOOST_CHECK( notFound ==
nullptr );
856 BOOST_CHECK( signals.empty() );
965 if(
pin->GetNumber() ==
"1" )
994 BOOST_CHECK( !builder.
HasSymbol(
"RES_0805" ) );
998 BOOST_CHECK( builder.
HasSymbol(
"RES_0805" ) );
1093 BOOST_CHECK( !notPower.has_value() );
1096 BOOST_CHECK( !notPower2.has_value() );
1138 BOOST_CHECK( gnd->IsPower() );
1143 BOOST_CHECK( vcc->IsPower() );
1149 BOOST_CHECK( vee->IsPower() );
1154 BOOST_CHECK( gndd->IsPower() );
1159 BOOST_CHECK( earth->IsPower() );
1164 BOOST_CHECK( pwrBar->IsPower() );
1169 BOOST_CHECK( pwrTri->IsPower() );
1179 BOOST_CHECK( !gnd->GetReferenceField().IsVisible() );
1180 BOOST_CHECK( !vcc->GetReferenceField().IsVisible() );
1182 size_t gndShapes = 0;
1183 size_t vccCircles = 0;
1185 for(
const SCH_ITEM& item : gnd->GetDrawItems() )
1188 for(
const SCH_ITEM& item : vcc->GetDrawItems() )
1203 BOOST_CHECK_EQUAL( PADS_SCH_SYMBOL_BUILDER::GetPowerStyleFromVariant(
"GND",
"G" ),
"GND" );
1204 BOOST_CHECK_EQUAL( PADS_SCH_SYMBOL_BUILDER::GetPowerStyleFromVariant(
"AGND",
"G" ),
"GND" );
1205 BOOST_CHECK_EQUAL( PADS_SCH_SYMBOL_BUILDER::GetPowerStyleFromVariant(
"CHGND",
"G" ),
"Chassis" );
1208 BOOST_CHECK_EQUAL( PADS_SCH_SYMBOL_BUILDER::GetPowerStyleFromVariant(
"+RAIL",
"P" ),
"PWR_BAR" );
1209 BOOST_CHECK_EQUAL( PADS_SCH_SYMBOL_BUILDER::GetPowerStyleFromVariant(
"-RAIL",
"P" ),
"GNDD" );
1212 BOOST_CHECK_EQUAL( PADS_SCH_SYMBOL_BUILDER::GetPowerStyleFromVariant(
"+ARROW",
"P" ),
"PWR_TRIANGLE" );
1213 BOOST_CHECK_EQUAL( PADS_SCH_SYMBOL_BUILDER::GetPowerStyleFromVariant(
"-ARROW",
"P" ),
"VEE" );
1216 BOOST_CHECK_EQUAL( PADS_SCH_SYMBOL_BUILDER::GetPowerStyleFromVariant(
"+BUBBLE",
"P" ),
"VCC" );
1217 BOOST_CHECK_EQUAL( PADS_SCH_SYMBOL_BUILDER::GetPowerStyleFromVariant(
"-BUBBLE",
"P" ),
"VEE" );
1241 BOOST_CHECK( sheets.count( 1 ) > 0 );
1252 std::vector<PADS_SCH::PART_PLACEMENT> partsOnSheet1 = parser.
GetPartsOnSheet( 1 );
1266 std::vector<PADS_SCH::SCH_SIGNAL> signalsOnSheet1 = parser.
GetSignalsOnSheet( 1 );
1269 BOOST_CHECK( signalsOnSheet1.size() > 0 );
1280 BOOST_CHECK( parser.
IsValid() );
1285 auto it = partTypes.find(
"RES0805" );
1290 BOOST_REQUIRE_EQUAL(
res.gates.size(), 1 );
1298 BOOST_REQUIRE_EQUAL( resGate.
decal_names.size(), 4 );
1305 BOOST_REQUIRE_EQUAL( resGate.
pins.size(), 2 );
1324 auto it = partTypes.find(
"PS2802-4-A" );
1329 BOOST_REQUIRE_EQUAL( ps.
gates.size(), 4 );
1332 for(
int g = 0; g < 4; g++ )
1335 BOOST_REQUIRE_GE( ps.
gates[g].decal_names.size(), 1 );
1340 BOOST_REQUIRE_EQUAL( ps.
gates[0].pins.size(), 4 );
1362 auto it = partTypes.find(
"43650-0400" );
1368 BOOST_REQUIRE_EQUAL( conn.
gates.size(), 1 );
1370 BOOST_REQUIRE_EQUAL( conn.
gates[0].pins.size(), 4 );
1373 for(
int p = 0; p < 4; p++ )
1391 auto gndIt = partTypes.find(
"$GND_SYMS" );
1403 BOOST_REQUIRE_EQUAL( gnd.
sigpins.size(), 2 );
1410 auto pwrIt = partTypes.find(
"$PWR_SYMS" );
1420 BOOST_REQUIRE_EQUAL( pwr.
sigpins.size(), 2 );
1436 auto it = partTypes.find(
"MMSZ5260BT1" );
1441 BOOST_REQUIRE_EQUAL( diode.
gates.size(), 1 );
1442 BOOST_REQUIRE_EQUAL( diode.
gates[0].decal_names.size(), 1 );
1445 BOOST_REQUIRE_EQUAL( diode.
gates[0].pins.size(), 2 );
1457 connPt.
name =
"TEST_CONN";
1469 connPt.
gates.push_back( gate );
1472 symDef.
name =
"EXTIN";
1480 symDef.
pins.push_back( symPin );
1486 auto pins15 = sym15->
GetPins();
1487 BOOST_REQUIRE_EQUAL( pins15.size(), 1u );
1495 BOOST_REQUIRE_EQUAL( pins1.size(), 1u );
1499 BOOST_CHECK_NE( sym15, sym1 );
1514 connPt.
name =
"TEST_MULTICONN";
1522 for(
int i = 1; i <= 4; i++ )
1525 pin.pin_id = std::to_string( i );
1530 connPt.
gates.push_back( gate );
1533 symDef.
name =
"EXTIN";
1541 symDef.
pins.push_back( symPin );
1543 std::vector<std::string> pinNumbers = {
"1",
"2",
"3",
"4" };
1544 std::string cacheKey =
"TEST_MULTICONN:conn:J1";
1551 for(
int unit = 1; unit <= 4; unit++ )
1553 std::vector<SCH_PIN*> unitPins;
1557 if(
pin->GetUnit() == unit )
1558 unitPins.push_back(
pin );
1561 BOOST_REQUIRE_EQUAL( unitPins.size(), 1u );
1571 BOOST_CHECK_NE( multiSym, other );
1579#include <sch_io/pads/pads_sch_schematic_builder.h>
1605 wire.
end.
x = 3000.0;
1606 wire.
end.
y = 2000.0;
1629 int expectedWires = 0;
1631 for(
const auto& signal : parser.
GetSignals() )
1632 expectedWires +=
static_cast<int>( signal.wires.size() );
1634 BOOST_CHECK( expectedWires > 0 );
1648 signal.
name =
"VCC";
1653 wire.
end.
x = 3000.0;
1654 wire.
end.
y = 2000.0;
1655 signal.
wires.push_back( wire );
1677 signal.
name =
"NET 1";
1733 wire.
end.
x = 3000.0;
1734 wire.
end.
y = 2000.0;
1765 LIB_ID libId( wxS(
"test" ), wxS(
"TEST" ) );
1796 footprintAttr.
name =
"PCB DECAL";
1797 footprintAttr.
value =
"CAP_0805";
1798 footprintAttr.
visible =
false;
1799 placement.
attributes.push_back( footprintAttr );
1807 LIB_ID libId( wxS(
"test" ), wxS(
"CAP" ) );
1834 valueAttr.
name =
"VALUE";
1835 valueAttr.
value =
"74HC00";
1841 refAttr.
name =
"REFDES";
1842 refAttr.
value =
"U1";
1852 LIB_ID libId( wxS(
"test" ), wxS(
"74HC00" ) );
1882 BOOST_CHECK(
true );
1899 mfrAttr.
name =
"Manufacturer";
1900 mfrAttr.
value =
"Texas Instruments";
1906 mpnAttr.
name =
"MPN";
1907 mpnAttr.
value =
"SN74HC00N";
1917 LIB_ID libId( wxS(
"test" ), wxS(
"74HC00" ) );
1954 refAttr.
name =
"Ref.Des.";
1955 refAttr.
value =
"R1";
1959 valAttr.
name =
"Part Type";
1960 valAttr.
value =
"10K";
1965 customAttr.
name =
"Tolerance";
1966 customAttr.
value =
"5%";
1968 placement.
attributes.push_back( customAttr );
1976 LIB_ID libId( wxS(
"test" ), wxS(
"RES" ) );
2007 emptyAttr.
name =
"SerialNumber";
2008 emptyAttr.
value =
"";
2013 validAttr.
name =
"Revision";
2014 validAttr.
value =
"A";
2024 LIB_ID libId( wxS(
"test" ), wxS(
"IC" ) );
2040 BOOST_CHECK( snField ==
nullptr );
2051 params.
fields[
"Title"] =
"Test Design";
2052 params.
fields[
"DATE"] =
"2025-01-12";
2053 params.
fields[
"Revision"] =
"A";
2054 params.
fields[
"Company Name"] =
"Test Company";
2106 BOOST_CHECK( tb.
GetTitle().IsEmpty() );
2107 BOOST_CHECK( tb.
GetDate().IsEmpty() );
2116 params.
fields[
"Title"] =
"Test";
2123 BOOST_CHECK(
true );
2131#include <sch_sheet.h>
2150 BOOST_CHECK( size.
x > 0 );
2151 BOOST_CHECK( size.
y > 0 );
2167 BOOST_CHECK( pos.
x > 0 );
2168 BOOST_CHECK( pos.
y > 0 );
2196 BOOST_CHECK( pos1.
x > pos0.
x );
2197 BOOST_CHECK( pos2.
y > pos0.
y );
2219 BOOST_CHECK( sheet->
GetScreen() !=
nullptr );
2223 BOOST_CHECK( pos.
x >= 0 );
2224 BOOST_CHECK( pos.
y >= 0 );
2228 BOOST_CHECK( size.
x > 0 );
2229 BOOST_CHECK( size.
y > 0 );
2254 BOOST_CHECK( filename.Contains( wxT(
"my_design" ) ) );
2255 BOOST_CHECK( filename.Contains( wxT(
"sheet2" ) ) );
2256 BOOST_CHECK( filename.EndsWith( wxT(
".kicad_sch" ) ) );
2281 BOOST_CHECK(
name.Contains( wxT(
"3" ) ) );
2299 BOOST_CHECK( sheet ==
nullptr );
2360 BOOST_CHECK(
pin ==
nullptr );
2383 BOOST_CHECK( screen.
Items().
size() > 0 );
2389 std::set<int> singleSheet = { 1 };
2403 std::set<int> multiSheet = { 1, 2, 3 };
2413 std::set<int> singleSheet = { 1 };
2434 bool foundValue =
false;
2438 if( attr.name ==
"Value" )
2441 BOOST_CHECK( attr.visible );
2447 BOOST_CHECK( foundValue );
2460 auto ptIt = parser.
GetPartTypes().find(
"91-HDSKT10DH" );
2462 BOOST_CHECK( ptIt->second.is_connector );
2465 auto resIt = parser.
GetPartTypes().find(
"71=B2002.2" );
2467 BOOST_CHECK( !resIt->second.is_connector );
2480 auto ptIt = parser.
GetPartTypes().find(
"91-HDSKT10DH" );
2492 auto resIt = parser.
GetPartTypes().find(
"71=B2002.2" );
2551 if( nn.anchor_ref ==
"@@@O14" )
2553 else if( nn.anchor_ref ==
"@@@O22" )
2569 bool foundRef =
false;
2570 bool foundPartType =
false;
2574 if( attr.name ==
"REF-DES" )
2582 else if( attr.name ==
"PART-TYPE" )
2584 foundPartType =
true;
2592 BOOST_CHECK( foundRef );
2593 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 ASCII schematic export files.
bool Parse(const std::string &aFileName)
const std::vector< NETNAME_LABEL > & GetNetNameLabels() const
const std::vector< BUS_DEF > & GetBuses() 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
Builds KiCad schematic elements (wires, junctions, labels, fields, sheets) from parsed PADS data.
SCH_LINE * CreateWire(const WIRE_SEGMENT &aWire)
SCH_SHEET_PIN * CreateSheetPin(SCH_SHEET *aSheet, const std::string &aSignalName, int aPinIndex)
Create a sheet pin that connects to a hierarchical label in the sub-schematic.
void ApplyPartAttributes(SCH_SYMBOL *aSymbol, const PART_PLACEMENT &aPlacement)
Set reference, value, footprint and other fields on a symbol from a part placement.
void CreateTitleBlock(SCH_SCREEN *aScreen)
Set the title block from PADS fields, checking custom names too because PADS designs often leave the ...
VECTOR2I CalculateSheetPosition(int aSheetIndex, int aTotalSheets) const
Position a sheet symbol in a roughly square grid on the parent.
int CreateCustomFields(SCH_SYMBOL *aSymbol, const PART_PLACEMENT &aPlacement)
Create KiCad user fields for PADS attributes that have no standard-field mapping.
SCH_LINE * CreateBusWire(const WIRE_SEGMENT &aWire)
SCH_HIERLABEL * CreateHierLabel(const std::string &aSignalName, const VECTOR2I &aPosition, SCH_SCREEN *aScreen)
Create a hierarchical label that connects to a sheet pin on the parent.
SCH_GLOBALLABEL * CreateNetLabel(const SCH_SIGNAL &aSignal, const VECTOR2I &aPosition, SPIN_STYLE aOrientation=SPIN_STYLE::RIGHT)
Create a net label.
static bool IsGlobalSignal(const std::string &aSignalName, const std::set< int > &aSheetNumbers)
A signal is global when it spans multiple sheets or is a common power net.
SCH_SHEET * CreateHierarchicalSheet(int aSheetNumber, int aTotalSheets, SCH_SHEET *aParentSheet, const wxString &aBaseFilename)
Create a sub-sheet positioned on its parent and backed by its own screen.
VECTOR2I GetDefaultSheetSize() const
static bool IsBusSignal(const std::string &aName)
Builds KiCad LIB_SYMBOL objects from parsed PADS symbol definitions.
bool HasSymbol(const std::string &aName) const
static std::optional< LIB_ID > GetKiCadPowerSymbolId(const std::string &aPadsName)
Map a PADS power symbol name to a KiCad power library LIB_ID, or nullopt if unmapped.
LIB_SYMBOL * BuildKiCadPowerSymbol(const std::string &aKiCadName)
Build a power symbol using hard-coded KiCad-standard graphics, or nullptr if the name is unrecognized...
static bool IsPowerSymbol(const std::string &aName)
LIB_SYMBOL * GetOrCreateSymbol(const SYMBOL_DEF &aSymbolDef)
Return the cached symbol for the given definition, building and caching it if needed.
LIB_SYMBOL * GetOrCreateConnectorPinSymbol(const PARTTYPE_DEF &aPartType, const SYMBOL_DEF &aSymbolDef, const std::string &aPinNumber)
Return a connector symbol variant carrying a specific pin number, since PADS connectors reuse one dec...
LIB_SYMBOL * GetOrCreateMultiUnitConnectorSymbol(const PARTTYPE_DEF &aPartType, const SYMBOL_DEF &aSymbolDef, const std::vector< std::string > &aPinNumbers, const std::string &aCacheKey)
Return the cached multi-unit connector symbol, building it if needed.
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)
Return a single-gate symbol with PARTTYPE pin overrides applied at build time.
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
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.
@ PT_UNSPECIFIED
unknown electrical properties: creates always a warning when connected
Definition of the SCH_SHEET_PATH and SCH_SHEET_LIST classes for Eeschema.
std::vector< std::string > decal_names
std::vector< PARTTYPE_PIN > pins
std::map< std::string, std::string > fields
std::vector< GATE_DEF > gates
std::vector< SPECIAL_VARIANT > special_variants
std::vector< SIGPIN > sigpins
std::string special_keyword
std::string symbol_name
The part type, which is also the power symbol's net name.
std::string decal_name
CAEDECAL the placed gate draws, empty when unresolved.
std::vector< PART_ATTRIBUTE > attributes
std::vector< PIN_CONNECTION > connections
std::vector< WIRE_SEGMENT > wires
std::vector< SYMBOL_GRAPHIC > graphics
std::vector< SYMBOL_PIN > pins
std::vector< CAEDECAL_ATTR > attrs
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)
BOOST_TEST_CONTEXT("Test Clearance")
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