MSCGEN (message sequence charts generator)

4. MSCGEN (message sequence charts generator)#

mscgetnはblockdiagとは独立なプログラムで、ネットワークプロトコルのようなメッセージ シークエンスを表示する画像を生成します。 sphinxcontrib-mscgenとともにmscgenプログラムをインストールする必要があります。 mscgenはblockdiagとおなじくgraphvizの DOT formatの影響をうけた形式の指令を使います。

sphinxconrib-mscgen example.

msc {
hscale="0.5";
a,b,c;
a -> b [ label = " ab()" ];
b -> c [ label = "bc(TRUE)" ];
c => c [ label = "process()" ];
}

リスト 4.1 mscgenへの入力例#
.. msc::
   hscale="0.5";
   a,b,c;
   a -> b [ label = " ab()" ];
   b -> c [ label = "bc(TRUE)" ];
   c => c [ label = "process()" ];

Alice -\\ Bob : ab()
Bob  -// Charie : bc(TRUE)
Charie --> Charie : process()

図 4.1 PlantUML で書き換えて見ます。#

Quote from website:

Mscgen is a small program that parses Message Sequence Chart
descriptions and produces PNG, SVG, EPS or server side image maps
(ismaps) as the output. Message Sequence Charts (MSCs) are a way
of representing entities and interactions over some time period
and are often used in combination with SDL. MSCs are popular in
Telecoms to specify how protocols operate although MSCs need not
be complicated to create or use. Mscgen aims to provide a simple
text language that is clear to create, edit and understand, which
can also be transformed into common image formats for display or
printing.

4.1. MSC for some fictional process#

msc{
hscale = "2";
a,b,c;
a->b [ label = "ab()" ] ;
b->c [ label = "bc(TRUE)"];
c=>c [ label = "process(1)" ];
c=>c [ label = "process(2)" ];
...;
c=>c [ label = "process(n)" ];
c=>c [ label = "process(END)" ];
a<<=c [ label = "callback()"];
---  [ label = "If more to run", ID="*" ];
a->a [ label = "next()"];
a->c [ label = "ac1()\nac2()"];
b<-c [ label = "cb(TRUE)"];
b->b [ label = "stalled(...)"];
a<-b [ label = "ab() = FALSE"];
}

skinparam responseMessageBelowArrow true
a->b: ab()
b->c: bc(TRUE)
c -->c: process(1)
c -->c:process(2)
|||
c--> c: process(n)
c--> c: process(END)
a <<--c: callback()
==  If more to run*  ==
a<-a: next()
a->c: ac1() \nac2()
b<-c: cb(TRUE)
b->b: stalled(...)
a<-b: ab() = FALSE

図 4.2 PlantUML version#

Example rendered MSC

# Fictional client-server protocol

msc {
arcgradient = 8;

a [label="Client"],b [label="Server"];

a=>b [label="data1"];
a-xb [label="data2"];
a=>b [label="data3"];
a<=b [label="ack1, nack2"];
a=>b [label="data2", arcskip="1"];
|||;
a<=b [label="ack3"];
|||;
}

title  Fictional client-server protocol

participant Client as a
participant Server as b

a --> b: data1
a ->x b: data2
a --> b: data3
a <-- b: ack1, nack2
a -->(10) b: data2
a (5)<-- b: ack3

図 4.3 Fictional client-server protocol#

msc{
# comment in mscgen code
A, B, C, D;

// other format for comment.
A -> B [ label ="message"];
B => C [ label ="method or function call"];
C >> D [ label ="method or function return value"];
D =>> C [label = "Callback"];
C :> B  [label = "Emphasized message"];
B -x A  [label = "lostmessage"];
... [label="omitted"];

A ->*  [label="broadcast"];

||| [label="extra vertical space"];

A box A [label="box"],
B rbox B [label="rbox"],
C abox C [label="abox"],
D note D [label="note"];
--- [label="comment"];
A abox B [label="abox", textbgcolour="#ff7f7f"];
B rbox C [label="rbox", textbgcolour="#7fff7f"];
C note D [label="note", textbgcolour="#7f7fff"];
}

A -> B : "message"
B --> C: method or function call
C ->> D: method or function return value
D -->> C: Callback
C -> B:  Emphasized message
B ->x A : lostmessage
... omitted ...
!pragma teoz true
A -> B
& B -> C :broadcast
& C -> D
|||
...  extra vertical space ...
|||
note over A : note
/ hnote over B : hnote
/ rnote over C : rnote
/ rnote over D
 Log Note
 with multiple lines.
 end rnote
 ... comment ...

hnote over A, B #ff7f7f: hnote
rnote over B, C #7fff7f : rnote
note over C, D #7f7fff: note
hnote across #green: hnote accross