Skip to content

Commit

Permalink
- OMEdit/simulation: Use -port XXXX to send status updates to OMEdit.…
Browse files Browse the repository at this point in the history
… TODO: Implement this in the GUI (Adeel)

git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@10267 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
sjoelund committed Nov 1, 2011
1 parent 6ac155e commit 2a24207
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion OMEdit/OMEditGUI/SimulationWidget.cpp
Expand Up @@ -354,11 +354,38 @@ void SimulationWidget::simulateModel(QString simulationParameters)
mpProgressDialog->mpCancelSimulationButton->setEnabled(true);
mpProgressDialog->setText(Helper::running_Simulation_text);
mpParentMainWindow->mpStatusBar->showMessage(Helper::running_Simulation);
mpSimulationProcess->start(file);

QTcpSocket *sock = 0;
QTcpServer server;
const int SOCKMAXLEN = 4096;
char buf[SOCKMAXLEN];
server.listen(QHostAddress("127.0.0.1"));
QStringList args("-port");
args << QString::number(server.serverPort());

mpSimulationProcess->start(file,args);
while (mpSimulationProcess->state() == QProcess::Starting || mpSimulationProcess->state() == QProcess::Running)
{
if (!sock && server.hasPendingConnections()) {
sock = server.nextPendingConnection();
} else if (!sock) {
server.waitForNewConnection(100,0);
} else {
while (sock->readLine(buf,SOCKMAXLEN) > 0) {
char *msg = 0;
double d = strtod(buf, &msg);
if (msg == buf || *msg != ' ') {
fprintf(stderr, "TODO: OMEdit GUI: COMM ERROR '%s'", msg);
} else {
fprintf(stderr, "TODO: OMEdit GUI: Display progress (%g%%) and message: %s", d/100.0, msg+1);
}
}
}
qApp->processEvents();
}
if (sock) delete sock;
server.close();

// we set the Progress Dialog box to hide when we cancel the simulation, so don't show user the plottin view just return.
if (mpProgressDialog->isHidden())
return;
Expand Down

0 comments on commit 2a24207

Please sign in to comment.