Für den Startpunkt und den Endpunkt im Zustandsdiagramms können Sie das Symbol [*] verwenden. Verwenden Sie --> um Pfeile zu definieren.
@startuml
[*] --> State1
State1 --> [*]
State1 : this is a string
State1 : this is another string
State1 -> State2
State2 --> [*]
@enduml
Change state rendering
You can use hide empty description to render state as simple box.
@startuml
hide empty description
[*] --> State1
State1 --> [*]
State1 : this is a string
State1 : this is another string
State1 -> State2
State2 --> [*]
@enduml
Verschachtelter Zustand
Ein Zustand kann auch verschachtelt werden. Dies funktioniert mit dem state Schlüsselwort und den geschweiften Klammern.
The stereotype <<choice>> can be used to use conditional state.
@startuml
state "Req(Id)" as ReqId <<sdlreceive>>
state "Minor(Id)" as MinorId
state "Major(Id)" as MajorId
state c <<choice>>
Idle --> ReqId
ReqId --> c
c --> MinorId : [Id <= 10]
c --> MajorId : [Id > 10]
@enduml
Stereotypes full example [choice, fork, join, end]
@startuml
state choice1 <<choice>>
state fork1 <<fork>>
state join2 <<join>>
state end3 <<end>>
[*] --> choice1 : from start\nto choice
choice1 --> fork1 : from choice\nto fork
choice1 --> join2 : from choice\nto join
choice1 --> end3 : from choice\nto end
fork1 ---> State1 : from fork\nto state
fork1 --> State2 : from fork\nto state
State2 --> join2 : from state\nto join
State1 --> [*] : from state\nto end
join2 --> [*] : from join\nto end
@enduml
You can added point with <<entryPoint>> and <<exitPoint>> stereotypes:
@startuml
state Somp {
state entry1 <<entryPoint>>
state entry2 <<entryPoint>>
state sin
entry1 --> sin
entry2 -> sin
sin -> sin2
sin2 --> exitA <<exitPoint>>
}
[*] --> entry1
exitA --> Foo
Foo1 -> entry2
@enduml
Pin [inputPin, outputPin]
You can added pin with <<inputPin>> and <<outputPin>> stereotypes:
@startuml
state Somp {
state entry1 <<inputPin>>
state entry2 <<inputPin>>
state sin
entry1 --> sin
entry2 -> sin
sin -> sin2
sin2 --> exitA <<outputPin>>
}
[*] --> entry1
exitA --> Foo
Foo1 -> entry2
@enduml
You can added expansion with <<expansionInput>> and <<expansionOutput>> stereotypes:
@startuml
state Somp {
state entry1 <<expansionInput>>
state entry2 <<expansionInput>>
state sin
entry1 --> sin
entry2 -> sin
sin -> sin2
sin2 --> exitA <<expansionOutput>>
}
[*] --> entry1
exitA --> Foo
Foo1 -> entry2
@enduml
Mit dem -> Symbol können waagerechte Pfeile erzeugt werden. Man kann die Richtung der Pfeile außerdem mit der folgenden Syntax festlegen:
-down-> (default arrow)
-right-> or ->
-left->
-up->
@startuml
[*] -up-> First
First -right-> Second
Second --> Third
Third -left-> Last
@enduml
Man kann die Länge eines Pfeils verkürzen, in dem man nur den ersten Buchstaben der Richtung verwendet (zum Beispiel, -d- anstelle von -down-) oder die ersten beiden Buchstaben (-do-).
Beachten Sie, dass sie mit dieser Möglichkeit sorgfältig umgehen: GraphViz liefert normalerweise recht gute Ergebnisse, ohne das manuell eingegriffen werden muss.
Notizen können mit den note left of, note right of, note top of, note bottom of Schlüsselworten an die Zustände gebunden werden. Die Notizen können sich auch über mehrere Zeilen erstrecken.
@startuml
[*] --> Active
Active --> Inactive
note left of Active : this is a short\nnote
note right of Inactive
A note can also
be defined on
several lines
end note
@enduml
Es ist auch möglich, freistehende Notizen hinzuzufügen.
@startuml
state foo
note "This is a floating note" as N1
@enduml
Note on link
You can put notes on state-transition or link, with note on link keyword.
@startuml
[*] -> State1
State1 --> State2
note on link
this is a state-transition note
end note
@enduml
Mehr über Notizen
Es ist auch möglich, Notizen für einen verbunden Zustand zu erstellen.
@startuml
[*] --> NotShooting
state "Not Shooting State" as NotShooting {
state "Idle mode" as Idle
state "Configuring mode" as Configuring
[*] --> Idle
Idle --> Configuring : EvConfig
Configuring --> Idle : EvConfig
}
note right of NotShooting : This is a note on a composite state
@enduml
Inline color
@startuml
state CurrentSite #pink {
state HardwareSetup #lightblue {
state Site #brown
Site -[hidden]-> Controller
Controller -[hidden]-> Devices
}
state PresentationSetup{
Groups -[hidden]-> PlansAndGraphics
}
state Trends #FFFF77
state Schedule #magenta
state AlarmSupression
}
@enduml