question

Aditya S3 avatar image
0 Likes"
Aditya S3 asked Eric M commented

Connecting flexsim to external application via UDP

Is there any way to connect FlexSim with an external application using UDP web sockets? I am currently working on building a digital twin for a warehouse where they use UDP to communicate with a few of the components and I am looking for emulating the behavior of UDP. Or Is there any way to emulate the UDP protocol in FlexSim?

FlexSim 21.1.2
flexsim 21.1.2communication socketcommunication socket plc and flexsimsockets
· 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.

Joerg Vogel avatar image Joerg Vogel commented ·

As far as I know you communicate through sockets. I am not aware of how to establish a broadcast and send a datagram without receiving an acknowledgement packet within a Windows socket process.

0 Likes 0 ·
Eric M avatar image Eric M commented ·

Hi @Aditya S3, was Ben Wilson's or Jörg Vogel's answer helpful? If so, please click the red "Accept" button at the bottom of one of their answers. Or if you still have questions, add a comment and we'll continue the conversation.

If we haven't heard back from you within 3 business days we'll auto-accept an answer, but you can always unaccept and comment back to reopen your question.

0 Likes 0 ·
Ben Wilson avatar image
1 Like"
Ben Wilson answered

FlexSim's native modeling language, FlexScript, does not natively support websockets. Without that support, anything you try will be a bit complicated.

Here are some alternative communication modes that may or may not work with your system:

========== SOCKETS ==========

FlexScript includes out-of-the-box support of Windows sockets. See the Command Reference > Communication commands section and search for the "client", "server" and "socket" commands. There are also related questions on this community that can help you with implementation.

========== WEBSOCKETS (using Chromium) ==========

FlexSim's integrated Chromium browser supports websockets.

You can use the commands callwebscriptmethod() and the JavaScript fireFlexsimEvent() function (on the Chromium side) to interact between your model logic and Chromium. See the version 21.0.0 Release Notes and History (flexsim.com) for information regarding fireFlexSimEvent's asynchronous nature.

This comment has an example model and some further explanation of callwebscriptmethod() and fireFlexsimEvent(), though it was created with an older version of FlexSim before fireFlexSimEvent() was asynchronous, so some updates may be required for this example to work in a modern version of FlexSim.

========== OPC UA ==========

FlexSim's OPC UA integration could communicate with a node-RED server you would set up. node-RED could then communicate with other services via websockets.

========== HTTP ==========

You could explore the HTTP api and whether your system can respond to HTTP requests. In addition to sending requests and receiving responses, if your simulation model needs to receive HTTP requests and send responses, you could learn about the FlexSim Webserver.

5 |100000

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

Joerg Vogel avatar image
1 Like"
Joerg Vogel answered

As documented there is not an init socketx implemented so far in socket communication. Maybe you can execute a program within Windows to send an udp datagram, similar to a power shell script.

5 |100000

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