mirror of
https://github.com/ra3xdh/qucs_s
synced 2025-03-28 21:13:26 +00:00
Merge pull request #1201 from ThomasZecha/current
Introduce optional netlisting to console
This commit is contained in:
commit
75040f363d
@ -828,7 +828,7 @@ QString Component::getVerilogACode() {
|
||||
}
|
||||
}
|
||||
|
||||
QString Component::getExpression(bool, bool) {
|
||||
QString Component::getExpression(spicecompat::SpiceDialect) {
|
||||
return QString();
|
||||
}
|
||||
|
||||
@ -840,7 +840,7 @@ QStringList Component::getExtraVariables() {
|
||||
return QStringList();
|
||||
}
|
||||
|
||||
QString Component::getProbeVariable(bool) {
|
||||
QString Component::getProbeVariable(spicecompat::SpiceDialect) {
|
||||
return QString();
|
||||
}
|
||||
|
||||
|
@ -44,10 +44,10 @@ public:
|
||||
QString getNetlist();
|
||||
QString getSpiceNetlist(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault);
|
||||
QString getVerilogACode();
|
||||
virtual QString getExpression(bool isXyce = false, bool isCdl = false);
|
||||
virtual QString getExpression(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault);
|
||||
virtual QString getEquations(QString sim, QStringList &dep_vars);
|
||||
virtual QStringList getExtraVariables();
|
||||
virtual QString getProbeVariable(bool isXyce = false);
|
||||
virtual QString getProbeVariable(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault);
|
||||
virtual QString getSpiceModel();
|
||||
virtual QString getSpiceLibrary() { return QString(); }
|
||||
virtual QStringList getSpiceLibraryFiles() { return QStringList(); }
|
||||
|
@ -119,14 +119,11 @@ QString Equation::getVAExpressions()
|
||||
/*!
|
||||
* \brief Equation::getExpression Extract equations that don't contain simulation variables
|
||||
* (voltages/cureents) in .PARAM section of spice netlist
|
||||
* \param isXyce True if Xyce is used.
|
||||
* \param isCdl True if CDL is used.
|
||||
* \param dialect Which spice-dialect is used.
|
||||
* \return .PARAM section of spice netlist as a single string.
|
||||
*/
|
||||
QString Equation::getExpression(bool isXyce, bool isCdl /* = false */)
|
||||
QString Equation::getExpression(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */)
|
||||
{
|
||||
Q_UNUSED(isCdl);
|
||||
|
||||
if (isActive != COMP_IS_ACTIVE) return QString();
|
||||
|
||||
QStringList ng_vars,ngsims;
|
||||
@ -145,9 +142,9 @@ QString Equation::getExpression(bool isXyce, bool isCdl /* = false */)
|
||||
QStringList tokens;
|
||||
QString eqn = Props.at(i)->Value;
|
||||
spicecompat::splitEqn(eqn,tokens);
|
||||
spicecompat::convert_functions(tokens,isXyce);
|
||||
spicecompat::convert_functions(tokens, dialect == spicecompat::SPICEXyce);
|
||||
eqn = tokens.join("");
|
||||
if (isXyce) {
|
||||
if (dialect == spicecompat::SPICEXyce) {
|
||||
eqn.replace("^","**");
|
||||
|
||||
if (!(fp_pattern.match(eqn).hasMatch()||
|
||||
|
@ -28,7 +28,7 @@ public:
|
||||
~Equation();
|
||||
Component* newOne();
|
||||
static Element* info(QString&, char* &, bool getNewOne=false);
|
||||
QString getExpression(bool isXyce, bool isCdl = false);
|
||||
QString getExpression(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault);
|
||||
QString getEquations(QString sim, QStringList &dep_vars);
|
||||
QString getVAvariables();
|
||||
QString getVAExpressions();
|
||||
|
@ -90,13 +90,13 @@ QString iProbe::spice_netlist(spicecompat::SpiceDialect dialect /* = spicecompat
|
||||
|
||||
/*!
|
||||
* \brief iProbe::getProbeVariable Get current probe variable
|
||||
* \param isXyce True if Xyce simulator
|
||||
* \param dialect Spice dialect used
|
||||
* \return Current probe variable in Ngspice or Xyce notation
|
||||
*/
|
||||
QString iProbe::getProbeVariable(bool isXyce)
|
||||
QString iProbe::getProbeVariable(spicecompat::SpiceDialect dialect)
|
||||
{
|
||||
QString s;
|
||||
if (isXyce) {
|
||||
if (dialect == spicecompat::SPICEXyce) {
|
||||
s = QStringLiteral("I(V%1)").arg(Name);
|
||||
} else {
|
||||
s = QStringLiteral("V%1#branch").arg(Name);
|
||||
|
@ -27,8 +27,8 @@ public:
|
||||
~iProbe();
|
||||
Component* newOne();
|
||||
static Element* info(QString&, char* &, bool getNewOne=false);
|
||||
QString getExpression(bool, bool) { return "";}
|
||||
QString getProbeVariable(bool isXyce = false);
|
||||
QString getExpression(spicecompat::SpiceDialect) { return "";}
|
||||
QString getProbeVariable(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault);
|
||||
|
||||
protected:
|
||||
QString spice_netlist(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault);
|
||||
|
@ -73,7 +73,7 @@ Element* vProbe::info(QString& Name, char* &BitmapFile, bool getNewOne)
|
||||
return 0;
|
||||
}
|
||||
|
||||
QString vProbe::getProbeVariable(bool)
|
||||
QString vProbe::getProbeVariable(spicecompat::SpiceDialect)
|
||||
{
|
||||
return Name;
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ public:
|
||||
~vProbe();
|
||||
Component* newOne();
|
||||
static Element* info(QString&, char* &, bool getNewOne=false);
|
||||
QString getProbeVariable(bool isXyce = false);
|
||||
QString getProbeVariable(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault);
|
||||
protected:
|
||||
QString spice_netlist(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault);
|
||||
};
|
||||
|
@ -149,7 +149,7 @@ void CdlNetlistWriter::startNetlist()
|
||||
{
|
||||
if (pc->isEquation)
|
||||
{
|
||||
s = pc->getExpression(false, true);
|
||||
s = pc->getExpression(spicecompat::CDL);
|
||||
a_netlistStream << s;
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +25,7 @@
|
||||
#include "main.h"
|
||||
#include "qucs.h"
|
||||
|
||||
ExternSimDialog::ExternSimDialog(Schematic *sch, bool netlist_mode) :
|
||||
ExternSimDialog::ExternSimDialog(Schematic* sch, bool netlist2Console, bool netlist_mode) :
|
||||
QDialog(sch),
|
||||
a_schematic(sch),
|
||||
a_buttonStopSim(new QPushButton(tr("Stop"),this)),
|
||||
@ -37,7 +37,8 @@ ExternSimDialog::ExternSimDialog(Schematic *sch, bool netlist_mode) :
|
||||
a_ngspice(new Ngspice(sch,this)),
|
||||
a_xyce(new Xyce(sch,this)),
|
||||
a_wasSimulated(true),
|
||||
a_hasError(false)
|
||||
a_hasError(false),
|
||||
a_netlist2Console(netlist2Console)
|
||||
{
|
||||
const QString workdir(QucsSettings.S4Qworkdir);
|
||||
|
||||
@ -296,26 +297,39 @@ void ExternSimDialog::slotStop()
|
||||
void ExternSimDialog::slotSaveNetlist()
|
||||
{
|
||||
QFileInfo inf(a_schematic->getDocName());
|
||||
QString filename = QFileDialog::getSaveFileName(this,tr("Save netlist"),inf.path()+QDir::separator()+"netlist.cir",
|
||||
"All files (*)");
|
||||
if (filename.isEmpty()) return;
|
||||
QString filename;
|
||||
|
||||
switch (QucsSettings.DefaultSimulator) {
|
||||
if (!a_netlist2Console)
|
||||
{
|
||||
filename = QFileDialog::getSaveFileName(
|
||||
this,
|
||||
tr("Save netlist"),
|
||||
inf.path() + QDir::separator() + "netlist.cir",
|
||||
"All files (*)");
|
||||
if (filename.isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
switch (QucsSettings.DefaultSimulator)
|
||||
{
|
||||
case spicecompat::simNgspice:
|
||||
case spicecompat::simSpiceOpus: {
|
||||
a_ngspice->SaveNetlist(filename);
|
||||
}
|
||||
case spicecompat::simSpiceOpus:
|
||||
a_ngspice->SaveNetlist(filename, a_netlist2Console);
|
||||
break;
|
||||
case spicecompat::simXyce: {
|
||||
a_xyce->SaveNetlist(filename);
|
||||
}
|
||||
case spicecompat::simXyce:
|
||||
a_xyce->SaveNetlist(filename, a_netlist2Console);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (!QFile::exists(filename)) {
|
||||
QMessageBox::critical(0, QObject::tr("Save netlist"),
|
||||
if (!a_netlist2Console && !QFile::exists(filename))
|
||||
{
|
||||
QMessageBox::critical(
|
||||
nullptr,
|
||||
QObject::tr("Save netlist"),
|
||||
QObject::tr("Disk write error!"), QMessageBox::Ok);
|
||||
}
|
||||
}
|
||||
|
@ -46,9 +46,12 @@ private:
|
||||
|
||||
bool a_wasSimulated;
|
||||
bool a_hasError;
|
||||
bool a_netlist2Console;
|
||||
|
||||
public:
|
||||
explicit ExternSimDialog(Schematic *sch,
|
||||
explicit ExternSimDialog(
|
||||
Schematic* sch,
|
||||
bool netlist2Console,
|
||||
bool netlist_mode = false);
|
||||
~ExternSimDialog();
|
||||
|
||||
|
@ -33,6 +33,10 @@
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <QScopedPointer>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
/*!
|
||||
\file ngspice.cpp
|
||||
\brief Implementation of the Ngspice class
|
||||
@ -67,8 +71,11 @@ Ngspice::Ngspice(Schematic *schematic, QObject *parent) :
|
||||
* \param[out] vars The list of output variables and node names.
|
||||
* \param[out] outputs The list of spice output raw text files.
|
||||
*/
|
||||
void Ngspice::createNetlist(QTextStream &stream, int ,
|
||||
QStringList &simulations, QStringList &vars, QStringList &outputs)
|
||||
void Ngspice::createNetlist(
|
||||
QTextStream& stream,
|
||||
QStringList& simulations,
|
||||
QStringList& vars,
|
||||
QStringList& outputs)
|
||||
{
|
||||
Q_UNUSED(simulations);
|
||||
|
||||
@ -464,7 +471,7 @@ void Ngspice::slotSimulate()
|
||||
|
||||
QString netfile = "spice4qucs.cir";
|
||||
QString tmp_path = QDir::toNativeSeparators(a_workdir+QDir::separator()+netfile);
|
||||
SaveNetlist(tmp_path);
|
||||
SaveNetlist(tmp_path, false);
|
||||
|
||||
removeAllSimulatorOutputs();
|
||||
|
||||
@ -583,24 +590,43 @@ void Ngspice::slotProcessOutput()
|
||||
* \brief Ngspice::SaveNetlist Create netlist and save it to file without execution
|
||||
* of simulator.
|
||||
* \param[in] filename Absolute path to netlist
|
||||
* \param[in] netlist2Console Whether netlist to console instead to file
|
||||
*/
|
||||
void Ngspice::SaveNetlist(QString filename)
|
||||
void Ngspice::SaveNetlist(QString filename, bool netlist2Console)
|
||||
{
|
||||
int num=0;
|
||||
a_sims.clear();
|
||||
a_vars.clear();
|
||||
|
||||
QFile spice_file(filename);
|
||||
if (spice_file.open(QFile::WriteOnly)) {
|
||||
QTextStream stream(&spice_file);
|
||||
createNetlist(stream,num,a_sims,a_vars,a_output_files);
|
||||
spice_file.close();
|
||||
QScopedPointer<QString> netlistString;
|
||||
QScopedPointer<QTextStream> netlistStream;
|
||||
QScopedPointer<QFile> netlistFile;
|
||||
|
||||
if (netlist2Console)
|
||||
{
|
||||
netlistString.reset(new QString);
|
||||
netlistStream.reset(new QTextStream(netlistString.get()));
|
||||
}
|
||||
else
|
||||
{
|
||||
netlistFile.reset(new QFile(filename));
|
||||
if (netlistFile->open(QFile::WriteOnly))
|
||||
{
|
||||
netlistStream.reset(new QTextStream(netlistFile.get()));
|
||||
}
|
||||
else
|
||||
{
|
||||
QString msg = QStringLiteral("Tried to save netlist \nin %1\n(could not open for writing!)").arg(filename);
|
||||
QString final_msg = QStringLiteral("%1\n This could be an error in the QSettings settings file\n(usually in ~/.config/qucs/qucs_s.conf)\nThe value for S4Q_workdir (default:/spice4qucs) needs to be writeable!\nFor a Simulation Simulation will raise error! (most likely S4Q_workdir does not exists)").arg(msg);
|
||||
QMessageBox::critical(nullptr,tr("Problem with SaveNetlist"), final_msg, QMessageBox::Ok);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
createNetlist(*netlistStream, a_sims, a_vars, a_output_files);
|
||||
|
||||
if (netlist2Console)
|
||||
{
|
||||
std::cout << netlistString->toUtf8().constData() << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -50,13 +50,16 @@ private:
|
||||
|
||||
public:
|
||||
explicit Ngspice(Schematic* schematic, QObject *parent = 0);
|
||||
void SaveNetlist(QString filename);
|
||||
void SaveNetlist(QString filename, bool netlist2Console);
|
||||
void setSimulatorCmd(QString cmd);
|
||||
void setSimulatorParameters(QString parameters);
|
||||
|
||||
protected:
|
||||
void createNetlist(QTextStream &stream, int NumPorts, QStringList &simulations,
|
||||
QStringList &vars, QStringList &outputs);
|
||||
void createNetlist(
|
||||
QTextStream& stream,
|
||||
QStringList& simulations,
|
||||
QStringList& vars,
|
||||
QStringList& outputs);
|
||||
|
||||
public slots:
|
||||
void slotSimulate();
|
||||
|
@ -25,6 +25,10 @@
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <QScopedPointer>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
/*!
|
||||
\file xyce.cpp
|
||||
\brief Implementation of the Xyce class
|
||||
@ -79,8 +83,11 @@ void Xyce::determineUsedSimulations(QStringList *sim_lst)
|
||||
* \param[out] vars The list of output variables and node names.
|
||||
* \param[out] outputs The list of spice output raw text files.
|
||||
*/
|
||||
void Xyce::createNetlist(QTextStream &stream, int , QStringList &simulations,
|
||||
QStringList &vars, QStringList &outputs)
|
||||
void Xyce::createNetlist(
|
||||
QTextStream& stream,
|
||||
QStringList& simulations,
|
||||
QStringList& vars,
|
||||
QStringList& outputs)
|
||||
{
|
||||
QString s;
|
||||
bool hasParSweep = false;
|
||||
@ -110,7 +117,7 @@ void Xyce::createNetlist(QTextStream &stream, int , QStringList &simulations,
|
||||
}
|
||||
for(Component *pc = a_schematic->a_DocComps.first(); pc != 0; pc = a_schematic->a_DocComps.next()) {
|
||||
if (pc->isProbe) {
|
||||
QString var_pr = pc->getProbeVariable(true);
|
||||
QString var_pr = pc->getProbeVariable(spicecompat::SPICEXyce);
|
||||
if (!vars.contains(var_pr)) {
|
||||
vars.append(var_pr);
|
||||
}
|
||||
@ -312,7 +319,6 @@ void Xyce::slotSimulate()
|
||||
return;
|
||||
}
|
||||
|
||||
int num=0;
|
||||
a_netlistQueue.clear();
|
||||
a_output_files.clear();
|
||||
|
||||
@ -332,7 +338,7 @@ void Xyce::slotSimulate()
|
||||
QFile spice_file(tmp_path);
|
||||
if (spice_file.open(QFile::WriteOnly)) {
|
||||
QTextStream stream(&spice_file);
|
||||
createNetlist(stream,num,sim_lst,a_vars,a_output_files);
|
||||
createNetlist(stream,sim_lst,a_vars,a_output_files);
|
||||
spice_file.close();
|
||||
}
|
||||
}
|
||||
@ -347,16 +353,36 @@ void Xyce::slotSimulate()
|
||||
* \brief Xyce::SaveNetlist Save netlist into specified file without
|
||||
* execution of simulator.
|
||||
* \param[in] filename The name of file in which netlist is saved
|
||||
* \param[in] netlist2Console Whether netlist to console instead to file
|
||||
*/
|
||||
void Xyce::SaveNetlist(QString filename)
|
||||
void Xyce::SaveNetlist(QString filename, bool netlist2Console)
|
||||
{
|
||||
determineUsedSimulations();
|
||||
int num = 0;
|
||||
QFile spice_file(filename);
|
||||
if (spice_file.open(QFile::WriteOnly)) {
|
||||
QTextStream stream(&spice_file);
|
||||
createNetlist(stream,num,a_simulationsQueue,a_vars,a_output_files);
|
||||
spice_file.close();
|
||||
|
||||
QScopedPointer<QString> netlistString;
|
||||
QScopedPointer<QTextStream> netlistStream;
|
||||
QScopedPointer<QFile> netlistFile;
|
||||
|
||||
if (netlist2Console)
|
||||
{
|
||||
netlistString.reset(new QString);
|
||||
netlistStream.reset(new QTextStream(netlistString.get()));
|
||||
}
|
||||
else
|
||||
{
|
||||
netlistFile.reset(new QFile(filename));
|
||||
|
||||
if (netlistFile->open(QFile::WriteOnly))
|
||||
{
|
||||
netlistStream.reset(new QTextStream(netlistFile.get()));
|
||||
}
|
||||
}
|
||||
|
||||
createNetlist(*netlistStream, a_simulationsQueue, a_vars, a_output_files);
|
||||
|
||||
if (netlist2Console)
|
||||
{
|
||||
std::cout << netlistString->toUtf8().constData() << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -48,13 +48,17 @@ public:
|
||||
void determineUsedSimulations(QStringList *sim_lst = NULL);
|
||||
explicit Xyce(Schematic* schematic, QObject *parent = 0);
|
||||
|
||||
void SaveNetlist(QString filename);
|
||||
void SaveNetlist(QString filename, bool netlist2Console);
|
||||
void setParallel(bool par);
|
||||
bool waitEndOfSimulation();
|
||||
|
||||
protected:
|
||||
void createNetlist(QTextStream &stream, int NumPorts, QStringList &simulations,
|
||||
QStringList &vars, QStringList &outputs);
|
||||
void createNetlist(
|
||||
QTextStream& stream,
|
||||
QStringList& simulations,
|
||||
QStringList& vars,
|
||||
QStringList& outputs);
|
||||
|
||||
protected slots:
|
||||
void slotFinished();
|
||||
void slotProcessOutput();
|
||||
|
581
qucs/main.cpp
581
qucs/main.cpp
@ -26,6 +26,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
#include <locale.h>
|
||||
#include <iostream>
|
||||
|
||||
#include <QApplication>
|
||||
#include <QString>
|
||||
@ -36,6 +37,9 @@
|
||||
#include <QMessageBox>
|
||||
#include <QRegularExpression>
|
||||
#include <QtSvg>
|
||||
#include <QCommandLineParser>
|
||||
#include <QTextStream>
|
||||
#include <QScopedPointer>
|
||||
|
||||
#include "qucs.h"
|
||||
#include "main.h"
|
||||
@ -50,6 +54,7 @@
|
||||
|
||||
#include "extsimkernels/ngspice.h"
|
||||
#include "extsimkernels/xyce.h"
|
||||
#include "extsimkernels/CdlNetlistWriter.h"
|
||||
|
||||
#if defined(_WIN32) ||defined(__MINGW32__)
|
||||
#include <windows.h> //for OutputDebugString
|
||||
@ -268,188 +273,298 @@ void qucsMessageOutput(QtMsgType type, const QMessageLogContext &context, const
|
||||
fflush(stderr);
|
||||
}
|
||||
|
||||
Schematic *openSchematic(QString schematic)
|
||||
Schematic* openSchematic(const QString& schematicFileName)
|
||||
{
|
||||
qDebug() << "*** try to load schematic :" << schematic;
|
||||
qDebug() << "*** try to load schematic :" << schematicFileName;
|
||||
|
||||
QFile file(schematic); // save simulator messages
|
||||
if(file.open(QIODevice::ReadOnly)) {
|
||||
QFile file(schematicFileName); // save simulator messages
|
||||
if (file.open(QIODevice::ReadOnly))
|
||||
{
|
||||
file.close();
|
||||
}
|
||||
else {
|
||||
fprintf(stderr, "Error: Could not load schematic %s\n", schematic.toLatin1().data());
|
||||
return NULL;
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "Error: Could not load schematic %s\n", schematicFileName.toLatin1().data());
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// populate Modules list
|
||||
//Module::registerModules ();
|
||||
|
||||
// new schematic from file
|
||||
Schematic *sch = new Schematic(0, schematic);
|
||||
Schematic *schematic = new Schematic(nullptr, schematicFileName);
|
||||
|
||||
// load schematic file if possible
|
||||
if(!sch->loadDocument()) {
|
||||
fprintf(stderr, "Error: Could not load schematic %s\n", schematic.toLatin1().data());
|
||||
delete sch;
|
||||
return NULL;
|
||||
}
|
||||
return sch;
|
||||
if (!schematic->loadDocument())
|
||||
{
|
||||
fprintf(stderr, "Error: Could not load schematic %s\n", schematicFileName.toLatin1().data());
|
||||
delete schematic;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
int doNetlist(QString schematic, QString netlist)
|
||||
return schematic;
|
||||
}
|
||||
|
||||
int doNetlist(QString schematicFileName, QString netlistFileName, bool netlist2Console)
|
||||
{
|
||||
QucsSettings.DefaultSimulator = spicecompat::simQucsator;
|
||||
Module::registerModules();
|
||||
Schematic *sch = openSchematic(schematic);
|
||||
if (sch == NULL) {
|
||||
|
||||
QScopedPointer<Schematic> schematic(openSchematic(schematicFileName));
|
||||
if (!schematic)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
qDebug() << "*** try to write netlist :" << netlist;
|
||||
if (!netlist2Console)
|
||||
{
|
||||
qDebug() << "*** try to write netlist :" << netlistFileName;
|
||||
}
|
||||
|
||||
QStringList Collect;
|
||||
QScopedPointer<QFile> netlistFile;
|
||||
QScopedPointer<QTextStream> netlistStream;
|
||||
QScopedPointer<QString> netlistString;
|
||||
|
||||
QPlainTextEdit *ErrText = new QPlainTextEdit(); //dummy
|
||||
QFile NetlistFile;
|
||||
QTextStream Stream;
|
||||
|
||||
Collect.clear(); // clear list for NodeSets, SPICE components etc.
|
||||
|
||||
NetlistFile.setFileName(netlist);
|
||||
if(!NetlistFile.open(QIODevice::WriteOnly)) {
|
||||
fprintf(stderr, "Error: Could not load netlist %s\n", netlist.toLatin1().data());
|
||||
if (!netlist2Console)
|
||||
{
|
||||
netlistFile.reset(new QFile(netlistFileName));
|
||||
if (!netlistFile->open(QIODevice::WriteOnly))
|
||||
{
|
||||
fprintf(stderr, "Error: Could not load netlist %s\n", netlistFileName.toLatin1().data());
|
||||
return -1;
|
||||
}
|
||||
|
||||
Stream.setDevice(&NetlistFile);
|
||||
int SimPorts = sch->prepareNetlist(Stream, Collect, ErrText);
|
||||
netlistStream.reset(new QTextStream(netlistFile.get()));
|
||||
}
|
||||
else
|
||||
{
|
||||
netlistString.reset(new QString);
|
||||
netlistStream.reset(new QTextStream(netlistString.get()));
|
||||
}
|
||||
|
||||
if(SimPorts < -5) {
|
||||
NetlistFile.close();
|
||||
QByteArray ba = netlist.toLatin1();
|
||||
QPlainTextEdit errText; // dummy
|
||||
QStringList Collect; // clear list for NodeSets, SPICE components etc.
|
||||
int SimPorts = schematic->prepareNetlist(*netlistStream, Collect, &errText);
|
||||
|
||||
if (SimPorts < -5)
|
||||
{
|
||||
QByteArray ba = netlistFileName.toLatin1();
|
||||
fprintf(stderr, "Error: Could not prepare netlist %s\n", ba.data());
|
||||
/// \todo better handling for error/warnings
|
||||
qCritical() << ErrText->toPlainText();
|
||||
qCritical() << errText.toPlainText();
|
||||
return 1;
|
||||
}
|
||||
|
||||
// output NodeSets, SPICE simulations etc.
|
||||
for(QStringList::Iterator it = Collect.begin();
|
||||
it != Collect.end(); ++it) {
|
||||
for (QStringList::Iterator it = Collect.begin(); it != Collect.end(); ++it)
|
||||
{
|
||||
// don't put library includes into netlist...
|
||||
if ((*it).right(4) != ".lst" &&
|
||||
(*it).right(5) != ".vhdl" &&
|
||||
(*it).right(4) != ".vhd" &&
|
||||
(*it).right(2) != ".v") {
|
||||
Stream << *it << '\n';
|
||||
(*it).right(2) != ".v")
|
||||
{
|
||||
*netlistStream << *it << '\n';
|
||||
}
|
||||
}
|
||||
|
||||
Stream << '\n';
|
||||
*netlistStream << '\n';
|
||||
|
||||
QString SimTime = sch->createNetlist(Stream, SimPorts);
|
||||
delete(sch);
|
||||
schematic->createNetlist(*netlistStream, SimPorts);
|
||||
|
||||
NetlistFile.close();
|
||||
if (netlist2Console)
|
||||
{
|
||||
std::cout << std::endl << netlistString->toLatin1().constData() << std::endl;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int runNgspice(QString schematic, QString dataset)
|
||||
int runNgspice(QString schematicFileName, QString dataset)
|
||||
{
|
||||
QucsSettings.DefaultSimulator = spicecompat::simNgspice;
|
||||
Module::registerModules();
|
||||
Schematic *sch = openSchematic(schematic);
|
||||
if (sch == NULL) {
|
||||
|
||||
QScopedPointer<Schematic> schematic(openSchematic(schematicFileName));
|
||||
if (!schematic)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
Ngspice *ngspice = new Ngspice(sch);
|
||||
QScopedPointer<Ngspice> ngspice(new Ngspice(schematic.get()));
|
||||
ngspice->slotSimulate();
|
||||
bool ok = ngspice->waitEndOfSimulation();
|
||||
if (!ok) {
|
||||
if (!ok)
|
||||
{
|
||||
fprintf(stderr, "Ngspice timed out or start error!\n");
|
||||
delete ngspice;
|
||||
return -1;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
ngspice->convertToQucsData(dataset);
|
||||
}
|
||||
|
||||
delete ngspice;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int runXyce(QString schematic, QString dataset)
|
||||
int runXyce(QString schematicFileName, QString dataset)
|
||||
{
|
||||
QucsSettings.DefaultSimulator = spicecompat::simXyce;
|
||||
Module::registerModules();
|
||||
Schematic *sch = openSchematic(schematic);
|
||||
if (sch == NULL) {
|
||||
|
||||
QScopedPointer<Schematic> schematic(openSchematic(schematicFileName));
|
||||
if (!schematic)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
Xyce *xyce = new Xyce(sch);
|
||||
QScopedPointer<Xyce> xyce(new Xyce(schematic.get()));
|
||||
xyce->slotSimulate();
|
||||
bool ok = xyce->waitEndOfSimulation();
|
||||
if (!ok) {
|
||||
if (!ok)
|
||||
{
|
||||
fprintf(stderr, "Xyce timed out or start error!\n");
|
||||
delete xyce;
|
||||
return -1;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
xyce->convertToQucsData(dataset);
|
||||
}
|
||||
|
||||
delete xyce;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int doNgspiceNetlist(QString schematic, QString netlist)
|
||||
int doNgspiceNetlist(QString schematicFileName, QString netlistFileName, bool netlist2Console)
|
||||
{
|
||||
QucsSettings.DefaultSimulator = spicecompat::simNgspice;
|
||||
Module::registerModules();
|
||||
Schematic *sch = openSchematic(schematic);
|
||||
if (sch == NULL) {
|
||||
|
||||
QScopedPointer<Schematic> schematic(openSchematic(schematicFileName));
|
||||
if (!schematic)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
Ngspice *ngspice = new Ngspice(sch);
|
||||
ngspice->SaveNetlist(netlist);
|
||||
delete ngspice;
|
||||
|
||||
if (!QFile::exists(netlist)) return -1;
|
||||
else return 0;
|
||||
QScopedPointer<Ngspice> ngspice(new Ngspice(schematic.get()));
|
||||
ngspice->SaveNetlist(netlistFileName, netlist2Console);
|
||||
|
||||
if (!netlist2Console && !QFile::exists(netlistFileName))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
int doXyceNetlist(QString schematic, QString netlist)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int doCdlNetlist(QString schematicFileName, QString netlistFileName, bool netlist2Console)
|
||||
{
|
||||
QucsSettings.DefaultSimulator = spicecompat::simNgspice;
|
||||
Module::registerModules();
|
||||
|
||||
QScopedPointer<Schematic> schematic(openSchematic(schematicFileName));
|
||||
if (!schematic)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
QScopedPointer<QTextStream> netlistStream;
|
||||
QScopedPointer<QString> netlistString;
|
||||
QScopedPointer<QFile> cdlFile;
|
||||
|
||||
if (netlist2Console)
|
||||
{
|
||||
netlistString.reset(new QString());
|
||||
netlistStream.reset(new QTextStream(netlistString.get()));
|
||||
}
|
||||
else
|
||||
{
|
||||
cdlFile.reset(new QFile(netlistFileName));
|
||||
|
||||
if (cdlFile->open(QFile::WriteOnly))
|
||||
{
|
||||
netlistStream.reset(new QTextStream(cdlFile.get()));
|
||||
}
|
||||
else
|
||||
{
|
||||
QString msg = QStringLiteral(
|
||||
"Tried to save netlist \nto %1\n(could not open for writing!)")
|
||||
.arg(netlistFileName);
|
||||
QString finalMsg = QStringLiteral(
|
||||
"%1\n This could be an error in the QSettings settings file\n"
|
||||
"(usually in ~/.config/qucs/qucs_s.conf)\n"
|
||||
"The value for S4Q_workdir (default:/spice4qucs) needs to be writeable!")
|
||||
.arg(msg);
|
||||
QMessageBox::critical(nullptr, QStringLiteral("Problem with SaveNetlist"), finalMsg, QMessageBox::Ok);
|
||||
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
CdlNetlistWriter cdlWriter(*netlistStream, schematic.get());
|
||||
if (!cdlWriter.write())
|
||||
{
|
||||
QMessageBox::critical(
|
||||
nullptr,
|
||||
QStringLiteral("Save CDL netlist"),
|
||||
QStringLiteral("Save CDL netlist failed!"),
|
||||
QMessageBox::Ok);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (netlist2Console)
|
||||
{
|
||||
std::cout << std::endl << netlistString->toUtf8().constData() << std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!QFile::exists(netlistFileName))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int doXyceNetlist(QString schematicFileName, QString netlistFileName, bool netlist2Console)
|
||||
{
|
||||
QucsSettings.DefaultSimulator = spicecompat::simXyce;
|
||||
Module::registerModules();
|
||||
Schematic *sch = openSchematic(schematic);
|
||||
if (sch == NULL) {
|
||||
QScopedPointer<Schematic> schematic(openSchematic(schematicFileName));
|
||||
|
||||
if (!schematic)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
Xyce *xyce = new Xyce(sch);
|
||||
xyce->SaveNetlist(netlist);
|
||||
delete xyce;
|
||||
|
||||
if (!QFile::exists(netlist)) return -1;
|
||||
else return 0;
|
||||
QScopedPointer<Xyce> xyce(new Xyce(schematic.get()));
|
||||
xyce->SaveNetlist(netlistFileName, netlist2Console);
|
||||
|
||||
if (!netlist2Console && !QFile::exists(netlistFileName))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
int doPrint(QString schematic, QString printFile,
|
||||
return 0;
|
||||
}
|
||||
|
||||
int doPrint(QString schematicFileName, QString printFile,
|
||||
QString page, int dpi, QString color, QString orientation)
|
||||
{
|
||||
QucsSettings.DefaultSimulator = spicecompat::simQucsator;
|
||||
Schematic *sch = openSchematic(schematic);
|
||||
if (sch == NULL) {
|
||||
|
||||
QScopedPointer<Schematic> schematic(openSchematic(schematicFileName));
|
||||
if (!schematic)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
sch->a_Nodes = &(sch->a_DocNodes);
|
||||
sch->a_Wires = &(sch->a_DocWires);
|
||||
sch->a_Diagrams = &(sch->a_DocDiags);
|
||||
sch->a_Paintings = &(sch->a_DocPaints);
|
||||
sch->a_Components = &(sch->a_DocComps);
|
||||
sch->reloadGraphs();
|
||||
schematic->a_Nodes = &(schematic->a_DocNodes);
|
||||
schematic->a_Wires = &(schematic->a_DocWires);
|
||||
schematic->a_Diagrams = &(schematic->a_DocDiags);
|
||||
schematic->a_Paintings = &(schematic->a_DocPaints);
|
||||
schematic->a_Components = &(schematic->a_DocComps);
|
||||
schematic->reloadGraphs();
|
||||
|
||||
qDebug() << "*** try to print file :" << printFile;
|
||||
|
||||
@ -458,11 +573,14 @@ int doPrint(QString schematic, QString printFile,
|
||||
//initial printer
|
||||
PrinterWriter *Printer = new PrinterWriter();
|
||||
Printer->setFitToPage(true);
|
||||
Printer->noGuiPrint(sch, printFile, page, dpi, color, orientation);
|
||||
} else {
|
||||
ImageWriter *Printer = new ImageWriter("");
|
||||
Printer->noGuiPrint(sch, printFile, color);
|
||||
Printer->noGuiPrint(schematic.get(), printFile, page, dpi, color, orientation);
|
||||
}
|
||||
else
|
||||
{
|
||||
ImageWriter *Printer = new ImageWriter("");
|
||||
Printer->noGuiPrint(schematic.get(), printFile, color);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -761,8 +879,8 @@ int main(int argc, char *argv[])
|
||||
QucsSettings.NodeWiring = 0;
|
||||
|
||||
// initially center the application
|
||||
QApplication a(argc, argv);
|
||||
//QDesktopWidget *d = a.desktop();
|
||||
QApplication app(argc, argv);
|
||||
//QDesktopWidget *d = app.desktop();
|
||||
QucsSettings.font = QApplication::font();
|
||||
QucsSettings.appFont = QApplication::font();
|
||||
QucsSettings.textFont = QFontDatabase::systemFont(QFontDatabase::FixedFont);
|
||||
@ -824,7 +942,6 @@ int main(int argc, char *argv[])
|
||||
QucsSettings.Qucsconv = QString(var);
|
||||
}
|
||||
|
||||
|
||||
var = getenv("ADMSXMLBINDIR");
|
||||
if (var != NULL) {
|
||||
QucsSettings.AdmsXmlBinDir.setPath(QString(var));
|
||||
@ -839,8 +956,10 @@ int main(int argc, char *argv[])
|
||||
#endif
|
||||
QFile adms(admsExec);
|
||||
if (adms.exists())
|
||||
{
|
||||
QucsSettings.AdmsXmlBinDir.setPath(QucsSettings.BinDir);
|
||||
}
|
||||
}
|
||||
|
||||
var = getenv("ASCOBINDIR");
|
||||
if (var != NULL) {
|
||||
@ -856,9 +975,10 @@ int main(int argc, char *argv[])
|
||||
#endif
|
||||
QFile asco(ascoExec);
|
||||
if (asco.exists())
|
||||
{
|
||||
QucsSettings.AscoBinDir.setPath(QucsSettings.BinDir);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
var = getenv("QUCS_OCTAVE");
|
||||
if (var != NULL) {
|
||||
@ -893,7 +1013,7 @@ int main(int argc, char *argv[])
|
||||
QucsSettings.sysDefaultFont = QApplication::font();
|
||||
QApplication::setFont(QucsSettings.appFont);
|
||||
|
||||
QTranslator tor( 0 );
|
||||
QTranslator tor(nullptr);
|
||||
QString lang = QucsSettings.Language;
|
||||
if (lang.isEmpty()) {
|
||||
QLocale loc;
|
||||
@ -907,148 +1027,211 @@ int main(int argc, char *argv[])
|
||||
// work properly !???!
|
||||
setlocale (LC_NUMERIC, "C");
|
||||
|
||||
QString inputfile;
|
||||
QString outputfile;
|
||||
|
||||
bool netlist_flag = false;
|
||||
bool print_flag = false;
|
||||
bool ngspice_flag = false;
|
||||
bool xyce_flag = false;
|
||||
bool run_flag = false;
|
||||
QString page = "A4";
|
||||
int dpi = 96;
|
||||
QString color = "RGB";
|
||||
QString orientation = "portraid";
|
||||
|
||||
// simple command line parser
|
||||
for (int i = 1; i < argc; ++i) {
|
||||
if (!strcmp(argv[i], "-h") || !strcmp(argv[i], "--help")) {
|
||||
fprintf(stdout,
|
||||
"Usage: %s [-hv] \n"
|
||||
" qucs -n -i FILENAME -o FILENAME\n"
|
||||
" qucs -p -i FILENAME -o FILENAME.[pdf|png|svg|eps] \n\n"
|
||||
" -h, --help display this help and exit\n"
|
||||
" -v, --version display version information and exit\n"
|
||||
" -n, --netlist convert Qucs schematic into netlist\n"
|
||||
" -p, --print print Qucs schematic to file (eps needs inkscape)\n"
|
||||
" --page [A4|A3|B4|B5] set print page size (default A4)\n"
|
||||
" --dpi NUMBER set dpi value (default 96)\n"
|
||||
" --color [RGB|RGB] set color mode (default RGB)\n"
|
||||
" --orin [portraid|landscape] set orientation (default portraid)\n"
|
||||
" -i FILENAME use file as input schematic\n"
|
||||
" -o FILENAME use file as output netlist\n"
|
||||
" --ngspice create Ngspice netlist\n"
|
||||
" --xyce Xyce netlist\n"
|
||||
" --run execute Ngspice/Xyce immediately\n"
|
||||
" -icons create component icons under ./bitmaps_generated\n"
|
||||
" -doc dump data for documentation:\n"
|
||||
" * file with of categories: categories.txt\n"
|
||||
" * one directory per category (e.g. ./lumped components/)\n"
|
||||
" - CSV file with component data ([comp#]_data.csv)\n"
|
||||
" - CSV file with component properties. ([comp#]_props.csv)\n"
|
||||
" -list-entries list component entry formats for schematic and netlist\n"
|
||||
, argv[0]);
|
||||
return 0;
|
||||
}
|
||||
else if (!strcmp(argv[i], "-v") || !strcmp(argv[i], "--version")) {
|
||||
#ifdef GIT
|
||||
fprintf(stdout, "qucs s" PACKAGE_VERSION " (" GIT ")" "\n");
|
||||
const QString applicationVersion(QString::fromUtf8("qucs s%1 (%2)").arg(PACKAGE_VERSION).arg(GIT));
|
||||
#else
|
||||
fprintf(stdout, "Qucs " PACKAGE_VERSION "\n");
|
||||
const QString applicationVersion(QString::fromUtf8("Qucs %1").arg(PACKAGE_VERSION));
|
||||
#endif
|
||||
return 0;
|
||||
|
||||
QCoreApplication::setApplicationVersion(applicationVersion);
|
||||
QStringList cmdArgs;
|
||||
for (int i = 0; i < argc; ++i)
|
||||
{
|
||||
cmdArgs << argv[i];
|
||||
}
|
||||
else if (!strcmp(argv[i], "-n") || !strcmp(argv[i], "--netlist")) {
|
||||
netlist_flag = true;
|
||||
|
||||
QCommandLineParser parser;
|
||||
parser.setSingleDashWordOptionMode(QCommandLineParser::ParseAsLongOptions);
|
||||
parser.addVersionOption();
|
||||
|
||||
parser.addOptions({
|
||||
{{"h", "help"}, QCoreApplication::translate("main", "display this help and exit")},
|
||||
{{"n", "netlist"}, QCoreApplication::translate("main", "convert Qucs schematic into netlist")},
|
||||
{{"p", "print"}, QCoreApplication::translate("main", "print Qucs schematic to file (eps needs inkscape)")},
|
||||
{"page", QCoreApplication::translate("main", "set print page size (default A4)"), "A4|A3|B4|B5", "A4"},
|
||||
{"dpi", QCoreApplication::translate("main", "set dpi value (default 96)"), "NUMBER", "96"},
|
||||
{"color", QCoreApplication::translate("main", "set color mode (default RGB)"), "RGB|BW", "RGB"},
|
||||
{"orin", QCoreApplication::translate("main", "set orientation (default portraid)"), "portraid|landscape", "portraid"},
|
||||
{"i", QCoreApplication::translate("main", "use file as input schematic"), "FILENAME"},
|
||||
{"o", QCoreApplication::translate("main", "use file as output netlist"), "FILENAME"},
|
||||
{"ngspice", QCoreApplication::translate("main", "create Ngspice netlist")},
|
||||
{"cdl", QCoreApplication::translate("main", "create CDL netlist")},
|
||||
{"xyce", QCoreApplication::translate("main", "Xyce netlist")},
|
||||
{"run", QCoreApplication::translate("main", "execute Ngspice/Xyce immediately")},
|
||||
{"icons", QCoreApplication::translate("main", "create component icons under ./bitmaps_generated")},
|
||||
{"doc", QCoreApplication::translate(
|
||||
"main",
|
||||
"dump data for documentation:\n"
|
||||
"* file with of categories: categories.txt\n"
|
||||
"* one directory per category (e.g. ./lumped\n"
|
||||
" components/)\n"
|
||||
" - CSV file with component data\n"
|
||||
" ([comp#]_data.csv)\n"
|
||||
" - CSV file with component properties.\n"
|
||||
" ([comp#]_props.csv)"
|
||||
)
|
||||
},
|
||||
{"list-entries", QCoreApplication::translate("main", "list component entry formats for schematic and netlist")},
|
||||
{{"c", "netlist2Console"}, QCoreApplication::translate("main", "write netlist to console")},
|
||||
});
|
||||
|
||||
parser.process(cmdArgs);
|
||||
|
||||
if (parser.isSet("help"))
|
||||
{
|
||||
// some modification of the Qt-generated usage text
|
||||
|
||||
QString helpText = parser.helpText();
|
||||
helpText.insert(
|
||||
helpText.indexOf('\n', 0)+1,
|
||||
QString::fromUtf8(
|
||||
" qucs -n -i FILENAME -o FILENAME\n"
|
||||
" qucs -p -i FILENAME -o FILENAME.[pdf|png|svg|eps]\n"));
|
||||
|
||||
QRegularExpression optIndent(QString::fromUtf8("--page|--dpi|--color|--orin|--ngspice|--xyce|--run|--cdl"));
|
||||
int idx;
|
||||
int from = 0;
|
||||
while ((idx = helpText.indexOf(optIndent, from)) != -1)
|
||||
{
|
||||
helpText.insert(idx, " ");
|
||||
from = idx +3;
|
||||
}
|
||||
else if (!strcmp(argv[i], "-p") || !strcmp(argv[i], "--print")) {
|
||||
print_flag = true;
|
||||
|
||||
std::cout << helpText.toUtf8().constData();
|
||||
exit(0);
|
||||
}
|
||||
else if (!strcmp(argv[i], "--page")) {
|
||||
page = argv[++i];
|
||||
}
|
||||
else if (!strcmp(argv[i], "--dpi")) {
|
||||
dpi = QString(argv[++i]).toInt();
|
||||
}
|
||||
else if (!strcmp(argv[i], "--color")) {
|
||||
color = argv[++i];
|
||||
}
|
||||
else if (!strcmp(argv[i], "--orin")) {
|
||||
orientation = argv[++i];
|
||||
}
|
||||
else if (!strcmp(argv[i], "-i")) {
|
||||
inputfile = argv[++i];
|
||||
}
|
||||
else if (!strcmp(argv[i], "-o")) {
|
||||
outputfile = argv[++i];
|
||||
}
|
||||
else if (!strcmp(argv[i], "--ngspice")) {
|
||||
ngspice_flag = true;
|
||||
}
|
||||
else if (!strcmp(argv[i], "--xyce")) {
|
||||
xyce_flag = true;
|
||||
}
|
||||
else if (!strcmp(argv[i], "--run")) {
|
||||
run_flag = true;
|
||||
}
|
||||
else if(!strcmp(argv[i], "-icons")) {
|
||||
|
||||
const bool netlist_flag(parser.isSet("netlist"));
|
||||
const bool print_flag(parser.isSet("print"));
|
||||
const QString page(parser.value("page"));
|
||||
const int dpi(parser.value("dpi").toInt());
|
||||
const QString color(parser.value("color"));
|
||||
const QString orientation(parser.value("orin"));
|
||||
const QString inputfile(parser.value("i"));
|
||||
const QString outputfile(parser.value("o"));
|
||||
const bool ngspice_flag(parser.isSet("ngspice"));
|
||||
const bool cdl_flag(parser.isSet("cdl"));
|
||||
const bool xyce_flag(parser.isSet("xyce"));
|
||||
const bool run_flag(parser.isSet("run"));
|
||||
const bool netlist2Console(parser.isSet("netlist2Console"));
|
||||
|
||||
#if 0
|
||||
std::cout << "Current cli values:" << std::endl;
|
||||
std::cout << "netlist_flag: " << netlist_flag << std::endl;
|
||||
std::cout << "print_flag: " << print_flag << std::endl;
|
||||
std::cout << "page: " << page.toUtf8().constData() << std::endl;
|
||||
std::cout << "dpi: " << dpi << std::endl;
|
||||
std::cout << "color: " << color.toUtf8().constData() << std::endl;
|
||||
std::cout << "orientation: " << orientation.toUtf8().constData() << std::endl;
|
||||
std::cout << "inputfile: " << inputfile.toUtf8().constData() << std::endl;
|
||||
std::cout << "outputfile: " << outputfile.toUtf8().constData() << std::endl;
|
||||
std::cout << "ngspice_flag: " << ngspice_flag << std::endl;
|
||||
std::cout << "cdl_flag: " << cdl_flag << std::endl;
|
||||
std::cout << "xyce_flag: " << xyce_flag << std::endl;
|
||||
std::cout << "run_flag: " << run_flag << std::endl;
|
||||
std::cout << "netlist2Console: " << netlist2Console << std::endl;
|
||||
std::cout << "icons: " << parser.isSet("icons") << std::endl;
|
||||
std::cout << "doc: " << parser.isSet("doc") << std::endl;
|
||||
std::cout << "list-entries: " << parser.isSet("list-entries") << std::endl;
|
||||
|
||||
exit(0);
|
||||
#endif
|
||||
|
||||
if (parser.isSet("icons"))
|
||||
{
|
||||
createIcons();
|
||||
return 0;
|
||||
}
|
||||
else if(!strcmp(argv[i], "-doc")) {
|
||||
|
||||
if (parser.isSet("doc"))
|
||||
{
|
||||
createDocData();
|
||||
return 0;
|
||||
}
|
||||
else if(!strcmp(argv[i], "-list-entries")) {
|
||||
|
||||
if (parser.isSet("list-entries"))
|
||||
{
|
||||
createListComponentEntry();
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
fprintf(stderr, "Error: Unknown option: %s\n", argv[i]);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
// check operation and its required arguments
|
||||
if (netlist_flag and print_flag) {
|
||||
if (netlist_flag and print_flag)
|
||||
{
|
||||
fprintf(stderr, "Error: --print and --netlist cannot be used together\n");
|
||||
return -1;
|
||||
} else if (((ngspice_flag||xyce_flag) && print_flag)||
|
||||
(run_flag && print_flag))
|
||||
}
|
||||
else if (cdl_flag and run_flag)
|
||||
{
|
||||
fprintf(stderr, "Error: --print and Ngspice/Xyce cannot be used together\n");
|
||||
fprintf(stderr, "Error: --cdl and --run cannot be used together\n");
|
||||
return -1;
|
||||
} else if (netlist_flag or print_flag) {
|
||||
if (inputfile.isEmpty()) {
|
||||
}
|
||||
else if (((ngspice_flag || xyce_flag || cdl_flag) && print_flag) || (run_flag && print_flag))
|
||||
{
|
||||
fprintf(stderr, "Error: --print and Ngspice/CDL/Xyce cannot be used together\n");
|
||||
return -1;
|
||||
}
|
||||
else if (netlist_flag or print_flag)
|
||||
{
|
||||
if (inputfile.isEmpty())
|
||||
{
|
||||
fprintf(stderr, "Error: Expected input file.\n");
|
||||
return -1;
|
||||
}
|
||||
if (outputfile.isEmpty()) {
|
||||
if (!netlist2Console && outputfile.isEmpty())
|
||||
{
|
||||
fprintf(stderr, "Error: Expected output file.\n");
|
||||
return -1;
|
||||
}
|
||||
// create netlist from schematic
|
||||
if (netlist_flag) {
|
||||
if (!run_flag) {
|
||||
if (ngspice_flag) return doNgspiceNetlist(inputfile, outputfile);
|
||||
else if (xyce_flag) return doXyceNetlist(inputfile, outputfile);
|
||||
else return doNetlist(inputfile, outputfile);
|
||||
} else {
|
||||
if (ngspice_flag) return runNgspice(inputfile, outputfile);
|
||||
else if (xyce_flag) return runXyce(inputfile, outputfile);
|
||||
else return 1;
|
||||
if (netlist_flag)
|
||||
{
|
||||
if (!run_flag)
|
||||
{
|
||||
if (ngspice_flag)
|
||||
{
|
||||
return doNgspiceNetlist(inputfile, outputfile, netlist2Console);
|
||||
}
|
||||
} else if (print_flag) {
|
||||
return doPrint(inputfile, outputfile,
|
||||
page, dpi, color, orientation);
|
||||
else if (cdl_flag)
|
||||
{
|
||||
return doCdlNetlist(inputfile, outputfile, netlist2Console);
|
||||
}
|
||||
else if (xyce_flag)
|
||||
{
|
||||
return doXyceNetlist(inputfile, outputfile, netlist2Console);
|
||||
}
|
||||
else
|
||||
{
|
||||
return doNetlist(inputfile, outputfile, netlist2Console);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ngspice_flag)
|
||||
{
|
||||
return runNgspice(inputfile, outputfile);
|
||||
}
|
||||
else if (xyce_flag)
|
||||
{
|
||||
return runXyce(inputfile, outputfile);
|
||||
}
|
||||
else
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (print_flag)
|
||||
{
|
||||
return doPrint(inputfile, outputfile, page, dpi, color, orientation);
|
||||
}
|
||||
}
|
||||
|
||||
QucsMain = new QucsApp();
|
||||
QucsMain = new QucsApp(netlist2Console);
|
||||
//1a.setMainWidget(QucsMain);
|
||||
|
||||
QucsMain->show();
|
||||
int result = a.exec();
|
||||
int result = app.exec();
|
||||
//saveApplSettings(QucsMain);
|
||||
return result;
|
||||
}
|
||||
|
122
qucs/qucs.cpp
122
qucs/qucs.cpp
@ -88,9 +88,9 @@
|
||||
//#include "extsimkernels/codemodelgen.h"
|
||||
#include "symbolwidget.h"
|
||||
|
||||
QucsApp::QucsApp()
|
||||
QucsApp::QucsApp(bool netlist2Console) :
|
||||
a_netlist2Console(netlist2Console)
|
||||
{
|
||||
|
||||
windowTitle = misc::getWindowTitle();
|
||||
setWindowTitle(windowTitle);
|
||||
|
||||
@ -575,11 +575,11 @@ void QucsApp::initView()
|
||||
messageDock = new MessageDock(this);
|
||||
|
||||
// initial projects directory model
|
||||
m_homeDirModel = new QucsFileSystemModel(this);
|
||||
m_proxyModel = new QucsSortFilterProxyModel();
|
||||
//m_proxyModel->setDynamicSortFilter(true);
|
||||
a_homeDirModel = new QucsFileSystemModel(this);
|
||||
a_proxyModel = new QucsSortFilterProxyModel();
|
||||
//a_proxyModel->setDynamicSortFilter(true);
|
||||
// show all directories (project and non-project)
|
||||
m_homeDirModel->setFilter(QDir::NoDot | QDir::AllDirs);
|
||||
a_homeDirModel->setFilter(QDir::NoDot | QDir::AllDirs);
|
||||
|
||||
// ............................................
|
||||
QString path = QucsSettings.qucsWorkspaceDir.absolutePath();
|
||||
@ -1386,21 +1386,21 @@ void QucsApp::readProjects()
|
||||
|
||||
if (path == homepath) {
|
||||
// in Qucs Home, disallow further up in the dirs tree
|
||||
m_homeDirModel->setFilter(QDir::NoDotAndDotDot | QDir::AllDirs);
|
||||
a_homeDirModel->setFilter(QDir::NoDotAndDotDot | QDir::AllDirs);
|
||||
} else {
|
||||
m_homeDirModel->setFilter(QDir::NoDot | QDir::AllDirs);
|
||||
a_homeDirModel->setFilter(QDir::NoDot | QDir::AllDirs);
|
||||
}
|
||||
|
||||
// set the root path
|
||||
QModelIndex rootModelIndex = m_homeDirModel->setRootPath(path);
|
||||
QModelIndex rootModelIndex = a_homeDirModel->setRootPath(path);
|
||||
// assign the model to the proxy and the proxy to the view
|
||||
m_proxyModel->setSourceModel(m_homeDirModel);
|
||||
m_proxyModel->setSortCaseSensitivity(Qt::CaseInsensitive);
|
||||
a_proxyModel->setSourceModel(a_homeDirModel);
|
||||
a_proxyModel->setSortCaseSensitivity(Qt::CaseInsensitive);
|
||||
// sort by first column (file name, only column show in the QListView)
|
||||
m_proxyModel->sort(0);
|
||||
Projects->setModel(m_proxyModel);
|
||||
a_proxyModel->sort(0);
|
||||
Projects->setModel(a_proxyModel);
|
||||
// fix the listview on the root path of the model
|
||||
Projects->setRootIndex(m_proxyModel->mapFromSource(rootModelIndex));
|
||||
Projects->setRootIndex(a_proxyModel->mapFromSource(rootModelIndex));
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------
|
||||
@ -2410,7 +2410,7 @@ void QucsApp::slotTune(bool checked)
|
||||
return;
|
||||
}
|
||||
|
||||
Schematic *d = dynamic_cast<Schematic*>(w);
|
||||
Schematic* d(dynamic_cast<Schematic*>(w));
|
||||
assert(d);
|
||||
|
||||
bool found = false;
|
||||
@ -3463,57 +3463,83 @@ void QucsApp::slotSimSettings()
|
||||
|
||||
void QucsApp::slotSimulateWithSpice()
|
||||
{
|
||||
if (!isTextDocument(DocumentTab->currentWidget())) {
|
||||
Schematic *sch = (Schematic*)DocumentTab->currentWidget();
|
||||
if (TuningMode) {
|
||||
QFileInfo Info(sch->getDocName());
|
||||
if (!isTextDocument(DocumentTab->currentWidget()))
|
||||
{
|
||||
Schematic* schematic(dynamic_cast<Schematic*>(DocumentTab->currentWidget()));
|
||||
if (TuningMode)
|
||||
{
|
||||
QFileInfo Info(schematic->getDocName());
|
||||
QString ext = Info.suffix();
|
||||
if (ext == "dpl") {
|
||||
QucsDoc *Doc = (QucsDoc *)sch;
|
||||
sch = (Schematic *) getSchematicWidget(Doc);
|
||||
if (sch == nullptr) return;
|
||||
if (ext == "dpl")
|
||||
{
|
||||
QucsDoc *doc(dynamic_cast<QucsDoc*>(schematic));
|
||||
Q_ASSERT(doc != nullptr);
|
||||
schematic = dynamic_cast<Schematic*>(getSchematicWidget(doc));
|
||||
if (schematic == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (sch->getDocName().isEmpty()) {
|
||||
auto biasState = sch->getShowBias();
|
||||
QMessageBox::warning(this,tr("Simulate schematic"),
|
||||
if (schematic->getDocName().isEmpty())
|
||||
{
|
||||
auto biasState = schematic->getShowBias();
|
||||
QMessageBox::warning(
|
||||
this,
|
||||
tr("Simulate schematic"),
|
||||
tr("Schematic not saved! Simulation of unsaved schematic "
|
||||
"not possible. Save schematic first!"));
|
||||
slotFileSaveAs();
|
||||
sch->setShowBias(biasState);
|
||||
schematic->setShowBias(biasState);
|
||||
}
|
||||
ExternSimDialog *SimDlg = new ExternSimDialog(sch);
|
||||
connect(SimDlg,SIGNAL(simulated(ExternSimDialog*)),
|
||||
this,SLOT(slotAfterSpiceSimulation(ExternSimDialog*)));
|
||||
ExternSimDialog *SimDlg = new ExternSimDialog(schematic, false);
|
||||
connect(SimDlg, SIGNAL(simulated(ExternSimDialog*)), this, SLOT(slotAfterSpiceSimulation(ExternSimDialog*)));
|
||||
connect(SimDlg, SIGNAL(warnings()), this, SLOT(slotShowWarnings()));
|
||||
connect(SimDlg, SIGNAL(success()), this, SLOT(slotResetWarnings()));
|
||||
if (TuningMode || sch->getShowBias() == 0) SimDlg->slotStart();
|
||||
else SimDlg->exec();
|
||||
|
||||
if (TuningMode || schematic->getShowBias() == 0)
|
||||
{
|
||||
SimDlg->slotStart();
|
||||
}
|
||||
else
|
||||
{
|
||||
SimDlg->exec();
|
||||
}
|
||||
/*disconnect(SimDlg, SIGNAL(simulated()), this, SLOT(slotAfterSpiceSimulation()));
|
||||
disconnect(SimDlg, SIGNAL(warnings()), this, SLOT(slotShowWarnings()));
|
||||
disconnect(SimDlg, SIGNAL(success()), this, SLOT(slotResetWarnings()));*/
|
||||
/*if (SimDlg->wasSimulated && sch->getSimOpenDpl())
|
||||
if (sch->getShowBias() < 1) slotChangePage(sch->getDocName(),sch->getDataDisplay());
|
||||
/*if (SimDlg->wasSimulated && schematic->getSimOpenDpl())
|
||||
if (schematic->getShowBias() < 1) slotChangePage(schematic->getDocName(), schematic->getDataDisplay());
|
||||
delete SimDlg;*/
|
||||
} else {
|
||||
QMessageBox::warning(this,tr("Simulate schematic"),
|
||||
}
|
||||
else
|
||||
{
|
||||
QMessageBox::warning(
|
||||
this,
|
||||
tr("Simulate schematic"),
|
||||
tr("Simulation of text document is not possible!"));
|
||||
}
|
||||
}
|
||||
|
||||
void QucsApp::slotSaveNetlist()
|
||||
{
|
||||
if (QucsSettings.DefaultSimulator == spicecompat::simQucsator) {
|
||||
QMessageBox::information(this,tr("Save netlist"),
|
||||
if (QucsSettings.DefaultSimulator == spicecompat::simQucsator)
|
||||
{
|
||||
QMessageBox::information(
|
||||
this,
|
||||
tr("Save netlist"),
|
||||
tr("This action is supported only for SPICE simulators!"));
|
||||
return;
|
||||
}
|
||||
if (!isTextDocument(DocumentTab->currentWidget())) {
|
||||
Schematic *sch = (Schematic*)DocumentTab->currentWidget();
|
||||
ExternSimDialog *SimDlg = new ExternSimDialog(sch, true);
|
||||
SimDlg->slotSaveNetlist();
|
||||
delete SimDlg;
|
||||
|
||||
if (!isTextDocument(DocumentTab->currentWidget()))
|
||||
{
|
||||
Schematic* schematic(dynamic_cast<Schematic*>(DocumentTab->currentWidget()));
|
||||
Q_ASSERT(schematic != nullptr);
|
||||
|
||||
ExternSimDialog simDlg(schematic, a_netlist2Console, true);
|
||||
simDlg.slotSaveNetlist();
|
||||
}
|
||||
}
|
||||
|
||||
@ -3524,7 +3550,8 @@ void QucsApp::slotSaveCdlNetlist()
|
||||
Schematic* schematic = dynamic_cast<Schematic*>(DocumentTab->currentWidget());
|
||||
Q_ASSERT(schematic != nullptr);
|
||||
|
||||
#ifdef NETLIST_CDL_TO_CONSOLE // for fast testing purposes
|
||||
if (a_netlist2Console)
|
||||
{
|
||||
QString netlistString;
|
||||
{
|
||||
QTextStream netlistStream(&netlistString);
|
||||
@ -3540,7 +3567,9 @@ void QucsApp::slotSaveCdlNetlist()
|
||||
printf("\nCDL netlist:\n%s\n", netlistString.toUtf8().constData());
|
||||
Content->refresh();
|
||||
}
|
||||
#else
|
||||
}
|
||||
else
|
||||
{
|
||||
QFileInfo inf(schematic->getDocName());
|
||||
QString filename = QFileDialog::getSaveFileName(
|
||||
this,
|
||||
@ -3569,8 +3598,7 @@ void QucsApp::slotSaveCdlNetlist()
|
||||
netlistFile.close();
|
||||
Content->refresh();
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -88,7 +88,7 @@ protected:
|
||||
class QucsApp : public QMainWindow {
|
||||
Q_OBJECT
|
||||
public:
|
||||
QucsApp();
|
||||
QucsApp(bool netlist2Console);
|
||||
~QucsApp();
|
||||
bool closeAllFiles();
|
||||
bool gotoPage(const QString&); // to load a document
|
||||
@ -251,10 +251,10 @@ private:
|
||||
// ********** Properties ************************************************
|
||||
QStack<QString> HierarchyHistory; // keeps track of "go into subcircuit"
|
||||
QString QucsFileFilter;
|
||||
QFileSystemModel *m_homeDirModel;
|
||||
QucsSortFilterProxyModel *m_proxyModel;
|
||||
QFileSystemModel *m_projModel;
|
||||
QFileSystemModel *a_homeDirModel;
|
||||
QucsSortFilterProxyModel *a_proxyModel;
|
||||
int ccCurIdx; // CompChooser current index (used during search)
|
||||
bool a_netlist2Console;
|
||||
|
||||
// ********** Methods ***************************************************
|
||||
void initView();
|
||||
|
@ -574,12 +574,12 @@ void QucsApp::initActions()
|
||||
|
||||
save_netlist = new QAction(tr("Save netlist"), this);
|
||||
save_netlist->setStatusTip(tr("Save netlist"));
|
||||
save_netlist->setWhatsThis(tr("Save netlist to file"));
|
||||
save_netlist->setWhatsThis(tr(QString::fromUtf8("Save netlist to %1").arg(a_netlist2Console ? "console" : "file").toLatin1().constData()));
|
||||
connect(save_netlist, SIGNAL(triggered()), SLOT(slotSaveNetlist()));
|
||||
|
||||
saveCdlNetlist = new QAction(tr("Save CDL netlist"), this);
|
||||
saveCdlNetlist->setStatusTip(tr("Save CDL netlist"));
|
||||
saveCdlNetlist->setWhatsThis(tr("Save CDL netlist to file"));
|
||||
saveCdlNetlist->setWhatsThis(tr(QString::fromUtf8("Save CDL netlist to %1").arg(a_netlist2Console ? "console" : "file").toLatin1().constData()));
|
||||
connect(saveCdlNetlist, SIGNAL(triggered()), SLOT(slotSaveCdlNetlist()));
|
||||
|
||||
setMarker = new QAction(QIcon((":/bitmaps/svg/marker.svg")), tr("Set Marker on Graph"), this);
|
||||
|
@ -77,9 +77,9 @@ Element* InclScript::info(QString& Name, char* &BitmapFile, bool getNewOne)
|
||||
return 0;
|
||||
}
|
||||
|
||||
QString InclScript::getExpression(bool, bool isCdl /* = false */)
|
||||
QString InclScript::getExpression(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */)
|
||||
{
|
||||
if (isActive != COMP_IS_ACTIVE || isCdl)
|
||||
if (isActive != COMP_IS_ACTIVE || dialect == spicecompat::CDL)
|
||||
return QString();
|
||||
return Props.at(0)->Value+"\n";
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ public:
|
||||
~InclScript();
|
||||
Component* newOne();
|
||||
static Element* info(QString&, char* &, bool getNewOne=false);
|
||||
QString getExpression(bool isXyce, bool isCdl = false);
|
||||
QString getExpression(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault);
|
||||
|
||||
protected:
|
||||
QString vhdlCode(int) { return QString(); }
|
||||
|
@ -69,8 +69,10 @@ Element* SpiceCSParam::info(QString& Name, char* &BitmapFile, bool getNewOne)
|
||||
return 0;
|
||||
}
|
||||
|
||||
QString SpiceCSParam::getExpression(bool)
|
||||
QString SpiceCSParam::getExpression(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */)
|
||||
{
|
||||
Q_UNUSED(dialect);
|
||||
|
||||
if (isActive != COMP_IS_ACTIVE) return QString();
|
||||
|
||||
QString s;
|
||||
|
@ -29,7 +29,7 @@ public:
|
||||
Component* newOne();
|
||||
static Element* info(QString&, char* &, bool getNewOne=false);
|
||||
static void splitEqn(QString &eqn, QStringList &tokens);
|
||||
QString getExpression(bool isXyce = false);
|
||||
QString getExpression(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault);
|
||||
|
||||
protected:
|
||||
QString netlist() { return QString(); }
|
||||
|
@ -70,9 +70,9 @@ Element* SpiceFunc::info(QString& Name, char* &BitmapFile, bool getNewOne)
|
||||
return 0;
|
||||
}
|
||||
|
||||
QString SpiceFunc::getExpression(bool, bool isCdl /* = false */)
|
||||
QString SpiceFunc::getExpression(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */)
|
||||
{
|
||||
if (isActive != COMP_IS_ACTIVE || isCdl) return QString();
|
||||
if (isActive != COMP_IS_ACTIVE || dialect == spicecompat::CDL) return QString();
|
||||
|
||||
QString s;
|
||||
s.clear();
|
||||
|
@ -28,7 +28,7 @@ public:
|
||||
~SpiceFunc();
|
||||
Component* newOne();
|
||||
static Element* info(QString&, char* &, bool getNewOne=false);
|
||||
QString getExpression(bool isXyce, bool isCdl = false);
|
||||
QString getExpression(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault);
|
||||
|
||||
protected:
|
||||
QString vhdlCode(int) { return QString(); }
|
||||
|
@ -70,14 +70,15 @@ Element* SpiceGlobalParam::info(QString& Name, char* &BitmapFile, bool getNewOne
|
||||
}
|
||||
|
||||
|
||||
QString SpiceGlobalParam::getExpression(bool, bool isCdl /* = false */)
|
||||
QString SpiceGlobalParam::getExpression(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */)
|
||||
{
|
||||
if (isActive != COMP_IS_ACTIVE) return QString();
|
||||
|
||||
QString s;
|
||||
s.clear();
|
||||
for (Property *pp : Props) {
|
||||
s += QStringLiteral(".%1PARAM %2 = %3\n").arg(isCdl ? "" : "GLOBAL_").arg(pp->Name).arg(pp->Value);
|
||||
s += QStringLiteral(".%1PARAM %2 = %3\n")
|
||||
.arg(dialect == spicecompat::CDL ? "" : "GLOBAL_").arg(pp->Name).arg(pp->Value);
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ public:
|
||||
Component* newOne();
|
||||
static Element* info(QString&, char* &, bool getNewOne=false);
|
||||
static void splitEqn(QString &eqn, QStringList &tokens);
|
||||
QString getExpression(bool isXyce, bool isCdl = false);
|
||||
QString getExpression(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault);
|
||||
|
||||
protected:
|
||||
QString vhdlCode(int) { return QString(); }
|
||||
|
@ -69,9 +69,9 @@ Element* SpiceIC::info(QString& Name, char* &BitmapFile, bool getNewOne)
|
||||
return 0;
|
||||
}
|
||||
|
||||
QString SpiceIC::getExpression(bool, bool isCdl /* = false */)
|
||||
QString SpiceIC::getExpression(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */)
|
||||
{
|
||||
if (isActive != COMP_IS_ACTIVE || isCdl) return QString();
|
||||
if (isActive != COMP_IS_ACTIVE || dialect == spicecompat::CDL) return QString();
|
||||
|
||||
QString s;
|
||||
s.clear();
|
||||
|
@ -28,7 +28,7 @@ public:
|
||||
~SpiceIC();
|
||||
Component* newOne();
|
||||
static Element* info(QString&, char* &, bool getNewOne=false);
|
||||
QString getExpression(bool isXyce, bool isCdl = false);
|
||||
QString getExpression(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault);
|
||||
|
||||
protected:
|
||||
QString vhdlCode(int) { return QString(); }
|
||||
|
@ -69,9 +69,9 @@ Element* SpiceNodeset::info(QString& Name, char* &BitmapFile, bool getNewOne)
|
||||
return 0;
|
||||
}
|
||||
|
||||
QString SpiceNodeset::getExpression(bool, bool isCdl /* = false */)
|
||||
QString SpiceNodeset::getExpression(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */)
|
||||
{
|
||||
if (isActive != COMP_IS_ACTIVE || isCdl) return QString();
|
||||
if (isActive != COMP_IS_ACTIVE || dialect == spicecompat::CDL) return QString();
|
||||
|
||||
QString s;
|
||||
s.clear();
|
||||
|
@ -28,7 +28,7 @@ public:
|
||||
~SpiceNodeset();
|
||||
Component* newOne();
|
||||
static Element* info(QString&, char* &, bool getNewOne=false);
|
||||
QString getExpression(bool isXyce, bool isCdl = false);
|
||||
QString getExpression(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault);
|
||||
|
||||
protected:
|
||||
QString vhdlCode(int) { return QString(); }
|
||||
|
@ -71,13 +71,13 @@ Element* SpiceOptions::info(QString& Name, char* &BitmapFile, bool getNewOne)
|
||||
return 0;
|
||||
}
|
||||
|
||||
QString SpiceOptions::getExpression(bool isXyce, bool isCdl /* = false */)
|
||||
QString SpiceOptions::getExpression(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */)
|
||||
{
|
||||
if (isActive != COMP_IS_ACTIVE || isCdl) return QString();
|
||||
if (isActive != COMP_IS_ACTIVE || dialect == spicecompat::CDL) return QString();
|
||||
|
||||
QString s;
|
||||
s.clear();
|
||||
if (isXyce) {
|
||||
if (dialect == spicecompat::SPICEXyce) {
|
||||
s += QStringLiteral(".OPTIONS %1 ").arg(Props.at(0)->Value);
|
||||
for (int i=1;i<Props.count();i++) {
|
||||
s += QStringLiteral(" %1 = %2 ").arg(Props.at(i)->Name).arg(Props.at(i)->Value);
|
||||
|
@ -29,7 +29,7 @@ public:
|
||||
Component* newOne();
|
||||
static Element* info(QString&, char* &, bool getNewOne=false);
|
||||
static void splitEqn(QString &eqn, QStringList &tokens);
|
||||
QString getExpression(bool isXyce, bool isCdl = false);
|
||||
QString getExpression(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault);
|
||||
|
||||
protected:
|
||||
QString vhdlCode(int) { return QString(); }
|
||||
|
@ -69,14 +69,14 @@ Element* SpiceParam::info(QString& Name, char* &BitmapFile, bool getNewOne)
|
||||
return 0;
|
||||
}
|
||||
|
||||
QString SpiceParam::getExpression(bool, bool isCdl /* = false */)
|
||||
QString SpiceParam::getExpression(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */)
|
||||
{
|
||||
if (isActive != COMP_IS_ACTIVE) return QString();
|
||||
|
||||
QString s;
|
||||
s.clear();
|
||||
for (Property *pp : Props) {
|
||||
if (isCdl)
|
||||
if (dialect == spicecompat::CDL)
|
||||
{
|
||||
s += QStringLiteral(".PARAM %1=%2\n").arg(pp->Name).arg(pp->Value);
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ public:
|
||||
Component* newOne();
|
||||
static Element* info(QString&, char* &, bool getNewOne=false);
|
||||
static void splitEqn(QString &eqn, QStringList &tokens);
|
||||
QString getExpression(bool isXyce, bool isCdl = false);
|
||||
QString getExpression(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault);
|
||||
|
||||
protected:
|
||||
QString vhdlCode(int) { return QString(); }
|
||||
|
Loading…
x
Reference in New Issue
Block a user