Implemented IFS building from EDD

This commit is contained in:
Vadim Kuznetzov 2016-09-30 17:57:07 +03:00
parent be2bcc27da
commit c04c4ebb0a
6 changed files with 62 additions and 6 deletions

View File

@ -32,7 +32,7 @@ SubCirPort::SubCirPort()
QObject::tr("type of the port (for digital simulation only)")
+" [analog, in, out, inout]"));
Props.append(new Property("XSPICE_Type","v",false,"Allowed XSPICE types: [v,i,vd,id,h,g,hd,gd]"));
Props.append(new Property("Conj","",false,
Props.append(new Property("Bounded","",false,
QObject::tr("Conjugated port for XSPICE differential ports")));
createSymbol();

View File

@ -95,7 +95,7 @@ bool CodeModelGen::createIFS(QTextStream &stream, Schematic *sch)
QString base = inf.completeBaseName();
base.remove('-').remove(' ');
stream<<"NAME TABLE:\n";
stream<<"NAME_TABLE:\n";
stream<<QString("C_Function_Name: cm_%1\n").arg(base);
stream<<QString("Spice_Model_Name: %1\n").arg(base);
@ -106,7 +106,7 @@ bool CodeModelGen::createIFS(QTextStream &stream, Schematic *sch)
for(;it!=ports.end();it++) {
QString pname = it.key();
QString ptype = it.value();
stream<<"\nPORT TABLE:\n";
stream<<"\nPORT_TABLE:\n";
stream<<QString("Port_Name: %1\n").arg(pname);
stream<<"Description: \" \"\n";
stream<<"Direction: inout\n";
@ -138,6 +138,38 @@ bool CodeModelGen::createIFS(QTextStream &stream, Schematic *sch)
return true;
}
bool CodeModelGen::createIFSfromEDD(QTextStream &stream, Schematic *sch, Component *pc)
{
prepare(sch);
if (pc->Model!="EDD") return false;
int Nbranch = pc->Props.at(1)->Value.toInt();
QStringList ports;
for(int i=0;i<Nbranch;i++) {
QString net1 = pc->Ports.at(2*i)->Connection->Name;
QString net2 = pc->Ports.at(2*i+1)->Connection->Name;
ports.append(net1+"_"+net2);
}
stream<<"NAME_TABLE:\n";
stream<<QString("C_Function_Name: cm_%1\n").arg(pc->Name);
stream<<QString("Spice_Model_Name: %1\n").arg(pc->Name);
foreach(QString pp,ports) {
stream<<"\nPORT_TABLE:\n";
stream<<QString("Port_Name: %1\n").arg(pp);
stream<<"Description: \" \"\n";
stream<<"Direction: inout\n";
stream<<"Default_Type: gd\n";
stream<<"Allowed_Types: [gd]\n";
stream<<"Vector: no\n";
stream<<"Vector_Bounds: - \n";
stream<<"Null_Allowed: no\n\n";
}
return true;
}
bool CodeModelGen::createMOD(QTextStream &stream, Schematic *sch)
{
QFileInfo inf(sch->DocName);

View File

@ -41,6 +41,7 @@ protected:
bool prepare(Schematic *sch);
public:
bool createIFS(QTextStream &stream, Schematic *sch);
bool createIFSfromEDD(QTextStream &stream, Schematic *sch, Component *pc);
bool createMOD(QTextStream &stream, Schematic *sch);
};

View File

@ -773,6 +773,11 @@ void MouseActions::rightPressMenu(Schematic *Doc, QMouseEvent *Event, float fX,
ComponentMenu->insertItem(QObject::tr("Export as image"), QucsMain,
SLOT(slotSaveDiagramToGraphicsFile()));
}
if (focusElement->Type & isComponent) {
Component *pc = (Component *)focusElement;
if (pc->Model == "EDD") ComponentMenu->insertItem(QObject::tr("Create XSPICE IFS"), QucsMain,
SLOT(slotEDDtoIFS()));
}
}
break;
}

View File

@ -2929,7 +2929,8 @@ void QucsApp::slotBuildVAModule()
}
void QucsApp::slotBuildXSPICEIfs()
void QucsApp::slotBuildXSPICEIfs(bool EDD)
{
if (!isTextDocument(DocumentTab->currentPage())) {
Schematic *Sch = (Schematic*)DocumentTab->currentPage();
@ -2944,7 +2945,17 @@ void QucsApp::slotBuildXSPICEIfs()
if (f.open(QIODevice::WriteOnly)) {
QTextStream stream(&f);
CodeModelGen *cmgen = new CodeModelGen;
bool r = cmgen->createIFS(stream,Sch);
bool r = false;
if (!EDD) {
r = cmgen->createIFS(stream,Sch);
} else {
for(Component *pc = Sch->DocComps.first(); pc != 0; pc = Sch->DocComps.next()) {
if (pc->isSelected) {
r = cmgen->createIFSfromEDD(stream,Sch,pc);
break;
}
}
}
if (!r) QMessageBox::critical(this,tr("Create XSPICE IFS"),
tr("Create IFS file failed!"
"Schematic is not subciruit!"),
@ -2954,3 +2965,9 @@ void QucsApp::slotBuildXSPICEIfs()
}
}
}
void QucsApp::slotEDDtoIFS()
{
slotBuildXSPICEIfs(true);
}

View File

@ -154,7 +154,8 @@ private slots:
void slotSimulateWithSpice();
void slotAfterSpiceSimulation();
void slotBuildVAModule();
void slotBuildXSPICEIfs();
void slotBuildXSPICEIfs(bool EDD = false);
void slotEDDtoIFS();
signals:
void signalKillEmAll();