question

Ryusuke T avatar image
2 Likes"
Ryusuke T asked William J commented

Does FlexSim support gRCP?

Hi,


I was asked by a customer if FlexSim supports gRCP.

Information on gRCP can be found below.

https://grpc.io/


Customers seem to be wondering if they can use gRCP to communicate with FlexSim via an external program.

Can you give me some information?


FlexSim 21.0.8
flexsim 21.0.8grcp
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Serge A avatar image
2 Likes"
Serge A answered Ryusuke T commented

I successfully used C++ gRPC API to create a FlexSim module for our client. While I can't disclose implementation details, here are some tips:

1. The easiest way to build and install grpc libs on Windows is to use vcpkg. I recommend pinning vcpkg version to one of their recent tags, this will help to re-create build environment without regenerating protocol files every time.

If you have already checked out vcpkg git repo, do something like this:

  1. git checkout 2021.05.21
  2. .\bootstrap-vcpkg.bat -disableMetrics
  3. .\vcpkg.exe update
  4. .\vcpkg.exe upgrade --no-dry-run

and then `vcpkg.exe integrate install`.

2. C++ side you should already know how to create FlexSim modules and follow grpc tutorials which explain how to generate C++ code from the proto files. These files will be compiled and linked to your FlexSim module.

I generated C++ code by manually calling protoc.exe with grpc_cpp_plugin.

3. I derived a class from FlexSim::SimpleDataType. A static Init() method works as Flexscript "constructor" and initializes a tree node and adds class-specific data that node. One of the instance methods can create a GRPC channel. stub_ data is a member of my class. Then there are different methods which more or less correspond to methods described in the protocol files which I have used (they are specific to your protocol files). Init and other methods are bound and can be called from Flexscript.

As long as you don't want to use grpc in async mode, implementation is relatively straightforward (provided you can figure out how to read generated C++ for gRPC and know how to create SimpleDataTypes).


· 1
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Adam Hales avatar image
1 Like"
Adam Hales answered William J commented

FlexSim does not natively support gRPC (Google Remote Procedure Call) for communication with external programs. However, it is possible to integrate FlexSim with gRPC by developing custom connectors or using APIs to establish communication. While FlexSim primarily utilizes other protocols for external communication, gRPC can be implemented with additional development effort. For testing and preparation, Study4Exam offers free practice questions for gRPC, which can help you better understand the protocol and its integration. Official resources like the FlexSim API documentation and the gRPC website (https://grpc.io/) can provide further insights on how to implement such integrations.

· 1
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Phil BoBo avatar image
1 Like"
Phil BoBo answered Ryusuke T commented

gRCP has a C++ interface. Basics tutorial | C++ | gRPC

You can use the DLL Maker or Module SDK to execute C++ code from FlexSim. So yes, you can use gRCP to communicate with FlexSim via an external program.

· 1
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.