57 virtual bool Run()
override;
59 virtual const wxString
GetName()
const override
61 return wxT(
"length" );
66 return wxT(
"Tests matched track lengths." );
78 const std::vector<CONNECTION>& aMatchedConnections );
80 const std::vector<CONNECTION>& aMatchedConnections );
82 const std::vector<CONNECTION>& aMatchedConnections );
89 const std::vector<CONNECTION>& aMatchedConnections )
93 bool minViolation =
false;
94 bool maxViolation =
false;
109 if( ( minViolation || maxViolation ) )
116 msg =
formatMsg(
_(
"(%s min length %s; actual %s)" ),
121 else if( maxViolation )
123 msg =
formatMsg(
_(
"(%s max length %s; actual %s)" ),
129 drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS(
" " ) + msg );
131 for(
auto offendingTrack : ent.items )
132 drcItem->AddItem( offendingTrack );
137 ( *ent.items.begin() )->GetLayer() );
143 const std::vector<CONNECTION>& aMatchedConnections )
148 avgLength += ent.total;
150 avgLength /= aMatchedConnections.size();
152 for(
const auto& ent : aMatchedConnections )
154 int skew = ent.total - avgLength;
160 msg.Printf(
_(
"(%s max skew %s; actual %s; average net length %s; actual %s)" ),
167 drcItem->SetErrorMessage( drcItem->GetErrorText() +
" " + msg );
170 drcItem->SetItems( offendingTrack );
175 ( *ent.items.begin() )->GetLayer() );
182 const std::vector<CONNECTION>& aMatchedConnections )
184 for(
const auto& ent : aMatchedConnections )
189 wxString msg = wxString::Format(
_(
"(%s max count %d; actual %d)" ),
194 drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS(
" " ) + msg );
196 for(
auto offendingTrack : ent.items )
197 drcItem->SetItems( offendingTrack );
202 ( *ent.items.begin() )->GetLayer() );
219 if( !aDelayReportMode )
221 if( !
reportPhase(
_(
"Gathering length-constrained connections..." ) ) )
225 std::map<DRC_RULE*, std::set<BOARD_CONNECTED_ITEM*> > itemSets;
231 const size_t progressDelta = 100;
254 for(
int i = 0; i < 3; i++ )
259 if( constraint.IsNull() )
264 itemSets[ constraint.GetParentRule() ].insert( citem );
270 std::map< DRC_RULE*, std::vector<CONNECTION> > matches;
272 for(
const std::pair<
DRC_RULE*
const, std::set<BOARD_CONNECTED_ITEM*> >& it : itemSets )
274 std::map<int, std::set<BOARD_CONNECTED_ITEM*> > netMap;
277 netMap[ citem->
GetNetCode() ].insert( citem );
279 for(
const std::pair<
const int, std::set<BOARD_CONNECTED_ITEM*> >& nitem : netMap )
282 ent.
items = nitem.second;
327 auto ftPath = ftCache->QueryFromToPath( ent.
items );
331 ent.
from = ftPath->fromName;
332 ent.
to = ftPath->toName;
336 ent.
from = ent.
to =
_(
"<unconstrained>" );
340 matches[ it.first ].push_back(ent);
344 if( !aDelayReportMode )
346 if( !
reportPhase(
_(
"Checking length constraints..." ) ) )
350 count = matches.size();
352 for( std::pair<
DRC_RULE*
const, std::vector<CONNECTION> > it : matches )
355 auto& matchedConnections = it.second;
360 std::sort( matchedConnections.begin(), matchedConnections.end(),
363 return a.netname < b.netname;
366 reportAux( wxString::Format( wxT(
"Length-constrained traces for rule '%s':" ),
367 it.first->m_Name ) );
371 reportAux(wxString::Format( wxT(
" - net: %s, from: %s, to: %s, "
372 "%d matching items, "
373 "total: %s (tracks: %s, vias: %s, pad-to-die: %s), "
378 (
int) ent.items.size(),
395 checkSkews( *skewConstraint, matchedConnections );
A base class derived from BOARD_ITEM for items that can be connected and have a net,...
Container for design settings for a BOARD object.
BOARD_STACKUP & GetStackupDescriptor()
bool m_UseHeightForLengthCalcs
Enable inclusion of stackup height in track length measurements and length tuning.
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Manage layers needed to make a physical board.
int GetLayerDistance(PCB_LAYER_ID aFirstLayer, PCB_LAYER_ID aSecondLayer) const
Calculate the distance (height) between the two given copper layers.
Information pertinent to a Pcbnew printed circuit board.
const NETINFO_LIST & GetNetInfo() const
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
std::shared_ptr< CONNECTIVITY_DATA > GetConnectivity() const
Return a list of missing connections between components/tracks.
const MINOPTMAX< int > & GetValue() const
DRC_RULE * GetParentRule() const
DRC_CONSTRAINT EvalRules(DRC_CONSTRAINT_T aConstraintType, const BOARD_ITEM *a, const BOARD_ITEM *b, PCB_LAYER_ID aLayer, REPORTER *aReporter=nullptr)
static std::shared_ptr< DRC_ITEM > Create(int aErrorCode)
Constructs a DRC_ITEM for the given error code.
void Add(const ENTRY &ent)
std::optional< DRC_CONSTRAINT > FindConstraint(DRC_CONSTRAINT_T aType)
bool runInternal(bool aDelayReportMode=false)
virtual const wxString GetName() const override
virtual ~DRC_TEST_PROVIDER_MATCHED_LENGTH()
void checkSkews(const DRC_CONSTRAINT &aConstraint, const std::vector< CONNECTION > &aMatchedConnections)
virtual const wxString GetDescription() const override
void checkViaCounts(const DRC_CONSTRAINT &aConstraint, const std::vector< CONNECTION > &aMatchedConnections)
DRC_LENGTH_REPORT m_report
virtual bool Run() override
Run this provider against the given PCB with configured options (if any).
DRC_TEST_PROVIDER_MATCHED_LENGTH()
DRC_LENGTH_REPORT BuildLengthReport() const
void checkLengths(const DRC_CONSTRAINT &aConstraint, const std::vector< CONNECTION > &aMatchedConnections)
Represent a DRC "provider" which runs some DRC functions over a BOARD and spits out DRC_ITEM and posi...
virtual bool reportPhase(const wxString &aStageName)
int forEachGeometryItem(const std::vector< KICAD_T > &aTypes, LSET aLayers, const std::function< bool(BOARD_ITEM *)> &aFunc)
virtual bool reportProgress(int aCount, int aSize, int aDelta)
virtual void reportViolation(std::shared_ptr< DRC_ITEM > &item, const VECTOR2I &aMarkerPos, int aMarkerLayer)
void reportAux(const wxString &aMsg)
wxString formatMsg(const wxString &aFormatString, const wxString &aSource, int aConstraint, int aActual)
virtual void reportRuleStatistics()
KICAD_T Type() const
Returns the type of object.
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
const wxString & GetNetname() const
NETINFO_ITEM * GetNetItem(int aNetCode) const
PCB_LAYER_ID BottomLayer() const
PCB_LAYER_ID TopLayer() const
wxString MessageTextFromValue(double aValue, bool aAddUnitLabel=true, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE)
A lower-precision version of StringFromValue().
@ DRCE_LENGTH_OUT_OF_RANGE
static DRC_REGISTER_TEST_PROVIDER< DRC_TEST_PROVIDER_ANNULAR_WIDTH > dummy
BOARD_CONNECTED_ITEM * fromItem
BOARD_CONNECTED_ITEM * toItem
std::set< BOARD_CONNECTED_ITEM * > items
@ PCB_VIA_T
class PCB_VIA, a via (like a track segment on a copper layer)
@ PCB_PAD_T
class PAD, a pad in a footprint
@ PCB_ARC_T
class PCB_ARC, an arc track segment on a copper layer
@ PCB_TRACE_T
class PCB_TRACK, a track segment (segment on a copper layer)