Here at Claytex we release our Modelica libraries at least twice a year; this process includes exporting encrypted copies of libraries to protect them, and ensuring all accompanying files are supplied to users. As we do this regularly for a large group of libraries, we’ve streamlined the task of preparing our libraries for release. So in this blog post I’m going to show you how we build our library release and share a tool to help you do the same.
A previous blog post explored library concealment for protection of intellectual property, if you’re interested in the options available to control what users can see and do once the library has been encrypted take a look at that post here.
Process for Building the Library Release
The process to produce our library release build has many steps. The image below illustrates a minimum set of steps to create an encrypted library release to distribute to your users.
Figure 1 – Process for building a library release
You could manually do each of the steps in the build process, however this can be a little tedious if you’re doing this regularly or for a lot of libraries. So we make use of scripting in Dymola to help automate this release build process.
By using the Modelica based scripting language, Dymola’s built-in functions, as well as functions from the Modelica and DymolaCommands libraries, we can write a script to execute all the commands necessary to build the library release as shown in Figure 1.
The script includes the commands:
- DymolaCommands.SimulatorAPI.openModel(“Path to package.mo file to be opened“) to open the libraries in Dymola.
- Modelica.Utilities.Files.createDirectory(“Name of the directory to be created“) to create the folders to store the files.
- saveEncryptedModel(“Library Name“, “Path to saved encrypted file including .moe filename”) to create the encrypted library file (i.e. the .moe file).
- Modelica.Utilities.Files.copy(“Old folder path“, “New folder path“) to copy and rename files.
Additional Files for Using the Encrypted Library
When supplying users with your library, it’s important that you supply all the required files to successfully use the library as well as the encrypted library file. These additional files need to be co-located with the libraries package.moe file to maintain the relative path relationships in the library. This typically includes the library’s:
- Images folder
- Resources folder
- Scripts folder
Our libraries also contain a help folder where we store exported HTML help documentation files which we also need to supply to our users.
Download a Script to Build Your Library Release
You can use the commands I’ve listed above to create your own library release build script, but I’ve created a script that you can download to do this.
The script allows you to produce a library release build for a single or multiple libraries, following the process in Figure 1. All you need to do is download the script, open it in Dymola, edit the inputs and then run the script to build your library release.
Download the Script to Build Your Library Release Here
Written by: Hannah Hammond-Scott – Modelica Project Leader
Please get in touch if you have any questions or have got a topic in mind that you would like us to write about. You can submit your questions / topics via: Tech Blog Questions / Topic Suggestion