|
@@ -4,6 +4,7 @@
|
|
|
#include "event.h"
|
|
|
#include "tool_time.h"
|
|
|
#include "common_tool.h"
|
|
|
+#include "log.h"
|
|
|
#include "area_business_person_dwell_checker.h"
|
|
|
/*
|
|
|
判断当前区域a中的人卡停留时间
|
|
@@ -13,11 +14,16 @@
|
|
|
|
|
|
struct SPersonDwellChecker : business_data
|
|
|
{
|
|
|
- uint64_t m_enter_time;
|
|
|
+ int m_enter_time;
|
|
|
point m_enter_point;
|
|
|
+ int m_level_time;
|
|
|
+ point m_level_point;
|
|
|
+ bool m_send_event; // 是否发生告警
|
|
|
SPersonDwellChecker()
|
|
|
{
|
|
|
m_enter_time = 0;
|
|
|
+ m_level_time = 0;
|
|
|
+ m_send_event = false;
|
|
|
}
|
|
|
};
|
|
|
|
|
@@ -25,11 +31,17 @@ struct SPersonDwellChecker : business_data
|
|
|
void area_business_person_dwell_checker::on_enter(const std::shared_ptr<area_hover>&a,
|
|
|
const std::shared_ptr<card_location_base>&c,std::shared_ptr<business_data>&ptr)
|
|
|
{
|
|
|
-
|
|
|
- auto ptr_temp = std::make_shared<SPersonDwellChecker>();
|
|
|
+ if (nullptr == ptr)
|
|
|
+ {
|
|
|
+ ptr = std::make_shared<SPersonDwellChecker>();
|
|
|
+ }
|
|
|
+ auto ptr_temp = dynamic_cast<SPersonDwellChecker*>(ptr.get());
|
|
|
ptr_temp->m_enter_point.set(c->x,c->y,c->z);
|
|
|
- ptr_temp->m_enter_time = tool_time::now_to_ms();
|
|
|
- ptr = ptr_temp;
|
|
|
+ ptr_temp->m_enter_time = tool_time::now_to_seconds();
|
|
|
+ ptr_temp->m_level_time = 0;
|
|
|
+ ptr_temp->m_level_point.set(0,0,0);
|
|
|
+ a->m_data[this->area_business_type()] = ptr;
|
|
|
+ log_info("area_business_person_dwell_checker::on_enter : In Area=%d Card = %d ",a->m_area->is_mine(),c->m_id);
|
|
|
}
|
|
|
|
|
|
|
|
@@ -37,13 +49,13 @@ void area_business_person_dwell_checker::on_enter(const std::shared_ptr<area_hov
|
|
|
void area_business_person_dwell_checker::on_hover(const std::shared_ptr<area_hover>&a,
|
|
|
const std::shared_ptr<card_location_base>&c,std::shared_ptr<business_data> ptr)
|
|
|
{
|
|
|
- auto ptr_temp = static_cast<SPersonDwellChecker*>(ptr.get());
|
|
|
- if(nullptr == ptr_temp)
|
|
|
+ auto ptr_temp = dynamic_cast<SPersonDwellChecker*>(ptr.get());
|
|
|
+ if(nullptr == ptr_temp || ptr_temp->m_enter_time == 0)
|
|
|
{
|
|
|
return ;
|
|
|
}
|
|
|
double limit_val = 0;
|
|
|
- double cur_val = (tool_time::now_to_ms() - ptr_temp->m_enter_time)/1000;
|
|
|
+ double cur_val = ( tool_time::now_to_seconds() - ptr_temp->m_enter_time);
|
|
|
EVENT_TYPE evType = EVENT_TYPE::ET_CARD_AREA_OVER_TIME_PERSON;
|
|
|
if(c->is_person())
|
|
|
{
|
|
@@ -51,6 +63,7 @@ void area_business_person_dwell_checker::on_hover(const std::shared_ptr<area_hov
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
+ ptr_temp->m_send_event = true;
|
|
|
evType = a->m_area->is_mine() ? EVENT_TYPE::ET_CARD_OVER_TIME_PERSON : EVENT_TYPE::ET_CARD_AREA_OVER_TIME_PERSON;
|
|
|
limit_val = a->m_area->m_limit_person_second;
|
|
|
}
|
|
@@ -71,13 +84,16 @@ void area_business_person_dwell_checker::on_hover(const std::shared_ptr<area_hov
|
|
|
void area_business_person_dwell_checker::on_leave(const std::shared_ptr<area_hover>&a,
|
|
|
const std::shared_ptr<card_location_base>&c,std::shared_ptr<business_data> ptr)
|
|
|
{
|
|
|
- auto ptr_temp = static_cast<SPersonDwellChecker*>(ptr.get());
|
|
|
+ auto ptr_temp = dynamic_cast<SPersonDwellChecker*>(ptr.get());
|
|
|
if(nullptr == ptr_temp)
|
|
|
{
|
|
|
return ;
|
|
|
}
|
|
|
- ptr_temp->m_enter_point.set(c->x,c->y,c->z);
|
|
|
- ptr_temp->m_enter_time = tool_time::now_to_ms();
|
|
|
+ ptr_temp->m_level_point.set(c->x,c->y,c->z);
|
|
|
+ ptr_temp->m_level_time = tool_time::now_to_seconds();
|
|
|
+ ptr_temp->m_enter_point.set(0,0,0);
|
|
|
+ ptr_temp->m_enter_time = 0;
|
|
|
+ ptr_temp->m_send_event = false;
|
|
|
EVENT_TYPE evType = EVENT_TYPE::ET_CARD_AREA_OVER_TIME_PERSON;
|
|
|
if(c->is_person())
|
|
|
{
|