question

Antonio GA2 avatar image
0 Likes"
Antonio GA2 asked Joshua S commented

Obtain data using the Emulation module with Modbus?

Hello How could I obtain data using the Emulation module with Modbus tcp / ipv4 either in JAVA or in c ++? If possible with an example to understand its operation.

FlexSim 18.2.2
c++modbusemulation moduletcpjava
· 2
5 |100000

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

Joshua S avatar image Joshua S commented ·

What data are you trying to obtain? Most of the data would would want is found in the "Variables" Tab of the Emulation properties window where you can read and write to the PLCs, Servers,or Client.

0 Likes 0 ·
Antonio GA2 avatar image Antonio GA2 Joshua S commented ·

Maybe, the time it takes to assemble a product.

But what I need is a way to get some kind of data in a program in JAVA or c ++, I was trying to connect JAVA with FlexSim using sockets, but I have not obtained results.

0 Likes 0 ·

1 Answer

Joshua S avatar image
0 Likes"
Joshua S answered Joshua S commented

A basic script to communicate with a C++ or Java server using FlexSim as the client is as such

socketinit();
int client=0;
client = clientcreate();
string hostname="127.0.0.1";
int port=502;
clientconnect(client,hostname,port);
print(client);
clientsend (client, "TestConnection");
print(clientreceive(client, NULL, 1024, 0));
clientclose(client);

The Emulation module in FlexSim is very specific to Modbus and OPC connections

· 3
5 |100000

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

Antonio GA2 avatar image Antonio GA2 commented ·

I could re-publish the answer, apparently it is no longer available.

1 Like 1 ·
Joshua S avatar image Joshua S Antonio GA2 commented ·

If you could that would be great so it can still be a good resource for others.

0 Likes 0 ·
Antonio GA2 avatar image Antonio GA2 commented ·

thanks, this script, in what part of the program do I place it?

0 Likes 0 ·
screenshot-9.png (116.8 KiB)