21.01.2022 Views

Sommerville-Software-Engineering-10ed

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

618 Chapter 21 ■ Real-time software engineering

Timeout

Card

inserted

into reader

Reading

do: get CC

details

Initializing

do: initialize

display

Waiting

do: display

welcome

Card removed

Validating

do: validate

credit card

Card OK

Hose out of holster

Ready

Hose in

holster

Nozzle

trigger on

Delivering

do:

deliver fuel

update display

Timeout

Invalid card

Nozzle trigger off

Resetting

do: display CC

error

Stopped

Nozzle trigger on

Payment ack.

Paying

do: debit

CC account

Hose in

holster

Figure 21.5 State

machine model of a

petrol (gas) pump

The names chosen in the state machine diagram are descriptive. The associated

information indicates actions taken by the system actuators or information that is

displayed. Notice that this system never terminates but idles in a waiting state when

the pump is not operating.

The fuel delivery system is designed to allow unattended operation, with the following

sequence of actions:

1. The buyer inserts a credit card into a card reader built into the pump. This causes

a transition to a Reading state where the card details are read and the buyer is

then asked to remove the card.

2. Removal of the card triggers a transition to a Validating state where the card is

validated.

3. If the card is valid, the system initializes the pump and, when the fuel hose is

removed from its holster, transitions to the Delivering state, where is ready to

deliver fuel. Activating the trigger on the nozzle causes fuel to be pumped; this

stops when the trigger is released (for simplicity, I have ignored the pressure

switch that is designed to stop fuel spillage).

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!