|
@@ -1,5 +1,6 @@
|
|
|
#include"area_business_motionless_persion.h"
|
|
|
|
|
|
+#include<chrono>
|
|
|
|
|
|
#include"common_tool.h"
|
|
|
#include"log.h"
|
|
@@ -10,21 +11,19 @@
|
|
|
#include"card.h"
|
|
|
#include"config_file.h"
|
|
|
|
|
|
-
|
|
|
struct motionless_data:business_data
|
|
|
{
|
|
|
motionless_data()
|
|
|
- :m_acc_0count(0)
|
|
|
+ :m_acc_start_time(0)
|
|
|
+ ,m_acc_0count(0)
|
|
|
,m_is_warning(false)
|
|
|
{
|
|
|
- // m_acc_0count=0;
|
|
|
- // m_acc_start_time=0;
|
|
|
}
|
|
|
|
|
|
///;检测到多少次之后定位完全静止
|
|
|
// std::atomic<int> m_acc_0count;
|
|
|
- // ///检测到多久之后告警
|
|
|
- // time_t m_acc_start_time;
|
|
|
+ ///检测到多久之后告警
|
|
|
+ time_t m_acc_start_time;
|
|
|
|
|
|
int m_acc_0count; //连续静止数量
|
|
|
bool m_is_warning; //
|
|
@@ -34,7 +33,7 @@ void area_business_motionless_persion::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","40"));
|
|
|
- // _acc_seconds_limit = std::stoi(config.get("service.motionless_acc_seconds_limit","120"));
|
|
|
+ _acc_seconds_limit = std::stoi(config.get("service.motionless_acc_seconds_limit","120"));
|
|
|
}
|
|
|
|
|
|
void area_business_motionless_persion::on_load_his(const std::shared_ptr<area_hover>&area_hover_ptr,
|
|
@@ -81,12 +80,18 @@ void area_business_motionless_persion::on_hover(const std::shared_ptr<area_hover
|
|
|
else
|
|
|
{
|
|
|
ptr_temp->m_acc_0count=0;
|
|
|
+ ptr_temp->m_acc_start_time = 0;
|
|
|
}
|
|
|
|
|
|
if(ptr_temp->m_acc_0count >= _acc_0count_limit)
|
|
|
{
|
|
|
ptr_temp->m_acc_0count = _acc_0count_limit;
|
|
|
- if(!ptr_temp->m_is_warning)
|
|
|
+ if(ptr_temp->m_acc_start_time == 0)
|
|
|
+ {
|
|
|
+ time(&ptr_temp->m_acc_start_time);
|
|
|
+ }
|
|
|
+ if(!ptr_temp->m_is_warning
|
|
|
+ && tool_time::elapse_seconds(ptr_temp->m_acc_start_time) >= _acc_seconds_limit)
|
|
|
{
|
|
|
ptr_temp->m_is_warning = true;
|
|
|
uint64_t id = tool_other::type_id_to_u64(card_ptr->m_type, card_ptr->m_id);
|
|
@@ -98,6 +103,9 @@ void area_business_motionless_persion::on_hover(const std::shared_ptr<area_hover
|
|
|
if(ptr_temp->m_is_warning)
|
|
|
{
|
|
|
ptr_temp->m_is_warning = false;
|
|
|
+
|
|
|
+ ptr_temp->m_acc_start_time = 0;
|
|
|
+
|
|
|
uint64_t id = tool_other::type_id_to_u64(card_ptr->m_type, card_ptr->m_id);
|
|
|
event_tool::instance()->handle_event(OT_CARD, ET_CARD_MOTIONLESS, id, 0, 0, false);
|
|
|
}
|
|
@@ -127,6 +135,8 @@ void area_business_motionless_persion::on_leave(const std::shared_ptr<area_hover
|
|
|
}
|
|
|
|
|
|
int area_business_motionless_persion::_acc_0count_limit=20;
|
|
|
+int area_business_motionless_persion::_acc_seconds_limit=120;
|
|
|
+
|
|
|
|
|
|
//void module_motionless_persion::deal_alarm(std::shared_ptr<card_location_base>& card_ptr)
|
|
|
//{
|