Pregunta

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

¿Fue útil?

Solución 2

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.

Otros consejos

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

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.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top