20#include <boost/test/unit_test.hpp>
46 (generator_version "9.99")
55 (gr_line (start -5 -5) (end 60 -5) (layer "Edge.Cuts") (width 0.05))
56 (gr_line (start 60 -5) (end 60 5) (layer "Edge.Cuts") (width 0.05))
57 (gr_line (start 60 5) (end -5 5) (layer "Edge.Cuts") (width 0.05))
58 (gr_line (start -5 5) (end -5 -5) (layer "Edge.Cuts") (width 0.05))
59 (footprint "Term1" (layer "F.Cu") (uuid "00000000-0000-0000-0000-000000000a01")
61 (pad "1" smd rect (at 0 0) (size 0.8 0.8) (layers "F.Cu") (net 1 "/NET_A") (uuid "00000000-0000-0000-0000-000000000a02"))
63 (footprint "Bridge" (layer "F.Cu") (uuid "00000000-0000-0000-0000-000000000b01")
65 (pad "1" smd rect (at -2.5 0) (size 0.8 0.8) (layers "F.Cu") (net 1 "/NET_A") (uuid "00000000-0000-0000-0000-000000000b02"))
66 (pad "2" smd rect (at 2.5 0) (size 0.8 0.8) (layers "F.Cu") (net 2 "/NET_B") (uuid "00000000-0000-0000-0000-000000000b03"))
68 (footprint "Term2" (layer "F.Cu") (uuid "00000000-0000-0000-0000-000000000c01")
70 (pad "1" smd rect (at 0 0) (size 0.8 0.8) (layers "F.Cu") (net 2 "/NET_B") (uuid "00000000-0000-0000-0000-000000000c02"))
72 (segment (start 0 0) (end 20 0) (width 0.2) (layer "F.Cu") (net 1))
73 (segment (start 25 0) (end 50 0) (width 0.2) (layer "F.Cu") (net 2))
80std::unique_ptr<BOARD> loadBoard(
const char* aText,
const std::string& aSubdir )
82 namespace fs = std::filesystem;
83 fs::path tmpDir = fs::temp_directory_path() / aSubdir;
84 fs::create_directories( tmpDir );
85 fs::path pcbPath = tmpDir /
"trunk_delay.kicad_pcb";
88 std::ofstream out( pcbPath );
93 std::unique_ptr<BOARD> board = std::make_unique<BOARD>();
94 plugin.
LoadBoard( pcbPath.string(), board.get() );
95 board->BuildConnectivity();
96 fs::remove( pcbPath );
101void tagChainNets(
BOARD* aBoard,
const wxString& aChain )
105 if( n && n->GetNetname().StartsWith( wxS(
"/NET_" ) ) )
106 n->SetNetChain( aChain );
111void setTerminals(
BOARD* aBoard,
const wxString& aChain,
double aTermAxMm,
double aTermBxMm )
113 PAD* termA =
nullptr;
114 PAD* termB =
nullptr;
115 constexpr int EPS = 100;
116 const VECTOR2I targetA(
static_cast<int>( aTermAxMm * 1000000 ), 0 );
117 const VECTOR2I targetB(
static_cast<int>( aTermBxMm * 1000000 ), 0 );
121 if( fp->Pads().empty() )
127 termA = fp->Pads().front();
130 termB = fp->Pads().front();
135 if( n && n->GetNetChain() == aChain )
138 n->SetTerminalPad( 0, termA );
140 n->SetTerminalPad( 1, termB );
146std::set<BOARD_CONNECTED_ITEM*> collectChainItems(
BOARD* aBoard,
const wxString& aChain )
148 std::set<BOARD_CONNECTED_ITEM*> items;
152 if( t->GetNet() && t->GetNet()->GetNetChain() == aChain )
158 for(
PAD* p : fp->Pads() )
160 if( p->GetNet() && p->GetNet()->GetNetChain() == aChain )
179 auto board = loadBoard(
DAISY_PCB,
"kicad_chain_trunk_delay" );
180 tagChainNets( board.get(), wxS(
"DSY" ) );
181 setTerminals( board.get(), wxS(
"DSY" ), 0.0, 50.0 );
184 collectChainItems( board.get(), wxS(
"DSY" ) ) );
187 BOOST_CHECK_CLOSE( topo.
TrunkLength(), 50.0e6, 5.0 );
190 BOOST_CHECK_CLOSE( topo.
TrunkDelay(), expectedDelayIU, 5.0 );
195 BOOST_CHECK_CLOSE( bridgingDelay, topo.
TrunkDelay(), 0.001 );
196 BOOST_CHECK_CLOSE( bridgingLen, 5.0e6, 0.001 );
206 auto board = loadBoard(
DAISY_PCB,
"kicad_chain_trunk_delay_noterms" );
207 tagChainNets( board.get(), wxS(
"DSY" ) );
211 collectChainItems( board.get(), wxS(
"DSY" ) ) );
213 BOOST_CHECK( !topo.
IsValid() );
219 BOOST_CHECK_CLOSE( bridgingLen, 5.0e6, 0.001 );
222 BOOST_CHECK_CLOSE( bridgingDelay, expectedDelayIU, 0.001 );
constexpr EDA_IU_SCALE pcbIUScale
Information pertinent to a Pcbnew printed circuit board.
const NETINFO_LIST & GetNetInfo() const
const FOOTPRINTS & Footprints() const
const TRACKS & Tracks() const
Build a topological view of a single named net chain's routed copper.
double TrunkLength() const
double TrunkDelay() const
Handle the data for a net.
A #PLUGIN derivation for saving and loading Pcbnew s-expression formatted files.
BOARD * LoadBoard(const wxString &aFileName, BOARD *aAppendToMe, const std::map< std::string, UTF8 > *aProperties=nullptr, PROJECT *aProject=nullptr) override
Load information from some input file format that this PCB_IO implementation knows about into either ...
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
std::tuple< double, double > BoardChainBridging(const BOARD *aBoard, const wxString &aNetChain)
Compute both the chain bridging length and its associated propagation delay (in internal delay IU,...
constexpr double DEFAULT_PROPAGATION_DELAY_PS_PER_MM
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
static const char * DAISY_PCB
BOOST_REQUIRE(intersection.has_value()==c.ExpectedIntersection.has_value())
BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_CASE(DaisyTrunkDelayEqualsBridgeWithoutStackup)
BOOST_CHECK_EQUAL(result, "25.4")
VECTOR2< int32_t > VECTOR2I