question

Ryusuke T avatar image
2 Likes"
Ryusuke T asked Ryusuke T 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:

git checkout 2021.05.21
.\bootstrap-vcpkg.bat -disableMetrics
.\vcpkg.exe update
.\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.

Ryusuke T avatar image Ryusuke T commented ·

Hi @Serge A ,


Thank you for your reply and introduction of tips.

This information will surely be useful!

0 Likes 0 ·
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.

Ryusuke T avatar image Ryusuke T commented ·

Hi @Phil BoBo ,


Thank you for your reply.

It was very helpful to know that communication was possible.

0 Likes 0 ·