Merge pull request #412 from ivandi69/custom_prefix

Add support for custom prefix to dataset variables
This commit is contained in:
Vadim Kuznetsov 2024-01-08 17:03:11 +03:00 committed by GitHub
commit fc497990f7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 21 additions and 14 deletions

View File

@ -1107,6 +1107,8 @@ void AbstractSpiceKernel::convertToQucsData(const QString &qucs_dataset)
bool hasParSweep = false;
bool hasDblParSweep = false;
QRegularExpression custom_prefix_rx("(?<=#).*?(?=#)");
QString custom_prefix = custom_prefix_rx.match(ngspice_output_filename).captured(0);
QRegularExpression four_rx(".*\\.four[0-9]+$");
QString full_outfile = workdir+QDir::separator()+ngspice_output_filename;
if (ngspice_output_filename.endsWith("HB.FD.prn")) {
@ -1199,7 +1201,7 @@ void AbstractSpiceKernel::convertToQucsData(const QString &qucs_dataset)
}
}
if (var_list.isEmpty()) continue; // nothing to convert
normalizeVarsNames(var_list);
normalizeVarsNames(var_list, custom_prefix);
QString indep = var_list.first();
//QList<double> sim_point;
@ -1298,7 +1300,7 @@ void AbstractSpiceKernel::removeAllSimulatorOutputs()
* for harmonic balance variable and current probes variables are supported.
* \param var_list This list contains variable names that need normalization.
*/
void AbstractSpiceKernel::normalizeVarsNames(QStringList &var_list)
void AbstractSpiceKernel::normalizeVarsNames(QStringList &var_list, const QString &custom_prefix)
{
QString prefix="";
QString iprefix="";
@ -1355,6 +1357,11 @@ void AbstractSpiceKernel::normalizeVarsNames(QStringList &var_list)
}
}
if ( !custom_prefix.isEmpty() ) {
for ( it = var_list.begin() ; it != var_list.end() ; ++it)
if ( !(*it).isEmpty() )
(*it).prepend(custom_prefix + ".");
}
}
/*!

View File

@ -48,7 +48,7 @@ class AbstractSpiceKernel : public QObject
private:
enum outType {xyceSTD, spiceRaw, spiceRawSwp, xyceSTDswp, Unknown};
void normalizeVarsNames(QStringList &var_list);
void normalizeVarsNames(QStringList &var_list, const QString &custom_prefix);
int checkRawOutupt(QString ngspice_file, QStringList &values);
void extractBinSamples(QDataStream &dbl, QList< QList<double> > &sim_points,
int NumPoints, int NumVars, bool isComplex);

View File

@ -100,18 +100,18 @@ void Ngspice::createNetlist(QTextStream &stream, int ,
if(pc->isSimulation && pc->isActive == COMP_IS_ACTIVE) {
s = pc->getSpiceNetlist();
QString sim_typ = pc->Model;
if (sim_typ==".AC") simulations.append("ac");
if (sim_typ==".TR") simulations.append("tran");
if (sim_typ==".CUSTOMSIM") simulations.append("custom");
if (sim_typ==".DISTO") simulations.append("disto");
if (sim_typ==".NOISE") simulations.append("noise");
if (sim_typ==".PZ") simulations.append("pz");
if (sim_typ==".SENS") simulations.append("sens");
if (sim_typ==".SENS_AC") simulations.append("sens_ac");
if (sim_typ==".SP") simulations.append("sp");
if (sim_typ==".FFT") simulations.append("fft");
if (sim_typ==".AC") if(!simulations.contains("ac")) simulations.append("ac");
if (sim_typ==".TR") if(!simulations.contains("tran")) simulations.append("tran");
if (sim_typ==".CUSTOMSIM") if(!simulations.contains("custom")) simulations.append("custom");
if (sim_typ==".DISTO") if(!simulations.contains("disto")) simulations.append("disto");
if (sim_typ==".NOISE") if(!simulations.contains("noise")) simulations.append("noise");
if (sim_typ==".PZ") if(!simulations.contains("pz")) simulations.append("pz");
if (sim_typ==".SENS") if(!simulations.contains("sens")) simulations.append("sens");
if (sim_typ==".SENS_AC") if(!simulations.contains("sens_ac")) simulations.append("sens_ac");
if (sim_typ==".SP") if(!simulations.contains("sp")) simulations.append("sp");
if (sim_typ==".FFT") if(!simulations.contains("fft")) simulations.append("fft");
if ((sim_typ==".SW")&&
(pc->Props.at(0)->Value.startsWith("DC"))) simulations.append("dc");
(pc->Props.at(0)->Value.startsWith("DC"))) if(!simulations.contains("dc")) simulations.append("dc");
// stream<<s;
}
}