Methodology

Overview

This section assumes that you have already read Introduction and know that UniMod defines methodology for modeling applications behavior using SWITCH-technology adapted for UML.

UniMod methodology describes how to create UML diagrams to model application behaviour. Also methodology defines interpretation rules (operational semantics) for created models. Tools implement these interpretation rules and allow to execute created models. All this stuff let us to say that UniMod project implements Executable UML idea.

SWITCH-technology

To create methodology adaptation of SWITCH-technology diagrams for UML-notation is described. Also operational semantics defined by SWITCH-technology is changed to sutisfy changed adapted diagrams. SWITCH-technology defines two types of diagrams for describing application behavior:

  • Connectivity schema - defines state machine interface;
  • Transition graph - defines state machine logic.

If system consists of more then one state machine, state machines interconnection schema must be created.

Connectivity Schema

Connectivity schema describes relations between finite state machines, event sources and controlled entities. Event sources must be placed on the left. Controlled entities must be placed on the right. State machines must be labeled with AR, where R – state machine number, and placed in the middle of schema.

For every event that produced by event sources link between event source and state machine is created. Link directed into state machine and labeled with event symbol eN, where N – is event number, and long event description.

For every input action link between controlled entity that owns input action and state machine is created. Link directed into state machine and is labeled with symbol of input action - xM, where M - is input action number.

For every output action link between state machine and controlled entity that owns output action is created. Link directed into controlled entity and labeled with symbol of output action - zK, where K – is output action number.

Connectivity schema may contain arbitrary amount of event sources, state machines and controlled entities.

Transition Graph

Transition graph is created for every state machine defined on connectivity schema. Transition graph describes combined machines (C-machines or Moore-Mealy machines).

Transition graph contains states and transitions between states. States is labeled with its name, list of output actions that will be executed on-enter and list of included state machines symbols. Transitions are labeled with Boolean condition that trigs transition and list of output actions that will be executed if transition trigs. Boolean condition contains logic formula in basis AND, OR, NOT. Terms of formula are symbols of events, symbols of input actions and 1 (TRUE), 0 (FALSE) constants.

A lot of sample projects based on SWITCH-technology may be found at SWITCH-technology home site http://is.ifmo.ru/projects_en/.

Adaptation process of described diagrams is introduced below.

Executable UML

Connectivity Schema Adaptation

SWITCH-technology connectivity schema is converted into UML Class diagram. To do so, event source stereotype, state machine stereotype and controlled object stereotype are introduced. Instances of these classes (objects) are placed on UML Class diagram. It’s very important to note, that just objects are placed on Class diagram, because, for example, if there are two different state machines that drive the same controlled object, they must share the same instance of controlled object in runtime.

Event source is connected with state machine with the only directed association without label. State machine is connected with controlled object with the only directed association labeled oP, where P – is local number of controlled object from state machine point of view. State machine use this label as controlled object identifier to refer to controlled object instance. Also such approach allows two different state machines to refer to the same controlled object using different symbols.

Controlled object class has two types of public methods: xM() – input action method, where M – is input action number, and zK() – output action method, where K – is output action number. Method name is used as action's symbol. Long action description may be defined as method tag – standard UML extension mechanism.

State machine object has name AR, where R – state machine number. State machine class has no methods. State machine object name is used as state machine symbol.

Transition Graph Adaptation

SWITCH-technology Transition graph is converted into UML Statechart diagram. Statechart diagram syntax changed in the following way: state may have two types of internal transitions - enter and include, state can’t has concurrent regions, initial and final pseudo states - are the only pseudo states allowed on diagram.

Enter internal transition defines list of output actions to be executed on-enter into state. Output actions are linked to methods of controlled objects using identifiers in form oP.zK, where oP is controlled object's symbol defined on Class diagram and zK – is controlled object method's name. Labels oP.zK and oP.xK are called fully qualified method identifier (FQMI).

Include internal transition defines list of included state machines symbols. State machines referred as AR.

Transition label has the following syntax: eN[guard_condition]/list_of_FQMI, where eN – is reference to method of event source, guard_condition – is Boolean expression in basis AND, OR, NOT, list_of_FQMI – the same list as list defined for state enter internal transition. Terms of guard_condition are FQMI, first order predicates <, >, <=, >=, !=, ==, Boolean constants and natural numbers constants.

Example of well-formed transition label: e1[o1.x1 && o2.x2 || o1.x10>10]/o1.z1,o2.z1.

Statechart has number of UML object constraint language (OCL) constraints that must be satisfied for well-specified diagram. Some additional constraints are introduced by UniMod:

  • all states on diagram must be attainable;
  • set of state outgoing transitions must be consistent;
  • set of state outgoing transitions must be complete.

The methodology Step-by-Step Process

Methodology suggests the following step-by-step process for creating application model:

  • analyze problem domain, create conceptual model using classical approches (Object-Oriented Methods: Principles and Practice (3rd Edition) by Ian Graham);
  • extract event sources, controlled objects and state machines from conceptual model. Event sources are active, they actuate state machines. Controlled objects are passive, they make actions only as a reaction to state machine calls. State machines react to event providers influence and, depending on it's active state and value of input actions, call controlled objects methods;
  • create UML Class diagram, put event sources on the left, put controlled objects on the right, put state machines in the middle, create associations between event sources, state machines and controlled objects. This Class diagram called connectivity diagram;
  • assign names to links between state machines and controlled objects using symbols like oP;
  • define and implement public methods of two main types for every controlled object: input actions xM() and output actions zK();
  • create one Statechart diagram per state machine;
  • implement controlled objects and event source on Java language;
  • automatically create XML-description, that describes diagrams content, for further interpreting.

Model Interpretation Rules

Model interpretation rules are described below:

  • On model startup, all event providers is initialized. After this, them start to send events to connected state machines.
  • Every state machine starts it's life in initial state and ends in final state.
  • On event receiving, state machine selects all outgoing transitions from active state, labelled with event that was received.
  • State machine iterates through all selected transitions and computes Boolean expressions wrtitten on them, till true expression will be found.
  • If transition with true Boolean expression is found, state machine executes output actions wrtitten on transition and pass into new state. In new state state machine executes on-enter output action wtitten in this state and executes included state machines.
  • If transition in not found, state machine continues transition search from super state of active state.
  • If root state machine reaches final state, it disposes all event providers. After disposing, system must stop it work.