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

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

axel_kohonen
Not applicable
1,634 Views
15 Replies
Message 1 of 16

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

axel_kohonen
Not applicable

[ FlexSim 16.1.2 ]

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

Accepted solutions (1)
1,635 Views
15 Replies
Replies (15)
Message 2 of 16

Ben_WilsonADSK
Community Manager
Community Manager
Accepted solution

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.

Message 3 of 16

axel_kohonen
Not applicable

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
Message 4 of 16

SCHamoen
Advisor
Advisor

@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.

Message 5 of 16

axel_kohonen
Not applicable

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
Message 6 of 16

SCHamoen
Advisor
Advisor

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.

Message 7 of 16

axel_kohonen
Not applicable

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
Message 8 of 16

SCHamoen
Advisor
Advisor

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.

Message 9 of 16

axel_kohonen
Not applicable

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
Message 10 of 16

chaoqing_x
Not applicable

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
Message 11 of 16

SCHamoen
Advisor
Advisor

@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

Message 12 of 16

vu_duc_nguyen
Not applicable

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
Message 13 of 16

akshay_p
Not applicable

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
Message 14 of 16

Ben_WilsonADSK
Community Manager
Community Manager
0 Likes
Message 15 of 16

axel_kohonen
Not applicable

Hi @Akshay P

I finally never tried anything beyond the inital tests as our client did choose to not pursue the idea.

Kind regards,

Axel

0 Likes
Message 16 of 16

logan_gold
Community Manager
Community Manager

Hey @Akshay P, Vu Duc Nguyen's comment is right with the issue and answer. I did not call socketend() as part of the endconnection() User Command. This should have happened between clientclose() and the return 1 line, like so:

clientclose(getnodenum(client));
setnodenum(client,0);
socketend();
return 1;
0 Likes