KiCad PCB EDA Suite
Loading...
Searching...
No Matches
drc_test_provider_net_chain_tuning_profiles.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright The KiCad Developers.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
20#include <thread_pool.h>
21#include "geometry/eda_angle.h"
22#include <numbers>
23#include <pcb_track.h>
24#include <drc/drc_engine.h>
25#include <drc/drc_item.h>
26#include <drc/drc_rule.h>
29
30
31/*
32 Net chain tuning profile checks. Ensures that all nets in a net chain
33 have a consistent tuning profile assigned
34*/
35
37{
38public:
40
42
43 virtual bool Run() override;
44
45 virtual const wxString GetName() const override { return wxT( "net chain tuning profiles" ); };
46};
47
48
50{
51 if( m_drcEngine->IsErrorLimitExceeded( DRCE_NET_CHAIN_TUNING_PROFILES ) )
52 {
53 REPORT_AUX( wxT( "Net chain tuning profiles ignored. Tests not run." ) );
54 return true; // continue with other tests
55 }
56
57 if( !reportPhase( _( "Checking net chain tuning profiles..." ) ) )
58 return false; // DRC cancelled
59
60 // Map of netchains to all declared tuning profile names that are a member of that net
61
62 const NETINFO_LIST& netsList = m_drcEngine->GetBoard()->GetNetInfo();
63
64 // Map of net chain name : net chain nets tuning profiles names
65 std::unordered_map<wxString, std::unordered_set<wxString>> netChainTuningProfileMap;
66
67 for( const auto net : netsList )
68 {
69 const wxString& netChain = net->GetNetChain();
70
71 if( netChain == wxEmptyString )
72 continue;
73
74 const NETCLASS* netClass = net->GetNetClass();
75 netChainTuningProfileMap[netChain].insert( netClass->GetTuningProfile() );
76 }
77
78 for( const auto& [netChain, tuningProfiles] : netChainTuningProfileMap )
79 {
80 if( tuningProfiles.size() == 1 )
81 continue;
82
83 if( !m_drcEngine->IsErrorLimitExceeded( DRCE_NET_CHAIN_TUNING_PROFILES ) )
84 {
85 wxString msg;
86 msg.Printf( _( "Net chain %s nets have multiple tuning profiles assigned" ), netChain );
87
88 std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( DRCE_NET_CHAIN_TUNING_PROFILES );
89
90 drcItem->SetErrorMessage( msg );
92 }
93 }
94
95 return !m_drcEngine->IsCancelled();
96}
97
98
99namespace detail
100{
102}
static std::shared_ptr< DRC_ITEM > Create(int aErrorCode)
Constructs a DRC_ITEM for the given error code.
Definition drc_item.cpp:418
virtual ~DRC_TEST_PROVIDER_NET_CHAIN_TUNING_PROFILES()=default
virtual bool Run() override
Run this provider against the given PCB with configured options (if any).
virtual bool reportPhase(const wxString &aStageName)
void reportViolation(std::shared_ptr< DRC_ITEM > &item, const VECTOR2I &aMarkerPos, int aMarkerLayer, const std::function< void(PCB_MARKER *)> &aPathGenerator=[](PCB_MARKER *){})
A collection of nets and the parameters used to route or test these nets.
Definition netclass.h:38
wxString GetTuningProfile() const
Definition netclass.h:252
Container for NETINFO_ITEM elements, which are the nets.
Definition netinfo.h:221
@ DRCE_NET_CHAIN_TUNING_PROFILES
Definition drc_item.h:105
#define REPORT_AUX(s)
#define _(s)
@ UNDEFINED_LAYER
Definition layer_ids.h:57
static DRC_REGISTER_TEST_PROVIDER< DRC_TEST_PROVIDER_ANNULAR_WIDTH > dummy
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:683