Skip to content

Commit

Permalink
ticket:5490 Enable new instantiation and API by default
Browse files Browse the repository at this point in the history
Prompt the user if the new instantiation fails and allow translation with the old.
Added two new APIs `enableNewInstantiation` and `disableNewInstantiation` which allows on/off for the new frontend instead of calling `clearCommandLineOptions` and `setCommandLineOptions`.
  • Loading branch information
adeas31 committed Jul 3, 2019
1 parent 212bdd7 commit 18ceea3
Show file tree
Hide file tree
Showing 10 changed files with 215 additions and 25 deletions.
12 changes: 12 additions & 0 deletions OMCompiler/Compiler/FrontEnd/ModelicaBuiltin.mo
Expand Up @@ -1511,6 +1511,18 @@ external "builtin";
annotation(preferredView="text");
end setCompilerFlags;

function enableNewInstantiation
output Boolean success;
external "builtin";
annotation(preferredView="text");
end enableNewInstantiation;

function disableNewInstantiation
output Boolean success;
external "builtin";
annotation(preferredView="text");
end disableNewInstantiation;

function setDebugFlags "example input: failtrace,-noevalfunc"
input String debugFlags;
output Boolean success;
Expand Down
20 changes: 20 additions & 0 deletions OMCompiler/Compiler/Script/CevalScript.mo
Expand Up @@ -1002,6 +1002,26 @@ algorithm
case (cache,_,"clearCommandLineOptions",_,_)
then (cache,Values.BOOL(false));

case (cache,_,"enableNewInstantiation",_,_)
equation
Flags.enableDebug(Flags.SCODE_INST);
then
(cache,Values.BOOL(true));

case (cache,_,"enableNewInstantiation",_,_)
then
(cache,Values.BOOL(false));

case (cache,_,"disableNewInstantiation",_,_)
equation
Flags.disableDebug(Flags.SCODE_INST);
then
(cache,Values.BOOL(true));

case (cache,_,"disableNewInstantiation",_,_)
then
(cache,Values.BOOL(false));

case (cache,_,"clearDebugFlags",_,_)
equation
Flags.resetDebugFlags();
Expand Down
20 changes: 20 additions & 0 deletions OMEdit/OMEdit/OMEditGUI/OMC/OMCProxy.cpp
Expand Up @@ -2498,6 +2498,16 @@ bool OMCProxy::setIndexReductionMethod(QString method)
}
}

/*!
* \brief OMCProxy::getCommandLineOptions
* Returns the enabled command line options.
* \return
*/
QList<QString> OMCProxy::getCommandLineOptions()
{
return mpOMCInterface->getCommandLineOptions();
}

/*!
* \brief OMCProxy::setCommandLineOptions
* Sets the OMC CommandLineOptions.
Expand Down Expand Up @@ -2529,6 +2539,16 @@ bool OMCProxy::clearCommandLineOptions()
}
}

bool OMCProxy::enableNewInstantiation()
{
return mpOMCInterface->enableNewInstantiation();
}

bool OMCProxy::disableNewInstantiation()
{
return mpOMCInterface->disableNewInstantiation();
}

/*!
* \brief OMCProxy::makeDocumentationUriToFileName
* Helper function for getDocumentationAnnotation. Takes the documentation html and replaces the modelica links with absolute pahts.\n
Expand Down
3 changes: 3 additions & 0 deletions OMEdit/OMEdit/OMEditGUI/OMC/OMCProxy.h
Expand Up @@ -217,8 +217,11 @@ class OMCProxy : public QObject
QString getIndexReductionMethod();
OMCInterface::getAvailableIndexReductionMethods_res getAvailableIndexReductionMethods();
bool setIndexReductionMethod(QString method);
QList<QString> getCommandLineOptions();
bool setCommandLineOptions(QString options);
bool clearCommandLineOptions();
bool enableNewInstantiation();
bool disableNewInstantiation();
QString makeDocumentationUriToFileName(QString documentation);
QString uriToFilename(QString uri);
QString getModelicaPath();
Expand Down
52 changes: 41 additions & 11 deletions OMEdit/OMEdit/OMEditGUI/Options/OptionsDialog.cpp
Expand Up @@ -573,9 +573,9 @@ void OptionsDialog::readSimulationSettings()
if (mpSettings->contains("simulation/parmodauto")) {
mpSimulationPage->getTranslationFlagsWidget()->getParmodautoCheckBox()->setChecked(mpSettings->value("simulation/parmodauto").toBool());
}
// save new instantiation
// save old instantiation
if (mpSettings->contains("simulation/newInst")) {
mpSimulationPage->getTranslationFlagsWidget()->getNewInstantiationCheckBox()->setChecked(mpSettings->value("simulation/newInst").toBool());
mpSimulationPage->getTranslationFlagsWidget()->getOldInstantiationCheckBox()->setChecked(!mpSettings->value("simulation/newInst").toBool());
}
if (mpSettings->contains("simulation/dataReconciliation")) {
mpSimulationPage->getTranslationFlagsWidget()->getDataReconciliationCheckBox()->setChecked(mpSettings->value("simulation/dataReconciliation").toBool());
Expand Down Expand Up @@ -622,6 +622,9 @@ void OptionsDialog::readSimulationSettings()
if (mpSettings->contains("simulation/deleteEntireSimulationDirectory")) {
mpSimulationPage->getDeleteEntireSimulationDirectoryCheckBox()->setChecked(mpSettings->value("simulation/deleteEntireSimulationDirectory").toBool());
}
if (mpSettings->contains("simulation/nfAPI")) {
mpSimulationPage->getEnableNewInstantiationAPICheckBox()->setChecked(mpSettings->value("simulation/nfAPI").toBool());
}
if (mpSettings->contains("simulation/outputMode")) {
mpSimulationPage->setOutputMode(mpSettings->value("simulation/outputMode").toString());
}
Expand Down Expand Up @@ -703,6 +706,13 @@ void OptionsDialog::readNotificationsSettings()
if (mpSettings->contains("notifications/alwaysAskForTextEditorError")) {
mpNotificationsPage->getAlwaysAskForTextEditorErrorCheckBox()->setChecked(mpSettings->value("notifications/alwaysAskForTextEditorError").toBool());
}
if (mpSettings->contains("notifications/promptOldFrontend")) {
bool ok;
int currentIndex = mpNotificationsPage->getOldFrontendComboBox()->findData(mpSettings->value("notifications/promptOldFrontend").toInt(&ok));
if (currentIndex > -1 && ok) {
mpNotificationsPage->getOldFrontendComboBox()->setCurrentIndex(currentIndex);
}
}
}

//! Reads the LineStyle section settings from omedit.ini
Expand Down Expand Up @@ -1190,8 +1200,8 @@ void OptionsDialog::saveSimulationSettings()
mpSettings->setValue("simulation/NLSanalyticJacobian", mpSimulationPage->getTranslationFlagsWidget()->getNLSanalyticJacobianCheckBox()->isChecked());
// save parmodauto
mpSettings->setValue("simulation/parmodauto", mpSimulationPage->getTranslationFlagsWidget()->getParmodautoCheckBox()->isChecked());
// save new instantiation
mpSettings->setValue("simulation/newInst", mpSimulationPage->getTranslationFlagsWidget()->getNewInstantiationCheckBox()->isChecked());
// save old instantiation
mpSettings->setValue("simulation/newInst", !mpSimulationPage->getTranslationFlagsWidget()->getOldInstantiationCheckBox()->isChecked());
// save dataReconciliation
mpSettings->setValue("simulation/dataReconciliation", mpSimulationPage->getTranslationFlagsWidget()->getDataReconciliationCheckBox()->isChecked());
// save command line options
Expand Down Expand Up @@ -1254,6 +1264,11 @@ void OptionsDialog::saveGlobalSimulationSettings()
} else {
MainWindow::instance()->getOMCProxy()->setCommandLineOptions("+ignoreSimulationFlagsAnnotation=false");
}
// save nfAPI
mpSettings->setValue("simulation/nfAPI", mpSimulationPage->getEnableNewInstantiationAPICheckBox()->isChecked());
if (mpSimulationPage->getEnableNewInstantiationAPICheckBox()->isChecked()) {
MainWindow::instance()->getOMCProxy()->setCommandLineOptions("-d=nfAPI");
}
}

//! Saves the Messages section settings to omedit.ini
Expand Down Expand Up @@ -1288,6 +1303,7 @@ void OptionsDialog::saveNotificationsSettings()
mpSettings->setValue("notifications/saveModelForBitmapInsertion", mpNotificationsPage->getSaveModelForBitmapInsertionCheckBox()->isChecked());
mpSettings->setValue("notifications/alwaysAskForDraggedComponentName", mpNotificationsPage->getAlwaysAskForDraggedComponentName()->isChecked());
mpSettings->setValue("notifications/alwaysAskForTextEditorError", mpNotificationsPage->getAlwaysAskForTextEditorErrorCheckBox()->isChecked());
mpSettings->setValue("notifications/promptOldFrontend", mpNotificationsPage->getOldFrontendComboBox()->itemData(mpNotificationsPage->getOldFrontendComboBox()->currentIndex()).toInt());
}

//! Saves the LineStyle section settings to omedit.ini
Expand Down Expand Up @@ -3661,6 +3677,10 @@ SimulationPage::SimulationPage(OptionsDialog *pOptionsDialog)
mpIgnoreCommandLineOptionsAnnotationCheckBox = new QCheckBox(tr("Ignore __OpenModelica_commandLineOptions annotation"));
// ignore simulation flags annotation checkbox
mpIgnoreSimulationFlagsAnnotationCheckBox = new QCheckBox(tr("Ignore __OpenModelica_simulationFlags annotation"));
//! @todo Remove this once we enable this bydefault in OMC.
/* Enable new instantiation use in OMC API */
mpEnableNewInstantiationAPICheckBox = new QCheckBox(tr("Enable new frontend use in the OMC API (faster GUI response)"));
mpEnableNewInstantiationAPICheckBox->setChecked(true);
/* save class before simulation checkbox */
mpSaveClassBeforeSimulationCheckBox = new QCheckBox(tr("Save class before simulation"));
mpSaveClassBeforeSimulationCheckBox->setToolTip(tr("Disabling this will effect the debugger functionality."));
Expand Down Expand Up @@ -3724,6 +3744,7 @@ SimulationPage::SimulationPage(OptionsDialog *pOptionsDialog)
pSimulationLayout->addWidget(mpCXXCompilerComboBox, row++, 1);
pSimulationLayout->addWidget(mpIgnoreCommandLineOptionsAnnotationCheckBox, row++, 0, 1, 2);
pSimulationLayout->addWidget(mpIgnoreSimulationFlagsAnnotationCheckBox, row++, 0, 1, 2);
pSimulationLayout->addWidget(mpEnableNewInstantiationAPICheckBox, row++, 0, 1, 2);
pSimulationLayout->addWidget(mpSaveClassBeforeSimulationCheckBox, row++, 0, 1, 2);
pSimulationLayout->addWidget(mpSwitchToPlottingPerspectiveCheckBox, row++, 0, 1, 2);
pSimulationLayout->addWidget(mpCloseSimulationOutputWidgetsBeforeSimulationCheckBox, row++, 0, 1, 2);
Expand Down Expand Up @@ -3966,16 +3987,25 @@ NotificationsPage::NotificationsPage(OptionsDialog *pOptionsDialog)
// create the always ask for text editor error
mpAlwaysAskForTextEditorErrorCheckBox = new QCheckBox(tr("Always ask for what to do with the text editor error"));
mpAlwaysAskForTextEditorErrorCheckBox->setChecked(true);
// prompt for old frontend
mpOldFrontendLabel = new Label(tr("If new frontend for code generation fails?"));
mpOldFrontendComboBox = new QComboBox;
mpOldFrontendComboBox->addItem(tr("Always ask for old frontend"), NotificationsPage::AlwaysAskForOF);
mpOldFrontendComboBox->addItem(tr("Try with old frontend once"), NotificationsPage::TryOnceWithOF);
mpOldFrontendComboBox->addItem(tr("Switch to old frontend permanently"), NotificationsPage::SwitchPermanentlyToOF);
mpOldFrontendComboBox->addItem(tr("Keep using new frontend"), NotificationsPage::KeepUsingNF);
// set the layout of notifications group
QGridLayout *pNotificationsLayout = new QGridLayout;
pNotificationsLayout->setAlignment(Qt::AlignTop);
pNotificationsLayout->addWidget(mpQuitApplicationCheckBox, 0, 0);
pNotificationsLayout->addWidget(mpItemDroppedOnItselfCheckBox, 1, 0);
pNotificationsLayout->addWidget(mpReplaceableIfPartialCheckBox, 2, 0);
pNotificationsLayout->addWidget(mpInnerModelNameChangedCheckBox, 3, 0);
pNotificationsLayout->addWidget(mpSaveModelForBitmapInsertionCheckBox, 4, 0);
pNotificationsLayout->addWidget(mpAlwaysAskForDraggedComponentName, 5, 0);
pNotificationsLayout->addWidget(mpAlwaysAskForTextEditorErrorCheckBox, 6, 0);
pNotificationsLayout->addWidget(mpQuitApplicationCheckBox, 0, 0, 1, 2);
pNotificationsLayout->addWidget(mpItemDroppedOnItselfCheckBox, 1, 0, 1, 2);
pNotificationsLayout->addWidget(mpReplaceableIfPartialCheckBox, 2, 0, 1, 2);
pNotificationsLayout->addWidget(mpInnerModelNameChangedCheckBox, 3, 0, 1, 2);
pNotificationsLayout->addWidget(mpSaveModelForBitmapInsertionCheckBox, 4, 0, 1, 2);
pNotificationsLayout->addWidget(mpAlwaysAskForDraggedComponentName, 5, 0, 1, 2);
pNotificationsLayout->addWidget(mpAlwaysAskForTextEditorErrorCheckBox, 6, 0, 1, 2);
pNotificationsLayout->addWidget(mpOldFrontendLabel, 7, 0);
pNotificationsLayout->addWidget(mpOldFrontendComboBox, 7, 1);
mpNotificationsGroupBox->setLayout(pNotificationsLayout);
// set the layout
QVBoxLayout *pLayout = new QVBoxLayout;
Expand Down
11 changes: 11 additions & 0 deletions OMEdit/OMEdit/OMEditGUI/Options/OptionsDialog.h
Expand Up @@ -620,6 +620,7 @@ class SimulationPage : public QWidget
QComboBox* getCXXCompilerComboBox() {return mpCXXCompilerComboBox;}
QCheckBox* getIgnoreCommandLineOptionsAnnotationCheckBox() {return mpIgnoreCommandLineOptionsAnnotationCheckBox;}
QCheckBox* getIgnoreSimulationFlagsAnnotationCheckBox() {return mpIgnoreSimulationFlagsAnnotationCheckBox;}
QCheckBox* getEnableNewInstantiationAPICheckBox() {return mpEnableNewInstantiationAPICheckBox;}
QCheckBox* getSaveClassBeforeSimulationCheckBox() {return mpSaveClassBeforeSimulationCheckBox;}
QCheckBox* getSwitchToPlottingPerspectiveCheckBox() {return mpSwitchToPlottingPerspectiveCheckBox;}
QCheckBox* getCloseSimulationOutputWidgetsBeforeSimulationCheckBox() {return mpCloseSimulationOutputWidgetsBeforeSimulationCheckBox;}
Expand All @@ -643,6 +644,7 @@ class SimulationPage : public QWidget
QComboBox *mpCXXCompilerComboBox;
QCheckBox *mpIgnoreCommandLineOptionsAnnotationCheckBox;
QCheckBox *mpIgnoreSimulationFlagsAnnotationCheckBox;
QCheckBox *mpEnableNewInstantiationAPICheckBox;
QCheckBox *mpSaveClassBeforeSimulationCheckBox;
QCheckBox *mpSwitchToPlottingPerspectiveCheckBox;
QCheckBox *mpCloseSimulationOutputWidgetsBeforeSimulationCheckBox;
Expand Down Expand Up @@ -709,6 +711,12 @@ class NotificationsPage : public QWidget
{
Q_OBJECT
public:
enum OldFrontend {
AlwaysAskForOF = 0,
TryOnceWithOF = 1,
SwitchPermanentlyToOF = 2,
KeepUsingNF = 3
};
NotificationsPage(OptionsDialog *pOptionsDialog);
QCheckBox* getQuitApplicationCheckBox() {return mpQuitApplicationCheckBox;}
QCheckBox* getItemDroppedOnItselfCheckBox() {return mpItemDroppedOnItselfCheckBox;}
Expand All @@ -717,6 +725,7 @@ class NotificationsPage : public QWidget
QCheckBox* getSaveModelForBitmapInsertionCheckBox() {return mpSaveModelForBitmapInsertionCheckBox;}
QCheckBox* getAlwaysAskForDraggedComponentName() {return mpAlwaysAskForDraggedComponentName;}
QCheckBox* getAlwaysAskForTextEditorErrorCheckBox() {return mpAlwaysAskForTextEditorErrorCheckBox;}
QComboBox* getOldFrontendComboBox() {return mpOldFrontendComboBox;}
private:
OptionsDialog *mpOptionsDialog;
QGroupBox *mpNotificationsGroupBox;
Expand All @@ -727,6 +736,8 @@ class NotificationsPage : public QWidget
QCheckBox *mpSaveModelForBitmapInsertionCheckBox;
QCheckBox *mpAlwaysAskForDraggedComponentName;
QCheckBox *mpAlwaysAskForTextEditorErrorCheckBox;
Label *mpOldFrontendLabel;
QComboBox *mpOldFrontendComboBox;
};

class LineStylePage : public QWidget
Expand Down

0 comments on commit 18ceea3

Please sign in to comment.