Skip to content

Commit

Permalink
Print a warning when no platforms are specified when generating an FMU
Browse files Browse the repository at this point in the history
... and also select the default choice when no such setting exists at
all in omedit.ini.
  • Loading branch information
atrosinenko authored and adeas31 committed Nov 5, 2018
1 parent b1cb26e commit ba17bb1
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
13 changes: 12 additions & 1 deletion OMEdit/OMEditGUI/MainWindow.cpp
Expand Up @@ -870,11 +870,22 @@ void MainWindow::exportModelFMU(LibraryTreeItem *pLibraryTreeItem)
QString type = OptionsDialog::instance()->getFMIPage()->getFMIExportType();
QString FMUName = OptionsDialog::instance()->getFMIPage()->getFMUNameTextBox()->text();
QSettings *pSettings = Utilities::getApplicationSettings();
QList<QString> platforms = pSettings->value("FMIExport/Platforms").toStringList();
QList<QString> platforms;
if (!pSettings->contains("FMIExport/Platforms")) {
QComboBox *pLinkingComboBox = OptionsDialog::instance()->getFMIPage()->getLinkingComboBox();
platforms.append(pLinkingComboBox->itemData(pLinkingComboBox->currentIndex()).toString());
} else {
platforms = pSettings->value("FMIExport/Platforms").toStringList();
}
int index = platforms.indexOf("none");
if (index > -1) {
platforms.removeAt(index);
}
if (platforms.empty()) {
MessagesWidget::instance()->addGUIMessage(MessageItem(MessageItem::Modelica, "", false, 0, 0, 0, 0,
GUIMessages::getMessage(GUIMessages::FMU_EMPTY_PLATFORMS).arg(Helper::toolsOptionsPath),
Helper::scriptingKind, Helper::warningLevel));
}
QString fmuFileName = mpOMCProxy->buildModelFMU(pLibraryTreeItem->getNameStructure(), version, type, FMUName, platforms);
if (!fmuFileName.isEmpty()) {
MessagesWidget::instance()->addGUIMessage(MessageItem(MessageItem::Modelica, "", false, 0, 0, 0, 0,
Expand Down
2 changes: 2 additions & 0 deletions OMEdit/OMEditGUI/Util/Helper.cpp
Expand Up @@ -760,6 +760,8 @@ QString GUIMessages::getMessage(int type)
return tr("A component with the name <b>%1</b> already exists. The name is changed from <b>%1</b> to <b>%2</b>.<br /><br />This is probably wrong because the component is declared as <b>inner</b>.");
case FMU_GENERATED:
return tr("The FMU is generated at <b>%1</b>.");
case FMU_EMPTY_PLATFORMS:
return tr("A source-only FMU will be generated because an empty list of platforms is selected. If this is not intended, check settings in <b>%1->FMI->Platforms</b>.");
case XML_GENERATED:
return tr("The XML is generated at <b>%1</b>.");
case FIGARO_GENERATED:
Expand Down
1 change: 1 addition & 0 deletions OMEdit/OMEditGUI/Util/Helper.h
Expand Up @@ -443,6 +443,7 @@ class GUIMessages : public QObject
MAKE_REPLACEABLE_IF_PARTIAL,
INNER_MODEL_NAME_CHANGED,
FMU_GENERATED,
FMU_EMPTY_PLATFORMS,
XML_GENERATED,
FIGARO_GENERATED,
ENCRYPTED_PACKAGE_GENERATED,
Expand Down

0 comments on commit ba17bb1

Please sign in to comment.