Skip to content

Commit

Permalink
Add new API call for OMEdit to query valid config flag options, like …
Browse files Browse the repository at this point in the history
…`getConfigFlagValidOptions("profiling")`

git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@20322 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
sjoelund committed Apr 30, 2014
1 parent 0241f4c commit b2da5dd
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 26 deletions.
19 changes: 11 additions & 8 deletions OMEdit/OMEditGUI/GUI/Dialogs/SimulationDialog.cpp
Expand Up @@ -252,7 +252,12 @@ void SimulationDialog::setUpForm()
mpOutputVariablesLabel->setToolTip(tr("Comma separated list of variables. Output the variables at the end of the simulation to the standard output."));
mpOutputVariablesTextBox = new QLineEdit;
// measure simulation time checkbox
mpProfilingCheckBox = new QCheckBox(tr("Profiling (~5-25% overhead)"));
QLabel *mpProfilingLabel = new Label(tr("Profiling (enable performance measurements)"));
mpProfilingCheckBox = new QComboBox();
QStringList profilingOptions = mpMainWindow->getOMCProxy()->getConfigFlagValidOptions("profiling");
mpProfilingCheckBox->addItems(profilingOptions);
mpProfilingCheckBox->setCurrentIndex(0);
mpProfilingCheckBox->setToolTip(mpMainWindow->getOMCProxy()->help("profiling"));
// cpu-time checkbox
mpCPUTimeCheckBox = new QCheckBox(tr("CPU Time"));
// enable all warnings
Expand Down Expand Up @@ -346,7 +351,8 @@ void SimulationDialog::setUpForm()
pSimulationFlagsTabLayout->addWidget(mpLinearizationTimeTextBox, 8, 1, 1, 2);
pSimulationFlagsTabLayout->addWidget(mpOutputVariablesLabel, 9, 0);
pSimulationFlagsTabLayout->addWidget(mpOutputVariablesTextBox, 9, 1, 1, 2);
pSimulationFlagsTabLayout->addWidget(mpProfilingCheckBox, 10, 0);
pSimulationFlagsTabLayout->addWidget(mpProfilingLabel, 10, 0);
pSimulationFlagsTabLayout->addWidget(mpProfilingCheckBox, 10, 1);
pSimulationFlagsTabLayout->addWidget(mpCPUTimeCheckBox, 11, 0);
pSimulationFlagsTabLayout->addWidget(mpEnableAllWarningsCheckBox, 12, 0);
pSimulationFlagsTabLayout->addWidget(mpLoggingGroupBox, 13, 0, 1, 3);
Expand Down Expand Up @@ -919,11 +925,7 @@ void SimulationDialog::simulate()
mSimulationParameters.append(", variableFilter=").append("\"").append(mpVariableFilterTextBox->text()).append("\"");
if (!mpCflagsTextBox->text().isEmpty())
mSimulationParameters.append(", cflags=").append("\"").append(mpCflagsTextBox->text()).append("\"");
if (mpProfilingCheckBox->isChecked()) {
mpMainWindow->getOMCProxy()->setCommandLineOptions("+profiling=all");
} else {
mpMainWindow->getOMCProxy()->setCommandLineOptions("+profiling=none");
}
mpMainWindow->getOMCProxy()->setCommandLineOptions("+profiling=" + mpProfilingCheckBox->currentText());
// setup simulation flags
// setup Model Setup file flag
if (!mpModelSetupFileTextBox->text().isEmpty())
Expand Down Expand Up @@ -1098,7 +1100,8 @@ void SimulationDialog::compilationProcessFinished(int exitCode, QProcess::ExitSt
outputFormat = mpOutputFormatComboBox->currentText();
}
SimulationOptions simulationOptions(mpLibraryTreeNode->getNameStructure(), fileNamePrefix, outputFormat, mSimulationFlags,
mpShowGeneratedFilesCheckBox->isChecked(), mpProfilingCheckBox->isChecked(),
mpShowGeneratedFilesCheckBox->isChecked(),
mpProfilingCheckBox->currentText() != "none",
mpMainWindow->getOMCProxy()->changeDirectory());
/* show the Transformational Debugger */
if (mpMainWindow->getOptionsDialog()->getSimulationPage()->getAlwaysShowTransformationsCheckBox()->isChecked())
Expand Down
2 changes: 1 addition & 1 deletion OMEdit/OMEditGUI/GUI/Dialogs/SimulationDialog.h
Expand Up @@ -177,7 +177,7 @@ class SimulationDialog : public QDialog
QLineEdit *mpLinearizationTimeTextBox;
Label *mpOutputVariablesLabel;
QLineEdit *mpOutputVariablesTextBox;
QCheckBox *mpProfilingCheckBox;
QComboBox *mpProfilingCheckBox;
QCheckBox *mpCPUTimeCheckBox;
QCheckBox *mpEnableAllWarningsCheckBox;
QGroupBox *mpLoggingGroupBox;
Expand Down
38 changes: 21 additions & 17 deletions OMEdit/OMEditGUI/GUI/Widgets/TransformationsWidget.cpp
Expand Up @@ -919,7 +919,7 @@ QTreeWidgetItem* TransformationsWidget::findEquationTreeItem(int equationIndex)
return 0;
}

// #include <qwt_plot.h>
#include <qwt_plot.h>

void TransformationsWidget::fetchEquationData(int equationIndex)
{
Expand All @@ -931,20 +931,6 @@ void TransformationsWidget::fetchEquationData(int equationIndex)
/* fetch operations */
fetchOperations(equation);

if (!equation->info.isValid)
return;
/* open the model with and go to the equation line */
QFile file(equation->info.file);
if (file.exists())
{
mpTSourceEditorFileLabel->setText(file.fileName());
mpTSourceEditorFileLabel->show();
file.open(QIODevice::ReadOnly);
mpTSourceEditor->setPlainText(QString(file.readAll()));
mpTSourceEditorInfoBar->hide();
file.close();
mpTSourceEditor->goToLineNumber(equation->info.lineStart);
}
/* TODO: This data is correct. Add this to some widget thingy somewhere.
* Maybe a small one that you can click to enlarge.
* Also add the count one (Model_prof.intdata)
Expand All @@ -959,7 +945,6 @@ void TransformationsWidget::fetchEquationData(int equationIndex)
w = new QwtPlot();

size_t rowSize = sizeof(double) * profilingNumSteps;
qDebug() << file.size() / rowSize;
file.seek(0);
QByteArray datax = file.read(rowSize);
file.seek((equation->profileBlock+2) * rowSize);
Expand All @@ -974,8 +959,26 @@ void TransformationsWidget::fetchEquationData(int equationIndex)
w->replot();
w->show();
}
} else {
qDebug() << equation->profileBlock;
}
#endif

if (!equation->info.isValid)
return;
/* open the model with and go to the equation line */
QFile file(equation->info.file);
if (file.exists())
{
mpTSourceEditorFileLabel->setText(file.fileName());
mpTSourceEditorFileLabel->show();
file.open(QIODevice::ReadOnly);
mpTSourceEditor->setPlainText(QString(file.readAll()));
mpTSourceEditorInfoBar->hide();
file.close();
mpTSourceEditor->goToLineNumber(equation->info.lineStart);
}

}

void TransformationsWidget::fetchDefines(OMEquation *equation)
Expand Down Expand Up @@ -1172,6 +1175,7 @@ void TransformationsWidget::parseProfiling(QString fileName)
bool ok;
QVariantMap result = parser.parse(file, &ok).toMap();
double totalStepsTime = result["totalTimeProfileBlocks"].toDouble();
QVariantList functions = result["functions"].toList();
QVariantList list = result["profileBlocks"].toList();
profilingNumSteps = result["numStep"].toInt() + 1; // Initialization is not a step, but part of the file
for (int i=0; i<list.size(); i++) {
Expand All @@ -1182,7 +1186,7 @@ void TransformationsWidget::parseProfiling(QString fileName)
mpInfoXMLFileHandler->equations[id]->maxTime = eq["maxTime"].toDouble();
mpInfoXMLFileHandler->equations[id]->time = time;
mpInfoXMLFileHandler->equations[id]->fraction = time / totalStepsTime;
mpInfoXMLFileHandler->equations[id]->profileBlock = i;
mpInfoXMLFileHandler->equations[id]->profileBlock = i + functions.size();
}
delete file;
}
23 changes: 23 additions & 0 deletions OMEdit/OMEditGUI/OMC/OMCProxy.cpp
Expand Up @@ -2421,3 +2421,26 @@ bool OMCProxy::setDebugFlags(QString debugFlags)
sendCommand("setDebugFlags(\"" + debugFlags + "\")");
return StringHandler::unparseBool(getResult());
}

QString OMCProxy::help(QString topic)
{
sendCommand("help(\"" + topic + "\")");
return StringHandler::unparse(getResult());
}

QStringList OMCProxy::getConfigFlagValidOptions(QString topic, QString *mainDescription, QStringList *descriptions)
{
QStringList validOptions;
sendCommand("(v1,v2,v3):=getConfigFlagValidOptions(\"" + topic + "\")");
sendCommand("v1");
validOptions = StringHandler::unparseStrings(getResult());
if (mainDescription) {
sendCommand("v2");
*mainDescription = StringHandler::unparse(getResult());
}
if (descriptions) {
sendCommand("v3");
*descriptions = StringHandler::unparseStrings(getResult());
}
return validOptions;
}
2 changes: 2 additions & 0 deletions OMEdit/OMEditGUI/OMC/OMCProxy.h
Expand Up @@ -212,6 +212,8 @@ class OMCProxy : public QObject
QString getDerivedClassModifierValue(QString className, QString modifierName);
bool getDocumentationClassAnnotation(QString className);
QString numProcessors();
QString help(QString topic);
QStringList getConfigFlagValidOptions(QString topic, QString *mainDescription = 0, QStringList *descriptions = 0);
bool setDebugFlags(QString flags);
signals:
void commandFinished();
Expand Down

0 comments on commit b2da5dd

Please sign in to comment.