Skip to content

Executable meta-model of Finite State Machines developped with GEMOC Studio

License

Notifications You must be signed in to change notification settings

echebbi/gemoc-fsm

Repository files navigation

Executable Finite State Machine

Motivation

This project is aimed to experiment with GEMOC Studio.

More specifically, the goal is to create a graphical editor based on Sirius that makes able to edit a Finite State Machine (FSM). Futhermore, it must be possible to simulate a FSM's execution thanks to GEMOC's Model Animator.

Screenshot of a Door FSM

Implemented features

Model
  • ECore meta-model
  • Nested FSM
  • Introduce a terminal state
Execution
  • Step-by-step CLI execution
  • Step-by-step UI execution
Representation
  • Diagram representation
  • Diagram editor
  • Tailored Properties view

Implementation

The Wiki sums up the implementation of such a FSM and describes how to use GEMOC. This is not a tutorial, rather a capitalization of my experience on using GEMOC Studio.

The different projects present in this repository are:

  • ice.master.fsm.model: defines the ECore meta-model of a FSM ;
  • ice.master.fsm.semantic: defines the Kermeta 3 Aspects describing a FSM's behavior ;
  • ice.master.fsm.xdsml.*: defines the xDSML used by GEMOC's Model Animator ;
  • ice.master.fsm.design: defines the Sirius Representation of a FSM.

Samples

The samples folder contains examples of projects defining a FSM:

  • ice.master.fsm.sample.door: represents a door owning three states (Opened, Closed, Broken) ;
  • ice.master.fsm.sample.device: represents a simple device owning a state (Off) and a nested FSM (On).

Import these projects in your workspace to test them.

Use this project

Table of Contents

1. Choose the right GEMOC Studio

At the time of writing, the latest version of GEMOC Studio is the 3.0.0-SNAPSHOT. Since it is a SNAPSHOT, the product evolves over time and some versions are more stables than overs.

The different versions are built by Jenkins, and I found out the build #33 to be pretty stable. Since Melange is not currently really trustworthy I strongly advise you to use this version of GEMOC.

2. Clone the repository

To use the projects, you must clone this repository locally. You can either use Eclipse's EGit or type the following command in your terminal:

git clone https://github.com/KazeJiyu/gemoc-fsm.git

3. Import the projects

Open GEMOC Studio, then import the projects with File > Import ... > Existing Projects into Workspace.

4. Open a second GEMOC instance

In order to use the plug-ins defining a FSM, a second GEMOC Studio has to be run. To this end, go to Run > Run Configurations .... Create a new Eclipse Application then click Run.

5. Create a new FSM

First of all, create a new project: File > New > Other... > Ecore Modeling Project.

Then, create a new FSM Model: File > New > Other... > Model Model.

Caution: the name is not really explicit, it should be changed soon.

The new file should open with the XML Editor. Close it, then right-click on the file to open it with the Model Model Editor.

You can now populate the FSM by right-clicking on the root and add new children. Their attributes can be edited through the Properties view.

6. Execute the FSM

Go to Run > Run Configurations... and create a new Gemoc Sequential eXecutable Model.

You must fill the following fields:

  • Model to execute: the path to the .fsm file defining the FSM to execute ;
  • Melange language: should be ice.master.fsm.xdsml.FSM ;
  • Main method: should be public static void ice.master.fsm.xdsml.fsm.aspects.FiniteStateMachineAspect.main(ice.master.fsm.xdsml.fsm.model.FiniteStateMachine) ;
  • Main model element path: the FSM to execute, should be / after validation.

Finally, click Run to launch the execution.

Note: to trigger a Transition, a FSM expects events. An event is merely a string that you can send by typing it into the original GEMOC Studio's console.

7. Debug the FSM

Go to Run > Debug Configurations... and create a new Gemoc Sequential eXecutable Model.

Fill the same fields than previously as well as the following ones:

  • Check Break at start to tell GEMOC to run the FSM step-by-step.

Note: to benefit from the MultiDimensional Trace view, you must open the Engine Addons tab and check Generic MultiDimensional Trace.

8. Create a representation of the FSM

From the Model Explorer, right-click on the root of the FSM, below the .fsm file and select New Representation.

The new representation should be created in the .aird file and open in the diagram editor.

9. Debug the representation of the FSM

You can debug a FSM with the help of a visual support by following the steps specified in Execute the FSM. The only change is to fill the Animator field with the path to the .aird file containing the FSM's representation.

Note: the FSM's current state is colored in orange only when selected from the Multidimensional Timeline view.

Useful links

The following links provide useful informations about GEMOC Studio and its use:

Releases

No releases published

Packages

No packages published