Use socket block read/write for geometry data

This commit is contained in:
Magne Sjaastad
2014-04-03 10:41:27 +02:00
parent 414384804e
commit b16536c9b0
5 changed files with 89 additions and 170 deletions

View File

@@ -1,7 +1,10 @@
#include <QtNetwork>
#include <QStringList>
#include <octave/oct.h>
#include "riSettings.h"
#include "riSocketTools.h"
void getActiveCellCenters(NDArray& cellCenterValues, const QString &hostName, quint16 port, const qint32& caseId, const QString& porosityModel)
@@ -61,24 +64,16 @@ void getActiveCellCenters(NDArray& cellCenterValues, const QString &hostName, qu
cellCenterValues.resize(dv);
while (socket.bytesAvailable() < (qint64)(byteCount))
{
if (!socket.waitForReadyRead(riOctavePlugin::longTimeOutMilliSecs))
{
error((("Waiting for data: ") + socket.errorString()).toLatin1().data());
return;
}
OCTAVE_QUIT;
}
quint64 bytesRead = 0;
double* internalMatrixData = cellCenterValues.fortran_vec();
bytesRead = socket.read((char*)(internalMatrixData), byteCount);
if (byteCount != bytesRead)
QStringList errorMessages;
if (!readBlockData(socket, (char*)(internalMatrixData), byteCount, errorMessages))
{
error("Could not read binary double data properly from socket");
octave_stdout << "Active cell count: " << activeCellCount << std::endl;
for (int i = 0; i < errorMessages.size(); i++)
{
error(errorMessages[i].toLatin1().data());
}
OCTAVE_QUIT;
}
return;