2019-05-21 06:40:42 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Copyright (C) 2019- Equinor ASA
|
|
|
|
//
|
|
|
|
// ResInsight is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
|
|
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
// FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
//
|
|
|
|
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
|
|
|
// for more details.
|
|
|
|
//
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////
|
|
|
|
#include "RiaGrpcPropertiesService.h"
|
|
|
|
|
|
|
|
#include "RiaGrpcCallbacks.h"
|
2019-06-03 07:33:16 -05:00
|
|
|
#include "RiaGrpcCaseService.h"
|
2019-05-21 06:40:42 -05:00
|
|
|
|
2019-05-21 09:33:41 -05:00
|
|
|
#include "RigActiveCellInfo.h"
|
|
|
|
#include "RigActiveCellsResultAccessor.h"
|
|
|
|
#include "RigAllGridCellsResultAccessor.h"
|
2019-05-21 06:40:42 -05:00
|
|
|
#include "RigCaseCellResultsData.h"
|
|
|
|
#include "RigEclipseCaseData.h"
|
|
|
|
#include "RigEclipseResultAddress.h"
|
2019-05-30 11:52:16 -05:00
|
|
|
#include "RigEclipseResultInfo.h"
|
2019-05-21 09:33:41 -05:00
|
|
|
#include "RigMainGrid.h"
|
|
|
|
#include "RigResultAccessor.h"
|
|
|
|
#include "RigResultAccessorFactory.h"
|
2019-05-22 08:30:09 -05:00
|
|
|
#include "RigResultModifier.h"
|
|
|
|
#include "RigResultModifierFactory.h"
|
2019-05-21 06:40:42 -05:00
|
|
|
|
2019-05-22 08:30:09 -05:00
|
|
|
#include "Rim3dView.h"
|
2019-05-21 06:40:42 -05:00
|
|
|
#include "RimEclipseCase.h"
|
|
|
|
|
2019-10-08 03:01:38 -05:00
|
|
|
#include <algorithm>
|
|
|
|
|
2019-05-21 06:40:42 -05:00
|
|
|
using namespace rips;
|
|
|
|
|
2019-08-13 06:15:58 -05:00
|
|
|
#define NUM_CONCURRENT_CLIENT_TO_SERVER_STREAMS 10
|
2019-06-04 03:33:11 -05:00
|
|
|
|
2019-05-21 06:40:42 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-05-21 09:33:41 -05:00
|
|
|
/// Abstract handler base class for streaming cell results to client
|
2019-05-21 06:40:42 -05:00
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
2019-05-21 09:33:41 -05:00
|
|
|
class RiaCellResultsStateHandler
|
2019-05-21 06:40:42 -05:00
|
|
|
{
|
2019-05-21 09:33:41 -05:00
|
|
|
typedef grpc::Status Status;
|
|
|
|
|
|
|
|
public:
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
RiaCellResultsStateHandler( bool clientStreamer = false )
|
|
|
|
: m_eclipseCase( nullptr )
|
|
|
|
, m_porosityModel( RiaDefines::MATRIX_MODEL )
|
|
|
|
, m_streamedValueCount( 0u )
|
|
|
|
, m_cellCount( 0u )
|
|
|
|
, m_clientStreamer( clientStreamer )
|
2019-05-21 06:40:42 -05:00
|
|
|
{
|
2019-05-21 09:33:41 -05:00
|
|
|
}
|
2019-05-21 06:40:42 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-08-13 06:15:58 -05:00
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2020-02-12 04:13:38 -06:00
|
|
|
size_t cellCount() const { return m_cellCount; }
|
2019-08-13 06:15:58 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-08-13 06:15:58 -05:00
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2020-02-12 04:13:38 -06:00
|
|
|
size_t streamedValueCount() const { return m_streamedValueCount; }
|
2019-08-13 06:15:58 -05:00
|
|
|
|
2019-05-21 09:33:41 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
Status init( const PropertyRequest* request )
|
2019-05-21 09:33:41 -05:00
|
|
|
{
|
2019-06-03 07:33:16 -05:00
|
|
|
int caseId = request->case_request().id();
|
2019-09-06 03:40:57 -05:00
|
|
|
m_eclipseCase = dynamic_cast<RimEclipseCase*>( RiaGrpcServiceInterface::findCase( caseId ) );
|
2019-05-22 08:30:09 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( m_eclipseCase )
|
2019-05-21 06:40:42 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
m_porosityModel = static_cast<RiaDefines::PorosityModelType>( request->porosity_model() );
|
2019-09-02 08:12:07 -05:00
|
|
|
auto caseData = m_eclipseCase->eclipseCaseData();
|
2019-09-06 03:40:57 -05:00
|
|
|
auto resultData = caseData->results( m_porosityModel );
|
|
|
|
auto resultType = static_cast<RiaDefines::ResultCatType>( request->property_type() );
|
|
|
|
size_t timeStep = static_cast<size_t>( request->time_step() );
|
2019-09-02 08:12:07 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
m_resultAddress = RigEclipseResultAddress( resultType, QString::fromStdString( request->property_name() ) );
|
2019-05-21 09:33:41 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( resultData->ensureKnownResultLoaded( m_resultAddress ) )
|
2019-05-21 06:40:42 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( timeStep < resultData->timeStepCount( m_resultAddress ) )
|
2019-05-21 09:33:41 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
initResultAccess( caseData, request->grid_index(), m_porosityModel, timeStep, m_resultAddress );
|
2019-05-21 09:33:41 -05:00
|
|
|
return grpc::Status::OK;
|
|
|
|
}
|
2019-09-06 03:40:57 -05:00
|
|
|
return grpc::Status( grpc::NOT_FOUND, "No such time step" );
|
2019-05-21 06:40:42 -05:00
|
|
|
}
|
2019-09-06 03:40:57 -05:00
|
|
|
else if ( m_clientStreamer )
|
2019-05-30 11:52:16 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
resultData->createResultEntry( m_resultAddress, true );
|
2019-05-30 11:52:16 -05:00
|
|
|
RigEclipseResultAddress addrToMaxTimeStepCountResult;
|
|
|
|
|
2020-02-12 04:43:15 -06:00
|
|
|
size_t timeStepCount = std::max( (size_t)1, resultData->maxTimeStepCount( &addrToMaxTimeStepCountResult ) );
|
2019-10-08 03:01:38 -05:00
|
|
|
|
2020-02-12 04:43:15 -06:00
|
|
|
const std::vector<RigEclipseTimeStepInfo> timeStepInfos =
|
|
|
|
resultData->timeStepInfos( addrToMaxTimeStepCountResult );
|
2019-09-06 03:40:57 -05:00
|
|
|
resultData->setTimeStepInfos( m_resultAddress, timeStepInfos );
|
|
|
|
auto scalarResultFrames = resultData->modifiableCellScalarResultTimesteps( m_resultAddress );
|
2019-10-08 03:01:38 -05:00
|
|
|
scalarResultFrames->resize( timeStepCount );
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( timeStep < resultData->timeStepCount( m_resultAddress ) )
|
2019-05-30 11:52:16 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
initResultAccess( caseData, request->grid_index(), m_porosityModel, timeStep, m_resultAddress );
|
2019-05-30 11:52:16 -05:00
|
|
|
return grpc::Status::OK;
|
|
|
|
}
|
2019-09-06 03:40:57 -05:00
|
|
|
return grpc::Status( grpc::NOT_FOUND, "No such time step" );
|
2019-05-30 11:52:16 -05:00
|
|
|
}
|
2019-09-06 03:40:57 -05:00
|
|
|
return grpc::Status( grpc::NOT_FOUND, "No such result" );
|
2019-05-21 06:40:42 -05:00
|
|
|
}
|
2019-09-06 03:40:57 -05:00
|
|
|
return grpc::Status( grpc::NOT_FOUND, "Couldn't find an Eclipse case matching the case Id" );
|
2019-05-21 06:40:42 -05:00
|
|
|
}
|
|
|
|
|
2019-05-22 08:30:09 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
/// Client streamers need to be initialised with the encapsulated parameters
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
Status init( const PropertyInputChunk* chunk )
|
2019-05-22 08:30:09 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( chunk->has_params() )
|
2019-05-22 08:30:09 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
return init( &( chunk->params() ) );
|
2019-05-22 08:30:09 -05:00
|
|
|
}
|
2019-09-06 03:40:57 -05:00
|
|
|
return grpc::Status( grpc::INVALID_ARGUMENT, "Need to have PropertyRequest parameters in first message" );
|
2019-05-22 08:30:09 -05:00
|
|
|
}
|
|
|
|
|
2019-05-21 09:33:41 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
Status assignStreamReply( PropertyChunk* reply )
|
2019-05-21 06:40:42 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
const size_t packageSize = RiaGrpcServiceInterface::numberOfMessagesForByteCount( sizeof( rips::PropertyChunk ) );
|
2019-05-21 06:40:42 -05:00
|
|
|
size_t packageIndex = 0u;
|
2019-09-06 03:40:57 -05:00
|
|
|
reply->mutable_values()->Reserve( (int)packageSize );
|
|
|
|
for ( ; packageIndex < packageSize && m_streamedValueCount < m_cellCount; ++packageIndex, ++m_streamedValueCount )
|
2019-05-21 06:40:42 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
reply->add_values( cellResult( m_streamedValueCount ) );
|
2019-05-21 06:40:42 -05:00
|
|
|
}
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( packageIndex > 0u )
|
2019-05-21 06:40:42 -05:00
|
|
|
{
|
|
|
|
return grpc::Status::OK;
|
|
|
|
}
|
2019-09-06 03:40:57 -05:00
|
|
|
return grpc::Status( grpc::OUT_OF_RANGE,
|
|
|
|
"We've reached the end. This is not an error but means transmission is finished" );
|
2019-05-21 06:40:42 -05:00
|
|
|
}
|
2019-05-21 09:33:41 -05:00
|
|
|
|
2019-05-22 08:30:09 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
Status receiveStreamRequest( const PropertyInputChunk* request, ClientToServerStreamReply* reply )
|
2019-05-22 08:30:09 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( request->has_values() )
|
2019-05-22 08:30:09 -05:00
|
|
|
{
|
|
|
|
auto values = request->values().values();
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( !values.empty() )
|
|
|
|
{
|
|
|
|
size_t currentCellIdx = m_streamedValueCount;
|
|
|
|
m_streamedValueCount += values.size();
|
|
|
|
|
|
|
|
for ( int i = 0; i < values.size() && currentCellIdx < m_cellCount; ++i, ++currentCellIdx )
|
|
|
|
{
|
|
|
|
setCellResult( currentCellIdx, values[i] );
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( m_streamedValueCount > m_cellCount )
|
|
|
|
{
|
|
|
|
return grpc::Status( grpc::OUT_OF_RANGE, "Attempting to write out of bounds" );
|
|
|
|
}
|
|
|
|
reply->set_accepted_value_count( static_cast<int64_t>( currentCellIdx ) );
|
|
|
|
return Status::OK;
|
|
|
|
}
|
2019-05-22 08:30:09 -05:00
|
|
|
}
|
2019-08-13 06:15:58 -05:00
|
|
|
return Status::OK;
|
2019-05-22 08:30:09 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void finish()
|
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( m_eclipseCase )
|
2019-05-22 08:30:09 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
auto caseData = m_eclipseCase->eclipseCaseData();
|
|
|
|
auto resultData = caseData->results( m_porosityModel );
|
|
|
|
resultData->recalculateStatistics( m_resultAddress );
|
2019-08-13 06:15:58 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
for ( Rim3dView* view : m_eclipseCase->views() )
|
2019-06-09 08:35:31 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
view->setCurrentTimeStepAndUpdate( view->currentTimeStep() );
|
2019-06-09 08:35:31 -05:00
|
|
|
view->createDisplayModelAndRedraw();
|
|
|
|
}
|
2019-05-22 08:30:09 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-05-21 09:33:41 -05:00
|
|
|
protected:
|
2019-09-06 03:40:57 -05:00
|
|
|
virtual void initResultAccess( RigEclipseCaseData* caseData,
|
|
|
|
size_t gridIndex,
|
|
|
|
RiaDefines::PorosityModelType porosityModel,
|
|
|
|
size_t timeStepIndex,
|
|
|
|
RigEclipseResultAddress resVarAddr ) = 0;
|
|
|
|
virtual double cellResult( size_t currentCellIndex ) const = 0;
|
|
|
|
virtual void setCellResult( size_t currentCellIndex, double value ) = 0;
|
2019-05-21 09:33:41 -05:00
|
|
|
|
|
|
|
protected:
|
2019-09-02 08:12:07 -05:00
|
|
|
RimEclipseCase* m_eclipseCase;
|
|
|
|
RiaDefines::PorosityModelType m_porosityModel;
|
|
|
|
size_t m_streamedValueCount;
|
|
|
|
size_t m_cellCount;
|
|
|
|
bool m_clientStreamer;
|
|
|
|
RigEclipseResultAddress m_resultAddress;
|
2019-05-21 09:33:41 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
class RiaActiveCellResultsStateHandler : public RiaCellResultsStateHandler
|
|
|
|
{
|
2019-05-30 11:52:16 -05:00
|
|
|
public:
|
2019-09-06 03:40:57 -05:00
|
|
|
RiaActiveCellResultsStateHandler( bool clientStreamer = false )
|
|
|
|
: RiaCellResultsStateHandler( clientStreamer )
|
|
|
|
, m_resultValues( nullptr )
|
2019-06-05 15:47:00 -05:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2019-05-21 09:33:41 -05:00
|
|
|
protected:
|
2019-09-06 03:40:57 -05:00
|
|
|
void initResultAccess( RigEclipseCaseData* caseData,
|
|
|
|
size_t gridIndex,
|
|
|
|
RiaDefines::PorosityModelType porosityModel,
|
|
|
|
size_t timeStepIndex,
|
|
|
|
RigEclipseResultAddress resVarAddr ) override
|
2019-05-21 09:33:41 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
auto activeCellInfo = caseData->activeCellInfo( porosityModel );
|
2019-10-08 03:01:38 -05:00
|
|
|
m_resultValues = caseData->results( porosityModel )->modifiableCellScalarResult( resVarAddr, timeStepIndex );
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( m_resultValues->empty() )
|
2019-05-30 11:52:16 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
m_resultValues->resize( activeCellInfo->reservoirCellResultCount() );
|
2019-05-30 11:52:16 -05:00
|
|
|
}
|
2019-09-06 03:40:57 -05:00
|
|
|
m_cellCount = activeCellInfo->reservoirActiveCellCount();
|
2019-05-21 09:33:41 -05:00
|
|
|
}
|
|
|
|
|
2020-02-12 04:13:38 -06:00
|
|
|
double cellResult( size_t currentCellIndex ) const override { return ( *m_resultValues )[currentCellIndex]; }
|
2019-05-21 09:33:41 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
void setCellResult( size_t currentCellIndex, double value ) override
|
2019-05-22 08:30:09 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
( *m_resultValues )[currentCellIndex] = value;
|
2019-05-22 08:30:09 -05:00
|
|
|
}
|
|
|
|
|
2019-05-21 09:33:41 -05:00
|
|
|
private:
|
2019-05-22 08:30:09 -05:00
|
|
|
std::vector<double>* m_resultValues;
|
2019-05-21 09:33:41 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
class RiaGridCellResultsStateHandler : public RiaCellResultsStateHandler
|
|
|
|
{
|
2019-05-30 11:52:16 -05:00
|
|
|
public:
|
2019-09-06 03:40:57 -05:00
|
|
|
RiaGridCellResultsStateHandler( bool clientStreamer = false )
|
|
|
|
: RiaCellResultsStateHandler( clientStreamer )
|
|
|
|
{
|
|
|
|
}
|
2019-05-30 11:52:16 -05:00
|
|
|
|
2019-05-21 09:33:41 -05:00
|
|
|
protected:
|
2019-09-06 03:40:57 -05:00
|
|
|
void initResultAccess( RigEclipseCaseData* caseData,
|
|
|
|
size_t gridIndex,
|
|
|
|
RiaDefines::PorosityModelType porosityModel,
|
|
|
|
size_t timeStepIndex,
|
|
|
|
RigEclipseResultAddress resVarAddr ) override
|
2019-05-21 09:33:41 -05:00
|
|
|
{
|
2020-02-13 06:52:01 -06:00
|
|
|
auto resultValues = caseData->results( porosityModel )->modifiableCellScalarResult( resVarAddr, timeStepIndex );
|
|
|
|
if ( resultValues->empty() )
|
|
|
|
{
|
|
|
|
resultValues->resize( caseData->grid( gridIndex )->cellCount() );
|
|
|
|
}
|
|
|
|
|
2020-02-12 04:43:15 -06:00
|
|
|
m_resultAccessor =
|
|
|
|
RigResultAccessorFactory::createFromResultAddress( caseData, gridIndex, porosityModel, timeStepIndex, resVarAddr );
|
|
|
|
m_resultModifier =
|
|
|
|
RigResultModifierFactory::createResultModifier( caseData, gridIndex, porosityModel, timeStepIndex, resVarAddr );
|
|
|
|
m_cellCount = caseData->grid( gridIndex )->cellCount();
|
2019-05-21 09:33:41 -05:00
|
|
|
}
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
double cellResult( size_t currentCellIndex ) const override
|
2019-05-21 09:33:41 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
return m_resultAccessor->cellScalar( currentCellIndex );
|
2019-05-21 09:33:41 -05:00
|
|
|
}
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
void setCellResult( size_t currentCellIndex, double value ) override
|
2019-05-22 08:30:09 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
return m_resultModifier->setCellScalar( currentCellIndex, value );
|
2019-05-22 08:30:09 -05:00
|
|
|
}
|
|
|
|
|
2019-05-21 09:33:41 -05:00
|
|
|
private:
|
|
|
|
cvf::ref<RigResultAccessor> m_resultAccessor;
|
2019-05-22 08:30:09 -05:00
|
|
|
cvf::ref<RigResultModifier> m_resultModifier;
|
2019-05-21 09:33:41 -05:00
|
|
|
};
|
2019-05-21 06:40:42 -05:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
grpc::Status RiaGrpcPropertiesService::GetAvailableProperties( grpc::ServerContext* context,
|
|
|
|
const AvailablePropertiesRequest* request,
|
|
|
|
AvailableProperties* reply )
|
2019-05-21 06:40:42 -05:00
|
|
|
{
|
2019-06-03 07:33:16 -05:00
|
|
|
int caseId = request->case_request().id();
|
2019-09-06 03:40:57 -05:00
|
|
|
RimEclipseCase* eclipseCase = dynamic_cast<RimEclipseCase*>( RiaGrpcServiceInterface::findCase( caseId ) );
|
|
|
|
if ( eclipseCase )
|
2019-05-21 06:40:42 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
auto porosityModel = static_cast<RiaDefines::PorosityModelType>( request->porosity_model() );
|
|
|
|
auto resultData = eclipseCase->eclipseCaseData()->results( porosityModel );
|
|
|
|
auto resultType = static_cast<RiaDefines::ResultCatType>( request->property_type() );
|
|
|
|
QStringList resultNames = resultData->resultNames( resultType );
|
|
|
|
if ( !resultNames.empty() )
|
2019-05-21 06:40:42 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
for ( QString resultName : resultNames )
|
2019-05-21 06:40:42 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
reply->add_property_names( resultName.toStdString() );
|
2019-05-21 06:40:42 -05:00
|
|
|
}
|
|
|
|
return grpc::Status::OK;
|
|
|
|
}
|
2019-09-06 03:40:57 -05:00
|
|
|
return grpc::Status( grpc::NOT_FOUND, "Could not find any results matching result type" );
|
2019-05-21 06:40:42 -05:00
|
|
|
}
|
2019-09-06 03:40:57 -05:00
|
|
|
return grpc::Status( grpc::NOT_FOUND, "No such case" );
|
2019-05-21 06:40:42 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
grpc::Status RiaGrpcPropertiesService::GetActiveCellProperty( grpc::ServerContext* context,
|
|
|
|
const PropertyRequest* request,
|
|
|
|
PropertyChunk* reply,
|
|
|
|
RiaActiveCellResultsStateHandler* stateHandler )
|
2019-05-21 09:33:41 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
return stateHandler->assignStreamReply( reply );
|
2019-05-21 09:33:41 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
grpc::Status RiaGrpcPropertiesService::GetGridProperty( grpc::ServerContext* context,
|
|
|
|
const rips::PropertyRequest* request,
|
|
|
|
rips::PropertyChunk* reply,
|
|
|
|
RiaGridCellResultsStateHandler* stateHandler )
|
2019-05-21 06:40:42 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
return stateHandler->assignStreamReply( reply );
|
2019-05-22 08:30:09 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
grpc::Status RiaGrpcPropertiesService::SetActiveCellProperty( grpc::ServerContext* context,
|
|
|
|
const rips::PropertyInputChunk* request,
|
|
|
|
rips::ClientToServerStreamReply* reply,
|
|
|
|
RiaActiveCellResultsStateHandler* stateHandler )
|
2019-05-22 08:30:09 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
return stateHandler->receiveStreamRequest( request, reply );
|
2019-05-21 06:40:42 -05:00
|
|
|
}
|
|
|
|
|
2019-05-22 12:58:12 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
grpc::Status RiaGrpcPropertiesService::SetGridProperty( grpc::ServerContext* context,
|
|
|
|
const rips::PropertyInputChunk* request,
|
|
|
|
rips::ClientToServerStreamReply* reply,
|
|
|
|
RiaGridCellResultsStateHandler* stateHandler )
|
2019-05-22 12:58:12 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
return stateHandler->receiveStreamRequest( request, reply );
|
2019-05-22 12:58:12 -05:00
|
|
|
}
|
2019-05-21 06:40:42 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-05-27 00:29:20 -05:00
|
|
|
std::vector<RiaGrpcCallbackInterface*> RiaGrpcPropertiesService::createCallbacks()
|
2019-05-21 06:40:42 -05:00
|
|
|
{
|
|
|
|
typedef RiaGrpcPropertiesService Self;
|
|
|
|
|
2019-06-04 03:33:11 -05:00
|
|
|
std::vector<RiaGrpcCallbackInterface*> callbacks;
|
2019-09-06 03:40:57 -05:00
|
|
|
callbacks =
|
|
|
|
{new RiaGrpcUnaryCallback<Self, AvailablePropertiesRequest, AvailableProperties>( this,
|
|
|
|
&Self::GetAvailableProperties,
|
|
|
|
&Self::RequestGetAvailableProperties ),
|
|
|
|
new RiaGrpcClientToServerStreamCallback<Self,
|
|
|
|
PropertyInputChunk,
|
|
|
|
ClientToServerStreamReply,
|
|
|
|
RiaActiveCellResultsStateHandler>( this,
|
|
|
|
&Self::SetActiveCellProperty,
|
|
|
|
&Self::RequestSetActiveCellProperty,
|
|
|
|
new RiaActiveCellResultsStateHandler(
|
|
|
|
true ) ),
|
|
|
|
new RiaGrpcClientToServerStreamCallback<Self,
|
|
|
|
PropertyInputChunk,
|
|
|
|
ClientToServerStreamReply,
|
|
|
|
RiaGridCellResultsStateHandler>( this,
|
|
|
|
&Self::SetGridProperty,
|
|
|
|
&Self::RequestSetGridProperty,
|
|
|
|
new RiaGridCellResultsStateHandler(
|
|
|
|
true ) )};
|
|
|
|
|
|
|
|
for ( int i = 0; i < NUM_CONCURRENT_CLIENT_TO_SERVER_STREAMS; ++i )
|
2019-06-04 03:33:11 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
callbacks.push_back(
|
|
|
|
new RiaGrpcServerToClientStreamCallback<Self,
|
|
|
|
PropertyRequest,
|
|
|
|
PropertyChunk,
|
|
|
|
RiaActiveCellResultsStateHandler>( this,
|
|
|
|
&Self::GetActiveCellProperty,
|
|
|
|
&Self::RequestGetActiveCellProperty,
|
|
|
|
new RiaActiveCellResultsStateHandler ) );
|
|
|
|
callbacks.push_back(
|
|
|
|
new RiaGrpcServerToClientStreamCallback<Self,
|
|
|
|
PropertyRequest,
|
|
|
|
PropertyChunk,
|
|
|
|
RiaGridCellResultsStateHandler>( this,
|
|
|
|
&Self::GetGridProperty,
|
|
|
|
&Self::RequestGetGridProperty,
|
|
|
|
new RiaGridCellResultsStateHandler ) );
|
2019-06-04 03:33:11 -05:00
|
|
|
}
|
|
|
|
return callbacks;
|
|
|
|
}
|
2019-05-22 12:58:12 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
static bool RiaGrpcPropertiesService_init = RiaGrpcServiceFactory::instance()->registerCreator<RiaGrpcPropertiesService>(
|
|
|
|
typeid( RiaGrpcPropertiesService ).hash_code() );
|