Changeset d5f420a in OpenModelica
- Timestamp:
- 2017-10-19T11:15:41+02:00 (7 years ago)
- Branches:
- Added-citation-metadata, maintenance/v1.14, maintenance/v1.15, maintenance/v1.16, maintenance/v1.17, maintenance/v1.18, maintenance/v1.19, maintenance/v1.20, maintenance/v1.21, maintenance/v1.22, maintenance/v1.23, master, omlib-staging
- Children:
- d60db4d4
- Parents:
- dbc50ee
- git-author:
- Adeel Asghar <adeel.asghar@…> (07/06/17 12:21:44)
- git-committer:
- Adeel Asghar <adeel.asghar@…> (10/19/17 11:15:41)
- Location:
- OMEdit/OMEditGUI/Simulation
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
OMEdit/OMEditGUI/Simulation/OpcUaClient.cpp
rdbc50ee rd5f420a 31 31 UA_StatusCode returnValue = UA_Client_connect(mpClient, UA_ClientConnectionTCP, endPoint.c_str()); 32 32 33 qDebug() << returnValue; 33 34 if (returnValue != UA_STATUSCODE_GOOD) { 34 35 UA_Client_disconnect(mpClient); -
OMEdit/OMEditGUI/Simulation/SimulationDialog.cpp
rdbc50ee rd5f420a 1113 1113 // embedded server port 1114 1114 if (mpInteractiveSimulationPortNumberTextBox->text().isEmpty()) { 1115 // look for an available port1116 QTcpSocket *pSocket = new QTcpSocket();1117 1115 qint16 port = 4841; 1118 // find a port not previously used by another opc ua server1119 pSocket->connectToHost(QHostAddress::LocalHost, port);1120 while (pSocket->waitForConnected(10)) {1121 port++;1122 pSocket->abort();1123 pSocket->connectToHost(QHostAddress::LocalHost, port);1124 }1125 1116 simulationOptions.setInteractiveSimulationPortNumber(port); 1126 1117 simulationFlags.append(QString("-embeddedServerPort=").append(QString::number(port))); … … 1640 1631 Helper::scriptingKind, Helper::errorLevel)); 1641 1632 } 1642 }1643 1644 /*!1645 * \brief SimulationDialog::embeddedServerError1646 * \param simulationOptions1647 * Handles what should be done if the OPC UA client is unable to bind to the server \n1648 * over the selected port. \n1649 */1650 void SimulationDialog::embeddedServerError(QString error)1651 {1652 // make the user aware of the problem1653 QMessageBox::critical(this, QString("%1 - %2").arg(Helper::applicationName, Helper::information),1654 "Embedded simulation server: " + error, Helper::ok);1655 1633 } 1656 1634 -
OMEdit/OMEditGUI/Simulation/SimulationDialog.h
rdbc50ee rd5f420a 232 232 void simulationProcessFinished(SimulationOptions simulationOptions, QDateTime resultFileLastModifiedDateTime); 233 233 void simulationProcessRunning(SimulationOptions simulationOptions); 234 void embeddedServerError(QString error);235 234 public slots: 236 235 void numberOfIntervalsRadioToggled(bool toggle); -
OMEdit/OMEditGUI/Simulation/SimulationOutputWidget.cpp
rdbc50ee rd5f420a 352 352 connect(mpSimulationProcessThread, SIGNAL(sendSimulationStarted()), SLOT(simulationProcessStarted())); 353 353 connect(mpSimulationProcessThread, SIGNAL(sendEmbeddedServerReady()), SLOT(embeddedServerReady())); 354 connect(mpSimulationProcessThread, SIGNAL(sendEmbeddedServerError(QString)), SLOT(embeddedServerError(QString)));355 354 connect(mpSimulationProcessThread, SIGNAL(sendSimulationOutput(QString,StringHandler::SimulationMessageType,bool)), 356 355 SLOT(writeSimulationOutput(QString,StringHandler::SimulationMessageType,bool))); … … 579 578 580 579 /*! 581 * \brief SimulationOutputWidget::embeddedServerReady582 * Slot activated when SimulationProcessThread sendembeddedServerError signal is raised.\n583 * The provided port is unbound and can be used for communication between the client and remote.584 */585 void SimulationOutputWidget::embeddedServerError(QString error)586 {587 MainWindow::instance()->getSimulationDialog()->embeddedServerError(error);588 }589 590 /*!591 580 * \brief SimulationOutputWidget::writeSimulationOutput 592 581 * Slot activated when SimulationProcessThread sendSimulationOutput signal is raised.\n -
OMEdit/OMEditGUI/Simulation/SimulationOutputWidget.h
rdbc50ee rd5f420a 119 119 void simulationProcessStarted(); 120 120 void embeddedServerReady(); 121 void embeddedServerError(QString error);122 121 void writeSimulationOutput(QString output, StringHandler::SimulationMessageType type, bool textFormat); 123 122 void simulationProcessFinished(int exitCode, QProcess::ExitStatus exitStatus); -
OMEdit/OMEditGUI/Simulation/SimulationProcessThread.cpp
rdbc50ee rd5f420a 36 36 37 37 #include <QDir> 38 #include <QTcpSocket>39 38 40 39 SimulationProcessThread::SimulationProcessThread(SimulationOutputWidget *pSimulationOutputWidget) … … 236 235 237 236 if (mpSimulationOutputWidget->getSimulationOptions().isInteractiveSimulation()) { 238 // make sure that the embedded server is ready to be connected to 239 int port = mpSimulationOutputWidget->getSimulationOptions().getInteractiveSimulationPortNumber(); 240 SimulationServerCheckThread *pEmbeddedServerCheckThread = new SimulationServerCheckThread(port); 241 connect(pEmbeddedServerCheckThread, SIGNAL(sendEmbeddedServerReady()), this, SLOT(embeddedServerReady())); 242 connect(pEmbeddedServerCheckThread, SIGNAL(sendEmbeddedServerError(QString)), this, SLOT(embeddedServerError(QString))); 243 connect(pEmbeddedServerCheckThread, SIGNAL(finished()), pEmbeddedServerCheckThread, SLOT(deleteLater())); 244 pEmbeddedServerCheckThread->start(); 245 } 246 } 247 248 /*! 249 * \brief SimulationServerCheckThread::run 250 * Raises the sendEmbeddedServerReady signal when the OPC UA server is ready to be connectd to. \n 251 */ 252 void SimulationServerCheckThread::run() 253 { 254 QTcpSocket *pTcpSocket = new QTcpSocket; 255 while (pTcpSocket->state() != QAbstractSocket::ConnectedState) { 256 pTcpSocket->connectToHost(QHostAddress::LocalHost, mPort); 257 msleep(10); 258 if (pTcpSocket->waitForConnected()) { 259 emit sendEmbeddedServerReady(); 260 } 261 } 262 // make the user aware of known socket errors 263 if (pTcpSocket->error() && pTcpSocket->error() != QAbstractSocket::UnknownSocketError) { 264 emit sendEmbeddedServerError(pTcpSocket->errorString()); 265 } 266 } 267 268 void SimulationProcessThread::embeddedServerReady() 269 { 270 emit sendEmbeddedServerReady(); 271 } 272 273 void SimulationProcessThread::embeddedServerError(QString error) 274 { 275 // if, somehow, the client is unable to bind to the server over the specified port 276 emit sendEmbeddedServerError(error); 237 emit sendEmbeddedServerReady(); 238 } 277 239 } 278 240 -
OMEdit/OMEditGUI/Simulation/SimulationProcessThread.h
rdbc50ee rd5f420a 78 78 void simulationProcessError(QProcess::ProcessError error); 79 79 void simulationProcessFinished(int exitCode, QProcess::ExitStatus exitStatus); 80 void embeddedServerReady();81 void embeddedServerError(QString error);82 80 signals: 83 81 void sendCompilationStarted(); … … 86 84 void sendSimulationStarted(); 87 85 void sendEmbeddedServerReady(); 88 void sendEmbeddedServerError(QString);89 86 void sendEstablishConnectionRunning(); 90 87 void sendSimulationOutput(QString, StringHandler::SimulationMessageType type, bool); … … 92 89 }; 93 90 94 class SimulationServerCheckThread : public QThread95 {96 Q_OBJECT97 public:98 SimulationServerCheckThread(int port)99 : mPort(port) {}100 ~SimulationServerCheckThread(){}101 virtual void run();102 private:103 int mPort;104 signals:105 void sendEmbeddedServerReady();106 void sendEmbeddedServerError(QString);107 };108 109 91 #endif // SIMULATIONPROCESSTHREAD_H
Note: See TracChangeset
for help on using the changeset viewer.