Skip to content

lulzbot3d/CuraEngineLE_gRPC_Definitions

Repository files navigation

gRPC Definitions for CuraEngineLE

Conan Badge

Size Badge License Badge

This repository contains the gRPC proto definitions for CuraEngineLE. These definitions are used to generate the gRPC code for the CuraEngineLE gRPC plugin system.

Overview

As part of the CuraEngineLE plugin system, the CuraEngineLE serves as gRPC client. The functionality of CuraEngineLE can be extended with CuraEngine plugins, which behaves as servers. The gRPC client/server uses the Protocol Buffers format. This repository contains the definitions for the gRPC server and client(s).

Usage

The gRPC definitions are available for the following languages:

Conan

Usage in conanfile.py

class CuraEngineLEPluginConan(ConanFile):
  ...

  def requirements(self):
    self.requires("asio-grpc/2.4.0")
    self.requires("curaenginele_grpc_definitions/(latest)@lulzbot/testing")
    ...

  def generate(self):
    tc = CMakeToolchain(self)
    cpp_info = self.dependencies["curaenginele_grpc_definitions"].cpp_info
    tc.variables["GRPC_IMPORT_DIRS"] = cpp_info.resdirs[0]
    tc.variables["GRPC_PROTOS"] = ";".join([str(p).replace("\\", "/") for p in Path(cpp_info.resdirs[0]).rglob("*.proto")])
    tc.generate()
    ...

Usage in CMakeLists.txt

...
find_package(asio-grpc REQUIRED)

asio_grpc_protobuf_generate(PROTOS "${GRPC_PROTOS}"
  IMPORT_DIRS ${GRPC_IMPORT_DIRS}
  OUT_VAR "ASIO_GRPC_PLUGIN_PROTO_SOURCES"
  OUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/generated"
  GENERATE_GRPC GENERATE_MOCK_CODE)

add_executable(engine_plugin_target_name ${PROTO_SRCS} ${ASIO_GRPC_PLUGIN_PROTO_SOURCES} main.cpp ...)

target_include_directories(engine_plugin_target_name
  PUBLIC
  ...
  PRIVATE
  ${CMAKE_CURRENT_BINARY_DIR}/generated
  )

target_link_libraries(simplify_boost_plugin PUBLIC asio-grpc::asio-grpc ...)
...
conan install . --build=missing --update

Python

pip install git+https://github.com/lulzbot3d/CuraEngineLE_gRPC_Definitions.git
import grpc

from CuraEngineGRPC.cura_pb2_grpc import CuraStub
import CuraEngineGRPC.cura_pb2 as cura_pb

....

Rust

Required dependencies before the gRPC definitions can be used are: protoc, protobuf.

Then add the following package to your Cargo.toml:

cargo add --git https://github.com/lulzbot3d/CuraEngineLE_gRPC_Definitions.git

About

Topics

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Contributors