Is demonstrates the use and access to HSM elements in a Kotlin application.
A page, conventionally called the compilation service, has been added to the HSM editor (currently a private project - https://github.com/mk590901/qhsm_editor_app, linkedin - https://www.linkedin.com/posts/michael-kanzieper-52931612_hsm-dart-flutter-activity-7241391192653938689-DUiV/?utm_source=share&utm_medium=member_desktop). It is designed to translate the HSM graphical scheme into the target code. At the moment, three compilers are implemented: for Dart, Java and Kotlin. An example of using this code in Dart applications is the project https://github.com/mk590901/Touch-Tracker, in Java - https://github.com/mk590901/Java-HSM. This project discusses the use of automatically generated code in a Kotlin app for Android.
Note: the HSM example from the book Practical Statecharts in C/C++, charter 4.2 An Annotated Example p.95 was chosen as the testing scheme.
The project includes the following parts, grouped into separate groups:
Locates in folder hsm, which contains two base classes QEvent and QHsm - porting of the framework of Miro Samek for Kotlin.
Subfolder implementation contains classes generated by the QHsm editor. It's probably worth noting that they weren't edited.
- Folder interfaces contains a set of interfaces created for access to QHsm, as well as for interaction of internal objects of the framework with each other.
- Folder support contains auxiliary classes that provide implementation of the previously mentioned interfaces.
These are three classes: MainActivity, ButtonAdapter and StringAdapter, which provide the functionality of the Android application as described in the App overview section.
Android app is designed to demonstrate the transitions of the above HSM scheme (pay attention on note reference) under the influence of events. The upper part of the application contains a dynamic list of QHsm transitions. The events list implemented as buttons list is located at the bottom of the screen. The application has minimal functional capabilities. It only demonstrates the connection and reflection of the processes inside QHsm by the application widgets.
The movie consists of three parts:
- Compilation of the HSM scheme by QHsm editor
- Demonstration of generated classes
- Execution of the Kotlin application
kotlin3.mp4
Adding a Kotlin compiler allows to extend the scope of QHsm approach in Kotlin apps.