2016-01-29 10:24:39 +00:00
|
|
|
/**
|
|
|
|
* @file board_netlist_updater.h
|
|
|
|
* @brief BOARD_NETLIST_UPDATER class definition
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
|
|
|
* Copyright (C) 2015 CERN
|
|
|
|
* Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
|
|
|
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
|
|
|
|
*
|
2021-01-27 22:15:38 +00:00
|
|
|
* Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors.
|
2016-01-29 10:24:39 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __BOARD_NETLIST_UPDATER_H
|
|
|
|
#define __BOARD_NETLIST_UPDATER_H
|
|
|
|
|
|
|
|
class BOARD;
|
|
|
|
class REPORTER;
|
|
|
|
class NETLIST;
|
|
|
|
class COMPONENT;
|
2020-11-13 15:15:52 +00:00
|
|
|
class FOOTPRINT;
|
2016-01-29 10:24:39 +00:00
|
|
|
class PCB_EDIT_FRAME;
|
|
|
|
|
2016-09-05 13:38:01 +00:00
|
|
|
#include <board_commit.h>
|
2016-01-29 10:24:39 +00:00
|
|
|
|
|
|
|
/**
|
2021-01-27 22:15:38 +00:00
|
|
|
* Update the #BOARD with a new netlist.
|
2016-01-29 10:24:39 +00:00
|
|
|
*
|
|
|
|
* The changes are made to the board are as follows they are not disabled in the status
|
|
|
|
* settings in the #NETLIST:
|
|
|
|
* - If a new component is found in the #NETLIST and not in the #BOARD, it is added
|
|
|
|
* to the #BOARD.
|
|
|
|
* - If a the component in the #NETLIST is already on the #BOARD, then one or more of the
|
|
|
|
* following actions can occur:
|
|
|
|
* + If the footprint name in the #NETLIST does not match the footprint name on the
|
|
|
|
* #BOARD, the footprint on the #BOARD is replaced with the footprint specified in
|
|
|
|
* the #NETLIST and the proper parameters are copied from the existing footprint.
|
|
|
|
* + If the reference designator in the #NETLIST does not match the reference designator
|
|
|
|
* on the #BOARD, the reference designator is updated from the #NETLIST.
|
|
|
|
* + If the value field in the #NETLIST does not match the value field on the #BOARD,
|
|
|
|
* the value field is updated from the #NETLIST.
|
|
|
|
* + If the time stamp in the #NETLIST does not match the time stamp on the #BOARD,
|
|
|
|
* the time stamp is updated from the #NETLIST.
|
|
|
|
* - After each footprint is added or update as described above, each footprint pad net
|
|
|
|
* name is compared and updated to the value defined in the #NETLIST.
|
2019-11-17 09:11:29 +00:00
|
|
|
* - After all of the footprints have been added, updated, and net names and
|
|
|
|
* pin function properly set, any extra unlock footprints are removed
|
|
|
|
* from the #BOARD.
|
2016-01-29 10:24:39 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
class BOARD_NETLIST_UPDATER
|
|
|
|
{
|
|
|
|
public:
|
2016-09-02 13:53:51 +00:00
|
|
|
BOARD_NETLIST_UPDATER( PCB_EDIT_FRAME* aFrame, BOARD* aBoard );
|
|
|
|
~BOARD_NETLIST_UPDATER();
|
|
|
|
|
|
|
|
/**
|
2021-01-27 22:15:38 +00:00
|
|
|
* Update the board's components according to the new netlist.
|
|
|
|
*
|
|
|
|
* See #BOARD_NETLIST_UPDATER class description for the details of the process.
|
2016-09-02 13:53:51 +00:00
|
|
|
*
|
|
|
|
* @param aNetlist the new netlist
|
|
|
|
* @return true if process was completed successfully
|
|
|
|
*/
|
|
|
|
bool UpdateNetlist( NETLIST& aNetlist );
|
|
|
|
|
2021-05-23 21:21:34 +00:00
|
|
|
void SetReporter( REPORTER* aReporter ) { m_reporter = aReporter; }
|
|
|
|
|
|
|
|
///< Enable dry run mode (just report, no changes to PCB).
|
|
|
|
void SetIsDryRun( bool aEnabled ) { m_isDryRun = aEnabled; }
|
|
|
|
|
|
|
|
void SetDeleteSinglePadNets( bool aEnabled ) { m_deleteSinglePadNets = aEnabled; }
|
2016-09-02 13:53:51 +00:00
|
|
|
|
2021-01-27 22:15:38 +00:00
|
|
|
///< Enable warning option if a connectable pad is not found in netlist
|
|
|
|
///< connectable = pad with a name and on a copper layer.
|
2021-05-23 21:21:34 +00:00
|
|
|
void SetWarnPadNoNetInNetlist( bool aEnabled ) { m_warnForNoNetPads = aEnabled; }
|
2019-11-17 15:37:32 +00:00
|
|
|
|
2021-05-23 21:21:34 +00:00
|
|
|
void SetReplaceFootprints( bool aEnabled ) { m_replaceFootprints = aEnabled; }
|
|
|
|
|
|
|
|
void SetDeleteUnusedFootprints( bool aEnabled ) { m_deleteUnusedFootprints = aEnabled; }
|
|
|
|
|
|
|
|
void SetLookupByTimestamp( bool aEnabled ) { m_lookupByTimestamp = aEnabled; }
|
|
|
|
|
|
|
|
std::vector<FOOTPRINT*> GetAddedFootprints() const { return m_addedFootprints; }
|
2016-01-29 14:43:40 +00:00
|
|
|
|
2016-01-29 10:24:39 +00:00
|
|
|
private:
|
2020-11-12 22:30:02 +00:00
|
|
|
void cacheNetname( PAD* aPad, const wxString& aNetname );
|
|
|
|
wxString getNetname( PAD* aPad );
|
2018-05-01 12:52:11 +00:00
|
|
|
|
2020-11-12 22:30:02 +00:00
|
|
|
void cachePinFunction( PAD* aPad, const wxString& aPinFunction );
|
|
|
|
wxString getPinFunction( PAD* aPad );
|
2019-11-17 09:11:29 +00:00
|
|
|
|
2021-05-23 21:21:34 +00:00
|
|
|
wxPoint estimateFootprintInsertionPosition();
|
2020-11-13 15:15:52 +00:00
|
|
|
|
2021-05-23 21:21:34 +00:00
|
|
|
FOOTPRINT* addNewFootprint( COMPONENT* aComponent );
|
2020-11-13 15:15:52 +00:00
|
|
|
|
2021-05-23 21:21:34 +00:00
|
|
|
FOOTPRINT* replaceFootprint( NETLIST& aNetlist, FOOTPRINT* aFootprint,
|
2020-11-13 15:15:52 +00:00
|
|
|
COMPONENT* aNewComponent );
|
|
|
|
|
2020-12-07 15:50:04 +00:00
|
|
|
bool updateFootprintParameters( FOOTPRINT* aPcbFootprint, COMPONENT* aNetlistComponent );
|
2020-11-13 15:15:52 +00:00
|
|
|
|
2021-01-15 12:30:22 +00:00
|
|
|
bool updateComponentPadConnections( FOOTPRINT* aFootprint, COMPONENT* aNewComponent );
|
2020-11-13 15:15:52 +00:00
|
|
|
|
2018-05-01 12:52:11 +00:00
|
|
|
void cacheCopperZoneConnections();
|
2020-11-13 15:15:52 +00:00
|
|
|
|
2018-05-01 12:52:11 +00:00
|
|
|
bool updateCopperZoneNets( NETLIST& aNetlist );
|
2020-11-13 15:15:52 +00:00
|
|
|
|
2016-09-02 13:53:51 +00:00
|
|
|
bool deleteSinglePadNets();
|
2020-11-13 15:15:52 +00:00
|
|
|
|
2020-11-13 17:04:34 +00:00
|
|
|
bool testConnectivity( NETLIST& aNetlist, std::map<COMPONENT*, FOOTPRINT*>& aFootprintMap );
|
2016-01-29 10:24:39 +00:00
|
|
|
|
2018-08-20 00:54:22 +00:00
|
|
|
PCB_EDIT_FRAME* m_frame;
|
|
|
|
BOARD_COMMIT m_commit;
|
|
|
|
BOARD* m_board;
|
|
|
|
REPORTER* m_reporter;
|
2016-01-29 10:24:39 +00:00
|
|
|
|
2020-11-12 22:30:02 +00:00
|
|
|
std::map<ZONE*, std::vector<PAD*>> m_zoneConnectionsCache;
|
|
|
|
std::map<wxString, wxString> m_oldToNewNets;
|
|
|
|
std::map<PAD*, wxString> m_padNets;
|
|
|
|
std::map<PAD*, wxString> m_padPinFunctions;
|
2021-05-23 21:21:34 +00:00
|
|
|
std::vector<FOOTPRINT*> m_addedFootprints;
|
2020-11-12 22:30:02 +00:00
|
|
|
std::map<wxString, NETINFO_ITEM*> m_addedNets;
|
2016-01-29 14:43:40 +00:00
|
|
|
|
2016-09-02 13:53:51 +00:00
|
|
|
bool m_deleteSinglePadNets;
|
2021-05-23 21:21:34 +00:00
|
|
|
bool m_deleteUnusedFootprints;
|
2016-09-02 13:53:51 +00:00
|
|
|
bool m_isDryRun;
|
|
|
|
bool m_replaceFootprints;
|
|
|
|
bool m_lookupByTimestamp;
|
2021-01-27 22:15:38 +00:00
|
|
|
bool m_warnForNoNetPads; // Warn if a connectable pad has no net in netlist (not found).
|
2016-01-29 10:24:39 +00:00
|
|
|
|
2016-09-02 13:53:51 +00:00
|
|
|
int m_warningCount;
|
|
|
|
int m_errorCount;
|
2019-04-17 08:54:00 +00:00
|
|
|
int m_newFootprintsCount; // the count of new footprints
|
|
|
|
// either really new or replaced by new fp.
|
2016-01-29 10:24:39 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|