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 }
相关文章
|
3月前
|
域名解析 弹性计算 开发者
阿里云备案服务码在哪申请?申请流程与服务码使用常见问题解答
备案服务码是用于阿里云备案系统的重要凭证,需通过购买云服务器等产品获取。用户需先购买符合要求的云服务器,再通过控制台申请备案服务码,且服务码可跨账号使用但需授权。云虚拟主机也可申请备案服务码。备案时,需在备案管理系统填写对应服务码。
|
10月前
|
存储 人工智能 安全
5款值的推荐的高效工具软件
本文介绍了五款实用工具软件:矢量设计工具Affinity Designer、数字绘画软件Sketchable、在线AI工具箱3171.CN、密码管理工具KeePassX及效率搜索软件Listary,涵盖设计、办公、安全与系统效率提升,助力高效工作。
309 0
|
存储 缓存 自然语言处理
SCOPE:面向大语言模型长序列生成的双阶段KV缓存优化框架
KV缓存是大语言模型(LLM)处理长文本的关键性能瓶颈,现有研究多聚焦于预填充阶段优化,忽视了解码阶段的重要性。本文提出SCOPE框架,通过分离预填充与解码阶段的KV缓存策略,实现高效管理。SCOPE保留预填充阶段的关键信息,并在解码阶段引入滑动窗口等策略,确保重要特征的有效选取。实验表明,SCOPE仅用35%原始内存即可达到接近完整缓存的性能水平,显著提升了长文本生成任务的效率和准确性。
800 3
SCOPE:面向大语言模型长序列生成的双阶段KV缓存优化框架
|
安全 大数据 Linux
云上体验最佳的服务器操作系统 - Alibaba Cloud Linux | 飞天技术沙龙-CentOS 迁移替换专场
本次方案的主题是云上体验最佳的服务器操作系统 - Alibaba Cloud Linux ,从 Alibaba Cloud Linux 的产生背景、产品优势以及云上用户使用它享受的技术红利等方面详细进行了介绍。同时,通过国内某社交平台、某快递企业、某手机客户大数据业务 3 大案例,成功助力客户实现弹性扩容能力提升、性能提升、降本增效。 1. 背景介绍 2. 产品介绍 3. 案例分享
397 1
|
负载均衡 网络协议 网络架构
静态路由 及其 实验操作
静态路由 及其 实验操作
|
Linux
Linux 驱动开发基础知识—— LED 驱动程序框架(四)
Linux 驱动开发基础知识—— LED 驱动程序框架(四)
376 0
Linux 驱动开发基础知识—— LED 驱动程序框架(四)
|
Java Linux 网络安全
在Linux上搭建Maven仓库的实战教程
在Linux上搭建Maven仓库的实战教程
1099 0
|
SQL 存储 消息中间件
小米基于 Flink 的实时数仓建设实践
本次分享围绕小米在实时数仓方面的探索与实践展开,主要涉及:Flink+Iceberg 实时数仓架构升级,稳定性与实时性优化;基于当前 Flink 实时数仓的不确定性问题,介绍 Merge into 功能和算子级状态清理的解决方案。
8478 0
小米基于 Flink 的实时数仓建设实践
|
传感器 算法 数据可视化
IMU模块中的一些基本概念和常见问题
IMU模块中的一些基本概念和常见问题
IMU模块中的一些基本概念和常见问题
|
XML Java 数据库连接
mybatis传参为map的写法
mybatis传参为map的写法
251 0

热门文章

最新文章