Removed riSocketTools and updated use of block data transfer

This commit is contained in:
Magne Sjaastad 2014-04-15 14:16:35 +02:00
parent e799a25c2e
commit f1a0bd679c
7 changed files with 31 additions and 113 deletions

View File

@ -4,28 +4,28 @@
# See http://www.cmake.org/Wiki/CMakeUserFindOctave
set(CPP_SOURCES
riGetActiveCellProperty.cpp
riSetActiveCellProperty.cpp
# riGetActiveCellInfo.cpp
# riGetMainGridDimensions.cpp
# riGetCurrentCase.cpp
# riGetCaseGroups.cpp
# riGetSelectedCases.cpp
# riGetCases.cpp
# riGetTimeStepDates.cpp
# riGetTimeStepDays.cpp
# riGetGridDimensions.cpp
# riGetCoarseningInfo.cpp
# riGetCellCenters.cpp
# riGetActiveCellCenters.cpp
# riGetCellCorners.cpp
# riGetActiveCellCorners.cpp
riGetGridProperty.cpp
riSetGridProperty.cpp
# riGetPropertyNames.cpp
# riGetWellNames.cpp
# riGetWellStatus.cpp
# riGetWellCells.cpp
riGetActiveCellProperty.cpp
riSetActiveCellProperty.cpp
riGetActiveCellInfo.cpp
riGetMainGridDimensions.cpp
riGetCurrentCase.cpp
riGetCaseGroups.cpp
riGetSelectedCases.cpp
riGetCases.cpp
riGetTimeStepDates.cpp
riGetTimeStepDays.cpp
riGetGridDimensions.cpp
riGetCoarseningInfo.cpp
riGetCellCenters.cpp
riGetActiveCellCenters.cpp
riGetCellCorners.cpp
riGetActiveCellCorners.cpp
riGetGridProperty.cpp
riSetGridProperty.cpp
riGetPropertyNames.cpp
riGetWellNames.cpp
riGetWellStatus.cpp
riGetWellCells.cpp
)
if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
@ -143,7 +143,6 @@ if (RESINSIGHT_OCTAVE_PLUGIN_QMAKE AND RESINSIGHT_OCTAVE_PLUGIN_MKOCTFILE)
"${CMAKE_CURRENT_BINARY_DIR}/riGetWellCells.oct"
SOURCES
${CPP_SOURCES}
riSocketTools.h
riSettings.h
)

View File

@ -4,7 +4,7 @@
#include <octave/oct.h>
#include "riSettings.h"
#include "riSocketTools.h"
#include "RiaSocketDataTransfer.cpp" // NB! Include cpp-file to avoid linking of additional file in oct-compile configuration
void getActiveCellCenters(NDArray& cellCenterValues, const QString &hostName, quint16 port, const qint32& caseId, const QString& porosityModel)
@ -66,7 +66,8 @@ void getActiveCellCenters(NDArray& cellCenterValues, const QString &hostName, qu
double* internalMatrixData = cellCenterValues.fortran_vec();
QStringList errorMessages;
if (!readBlockData(socket, (char*)(internalMatrixData), byteCount, errorMessages))
if (!RiaSocketDataTransfer::readBlockDataFromSocket(&socket, (char*)(internalMatrixData), byteCount, errorMessages))
{
for (int i = 0; i < errorMessages.size(); i++)
{

View File

@ -4,7 +4,7 @@
#include <octave/oct.h>
#include "riSettings.h"
#include "riSocketTools.h"
#include "RiaSocketDataTransfer.cpp" // NB! Include cpp-file to avoid linking of additional file in oct-compile configuration
void getActiveCellCorners(NDArray& cellCornerValues, const QString &hostName, quint16 port, const qint32& caseId, const QString& porosityModel)
@ -66,7 +66,7 @@ void getActiveCellCorners(NDArray& cellCornerValues, const QString &hostName, qu
double* internalMatrixData = cellCornerValues.fortran_vec();
QStringList errorMessages;
if (!readBlockData(socket, (char*)(internalMatrixData), byteCount, errorMessages))
if (!RiaSocketDataTransfer::readBlockDataFromSocket(&socket, (char*)(internalMatrixData), byteCount, errorMessages))
{
for (int i = 0; i < errorMessages.size(); i++)
{

View File

@ -4,7 +4,7 @@
#include <octave/oct.h>
#include "riSettings.h"
#include "riSocketTools.h"
#include "RiaSocketDataTransfer.cpp" // NB! Include cpp-file to avoid linking of additional file in oct-compile configuration
void getCellCenters(NDArray& cellCenterValues, const QString &hostName, quint16 port, const qint32& caseId, const quint32& gridIndex)
@ -69,10 +69,9 @@ void getCellCenters(NDArray& cellCenterValues, const QString &hostName, quint16
dv(3) = 3;
cellCenterValues.resize(dv);
double* internalMatrixData = cellCenterValues.fortran_vec();
QStringList errorMessages;
if (!readBlockData(socket, (char*)(internalMatrixData), byteCount, errorMessages))
if (!RiaSocketDataTransfer::readBlockDataFromSocket(&socket, (char*)(internalMatrixData), byteCount, errorMessages))
{
for (int i = 0; i < errorMessages.size(); i++)
{

View File

@ -4,7 +4,7 @@
#include <octave/oct.h>
#include "riSettings.h"
#include "riSocketTools.h"
#include "RiaSocketDataTransfer.cpp" // NB! Include cpp-file to avoid linking of additional file in oct-compile configuration
@ -74,7 +74,7 @@ void getCellCorners(NDArray& cellCornerValues, const QString &hostName, quint16
double* internalMatrixData = cellCornerValues.fortran_vec();
QStringList errorMessages;
if (!readBlockData(socket, (char*)(internalMatrixData), byteCount, errorMessages))
if (!RiaSocketDataTransfer::readBlockDataFromSocket(&socket, (char*)(internalMatrixData), byteCount, errorMessages))
{
for (int i = 0; i < errorMessages.size(); i++)
{

View File

@ -3,7 +3,6 @@
#include <octave/oct-map.h>
#include "riSettings.h"
#include "riSocketTools.h"
void getCurrentCase(qint64& caseId, QString& caseName, QString& caseType, qint64& caseGroupId, const QString &hostName, quint16 port)
{

View File

@ -1,80 +0,0 @@
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool readBlockData_to_be_deleted(QTcpSocket& socket, char* data, quint64 bytesToRead, QStringList& errorMessages)
{
quint64 bytesRead = 0;
int blockCount = 0;
quint64 maxBlockSize = riOctavePlugin::socketMaxByteCount;
while (bytesRead < bytesToRead)
{
if (socket.bytesAvailable())
{
quint64 byteCountToRead = qMin(bytesToRead - bytesRead, maxBlockSize);
qint64 actuallyBytesRead = socket.read(data + bytesRead, byteCountToRead);
if (actuallyBytesRead < 0)
{
errorMessages.push_back("Error detected when reading data, error string from socket :");
errorMessages.push_back(socket.errorString());
return false;
}
bytesRead += actuallyBytesRead;
octave_stdout << "Bytes read " << bytesRead << " of total " << bytesToRead << std::endl;
blockCount++;
}
else
{
if (!socket.waitForReadyRead())
{
errorMessages.push_back("Waited for data for %1 milli seconds.");
errorMessages.push_back(socket.errorString());
return false;
}
}
}
octave_stdout << "Bytes read " << bytesToRead << std::endl;
return true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool writeBlockData_to_be_deleted(QTcpSocket& socket, const char* data, quint64 bytesToWrite, QStringList& errorMessages)
{
quint64 bytesWritten = 0;
int blockCount = 0;
quint64 maxBlockSize = riOctavePlugin::socketMaxByteCount;
while (bytesWritten < bytesToWrite)
{
quint64 byteCountToWrite = qMin(bytesToWrite - bytesWritten, maxBlockSize);
qint64 actuallyBytesWritten = socket.write(data + bytesWritten, byteCountToWrite);
if (actuallyBytesWritten < 0)
{
errorMessages.push_back("Error detected when writing data, error string from socket");
errorMessages.push_back(socket.errorString());
return false;
}
bytesWritten += actuallyBytesWritten;
blockCount++;
}
return true;
}