gpt4 book ai didi

sequence-diagram - 使用快速序列图编辑器制作序列图

转载 作者:行者123 更新时间:2023-12-04 02:00:55 26 4
gpt4 key购买 nike

任何有经验的人 Quick Sequence Diagram Editor ?即时显示+文本源代码+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

我想我不清楚是什么开始/结束了这些垂直条。我有一个单线程的情况,但涉及状态,并且所有消息都是异步的。我想这意味着我应该使用外部对象来表示该状态及其生命周期。我想要的是一个时间线来表示消息序列
  • al:atm.给我 10 美元
  • atm:bank.check al 的账户余额
  • 银行:atm.al 有 $3
  • atm:al.you 只有 $3

  • 和另一个时间线来表示消息序列
  • bill:atm.给我 20 美元
  • atm:bank.check bill 的账户余额
  • 银行:atm.bill 有 $765
  • atm:bank.hmm 你确定吗?
  • 银行:atm.yes 我敢肯定,账单有 765 美元
  • atm:bill。这里是 20 美元,现在走开
  • atm:bank。我刚刚给了比尔 20 美元
  • 银行:atm.great,他是个很酷的家伙

  • 其他“俏皮话”代表我现在不关心的其他杂项信息。

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

    最佳答案

    当一个新线程启动时(并且来自用户的消息总是启动一个新线程)它不会停止,直到它被明确停止或直到图表结束。例如。 atm:stop 终止 atm 线程

    这是第一次尝试
    (多线程模式下的一切):

    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

    关于sequence-diagram - 使用快速序列图编辑器制作序列图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1850096/

    26 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com