h1. Yakindu Statechart tool concepts


h2. Modeling

Yakindu Statechart Models are based on statecharts as defined by David Harel and are close to UML state machines. Thus, they support all structural model elements as defined by the UML specification, which are States (orthogonal and hierarchical), Regions, Transitions and Pseudo States (History, Deep History, Initial, Final, Choice, Join / Fork).
In addition, Yakindu Statechart Models specify interfaces that define the interaction of the state machine with its environment. Besides some more advanced concepts like Entry / Exit Points, an interface basically consists of in and out Events as well as Variables including types. These well-defined statechart interfaces are especially useful in the context of component models and product line engineering.

For defining interfaces and modeling the dynamic aspects of statecharts (triggers, guards and actions) SCT provides a statically typed, textual action language. It tightly integrates into the graphical editor and supports the user with code completion, syntax highlighting, cross referencing and validation during modeling.

Declarations of interfaces, events, variables etc. are done in a textual modeling field in the editor. The language expressions that define actions are directly added to the elements like states or transitions. 

h2. Simulation

Yakindu Statechart Models can be executed via an integrated simulation engine. The simulation engine supports two different types of execution semantics:

* cycle based 
* event driven

The default execution semantic is *cycle based* which executes a statechart cycle within a fixed period of time and thus allows processing of concurrent events. In contrast, the *event based* approach executes a statechart cycle as soon as an event occurrs.

During simulation, the currently active states and the transition path including the previous states are highlighted in the editor for visual debugging. An additional view shows the variable values and allows to raise events. 

Apart from that, the engine uses a *virtual time* during simulation. The user can provide a time scaling factor that is multiplied with the real time. This is especially useful during debugging, if the statechart model contains very tight or long running time triggers.

h2. Code Generation

Yakindu Statechart Tools currently support the generation of Java, C and C++ Code.  All generators can be customized with a *generator model*. This is a textual model file where generator features, like the execution type (event or cycle based), or the interface styles (static or generic), can be specified. The code generation process can either be executed with a builder that starts code generation on resource change or manually with a context menu action.

h2. Domain specific adaptability

Yakindu Statechart Tools were developed with a domain specific adaptability in mind. Several extension points allow the customization of all mentioned aspects. It is possible to contribute a custom type system or custom action languages which may be a dialect of the textual description language or a complete new language.

Also, the different code generators can be customized or new code generators for other target languages can be plugged in easily.

h2. Yakindu SC Modeling perspective

For state machine modeling purposes open the Yakindu *SC Modeling* perspective by clicking *Window* > *Open Perspective* > *SC Modeling*. This perspective is optimized for statechart modeling. It consists of 
* "Project Explorer":PLUGIN_ROOT/org.eclipse.platform.doc.user/concepts/cnav.htm on the left
* "Outline":PLUGIN_ROOT/org.eclipse.platform.doc.user/concepts/coutline.htm View on the right
* YAKINDU Statechart Editor at the top
* "Problems":PLUGIN_ROOT/org.eclipse.platform.doc.user/concepts/cprbview.htm and "Properties View":PLUGIN_ROOT/org.eclipse.platform.doc.user/concepts/cpropview.htm at the bottom

!../02_Getting_Started/images/sc_modeling_perspective.jpg!


h2. Yakindu SC Simulation perspective

To simulate a state machine use the Yakindu *SC Simulation* perspective by clicking *Window* > *Open Perspective* > *SC Simulation*. This perspective is optimized for simulation purposes and consists of:

* "Project Explorer":PLUGIN_ROOT/org.eclipse.platform.doc.user/concepts/cnav.htm on the left
* "Outline":PLUGIN_ROOT/org.eclipse.platform.doc.user/concepts/coutline.htm view on the right top
* Simulation View on the right bottom
* Debug view at the top
* YAKINDU Statechart Editor at the bottom

!../02_Getting_Started/images/sc_simulation_perspective.jpg!



h2. YAKINDU Statechart Editor

With the YAKINDU Statechart editor you create or modify state models. The editor automatically opens on .sct files. To create a new YAKINDU statechart model click *File* > *New* > *Other...* > *YAKINDU Statechart model*. Give it a speaking name and click *Finish*. The newly created model opens in the statechart editor. Also the SC Modeling perspective opens.

!../02_Getting_Started/images/sc_editor_01.jpg!


The editor consists of three parts: 
* the graphic canvas to design the state machine
* the palette on the right that owns the elements to design the state machine 
* a textual modeling field on the left

You can use the textual modeling field to define internal behavior of states and declare events or variables. The "reference":../05_Reference/reference.html#Statechartdescriptionlanguage explains this language.

Elements that cause problems get warning and error markers attached. For more details about the problems open the *Problems View*.

h2. Simulation View

The simulation view is an interactive view to watch and control the state machine simulation. To get it open the simulation perspective. 

Start a simulation by clicking *Run* > *Run*. 

!../02_Getting_Started/images/simulation_view_active.jpg!

During the simulation in the statechart editor the active state gets a red color. The previous transition is green. The simulation view shows the events that trigger the states. You can change values here to trigger events. Beneath the table there are two clocks. One for the _virtual time_ and one for the _real time_ and a slider to change virtual time.

You can also select an _event driven_ or _cycle based_ run configuration.

h2. YAKINDU SCT Nature

YAKINDU model projects are associated with the *YAKINDU SCT nature*. On projects with *YAKINDU SCT nature* _.sct_ and _.sgen_ files are automatically build and checked for problems. So you get fast feedback during editing. You can toggle the SCT nature by right clicking *Configure* > *Add* or *Remove YAKINDU SCT Nature* on the project.




