56 virtual bool Run()
override;
58 virtual const wxString
GetName()
const override 65 return "Tests matched track lengths.";
82 typedef std::set<BOARD_CONNECTED_ITEM*>
CITEMS;
105 bool minViolation =
false;
106 bool maxViolation =
false;
121 if( ( minViolation || maxViolation ) )
127 m_msg.Printf(
_(
"(%s min length: %s; actual: %s)" ),
132 else if( maxViolation )
134 m_msg.Printf(
_(
"(%s max length: %s; actual: %s)" ),
140 drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS(
" " ) +
m_msg );
142 for(
auto offendingTrack : ent.items )
143 drcItem->AddItem( offendingTrack );
158 avgLength += ent.total;
160 avgLength /= matchedConnections.size();
162 for(
const auto& ent : matchedConnections )
164 int skew = ent.total - avgLength;
169 m_msg.Printf(
_(
"(%s max skew: %s; actual: %s; average net length: %s; actual: %s)" ),
176 drcItem->SetErrorMessage( drcItem->GetErrorText() +
" " +
m_msg );
179 drcItem->SetItems( offendingTrack );
192 for(
const auto& ent : matchedConnections )
198 m_msg.Printf(
_(
"(%s max count: %d; actual: %d)" ),
203 drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS(
" " ) +
m_msg );
205 for(
auto offendingTrack : ent.items )
206 drcItem->SetItems( offendingTrack );
227 if( !aDelayReportMode )
229 if( !
reportPhase(
_(
"Gathering length-constrained connections..." ) ) )
233 std::map<DRC_RULE*, CITEMS> itemSets;
235 auto evaluateLengthConstraints =
244 for(
int i = 0; i < 3; i++ )
249 if( constraint.IsNull() )
252 auto citem = static_cast<BOARD_CONNECTED_ITEM*>( item );
254 itemSets[ constraint.GetParentRule() ].insert( citem );
265 evaluateLengthConstraints );
267 std::map<DRC_RULE*, LENGTH_ENTRIES> matches;
269 for(
auto it : itemSets )
271 std::map<int, CITEMS> netMap;
273 for(
auto citem : it.second )
274 netMap[ citem->GetNetCode() ].insert( citem );
277 for(
auto nitem : netMap )
280 ent.
items = nitem.second;
300 ent.
totalRoute += static_cast<TRACK*>( citem )->GetLength();
304 ent.
totalRoute += static_cast<ARC*>( citem )->GetLength();
308 ent.
totalPadToDie += static_cast<PAD*>( citem )->GetPadToDieLength();
316 auto ftPath = ftCache->QueryFromToPath( ent.
items );
320 ent.
from = ftPath->fromName;
321 ent.
to = ftPath->toName;
325 ent.
from = ent.
to =
_(
"<unconstrained>");
329 matches[ it.first ].push_back(ent);
333 if( !aDelayReportMode )
335 for(
auto it : matches )
338 auto& matchedConnections = it.second;
340 std::sort( matchedConnections.begin(), matchedConnections.end(),
347 it.first->m_Name ) );
349 for(
auto& ent : matchedConnections )
352 "%d matching items, " 353 "total: %s (tracks: %s, vias: %s, pad-to-die: %s), " 358 (
int) ent.items.size(),
369 if( lengthConstraint )
379 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...
void checkSkewViolations(DRC_CONSTRAINT &aConstraint, LENGTH_ENTRIES &aMatchedConnections)
DRC_LENGTH_REPORT m_report
static DRC_REGISTER_TEST_PROVIDER< DRC_TEST_PROVIDER_ANNULUS > dummy
void checkViaCountViolations(DRC_CONSTRAINT &aConstraint, LENGTH_ENTRIES &aMatchedConnections)
std::vector< LENGTH_ENTRY > LENGTH_ENTRIES
class ARC, an arc track segment on a copper layer
static int computeViaThruLength(VIA *aVia, const std::set< BOARD_CONNECTED_ITEM * > &conns)
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)
A base class derived from BOARD_ITEM for items that can be connected and have a net,...
virtual void reportRuleStatistics()
virtual bool Run() override
Runs this provider against the given PCB with configured options (if any).
class TRACK, a track segment (segment on a copper layer)
void Add(const ENTRY &ent)
DRC_RULE * GetParentRule() const
std::set< BOARD_CONNECTED_ITEM * > CITEMS
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
EDA_UNITS userUnits() const
void checkLengthViolations(DRC_CONSTRAINT &aConstraint, LENGTH_ENTRIES &aMatchedConnections)
virtual const wxString GetDescription() const override
DRC_CONSTRAINT EvalRules(DRC_CONSTRAINT_T aConstraintId, 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
virtual void reportViolation(std::shared_ptr< DRC_ITEM > &item, wxPoint aMarkerPos)
int forEachGeometryItem(const std::vector< KICAD_T > &aTypes, LSET aLayers, const std::function< bool(BOARD_ITEM *)> &aFunc)
DRC_TEST_PROVIDER is a base class that represents a DRC "provider" which runs some DRC functions over...
const MINOPTMAX< int > & GetValue() const
Information pertinent to a Pcbnew printed circuit board.
BOARD_CONNECTED_ITEM * toItem
class 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.