#ifndef MODULE_MOTIONLESS_PERSION_H #define MODULE_MOTIONLESS_PERSION_H /** * @brief 简要说明 * @author 戴月腾 * @date 2019-01-12 */ #include"module_singleton_base.h" #include"module_i_thread.h" #include"card.h" #include"config_file.h" /** * @brief 一、硬件输出的状态 当完全静止时人卡会连续发送 30 次定位数据,在该定位数据中的加速度状态为 0;发送 完这一系列的定位数据之后进入休眠状态,不再发送任何定位数据。 当人卡从静止切换到运动状态会在毫秒级完成。然后 2 秒后把定位数据发上来,此时加 速度状态为 1(运动状态)。 二、处理逻辑 当连续收到 X(X 可以配置,X 建议不小于 10)次静止状态定位数据之后才认为完全静止。 经过 Y(Y 可以配置)秒之后开始告警,只要收到运动状态的定位数据就认为非静止立刻取消 告警 */ class module_motionless_persion : public i_thread, public singleton_base { private: friend class singleton_base; module_motionless_persion() { } int _acc_0count_limit; int _acc_seconds_limit; void run() { auto cardlist = card_list::instance()->m_map; auto iter_m_map=cardlist.begin(); for(;iter_m_map!=cardlist.end();++iter_m_map) { deal_alarm(iter_m_map->second); } } void deal_alarm(std::shared_ptr& card_ptr); public: void init(config_file& config) { sleep_ms = std::stoi(config.get("service.motionless_thread_sleep_ms","5000")); _acc_0count_limit = std::stoi(config.get("service.motionless_acc_0count_limit","20")); _acc_seconds_limit = std::stoi(config.get("service.motionless_acc_seconds_limit","120")); } void on_enter(std::shared_ptr card_ptr, int index); void on_hover(std::shared_ptr card_ptr, int index); void on_leave(std::shared_ptr card_ptr, int index); }; #endif // MODULE_MOTIONLESS_PERSION_H