如何在有限状态机实现中与用户通信?
基本上我有一个自定义实现的有限状态机,它主要侦听硬件开关状态更改以启动转换,但有些事情需要与用户通信......
例如,用户需要告诉它是否重复或保存并重置。
我对如何做到这一点有一个很好的想法...我可以在到达该点时引发事件,然后 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我猜想组织这种通信的一种自然方法是在您的机器中设置一个特殊的状态(或多个状态)。
I'd guess that a natural way to organize such communication would be to set up a special state (or states) in your machine.