IAR VisualState 需要为状态内的每个表达式触发
我已经使用基于状态机的设计工具有一段时间了,并且见过 UML 建模工具,它们允许您在状态内执行逻辑(调用函数,执行其他操作)。然而,在使用 IAR VisualState 几天后,您似乎无法在没有触发器的情况下在状态内执行逻辑。我很困惑,因为对一个状态内的每一个动作都有一个触发器是没有意义的!
这是我对状态图工具的期望: 如果我进入 StateA,进入该状态后,我在入口部分设置我的值,然后我想调用一个函数(我只想调用它,NO TRIGGER),并且在该函数内部,我想触发一个基于一些逻辑,该事件将触发从 StateA 到 StateB 或 StateC 的状态转换。
这个期待有什么问题吗?在 VisualSTATE 中可以吗?
非常感谢您的帮助。
I have been using State machine based design tools for some time, and have seen UML modeling tools that allow you to execute your logic (call functions, do other stuff) inside a state. However, after spending a couple days with IAR VisualState, it appears that you cannot execute your logic inside a state without a trigger. I am confused as it does not make sense TO HAVE A TRIGGER for every single action inside a state !
Here is what I expect from a state chart tool:
If I enter StateA, upon entering the state I set my values in entry section, then I would like to call a function (I just want to call it, NO TRIGGER), and inside that function, I want to trigger an event based on some logic, and that event would trigget state transition from StateA to StateB or StateC.
Is there something wrong with this expectation? Is it possible in VisualSTATE?
Help is greatly appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
VisualSTATE 采用事件驱动范例,就像任何图形用户界面程序一样。在这样的系统中发生的任何事情都是由事件触发的。然后系统通过执行操作(计算)并可能通过更改状态(状态转换)来做出响应。
事件驱动系统最困难的方面可能是控制反转,即仅当有事件要处理时才调用(状态机)代码。否则,您的代码甚至不会处于活动状态。这意味着您无法掌控一切,但事件却可以。你的工作是响应事件。
也许在使用 VisualSTATE 之前,您可以阅读任何有关 Windows GUI 编程的书籍(Visual Basic 是一个很好的起点)并构建几个事件驱动应用程序。完成此操作后,VisualSTATE 背后的理念将变得更加清晰。
VisualSTATE imposes the event-driven paradigm, just like any Graphical User Interface program. Anything and everything that happens in such systems is triggered by an event. The system then responds by performing actions (computation) and possibly by changing the state (state transition).
Probably the most difficult aspect of event-driven systems is the inversion of control, that is, your (state machine) code is called only when there is an event to process. Otherwise, your code is not even active. This means that you are not in control, the events are. Your job is to respond to events.
Perhaps before you play with visualSTATE, you could pick up any book on GUI programming for Windows (Visual Basic is a good starting point) and build a couple of event-driven applications. After you do this, the philosophy behind visualSTATE will become much clearer.
创建 3 个状态:A、B、C,其中状态 A 是默认状态。
通过进入状态 A,调用操作函数 [让你
变量 a 和 b 遵循某种算法],后跟 ^Signal1。
Entry/ action()^Signal1
进行由 Signal1 驱动的转换[将为您提供一个事件],从状态 A 到 2 个守卫:
a <= b,转换到状态 C
<代码>a> b、转换到状态B
Create 3 states: A, B, C where state A is a default state.
By entering state A, call action function [that sets you
variables a and b following some algorithm], followed by ^Signal1.
Entry/ action()^Signal1
Make a transition driven by Signal1 [will serve you as an event] from state A with 2 guards:
a <= b, transition to state C
a > b, transition to state B