Skip to content

Commit d34cb2e

Browse files
committed
ticket:4262 Adapted to new output of translateModelFMU and translateModelXML.
1 parent 078fe45 commit d34cb2e

File tree

4 files changed

+29
-29
lines changed

4 files changed

+29
-29
lines changed

OMEdit/OMEditGUI/MainWindow.cpp

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -770,13 +770,14 @@ void MainWindow::exportModelFMU(LibraryTreeItem *pLibraryTreeItem)
770770
QSettings *pSettings = Utilities::getApplicationSettings();
771771
QList<QString> platforms = pSettings->value("FMIExport/Platforms").toStringList();
772772
int index = platforms.indexOf("none");
773-
if (index > -1)
773+
if (index > -1) {
774774
platforms.removeAt(index);
775-
if (mpOMCProxy->buildModelFMU(pLibraryTreeItem->getNameStructure(), version, type, FMUName, platforms)) {
776-
MessagesWidget::instance()->addGUIMessage(MessageItem(MessageItem::Modelica, "", false, 0, 0, 0, 0, GUIMessages::getMessage(GUIMessages::FMU_GENERATED)
777-
.arg(FMUName.isEmpty() ? pLibraryTreeItem->getNameStructure() : FMUName)
778-
.arg(OptionsDialog::instance()->getGeneralSettingsPage()->getWorkingDirectory()), Helper::scriptingKind,
779-
Helper::notificationLevel));
775+
}
776+
QString fmuFileName = mpOMCProxy->buildModelFMU(pLibraryTreeItem->getNameStructure(), version, type, FMUName, platforms);
777+
if (!fmuFileName.isEmpty()) {
778+
MessagesWidget::instance()->addGUIMessage(MessageItem(MessageItem::Modelica, "", false, 0, 0, 0, 0,
779+
GUIMessages::getMessage(GUIMessages::FMU_GENERATED).arg(fmuFileName),
780+
Helper::scriptingKind, Helper::notificationLevel));
780781
}
781782
// hide progress bar
782783
hideProgressBar();
@@ -797,10 +798,11 @@ void MainWindow::exportModelXML(LibraryTreeItem *pLibraryTreeItem)
797798
// show the progress bar
798799
mpProgressBar->setRange(0, 0);
799800
showProgressBar();
800-
if (mpOMCProxy->translateModelXML(pLibraryTreeItem->getNameStructure())) {
801-
MessagesWidget::instance()->addGUIMessage(MessageItem(MessageItem::Modelica, "", false, 0, 0, 0, 0, GUIMessages::getMessage(GUIMessages::XML_GENERATED)
802-
.arg(OptionsDialog::instance()->getGeneralSettingsPage()->getWorkingDirectory()).arg(pLibraryTreeItem->getNameStructure()),
803-
Helper::scriptingKind, Helper::notificationLevel));
801+
QString xmlFileName = mpOMCProxy->translateModelXML(pLibraryTreeItem->getNameStructure());
802+
if (!xmlFileName.isEmpty()) {
803+
MessagesWidget::instance()->addGUIMessage(MessageItem(MessageItem::Modelica, "", false, 0, 0, 0, 0,
804+
GUIMessages::getMessage(GUIMessages::XML_GENERATED).arg(xmlFileName),
805+
Helper::scriptingKind, Helper::notificationLevel));
804806
}
805807
// hide progress bar
806808
hideProgressBar();

OMEdit/OMEditGUI/OMC/OMCProxy.cpp

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2076,34 +2076,32 @@ OMCInterface::getSimulationOptions_res OMCProxy::getSimulationOptions(QString cl
20762076
* \param platforms
20772077
* \return
20782078
*/
2079-
bool OMCProxy::buildModelFMU(QString className, double version, QString type, QString fileNamePrefix, QList<QString> platforms)
2079+
QString OMCProxy::buildModelFMU(QString className, double version, QString type, QString fileNamePrefix, QList<QString> platforms)
20802080
{
2081-
bool result = false;
20822081
fileNamePrefix = fileNamePrefix.isEmpty() ? "<default>" : fileNamePrefix;
2083-
QString res = mpOMCInterface->buildModelFMU(className, QString::number(version), type, fileNamePrefix, platforms);
2084-
if (res.compare("SimCode: The model " + className + " has been translated to FMU") == 0) {
2085-
result = true;
2082+
QString fmuFileName = mpOMCInterface->buildModelFMU(className, QString::number(version), type, fileNamePrefix, platforms);
2083+
if (!fmuFileName.isEmpty()) {
20862084
MainWindow::instance()->getLibraryWidget()->getLibraryTreeModel()->loadDependentLibraries(getClassNames());
20872085
}
20882086
printMessagesStringInternal();
2089-
return result;
2087+
return fmuFileName;
20902088
}
20912089

20922090
/*!
2093-
Creates the XML of the model.
2094-
\param className - the name of the class.
2095-
\return the created XML location
2096-
*/
2097-
bool OMCProxy::translateModelXML(QString className)
2091+
* \brief OMCProxy::translateModelXML
2092+
* Creates the XML of the model.
2093+
* \param className - the name of the class.
2094+
* \return the created XML location
2095+
*/
2096+
QString OMCProxy::translateModelXML(QString className)
20982097
{
2099-
bool result = false;
21002098
sendCommand("translateModelXML(" + className + ")");
2101-
if (StringHandler::unparse(getResult()).compare("SimCode: The model " + className + " has been translated to XML") == 0) {
2102-
result = true;
2099+
QString xmlFileName = StringHandler::unparse(getResult());
2100+
if (!xmlFileName.isEmpty()) {
21032101
MainWindow::instance()->getLibraryWidget()->getLibraryTreeModel()->loadDependentLibraries(getClassNames());
21042102
}
21052103
printMessagesStringInternal();
2106-
return result;
2104+
return xmlFileName;
21072105
}
21082106

21092107
/*!

OMEdit/OMEditGUI/OMC/OMCProxy.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,8 @@ class OMCProxy : public QObject
191191
QString checkAllModelsRecursive(QString className);
192192
bool isExperiment(QString className);
193193
OMCInterface::getSimulationOptions_res getSimulationOptions(QString className, double defaultTolerance = 1e-6);
194-
bool buildModelFMU(QString className, double version, QString type, QString fileNamePrefix, QList<QString> platforms);
195-
bool translateModelXML(QString className);
194+
QString buildModelFMU(QString className, double version, QString type, QString fileNamePrefix, QList<QString> platforms);
195+
QString translateModelXML(QString className);
196196
QString importFMU(QString fmuName, QString outputDirectory, int logLevel, bool debugLogging, bool generateInputConnectors, bool generateOutputConnectors);
197197
QString importFMUModelDescription(QString fmuModelDescriptionName, QString outputDirectory, int logLevel, bool debugLogging, bool generateInputConnectors, bool generateOutputConnectors);
198198
QString getMatchingAlgorithm();

OMEdit/OMEditGUI/Util/Helper.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -634,9 +634,9 @@ QString GUIMessages::getMessage(int type)
634634
case INNER_MODEL_NAME_CHANGED:
635635
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>.");
636636
case FMU_GENERATED:
637-
return tr("The FMU %1.fmu is generated at %2");
637+
return tr("The FMU is generated at <b>%1</b>.");
638638
case XML_GENERATED:
639-
return tr("The XML is generated at %1/%2.xml");
639+
return tr("The XML is generated at <b>%1</b>.");
640640
case FIGARO_GENERATED:
641641
return tr("The FIGARO is generated.");
642642
case UNLOAD_CLASS_MSG:

0 commit comments

Comments
 (0)