Added more detailed timeout for data transfer between ResInsight and Octave

p4#: 22148
This commit is contained in:
Magne Sjaastad 2013-08-12 11:38:09 +02:00
parent 494a5857dd
commit 8c128aeb6e
19 changed files with 55 additions and 82 deletions

View File

@ -9,12 +9,10 @@ void getActiveCellCenters(NDArray& cellCenterValues, const QString &hostName, qu
QString serverName = hostName;
quint16 serverPort = port;
const int timeout = riOctavePlugin::timeOutMilliSecs;
QTcpSocket socket;
socket.connectToHost(serverName, serverPort);
if (!socket.waitForConnected(timeout))
if (!socket.waitForConnected(riOctavePlugin::connectTimeOutMilliSecs))
{
error((("Connection: ") + socket.errorString()).toLatin1().data());
return;
@ -35,7 +33,7 @@ void getActiveCellCenters(NDArray& cellCenterValues, const QString &hostName, qu
while (socket.bytesAvailable() < (int)(2 * sizeof(quint64)))
{
if (!socket.waitForReadyRead(timeout))
if (!socket.waitForReadyRead(riOctavePlugin::shortTimeOutMilliSecs))
{
error((("Waiting for header: ") + socket.errorString()).toLatin1().data());
return;
@ -65,7 +63,7 @@ void getActiveCellCenters(NDArray& cellCenterValues, const QString &hostName, qu
while (socket.bytesAvailable() < (qint64)(byteCount))
{
if (!socket.waitForReadyRead(timeout))
if (!socket.waitForReadyRead(riOctavePlugin::longTimeOutMilliSecs))
{
error((("Waiting for data: ") + socket.errorString()).toLatin1().data());
return;

View File

@ -9,12 +9,10 @@ void getActiveCellCorners(NDArray& cellCornerValues, const QString &hostName, qu
QString serverName = hostName;
quint16 serverPort = port;
const int timeout = riOctavePlugin::timeOutMilliSecs;
QTcpSocket socket;
socket.connectToHost(serverName, serverPort);
if (!socket.waitForConnected(timeout))
if (!socket.waitForConnected(riOctavePlugin::connectTimeOutMilliSecs))
{
error((("Connection: ") + socket.errorString()).toLatin1().data());
return;
@ -35,7 +33,7 @@ void getActiveCellCorners(NDArray& cellCornerValues, const QString &hostName, qu
while (socket.bytesAvailable() < (int)(2 * sizeof(quint64)))
{
if (!socket.waitForReadyRead(timeout))
if (!socket.waitForReadyRead(riOctavePlugin::shortTimeOutMilliSecs))
{
error((("Waiting for header: ") + socket.errorString()).toLatin1().data());
return;
@ -65,7 +63,7 @@ void getActiveCellCorners(NDArray& cellCornerValues, const QString &hostName, qu
while (socket.bytesAvailable() < (qint64)(byteCount))
{
if (!socket.waitForReadyRead(timeout))
if (!socket.waitForReadyRead(riOctavePlugin::longTimeOutMilliSecs))
{
error((("Waiting for data: ") + socket.errorString()).toLatin1().data());
return;

View File

@ -9,12 +9,10 @@ void getActiveCellInfo(int32NDArray& activeCellInfo, const QString &hostName, qu
QString serverName = hostName;
quint16 serverPort = port;
const int timeout = riOctavePlugin::timeOutMilliSecs;
QTcpSocket socket;
socket.connectToHost(serverName, serverPort);
if (!socket.waitForConnected(timeout))
if (!socket.waitForConnected(riOctavePlugin::connectTimeOutMilliSecs))
{
error((("Connection: ") + socket.errorString()).toLatin1().data());
return;
@ -35,7 +33,7 @@ void getActiveCellInfo(int32NDArray& activeCellInfo, const QString &hostName, qu
while (socket.bytesAvailable() < (int)(2*sizeof(quint64)))
{
if (!socket.waitForReadyRead(timeout))
if (!socket.waitForReadyRead(riOctavePlugin::shortTimeOutMilliSecs))
{
error((("Waiting for header: ") + socket.errorString()).toLatin1().data());
return;
@ -69,7 +67,7 @@ void getActiveCellInfo(int32NDArray& activeCellInfo, const QString &hostName, qu
{
while (socket.bytesAvailable() < (int)byteCount)
{
if (!socket.waitForReadyRead(timeout))
if (!socket.waitForReadyRead(riOctavePlugin::longTimeOutMilliSecs))
{
QString errorMsg = QString("Waiting for column number: %1 of %2: %3").arg(tIdx).arg(columnCount).arg(socket.errorString());

View File

@ -5,12 +5,10 @@
void getActiveCellProperty(Matrix& propertyFrames, const QString &serverName, quint16 serverPort,
const qint64& caseId, QString propertyName, const int32NDArray& requestedTimeSteps, QString porosityModel)
{
const int Timeout = riOctavePlugin::timeOutMilliSecs;
QTcpSocket socket;
socket.connectToHost(serverName, serverPort);
if (!socket.waitForConnected(Timeout))
if (!socket.waitForConnected(riOctavePlugin::connectTimeOutMilliSecs))
{
error((("Connection: ") + socket.errorString()).toLatin1().data());
return;
@ -40,7 +38,7 @@ void getActiveCellProperty(Matrix& propertyFrames, const QString &serverName, qu
while (socket.bytesAvailable() < (int)(2*sizeof(quint64)))
{
if (!socket.waitForReadyRead(Timeout))
if (!socket.waitForReadyRead(riOctavePlugin::shortTimeOutMilliSecs))
{
error((("Waiting for header: ") + socket.errorString()).toLatin1().data());
return;
@ -71,7 +69,7 @@ void getActiveCellProperty(Matrix& propertyFrames, const QString &serverName, qu
{
while (socket.bytesAvailable() < (int)byteCount)
{
if (!socket.waitForReadyRead(Timeout))
if (!socket.waitForReadyRead(riOctavePlugin::longTimeOutMilliSecs))
{
error((("Waiting for timestep data number: ") + QString::number(tIdx)+ ": " + socket.errorString()).toLatin1().data());
octave_stdout << "Active cells: " << activeCellCount << ", Timesteps: " << timestepCount << std::endl;

View File

@ -9,12 +9,10 @@ void getCaseGroups(std::vector<QString>& groupNames, std::vector<int>& groupIds,
QString serverName = hostName;
quint16 serverPort = port;
const int timeout = riOctavePlugin::timeOutMilliSecs;
QTcpSocket socket;
socket.connectToHost(serverName, serverPort);
if (!socket.waitForConnected(timeout))
if (!socket.waitForConnected(riOctavePlugin::connectTimeOutMilliSecs))
{
error((("Connection: ") + socket.errorString()).toLatin1().data());
return;
@ -33,7 +31,7 @@ void getCaseGroups(std::vector<QString>& groupNames, std::vector<int>& groupIds,
// Get response. First wait for the header
while (socket.bytesAvailable() < (int)(2*sizeof(quint64)))
{
if (!socket.waitForReadyRead(timeout))
if (!socket.waitForReadyRead(riOctavePlugin::shortTimeOutMilliSecs))
{
error((("Waiting for data: ") + socket.errorString()).toLatin1().data());
return;
@ -51,7 +49,7 @@ void getCaseGroups(std::vector<QString>& groupNames, std::vector<int>& groupIds,
// Get response. Read all data for command
while (socket.bytesAvailable() < (int)byteCount)
{
if (!socket.waitForReadyRead(timeout))
if (!socket.waitForReadyRead(riOctavePlugin::shortTimeOutMilliSecs))
{
error((("Waiting for data: ") + socket.errorString()).toLatin1().data());
return;

View File

@ -9,12 +9,10 @@ void getCases(std::vector<qint64>& caseIds, std::vector<QString>& caseNames, std
QString serverName = hostName;
quint16 serverPort = port;
const int timeout = riOctavePlugin::timeOutMilliSecs;
QTcpSocket socket;
socket.connectToHost(serverName, serverPort);
if (!socket.waitForConnected(timeout))
if (!socket.waitForConnected(riOctavePlugin::connectTimeOutMilliSecs))
{
error((("Connection: ") + socket.errorString()).toLatin1().data());
return;
@ -35,7 +33,7 @@ void getCases(std::vector<qint64>& caseIds, std::vector<QString>& caseNames, std
while (socket.bytesAvailable() < (int)(sizeof(quint64)))
{
if (!socket.waitForReadyRead(timeout))
if (!socket.waitForReadyRead(riOctavePlugin::shortTimeOutMilliSecs))
{
error((("Waiting for header: ") + socket.errorString()).toLatin1().data());
return;
@ -47,7 +45,7 @@ void getCases(std::vector<qint64>& caseIds, std::vector<QString>& caseNames, std
while (socket.bytesAvailable() < (int)(byteCount))
{
if (!socket.waitForReadyRead(timeout))
if (!socket.waitForReadyRead(riOctavePlugin::shortTimeOutMilliSecs))
{
error((("Waiting for data: ") + socket.errorString()).toLatin1().data());
return;

View File

@ -9,12 +9,10 @@ void getCellCenters(NDArray& cellCenterValues, const QString &hostName, quint16
QString serverName = hostName;
quint16 serverPort = port;
const int timeout = riOctavePlugin::timeOutMilliSecs;
QTcpSocket socket;
socket.connectToHost(serverName, serverPort);
if (!socket.waitForConnected(timeout))
if (!socket.waitForConnected(riOctavePlugin::connectTimeOutMilliSecs))
{
error((("Connection: ") + socket.errorString()).toLatin1().data());
return;
@ -35,7 +33,7 @@ void getCellCenters(NDArray& cellCenterValues, const QString &hostName, quint16
while (socket.bytesAvailable() < (int)(5 * sizeof(quint64)))
{
if (!socket.waitForReadyRead(timeout))
if (!socket.waitForReadyRead(riOctavePlugin::shortTimeOutMilliSecs))
{
error((("Waiting for header: ") + socket.errorString()).toLatin1().data());
return;
@ -70,7 +68,7 @@ void getCellCenters(NDArray& cellCenterValues, const QString &hostName, quint16
while (socket.bytesAvailable() < (qint64)(byteCount))
{
if (!socket.waitForReadyRead(timeout))
if (!socket.waitForReadyRead(riOctavePlugin::longTimeOutMilliSecs))
{
error((("Waiting for data: ") + socket.errorString()).toLatin1().data());
return;

View File

@ -9,12 +9,10 @@ void getCellCorners(NDArray& cellCornerValues, const QString &hostName, quint16
QString serverName = hostName;
quint16 serverPort = port;
const int timeout = riOctavePlugin::timeOutMilliSecs;
QTcpSocket socket;
socket.connectToHost(serverName, serverPort);
if (!socket.waitForConnected(timeout))
if (!socket.waitForConnected(riOctavePlugin::connectTimeOutMilliSecs))
{
error((("Connection: ") + socket.errorString()).toLatin1().data());
return;
@ -35,7 +33,7 @@ void getCellCorners(NDArray& cellCornerValues, const QString &hostName, quint16
while (socket.bytesAvailable() < (int)(5 * sizeof(quint64)))
{
if (!socket.waitForReadyRead(timeout))
if (!socket.waitForReadyRead(riOctavePlugin::shortTimeOutMilliSecs))
{
error((("Waiting for header: ") + socket.errorString()).toLatin1().data());
return;
@ -72,7 +70,7 @@ void getCellCorners(NDArray& cellCornerValues, const QString &hostName, quint16
while (socket.bytesAvailable() < (qint64)(byteCount))
{
if (!socket.waitForReadyRead(timeout))
if (!socket.waitForReadyRead(riOctavePlugin::longTimeOutMilliSecs))
{
error((("Waiting for data: ") + socket.errorString()).toLatin1().data());
return;

View File

@ -9,12 +9,10 @@ void getCoarseningInfo(int32NDArray& coarseningInfo, const QString &hostName, qu
QString serverName = hostName;
quint16 serverPort = port;
const int Timeout = 5 * 1000;
QTcpSocket socket;
socket.connectToHost(serverName, serverPort);
if (!socket.waitForConnected(Timeout))
if (!socket.waitForConnected(riOctavePlugin::connectTimeOutMilliSecs))
{
error((("Connection: ") + socket.errorString()).toLatin1().data());
return;
@ -35,7 +33,7 @@ void getCoarseningInfo(int32NDArray& coarseningInfo, const QString &hostName, qu
while (socket.bytesAvailable() < (int)(sizeof(quint64)))
{
if (!socket.waitForReadyRead(Timeout))
if (!socket.waitForReadyRead(riOctavePlugin::shortTimeOutMilliSecs))
{
error((("Waiting for header: ") + socket.errorString()).toLatin1().data());
return;

View File

@ -9,12 +9,10 @@ void getCurrentCase(qint64& caseId, QString& caseName, QString& caseType, qint64
QString serverName = hostName;
quint16 serverPort = port;
const int timeout = riOctavePlugin::timeOutMilliSecs;
QTcpSocket socket;
socket.connectToHost(serverName, serverPort);
if (!socket.waitForConnected(timeout))
if (!socket.waitForConnected(riOctavePlugin::connectTimeOutMilliSecs))
{
error((("Connection: ") + socket.errorString()).toLatin1().data());
return;
@ -35,7 +33,7 @@ void getCurrentCase(qint64& caseId, QString& caseName, QString& caseType, qint64
while (socket.bytesAvailable() < (int)(sizeof(quint64)))
{
if (!socket.waitForReadyRead(timeout))
if (!socket.waitForReadyRead(riOctavePlugin::shortTimeOutMilliSecs))
{
error((("Waiting for header: ") + socket.errorString()).toLatin1().data());
return;
@ -47,7 +45,7 @@ void getCurrentCase(qint64& caseId, QString& caseName, QString& caseType, qint64
while (socket.bytesAvailable() < (int)(byteCount))
{
if (!socket.waitForReadyRead(timeout))
if (!socket.waitForReadyRead(riOctavePlugin::shortTimeOutMilliSecs))
{
error((("Waiting for data: ") + socket.errorString()).toLatin1().data());
return;

View File

@ -9,12 +9,10 @@ void getGridDimensions(int32NDArray& gridDimensions, const QString &hostName, qu
QString serverName = hostName;
quint16 serverPort = port;
const int Timeout = 5 * 1000;
QTcpSocket socket;
socket.connectToHost(serverName, serverPort);
if (!socket.waitForConnected(Timeout))
if (!socket.waitForConnected(riOctavePlugin::connectTimeOutMilliSecs))
{
error((("Connection: ") + socket.errorString()).toLatin1().data());
return;
@ -35,7 +33,7 @@ void getGridDimensions(int32NDArray& gridDimensions, const QString &hostName, qu
while (socket.bytesAvailable() < (int)(sizeof(quint64)))
{
if (!socket.waitForReadyRead(Timeout))
if (!socket.waitForReadyRead(riOctavePlugin::shortTimeOutMilliSecs))
{
error((("Waiting for header: ") + socket.errorString()).toLatin1().data());
return;

View File

@ -5,12 +5,12 @@
void getGridProperty(NDArray& propertyFrames, const QString &serverName, quint16 serverPort,
const int& caseId, int gridIdx, QString propertyName, const int32NDArray& requestedTimeSteps, QString porosityModel)
{
const int Timeout = riOctavePlugin::timeOutMilliSecs;
const int Timeout = riOctavePlugin::shortTimeOutMilliSecs;
QTcpSocket socket;
socket.connectToHost(serverName, serverPort);
if (!socket.waitForConnected(Timeout))
if (!socket.waitForConnected(riOctavePlugin::connectTimeOutMilliSecs))
{
error((("Connection: ") + socket.errorString()).toLatin1().data());
return;
@ -40,7 +40,7 @@ void getGridProperty(NDArray& propertyFrames, const QString &serverName, quint16
while (socket.bytesAvailable() < (int)(4*sizeof(quint64)))
{
if (!socket.waitForReadyRead(Timeout))
if (!socket.waitForReadyRead(riOctavePlugin::shortTimeOutMilliSecs))
{
error((("Waiting for header: ") + socket.errorString()).toLatin1().data());
return;
@ -81,7 +81,7 @@ void getGridProperty(NDArray& propertyFrames, const QString &serverName, quint16
while (socket.bytesAvailable() < (int)totalByteCount)
{
if (!socket.waitForReadyRead(Timeout))
if (!socket.waitForReadyRead(riOctavePlugin::longTimeOutMilliSecs))
{
error(("Waiting for data : " + socket.errorString()).toLatin1().data());
return ;

View File

@ -1,18 +1,17 @@
#include <QtNetwork>
#include <octave/oct.h>
#include "riSettings.h"
void getMainGridDimensions(int32NDArray& gridDimensions, const QString &hostName, quint16 port, QString caseName)
{
QString serverName = hostName;
quint16 serverPort = port;
const int Timeout = 5 * 1000;
QTcpSocket socket;
socket.connectToHost(serverName, serverPort);
if (!socket.waitForConnected(Timeout))
if (!socket.waitForConnected(riOctavePlugin::connectTimeOutMilliSecs))
{
error((("Connection: ") + socket.errorString()).toLatin1().data());
return;
@ -34,7 +33,7 @@ void getMainGridDimensions(int32NDArray& gridDimensions, const QString &hostName
while (socket.bytesAvailable() < (int)(3*sizeof(quint64)))
{
if (!socket.waitForReadyRead(Timeout))
if (!socket.waitForReadyRead(riOctavePlugin::shortTimeOutMilliSecs))
{
error((("Waiting for header: ") + socket.errorString()).toLatin1().data());
return;

View File

@ -9,12 +9,10 @@ void getSelectedCases(std::vector<qint64>& caseIds, std::vector<QString>& caseNa
QString serverName = hostName;
quint16 serverPort = port;
const int timeout = riOctavePlugin::timeOutMilliSecs;
QTcpSocket socket;
socket.connectToHost(serverName, serverPort);
if (!socket.waitForConnected(timeout))
if (!socket.waitForConnected(riOctavePlugin::connectTimeOutMilliSecs))
{
error((("Connection: ") + socket.errorString()).toLatin1().data());
return;
@ -35,7 +33,7 @@ void getSelectedCases(std::vector<qint64>& caseIds, std::vector<QString>& caseNa
while (socket.bytesAvailable() < (int)(sizeof(quint64)))
{
if (!socket.waitForReadyRead(timeout))
if (!socket.waitForReadyRead(riOctavePlugin::shortTimeOutMilliSecs))
{
error((("Waiting for header: ") + socket.errorString()).toLatin1().data());
return;
@ -47,7 +45,7 @@ void getSelectedCases(std::vector<qint64>& caseIds, std::vector<QString>& caseNa
while (socket.bytesAvailable() < (int)(byteCount))
{
if (!socket.waitForReadyRead(timeout))
if (!socket.waitForReadyRead(riOctavePlugin::shortTimeOutMilliSecs))
{
error((("Waiting for data: ") + socket.errorString()).toLatin1().data());
return;

View File

@ -17,12 +17,10 @@ void getTimeStepDates( std::vector<qint32>& yearValues,
QString serverName = hostName;
quint16 serverPort = port;
const int timeout = riOctavePlugin::timeOutMilliSecs;
QTcpSocket socket;
socket.connectToHost(serverName, serverPort);
if (!socket.waitForConnected(timeout))
if (!socket.waitForConnected(riOctavePlugin::connectTimeOutMilliSecs))
{
error((("Connection: ") + socket.errorString()).toLatin1().data());
return;
@ -43,7 +41,7 @@ void getTimeStepDates( std::vector<qint32>& yearValues,
while (socket.bytesAvailable() < (int)(sizeof(quint64)))
{
if (!socket.waitForReadyRead(timeout))
if (!socket.waitForReadyRead(riOctavePlugin::shortTimeOutMilliSecs))
{
error((("Waiting for header: ") + socket.errorString()).toLatin1().data());
return;
@ -55,7 +53,7 @@ void getTimeStepDates( std::vector<qint32>& yearValues,
while (socket.bytesAvailable() < (int)(byteCount))
{
if (!socket.waitForReadyRead(timeout))
if (!socket.waitForReadyRead(riOctavePlugin::shortTimeOutMilliSecs))
{
error((("Waiting for data: ") + socket.errorString()).toLatin1().data());
return;

View File

@ -11,12 +11,10 @@ void getTimeStepDates( std::vector<double>& decimalDays,
QString serverName = hostName;
quint16 serverPort = port;
const int timeout = riOctavePlugin::timeOutMilliSecs;
QTcpSocket socket;
socket.connectToHost(serverName, serverPort);
if (!socket.waitForConnected(timeout))
if (!socket.waitForConnected(riOctavePlugin::shortTimeOutMilliSecs))
{
error((("Connection: ") + socket.errorString()).toLatin1().data());
return;
@ -37,7 +35,7 @@ void getTimeStepDates( std::vector<double>& decimalDays,
while (socket.bytesAvailable() < (int)(sizeof(quint64)))
{
if (!socket.waitForReadyRead(timeout))
if (!socket.waitForReadyRead(riOctavePlugin::shortTimeOutMilliSecs))
{
error((("Waiting for header: ") + socket.errorString()).toLatin1().data());
return;
@ -49,7 +47,7 @@ void getTimeStepDates( std::vector<double>& decimalDays,
while (socket.bytesAvailable() < (int)(byteCount))
{
if (!socket.waitForReadyRead(timeout))
if (!socket.waitForReadyRead(riOctavePlugin::shortTimeOutMilliSecs))
{
error((("Waiting for data: ") + socket.errorString()).toLatin1().data());
return;

View File

@ -9,7 +9,7 @@ void setEclipseProperty(const Matrix& propertyFrames, const QString &hostName, q
QTcpSocket socket;
socket.connectToHost(hostName, port);
if (!socket.waitForConnected(riOctavePlugin::timeOutMilliSecs))
if (!socket.waitForConnected(riOctavePlugin::connectTimeOutMilliSecs))
{
error((("Connection: ") + socket.errorString()).toLatin1().data());
return;
@ -47,7 +47,7 @@ void setEclipseProperty(const Matrix& propertyFrames, const QString &hostName, q
socketStream << (qint64)timeStepByteCount;
const double* internalData = propertyFrames.fortran_vec();
int dataWritten = socket.write((const char *)internalData, timeStepByteCount*timeStepCount);
qint64 dataWritten = socket.write((const char *)internalData, timeStepByteCount*timeStepCount);
if (dataWritten == timeStepByteCount*timeStepCount)
{
@ -72,7 +72,7 @@ void setEclipseProperty(const Matrix& propertyFrames, const QString &hostName, q
while(socket.bytesToWrite() && socket.state() == QAbstractSocket::ConnectedState)
{
// octave_stdout << "Bytes to write: " << socket.bytesToWrite() << std::endl;
socket.waitForBytesWritten(riOctavePlugin::timeOutMilliSecs);
socket.waitForBytesWritten(riOctavePlugin::longTimeOutMilliSecs);
OCTAVE_QUIT;
}

View File

@ -9,7 +9,7 @@ void setEclipseProperty(const NDArray& propertyFrames, const QString &hostName,
QTcpSocket socket;
socket.connectToHost(hostName, port);
if (!socket.waitForConnected(riOctavePlugin::timeOutMilliSecs))
if (!socket.waitForConnected(riOctavePlugin::shortTimeOutMilliSecs))
{
error((("Connection: ") + socket.errorString()).toLatin1().data());
return;
@ -93,7 +93,7 @@ void setEclipseProperty(const NDArray& propertyFrames, const QString &hostName,
while(socket.bytesToWrite() && socket.state() == QAbstractSocket::ConnectedState)
{
// octave_stdout << "Bytes to write: " << socket.bytesToWrite() << std::endl;
socket.waitForBytesWritten(riOctavePlugin::timeOutMilliSecs);
socket.waitForBytesWritten(riOctavePlugin::longTimeOutMilliSecs);
OCTAVE_QUIT;
}

View File

@ -20,7 +20,9 @@
namespace riOctavePlugin
{
const int timeOutMilliSecs = 5000;
const int connectTimeOutMilliSecs = 5000;
const int shortTimeOutMilliSecs = 5000;
const int longTimeOutMilliSecs = 6 * shortTimeOutMilliSecs;
// Octave data structure : CaseInfo
char caseInfo_CaseId[] = "CaseId";