[State Diagram] History pseudo-states

0 votes
asked Sep 17, 2018 in Wanted features by edobez (140 points)
Hello,

Is it already possible to draw pseudo-states like Deep and Shallow history on State Diagrams?

This would be a nice feature to get closer to the UML specification.

Thanks,

Edoardo
commented Sep 18, 2018 by edobez (140 points)
I later found that this is strictly related to question http://forum.plantuml.net/1665/history-pseudostate. It hasn't been answered though.

4 Answers

0 votes
answered Sep 17, 2018 by Artrax
You can use [H], but this state is not accessible from the outside of a state.

state example {

[H] --> Some

}

Other --> [H] 'Would be another state'
commented Sep 18, 2018 by edobez (140 points)
Thank you, this is something but it doesn't solve my problem since as you said you can't target the History pseudo-state from outside. This is a common state pattern named "Transition to History".
commented Sep 19, 2018 by Artrax
I know, but what you want to do is not possible with plantuml
+1 vote
answered Jan 22, 2019 by Frédéric Guérin

This is not be a perfect solution...

@startuml

hide empty description
skinparam shadowing false

skinparam state<<history>> {
    backgroundColor transparent
    borderColor transparent
    fontSize 30
}

title History Demo
[*] --> Closed
Open --> Closed

state Open {
    [*] -r-> Red
    Red -r-> Green
    Green --> Yellow
    Yellow --> Red
    state "Ⓗ" as H<<history>>
    Closed --> H
}

@enduml

As you can see below, a residual problem is that the arrow to the history state stops short of reaching to it!

image

 

0 votes
answered Aug 10, 2020 by Momeni

You can mix the <<entrypoint>> stereotype (referring to the intended composite state) and the [H] syntax (supporting the history pseudo state shape) in order to implement the "transition to history state" pattern.

Example:

@startuml
state comp {
    state en1 <<entrypoint>>
    [*] --> a
    a --> b
    b --> c
    c --> [*]
    en1 --> [H]
}

[*] --> en1
@enduml

0 votes
answered Aug 10, 2020 by Serge Wenger Work (15,770 points)

At my point of view, all you need is implemented:

@startuml
[*] -> State1
State1 --> State2 : Succeeded
State1 --> [*] : Aborted
State2 --> State3 : Succeeded
State2 --> [*] : Aborted
state State3 {
  state "Accumulate Enough Data" as long1
  long1 : Just a test
  [*] --> long1
  long1 --> long1 : New Data
  long1 --> ProcessData : Enough Data
  State2 --> [H]: Resume
}
State3 --> State2 : Pause
State2 --> State3[H*]: DeepResume
State3 --> State3 : Failed
State3 --> [*] : Succeeded / Save Result
State3 --> [*] : Aborted
@enduml
http://www.plantuml.com/plantuml/png/PP11IyD048Nl-oiUFHQADDvoa1Qg50zIpB7qC6w6AcmIoSpeGVplkbcM9knfb_VcctcydIYDQbrmv_K5cmSqIifRbnviibAXHcFUCxVSpjs8rTY_3QDcexfXzoLMeSGa6fduSK0ILdllhRCG_u_zODTt74Xf1HA4eRzk7TAB6iyc2eAog4DS7yyifoObpx_mzxHiOPx6mRD8r57FJpfW7lvugV7AOXsxNvTYBwiwaGcNRPoFwt_omFoPw8ADVJtHH-0sMxciMO-uGqDVF2K8cWVBLdVSjzQ5Fm00
...