From 1cfdb0ddb19bb7a0193556f697736aa8c322e71a Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 28 May 2013 09:20:09 +0200 Subject: [PATCH] Write all double values in one go. Fixed argument parsing. p4#: 21746 --- .../RiaPropertyDataCommands.cpp | 69 +++++++++++-------- OctavePlugin/riGetGridProperty.cpp | 8 +-- 2 files changed, 44 insertions(+), 33 deletions(-) diff --git a/ApplicationCode/SocketInterface/RiaPropertyDataCommands.cpp b/ApplicationCode/SocketInterface/RiaPropertyDataCommands.cpp index cdb9972f68..c688a88f7b 100644 --- a/ApplicationCode/SocketInterface/RiaPropertyDataCommands.cpp +++ b/ApplicationCode/SocketInterface/RiaPropertyDataCommands.cpp @@ -20,11 +20,25 @@ #include "RiaSocketServer.h" #include "RiaSocketTools.h" -#include "RimCase.h" +#include "RiuMainWindow.h" + #include "RigCaseData.h" #include "RigCaseCellResultsData.h" #include "RimReservoirCellResultsCacher.h" +#include "RimCase.h" +#include "RimInputCase.h" +#include "RimInputPropertyCollection.h" +#include "RimUiTreeModelPdm.h" +#include "RimReservoirView.h" +#include "RimResultSlot.h" +#include "RimCellEdgeResultSlot.h" +#include "RimCellRangeFilterCollection.h" +#include "RimCellPropertyFilterCollection.h" +#include "RimWellCollection.h" +#include "Rim3dOverlayInfoConfig.h" + +#include //-------------------------------------------------------------------------------------------------- @@ -189,13 +203,20 @@ public: virtual bool interpretCommand(RiaSocketServer* server, const QList& args, QDataStream& socketStream) { - - RimCase* rimCase = RiaSocketTools::findCaseFromArgs(server, args); - - int gridIdx = args[2].toInt(); - - QString propertyName = args[3]; + int caseId = args[1].toInt(); + int gridIdx = args[2].toInt(); + QString propertyName = args[3]; QString porosityModelName = args[4]; + + RimCase*rimCase = server->findReservoir(caseId); + if (rimCase == NULL) + { + server->errorMessageDialog()->showMessage(RiaSocketServer::tr("ResInsight SocketServer: \n") + RiaSocketServer::tr("Could not find the case with ID: \"%1\"").arg(caseId)); + + // No data available + socketStream << (quint64)0 << (quint64)0 << (quint64)0 << (quint64)0 ; + return true; + } RifReaderInterface::PorosityModelResultType porosityModelEnum = RifReaderInterface::MATRIX_RESULTS; if (porosityModelName == "Fracture") @@ -237,11 +258,11 @@ public: return true; } - // Create a list of all the requested timesteps + // Create a list of all the requested time steps std::vector requestedTimesteps; - if (args.size() <= 4) + if (args.size() <= 5) { // Select all for (size_t tsIdx = 0; tsIdx < scalarResultFrames->size(); ++tsIdx) @@ -252,7 +273,7 @@ public: else { bool timeStepReadError = false; - for (int argIdx = 4; argIdx < args.size(); ++argIdx) + for (int argIdx = 5; argIdx < args.size(); ++argIdx) { bool conversionOk = false; int tsIdx = args[argIdx].toInt(&conversionOk); @@ -287,11 +308,15 @@ public: socketStream << cellCountJ; socketStream << cellCountK; - // Write timestep count + // Write time step count quint64 timestepCount = (quint64)requestedTimesteps.size(); socketStream << timestepCount; + size_t doubleValueCount = cellCountI * cellCountJ * cellCountK * timestepCount * sizeof(double); + std::vector values(doubleValueCount); + size_t valueIdx = 0; + for (size_t tsIdx = 0; tsIdx < timestepCount; tsIdx++) { for (size_t k = 0; k < cellCountK; k++) @@ -307,17 +332,19 @@ public: if (resultIdx < scalarResultFrames->at(requestedTimesteps[tsIdx]).size()) { - socketStream << scalarResultFrames->at(requestedTimesteps[tsIdx])[resultIdx]; + values[valueIdx++] = scalarResultFrames->at(requestedTimesteps[tsIdx])[resultIdx]; } else { - socketStream << HUGE_VAL; + values[valueIdx++] = HUGE_VAL; } } } } } + server->currentClient()->write((const char *)values.data(), doubleValueCount); + return true; } }; @@ -327,27 +354,11 @@ static bool RiaGetGridProperty_init = RiaSocketCommandFactory::instance()->regis -#include -#include "RiuMainWindow.h" -#include "RimInputCase.h" -#include "RimInputPropertyCollection.h" - -#include "RimUiTreeModelPdm.h" - - -#include "RimReservoirView.h" -#include "RimResultSlot.h" -#include "RimCellEdgeResultSlot.h" -#include "RimCellRangeFilterCollection.h" -#include "RimCellPropertyFilterCollection.h" -#include "RimWellCollection.h" -#include "Rim3dOverlayInfoConfig.h" //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- - class RiaSetActiveCellProperty: public RiaSocketCommand { public: diff --git a/OctavePlugin/riGetGridProperty.cpp b/OctavePlugin/riGetGridProperty.cpp index 1a00d5e78a..a3d0219fec 100644 --- a/OctavePlugin/riGetGridProperty.cpp +++ b/OctavePlugin/riGetGridProperty.cpp @@ -122,10 +122,10 @@ DEFUN_DLD (riGetGridProperty, args, nargout, "\n" "Matrix[numI][numJ][numK][numTimestepsRequested] riGetGridProperty([CaseId], GridIndex , PropertyName, [RequestedTimeSteps], [PorosityModel = \"Matrix\"|\"Fracture\"])" "\n" - "This function returns a matrix of the requested property data for all the grid cells in the requested grid for each requested time step." - "Grids are indexed from 0 (main grid) to max number of LGR's" - "If the CaseId is not defined, ResInsight’s Current Case is used." - "The RequestedTimeSteps must contain a list of indices to the requested time steps. If not defined, all the time steps are returned" + "This function returns a matrix of the requested property data for all the grid cells in the requested grid for each requested time step.\n" + "Grids are indexed from 0 (main grid) to max number of LGR's.\n" + "If the CaseId is not defined, ResInsight’s Current Case is used.\n" + "The RequestedTimeSteps must contain a list of indices to the requested time steps. If not defined, all the time steps are returned.\n" ) { if (nargout < 1)