Moved socket max byte count to riSettings

Added header files to cmake
This commit is contained in:
Magne Sjaastad 2014-04-03 08:16:15 +02:00
parent 1fd4c56a46
commit 414384804e
3 changed files with 42 additions and 3 deletions

View File

@ -141,7 +141,10 @@ if (RESINSIGHT_OCTAVE_PLUGIN_QMAKE AND RESINSIGHT_OCTAVE_PLUGIN_MKOCTFILE)
"${CMAKE_CURRENT_BINARY_DIR}/riGetWellNames.oct"
"${CMAKE_CURRENT_BINARY_DIR}/riGetWellStatus.oct"
"${CMAKE_CURRENT_BINARY_DIR}/riGetWellCells.oct"
SOURCES ${CPP_SOURCES}
SOURCES
${CPP_SOURCES}
riSocketTools.h
riSettings.h
)

View File

@ -24,6 +24,8 @@ namespace riOctavePlugin
const int shortTimeOutMilliSecs = 5000;
const int longTimeOutMilliSecs = 6000000;
const int socketMaxByteCount = 100000;
// Octave data structure : CaseInfo
char caseInfo_CaseId[] = "CaseId";
char caseInfo_CaseName[] = "CaseName";

View File

@ -7,7 +7,7 @@ bool readBlockData(QTcpSocket& socket, char* data, quint64 bytesToRead, QStringL
quint64 bytesRead = 0;
int blockCount = 0;
quint64 maxBlockSize = 100000;
quint64 maxBlockSize = riOctavePlugin::socketMaxByteCount;
while (bytesRead < bytesToRead)
{
@ -18,7 +18,7 @@ bool readBlockData(QTcpSocket& socket, char* data, quint64 bytesToRead, QStringL
qint64 actuallyBytesRead = socket.read(data + bytesRead, byteCountToRead);
if (actuallyBytesRead < 0)
{
errorMessages.push_back("Error detected when writing data, error string from socket");
errorMessages.push_back("Error detected when reading data, error string from socket :");
errorMessages.push_back(socket.errorString());
return false;
@ -41,6 +41,40 @@ bool readBlockData(QTcpSocket& socket, char* data, quint64 bytesToRead, QStringL
}
}
}
octave_stdout << "Bytes read " << bytesToRead << std::endl;
return true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool writeBlockData(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;
}