Skip to content

Commit

Permalink
Updated TLMPlugin to OMTLMSimulator.
Browse files Browse the repository at this point in the history
  • Loading branch information
adeas31 committed Jun 8, 2017
1 parent 1ff64b5 commit 44459e5
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 38 deletions.
43 changes: 19 additions & 24 deletions OMEdit/OMEditGUI/MainWindow.cpp
Expand Up @@ -888,31 +888,26 @@ void MainWindow::fetchInterfaceData(LibraryTreeItem *pLibraryTreeItem, QString s
return;
}
}
if (OptionsDialog::instance()->getTLMPage()->getTLMManagerProcessTextBox()->text().isEmpty()) {
QString message = GUIMessages::getMessage(GUIMessages::TLMMANAGER_NOT_SET).arg(Helper::toolsOptionsPath);
QMessageBox::information(this, QString(Helper::applicationName).append(" - ").append(Helper::information), message, Helper::ok);
if (pLibraryTreeItem->isSaved()) {
fetchInterfaceDataHelper(pLibraryTreeItem, singleModel);
} else {
if (pLibraryTreeItem->isSaved()) {
fetchInterfaceDataHelper(pLibraryTreeItem, singleModel);
} else {
QMessageBox *pMessageBox = new QMessageBox(this);
pMessageBox->setWindowTitle(QString(Helper::applicationName).append(" - ").append(Helper::question));
pMessageBox->setIcon(QMessageBox::Question);
pMessageBox->setAttribute(Qt::WA_DeleteOnClose);
pMessageBox->setText(GUIMessages::getMessage(GUIMessages::COMPOSITEMODEL_UNSAVED).arg(pLibraryTreeItem->getNameStructure()));
pMessageBox->setStandardButtons(QMessageBox::Yes | QMessageBox::No);
pMessageBox->setDefaultButton(QMessageBox::Yes);
int answer = pMessageBox->exec();
switch (answer) {
case QMessageBox::Yes:
if (mpLibraryWidget->saveLibraryTreeItem(pLibraryTreeItem)) {
fetchInterfaceDataHelper(pLibraryTreeItem, singleModel);
}
break;
case QMessageBox::No:
default:
break;
}
QMessageBox *pMessageBox = new QMessageBox(this);
pMessageBox->setWindowTitle(QString(Helper::applicationName).append(" - ").append(Helper::question));
pMessageBox->setIcon(QMessageBox::Question);
pMessageBox->setAttribute(Qt::WA_DeleteOnClose);
pMessageBox->setText(GUIMessages::getMessage(GUIMessages::COMPOSITEMODEL_UNSAVED).arg(pLibraryTreeItem->getNameStructure()));
pMessageBox->setStandardButtons(QMessageBox::Yes | QMessageBox::No);
pMessageBox->setDefaultButton(QMessageBox::Yes);
int answer = pMessageBox->exec();
switch (answer) {
case QMessageBox::Yes:
if (mpLibraryWidget->saveLibraryTreeItem(pLibraryTreeItem)) {
fetchInterfaceDataHelper(pLibraryTreeItem, singleModel);
}
break;
case QMessageBox::No:
default:
break;
}
}
}
Expand Down
60 changes: 53 additions & 7 deletions OMEdit/OMEditGUI/Options/OptionsDialog.cpp
Expand Up @@ -1343,7 +1343,7 @@ void OptionsDialog::addListItems()
// TLM Item
QListWidgetItem *pTLMItem = new QListWidgetItem(mpOptionsList);
pTLMItem->setIcon(QIcon(":/Resources/icons/tlm-icon.svg"));
pTLMItem->setText(tr("TLM"));
pTLMItem->setText(tr("OMTLMSimulator"));
// Traceability Item
QListWidgetItem *pTraceabilityItem = new QListWidgetItem(mpOptionsList);
pTraceabilityItem->setIcon(QIcon(":/Resources/icons/traceability.svg"));
Expand Down Expand Up @@ -4334,20 +4334,23 @@ TLMPage::TLMPage(OptionsDialog *pOptionsDialog)
mpOptionsDialog = pOptionsDialog;
mpGeneralGroupBox = new QGroupBox(Helper::general);
// TLM Plugin Path
mpTLMPluginPathLabel = new Label(tr("TLM Plugin Path:"));
mpTLMPluginPathLabel = new Label(tr("Path:"));
mpTLMPluginPathTextBox = new QLineEdit;
mpTLMPluginPathTextBox->setPlaceholderText(QString("%1/OMTLMSimulator/bin").arg(Helper::OpenModelicaHome));
mpBrowseTLMPluginPathButton = new QPushButton(Helper::browse);
mpBrowseTLMPluginPathButton->setAutoDefault(false);
connect(mpBrowseTLMPluginPathButton, SIGNAL(clicked()), SLOT(browseTLMPluginPath()));
// TLM Manager Process
mpTLMManagerProcessLabel = new Label(tr("TLM Manager Process:"));
mpTLMManagerProcessLabel = new Label(tr("Manager Process:"));
mpTLMManagerProcessTextBox = new QLineEdit;
mpTLMManagerProcessTextBox->setPlaceholderText(QString("%1/OMTLMSimulator/bin/tlmmanager").arg(Helper::OpenModelicaHome));
mpBrowseTLMManagerProcessButton = new QPushButton(Helper::browse);
mpBrowseTLMManagerProcessButton->setAutoDefault(false);
connect(mpBrowseTLMManagerProcessButton, SIGNAL(clicked()), SLOT(browseTLMManagerProcess()));
// TLM Monitor Process
mpTLMMonitorProcessLabel = new Label(tr("TLM Monitor Process:"));
mpTLMMonitorProcessLabel = new Label(tr("Monitor Process:"));
mpTLMMonitorProcessTextBox = new QLineEdit;
mpTLMMonitorProcessTextBox->setPlaceholderText(QString("%1/OMTLMSimulator/bin/tlmmonitor").arg(Helper::OpenModelicaHome));
mpBrowseTLMMonitorProcessButton = new QPushButton(Helper::browse);
mpBrowseTLMMonitorProcessButton->setAutoDefault(false);
connect(mpBrowseTLMMonitorProcessButton, SIGNAL(clicked()), SLOT(browseTLMMonitorProcess()));
Expand All @@ -4360,9 +4363,10 @@ TLMPage::TLMPage(OptionsDialog *pOptionsDialog)
pGeneralGroupBoxLayout->addWidget(mpTLMManagerProcessLabel, 1, 0);
pGeneralGroupBoxLayout->addWidget(mpTLMManagerProcessTextBox, 1, 1);
pGeneralGroupBoxLayout->addWidget(mpBrowseTLMManagerProcessButton, 1, 2);
pGeneralGroupBoxLayout->addWidget(mpTLMMonitorProcessLabel, 2, 0);
pGeneralGroupBoxLayout->addWidget(mpTLMMonitorProcessTextBox, 2, 1);
pGeneralGroupBoxLayout->addWidget(mpBrowseTLMMonitorProcessButton, 2, 2);
pGeneralGroupBoxLayout->addWidget(mpTLMMonitorProcessLabel, 3, 0);
pGeneralGroupBoxLayout->addWidget(mpTLMMonitorProcessTextBox, 3, 1);
pGeneralGroupBoxLayout->addWidget(mpBrowseTLMMonitorProcessButton, 3, 2);
pGeneralGroupBoxLayout->addWidget(new Label(tr("* Default OMTLMSimulator paths are used if above field are empty.")), 4, 0, 1, 3);
mpGeneralGroupBox->setLayout(pGeneralGroupBoxLayout);
QVBoxLayout *pMainLayout = new QVBoxLayout;
pMainLayout->setAlignment(Qt::AlignTop);
Expand All @@ -4371,6 +4375,48 @@ TLMPage::TLMPage(OptionsDialog *pOptionsDialog)
setLayout(pMainLayout);
}

/*!
* \brief TLMPage::getOMTLMSimulatorPath
* Returns the OMTLMSimulator path.
* \return
*/
QString TLMPage::getOMTLMSimulatorPath()
{
if (mpTLMPluginPathTextBox->text().isEmpty()) {
return mpTLMPluginPathTextBox->placeholderText();
} else {
return mpTLMPluginPathTextBox->text();
}
}

/*!
* \brief TLMPage::getOMTLMSimulatorManagerPath
* Returns the OMTLMSimulator manager path.
* \return
*/
QString TLMPage::getOMTLMSimulatorManagerPath()
{
if (mpTLMManagerProcessTextBox->text().isEmpty()) {
return mpTLMManagerProcessTextBox->placeholderText();
} else {
return mpTLMManagerProcessTextBox->text();
}
}

/*!
* \brief TLMPage::getOMTLMSimulatorMonitorPath
* Returns the OMTLMSimulator monitor path.
* \return
*/
QString TLMPage::getOMTLMSimulatorMonitorPath()
{
if (mpTLMMonitorProcessTextBox->text().isEmpty()) {
return mpTLMMonitorProcessTextBox->placeholderText();
} else {
return mpTLMMonitorProcessTextBox->text();
}
}

/*!
* \brief TLMPage::browseTLMPath
* Browse TLM path.
Expand Down
3 changes: 3 additions & 0 deletions OMEdit/OMEditGUI/Options/OptionsDialog.h
Expand Up @@ -857,6 +857,9 @@ class TLMPage : public QWidget
Q_OBJECT
public:
TLMPage(OptionsDialog *pOptionsDialog);
QString getOMTLMSimulatorPath();
QString getOMTLMSimulatorManagerPath();
QString getOMTLMSimulatorMonitorPath();
QLineEdit* getTLMPluginPathTextBox() {return mpTLMPluginPathTextBox;}
QLineEdit* getTLMManagerProcessTextBox() {return mpTLMManagerProcessTextBox;}
QLineEdit* getTLMMonitorProcessTextBox() {return mpTLMMonitorProcessTextBox;}
Expand Down
8 changes: 4 additions & 4 deletions OMEdit/OMEditGUI/TLM/FetchInterfaceDataThread.cpp
Expand Up @@ -68,16 +68,16 @@ void FetchInterfaceDataThread::run()
QProcessEnvironment environment;
#ifdef WIN32
environment = StringHandler::simulationProcessEnvironment();
environment.insert("PATH", pTLMPage->getTLMPluginPathTextBox()->text() + ";" + environment.value("PATH"));
environment.insert("PATH", pTLMPage->getOMTLMSimulatorPath() + ";" + environment.value("PATH"));
#else
environment = QProcessEnvironment::systemEnvironment();
environment.insert("PATH", pTLMPage->getTLMPluginPathTextBox()->text() + ":" + environment.value("PATH"));
#endif
environment.insert("TLMPluginPath", pTLMPage->getTLMPluginPathTextBox()->text());
environment.insert("TLMPluginPath", pTLMPage->getOMTLMSimulatorPath());
mpManagerProcess->setProcessEnvironment(environment);
mpManagerProcess->start(pTLMPage->getTLMManagerProcessTextBox()->text(), args);
mpManagerProcess->start(pTLMPage->getOMTLMSimulatorManagerPath(), args);
mManagerProcessId = Utilities::getProcessId(mpManagerProcess);
emit sendManagerOutput(QString("%1 %2").arg(pTLMPage->getTLMManagerProcessTextBox()->text()).arg(args.join(" ")), StringHandler::OMEditInfo);
emit sendManagerOutput(QString("%1 %2").arg(pTLMPage->getOMTLMSimulatorManagerPath()).arg(args.join(" ")), StringHandler::OMEditInfo);
exec();
}

Expand Down
6 changes: 3 additions & 3 deletions OMEdit/OMEditGUI/TLM/TLMCoSimulationDialog.cpp
Expand Up @@ -187,15 +187,15 @@ void TLMCoSimulationDialog::show(LibraryTreeItem *pLibraryTreeItem)
mpHeadingLabel->setText(QString("%1 - %2").arg(Helper::tlmCoSimulationSetup).arg(mpLibraryTreeItem->getName()));
// if user has nothing in TLM plugin path then read from OptionsDialog
if (mpTLMPluginPathTextBox->text().isEmpty()) {
mpTLMPluginPathTextBox->setText(OptionsDialog::instance()->getTLMPage()->getTLMPluginPathTextBox()->text());
mpTLMPluginPathTextBox->setText(OptionsDialog::instance()->getTLMPage()->getOMTLMSimulatorPath());
}
// if user has nothing in manager process box then read from OptionsDialog
if (mpManagerProcessTextBox->text().isEmpty()) {
mpManagerProcessTextBox->setText(OptionsDialog::instance()->getTLMPage()->getTLMManagerProcessTextBox()->text());
mpManagerProcessTextBox->setText(OptionsDialog::instance()->getTLMPage()->getOMTLMSimulatorManagerPath());
}
// if user has nothing in monitor process box then read from OptionsDialog
if (mpMonitorProcessTextBox->text().isEmpty()) {
mpMonitorProcessTextBox->setText(OptionsDialog::instance()->getTLMPage()->getTLMMonitorProcessTextBox()->text());
mpMonitorProcessTextBox->setText(OptionsDialog::instance()->getTLMPage()->getOMTLMSimulatorMonitorPath());
}
setVisible(true);
}
Expand Down

0 comments on commit 44459e5

Please sign in to comment.