Live Sequence Charts for Mermaid

Write a chart on the left. The diagram updates as you type.

Chart text

Saved in this browser
Syntax cheat-sheet

Chart

lsc-alpha universal
First line. Mode: universal (must happen), existential (can happen) or subchart.
title Car departure
Shown in the header tab.
defaults cold
Make elements cold unless marked hot. The default is hot.
accTitle: … / accDescr: …
Accessible title and description; accDescr { … } spans lines.
%% comment
Whole lines only.

Declarations

instance car as "Car", carHandler
Columns, in order. participant works too; actor draws a stick figure.
var car.mode: {pass, stop}
Types: bool, int, int[0..9], {a, b}.
visible car ->> carHandler: arrivReq
An event the chart constrains but doesn't show.
activation when car.idle
Condition that activates the chart.
activation on env ->> car: setDest
Message that activates it, drawn entering the frame.
prechart … end
Scenario that, once matched, makes the body required. No hot/cold inside.

Messages

car ->> carHandler: departReq
Synchronous: filled arrowhead.
car -) cruiser: start(90)
Asynchronous: open arrowhead.
cold car -) cruiser: start
Cold message: dashed line. Dashes never mean replies.
send #a client -) server: req
receive #a server from client: req
Send and receipt at separate points; the label pairs them.
env -) car: setDest
To or from the environment, drawn to the frame edge.

Conditions and temperature

condition car, proxSensor: car.mode = stop
Hot: must hold. Shared by the instances listed.
cold condition car: "stops->isEmpty"
Cold: exits the block when false. Quoted text is not checked.
cold progress car
Make the line cold from here until the next progress or the block's end.
Operators
= != < <= > >= + - * / and or not ( )

Blocks

subchart "Retry" over a, b repeat * … end
Repeat * loops until a cold condition is false; also an int or an int variable.
if car: car.mode = stop … else … end
Guarded alternatives.
coregion car … end
Events on car in any order.
simultaneous controller … end
Events at one location on the listed instances.

Lifetimes and notes

create carHandler as "Handler" by terminal
Starts a lifetime with a “new” arrow.
destroy carHandler
Ends it with an X.
timeout car: tm(90)
Square self-loop.
note over a, b: text
Also note left of a and note right of a.

Diagram