One Framework 0.1.0
RoboMaster嵌入式框架“一键”解决方案,为你的“创意”服务。
载入中...
搜索中...
未找到
NotifyGuard< StatusT > 模板类 参考

状态去重 Guard,只在状态真正改变时才发送通知 更多...

#include <NotifyGuard.hpp>

NotifyGuard< StatusT > 的协作图:

Public 成员函数

 NotifyGuard (const FixedString< MAX_KEY_LEN > &key)
 
bool set (const StatusT &status)
 设置状态,只有与上次不同时才发送
 
void reset ()
 重置缓存,下次 set 将强制发送
 
const std::optional< StatusT > & current () const
 获取当前缓存的状态(如果有)
 

详细描述

template<typename StatusT>
class OF::NotifyGuard< StatusT >

状态去重 Guard,只在状态真正改变时才发送通知

模板参数
StatusTLEDStatusBuzzerStatus

使用示例: NotifyGuard<LEDStatus> m_led_guard{"chassis"}; m_led_guard.set({c_warning, LEDMode::Breathing, 1, 300}); // 自动去重

构造及析构函数说明

◆ NotifyGuard()

template<typename StatusT>
NotifyGuard ( const FixedString< MAX_KEY_LEN > & key)
inlineexplicit

成员函数说明

◆ current()

template<typename StatusT>
const std::optional< StatusT > & current ( ) const
inline

获取当前缓存的状态(如果有)

◆ reset()

template<typename StatusT>
void reset ( )
inline

重置缓存,下次 set 将强制发送

◆ set()

template<typename StatusT>
bool set ( const StatusT & status)
inline

设置状态,只有与上次不同时才发送

参数
status新状态
返回
true 如果实际发送了更新

该类的文档由以下文件生成: