Hierarchical_State_Machine Class Reference

简介:
  #include <Hierarchical_State_Machine.h>

Collaboration diagram for Hierarchical_State_Machine:

[legend]
List of all members.

Detailed Description

This is an example of state machine implementation using Hierarchical State Machines.

For details refer to the article on Hierarchical State Machines

In conventional state machine design, all states are considered at the same level. The design does not capture the commonality that exists among states. In real life, many states handle most messages in similar fashion and differ only in handling of few key messages. Even when the actual handling differs, there is still some commonality. Hierarchical state machine design captures the commonality by organizing the states as a hierarchy. The states at the higher level in hierarchy perform the common message handling, while the lower level states inherit the commonality from higher level ones and perform the state specific functions. This examples explores hierarchichal state machines using an example of a hardware unit that can be in the following states:

Definition at line 32 of file Hierarchical_State_Machine.h.

 

Public Member Functions

void  On_Message (const Message *p_Message)
  Receive methods and invoke the handler for the currently active state.


Private Member Functions

void  Next_State (Unit_State &r_State)
  This private method changes the state for the state machine.


Private Attributes

Unit_State p_Current_State
  Pointer to the current state.

Static Private Attributes

Active  Active_State
  Static declaration of Active state. Static declarations share the same states across multiple instances.
Standby  Standby_State
  Static declaration of Standby state.
Suspect  Suspect_State
  Static declaration of Suspect state.
Failed  Failed_State
  Static declaration of Failed State.

Member Function Documentation

void Hierarchical_State_Machine::Next_State Unit_State r_State  )  [private]
 

This private method changes the state for the state machine.

The p_Current_State variable is updated with the new state

Parameters:
r_State  Reference to the desired next state

Definition at line 169 of file Hierarchical_State_Machine.h.

00170 {
00171     p_Current_State = &r_State;
00172 }

void Hierarchical_State_Machine::On_Message const Message *  p_Message  )   
 

Receive methods and invoke the handler for the currently active state.

Note that p_Current_State has already been set to the current state.

Parameters:
p_Message  Pointer to the message being processed.

Definition at line 17 of file Hierarchical_State_Machine.cpp.

00018 {
00019     switch (p_Message->GetType())
00020     {
00021     case Message::FAULT_TRIGGER:
00022         p_Current_State->On_Fault_Trigger(*this, p_Message);
00023         break;
00024 
00025     case Message::SWITCHOVER:
00026         p_Current_State->On_Switchover(*this, p_Message);
00027         break;
00028 
00029     case Message::DIAGNOSTICS_PASSED:
00030         p_Current_State->On_Diagnostics_Passed(*this, p_Message);
00031         break;
00032 
00033     case Message::DIAGNOSTICS_FAILED:
00034         p_Current_State->On_Diagnostics_Failed(*this, p_Message);
00035         break;
00036 
00037     case Message::OPERATOR_INSERVICE:
00038         p_Current_State->On_Operator_Inservice(*this, p_Message);
00039         break;
00040 
00041     default:
00042         assert(false);
00043         break;
00044     }
00045 }
相关文章
|
SQL 存储 消息中间件
小米基于 Flink 的实时数仓建设实践
本次分享围绕小米在实时数仓方面的探索与实践展开,主要涉及:Flink+Iceberg 实时数仓架构升级,稳定性与实时性优化;基于当前 Flink 实时数仓的不确定性问题,介绍 Merge into 功能和算子级状态清理的解决方案。
8478 0
小米基于 Flink 的实时数仓建设实践
|
10月前
|
存储 人工智能 安全
5款值的推荐的高效工具软件
本文介绍了五款实用工具软件:矢量设计工具Affinity Designer、数字绘画软件Sketchable、在线AI工具箱3171.CN、密码管理工具KeePassX及效率搜索软件Listary,涵盖设计、办公、安全与系统效率提升,助力高效工作。
318 0
|
传感器 算法 数据可视化
IMU模块中的一些基本概念和常见问题
IMU模块中的一些基本概念和常见问题
IMU模块中的一些基本概念和常见问题
|
XML Java 数据库连接
mybatis传参为map的写法
mybatis传参为map的写法
253 0
|
Android开发
Android远程桌面助手
很早之前,做过一个《WinCE远程桌面助手》,在没有屏幕或者在调试LCD驱动时,发挥了很大作用,平日开发也是必备。后来还被网友用于处理一些疑难问题,如无法输入开机密码时可通过该工具远程输入,触屏坏了也可远程操作。
3054 0
|
Linux
Linux 驱动开发基础知识—— LED 驱动程序框架(四)
Linux 驱动开发基础知识—— LED 驱动程序框架(四)
377 0
Linux 驱动开发基础知识—— LED 驱动程序框架(四)
|
存储 数据可视化 开发工具
Github代码fork之后,如何与原仓库进行同步?
Github代码fork之后,如何与原仓库进行同步?
1806 0
|
负载均衡 网络协议 网络架构
静态路由 及其 实验操作
静态路由 及其 实验操作