KiCad PCB EDA Suite
Loading...
Searching...
No Matches
netlist_exporter_allegro.h
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 (C) 1992-2013 jp.charras at wanadoo.fr
5 * Copyright (C) 2013 SoftPLC Corporation, Dick Hollenbeck <[email protected]>
6 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <https://www.gnu.org/licenses/>.
20 */
21
22#ifndef NETLIST_EXPORTER_ALLEGRO_H
23#define NETLIST_EXPORTER_ALLEGRO_H
24
26#include <list>
27#include <sch_pin.h>
28#include <symbol.h>
29
34{
35public:
36 NETLIST_EXPORTER_ALLEGRO( SCHEMATIC* aSchematic, KIWAY* aKiway ) :
37 NETLIST_EXPORTER_BASE( aSchematic, aKiway ),
38 m_f( nullptr )
39 {
40 }
41
46 bool writeNetlist( const wxString& aOutFileName, unsigned aNetlistOptions, REPORTER& aReporter ) override;
47
55 static bool CompareSymbolSheetpath( const std::pair<SCH_SYMBOL*, SCH_SHEET_PATH>& aItem1,
56 const std::pair<SCH_SYMBOL*, SCH_SHEET_PATH>& aItem2 );
57
65 static bool CompareSymbolRef( const wxString& aRefText1, const wxString& aRefText2 );
66
74 static bool CompareLibPin( const SCH_PIN* aPin1, const SCH_PIN* aPin2 );
75
87 static wxString formatRoom( const SCH_SHEET_PATH& aSheetPath );
88
89private:
91
96 bool toAllegroPackages();
97
102 void toAllegroNets();
103
109
120 wxString formatDevice( wxString aString );
121
132 wxString formatText( wxString aString );
133
146 wxString formatPin( const SCH_PIN& aPin );
147
156 wxString formatFunction( wxString aName, std::vector<SCH_PIN*> aPinList );
157
169 wxString getGroupField( int aGroupIndex, const wxArrayString& aFieldArray, bool aSanitize = true );
170
177 static wxString removeTailDigits( wxString aString );
178
185 static unsigned int extractTailNumber( wxString aString );
186
187 struct NET_NODE
188 {
189 NET_NODE( SCH_PIN* aPin, const SCH_SHEET_PATH& aSheet ) :
190 m_Pin( aPin ),
191 m_Sheet( aSheet )
192 {}
193
194 bool operator<( const NET_NODE& aNetNode ) const
195 {
196 wxString refText1 = m_Pin->GetParentSymbol()->GetRef( &m_Sheet );
197 wxString refText2 = aNetNode.m_Pin->GetParentSymbol()->GetRef( &aNetNode.m_Sheet );
198
199 if( refText1 == refText2 )
200 {
201 unsigned long val1, val2;
202
203 //From wxWidgets 3.1.6, the function ToULong can be replaced with ToUInt
204 bool convertingResult = m_Pin->GetShownNumber().ToULong( &val1 );
205 convertingResult &= aNetNode.m_Pin->GetShownNumber().ToULong( &val2 );
206
207 if( convertingResult )
208 {
209 return val1 < val2;
210 }
211 else
212 {
213 return m_Pin->GetShownNumber() < aNetNode.m_Pin->GetShownNumber();
214 }
215 }
216
217 return CompareSymbolRef( refText1, refText2 );
218 }
219
222 };
223
224 FILE* m_f ;
225 wxString m_exportPath;
226 std::multimap<wxString, wxString> m_packageProperties;
227
229 std::multimap<int, std::pair<SCH_SYMBOL*, SCH_SHEET_PATH> > m_componentGroups;
230
232 std::list<std::pair<SCH_SYMBOL*, SCH_SHEET_PATH>> m_orderedSymbolsSheetpath;
233 std::multimap<wxString, NET_NODE> m_netNameNodes;
234};
235
236#endif
A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad...
Definition kiway.h:348
bool toAllegroPackages()
Write the $PACKAGES section.
static wxString formatRoom(const SCH_SHEET_PATH &aSheetPath)
Generate an Allegro room name from a sheet path.
wxString formatDevice(wxString aString)
Convert a string into one safe for a Telesis device name.
wxString m_exportPath
Directory to store device files.
static unsigned int extractTailNumber(wxString aString)
Extract the str's tailing number.
NETLIST_EXPORTER_ALLEGRO(SCHEMATIC *aSchematic, KIWAY *aKiway)
FILE * m_f
File pointer for netlist file writing operation.
static wxString removeTailDigits(wxString aString)
Remove the str's tailing digits.
void toAllegroPackageProperties()
Write $A_PROPERTIES section.
std::list< std::pair< SCH_SYMBOL *, SCH_SHEET_PATH > > m_orderedSymbolsSheetpath
Store the ordered symbols with sheetpath.
bool writeNetlist(const wxString &aOutFileName, unsigned aNetlistOptions, REPORTER &aReporter) override
Write netlist to aOutFileName.
static bool CompareSymbolSheetpath(const std::pair< SCH_SYMBOL *, SCH_SHEET_PATH > &aItem1, const std::pair< SCH_SYMBOL *, SCH_SHEET_PATH > &aItem2)
Compare two std::pair<SCH_SYMBOL*, SCH_SHEET_PATH> variables.
wxString formatText(wxString aString)
Convert a string into Telesis-safe format.
std::multimap< wxString, wxString > m_packageProperties
wxString formatFunction(wxString aName, std::vector< SCH_PIN * > aPinList)
Generate the definition of a function in Telesis format, which consists of multiple declarations (PIN...
static bool CompareLibPin(const SCH_PIN *aPin1, const SCH_PIN *aPin2)
Compare two SCH_PIN* variables.
wxString formatPin(const SCH_PIN &aPin)
Generate a Telesis-compatible pin name from a pin node.
static bool CompareSymbolRef(const wxString &aRefText1, const wxString &aRefText2)
Compare two wxString variables.
wxString getGroupField(int aGroupIndex, const wxArrayString &aFieldArray, bool aSanitize=true)
Look up a field for a component group, which may have mismatched case, or the component group may not...
std::multimap< wxString, NET_NODE > m_netNameNodes
Store the NET_NODE with the net name.
std::multimap< int, std::pair< SCH_SYMBOL *, SCH_SHEET_PATH > > m_componentGroups
Store the component group.
void toAllegroNets()
Write the $NETS section.
NETLIST_EXPORTER_BASE(SCHEMATIC *aSchematic, KIWAY *aKiway)
A pure virtual class used to derive REPORTER objects from.
Definition reporter.h:73
Holds all the data relating to one schematic.
Definition schematic.h:149
const SYMBOL * GetParentSymbol() const
Definition sch_item.cpp:350
const wxString & GetShownNumber() const
Definition sch_pin.cpp:708
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
virtual const wxString GetRef(const SCH_SHEET_PATH *aSheet, bool aIncludeUnit=false) const =0
bool operator<(const NET_NODE &aNetNode) const
NET_NODE(SCH_PIN *aPin, const SCH_SHEET_PATH &aSheet)