21#include <boost/test/unit_test.hpp>
47 (generator_version "9.99")
56 (gr_line (start -5 -5) (end 60 -5) (layer "Edge.Cuts") (width 0.05))
57 (gr_line (start 60 -5) (end 60 5) (layer "Edge.Cuts") (width 0.05))
58 (gr_line (start 60 5) (end -5 5) (layer "Edge.Cuts") (width 0.05))
59 (gr_line (start -5 5) (end -5 -5) (layer "Edge.Cuts") (width 0.05))
60 (footprint "Term1" (layer "F.Cu") (uuid "00000000-0000-0000-0000-000000000a01")
62 (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"))
64 (footprint "Bridge" (layer "F.Cu") (uuid "00000000-0000-0000-0000-000000000b01")
66 (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"))
67 (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"))
69 (footprint "Term2" (layer "F.Cu") (uuid "00000000-0000-0000-0000-000000000c01")
71 (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"))
73 (segment (start 0 0) (end 20 0) (width 0.2) (layer "F.Cu") (net 1))
74 (segment (start 25 0) (end 50 0) (width 0.2) (layer "F.Cu") (net 2))
81std::unique_ptr<BOARD> loadBoard(
const char* aText,
const std::string& aSubdir )
83 namespace fs = std::filesystem;
84 fs::path tmpDir = fs::temp_directory_path() / aSubdir;
85 fs::create_directories( tmpDir );
86 fs::path pcbPath = tmpDir /
"trunk_delay.kicad_pcb";
89 std::ofstream out( pcbPath );
94 std::unique_ptr<BOARD> board = std::make_unique<BOARD>();
95 plugin.
LoadBoard( pcbPath.string(), board.get() );
96 board->BuildConnectivity();
97 fs::remove( pcbPath );
102void tagChainNets(
BOARD* aBoard,
const wxString& aChain )
106 if( n && n->GetNetname().StartsWith( wxS(
"/NET_" ) ) )
107 n->SetNetChain( aChain );
112void setTerminals(
BOARD* aBoard,
const wxString& aChain,
double aTermAxMm,
double aTermBxMm )
114 PAD* termA =
nullptr;
115 PAD* termB =
nullptr;
116 constexpr int EPS = 100;
117 const VECTOR2I targetA(
static_cast<int>( aTermAxMm * 1000000 ), 0 );
118 const VECTOR2I targetB(
static_cast<int>( aTermBxMm * 1000000 ), 0 );
122 if( fp->Pads().empty() )
128 termA = fp->Pads().front();
131 termB = fp->Pads().front();
136 if( n && n->GetNetChain() == aChain )
139 n->SetTerminalPad( 0, termA );
141 n->SetTerminalPad( 1, termB );
147std::set<BOARD_CONNECTED_ITEM*> collectChainItems(
BOARD* aBoard,
const wxString& aChain )
149 std::set<BOARD_CONNECTED_ITEM*> items;
153 if( t->GetNet() && t->GetNet()->GetNetChain() == aChain )
159 for(
PAD* p : fp->Pads() )
161 if( p->GetNet() && p->GetNet()->GetNetChain() == aChain )
180 auto board = loadBoard(
DAISY_PCB,
"kicad_chain_trunk_delay" );
181 tagChainNets( board.get(), wxS(
"DSY" ) );
182 setTerminals( board.get(), wxS(
"DSY" ), 0.0, 50.0 );
185 collectChainItems( board.get(), wxS(
"DSY" ) ) );
188 BOOST_CHECK_CLOSE( topo.
TrunkLength(), 50.0e6, 5.0 );
191 BOOST_CHECK_CLOSE( topo.
TrunkDelay(), expectedDelayIU, 5.0 );
196 BOOST_CHECK_CLOSE( bridgingDelay, topo.
TrunkDelay(), 0.001 );
197 BOOST_CHECK_CLOSE( bridgingLen, 5.0e6, 0.001 );
207 auto board = loadBoard(
DAISY_PCB,
"kicad_chain_trunk_delay_noterms" );
208 tagChainNets( board.get(), wxS(
"DSY" ) );
212 collectChainItems( board.get(), wxS(
"DSY" ) ) );
214 BOOST_CHECK( !topo.
IsValid() );
220 BOOST_CHECK_CLOSE( bridgingLen, 5.0e6, 0.001 );
223 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