2017-11-02  本文已影响0人  爱因斯坤图灵

                       Introduction to Embedded Systems

                               15352197    梁艺坤    1509     数据科学与计算机学院

1. Advantages of StateCharts

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

Solution: 状态图不仅可以同时表现两个或多个状态同时执行的情况,即并行性,而且还能显式各个状态之间的层次关系。此外,状态图能够保护各个状态之间的转换,即只有满足某个条件才进行转换,并且在转换的时候的可以伴有某些动作,这些动作可以对变量造成影响或者触发生成新的事件。

2. Disadvantages of StateCharts

What are the disadvantages of the StateChart formalism?

Solution: 当系统变得很大的时候,对应的状态图也会随着增大,并且很难理解,这是因为在状态转移的同时伴有某些行动,这些行动可以对变量造成影响,这样的话状态转移的一些信息就会流失到这些变量这种。此外,某些隐藏的状态也会使得状态图难以分析。


3. 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 and denotes the 

Solution:

4. 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 by the StateChart from Fig.1

Solution: 

5. 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:

a,b,e,b,d,b. Use a table notation.

Solution:

6. 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.

Solution:

原始的有限状态机图:

最少状态的有限状态机图:

7. StateChart model of a vending machine

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

a. Describe the trace of transitions occurring when the user inserts a coin and orders a tea.

b. The control of the vending machine has a bug that allows the user to cheat. Describe the trace of transitions that illustrate

     the bug.

c. Draw the corresponding StateChart that fixes the bug.


Solution: 

a.          A1.0 -----> A1.1 (coin_in/ok)

             A2.A -----> A2.B (ok)

            A2.B -----> A2.D(req_tea/start_tea)

            A2.D -----> A2.A (drink_ready/done)

            A1.1 -----> A1.0(done)


b.          A1.0 -----> A1.1(coin_in/ok)

             A2.A -----> A2.B (ok)

             A2.B -----> A2.D(req_tea/start_tea)

             A1.1 -----> A1.0(cancel/coin_out, reset)

             A2.D -----> A2.A (drink_ready/done)

c. 原来的bug是A2中req_tea之后,A1中还可以进行cancel操作,导致取出硬币后还能够喝到茶。现在在A1中加入了一个状态2,并且由状态1通过wait条件触发,在A2中req_tea之后除了有start_tea的行动,还应该有wait,这样就能保证在A2中req_tea之后既开始准备茶,又禁止了顾客取出硬币。

上一篇下一篇

猜你喜欢

热点阅读