Skip to content

Commit

Permalink
Adapt to oms_setTolerance
Browse files Browse the repository at this point in the history
  • Loading branch information
adeas31 committed Jan 18, 2019
1 parent 0bae201 commit 2b48418
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 26 deletions.
6 changes: 4 additions & 2 deletions OMEdit/OMEditGUI/Modeling/Commands.cpp
Expand Up @@ -2875,7 +2875,8 @@ void SystemSimulationInformationCommand::redoInternal()
setFailed(true);
return;
}
if (!OMSProxy::instance()->setTolerance(mpLibraryTreeItem->getNameStructure(), mpWCSystemSimulationInformation->mTolerance)) {
if (!OMSProxy::instance()->setTolerance(mpLibraryTreeItem->getNameStructure(), mpWCSystemSimulationInformation->mAbsoluteTolerance,
mpWCSystemSimulationInformation->mRelativeTolerance)) {
setFailed(true);
return;
}
Expand All @@ -2884,7 +2885,8 @@ void SystemSimulationInformationCommand::redoInternal()
setFailed(true);
return;
}
if (!OMSProxy::instance()->setTolerance(mpLibraryTreeItem->getNameStructure(), mpSCSystemSimulationInformation->mTolerance)) {
if (!OMSProxy::instance()->setTolerance(mpLibraryTreeItem->getNameStructure(), mpSCSystemSimulationInformation->mAbsoluteTolerance,
mpSCSystemSimulationInformation->mRelativeTolerance)) {
setFailed(true);
return;
}
Expand Down
6 changes: 3 additions & 3 deletions OMEdit/OMEditGUI/OMS/OMSProxy.cpp
Expand Up @@ -1367,13 +1367,13 @@ bool OMSProxy::setTLMSocketData(QString cref, QString address, int managerPort,
* \param tolerance
* \return
*/
bool OMSProxy::setTolerance(QString cref, double tolerance)
bool OMSProxy::setTolerance(QString cref, double absoluteTolerance, double relativeTolerance)
{
QString command = "oms_setTolerance";
QStringList args;
args << "\"" + cref + "\"" << QString::number(tolerance);
args << "\"" + cref + "\"" << QString::number(absoluteTolerance) << QString::number(relativeTolerance);
LOG_COMMAND(command, args);
oms_status_enu_t status = oms_setTolerance(cref.toStdString().c_str(), tolerance, tolerance);
oms_status_enu_t status = oms_setTolerance(cref.toStdString().c_str(), absoluteTolerance, relativeTolerance);
logResponse(command, status, &commandTime);
return statusToBool(status);
}
Expand Down
2 changes: 1 addition & 1 deletion OMEdit/OMEditGUI/OMS/OMSProxy.h
Expand Up @@ -130,7 +130,7 @@ class OMSProxy : public QObject
bool setTLMBusGeometry(QString cref, const ssd_connector_geometry_t* pGeometry);
bool setTLMConnectionParameters(QString crefA, QString crefB, const oms_tlm_connection_parameters_t *pParameters);
bool setTLMSocketData(QString cref, QString address, int managerPort, int monitorPort);
bool setTolerance(QString cref, double tolerance);
bool setTolerance(QString cref, double absoluteTolerance, double relativeTolerance);
void setWorkingDirectory(QString path);
bool simulate_asynchronous(QString cref);
bool terminate(QString cref);
Expand Down
48 changes: 32 additions & 16 deletions OMEdit/OMEditGUI/OMS/SystemSimulationInformationDialog.cpp
Expand Up @@ -48,13 +48,15 @@ TLMSystemSimulationInformation::TLMSystemSimulationInformation()
WCSystemSimulationInformation::WCSystemSimulationInformation()
{
mFixedStepSize = 0.0;
mTolerance = 0.0;
mAbsoluteTolerance = 0.0;
mRelativeTolerance = 0.0;
}

SCSystemSimulationInformation::SCSystemSimulationInformation()
{
mFixedStepSize = 0.0;
mTolerance = 0.0;
mAbsoluteTolerance = 0.0;
mRelativeTolerance = 0.0;

mDescription = "";
mAbsoluteTolerance = 0.0;
Expand Down Expand Up @@ -105,19 +107,27 @@ SystemSimulationInformationDialog::SystemSimulationInformationDialog(GraphicsVie
mpFixedStepSizeLabel = new Label(tr("Fixed Step Size:"));
mpFixedStepSizeTextBox = new QLineEdit;
mpFixedStepSizeTextBox->setValidator(pDoubleValidator);
// tolerance
mpToleranceLabel = new Label("Tolerance:");
mpToleranceTextBox = new QLineEdit;
mpToleranceTextBox->setValidator(pDoubleValidator);
// absolute tolerance
mpAbsoluteToleranceLabel = new Label("Absolute Tolerance:");
mpAbsoluteToleranceTextBox = new QLineEdit;
mpAbsoluteToleranceTextBox->setValidator(pDoubleValidator);
// relative tolerance
mpRelativeToleranceLabel = new Label("Relative Tolerance:");
mpRelativeToleranceTextBox = new QLineEdit;
mpRelativeToleranceTextBox->setValidator(pDoubleValidator);
} else { // oms_system_sc
// fixed step size
mpFixedStepSizeLabel = new Label(tr("Fixed Step Size:"));
mpFixedStepSizeTextBox = new QLineEdit;
mpFixedStepSizeTextBox->setValidator(pDoubleValidator);
// tolerance
mpToleranceLabel = new Label("Tolerance:");
mpToleranceTextBox = new QLineEdit;
mpToleranceTextBox->setValidator(pDoubleValidator);
// absolute tolerance
mpAbsoluteToleranceLabel = new Label("Absolute Tolerance:");
mpAbsoluteToleranceTextBox = new QLineEdit;
mpAbsoluteToleranceTextBox->setValidator(pDoubleValidator);
// relative tolerance
mpRelativeToleranceLabel = new Label("Relative Tolerance:");
mpRelativeToleranceTextBox = new QLineEdit;
mpRelativeToleranceTextBox->setValidator(pDoubleValidator);
}
// buttons
mpOkButton = new QPushButton(Helper::ok);
Expand Down Expand Up @@ -146,13 +156,17 @@ SystemSimulationInformationDialog::SystemSimulationInformationDialog(GraphicsVie
} else if (mpGraphicsView->getModelWidget()->getLibraryTreeItem()->isWCSystem()) {
pMainLayout->addWidget(mpFixedStepSizeLabel, row, 0);
pMainLayout->addWidget(mpFixedStepSizeTextBox, row++, 1);
pMainLayout->addWidget(mpToleranceLabel, row, 0);
pMainLayout->addWidget(mpToleranceTextBox, row++, 1);
pMainLayout->addWidget(mpAbsoluteToleranceLabel, row, 0);
pMainLayout->addWidget(mpAbsoluteToleranceTextBox, row++, 1);
pMainLayout->addWidget(mpRelativeToleranceLabel, row, 0);
pMainLayout->addWidget(mpRelativeToleranceTextBox, row++, 1);
} else { // oms_system_sc
pMainLayout->addWidget(mpFixedStepSizeLabel, row, 0);
pMainLayout->addWidget(mpFixedStepSizeTextBox, row++, 1);
pMainLayout->addWidget(mpToleranceLabel, row, 0);
pMainLayout->addWidget(mpToleranceTextBox, row++, 1);
pMainLayout->addWidget(mpAbsoluteToleranceLabel, row, 0);
pMainLayout->addWidget(mpAbsoluteToleranceTextBox, row++, 1);
pMainLayout->addWidget(mpRelativeToleranceLabel, row, 0);
pMainLayout->addWidget(mpRelativeToleranceTextBox, row++, 1);
}
pMainLayout->addWidget(mpButtonBox, row++, 0, 1, 2, Qt::AlignRight);
setLayout(pMainLayout);
Expand Down Expand Up @@ -204,10 +218,12 @@ void SystemSimulationInformationDialog::setSystemSimulationInformation()
tlmSystemSimulationInformation.mMonitorPort = mpMonitorPortTextBox->text().toInt();
} else if (mpGraphicsView->getModelWidget()->getLibraryTreeItem()->isWCSystem()) {
wcSystemSimulationInformation.mFixedStepSize = mpFixedStepSizeTextBox->text().toDouble();
wcSystemSimulationInformation.mTolerance = mpToleranceTextBox->text().toDouble();
wcSystemSimulationInformation.mAbsoluteTolerance = mpAbsoluteToleranceTextBox->text().toDouble();
wcSystemSimulationInformation.mRelativeTolerance = mpRelativeToleranceTextBox->text().toDouble();
} else { // oms_system_sc
scSystemSimulationInformation.mFixedStepSize = mpFixedStepSizeTextBox->text().toDouble();
scSystemSimulationInformation.mTolerance = mpToleranceTextBox->text().toDouble();
wcSystemSimulationInformation.mAbsoluteTolerance = mpAbsoluteToleranceTextBox->text().toDouble();
wcSystemSimulationInformation.mRelativeTolerance = mpRelativeToleranceTextBox->text().toDouble();
}
// system simulation information command
SystemSimulationInformationCommand *pSystemSimulationInformationCommand;
Expand Down
10 changes: 6 additions & 4 deletions OMEdit/OMEditGUI/OMS/SystemSimulationInformationDialog.h
Expand Up @@ -57,7 +57,8 @@ class WCSystemSimulationInformation
WCSystemSimulationInformation();

double mFixedStepSize;
double mTolerance;
double mAbsoluteTolerance;
double mRelativeTolerance;
};

class SCSystemSimulationInformation
Expand All @@ -66,7 +67,6 @@ class SCSystemSimulationInformation
SCSystemSimulationInformation();

double mFixedStepSize;
double mTolerance;

QString mDescription;
double mAbsoluteTolerance;
Expand Down Expand Up @@ -95,8 +95,10 @@ class SystemSimulationInformationDialog : public QDialog
// WC system simulation information
Label *mpFixedStepSizeLabel;
QLineEdit *mpFixedStepSizeTextBox;
Label *mpToleranceLabel;
QLineEdit *mpToleranceTextBox;
Label *mpAbsoluteToleranceLabel;
QLineEdit *mpAbsoluteToleranceTextBox;
Label *mpRelativeToleranceLabel;
QLineEdit *mpRelativeToleranceTextBox;
QPushButton *mpOkButton;
QPushButton *mpCancelButton;
QDialogButtonBox *mpButtonBox;
Expand Down

0 comments on commit 2b48418

Please sign in to comment.