mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Removed riSocketTools and updated use of block data transfer
This commit is contained in:
parent
476387fda4
commit
c0f5d0090f
@ -4,28 +4,28 @@
|
|||||||
# See http://www.cmake.org/Wiki/CMakeUserFindOctave
|
# See http://www.cmake.org/Wiki/CMakeUserFindOctave
|
||||||
|
|
||||||
set(CPP_SOURCES
|
set(CPP_SOURCES
|
||||||
riGetActiveCellProperty.cpp
|
riGetActiveCellProperty.cpp
|
||||||
riSetActiveCellProperty.cpp
|
riSetActiveCellProperty.cpp
|
||||||
# riGetActiveCellInfo.cpp
|
riGetActiveCellInfo.cpp
|
||||||
# riGetMainGridDimensions.cpp
|
riGetMainGridDimensions.cpp
|
||||||
# riGetCurrentCase.cpp
|
riGetCurrentCase.cpp
|
||||||
# riGetCaseGroups.cpp
|
riGetCaseGroups.cpp
|
||||||
# riGetSelectedCases.cpp
|
riGetSelectedCases.cpp
|
||||||
# riGetCases.cpp
|
riGetCases.cpp
|
||||||
# riGetTimeStepDates.cpp
|
riGetTimeStepDates.cpp
|
||||||
# riGetTimeStepDays.cpp
|
riGetTimeStepDays.cpp
|
||||||
# riGetGridDimensions.cpp
|
riGetGridDimensions.cpp
|
||||||
# riGetCoarseningInfo.cpp
|
riGetCoarseningInfo.cpp
|
||||||
# riGetCellCenters.cpp
|
riGetCellCenters.cpp
|
||||||
# riGetActiveCellCenters.cpp
|
riGetActiveCellCenters.cpp
|
||||||
# riGetCellCorners.cpp
|
riGetCellCorners.cpp
|
||||||
# riGetActiveCellCorners.cpp
|
riGetActiveCellCorners.cpp
|
||||||
riGetGridProperty.cpp
|
riGetGridProperty.cpp
|
||||||
riSetGridProperty.cpp
|
riSetGridProperty.cpp
|
||||||
# riGetPropertyNames.cpp
|
riGetPropertyNames.cpp
|
||||||
# riGetWellNames.cpp
|
riGetWellNames.cpp
|
||||||
# riGetWellStatus.cpp
|
riGetWellStatus.cpp
|
||||||
# riGetWellCells.cpp
|
riGetWellCells.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
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"
|
"${CMAKE_CURRENT_BINARY_DIR}/riGetWellCells.oct"
|
||||||
SOURCES
|
SOURCES
|
||||||
${CPP_SOURCES}
|
${CPP_SOURCES}
|
||||||
riSocketTools.h
|
|
||||||
riSettings.h
|
riSettings.h
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
#include <octave/oct.h>
|
#include <octave/oct.h>
|
||||||
|
|
||||||
#include "riSettings.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)
|
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();
|
double* internalMatrixData = cellCenterValues.fortran_vec();
|
||||||
QStringList errorMessages;
|
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++)
|
for (int i = 0; i < errorMessages.size(); i++)
|
||||||
{
|
{
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
#include <octave/oct.h>
|
#include <octave/oct.h>
|
||||||
|
|
||||||
#include "riSettings.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)
|
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();
|
double* internalMatrixData = cellCornerValues.fortran_vec();
|
||||||
QStringList errorMessages;
|
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++)
|
for (int i = 0; i < errorMessages.size(); i++)
|
||||||
{
|
{
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
#include <octave/oct.h>
|
#include <octave/oct.h>
|
||||||
|
|
||||||
#include "riSettings.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)
|
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;
|
dv(3) = 3;
|
||||||
cellCenterValues.resize(dv);
|
cellCenterValues.resize(dv);
|
||||||
|
|
||||||
|
|
||||||
double* internalMatrixData = cellCenterValues.fortran_vec();
|
double* internalMatrixData = cellCenterValues.fortran_vec();
|
||||||
QStringList errorMessages;
|
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++)
|
for (int i = 0; i < errorMessages.size(); i++)
|
||||||
{
|
{
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
#include <octave/oct.h>
|
#include <octave/oct.h>
|
||||||
|
|
||||||
#include "riSettings.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();
|
double* internalMatrixData = cellCornerValues.fortran_vec();
|
||||||
QStringList errorMessages;
|
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++)
|
for (int i = 0; i < errorMessages.size(); i++)
|
||||||
{
|
{
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
#include <octave/oct-map.h>
|
#include <octave/oct-map.h>
|
||||||
|
|
||||||
#include "riSettings.h"
|
#include "riSettings.h"
|
||||||
#include "riSocketTools.h"
|
|
||||||
|
|
||||||
void getCurrentCase(qint64& caseId, QString& caseName, QString& caseType, qint64& caseGroupId, const QString &hostName, quint16 port)
|
void getCurrentCase(qint64& caseId, QString& caseName, QString& caseType, qint64& caseGroupId, const QString &hostName, quint16 port)
|
||||||
{
|
{
|
||||||
|
@ -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;
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user