Skip to content

Commit

Permalink
Always apply custom prefix enclosed by '#'
Browse files Browse the repository at this point in the history
This fixes a regression in ra3xdh#513. If the only simulation is custom
and it contains custom prefixed output, the custom prefix is not applied.
  • Loading branch information
ivandi committed Feb 17, 2024
1 parent 41cd865 commit b7cf37a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
28 changes: 15 additions & 13 deletions qucs/extsimkernels/abstractspicekernel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1175,12 +1175,14 @@ void AbstractSpiceKernel::convertToQucsData(const QString &qucs_dataset)
bool hasParSweep = false;
bool hasDblParSweep = false;

QString custom_prefix;
QString dataset_prefix;
bool isCustomPrefix = false;
if ( ngspice_output_filename.startsWith("spice4qucs.") ) {
custom_prefix = ngspice_output_filename.section('.', 1, 1).toLower();
dataset_prefix = ngspice_output_filename.section('.', 1, 1).toLower();
} else {
QRegularExpression custom_prefix_rx("(?<=#).*?(?=#)");
custom_prefix = custom_prefix_rx.match(ngspice_output_filename).captured(0).toLower();
QRegularExpression dataset_prefix_rx("(?<=#).*?(?=#)");
dataset_prefix = dataset_prefix_rx.match(ngspice_output_filename).captured(0).toLower();
isCustomPrefix = !dataset_prefix.isEmpty();
}
QRegularExpression four_rx(".*\\.four[0-9]+$");
QString full_outfile = workdir+QDir::separator()+ngspice_output_filename;
Expand Down Expand Up @@ -1210,15 +1212,15 @@ void AbstractSpiceKernel::convertToQucsData(const QString &qucs_dataset)
parseNoiseOutput(full_outfile,sim_points,var_list,hasParSweep);
if (hasParSweep) {
QString res_file = QDir::toNativeSeparators(workdir + QDir::separator()
+ "spice4qucs." + custom_prefix + ".cir.res");
+ "spice4qucs." + dataset_prefix + ".cir.res");
parseResFile(res_file,swp_var,swp_var_val);
}
} else if (ngspice_output_filename.endsWith(".pz")) {
isComplex = true;
parsePZOutput(full_outfile,sim_points,var_list,hasParSweep);
if (hasParSweep) {
QString res_file = QDir::toNativeSeparators(workdir + QDir::separator()
+ "spice4qucs." + custom_prefix + ".cir.res");
+ "spice4qucs." + dataset_prefix + ".cir.res");
parseResFile(res_file,swp_var,swp_var_val);
}
} else if (ngspice_output_filename.endsWith(".SENS.prn")) {
Expand All @@ -1236,12 +1238,12 @@ void AbstractSpiceKernel::convertToQucsData(const QString &qucs_dataset)
if (ngspice_output_filename.endsWith("_swp_swp.plot")) { // 2-var parameter sweep
hasDblParSweep = true;
QString res2_file = QDir::toNativeSeparators(workdir + QDir::separator()
+ "spice4qucs." + custom_prefix + ".cir.res1");
+ "spice4qucs." + dataset_prefix + ".cir.res1");
parseResFile(res2_file,swp_var2,swp_var2_val);
}

QString res_file = QDir::toNativeSeparators(workdir + QDir::separator()
+ "spice4qucs." + custom_prefix + ".cir.res");
+ "spice4qucs." + dataset_prefix + ".cir.res");
parseResFile(res_file,swp_var,swp_var_val);

parseSTEPOutput(full_outfile,sim_points,var_list,isComplex);
Expand Down Expand Up @@ -1273,7 +1275,7 @@ void AbstractSpiceKernel::convertToQucsData(const QString &qucs_dataset)
}
}
if (var_list.isEmpty()) continue; // nothing to convert
normalizeVarsNames(var_list, custom_prefix);
normalizeVarsNames(var_list, dataset_prefix, isCustomPrefix);

QString indep = var_list.first();
//QList<double> sim_point;
Expand Down Expand Up @@ -1377,7 +1379,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, const QString &custom_prefix)
void AbstractSpiceKernel::normalizeVarsNames(QStringList &var_list, const QString &dataset_prefix, bool isCustom)
{
QString prefix="";
QString iprefix="";
Expand Down Expand Up @@ -1434,11 +1436,11 @@ void AbstractSpiceKernel::normalizeVarsNames(QStringList &var_list, const QStrin
}
}

if ( needsPrefix )
if ( !custom_prefix.isEmpty() ) {
if ( needsPrefix || isCustom )
if ( !dataset_prefix.isEmpty() ) {
for ( it = var_list.begin() ; it != var_list.end() ; ++it)
if ( !(*it).isEmpty() )
(*it).prepend(custom_prefix + ".");
(*it).prepend(dataset_prefix + ".");
}
}

Expand Down
2 changes: 1 addition & 1 deletion qucs/extsimkernels/abstractspicekernel.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class AbstractSpiceKernel : public QObject
private:
enum outType {xyceSTD, spiceRaw, spiceRawSwp, xyceSTDswp, spicePrn, Unknown};

void normalizeVarsNames(QStringList &var_list, const QString &custom_prefix);
void normalizeVarsNames(QStringList &var_list, const QString &dataset_prefix, bool isCustom = false);
int checkRawOutupt(QString ngspice_file, QStringList &values);
void extractBinSamples(QDataStream &dbl, QList< QList<double> > &sim_points,
int NumPoints, int NumVars, bool isComplex);
Expand Down

0 comments on commit b7cf37a

Please sign in to comment.