question

Axel Kohonen avatar image
4 Likes"
Axel Kohonen asked Ben Wilson edited

What would be the best way to communicate between Flexsim and other processes, e.g. a WMS system?

Hi,

I am wondering what different kinds of methods there exists in Flexsim to communicate with another system running either on a web server or a local virtual machine? The system could be e.g. a WMS system that gives orders to Flexsim on what to do inside the warehouse. In the web communication thread the http solution is outlined and that could be a working solution.

Are there other solutions to the problem or other interfaces that one can use to communicate between Flexsim and some other software? Should one choose a different approach if the other system is a web server than when it is a local virtual machine?

What is needed is that Flexsim and the other system can send each other messages and react to them and also that their clocks can be synced somehow so that neither gets ahead of the other. One option could be that Flexsim sends it's clock to the other system and the other system responds by giving Flexsim the tasks that need to happen at that time.

Thank you!

Kind regards,

Axel

FlexSim 16.1.2
web communicationcommunicationwms
5 |100000

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

Ben Wilson avatar image
4 Likes"
Ben Wilson answered Ben Wilson edited

In addition to the web communication thread you've already pointed to, you may also consider looking into using sockets. @Logan Gold created a socket example model, last updated in January 2016, that was posted on the old forum.

You can get more documentation of FlexSim's socket communication abilities by checking out all the socket, server, and client commands located under the Communication category.

· 6
5 |100000

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

Axel Kohonen avatar image Axel Kohonen commented ·

Hi Ben,

Thank you! Will look at the sockets communication. Are sockets and http the two recommended ways of communicating with external programs? Or are there some other options as well that could work?

Also, as a note the socket example by @Logan Gold had some problems with using the backward dash instead of the forward dash so the references to the client did not work correctly until I changed to forward dashes (that the sampler gives when I pick the client node from the tree). Could be an operating system / language thing maybe?

Also, did not get the serverclose to work properly it seemed. I could open the connection and send data over it and close the client side and then the server. However, if I tried to opent the server again then it worked, but the client was not able to connect to it as the serverinit command did not return true. The FLexsim 16.1.2 versions of the files are attached. sockets-server.fsm

sockets-client.fsm

Kind regards,

Axel

0 Likes 0 ·
sockets-server.fsm (16.2 KiB)
sockets-client.fsm (13.6 KiB)
Vu Duc Nguyen avatar image Vu Duc Nguyen Axel Kohonen commented ·

Hi @Axel Kohonen, I guess the reason that the client was not able to connect again is that in the sample model the client did not call socketend when disconnecting. Both the server and the client need to call socketinit and socketend in pairs. If socketinit is called twice, without socketend being called in between, the 2nd call will return false. You probably already figured out the reason, since this is a pretty old post, but just put it here in case other users are interested to know.

0 Likes 0 ·
Akshay P avatar image Akshay P Axel Kohonen commented ·

hi @Axel Kohonen,

Were you able to fix the issue? If yes, can you please attach the updated files? I am trying to figure out the fix to this problem as well and idk what it is.

Regards,

Akshay Pundir


0 Likes 0 ·
Ben Wilson avatar image Ben Wilson ♦♦ Akshay P commented ·
0 Likes 0 ·
Show more comments
Steven Hamoen avatar image
2 Likes"
Steven Hamoen answered Chaoqing X commented

@Axel Kohonen I don't know what the prefered way is but there are other ways possible also. Flexsim is capable to communicate with databases so maybe it can communicate directly with the WMS database?. You can use the standard Flexsim functions with ODBC or wrap the native driver in a C++ dll and use that.

There are also complex solutions thinkable like a COM object or very simple ones with just text files being written and read.

· 7
5 |100000

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

Steven Hamoen avatar image Steven Hamoen commented ·

Hi @Axel Kohonen if flexsim just checks the order in the database every x time and if there are new orders, reads them and executes the transports I don't see any problems. In a DLL you can have a seperate thread checking the database all the time if it slows Flexsim down to much.

1 Like 1 ·
Axel Kohonen avatar image Axel Kohonen Steven Hamoen commented ·

Hi @steven.hamoen, would this be implemented such that you would have a separate database table in the database that would contain the transfer orders that FlexSim would read and execute and then tell the database to remove the transfer task? Or how is this actually done?

0 Likes 0 ·
Steven Hamoen avatar image Steven Hamoen commented ·

HI @Axel Kohonen I think there are different solutions here. In its simplest form you would have a field that is false if the order is not executed and Flexsim turns it into true if it has been executed. But indeed you could also have a separate table. I'm not sure about your actual setup and the wishes so it would be difficult to give any advice here.

1 Like 1 ·
Axel Kohonen avatar image Axel Kohonen Steven Hamoen commented ·

Hi Steven,

Thank you! Will need to check what is the best option when we know a bit more about the specific setup.

0 Likes 0 ·
Axel Kohonen avatar image Axel Kohonen commented ·

Hi @steven.hamoen,

Thank you for the input! We will be using the logic of the WMS system and not have any of the logic in FlexSim. FlexSim would just move the items from A to B as given orders by the WMS. So I guess this rules out the database communication. Am I correct?

COM objects is probably complex as you say and text files could work if the WMS and FlexSim runs on the same computer. However, we will possibly have the WMS running on a remote server so in this case the text file option would not work.

Thanks!

Axel

0 Likes 0 ·
Chaoqing X avatar image Chaoqing X commented ·

Hi @steven.hamoen,I have meet the same quetions which @Axel Kohonen had met, but i still donot find the solutions.my purpose is as follows:

We will be using the logic of the WMS system and not have any of the logic in FlexSim. FlexSim would just move the items from A to B as given orders by the WMS or control the fixed resources. Mybe there are so many objects in the model,such as crane,AGV,operators,conveyor and so on.

I try to use socket to communication.but there are so many problems:

(1)I have to send Message Loop to check if flexsim receive the order from wms。this way would burden model.

(2)flexsim is as clients,when i check if flexsim receive the order from server(wms),diferent flexsim script,diferent result.when flexsim script is "clientreceive(num,buffer,15,0)",flexsim can receive the message from server. but when flexsim script is "clientreceive(num,buffer,15,1)",flexsim can not receive the message from server.

(3)flexsim is as svever,when i check if flexsim receive the order from wms, when i check if flexsim receive the order from wms,the first time can receive the message from client(wms),but the second time is failed.2017-1-9-2serverclients-v2016.fsm

0 Likes 0 ·
Steven Hamoen avatar image Steven Hamoen Chaoqing X commented ·

@Chaoqing X This is a different question! You have a solution but you now have problems with this solution. Please post this in its own thread

1 Like 1 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

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