如何在有限状态机实现中与用户通信?

发布于 2024-08-19 23:12:13 字数 250 浏览 5 评论 0原文

基本上我有一个自定义实现的有限状态机,它主要侦听硬件开关状态更改以启动转换,但有些事情需要与用户通信......

例如,用户需要告诉它是否重复或保存并重置。

我对如何做到这一点有一个很好的想法...我可以在到达该点时引发事件,然后 UI 层将询问用户,然后触发转换,但是有没有更好的方法或一些模式我应该跟随?

只是寻找一些见解,这样我就不会以错误的方式这样做。

我将其标记为社区维基,因为它实际上并不是单一答案类型的问题。

Basically I have a custom implemented finite state machine that mostly listens for hardware switch state changes for initiating transitions, but some things need communication with the user...

For instance, the user needs to tell it whether to repeat or save and reset.

I have a pretty good idea of how to do it... I can raise events when it gets to that point, and then the UI layer will ask the user and then trigger the transition, but is there some better way or some patterns I should be following?

Just looking for some insight so I don't do this the wrong way.

I'm marking this as community wiki since it's not really a single answer type of question.

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

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

发布评论

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

评论(1

提笔落墨 2024-08-26 23:12:13

我猜想组织这种通信的一种自然方法是在您的机器中设置一个特殊的状态(或多个状态)。

开始->询问用户名 ->打个招呼

I'd guess that a natural way to organize such communication would be to set up a special state (or states) in your machine.

Start -> Ask user's name -> Say hello

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