umlstate-machinesequence-diagram

How can i represents a sequence diagram that has nested alternative in State machine?


I have created a sequence diagram, the diagram has a alt where the therapist can choose to control a video recorder or talk to a couple, inside that alt there are two alt, where the first alt is talk to A or talk to B, and the second alt is control to A or control to B

Sequence diagram: enter image description here

Reference

enter image description here

state machine:

enter image description here

I am not sure, how i can make a loop for the statemachine, I have tried making a new state after Greeting B, which i call session, the idea was that after each of the other states it is possible to go to session state, and from there go to the other states, representing some kind of loop.

But I come across this problem, i made two new lines in the sequence diagram so i can go to another state after greeting, when I am at the state talking to B, i can go back to session, using the input replyB, but if i now am in session and want to go to talking to A i have no idea what input to use and how

enter image description here

Update on statemachine:

enter image description here


Solution

  • Sequence diagrams model a scenario of interactions between instances. State diagrams document states of an instance, a class or a system and how you may transition from one state to the next. There is therefore no trick to translate the sequence into states. It all depends on the focus of your state diagram and the states that would be relevant.

    I don't have the full picture of your scenario, but if the state diagram is for the Therapist, you could imagine the state:

    The questing remains, what triggers the change of states ? A message received is a good trigger, but a message sent doesn't tell what event made the therapist send the message.

    In any case, the states must have different names (so no two states s1).

    Forks are meant for parallel states, for example when giving control to a composite state with orthogonal regions. This seems not needed here. Decision nodes are for alternatives, e.g. when a same outgoing transition could reach one of several states depending on some conditions. The semantic is similar to alt, but imho, they should best be avoided in state diagrams and be kept for activity diagrams.