嵌入式导论练习题2

Introduction to Embedded Systems

Exercise 2 MOC-stateChartStatechart

  1. Advantages of StateCharts

What are the most important extensions of the StateChart model in
comparison to an ordinary Finite state machine (FSM)?

状态图可以对层次结构和并发进行建模。可以警戒(有条件地启用)转换。此外,转换可以与操作相关联。 操作可以与操作相关联。 操作可以对变量执行计算,并生成新事件。状态图(Statechart Diagram)是描述一个实体基于事件反应的动态行为,显示了该实体如何根据当前所处的状态对不同的事件做出反应。

  1. Disadvantages of StateCharts

What are the disadvantages of the StateChart formalism?

虽然StateChart比普通的FSM更好,但是它们在大型系统中的规模越来越大,往往很难理解。 重复使用的潜力是有限的。 与转换相关的操作提供了强大的扩展,但另一方面,广泛使用的操作将部分系统状态信息从状态本身移动到变量。 这种隐藏状态使系统分析困难。

  1. Tree of states for StateChart

Given the StateChart in Figure 1. Draw the state space of the StateChart
as a tree, which shows the hierarchy of states anddenotes the state types
(basic state, sequential states, and parallel states).

ex1.jpg
image.png
  1. Formal computation of state space

How would you formally compute the set of states? Compute the set of
states for the hierarchical automata which is defined bythe StateChart from
Fig.1

image.png
  1. Analysis

The automaton defined by the StateChart from Fig. 1 passes through a
number of states, when external events are applied.Show the sequence of
state that are passed through, starting from the initial state, for the
following sequence of events:

image.png
  1. Conversion of StateChart to a finite state machine (FSM)

Draw a finite state machine which is equivalent to the StateChart from
Fig. 1. Minimize the number of states.

image.png
image.png
  1. StateChart model of a vending machine

The StateChart model of a simplified vending machine is shown in Figure
2.

  • Describe the trace of transitions occurring when the user inserts a coin and orders a tea.
image.png
  • The control of the vending machine has a bug that allows the user to cheat.
    Describe the trace of transitions that illustratethe bug.


    image.png
  • Draw the corresponding StateChart that fixes the bug.

Bug:


ex2.jpg

Correct:


image.png

Simulated:

设置一个人想要喝咖啡的状态:

输入事件:

coin_in=1;
cancel=0;
drink_ready=1
req_tea=0;
req_coffee=0;

image.png

仿真结果为:

输出事件

start_coffee=1;
start_tea=0;
coin_out=0;

验证模型是正确的,输出为

image.png
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • A:工作中,常常会接到同事打来的电话,如果这个同事正好是之前跟我有工作接触,且正在等待我对一些事情的回复的话,此时...
    喜哥的朝九晚五阅读 1,826评论 9 0
  • 今天听到两个故事,挺好,就想记录下来,结果此时想记的时候却发现能记住的都很模糊了,因此就又听了一遍。 故事是这样的...
    奔跑fjn阅读 1,800评论 0 1
  • 不知从什么时候起,我的生活中已离不开草木,它对我来说就如空气和水。 草木遵循的是大道
    小金宝阅读 1,469评论 0 0
  • 第二十课、今天我们学习日常生活用语中经常涉及到的一个词语——什么。 韩语中表示"什么"的词有两个 무엇, 무슨 、...
    无意惹东风阅读 3,218评论 3 4
  • 分子集自由人 我们生活中的斜杠青年是怎样的状态呢? 表捉急! 分子集第二期社群分享 来了一位生活中的斜杠青年 ▼ ...
    哲神阅读 3,517评论 0 1