Question

As a newbie am trying to develop a state machine using Visio for a cd writer. below are the device operations/transactions and attached, is a diagram of what I've done so far, am unsure if its accurately represented.

Device operation 
  • Load button- causes the drawer to open and to shut if open(load an empty cdr)

  • Burn button- starts recording document on the cdr, green light comes on in the burning process
    and goes off when completed. Once cdr is burned writer stops.

  • Verify button- verifies the document previously recorded on the cdr, green light comes on in the process and goes off when completed, then device stops

  • Cancel button- stops process anytime during recording or verifying

  • Cancel button- no effect if cd writer is empty or not busy verifying or recording When powered up- CD Writer will ensure the drawer is closed

  • Burn button – has no effect when cd writer is empty and during recording or verifying process.

  • Verifying can only be started when the CD Writer is not busy recording.

    enter image description here

Was it helpful?

Solution

Visually your diagram looks like a state machine and states have good-sounding names - it's a good start. :)

The first issue I see there is the transition specification. It is definitelly not correct. State transitions in UML are specify in the folowing format:

event [guard] /action

where:

  • event (or trigger) is an external on internal "signal" that starts the transition. It can be a button activated by a user, an elapsed timer, a detected error, etc. It can even be omitted.
  • guard is a logical condition that should be fulfilled in order to start the transition. It is usually an expression returning a boolean value of tru or false. It can also be omitted.
  • action is a kind of side-effect, something that is executed when the transition is triggered. Ic can also be omitted.

Getting back to your diagram I would say that...

  1. most of the labels on your transitions should not carrry "/" as it indicates an action. There are mostly manual triggers, like "load" (pressing the button to open the drawer), "Cancel", "butn", etc.
  2. Consider some events that are triggered internally, like "burning done", or "CD loaded"
  3. You can add some guard conditions in the situations where possible
  4. I would remove all the triggers with no effect (like cancel with no CD in). It makes the diagram simplier with no loss of information
  5. States LOADED and IDLE in your case are kind of strange, weak. It is not clear what makes them different (see the example below)

Here is a diagram that I find a bit more acurate (see notes for additional comments):

enter image description here

OTHER TIPS

You need to specify explicit events as triggers of the transitions.

In the current state machine, each transition (except the one leaving the initial vertex) has an effect, but not a trigger. More accurately, they are triggered by the default completion event, and are therefore automatic.

Moreover, since all transitions react to the same event, your state machine is non-deterministic. For instance, in the state loaded, the transitions to Recording, empty, and loaded all react to the completion event. When the completion event is dispatched, these transitions are said to be conflicting, and one of them is selected non-deterministically. I am sure this is no what you want.

Read the UML Specification, and define triggers for your transitions.

  • You don't need to depict the transitions from "empty" to "empty" as transitions without any actions or state transitions would not need to be drawn in the Statemachine diagrams. (State Transition tables are often used for the checks of any missing transitions for such cases.)
  • "loaded" and "Idle" can be represented in one as a same state
  • To represent the "green light", I would write "turn on the green light" as entry action in Recording and "turn off the green light" as exit

Here's the diagram I drew. The status of tray (whether its opened or closed) should be considered in the actual model, but its not on my sample diagram below.

enter image description here

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top