on
SysML v2 language in LionWeb
The interoperability of modeling frameworks is an important condition for creating an ecosystem of modeling tools, where one can mix and match components from various technologies and benefit from the best capabilities each tool has to offer. The LionWeb protocol was started with the mission to achieve such interoperability between modeling frameworks and language workbenches. By connecting an MDE (model driven engineering) tool to the LionWeb protocol, we make it possible to exchange metamodels (or languages) and models between our tool and the other MDE tools, that support LionWeb protocol.
To demonstrate the benefits of LionWeb, I applied it to the SysML v2 language, a general-purpose modeling language, that is highly anticipated in the world of MBSE (Model Based System Engineering). The SysML v2 language is being developed by a team from Object Management Group (OMG) and is being prototyped in the open-source pilot implementation. The pilot implementation of SysML v2 uses Eclipse Modeling Framework (EMF) for capturing the structure of the language and Xtext for providing its textual notation.
The EMF implementation of SysML v2 provides an important reference definition and is used by early adopters and the community to validate the language design and to experiment with the technologies such as formal analysis of SysML v2 models. The LionWeb protocol allows for opening up this SysML v2 implementation to the other modeling frameworks from the ecosystem, JetBrains MPS and Freon. JetBrains MPS is a powerful and mature language workbench. Its projectional editor supports a wide range of domain-specific notations, from text to tables, formulas, and diagrams. Freon provides a highly-customizable language editor in a web browser. In addition to an editor, we can benefit from scoping, typing, constraints validation, interpretation and model transformations. The LionWeb protocol connects them all and allows for using the best of all worlds for SysML v2.
Transferring a language from one modeling framework to another
-
As EMF Ecore is supported by the LionWeb protocol, it is possible to export SysML v2 (i.e., its ecore meta-model from the pilot implementation) to the LionWeb Json format.
-
We import the resulting LionWeb Json into two other language workbenches, supported by LionWeb: JetBrains MPS and Freon:
-
The import of a LionWeb language into MPS and Freon results into automatic generation of the language definition artifacts in these tools:
A fragment of the metamodel of the SysML v2 language defined in Ecore: |
A fragment of the corresponding metamodel of SysML v2 generated in JetBrains MPS: |
A fragment of the corresponding language definition of SysML v2 generated in Freon (~1100 LOC in total): |
There are about 180 concepts in the pilot metamodel of SysML v2, not counting their properties and cross-references. With LionWeb, we transferred all these concepts, their properties and cross-references, from one language definition format (Ecore) to two other formats (MPS structure definition and Freon AST), automatically and without even bothering what these formats look like. Just imagine how much work would it take to recreate the SysML v2 metamodel in MPS or Freon from scratch!
Instantiating language models
Now as we have the SysML v2 language structure in MPS and Freon, we build the corresponding language infrastructure. This includes, among others, a default reflective editor for the SysML v2 language. Thus, we can instantiate a SysML v2 model using the default editor.
As a reference, I take this example SysML v2 model from the pilot implementation library, shown here both in the Xtext textual notation and as the underlying EMF tree:
In the MPS reflective editor, a model appears with the placeholders for all its properties and references.
This is the default editor, automatically generated from the metamodel of the SysML v2 language.
For the actual use, we need to create a custom editor for the SysML v2 language, in the same way as Xtext provides the custom textual notation for the ecore meta-model of SysML v2 in EMF.
In the Freon editor, the situation is the same: all the properties and features of the PictureTaking package
are shown by default, as this editor is generated automatically from the meta-model.
To make it usable, we need to define a custom editor.
Next steps
What we have achieved so far, is transferring the abstract structure of a language from one tool to another. This is only the first step. Here are some further steps that we can take to leverage the benefits of our ecosystem of interoperable language engineering tools.
-
Using LionWeb protocol, automatically transfer SysML v2 models on the M1 level, from one tool to another. The LionWeb implementation that we use in our exercise already allows for transferring M1-models between the tools. We haven’t tried it yet for the SysML v2 language.
-
Enhance SysML v2 language with custom tailored notations, constraints, and evaluations in MPS and Freon. Just imagine that we could use MPS KernelF language notation for the KerML expressions of SysML v2:
-
Adapt SysML v2 to a concrete system domain by building a DSL (domain-specific language) on top of it. This is what language workbenches like MPS are good at: building domain-specific extensions on top of a language.
-
Develop model transformations and generators using powerful tools of MPS.
About Ulyana Tikhonova
I am a Model Driven Software Engineer at F1RE, since April 2024. I am a big fan of domain-specific languages (DSLs) and model-driven approach. I did my PhD on the semantics of DSLs and had worked with model-based testing on an industrial scale.
You can contact me at ulyana@f1re.io.