-1

My system has two state machines, one master, one slave. And the states between the master and the slave are not one to one. The possible interactions are as follows.

  • If the master transits to certain master state, it will notify the slave to transit to certain slave state

  • The slave may request the master to enter certain master state; if master succeeds, the master will notify the slave to enter certain slave state.

  • The slave may request certain data from master

What is the proper UML diagram to describe those interactions? Statechart diagram is limited to state transition only and can't describe the request from the slave(either state transition or data); Interaction diagram is limited to class/object and can't applied on state.

www.admiraalit.nl
  • 5,768
  • 1
  • 17
  • 32
yk42b
  • 179
  • 3
  • 15

2 Answers2

0

You can describe those interactions using two UML state machine diagrams, one for the master and one for the slave. For example, to specify that a transition from state Idle to state Busy of the slave takes place upon receipt of signal Req from master, you draw a transition from Idle to Busy with transition label Req in the slave's state machine diagram. To specify that master sends signal Req when it enters state X, you write entry/Req inside the state symbol of X in the master's state machine diagram.

Alternatively, you may draw elements for sending and receiving signals (see sections 14.2.4.8.2 to 14.2.4.8.5 of UML 2.5.1 specification):

signal-symbols

For example, to go from Idle to Busy upon receipt of signal Req with parameter id:

signal-receipt

You also described the situation where the slave requests certain data from the master. For this, you need a third diagram (or a textual specification) of the interface provided by the master and required by the slave, for example:

interface

In the slave's state machine diagram, you can call an operation defined in the interface. For example, to call the read operation of master when the slave enters state Busy and store it in local variable x, write entry/x:=master.read() inside the state symbol X.

For an introduction to the UML state machine diagram, please refer to wikipedia

www.admiraalit.nl
  • 5,768
  • 1
  • 17
  • 32
0

What you describe is the interaction between the master and the slave.

There is no single solution to that and it is really difficult to have at the same picture both all possible states and the logic of the transaction (actually I don't think it is possible at all).

The main diagrams to be considered here would be:

  1. Sequence diagram depicting the process of requesting/changing states (you may have few showing various triggers for the change and use alt/opt to show further behaviour)
  2. Activity diagram depicting how the process of state changing is handled
  3. Interaction overview diagram with state changes being shown at the "activity" level and negotiation between the master and the slave in the "sequence" parts.

Especially the last one is an interesting option here as it combines possibilities of activity and sequence diagrams. Usually it's an overkill but might be the best idea for your specific case.

In addition to those you may also use the state machine diagram (two, one for master and one for slave) but they will not be able to show the interaction between the two entities. It might be useful though to explain what are the available states.

If it is not clear feel free to comment this answer asking for more details. I will try building example of each of those diagrams then (activity diagram example you already have in the answer by www.admiraalit.nl).

Ister
  • 5,958
  • 17
  • 26