Skip to content

The repository contains a project of HSM oriented application in Kotlin for Android. App uses code elements automatically generated by the HSM editor when compiling the graphical scheme in Kotlin.

Notifications You must be signed in to change notification settings

mk590901/Kotlin-HSM

Repository files navigation

Kotlin HSM App

Is demonstrates the use and access to HSM elements in a Kotlin application.

Goal

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.

Project structure

The project includes the following parts, grouped into separate groups:

QHsm core

Locates in folder hsm, which contains two base classes QEvent and QHsm - porting of the framework of Miro Samek for Kotlin.

Generated code

Subfolder implementation contains classes generated by the QHsm editor. It's probably worth noting that they weren't edited.

Auxiliary elements

  • 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.

Kotlin App

These are three classes: MainActivity, ButtonAdapter and StringAdapter, which provide the functionality of the Android application as described in the App overview section.

App overview

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.

Movie

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

Conclusion

Adding a Kotlin compiler allows to extend the scope of QHsm approach in Kotlin apps.

About

The repository contains a project of HSM oriented application in Kotlin for Android. App uses code elements automatically generated by the HSM editor when compiling the graphical scheme in Kotlin.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published