Information about Simulink MDL and SLX formats?
Asked Answered
F

3

15

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

Feign answered 1/5, 2014 at 12:58 Comment(6)
Why you need this ? Are you trying to parse the model files ?Roughneck
@Roughneck I know that parsing MDL files is a bad idea, and from looking at SLX files I can see that it's probably also a bad idea to parse SLX files. Nevertheless I want to know what's known about this file format (actually both of these formats), because this has come up in my job. If I found an official looking reference saying "DON'T PARSE SLX FILES!" then that'd be helpful too. I updated my question to reflect this.Feign
The only "official" bit about the file format is in mathworks.co.uk/help/simulink/ug/saving-a-model.html#btbr7kx-1Covet
@DouglasB.Staple IMO parsing .mdl was never a bad idea, until .slx shown up. If its possible, you can tell what you actually need from .slx, there are several Simulink APIs which could do lot of stuffs.Roughneck
I agree with @P0W's comments. Any program relying on parsing a Simulink model is bound to break at the next release. The file format is not documented and probably never will be. Much better to use the API.Covet
@am304, I don't think P0W was saying to avoid parsing Simulink models. It was me that said that. However, in my experience the differences in files between Simulink versions is smaller than what people tend to say. I want to know what information and tools are available.Feign
S
5

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.

Shrew answered 11/9, 2014 at 15:28 Comment(1)
can I get metadata from slx file with using Simulink Library for Java? I write metadata to slx file using next MATLAB code: h = load_system(pathToFile); set_param(h, 'Metadata', properties)Heliogabalus
F
12

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

Feign answered 1/5, 2014 at 15:28 Comment(0)
S
5

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.

Shrew answered 11/9, 2014 at 15:28 Comment(1)
can I get metadata from slx file with using Simulink Library for Java? I write metadata to slx file using next MATLAB code: h = load_system(pathToFile); set_param(h, 'Metadata', properties)Heliogabalus
S
4

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.

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.

Shufu answered 20/6, 2014 at 16:6 Comment(1)
Thanks a lot. What you wrote is consistent with and builds on my understanding.Feign

© 2022 - 2024 — McMap. All rights reserved.