qicadnetlist.h
213 lines
| 6.3 KiB
| text/x-c
|
CLexer
/ qilib / qicadnetlist.h
r1 | /*------------------------------------------------------------------------------ | |||
-- This file is a part of the Kicad Tools Software | ||||
-- Copyright (C) 2014, Plasma Physics Laboratory - CNRS | ||||
-- | ||||
-- 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, write to the Free Software | ||||
-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||||
-------------------------------------------------------------------------------*/ | ||||
/*-- Author : Alexis Jeandet | ||||
-- Mail : alexis.jeandet@member.fsf.org | ||||
----------------------------------------------------------------------------*/ | ||||
r3 | #ifndef QICADNETLIST_H | |||
#define QICADNETLIST_H | ||||
#include <QString> | ||||
#include <QStringList> | ||||
r0 | #include <QList> | |||
#include <QFile> | ||||
#include <parsers/lispLike_driver.h> | ||||
r3 | #include <qicadlisplikelexique.h> | |||
r0 | ||||
namespace QIlib{ | ||||
r1 | ||||
r2 | class QIcadNetListDesign : public QIcadAbstractNodeWrapper | |||
r1 | { | |||
public: | ||||
r2 | QIcadNetListDesign(QIlib::AbstractNode* node); | |||
QIcadNetListDesign(){} | ||||
r1 | QIcadAbstractNodeWrapper source; | |||
QIcadAbstractNodeWrapper date; | ||||
QIcadAbstractNodeWrapper tool; | ||||
r2 | void setNode(QIlib::AbstractNode* node); | |||
r1 | }; | |||
r2 | ||||
r1 | /* | |||
* (comp (ref IC1) | ||||
(value 24L-MOD-8) | ||||
(libsource (lib guan) (part 24L-MOD-8)) | ||||
(sheetpath (names /) (tstamps /)) | ||||
(tstamp 52533BBE)) | ||||
*/ | ||||
class QIcadNetListComponent:public QIcadAbstractNodeWrapper | ||||
{ | ||||
r2 | class QIcadNetListLibSource : QIcadAbstractNodeWrapper | |||
{ | ||||
public: | ||||
QIcadNetListLibSource(AbstractNode* node); | ||||
QIcadNetListLibSource(){} | ||||
QIcadAbstractNodeWrapper lib; | ||||
QIcadAbstractNodeWrapper part; | ||||
void setNode(AbstractNode* node); | ||||
}; | ||||
class QIcadNetListSheetPath : QIcadAbstractNodeWrapper | ||||
{ | ||||
public: | ||||
QIcadNetListSheetPath(AbstractNode* node); | ||||
QIcadNetListSheetPath(){} | ||||
QIcadAbstractNodeWrapper names; | ||||
QIcadAbstractNodeWrapper tstamps; | ||||
void setNode(AbstractNode* node); | ||||
}; | ||||
r1 | public: | |||
QIcadNetListComponent(AbstractNode* node); | ||||
QIcadAbstractNodeWrapper ref; | ||||
QIcadAbstractNodeWrapper value; | ||||
r2 | QIcadNetListLibSource libsource; | |||
QIcadNetListSheetPath sheetpath; | ||||
r1 | QIcadAbstractNodeWrapper tstamp; | |||
r2 | void setNode(QIlib::AbstractNode* node); | |||
r1 | }; | |||
/* | ||||
(libparts | ||||
(libpart (lib guan) (part 24L-MOD-8) | ||||
(fields | ||||
(field (name Reference) IC) | ||||
(field (name Value) 24L-MOD-8)) | ||||
(pins | ||||
(pin (num 1) (name GND) (type power_in)) | ||||
(pin (num 2) (name VCC) (type power_in)) | ||||
*/ | ||||
class QIcadNetListField : QIcadAbstractNodeWrapper | ||||
{ | ||||
public: | ||||
QIcadNetListField(AbstractNode* node); | ||||
QIcadAbstractNodeWrapper name; | ||||
r2 | void setNode(AbstractNode* node); | |||
r0 | }; | |||
r1 | ||||
class QIcadNetListLibPart : QIcadAbstractNodeWrapper | ||||
{ | ||||
class QIcadNetListPin : QIcadAbstractNodeWrapper | ||||
{ | ||||
public: | ||||
QIcadNetListPin(AbstractNode* node); | ||||
QIcadAbstractNodeWrapper type; | ||||
QIcadAbstractNodeWrapper num; | ||||
QIcadAbstractNodeWrapper name; | ||||
r2 | void setNode(AbstractNode* node); | |||
r1 | }; | |||
public: | ||||
QIcadNetListLibPart(AbstractNode* node); | ||||
r2 | QIcadAbstractNodeWrapper lib; | |||
QIcadAbstractNodeWrapper part; | ||||
r1 | QList<QIcadNetListField*> fields; | |||
QList<QIcadNetListPin*> pins; | ||||
r2 | void setNode(AbstractNode* node); | |||
void setFields(QIlib::AbstractNode* node); | ||||
void apendFields(QIlib::AbstractNode* node); | ||||
void setPins(QIlib::AbstractNode* node); | ||||
void apendPins(QIlib::AbstractNode* node); | ||||
r1 | }; | |||
/* | ||||
(libraries | ||||
(library (logical guan) | ||||
(uri /home/guan/boards/guan.lib)) | ||||
(library (logical device) | ||||
(uri /usr/share/kicad/library/device.lib)) | ||||
(library (logical conn) | ||||
(uri /usr/share/kicad/library/conn.lib))) | ||||
*/ | ||||
class QIcadNetListLibrary : QIcadAbstractNodeWrapper | ||||
{ | ||||
public: | ||||
QIcadNetListLibrary(AbstractNode* node); | ||||
QIcadAbstractNodeWrapper uri; | ||||
r2 | QIcadAbstractNodeWrapper logical; | |||
void setNode(AbstractNode* node); | ||||
r1 | }; | |||
/* | ||||
(nets | ||||
(net (code 15) (name "") | ||||
(node (ref C4) (pin 1)) | ||||
(node (ref U2) (pin 4))) | ||||
(net (code 16) (name GND) | ||||
(node (ref D1) (pin 2)) | ||||
(node (ref C1) (pin 2)) | ||||
(node (ref IC1) (pin 1)) | ||||
*/ | ||||
class QIcadNetListNet : QIcadAbstractNodeWrapper | ||||
{ | ||||
class QIcadNetListNetNode: QIcadAbstractNodeWrapper | ||||
{ | ||||
public: | ||||
QIcadNetListNetNode(AbstractNode* node); | ||||
QIcadAbstractNodeWrapper ref; | ||||
QIcadAbstractNodeWrapper pin; | ||||
r2 | void setNode(AbstractNode* node); | |||
r1 | }; | |||
public: | ||||
QIcadNetListNet(AbstractNode* node); | ||||
QList<QIcadNetListNetNode*> NetNodes; | ||||
r2 | QIcadAbstractNodeWrapper code; | |||
QIcadAbstractNodeWrapper name; | ||||
void setNode(AbstractNode* node); | ||||
r1 | }; | |||
r2 | class QIcadNetListRoot : public QIcadAbstractNodeWrapper | |||
{ | ||||
public: | ||||
QIcadNetListRoot(QIlib::AbstractNode* node); | ||||
QIcadNetListDesign design; | ||||
QList<QIcadNetListComponent*> components; | ||||
QList<QIcadNetListLibPart*> libparts; | ||||
QList<QIcadNetListLibrary*> libraries; | ||||
QList<QIcadNetListNet*> nets; | ||||
void setNode(QIlib::AbstractNode* node); | ||||
void setComponents(QIlib::AbstractNode* node); | ||||
void apendComponents(QIlib::AbstractNode* node); | ||||
void setLibParts(QIlib::AbstractNode* node); | ||||
void apendLibParts(QIlib::AbstractNode* node); | ||||
void setLibraries(QIlib::AbstractNode* node); | ||||
void apendLibraries(QIlib::AbstractNode* node); | ||||
void setNets(QIlib::AbstractNode* node); | ||||
void apendNets(QIlib::AbstractNode* node); | ||||
}; | ||||
r1 | ||||
r0 | class QIcadNetList : private lispLike_Driver | |||
{ | ||||
public: | ||||
QIcadNetList(); | ||||
bool parseNetList(const QString& netlist); | ||||
r3 | // QString toString(); | |||
r0 | QString fileName; | |||
QString print(); | ||||
r2 | QIcadNetListRoot* netlistRoot; | |||
r0 | private: | |||
QIlib::AbstractNode* getAbstractNode(const QString& node,int index); | ||||
QIlib::AbstractNode* getAbstractNode(QIlib::AbstractNode* rootNode,const QString& node,int* index); | ||||
void updateConcreteTree(); | ||||
}; | ||||
} | ||||
#endif // QICADNETLIST_H | ||||