Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Information about Simulink MDL and SLX formats?

What information is available about these file formats? What tools are available for parsing these files?

like image 639
Douglas B. Staple Avatar asked May 01 '14 12:05

Douglas B. Staple


People also ask

What is the difference between SLX and MDL in Simulink?

SLX stores model information using Unicode® UTF-8 in XML and other international formats. Saving Simulink models in the SLX format: Typically reduces file size compared to MDL. The file size reduction between MDL and SLX varies depending on the model.

What is the difference between MDL and SLX?

The SLX files contain one or more XML files whose internal structure is similar to that of an MDL file, but in XML format. In addition, binary resources such as graphics may be stored in separate JPG files rather than being text-encoded and directly embedded as they are in an MDL file.

What is the MDL file format?

MDL represents Cognos Transformer models in text format (. mdl) and you can view the text in any text editor. The . py? file is a representation of the model, stored in default binary format.

What is MDL file in Matlab?

mdl-files which is an ASCII file containing information describing the model. Each section is started by a keyword filled with pairs of parameters and values. It contains information about each system and subsystem and their con- tained blocks, ports and lines in hierarchical order.


3 Answers

Very little information is publicly available. Here's the little I've found:

MDL and SLX are MathWorks proprietary file formats for storing Simulink models. SLX was introduced in Simulink R2012a and made the default file format in R2012b. Besides the file structure, the content of SLX and MDL files are very similar. For example, key-value pairs appear to be the same between the two formats. People often say that parsing these files is a bad idea because they can change between Simulink versions (see e.g. am304 and my comments above), but I have not seen much evidence of this.

The MDL format seems to have been developed in-house at MathWorks. There seems to have been an MDL parser for python, but it was of limited functionality, and the website is down as of May 2014.

An SLX file is a zip file containing a collection of XML files, with most of the model specification stored in simulink/blockdiagram.xml. @am304 pointed out this information from the MathWorks website:

SLX is a compressed package that conforms to the Open Packaging Conventions (OPC) interoperability standard. SLX stores model information using Unicode® UTF-8 in XML and other international formats. Saving Simulink models in the SLX format:

  • Typically reduces file size compared to MDL. The file size reduction between MDL and SLX varies depending on the model.

  • Solves some problems in previous releases with loading and saving MDL files containing Korean and Chinese characters.

  • Enables incremental loading and saving. Simulink optimizes performance and memory usage by loading only required parts of the model and saving only modified parts of the model.

Here are a few more references besides the ones in the text above:
How convert simulink files to XML
http://www.scootersoftware.com/vbulletin/showthread.php?t=11568
http://blog.xogeny.com/blog/dont-zip/
http://blog.developpez.com/matlab/p11469/simulink-2/nouveau-format-slx-pour-les-modeles-simulink

like image 116
Douglas B. Staple Avatar answered Oct 20 '22 00:10

Douglas B. Staple


Update (2015/04/02)

The new version of the Simulink Library for Java has full SLX format support. The documentation is not explicit, but the source code contains all details for parsing it.

Old answer

As answered by rob, the Simulink Library for Java supports Simulink's MDL file format and also can parse the Stateflow content. The library is Open Source, but the only documentation is the source code.

We are currently (as of September 2014) working on SLX support and expect to release this in the next 1 or 2 months. If you need the code before this time, feel free to contact me.

It is true that when using the library, your code may possibly break with a new Simulink release, as the file format is not documented and we had to reverse engineer most of it. However, we are currently actively updating the library in case of problems and with the source code you might be able to fix it even if we are not around.

PS: I would have posted this as a comment to rob's answer, but it seems I do not have sufficient reputation to do so :(

Disclosure: I am one of the developers of the mentioned library.

like image 24
Benjamin Hummel Avatar answered Oct 20 '22 00:10

Benjamin Hummel


What information is available about these file formats?

MathWorks does have some documentation for the MDL file format in R2007b.

SLX files are zipfile containers whose internal structure is based on OOXML's OPC format. The SLX files contain one or more XML files whose internal structure is similar to that of an MDL file, but in XML format. In addition, binary resources such as graphics may be stored in separate JPG files rather than being text-encoded and directly embedded as they are in an MDL file.

Both formats change as new features are added to Simulink, but you can expect SLX to be less stable as MathWorks refactors SLX's internal file structure. For example, in R2014b, MathWorks has started breaking sections of the traditionally monolithic blockdiagram.xml out into separate files such as stateflow.xml and graphicalInterface.xml.

What tools are available for parsing these files?

There are a few publicly-available libraries/APIs for parsing Simulink, but I haven't used any of them so I'm not sure how well they work.

  • Simulink Library for Java (formerly called ConQAT) (Java) - MDL, SLX
  • TSMP - Tiny Simulink Model Parser (.NET) - MDL
  • Simulink-Model-Parsing-Tools (Python) - MDL

You may also be able to find others by searching for Simulink parser.

If none of those do the trick, some commercial tools parse MDL and SLX directly rather than relying on the MATLAB API. You could possibly inquire about licensing the parser used in some commercially-available Simulink tool.

like image 29
rob Avatar answered Oct 20 '22 00:10

rob