modelica-3rdparty / Modelica_DeviceDrivers

Free library for interfacing hardware drivers to Modelica models. There is support for joysticks, keyboards, UDP, TCP/IP, LCM, MQTT, shared memory, AD/DA converters, serial port and other devices.
BSD 3-Clause "New" or "Revised" License
77 stars 31 forks source link

Transfer a large amount of data from Dymola to MATLAB via UDP #336

Closed Satinelamp closed 3 years ago

Satinelamp commented 3 years ago

I am considering using the Modelic_DeviceDrivers library to transfer data via UDP, but it turns out I have to connect every variable via a component, and I have a few thousands of variables, it would take too much effort to connect them.
How could I transfer a large amount of data from Dymola to MATLAB efficiently via UDP?

bernhard-thiele commented 3 years ago

Maybe you could mechanize it by using the underlying Modelica functions directly, instead of using the drag'n drop blocks. Though I'm not sure whether it is a good idea using this UDP interface if you have so many variables. It could work, could be even rather efficient, but it simply stuffs everything sequentially in one UDP message. It's rather easy to introduce offset bugs if message construction and deconstruction don't fit exactly and it is potentially hard to debug if you have so many variables.

Satinelamp commented 3 years ago

Except for UDP, is there any other method that allows massive data exchange via the internet efficiently?

bernhard-thiele commented 3 years ago

UDP may drop packets, it is particularly for time-sensitve applications, e.g., (soft) real-time applications. Otherwise TCP provides a more reliable data stream. MDD is intended for rather simple use cases. There are various libraries available for a more high-level data exchange, e.g., https://zeromq.org/ , but I'm not aware of any ports to Modelica language bindings. I've so far only used the OS functions directly.