|
@@ -13,15 +13,21 @@
|
|
|
struct motionless_data:business_data
|
|
|
{
|
|
|
motionless_data()
|
|
|
+ :m_acc_0count(0)
|
|
|
+ ,m_warn_flag(false)
|
|
|
{
|
|
|
- m_acc_0count=0;
|
|
|
+// m_acc_0count=0;
|
|
|
// m_acc_start_time=0;
|
|
|
}
|
|
|
|
|
|
- ///;检测到多少次之后定位完全静止
|
|
|
- std::atomic<int> m_acc_0count;
|
|
|
+
|
|
|
+ ///;检测到多少次之后定位完全静止
|
|
|
+ // std::atomic<int> m_acc_0count;
|
|
|
// ///检测到多久之后告警
|
|
|
// time_t m_acc_start_time;
|
|
|
+
|
|
|
+ int m_acc_0count; //连续静止数量
|
|
|
+ bool m_warn_flag; //告警推送标志
|
|
|
};
|
|
|
|
|
|
void area_business_motionless_persion::on_enter(const std::shared_ptr<area_hover>&a,
|
|
@@ -35,34 +41,44 @@ void area_business_motionless_persion::on_hover(const std::shared_ptr<area_hover
|
|
|
const std::shared_ptr<card_location_base>&card_ptr,std::shared_ptr<business_data> ptr)
|
|
|
{
|
|
|
auto ptr_temp = static_cast<motionless_data*>(ptr.get());
|
|
|
+
|
|
|
+ bool do_send=false;//是否需要发送
|
|
|
+
|
|
|
if(0 == static_cast<int>(card_ptr->m_acc))
|
|
|
{
|
|
|
- ptr_temp->m_acc_0count++;
|
|
|
+ if((do_send = ++ptr_temp->m_acc_0count >= _acc_0count_limit && !ptr_temp->m_warn_flag)) //检测计数 && 是否已经发送,已经发送的话,就不发了
|
|
|
+ {
|
|
|
+ ptr_temp->m_warn_flag=true; //如果确定发送的话,更新数据状态
|
|
|
+ }
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
ptr_temp->m_acc_0count=0;
|
|
|
+ if((do_send=ptr_temp->m_warn_flag))//如果正在告警,则取消告警
|
|
|
+ {
|
|
|
+ ptr_temp->m_warn_flag=false;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- if(ptr_temp->m_acc_0count >= _acc_0count_limit)
|
|
|
- {
|
|
|
- ptr_temp->m_acc_0count = _acc_0count_limit;
|
|
|
- }
|
|
|
-
|
|
|
- bool is_alarm = ptr_temp->m_acc_0count >= _acc_0count_limit;
|
|
|
-
|
|
|
- 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, is_alarm);
|
|
|
+ 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);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
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)
|
|
|
{
|
|
|
- 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);
|
|
|
+ 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);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
-int area_business_motionless_persion::_acc_0count_limit;
|
|
|
+int area_business_motionless_persion::_acc_0count_limit=20;
|
|
|
|
|
|
//void module_motionless_persion::deal_alarm(std::shared_ptr<card_location_base>& card_ptr)
|
|
|
//{
|