Semantic of State Diagrams

0 votes
asked Oct 31, 2024 in Question / help by Peter

Hi,

I have problems to understand the semantic of the state diagrams. For example there is this example in the reference example "https://pdf.plantuml.net/PlantUML_Language_Reference_Guide_en.pdf". In this example I would expect that state Configuring is not inside state NotShooting. Why is Configuring rendered inside NotShooting?

If I simply copy the state Configuring on top of the text it renders as I would expect.

Is there an explanation on this?

Peter

1 Answer

0 votes
answered Nov 3, 2024 by The-Lu (89,080 points)

Hello P.,

Why is Configuring rendered inside NotShooting?

Because it is defining first inside `NotShooting`, as:

@startuml
state NotShooting {
  [*] --> Idle
  Idle --> Configuring : EvConfig
  Configuring --> Idle : EvConfig
}
@enduml

If that can help,

Regards,
Th.

commented Nov 3, 2024 by The-Lu (89,080 points)
commented Nov 3, 2024 by anonymous
Hello,

is is then ok to always define all states with their correct hierarchy first.

Only exemption is the transition to the init states because there is no differentiation of  init pseudo state possible.

My result would look like this:

@startuml
scale 350 width

state NotShooting {

  state Idle{

  }

  [*] --> Idle

}

[*] --> NotShooting

state Configuring {
  state NewValuePreview {
    state State1{

    }

    state State2{

    }
  }
  [*] --> NewValueSelection

}

State1 -> State2
Idle --> Configuring : EvConfig
Configuring --> Idle : EvConfig
NewValueSelection --> NewValuePreview : EvNewValue
NewValuePreview --> NewValueSelection : EvNewValueRejected
NewValuePreview --> NewValueSelection : EvNewValueSaved

@enduml

Is there anything wrong with this approach from your point of view?

Any problems to expect with how PlantUML works?

Peter
commented Nov 4, 2024 by The-Lu (89,080 points)

Hi A.,

That is OK, and conform with other approach:

  • Define first the states (and the hierarchy)
  • Then the links between states
  • with the exception of internal start/stop ([*]) links
As:
@startuml
scale 300 width

state NotShooting {
  state Idle
  [*] --> Idle
}

state Configuring {
  state NewValuePreview {
    state State1
    state State2
  }
  [*] --> NewValueSelection
}

[*] --> NotShooting
State1 -> State2
Idle --> Configuring : EvConfig
Configuring --> Idle : EvConfig
NewValueSelection --> NewValuePreview : EvNewValue
NewValuePreview --> NewValueSelection : EvNewValueRejected
NewValuePreview --> NewValueSelection : EvNewValueSaved

@enduml

Enjoy,
Regards,
Th.

...