The In Use composite state defines the dialing behaviour
of the telephone.
In this step, you will do the following:
- add an entry to the composite state
- populate the composite state with the necessary states and transitions
- From the palette, click the composite state icon (
) and drop it on the canvas below
the other states. A composite state appears like the one shown
here.

- Rename the composite state to In Use, and
add an entry called Initialize with the following code:
dialedNumber = new String();
- In the composite state, rename InitialState2,
to In Use Start, and FinalState2 to Too
long dialing.
- Drop new states into the composite state with the following names:
- Dial Tone Playing
- Dialing
- Connecting
- Talking
- Drop a final state into the composite state called In
Use End. Your composite state should look like this
image:

- Add an entry to the Connecting state called TryToConnect with
the following code:
System.out.println("Connecting...");
- Add an entry to the Talking state called Connected with
the following code:
java.lang.String __result__1 = "Connected to ";
java.lang.String __result__3;
{// append text
__result__3 = __result__1.concat(dialedNumber);
}
{// print to log
System.out.println(__result__3);
}
- Add an entry to the In Use End state called CallEnded with
the following code:
System.out.println("Call ended...");
- Link the states within the composite state as follows:
- Link the In Use Start state to the Dial
Tone Playing state.
- Create an action called PlayDialTone on this transition
with this code:
System.out.println("Playing dial tone.");
- Link theDial Tone Playing state to the Dialing state.
- Drop the operation called digit onto this transition.
- Create an action called AppendDigit with this code:
java.lang.String __result__2 = digit_Input_digit.getString("digit");
java.lang.String __result__3;
{// append text
__result__3 = dialedNumber.concat(__result__2);
}
dialedNumber = __result__3;
- Link theDial Tone Playing state to the Too
long dialing state.
- Create a timeout called No dialing with a literal
duration of 30 seconds.
- Link theDialing state to the Too
long dialing state.
- Create a timeout called Too long dialing with a
literal duration of 30 seconds.
- Link theDialing state to the Connecting state.
- Create a condition called FinishedDialing with
the following code:
int __result__2;
{// text length
__result__2 = dialedNumber.length();
}
byte __result__3 = 4;
boolean __result__4;
{// equal to
__result__4 = __result__2 == __result__3;
}
return __result__4;
- Create and configure a self transition on the Dialing state. Hover over the Dialing state until a yellow grabber
appears. Left-click your mouse to create the beginning of the transition,
and then drag the cursor back over the state and click it. A self transition
will appear as shown in this image:

- Drop the operation called digit onto this transition.
- Create an action called AppendDigit with this code:
java.lang.String __result__2 = digit_Input_digit.getString("digit");
java.lang.String __result__3;
{// append text
__result__3 = dialedNumber.concat(__result__2);
}
dialedNumber = __result__3;
- Link the Connecting state to the Talking state.
- Create a condition called NotBusy and configure
it as follows:
- In the Details tab for the NotBusy condition, click
the Invoke radio button.
- Similarly, click the Invert result check box.
- From the Reference drop down list, select TelcoConnectionService.
- From the Operation drop down list, select isBusy.
- From the Variables column, click on dialedNumber,
click to in the Operation input column,
and click Set. Your properties area should look like
the one shown in this image:

- Similarly, create a action called Connect, and
configure an invoke for it as follows:
- Select the TelcoConnectionService reference and
the connect operation.
- Link the from operation input to the telephoneNumber variable.
- Link the to operation input to the dialedNumber variable.

- Click the Output parameter radio button, and link
the connectOK operation output to the dummyBoolean variable.
- Link the Connecting state to the In
Use End state.
- Create a condition called Busy, and configure an invoke for
it as follows:
- Select the TelcoConnectionService reference and
the isBusy operation.
- Link the to operation input to the dialedNumber variable.

- Create an action called NoConnection with the following
code:
System.out.println("The number was busy.");
- Link theTalking state to the In
Use End state.
- Drop the remoteDisconnect operation onto this transition.
- Create an action called NotifyDisconnected with
the following code:
System.out.println("The party you were talking to has disconnected.");
The In Use composite state should look like the one in this image
when you are finished:
