[英]How do I communicate with the user in a finite state machine implementation?
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? 我对如何做到这一点非常了解...我可以在达到这一点时引发事件,然后UI层会询问用户然后触发转换,但是有更好的方法或某些模式我应该遵循?
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. 我将此标记为社区维基,因为它不是真正的单一答案类型的问题。
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 开始 - >询问用户名 - >打招呼
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.