Introduction
The Object Management Group's (OMG) Systems Modelling Language (OMG SysML) can be used to describe various kind of systems. After modelling a system, one scenario is that software engineers use these models to write any form of software. For example, software experts may write code for a system that has to be developed. Another scenario is that one wants to simulate the system, e.g., to learn something about its implications. When starting to write code, soon the problem arises how to reuse the work done in the modelling phase. One possible way are Model-to-Text transformations. Model-to-Text transformations, as a part of Model Driven Software Engineering (MDSE), enable to generate code from models. Thus one can save time in the development phase, since software engineers do not have to start writing code from scratch.Hence, to address the problem of reusing SysML models for further work, a model driven code generation approach was used in this work. In particular, a code generator is proposed to translate different SysML diagram kinds into respective Python code. This code generator relies on the Eclipse Modelling Framework (EMF) and the SysML implementation of the UML and SysML modelling tool Papyrus. In order to show the practical usage of the code generator an example of a coffee machine serves as an input for our SysML2Python code generator. As a result with the SysML2Python code generator, we were able to successfully generate Python code out of our supported SysML diagram types. These supported diagram types are the Block Definition Diagram (BDD), Internal Block Diagram (IBD) and Parametric Diagram (PAR).
SysML Diagram Types (dark blue: Supported by SysML2Python Code Generator) |
Used Technology
- Python, which is an universally applicable, object-oriented interpreter for high-level programming
- Object Management Group (OMG) Systems Modelling Language (OMG SysML), which is a general-purpose language for systems engineering applications
- Xtend, which is a programming language and was used to write the SysML2Python code generator
- Papyrus, which is a tool for graphical modelling of UML, SysML and other modelling languages
Implementation
Our SysML2Python code generator takes an .uml file as input file, which holds the SysML Features attached with Stereotypes in form of a tree, and generates one Python module as output file.
In Papyrus, the information of the modelled system is represented in a single file, regardless of the number of actual modelled diagrams. For example, in case of an Internal Block Diagram the information of its own and its base the Block Definition diagram is stored in a single .uml. This file serves as input for the code generator.
The code generator generates one output file (the Python module of the .uml file). The main reason for a single file is that the generated code can easily be imported by another Python program. For each element in the .uml file the type of the element is queried first (via use of the instanceof operator). Then, the corresponding method is invoked, which holds the individual structure for each type. The next code snippet shows this structure. The polymorphic generateElement method invokes the corresponding method of the type of the actual element (see line 5 in the next code snippet).
In Papyrus, the information of the modelled system is represented in a single file, regardless of the number of actual modelled diagrams. For example, in case of an Internal Block Diagram the information of its own and its base the Block Definition diagram is stored in a single .uml. This file serves as input for the code generator.
The code generator generates one output file (the Python module of the .uml file). The main reason for a single file is that the generated code can easily be imported by another Python program. For each element in the .uml file the type of the element is queried first (via use of the instanceof operator). Then, the corresponding method is invoked, which holds the individual structure for each type. The next code snippet shows this structure. The polymorphic generateElement method invokes the corresponding method of the type of the actual element (see line 5 in the next code snippet).
fsa.generateFile('''<<ModelName>>.py''', '''
"""GENERATED BLOCKS"""
<<FOR EObject obj : root.eContents>>
<<IF obj instanceof org.eclipse.uml2.uml.Class>>
<<generateElement(obj)>>
<<ENDIF>>
<<ENDFOR>>
''')
Conclusion and Future Work
The objective of this project was to generate Python code from SysML Block Definition-, Internal Block- and Parametric Diagrams. The proposed solution called 'SysML2Python Code Generator', which uses the Eclipse Modelling Framework, Xtend and Papyrus. allows to generate code from .uml files that contain a SysML model. The generated code can easily be imported by other Python applications and has great potential to be used as a basis for further programs. A specially interesting application would be to use the generated code as a base for simulations of SysML models. Nevertheless, further study on generating code from SysML equations is needed to address the issue of using more complex equations in parametric diagrams (e.g. to have built-in functionality to simulate the behaviour of the system over time).
This comment has been removed by the author.
ReplyDeleteYour post about technology was very helpful to me. Very clear step-by-step instructions. I appreciate your hard work and thanks for sharing.
ReplyDeletePython Training in Chennai
Python Classes in Chennai
Thanks for sharing a worthy information in detail. This is really helpful for learning. Keep doing more.
ReplyDeleteBest IELTS Classes in Mulund
IELTS Centres in Mulund East
IELTS Coaching Classes in Mulund
IELTS Training in Mulund
IELTS Coaching Centres in Mulund
Best IELTS Course in Mulund West
IELTS Training Institute near me
thanks for share amazing article
ReplyDelete슈어맨
슈어맨
Coast Guard Day Messages
National Grandparents Day Messages
telegram group links
ReplyDeleteSach janiye
ReplyDeleteMrinalini Sarabhai
Sandeep Maheshwari
dr sarvepalli radhakrishnan
Arun Gawli
Rani Padmini
Sushruta
Harshavardhana
Nanaji Deshmukh
Tansen
Thanks for sharing information awesome blog post Online Education Quiz website For Exam Follow this website Gk in Hindi
ReplyDeleteI love to read your articles because your writing style is too good, its is very helpful for all of us and I never get bored while reading your article. KEEP SHARING!!
ReplyDeleteandroid apps apkzm
android apps apkzm
android apps apkzm
android apps apkzm
android apps apkzm
android apps apkzm
android apps apkzm
android apps apkzm
android apps apkzm
https://www.pforprograms.com/2020/09/cc-basic-programs-with-example-and.html
ReplyDeleteIt's been our pleasure to inform you that our institution is offering a great deal by giving CS executive classes and a free CSEET class only for those who are interested in gaining knowledge. So what are you waiting for contact us or visit our website at https://uniqueacademyforcommerce.com/
ReplyDeleteLogin Your TriumphFX Account. Read In Depth TriumphFX Review.
ReplyDeleteAmazing opportunities came with amazing time and here is our institution offering you CS executive classes and a free of cost CSEET classes. So what are you waiting for contact us or visit our website
ReplyDeletecs executive
freecseetvideolectures/
Set An Alert For Dollar To Real To Receive An Email When The Exchange Rate Changes. Alternatively, Bookmark The Page And Check Back Here Regularly.
ReplyDeleteIf You Want To Trade Forex, Cfds, Crypto, Commodities Or Any Other Market Online, Then You Don't Need To Look Any Further. Aximtrade Mt4 Download Offers A Full Suite Of Award Winning Trading Tools, Including The Award-winning Mt4 Platform.
ReplyDeleteGQFX Review Offers A Safe And Secure Platform To Do Forex Trading And CFDs And Our Customer Support Is Ready To Help You 24/7. You Can Easily Sign Up Your GQFX Login Account Here.
ReplyDeleteNice Topics.. Read My Review Of An Online Cfd Trading Broker, Aximtrade Reviews With A Focus On Their Platform And Customer Support Services. I Have Been Using Them For Over A Year And This Is My Honest, Unbiased Review.
ReplyDeleteDownload Aximtrade Reviews Mt4: A Complete Solution For Your Forex Trading.
ReplyDeleteI needed to gratitude for this prominent appropriate to apply!! I truly adored all minuscule piece of it. I have you bookmarked your site to try out the presented assets you articulate. Sony Vegas Pre Cracked
ReplyDeleteGoodness! Such an awesome and helpful call that is. I basically in all actuality praise it. it's for that excuse attractive and as an end result impressive. I'm recently stunned. I dream that you keep up with to make a get adhering to of your seriously be sick bearing in considerations this in the with moreover!thanks https://cyberspc.com/microsoft-office-2010-full-version/
ReplyDeleteExcellent post.
ReplyDeleteJewellery Software
Jewellery Software