|
@@ -14,76 +14,98 @@
|
|
|
struct motionless_data:business_data
|
|
|
{
|
|
|
motionless_data()
|
|
|
- :m_acc_0count(0)
|
|
|
- ,m_warn_flag(false)
|
|
|
+ :m_acc_0count(0)
|
|
|
+ ,m_is_warning(false)
|
|
|
{
|
|
|
-// m_acc_0count=0;
|
|
|
-// m_acc_start_time=0;
|
|
|
+ // m_acc_0count=0;
|
|
|
+ // m_acc_start_time=0;
|
|
|
}
|
|
|
|
|
|
+ ///;检测到多少次之后定位完全静止
|
|
|
+ // std::atomic<int> m_acc_0count;
|
|
|
+ // ///检测到多久之后告警
|
|
|
+ // time_t m_acc_start_time;
|
|
|
|
|
|
- ///;检测到多少次之后定位完全静止
|
|
|
- // std::atomic<int> m_acc_0count;
|
|
|
-// ///检测到多久之后告警
|
|
|
-// time_t m_acc_start_time;
|
|
|
-
|
|
|
- int m_acc_0count; //连续静止数量
|
|
|
- bool m_warn_flag; //告警推送标志
|
|
|
+ int m_acc_0count; //连续静止数量
|
|
|
+ bool m_is_warning; //
|
|
|
};
|
|
|
|
|
|
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"));
|
|
|
+ // 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"));
|
|
|
}
|
|
|
|
|
|
void area_business_motionless_persion::on_enter(const std::shared_ptr<area_hover>&a,
|
|
|
- const std::shared_ptr<card_location_base>&card_ptr,std::shared_ptr<business_data>&ptr)
|
|
|
+ const std::shared_ptr<card_location_base>&card_ptr,std::shared_ptr<business_data>&ptr)
|
|
|
{
|
|
|
+ if(!card_ptr->is_person())
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
auto ptr_temp = std::make_shared<motionless_data>();
|
|
|
ptr = ptr_temp;
|
|
|
+
|
|
|
+ auto ev_ptr_temp = event_list::instance()->get_event_card(card_ptr->m_id, card_ptr->m_type, ET_CARD_MOTIONLESS);
|
|
|
+ ptr_temp->m_is_warning = (nullptr != ev_ptr_temp && !ev_ptr_temp->is_end());
|
|
|
}
|
|
|
|
|
|
void area_business_motionless_persion::on_hover(const std::shared_ptr<area_hover>&area_hover_ptr,
|
|
|
- const std::shared_ptr<card_location_base>&card_ptr,std::shared_ptr<business_data> ptr)
|
|
|
+ const std::shared_ptr<card_location_base>&card_ptr,std::shared_ptr<business_data> ptr)
|
|
|
{
|
|
|
- auto ptr_temp = static_cast<motionless_data*>(ptr.get());
|
|
|
+ if(!card_ptr->is_person())
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
- bool do_send=false;//是否需要发送
|
|
|
+ auto ptr_temp = static_cast<motionless_data*>(ptr.get());
|
|
|
|
|
|
if(0 == static_cast<int>(card_ptr->m_acc))
|
|
|
{
|
|
|
- if((do_send = ++ptr_temp->m_acc_0count >= _acc_0count_limit && !ptr_temp->m_warn_flag)) //检测计数 && 是否已经发送,已经发送的话,就不发了
|
|
|
- {
|
|
|
- ptr_temp->m_warn_flag=true; //如果确定发送的话,更新数据状态
|
|
|
- }
|
|
|
+ ++ptr_temp->m_acc_0count;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
ptr_temp->m_acc_0count=0;
|
|
|
- if((do_send=ptr_temp->m_warn_flag))//如果正在告警,则取消告警
|
|
|
- {
|
|
|
- ptr_temp->m_warn_flag=false;
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
- if(do_send)//需要发送
|
|
|
- {
|
|
|
- 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, ptr_temp->m_warn_flag);
|
|
|
- }
|
|
|
+ if(ptr_temp->m_acc_0count >= _acc_0count_limit)
|
|
|
+ {
|
|
|
+ ptr_temp->m_acc_0count = _acc_0count_limit;
|
|
|
+ if(!ptr_temp->m_is_warning)
|
|
|
+ {
|
|
|
+ ptr_temp->m_is_warning = true;
|
|
|
+ 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, true);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if(ptr_temp->m_is_warning)
|
|
|
+ {
|
|
|
+ ptr_temp->m_is_warning = false;
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
void area_business_motionless_persion::on_leave(const std::shared_ptr<area_hover>&area_hover_ptr,
|
|
|
- const std::shared_ptr<card_location_base>&card_ptr,std::shared_ptr<business_data> ptr)
|
|
|
+ const std::shared_ptr<card_location_base>&card_ptr,std::shared_ptr<business_data> ptr)
|
|
|
{
|
|
|
+ if(!card_ptr->is_person())
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
auto ptr_temp = static_cast<motionless_data*>(ptr.get());
|
|
|
- if(ptr_temp->m_warn_flag)//如果正在告警,则发送取消告警的信息
|
|
|
- {
|
|
|
- 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);
|
|
|
- }
|
|
|
+ if(ptr_temp->m_is_warning)//如果正在告警,则发送取消告警的信息
|
|
|
+ {
|
|
|
+ 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);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
int area_business_motionless_persion::_acc_0count_limit=20;
|