< Previous | Next >

Introduction

This sample emulates a telephone.

A state machine is an event driven business transaction in which external operations trigger changes that guide the state machine from one discrete mode to another. Each mode is an individual state, and this mode determines what activities and operations can occur.

If you are new to state machines, then we recommend that you familiarize yourself with the editor as well as some of the building blocks that you'll be working with.

To work with the state machine sample, you can either browse the ready-made sample or you can build it yourself. These activities are described in the following topics:
This sample should take you about 60 minutes to build it yourself.

Expected results

At the completion of this sample, you will have the following business state machine in your editor:
SaleOrderTransactionStateMachine

Here is a brief description of the functionality that this diagram represents.

When the state machine begins at the Start state, the first operation is init, and it initializes the telephone.

The state machine then enters the On Hook state where it will wait for an event to happen. If the operation arrives that signals that the phone has been unplugged, then the state machine moves to the End final state. If however, the operation arrives that signals that the receiver has been taken off the hook, then the state machine moves into the In Use composite state.

The In Use composite state nests a number of states and transitions that define the dialing behaviour of the telephone. It begins with the In Use Start state, and immediately moves through the PlayDialTone action to the DialTonePlaying state. While there, it waits for the phone number to be dialed. If the digit event arrives, the AppendDigit action records the digit that has just been punched in, and the state machine moves to the Dialing state. If no digit has been dialed within a predefined period of time, then the No dialing timeout event moves the state machine to the Too long dialing final state.

There are a number of ways out of the Dialing state. If the user takes too long between entries, then the Too long dialing timeout forces a move to the Too long dialing final state. If the user enters another number, then it is recorded by the AppendDigit action, and a self-transition returns to the Dialing state to await more input. When a total of four digits have been received, the FinishedDialing condition will move the machine to the Connecting state.

The Connecting state will attempt to establish a connection with the third party. If the Busy condition evaluates to true, then a connection cannot be established, and the state machine will move to the In Use End final state. Alternatively, if the NotBusy condition is fired, then a connection is established, and the machine will move to the Talking state.

The state machine will stay in the Talking state until the call ends. There are two ways that the call can end. In the first way, the state machine will move to the Disconnected state if either of the final states in the In Use composite state are reached (The Too long dialing is reached when too much time passes between entries, and the In Use End state is reached when the call is disconnected remotely. The state machine will stay in the Disconnected state until the phone is returned to the hook).

The second way that a call can end is if the user hangs the phone up (as recorded by the onHook operation), in which case the state machine will return to the On Hook state.

Modules in this tutorial

Feedback
(C) Copyright IBM Corporation 2005, 2006. All Rights Reserved.
< Previous | Next >