diff --git a/ApplicationCode/CMakeLists.txt b/ApplicationCode/CMakeLists.txt index 7b13bdf5f1..2daa688287 100644 --- a/ApplicationCode/CMakeLists.txt +++ b/ApplicationCode/CMakeLists.txt @@ -23,9 +23,6 @@ endif(Qt5Core_FOUND) CONFIGURE_FILE( ${CMAKE_SOURCE_DIR}/ApplicationCode/Adm/RiaVersionInfo.h.cmake ${CMAKE_BINARY_DIR}/Generated/RiaVersionInfo.h ) -CONFIGURE_FILE( ${CMAKE_SOURCE_DIR}/ApplicationCode/Adm/RiaVersionInfo.py.cmake - ${CMAKE_SOURCE_DIR}/Python/generated/RiaVersionInfo.py -) if (MSVC AND (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 19.11)) # VS 2017 : Disable warnings from from gtest code, using deprecated code related to TR1 diff --git a/ApplicationCode/GrpcInterface/CMakeLists.cmake b/ApplicationCode/GrpcInterface/CMakeLists.cmake index f3e6e911b8..ccb0d89738 100644 --- a/ApplicationCode/GrpcInterface/CMakeLists.cmake +++ b/ApplicationCode/GrpcInterface/CMakeLists.cmake @@ -79,7 +79,7 @@ set(PROTO_FILES "Properties" ) -set(GRPC_PYTHON_SOURCE_PATH "${CMAKE_SOURCE_DIR}/Python") +set(GRPC_PYTHON_SOURCE_PATH "${CMAKE_CURRENT_LIST_DIR}/Python") set(GRPC_PYTHON_DEST_PATH "${CMAKE_BINARY_DIR}/Python") foreach(proto_file ${PROTO_FILES}) @@ -150,7 +150,8 @@ if (PYTHON_EXECUTABLE AND EXISTS ${PYTHON_EXECUTABLE}) "examples/ResultValues.py" "examples/SelectedCases.py" "examples/AllCases.py" - "examples/SetResultValues.py" + "examples/SetActiveCellProperties.py" + "examples/SetGridProperties.py" "tests/test_sample.py" ) @@ -158,7 +159,7 @@ if (PYTHON_EXECUTABLE AND EXISTS ${PYTHON_EXECUTABLE}) list(APPEND GRPC_PYTHON_SOURCES_FULL_PATH "${GRPC_PYTHON_SOURCE_PATH}/${PYTHON_SCRIPT}") endforeach() if (MSVC) - source_group(TREE ${GRPC_PYTHON_SOURCE_PATH} FILES ${GRPC_PYTHON_SOURCES_FULL_PATH} PREFIX "Python") + source_group(TREE ${GRPC_PYTHON_SOURCE_PATH} FILES ${GRPC_PYTHON_SOURCES_FULL_PATH} PREFIX "GrpcInterface\\Python") endif(MSVC) endif(PYTHON_EXECUTABLE AND EXISTS ${PYTHON_EXECUTABLE}) @@ -166,5 +167,9 @@ endif(PYTHON_EXECUTABLE AND EXISTS ${PYTHON_EXECUTABLE}) list ( APPEND GRPC_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES}) list ( APPEND GRPC_CPP_SOURCES ${SOURCE_GROUP_SOURCE_FILES}) +CONFIGURE_FILE( ${CMAKE_SOURCE_DIR}/ApplicationCode/Adm/RiaVersionInfo.py.cmake + ${GRPC_PYTHON_SOURCE_PATH}/generated/RiaVersionInfo.py +) + source_group( "GrpcInterface" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CMAKE_CURRENT_LIST_DIR}/CMakeLists.cmake ) source_group( "GrpcInterface\\GrpcProtos" FILES ${GRPC_PROTO_FILES_FULL_PATH} ) \ No newline at end of file diff --git a/Python/.gitignore b/ApplicationCode/GrpcInterface/Python/.gitignore similarity index 100% rename from Python/.gitignore rename to ApplicationCode/GrpcInterface/Python/.gitignore diff --git a/Python/api/ResInsight.py b/ApplicationCode/GrpcInterface/Python/api/ResInsight.py similarity index 90% rename from Python/api/ResInsight.py rename to ApplicationCode/GrpcInterface/Python/api/ResInsight.py index 5ae13daec2..7e8485d093 100644 --- a/Python/api/ResInsight.py +++ b/ApplicationCode/GrpcInterface/Python/api/ResInsight.py @@ -131,20 +131,16 @@ class Properties: chunk = Properties_pb2.ResultRequestChunk() if index is -1: chunk.params.CopyFrom(parameters) - print("Added parameters") index += 1; else: actualChunkSize = min(len(array) - index + 1, chunkSize) chunk.values.CopyFrom(Properties_pb2.ResultArray(values = array[index:index+actualChunkSize])) - print("Added values") index += actualChunkSize - print(index) yield chunk # Final empty message to signal completion chunk = Properties_pb2.ResultRequestChunk() yield chunk - print("finished") def availableProperties(self, caseId, propertyType, porosityModel = 'MATRIX_MODEL'): propertyTypeEnum = Properties_pb2.PropertyType.Value(propertyType) @@ -175,7 +171,6 @@ class Properties: def setActiveCellResults(self, values, caseId, propertyType, propertyName, timeStep, gridIndex = 0, porosityModel = 'MATRIX_MODEL'): propertyTypeEnum = Properties_pb2.PropertyType.Value(propertyType) porosityModelEnum = GridInfo_pb2.PorosityModelType.Value(porosityModel) - print (propertyName) request = Properties_pb2.ResultRequest(request_case = CaseInfo_pb2.Case(id=caseId), property_type = propertyTypeEnum, property_name = propertyName, @@ -184,7 +179,6 @@ class Properties: porosity_model = porosityModelEnum) try: request_iterator = self.generateResultRequestArrays(values, request) - print("Starting to send data") self.properties.SetActiveCellResults(request_iterator) except grpc.RpcError as e: if e.code() == grpc.StatusCode.NOT_FOUND: @@ -192,6 +186,24 @@ class Properties: else: print("Other error", e) + def setGridResults(self, values, caseId, propertyType, propertyName, timeStep, gridIndex = 0, porosityModel = 'MATRIX_MODEL'): + propertyTypeEnum = Properties_pb2.PropertyType.Value(propertyType) + porosityModelEnum = GridInfo_pb2.PorosityModelType.Value(porosityModel) + request = Properties_pb2.ResultRequest(request_case = CaseInfo_pb2.Case(id=caseId), + property_type = propertyTypeEnum, + property_name = propertyName, + time_step = timeStep, + grid_index = gridIndex, + porosity_model = porosityModelEnum) + try: + request_iterator = self.generateResultRequestArrays(values, request) + self.properties.SetGridResults(request_iterator) + except grpc.RpcError as e: + if e.code() == grpc.StatusCode.NOT_FOUND: + print("Command not found") + else: + print("Other error", e) + class Instance: @staticmethod def is_port_in_use(port): diff --git a/Python/api/__init__.py b/ApplicationCode/GrpcInterface/Python/api/__init__.py similarity index 100% rename from Python/api/__init__.py rename to ApplicationCode/GrpcInterface/Python/api/__init__.py diff --git a/Python/examples/AllCases.py b/ApplicationCode/GrpcInterface/Python/examples/AllCases.py similarity index 100% rename from Python/examples/AllCases.py rename to ApplicationCode/GrpcInterface/Python/examples/AllCases.py diff --git a/Python/examples/CommandExample.py b/ApplicationCode/GrpcInterface/Python/examples/CommandExample.py similarity index 100% rename from Python/examples/CommandExample.py rename to ApplicationCode/GrpcInterface/Python/examples/CommandExample.py diff --git a/Python/examples/GridInfoStreamingExample.py b/ApplicationCode/GrpcInterface/Python/examples/GridInfoStreamingExample.py similarity index 100% rename from Python/examples/GridInfoStreamingExample.py rename to ApplicationCode/GrpcInterface/Python/examples/GridInfoStreamingExample.py diff --git a/Python/examples/ResultValues.py b/ApplicationCode/GrpcInterface/Python/examples/ResultValues.py similarity index 100% rename from Python/examples/ResultValues.py rename to ApplicationCode/GrpcInterface/Python/examples/ResultValues.py diff --git a/Python/examples/SelectedCases.py b/ApplicationCode/GrpcInterface/Python/examples/SelectedCases.py similarity index 100% rename from Python/examples/SelectedCases.py rename to ApplicationCode/GrpcInterface/Python/examples/SelectedCases.py diff --git a/Python/examples/SetResultValues.py b/ApplicationCode/GrpcInterface/Python/examples/SetActiveCellProperties.py similarity index 100% rename from Python/examples/SetResultValues.py rename to ApplicationCode/GrpcInterface/Python/examples/SetActiveCellProperties.py diff --git a/ApplicationCode/GrpcInterface/Python/examples/SetGridProperties.py b/ApplicationCode/GrpcInterface/Python/examples/SetGridProperties.py new file mode 100644 index 0000000000..bf15573601 --- /dev/null +++ b/ApplicationCode/GrpcInterface/Python/examples/SetGridProperties.py @@ -0,0 +1,16 @@ +import sys +import os +sys.path.insert(1, os.path.join(sys.path[0], '../api')) +import ResInsight + +resInsight = ResInsight.Instance.find() + +totalCellCount = resInsight.gridInfo.cellCount(caseId=0).reservoir_cell_count + +values = [] +for i in range(0, totalCellCount): + values.append(i % 2 * 0.75); + +print("Applying values to full grid") +resInsight.properties.setGridResults(values, 0, 'DYNAMIC_NATIVE', 'SOIL', 0) + diff --git a/Python/tests/test_sample.py b/ApplicationCode/GrpcInterface/Python/tests/test_sample.py similarity index 100% rename from Python/tests/test_sample.py rename to ApplicationCode/GrpcInterface/Python/tests/test_sample.py