diff --git a/ApplicationCode/GrpcInterface/RiaGrpcCaseService.cpp b/ApplicationCode/GrpcInterface/RiaGrpcCaseService.cpp index 92f32093ae..c2a31471b5 100644 --- a/ApplicationCode/GrpcInterface/RiaGrpcCaseService.cpp +++ b/ApplicationCode/GrpcInterface/RiaGrpcCaseService.cpp @@ -189,10 +189,13 @@ const std::vector& RiaActiveCellInfoStateHandler::reservoirCells() cons //-------------------------------------------------------------------------------------------------- grpc::Status RiaActiveCellInfoStateHandler::assignReply( rips::CellInfoArray* reply ) { - const size_t packageSize = RiaGrpcServiceInterface::numberOfMessagesForByteCount( sizeof( rips::CellInfoArray ) ); - size_t packageIndex = 0u; + const size_t packageSize = RiaGrpcServiceInterface::numberOfDataUnitsInPackage( sizeof( rips::CellInfo ) ); + size_t indexInPackage = 0u; reply->mutable_data()->Reserve( (int)packageSize ); - for ( ; packageIndex < packageSize && m_currentCellIdx < m_activeCellInfo->reservoirCellCount(); ++packageIndex ) + + // Stream until you've reached the package size or total cell count. Whatever comes first. + // If you've reached the package size you'll come back for another round. + for ( ; indexInPackage < packageSize && m_currentCellIdx < m_activeCellInfo->reservoirCellCount(); ++indexInPackage ) { rips::CellInfo singleCellInfo; grpc::Status singleCellInfoStatus = assignNextActiveCellInfoData( &singleCellInfo ); @@ -206,7 +209,7 @@ grpc::Status RiaActiveCellInfoStateHandler::assignReply( rips::CellInfoArray* re break; } } - if ( packageIndex > 0u ) + if ( indexInPackage > 0u ) { return Status::OK; } diff --git a/ApplicationCode/GrpcInterface/RiaGrpcPropertiesService.cpp b/ApplicationCode/GrpcInterface/RiaGrpcPropertiesService.cpp index eaca842a6c..f615d265c1 100644 --- a/ApplicationCode/GrpcInterface/RiaGrpcPropertiesService.cpp +++ b/ApplicationCode/GrpcInterface/RiaGrpcPropertiesService.cpp @@ -142,14 +142,18 @@ public: //-------------------------------------------------------------------------------------------------- Status assignStreamReply( PropertyChunk* reply ) { - const size_t packageSize = RiaGrpcServiceInterface::numberOfMessagesForByteCount( sizeof( rips::PropertyChunk ) ); - size_t packageIndex = 0u; + // How many data units will fit into one stream package? + const size_t packageSize = RiaGrpcServiceInterface::numberOfDataUnitsInPackage( sizeof( double ) ); + size_t indexInPackage = 0u; reply->mutable_values()->Reserve( (int)packageSize ); - for ( ; packageIndex < packageSize && m_streamedValueCount < m_cellCount; ++packageIndex, ++m_streamedValueCount ) + + // Stream until you've reached the package size or total cell count. Whatever comes first. + // If you've reached the package size you'll come back for another round. + for ( ; indexInPackage < packageSize && m_streamedValueCount < m_cellCount; ++indexInPackage, ++m_streamedValueCount ) { reply->add_values( cellResult( m_streamedValueCount ) ); } - if ( packageIndex > 0u ) + if ( indexInPackage > 0u ) { return grpc::Status::OK; } @@ -274,12 +278,6 @@ protected: size_t timeStepIndex, RigEclipseResultAddress resVarAddr ) override { - auto resultValues = caseData->results( porosityModel )->modifiableCellScalarResult( resVarAddr, timeStepIndex ); - if ( resultValues->empty() ) - { - resultValues->resize( caseData->grid( gridIndex )->cellCount() ); - } - m_resultAccessor = RigResultAccessorFactory::createFromResultAddress( caseData, gridIndex, porosityModel, timeStepIndex, resVarAddr ); m_resultModifier = diff --git a/ApplicationCode/GrpcInterface/RiaGrpcServiceInterface.cpp b/ApplicationCode/GrpcInterface/RiaGrpcServiceInterface.cpp index 302ec2d227..53f1832d14 100644 --- a/ApplicationCode/GrpcInterface/RiaGrpcServiceInterface.cpp +++ b/ApplicationCode/GrpcInterface/RiaGrpcServiceInterface.cpp @@ -53,14 +53,13 @@ RimCase* RiaGrpcServiceInterface::findCase( int caseId ) } //-------------------------------------------------------------------------------------------------- -/// Find the number of messages that will fit in the given bytes. -/// The default argument is meant to be a sensible size for GRPC. +/// Find the number of data items that will fit in the given bytes. +/// The default argument for numBytesWantedInPackage is meant to be a sensible size for GRPC. //-------------------------------------------------------------------------------------------------- -size_t RiaGrpcServiceInterface::numberOfMessagesForByteCount( size_t messageSize, - size_t numBytesWantedInPackage /*= 64 * 1024u*/ ) +size_t RiaGrpcServiceInterface::numberOfDataUnitsInPackage( size_t dataUnitSize, size_t packageByteCount /*= 64 * 1024u*/ ) { - size_t messageCount = numBytesWantedInPackage / messageSize; - return messageCount; + size_t dataUnitCount = packageByteCount / dataUnitSize; + return dataUnitCount; } //-------------------------------------------------------------------------------------------------- @@ -137,13 +136,17 @@ void RiaGrpcServiceInterface::copyPdmObjectFromRipsToCaf( const rips::PdmObject* auto pdmValueField = dynamic_cast( field ); if ( pdmValueField ) { - QString keyword = pdmValueField->keyword(); - QString value = QString::fromStdString( parametersMap[keyword.toStdString()] ); - - QVariant oldValue, newValue; - if ( assignFieldValue( value, pdmValueField, &oldValue, &newValue ) ) + auto ricfHandle = pdmValueField->template capability(); + if ( ricfHandle ) { - destination->uiCapability()->fieldChangedByUi( field, oldValue, newValue ); + QString keyword = pdmValueField->keyword(); + QString value = QString::fromStdString( parametersMap[keyword.toStdString()] ); + + QVariant oldValue, newValue; + if ( assignFieldValue( value, pdmValueField, &oldValue, &newValue ) ) + { + destination->uiCapability()->fieldChangedByUi( field, oldValue, newValue ); + } } } } diff --git a/ApplicationCode/GrpcInterface/RiaGrpcServiceInterface.h b/ApplicationCode/GrpcInterface/RiaGrpcServiceInterface.h index 50b4f04501..9fab7c6b9b 100644 --- a/ApplicationCode/GrpcInterface/RiaGrpcServiceInterface.h +++ b/ApplicationCode/GrpcInterface/RiaGrpcServiceInterface.h @@ -52,7 +52,7 @@ public: virtual std::vector createCallbacks() = 0; virtual ~RiaGrpcServiceInterface() = default; static RimCase* findCase( int caseId ); - static size_t numberOfMessagesForByteCount( size_t messageSize, size_t byteCount = 64 * 1024u ); + static size_t numberOfDataUnitsInPackage( size_t dataUnitSize, size_t packageByteCount = 64 * 1024u ); static void copyPdmObjectFromCafToRips( const caf::PdmObjectHandle* source, rips::PdmObject* destination ); static void copyPdmObjectFromRipsToCaf( const rips::PdmObject* source, caf::PdmObjectHandle* destination );