When it is in the On Hook state, the state machine is quite
simply waiting for an event to happen. An offHook operation will signal
that the phone is about to be used, and an unplug operation means that
it is going to be disconnected.
In this step, you will do the following:
- rename the automatically generated states
- add an entry for the On Hook state
- add an operation and an action to the transition into the On Hook state
- add an operation and an action to the transition that exits
the On Hook state
- Click the InitialState1, and rename it to Start.
- Similarly, rename FinalState1 to End,
and State1 to On Hook.
- Add and configure an entry for this state
- Click On Hook, and select the Add
an Entry icon from the action menu that pops up.
- Click this new entry, and rename it to ReceiverOnHook.
- In the Properties view, click the Details tab,
and click the Java radio button.
- Paste the following code into the Java editor:
System.out.println("Pick up receiver to start dialing.");
- Create an action on the first transition.
- Click the transition between the Start and On Hook states.
- From the action menu, click the Add an Action icon,
and name it InitializeTelephoneNumber.
- Add the following code to the Java editor:
telephoneNumber = init_Input_id;
- Create an action on the second transition.
- Drag and drop the unplug operation from
the Interfaces area to the transition between the On Hook and End states.
- Create an action named end with the following
code:
java.lang.String __result__1 = "Unplugged, ending";
{// print to log
System.out.println(__result__1);
}
Your states and transitions should look like the ones in this image:
