58 virtual bool Run()
override;
60 virtual const wxString
GetName()
const override 62 return wxT(
"length" );
67 return wxT(
"Tests matched track lengths." );
94 std::vector<CONNECTION>& aMatchedConnections )
98 bool minViolation =
false;
99 bool maxViolation =
false;
114 if( ( minViolation || maxViolation ) )
121 msg.Printf(
_(
"(%s min length: %s; actual: %s)" ),
126 else if( maxViolation )
128 msg.Printf(
_(
"(%s max length: %s; actual: %s)" ),
134 drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS(
" " ) + msg );
136 for(
auto offendingTrack : ent.items )
137 drcItem->AddItem( offendingTrack );
147 std::vector<CONNECTION>& aMatchedConnections )
152 avgLength += ent.total;
154 avgLength /= aMatchedConnections.size();
156 for(
const auto& ent : aMatchedConnections )
158 int skew = ent.total - avgLength;
164 msg.Printf(
_(
"(%s max skew: %s; actual: %s; average net length: %s; actual: %s)" ),
171 drcItem->SetErrorMessage( drcItem->GetErrorText() +
" " + msg );
174 drcItem->SetItems( offendingTrack );
185 std::vector<CONNECTION>& aMatchedConnections )
187 for(
const auto& ent : aMatchedConnections )
194 msg.Printf(
_(
"(%s max count: %d; actual: %d)" ),
199 drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS(
" " ) + msg );
201 for(
auto offendingTrack : ent.items )
202 drcItem->SetItems( offendingTrack );
223 if( !aDelayReportMode )
225 if( !
reportPhase(
_(
"Gathering length-constrained connections..." ) ) )
229 std::map<DRC_RULE*, std::set<BOARD_CONNECTED_ITEM*> > itemSets;
231 auto evaluateLengthConstraints =
240 for(
int i = 0; i < 3; i++ )
245 if( constraint.IsNull() )
248 auto citem = static_cast<BOARD_CONNECTED_ITEM*>( item );
250 itemSets[ constraint.GetParentRule() ].insert( citem );
261 evaluateLengthConstraints );
263 std::map<DRC_RULE*, std::vector<CONNECTION> > matches;
265 for(
auto it : itemSets )
267 std::map<int, std::set<BOARD_CONNECTED_ITEM*> > netMap;
269 for(
auto citem : it.second )
270 netMap[ citem->GetNetCode() ].insert( citem );
273 for(
auto nitem : netMap )
276 ent.
items = nitem.second;
297 const PCB_VIA* v = static_cast<PCB_VIA*>( citem );
305 ent.
totalRoute += static_cast<PCB_TRACK*>( citem )->GetLength();
309 ent.
totalRoute += static_cast<PCB_ARC*>( citem )->GetLength();
313 ent.
totalPadToDie += static_cast<PAD*>( citem )->GetPadToDieLength();
321 auto ftPath = ftCache->QueryFromToPath( ent.
items );
325 ent.
from = ftPath->fromName;
326 ent.
to = ftPath->toName;
330 ent.
from = ent.
to =
_(
"<unconstrained>" );
334 matches[ it.first ].push_back(ent);
338 if( !aDelayReportMode )
340 for(
auto it : matches )
343 auto& matchedConnections = it.second;
345 std::sort( matchedConnections.begin(), matchedConnections.end(),
352 it.first->m_Name ) );
354 for(
auto& ent : matchedConnections )
357 "%d matching items, " 358 "total: %s (tracks: %s, vias: %s, pad-to-die: %s), " 363 (
int) ent.items.size(),
374 if( lengthConstraint )
380 checkSkews( *skewConstraint, matchedConnections );
384 if( viaCountConstraint )
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
OPT< DRC_CONSTRAINT > FindConstraint(DRC_CONSTRAINT_T aType)
wxString MessageTextFromValue(EDA_UNITS aUnits, int aValue, bool aAddUnitLabel, EDA_DATA_TYPE aType)
Convert a value to a string using double notation.
static std::shared_ptr< DRC_ITEM > Create(int aErrorCode)
Constructs a DRC_ITEM for the given error code.
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
virtual void reportViolation(std::shared_ptr< DRC_ITEM > &item, const wxPoint &aMarkerPos)
DRC_LENGTH_REPORT m_report
void checkSkews(DRC_CONSTRAINT &aConstraint, std::vector< CONNECTION > &aMatchedConnections)
int GetLayerDistance(PCB_LAYER_ID aFirstLayer, PCB_LAYER_ID aSecondLayer) const
Calculate the distance (height) between the two given copper layers.
class PCB_ARC, an arc track segment on a copper layer
const NETINFO_LIST & GetNetInfo() const
class PAD, a pad in a footprint
virtual std::set< DRC_CONSTRAINT_T > GetConstraintTypes() const override
bool runInternal(bool aDelayReportMode=false)
PCB_LAYER_ID BottomLayer() const
A base class derived from BOARD_ITEM for items that can be connected and have a net,...
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
virtual void reportRuleStatistics()
virtual bool Run() override
Run this provider against the given PCB with configured options (if any).
class PCB_TRACK, a track segment (segment on a copper layer)
static DRC_REGISTER_TEST_PROVIDER< DRC_TEST_PROVIDER_ANNULAR_WIDTH > dummy
void checkLengths(DRC_CONSTRAINT &aConstraint, std::vector< CONNECTION > &aMatchedConnections)
void Add(const ENTRY &ent)
DRC_RULE * GetParentRule() const
BOARD_STACKUP & GetStackupDescriptor()
PCB_LAYER_ID TopLayer() const
BOARD_CONNECTED_ITEM * fromItem
virtual const wxString GetName() const override
virtual bool reportPhase(const wxString &aStageName)
DRC_LENGTH_REPORT BuildLengthReport() const
std::shared_ptr< CONNECTIVITY_DATA > GetConnectivity() const
Return a list of missing connections between components/tracks.
const wxString & GetNetname() const
void checkViaCounts(DRC_CONSTRAINT &aConstraint, std::vector< CONNECTION > &aMatchedConnections)
EDA_UNITS userUnits() const
virtual const wxString GetDescription() const override
DRC_CONSTRAINT EvalRules(DRC_CONSTRAINT_T aConstraintType, const BOARD_ITEM *a, const BOARD_ITEM *b, PCB_LAYER_ID aLayer, REPORTER *aReporter=nullptr)
virtual ~DRC_TEST_PROVIDER_MATCHED_LENGTH()
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
virtual int GetNumPhases() const override
int forEachGeometryItem(const std::vector< KICAD_T > &aTypes, LSET aLayers, const std::function< bool(BOARD_ITEM *)> &aFunc)
Represent a DRC "provider" which runs some DRC functions over a BOARD and spits out #DRC_ITEMs and po...
bool m_UseHeightForLengthCalcs
Enable inclusion of stackup height in track length measurements and length tuning.
const MINOPTMAX< int > & GetValue() const
Information pertinent to a Pcbnew printed circuit board.
BOARD_CONNECTED_ITEM * toItem
std::set< BOARD_CONNECTED_ITEM * > items
class PCB_VIA, a via (like a track segment on a copper layer)
DRC_TEST_PROVIDER_MATCHED_LENGTH()
NETINFO_ITEM * GetNetItem(int aNetCode) const
virtual void reportAux(wxString fmt,...)
KICAD_T Type() const
Returns the type of object.
Container for design settings for a BOARD object.