YAKINDU SCT 2 Reference

State chart elements

In the following the state chart elements of the YAKINDU SCT 2 editor are described. The meta model of the YAKINDU SCT 2 is the model of finite state machines. It is based on the view of a system that is defined by a finite number of states. The behavior of that system is based on the active states. These states are determined by the history of the state machine. Very important are the theoretical models for state machines by Mealy and Moore. Mealy state machines associate actions with transitions. Moore machines associate actions with states (entry, exit). In the YAKINDU SCT 2 both is possible.

The YAKINDU SCT 2 meta model is designed similar to the UML state chart meta model with the following differences

The model interpreter and different flavors of generated code follow these same core semantics.

Please refer to the description of the UML Statecharts for more details.

Regions

As already mentioned the YAKINDU state charts are self contained. They are organized in regions. Due to this it is possible to organize multiple state machines in different regions and to run them concurrently.

States

States are the central elements of a state machine. A state has to be placed inside a region and needs a unique name inside this region. During simulation each state can be active or passive. An active state has actions that are accomplished. Either an action is carried out on entering a state, during active state or on exit.

Transitions

A transition is the transfer of one state to another. Transitions are diagrammed as arrows and can carry events and actions but must not.

The syntax of events and actions is defined by a textual description language (#Statechartdescriptionlanguage). Please refer to the documentation section Events for more details. For more details on Actions refer to the chapter Actions.

If a state has more than one outgoing transition without event that transition is carried out first that was modeled first.

Initial state and final state

Initial and final states are pseudo states, because the state chart does not rest on them. Pseudo states express characteristics that are impossible to express by simple states.

The initial state is always the first state that is active during interpretation or simulation of the state machine. An initial state can only have one outgoing transition and no incoming. This transition has no events or actions.

Inside a region only one initial state is allowed, but every region can have an initial state.

Choice

Choice is also a pseudo state. It can be used to model a conditional path. Choice nodes divide a transition into multiple parts.

Usually the first transition points towards the choice node. One of the choice outgoing transitions can carry a condition.

Junction

A junction is a pseudo state do combine transitions. This is very comfortable if a state machine has many similar transitions. Junctions add clear arrangement to the state machine.

Composite State

A composite state is a state that is composed of other state machines. These are also organized in regions. Besides the simple composite state YAKINDU knows two kinds of composite states: orthogonal state and submachine states.

Composite states contain other state machine branches.

Orthogonal states

In the context of state machines orthogonal states are states that are independent from each other. The most famous example is the keyboard example:

Submachine states

Submachine states may contain complete state machines. Here the user can chose another state machine to be included or create a new sub statemachine. During simulation only the top level statemachine is interpreted. It is not possible to jump to the sub level state machines and back.

Shallow History

The shallow history state is a pseudo state that is placed inside regions of composite states. It is used to ‚remember’ the last active state inside a composite state. So it is possible to jump to this state instead of starting at the inner entry state again. The following example of a questionaire answering will explain this:

The interesting parts in this state chart are the events checkProgress and goon. CheckProgress jumps back to the init state while assigning the current progress count to the variable temp. goon jumps to the shallow history state that was placed inside the composite state.

On triggering the goon event the last active state is activated again.

Deep History

Deep history is similar to shallow history but more complex. With a deep history the latest state of multiple nested states is remembered.

Statechart description language

The textual description language is used to declare and describe behaviors in the state machine. It is case sensitive.

Typesystem

The language has an integrated small typesystem with the following simple types:

So events and variables can be declared with types:

var intVar : integer
var realVar : real
var boolVar : boolean
var stringVar : string
var voidVar : void
event addInt : integer
event checkValidity : boolean
 

Expressions

Expressions can be defined similar to other programming languages. The language offers operators to define logical expressions, bitwise arithmetic, and arithmetic expressions and bit shifting.

Logical expressions are similar to other programming languages. The return type is boolean. In the following there are some examples of these:

Logical AND

var1 && var2

Logical OR

var1 ||  var2 

Logical NOT

!var1 

Conditional expression

var1 ? var2 : 23 

Bitwise XOR

var1 ^ var2

Bitwise OR

var1 | var2

Bitwise AND

var1 & var2

Logical Relations and Shift Operators

less than <
equal or less than <=
greater than >
equal or greater than >=
equal ==
not equal !=
shift left <<
shift right >>

Binary arithmetic operators

plus +
minus -
multiply *
divide /
modulo %

Unary arithmetic operators

positive +
negative -
circa ~

Statements

A statements can be either an assignment, raising an event or call an operation. The language has the following assignment operators:

An event is raised by the keyword raise followed by the event name and if it is an interface event the name of the interface.

An operation is called similar to other programming languages with the operation name and passing concrete parameters. The parameters can be expressions.

Scopes

Namespace

The language allows to define unique namespaces, which can be used to qualify references to the statechart.

namespace trafficlights


interface scope

Declarations in the interface scope are externally visible. They can be shared within the environment.

interface NamedInterface:
in event event1
out event event3
var variable1 : real
entrypoint entry1
exitpoint exit1


internal scope

Declarations made in an internal scope are only visible for contained states.

internal:
var localVariable1: integer
event localEvent: integer
local event localEvent2: NamedInterface.event1 || localEvent
local event localEvent3: localEvent || localEvent2 : 25
operation localOperation (integer, integer): integer
localEvent3 / raise NamedInterface.event3 :
localOperation(valueOf(localEvent),NamedInterface.variable1);

Declarations

Within scopes there can be declarations of Events, Variables, Operations, LocalReactions, EntryPoints and ExitPoints.

Events

Within interface scope events have an direction. They can either be ingoing or outgoing:

interface NamedInterface:
in event event1
out event event2

Within local scope events can carry variables:

internal:
event localEvent1 : integer

Local events can be derived from interface events or other local events and can have a value assignment:

internal:
event localEvent1: integer
local event localEvent2 = NamedInterface.event1 || localEvent1
local event localEvent3 = localEvent2 || 25

Variables

Variables can have different visibilities. They can be visible for the environment:

var variable1: real

Variables can be readonly (constants):

var readonly pi: real = 3.1415

Variables can be referenced by the environment.

var external variable3: integer = 34

Reaction Triggers

Actions are key constructs in state machines to model behavior. The YAKINDU SCT 2 knows the following kinds of actions.

after

The after trigger specifies one-shot time events.

After the specified time the reaction is triggered. An after trigger can be used in transitions of states as well in local reactions of states and statecharts. The specified time starts when the state or statechart is entered.

after 20 s

Structure:

after time ( unit )?

The time unit can be:


every

The every trigger specifies periodic time events.

The reaction is triggered periodically after the specified time. An every trigger can be used in transitions of states as well in local reactions of states and statecharts. The specified time starts when the state or statechart is entered and repeats periodically.

every 200 ms

Structure:

every time ( unit )?

The time unit can be:


always

This trigger is always true and enables a reaction to be executed in every run to completion step (RTS). It is equivalent to oncycle.


default, else

The default trigger is equivalent to the else trigger. It is intended for use for the outgoing transitions of choice pseudo states, to make sure that always an outgoing transition can be taken. It can only be be used in transitions and implies the lowest evaluation priority for that transition.


entry

An entry trigger marks actions that are carried out on entering a state or state machine.


exit

An exit trigger marks actions that are carried out on exiting a state or state machine.


oncycle

The oncycle trigger is always true and enables a reaction to be executed in every run to completion step (RTS). It is equivalent to always.


Operations

Operations can have none, one or multiple parameters. The parameters are only declarated by their type. An operation can have one return type similar to Java.

operation localOperation (integer, integer):integer
localEvent3/ raise NamedInterface3.event1

LocalReactions

Local reactions describe the internal behavior of a state. So they have internal scope. A local reaction is declared as follows:

LocalReaction: ReactionTrigger '/' ReactionEffect ('#' ReactionProperties)?

ReactionTrigger: (Event ("," Event	)* 	(=> '[' Expression ']')?) | '[' Expression ']'					

ReactionEffect:  Statement (';' Statement )* (';')?

Statement: Assignment | EventRaising | OperationCall

ReactionProperties: (EntryPoint | ExitPoint)*

Within a local reaction an interface event can be raised:

internal:
localEvent1 / raise NamedInterface.event3 : localOperation (valueOf(localEvent), NamedInterface.variable1);

Local reactions can have priority values. These are defined by a following # and the integer number of priority:

localEvent2 / NamedInterface.variable2 += 3; #1
localEvent3 / NamedInterface.variable4 += 2.0; #2

EntryPoints

Every state chart has an entry point. An entry point can be declared like the following:

entrypoint entry1


ExitPoints

Every state chart has an exit point. This exit point can be declared like the following.

exitpoint exit1

SGraph

SGraph is the metamodel for the graphical part of the statechart editor. It owns all core elements of a state machine like states, pseudostates, transitons etc. but it describes how these elements shall be shown by the editor.

SExec

SExec is the name of an intermediate execution model. This intermediate model is used behind the scenes as a foundation for the code generators and the simulation engine. This guarantees that the simulation behaves in the same way as the generated Statechart implementations. It captures the execution behavior and may also serve as the basis of custom code generators.

SGen

All generators can be customized with a generator model. This is a textual model file where generator features, like i.e. the outlet path, can be specified. The following screenshot shows an example configuration for the java code generator.

To get started with the generator model, we included a new Eclipse wizard that creates a basic configuration file with default values.

The generator model is associated with the builder. If Project > Build Automatically is checked the files are generated. In the following the specific customizing features of the generator models are explained.

Generator model for Java

The generator model for Java is used to customize the generation of Java code from the state chart model.

Feature Outlet

With the feature Outlet you define the folder the source files will be generated in:

		feature Outlet {
			targetProject = "org.terra.coffee.machine"
			targetFolder = "src-gen"			
		}

Feature LicenseHeader

With the feature Licence header you can set a licence text that is added to the headers of all generated files:

		feature licenseHeader {
			licenseText = "Copyright (c) 2012 itemis AG.
 All rights reserved."			
		}


Feature Debug

The feature debug controls the output of debug information. An important information source is the intermediate model sExec.

		feature Debug {
			dumpSexec = false			
		}

Feature FunctionInlining

		feature FunctionInlining {
			inlineChoices=true
			inlineEnterRegion=true
			inlineEnterSequences=true
			inlineEntries=true
			inlineEntryActions=true
			inlineExitActions=true
			inlineExitRegion=true
			inlineExitSequences=true
			inlineReactions=true
		}

Feature GeneralFeatures

		feature GeneralFeatures {
			EventBasedStatemachine=true
			GenericInterfaceSupport=true
			InterfaceObserverSupport=true
			RuntimeService=false
			StatemachineFactorySupport=true
			TimerService=true
		}

Feature Naming

		feature Naming {
			basePackage="org.java"
			implementationSuffix="ipl"
		}

Generator model for C

Feature Outlet

The feature is similar to the target language Java.

Feature LicenseHeader

The feature is similar to the target language Java.

Feature Debug

The feature is similar to the target language Java.

Feature CCodeFeature

		feature CCodeFeature {
			DebugType="DEBUG"
			InterfaceEventListener=false
			Singleton=true
		}

Feature FunctionInlining

Generator model for C++

Feature Outlet

The feature is similar to the target language Java.

Feature LicenseHeader

The feature is similar to the target language Java.

Feature Debug

The feature is similar to the target language Java.

Feature FunctionInlining