使用快速序列图编辑器创建序列图

发布于 2024-08-13 17:43:55 字数 1591 浏览 5 评论 0原文

有人有快速序列图编辑器的经验吗?即时显示+文本源代码+Java实现的组合对我来说很有吸引力,但我不太明白如何让语法做我想要的事情,而且文档也不是很清楚。这是一个人为的示例:

al:Actor
bill:Actor
atm:ATM[a]
bank:Bank[a]

al:atm.give me $10
atm:al has $3=bank.check al's account balance
al:atm.what time is it
atm:al.it's now
atm:al.stop bugging me
atm:al.you only have $3
atm:bill.and don't you open your mouth
bill:atm.who asked you?
bill:atm.give me $20
al:atm.hey, I'm not finished!
atm:bill has $765=bank.check bill's account balance
atm:yes I'm sure, bill has $765=bank.hmm are you sure?
atm:bill.here's $20, now go away
atm:great, he's a cool dude=bank.I just gave Bill $20
al:atm.what about my $10?
atm:al.read my lips: you only have $3

这是单线程模式下 QSDE 的结果:

single-threaded

和多线程模式下的 结果- 线程模式:

multi-threaded

我想我不清楚这些竖条的开始/结束是什么。我遇到的情况是单线程的,但涉及状态,并且所有消息都是异步的。我想这意味着我应该使用外部对象来表示该状态及其生命周期。我想要的是一个时间线来表示消息序列

  1. al:atm.给我 10 美元
  2. atm:bank.检查 al 的帐户余额
  3. bank:atm.al 有 3 美元
  4. atm:al.你只有 3 美元

和另一个时间线来表示消息序列

  1. bill:atm.给我 20 美元
  2. atm:bank.check 账单账户余额
  3. bank:atm.bill 有 765 美元
  4. atm:bank.hmm 你确定吗?
  5. 银行:atm.是的,我确定,比尔有 765 美元
  6. atm:比尔。这里有 20 美元,现在走开
  7. atm:银行。我刚刚给了比尔 20 美元
  8. 银行:atm.太棒了,他是一个很酷的家伙

,其他“俏皮话”代表其他人我现在不关心的各种消息。

有没有办法用 QSDE 来做到这一点?

Anyone have experience with Quick Sequence Diagram Editor? The combination of instant display + text source code + Java implementation is very attractive to me, but I can't quite figure out how to make the syntax do what I want, and the documentation's not very clear. Here's a contrived example:

al:Actor
bill:Actor
atm:ATM[a]
bank:Bank[a]

al:atm.give me $10
atm:al has $3=bank.check al's account balance
al:atm.what time is it
atm:al.it's now
atm:al.stop bugging me
atm:al.you only have $3
atm:bill.and don't you open your mouth
bill:atm.who asked you?
bill:atm.give me $20
al:atm.hey, I'm not finished!
atm:bill has $765=bank.check bill's account balance
atm:yes I'm sure, bill has $765=bank.hmm are you sure?
atm:bill.here's $20, now go away
atm:great, he's a cool dude=bank.I just gave Bill $20
al:atm.what about my $10?
atm:al.read my lips: you only have $3

Here's the result from QSDE in single-threaded mode:

single-threaded

and in multi-threaded mode:

multi-threaded

I guess I'm not clear what starts/ends those vertical bars. I have a situation which is single-threaded, but there's state involved, and all the messages are asynchronous. I guess that means I should use an external object to represent that state and its lifetime. What I want is for one timeline to represent the message sequence

  1. al:atm.give me $10
  2. atm:bank.check al's account balance
  3. bank:atm.al has $3
  4. atm:al.you only have $3

and another timeline to represent the message sequence

  1. bill:atm.give me $20
  2. atm:bank.check bill's account balance
  3. bank:atm.bill has $765
  4. atm:bank.hmm are you sure?
  5. bank:atm.yes I'm sure, bill has $765
  6. atm:bill.here's $20, now go away
  7. atm:bank.I just gave Bill $20
  8. bank:atm.great, he's a cool dude

with the other "wisecracks" representing other miscellaneous messages that I don't care about right now.

Is there a way to do this with QSDE?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

橘寄 2024-08-20 17:43:55

当一个新线程启动时(来自用户的消息总是启动一个新线程),它不会停止,直到它被显式停止或直到图表结束。 终止 atm 线程

例如 atm:stop第一次尝试
(多线程模式下的所有内容):

atmsmall

al:Actor
bill:Actor
atm:ATM[a]
bank:Bank[a]

al:atm.give me $10
atm:al has $3=bank.check al's account balance
atm:al.you only have $3
atm:stop

bill:atm.give me $20
atm:bill has $765=bank.check bill's account balance
atm:yes I'm sure, bill has $765=bank.hmm are you sure?
atm:bill.here's $20, now go away
atm:great, he's a cool dude=bank.I just gave Bill $20

具有异步消息的另一个版本

(可以说消息应该是异步的,因为它们是通过网络。无论如何,现在所有箭头看起来都一样)

“>”在消息开始时启动一个新线程(默认情况下,来自用户和进程的所有消息都会启动一个新线程。)

“&”最后意味着调用立即返回,并且不会显示新线程。您可以使用它来模拟向现有线程发送消息。
(默认情况下,发送给用户和进程的所有消息总是立即返回。)

atmsmallthreads

al:Actor
bill:Actor
atm:ATM[a]
bank:Bank[a]

al:atm.give me $10
atm:>bank.check al's account balance
bank:>atm.al has $3&
bank:stop
atm:al.you only have $3
atm:stop

bill:atm.give me $20
atm:>bank.check bill's account balance
bank:>atm.bill has $765&
bank:stop

atm:>bank.hmm are you sure?
bank:>atm.yes I'm sure, bill has $765&
bank:stop

atm:bill.here's $20, now go away
atm:>bank.I just gave Bill $20
bank:>atm.great, he's a cool dude&
bank:stop

完整示例,其中包含所有俏皮话,

但不清楚该示例中 ATM 中的某个线程何时应该停止。 ATM 的行为似乎更像是用户或进程,而不是对象。所以这个例子不一定有意义

atmbig

al:Actor
bill:Actor
atm:ATM[a]
bank:Bank[a]

al:atm[a].give me $10
atm:al has $3=bank.check al's account balance

al:atm.what time is it
atm:al.it's now
atm:stop

atm:al.stop bugging me
atm:al.you only have $3

atm:bill.and don't you open your mouth
bill:atm.who asked you?&
atm:stop

bill:atm.give me $20
al:atm.hey, I'm not finished!&
atm:bill has $765=bank.check bill's account balance
atm:yes I'm sure, bill has $765=bank.hmm are you sure?
atm:bill.here's $20, now go away
atm:great, he's a cool dude=bank.I just gave Bill $20
atm:_
atm:stop

al:atm.what about my $10?
atm:al.read my lips: you only have $3

When a new thread is started (and a message from an user always starts a new thread) it does not stop until it is explicitly stopped or until the diagram ends. E.g. atm:stop terminates the atm thread

here a first attempt
(everything in multithreaded mode):

atmsmall

al:Actor
bill:Actor
atm:ATM[a]
bank:Bank[a]

al:atm.give me $10
atm:al has $3=bank.check al's account balance
atm:al.you only have $3
atm:stop

bill:atm.give me $20
atm:bill has $765=bank.check bill's account balance
atm:yes I'm sure, bill has $765=bank.hmm are you sure?
atm:bill.here's $20, now go away
atm:great, he's a cool dude=bank.I just gave Bill $20

another version with asynchronous messages

(arguably the messages should be asynchronous, since they are transmitted over the network. Anyway now all arrows look the same)

">" at the start of a message starts a new thread (all messages from users and processes start a new thread by default.)

"&" at the end means that the call returns immediately, and the new thread is not shown. you can use this to simulate sending messages to existing threads.
(all messages TO users and processes always return immediately by default. )

atmsmallthreads

al:Actor
bill:Actor
atm:ATM[a]
bank:Bank[a]

al:atm.give me $10
atm:>bank.check al's account balance
bank:>atm.al has $3&
bank:stop
atm:al.you only have $3
atm:stop

bill:atm.give me $20
atm:>bank.check bill's account balance
bank:>atm.bill has $765&
bank:stop

atm:>bank.hmm are you sure?
bank:>atm.yes I'm sure, bill has $765&
bank:stop

atm:bill.here's $20, now go away
atm:>bank.I just gave Bill $20
bank:>atm.great, he's a cool dude&
bank:stop

The full example with all the wisecracks

it is unclear from the example when exactly a thread in ATM should stop. ATM seems to be acting more like a user or process, not an object. So the example does not necessarily make sense

atmbig

al:Actor
bill:Actor
atm:ATM[a]
bank:Bank[a]

al:atm[a].give me $10
atm:al has $3=bank.check al's account balance

al:atm.what time is it
atm:al.it's now
atm:stop

atm:al.stop bugging me
atm:al.you only have $3

atm:bill.and don't you open your mouth
bill:atm.who asked you?&
atm:stop

bill:atm.give me $20
al:atm.hey, I'm not finished!&
atm:bill has $765=bank.check bill's account balance
atm:yes I'm sure, bill has $765=bank.hmm are you sure?
atm:bill.here's $20, now go away
atm:great, he's a cool dude=bank.I just gave Bill $20
atm:_
atm:stop

al:atm.what about my $10?
atm:al.read my lips: you only have $3
生死何惧 2024-08-20 17:43:55

艾尔和比尔是人类。人类怎么可能成为单线程情况的一部分呢?与程序相反,人类不会停滞不前,直到另一个程序返回。它们可以触发计算活动并从计算机接收信号,但它们不会进入线程堆栈。

该文档明确指出(引自多线程帮助):

“新生成的线程可以通过其相应生命线的颜色与旧线程区分开来。”

“通常,演员向对象发送的消息(动态)会产生一个新线程。”

这就是垂直条的来源。

如果您想要单线程或双线程情况,您应该使用对象,而不是参与者。

Al and Bill are human. How can a human being possibly be part of a single-threaded situation? Human beings, in contrast to procedures, do not stand still until another procedure returns. They can trigger computational activities and receive signals from a computer, but they do not go down to a thread's stack.

The documentation clearly states (cited from Multithreading Help):

"A newly spawned thread can be distinguished from older threads by the colour of its corresponding lifelines."

"As a rule, a message sent by an actor to an object (dynamically) spawns a new thread."

So this is where your vertical bars come from.

If you want single- or dual-threaded situations, you should use objects, not actors.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文