diff options
author | Siddhant Ranade | 2014-07-06 12:33:35 +0530 |
---|---|---|
committer | Siddhant Ranade | 2014-07-06 12:33:35 +0530 |
commit | 27a794a4e25e795dae4a4fa255dec880732db8a6 (patch) | |
tree | 0de38699b91b780f750223e155b79804bd5747c6 | |
parent | 11d816292ade5dea7b877e6289fa0437a809b5ac (diff) | |
download | Pspice-Kicad-Converter-27a794a4e25e795dae4a4fa255dec880732db8a6.tar.gz Pspice-Kicad-Converter-27a794a4e25e795dae4a4fa255dec880732db8a6.tar.bz2 Pspice-Kicad-Converter-27a794a4e25e795dae4a4fa255dec880732db8a6.zip |
Component and ComponentInstance are now independent.
fixComp and fixInst are now separate.
Component::print changed. Is more accurate now.
-rw-r--r-- | lib/component.cpp | 10 | ||||
-rw-r--r-- | lib/component.h | 2 | ||||
-rw-r--r-- | lib/header.h | 1 | ||||
-rw-r--r-- | lib/misc.cpp | 21 | ||||
-rw-r--r-- | lib/misc.h | 5 |
5 files changed, 28 insertions, 11 deletions
diff --git a/lib/component.cpp b/lib/component.cpp index 16eb6ca..9ccb936 100644 --- a/lib/component.cpp +++ b/lib/component.cpp @@ -70,7 +70,7 @@ void Pin::print(ostream& out, int shiftx, int shifty){ } //print function of class component to print all the components to output's cache lib file void Component::print(ostream& out){ - out<<"#\n# "<<type<<"\n#\nDEF "<<type<<" "<<type<<" 0 30 Y Y 1 F N"<<endl; //upto DEF line printed + out<<"#\n# "<<type<<"\n#\nDEF "<<type<<" "<<ref<<" 0 30 Y Y 1 F N"<<endl; //upto DEF line printed out<<"F0 \""<<ref<<"\" 0 0 30 H V L CNN"<<endl; //F0 line out<<"F1 \""<<type<<"\" 0 60 30 H V L CNN"<<endl; //F1 line out<<"DRAW"<<endl; @@ -97,12 +97,16 @@ Component::Component(istream& in, string t){ string line=skipTo(in, "*symbol "+t); } skipTo(in, "@attributes"); + g=in.tellg(); + getline(in, line); while(line[0]=='a'){ Attribute attr(line); // creating attributes by calling its constructor - if(attr.name=="PKGREF") { - ref=attr.value; //assigning attributes of PKGREF to the component + if(attr.name=="REFDES"||attr.name=="refdes") { + ref=attr.value.substr(0, attr.value.length()-1); //assigning attributes of PKGREF to the component //cout<<"**"<<attr.value<<endl; ///DEBUG } + if(attr.name=="VALUE" || attr.name=="DC" || attr.name=="GAIN" || attr.name=="COEFF") + value=attr.value; //assigning attributes of above cases to the component g=in.tellg(); getline(in, line); ///cerr<<"***"<<line<<endl; ///DEBUG diff --git a/lib/component.h b/lib/component.h index 2c93a92..b14d4f3 100644 --- a/lib/component.h +++ b/lib/component.h @@ -23,7 +23,7 @@ class Pin{ class Component{ public: - string type, ref; //annotation; + string type, ref, value; //annotation; vector<Pin> pins; Design des; //create object of design class to access its method Component(); //default constructor of Component class diff --git a/lib/header.h b/lib/header.h index 3da78c8..0f0beb2 100644 --- a/lib/header.h +++ b/lib/header.h @@ -23,6 +23,5 @@ extern const int MULT; //Pspice coordinates are too small. They need to be sca extern const string nameAppend; extern const vector<string> REMOVEDCOMPONENTS; -//~ extern Component _dummy_Component; #endif diff --git a/lib/misc.cpp b/lib/misc.cpp index 4c2217a..37e3b2e 100644 --- a/lib/misc.cpp +++ b/lib/misc.cpp @@ -94,8 +94,8 @@ string stripNumFromRef(const string& ref){ return ref.substr(0, i+1); } -void fixComp(ComponentInstance& ci, Component& c){ - string ref=stripNumFromRef(ci.attrs[0].value); +void fixComp(Component& c){ + string& ref=c.ref; if(ref=="Q"){ for(int i=0; i<c.pins.size(); i++){ if(c.pins[i].n=="e"||c.pins[i].n=="E") c.pins[i].n="1"; @@ -110,7 +110,7 @@ void fixComp(ComponentInstance& ci, Component& c){ if(c.pins[i].n=="s"||c.pins[i].n=="S") c.pins[i].n="S"; if(c.pins[i].n=="d"||c.pins[i].n=="D") c.pins[i].n="D"; } - ci.attrs[0].value="Q?"; + ref="Q"; return; } if(ref=="E"){ @@ -149,6 +149,21 @@ void fixComp(ComponentInstance& ci, Component& c){ } return; } + if(c.type=="VPLOT1"||c.type=="VPLOT2"||c.type=="VPRINT1"||c.type=="VPRINT2"||c.type=="IPRINT"||c.type=="IPLOT"){ + ref="U"; + c.value=c.type; + if(c.type=="VPLOT2") c.value="VPLOT8"; + if(c.type=="VPRINT2") c.value="VPRINT"; + return; + } +} + +void fixInst(ComponentInstance& ci){ + string ref=stripNumFromRef(ci.attrs[0].value); + if(ref=="J"||ref=="M"){ + ci.attrs[0].value="Q?"; + return; + } if(ci.type=="VAC"||ci.type=="VDC"||ci.type=="VPULSE"||ci.type=="VSIN"||ci.type=="VEXP"||ci.type=="VPWL"){ if(ci.attrs[1].value=="VAC"||ci.attrs[1].value=="VDC"||ci.attrs[1].value=="VPULSE"||ci.attrs[1].value=="VEXP") ci.attrs[1].value=ci.attrs[1].value.substr(1, ci.attrs[1].value.size()-1); @@ -14,8 +14,6 @@ See LICENSE.txt //#include "component.h" //#include "component_instance.h" -extern Component _dummy_Component; - string findLibrary(string& s); string readDate(string); string readShortDate(string); @@ -23,6 +21,7 @@ string skipTo(istream&, string); string exec(const char*); string itos(int); string stripNumFromRef(const string&); -void fixComp(ComponentInstance& ci, Component& c=_dummy_Component); +void fixComp(Component&); +void fixInst(ComponentInstance&); #endif |