Main Content

通过使用校验状态活动运营商

在州流中®chart with parallel state decomposition, substates can be active at the same time. To coordinate the behavior of different parallel states, one state can check the substate activity of another state and react accordingly. For example, one state can keep its substates synchronized with the substates of the other state.

运营商

要检查状态是否在给定的时间步骤中是否处于活动状态,请调用operator in state and transition actions. The操作员采用合格的状态名称endy_name.并返回布尔输出。如果是国家endy_name.活跃,返回值1(true)。除此以外,返回值0()。

在(endy_name.

例如,在此图表中,风扇and加热器are parallel (AND) states. Each state has a pair of substates,OnandOff。每次图表醒来时,国家的活动成分风扇交替之间风扇。Offand粉丝。在该州加热器, 条件s on the transitions check the substate activity in风扇并保持状态同步。有效的变化器的变化风扇causes a corresponding change of active substate in加热器

R.esolution of State Activity

检查状态活动是两部分过程。首先,StateFlow图表通过执行匹配状态的图表层次结构的本地化搜索来解析限定状态名称。然后,图表确定匹配状态是否处于活动状态。

该search begins at the hierarchy level where theoperator is called with the qualified state name:

  • 对于状态操作,起点是包含该动作的状态。

  • 对于过渡标签,起始点是转换源的父级。

解决方法将图表层次结构的每个级别搜索到状态的路径。如果状态匹配路径,则该进程将该状态添加到可能匹配的列表中。然后,该过程继续在层次结构中搜索一个级别。解决过程中搜索层次结构的图表级别后停止。如果存在唯一匹配,则图表检查匹配状态是否处于活动状态。否则,解决程序进程失败。模拟停止错误。

该流程图说明了用于检查状态活动的过程中的不同阶段。

B.est Practices for Checking State Activity

要解决状态活动,状态溢图不会对所有状态进行详尽的搜索,并且在找到第一次匹配后不会停止。为了提高查找独特搜索结果的机会:

  • 在限定数据名称中使用特定路径。

  • 给出国家唯一名称。

  • Use states and boxes as enclosures to limit the scope of the path resolution search.

状态活动分辨率的例子

搜索查找子变电站的本地副本

This chart contains two parallel states,一种andB.。Each state has a pair of substates,A1andA2A1有代价Xandy,而且A1有代价P.and问:。在A.A2and inB.A2, 条件在(A1.Y)guards the transition fromP.问:

th图表解析每个合格的国家名称e local copy of the substatey

  • 在该州一种, 条件在(A1.Y)检查国家的活动A.A1.Y.

  • 在该州B., 条件在(A1.Y)检查国家的活动B.。A1。y

例如,此表列出了状态下的分辨率过程中的不同阶段一种

阶段 Description R.esult
1 从州开始A.A2,图表搜索了该州A.A2。一种1。y No match found.
2 Moving up to the next level of the hierarchy (state一种),图表搜索该州A.A1.Y. 匹配找到。
3. 移动到层次结构的下一个级别(图表级别),图表搜索了该州A1。y No match found.

搜索以匹配为止。B.ecause the resolution algorithm localizes the scope of the search, theoperator guarding the transition inA.A2detects only the stateA.A1.Y.。该operator guarding the transition inB.A2detects only the stateB.。A1。y

检查其他副本的状态活动y,使用更具体的合格状态名称:

  • 在州一种, use the expression在(B.A1.Y)

  • 在州B., use the expression在(A.A1.Y)

搜索生产没有匹配

在this chart, the行动中的行动一种。B.包含表达式在(Q.R)。StateFlow无法解析限定状态名称问:。R.

此表列出了分辨率过程中的不同阶段。

阶段 Description R.esult
1 从州开始一种。B.,图表搜索了该州A.b.q.r. No match found.
2 Moving up to the next level of the hierarchy (state一种),图表搜索该州一种。问:。R. No match found.
3. 移动到层次结构的下一个级别(图表级别),图表搜索了该州问:。R. No match found.

搜索在图表级别结束,找不到匹配项问:。R., resulting in an error.

To avoid this error, use a more specific qualified state name. For instance, check state activity by using the expression在(p.q.r)

Search Finds the Wrong State

在this chart, the行动中的行动一种。B.包含表达式在(Q.R)。解决合格的状态名称时问:。R.,StateFlow无法检测到子变量一种。B.。p.q.r.

此表列出了分辨率过程中的不同阶段。

阶段 Description R.esult
1 从州开始一种。B.,图表搜索了该州A.b.q.r. No match found
2 Moving up to the next level of the hierarchy (state一种),图表搜索该州一种。问:。R. No match found.
3. 移动到层次结构的下一个级别(图表级别),图表搜索了该州问:。R. 匹配找到。

搜索以匹配为止。该操作员仅检测代表R.顶级状态问:

To check the state activity of一种。B.。p.q.r., use a more specific qualified state name. For instance, use the expression在(p.q.r)

搜索产生多个匹配

在this chart, the行动中的行动一种。B.包含表达式在(p.q.r)。StateFlow无法解析限定状态名称p.q.r.

此表列出了分辨率过程中的不同阶段。

阶段 Description R.esult
1 从州开始一种。B.,寻找州一种。B.。p.q.r. 找到匹配
2 Moving up to the next level of the hierarchy (state一种),图表搜索该州A.P.Q.r. No match found.
3. 移动到层次结构的下一个级别(图表级别),图表搜索了该州p.q.r. 匹配找到。

搜索在图表级别结束,找到了两场比赛p.q.r., resulting in an error.

避免此错误:

  • 使用更具体的合格状态名称。例如:

    • 检查内部的子变化活动B., use the expression在(b.p.q.r)

    • To check the substate activity in the top-level stateP., use the expression在(\ p.q.r)

  • R.ename one of the matching states.

  • Enclose the top-level stateP.在a box or another state. Adding an enclosure prevents the search process from detecting substates in the top-level state.

也可以看看

|

R.elated Topics