|
@@ -7,9 +7,15 @@
|
|
|
#include <point.h>
|
|
|
#include "common.h"
|
|
|
#include <write-copy.h>
|
|
|
+
|
|
|
struct area_hover;
|
|
|
struct point;
|
|
|
+struct area_business;
|
|
|
+struct card_location_base;
|
|
|
|
|
|
+/*
|
|
|
+ 每个区域对应一个area对象。
|
|
|
+*/
|
|
|
struct area
|
|
|
{
|
|
|
area(int id,int limit_count_person, int limit_time_person,double scale,int32_t mapid,int32_t type)
|
|
@@ -24,9 +30,10 @@ struct area
|
|
|
{
|
|
|
}
|
|
|
|
|
|
- virtual void on_hover(uint32_t card_id,std::shared_ptr<area_hover>&c,double speed,int32_t type);
|
|
|
- virtual void on_enter(uint32_t card_id,std::shared_ptr<area_hover>&c,double speed,int32_t type);
|
|
|
- virtual void on_leave(uint32_t card_id,std::shared_ptr<area_hover>&c,double speed,int32_t type);
|
|
|
+ virtual void on_hover(std::shared_ptr<area_hover>&a,std::shared_ptr<card_location_base>&c);
|
|
|
+ virtual void on_enter(std::shared_ptr<area_hover>&a,std::shared_ptr<card_location_base>&c);
|
|
|
+ virtual void on_leave(std::shared_ptr<area_hover>&a,std::shared_ptr<card_location_base>&c);
|
|
|
+
|
|
|
bool in_area(const point & p);
|
|
|
int id()const
|
|
|
{
|
|
@@ -63,17 +70,33 @@ struct area
|
|
|
m_limit_vehicle_count=limit_count_vehicle;
|
|
|
m_limit_vehicle_second=limit_time_vehicle;
|
|
|
}
|
|
|
-
|
|
|
- std::vector<point> m_bound;
|
|
|
public:
|
|
|
+ std::vector<std::shared_ptr<area_business>> m_area_business_list;
|
|
|
+public:
|
|
|
+ std::vector<point> m_bound;
|
|
|
//std::atomic<int> m_card_count;
|
|
|
+ //数据库唯一ID
|
|
|
int m_id;
|
|
|
///区域类型 AREA_TYPE
|
|
|
+
|
|
|
+ //用户定义的业务类型,BIT集合
|
|
|
+ /*
|
|
|
+ 1:位置[优先级]
|
|
|
+ 2:超时[超时时间分钟数]
|
|
|
+ 3:超员[人员数量、车辆数量]
|
|
|
+ 4:超速[超速值、判断策略N/M]
|
|
|
+ 5:人员考勤
|
|
|
+ 6:车辆考勤[离开最小,离开最小距离]
|
|
|
+ 7:禁区[进入时长]
|
|
|
+ 8:猴车区域
|
|
|
+ */
|
|
|
int m_area_type;
|
|
|
|
|
|
+ //人卡超时及超员数量
|
|
|
int m_limit_person_second;
|
|
|
int m_limit_person_count;
|
|
|
|
|
|
+ //人卡超时及超员数量
|
|
|
int m_limit_vehicle_second;
|
|
|
int m_limit_vehicle_count;
|
|
|
double m_scale;
|
|
@@ -108,6 +131,13 @@ struct area_hover
|
|
|
int landmark_id;
|
|
|
int landmark_dir;
|
|
|
double landmark_dis;
|
|
|
+
|
|
|
+ /*
|
|
|
+ 记录该业务所关心的需持续使用的数据,每个业务一个指针
|
|
|
+ 建议该数据项在on_enter时初始化,on_leave时清除
|
|
|
+ */
|
|
|
+ std::vector<void*> m_hover_data;
|
|
|
+
|
|
|
area_hover()=default;
|
|
|
area_hover(std::shared_ptr<area>&area,const point&pt,double speed)
|
|
|
:m_area(area)
|
|
@@ -154,10 +184,13 @@ struct area_hover
|
|
|
|
|
|
//每张卡包含一个对象
|
|
|
//在解析出数据点时,调用on_point
|
|
|
+struct site;
|
|
|
struct area_tool
|
|
|
{
|
|
|
std::shared_ptr<area_hover> m_area_hover=nullptr;
|
|
|
- void on_point(uint32_t card_id,const point&pt,double speed,int16_t type);
|
|
|
+
|
|
|
+ void on_point(const std::shared_ptr<site>&s,std::shared_ptr<card_location_base> c,const point&pt);
|
|
|
+
|
|
|
void setLandmark(const point &pt)
|
|
|
{
|
|
|
if(m_area_hover)
|
|
@@ -172,43 +205,40 @@ struct area_tool
|
|
|
return true;
|
|
|
return m_area_hover->m_area->special();
|
|
|
}
|
|
|
+
|
|
|
std::tuple<time_t,time_t,int,int,int,int,double> getLandmark()
|
|
|
{
|
|
|
if(m_area_hover)
|
|
|
return m_area_hover->getLandmark();
|
|
|
else
|
|
|
return std::make_tuple(0,0,0,0,0,0,0);
|
|
|
-
|
|
|
- }
|
|
|
- //检测是否超时
|
|
|
- void on_timer(int64_t card_id)
|
|
|
- {
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- void do_hover_biz(uint32_t card_id,double speed,int16_t type)
|
|
|
- {
|
|
|
- m_area_hover->m_area->on_hover(card_id,m_area_hover,speed,type);
|
|
|
- }
|
|
|
-
|
|
|
- void do_enter_biz(uint32_t card_id,double speed,int16_t type)
|
|
|
- {
|
|
|
- m_area_hover->m_area->on_enter(card_id,m_area_hover,speed,type);
|
|
|
- }
|
|
|
-
|
|
|
- void do_leave_biz(uint32_t card_id,double speed,int16_t type)
|
|
|
- {
|
|
|
- m_area_hover->m_area->on_leave(card_id,m_area_hover,speed,type);
|
|
|
}
|
|
|
|
|
|
- void change_area(uint32_t card_id,double speed,int16_t type,int32_t new_areaid)
|
|
|
- {
|
|
|
- do_leave_biz(card_id,speed,type);
|
|
|
- auto area = area_list::instance()->get(new_areaid);
|
|
|
- point pt;
|
|
|
- m_area_hover.reset(new area_hover(area,pt,speed));
|
|
|
- do_enter_biz(card_id,speed,type);
|
|
|
- }
|
|
|
+ void do_hover_biz(uint32_t card_id,double speed,int16_t type)
|
|
|
+ {
|
|
|
+// m_area_hover->m_area->on_hover(card_id,m_area_hover,speed,type);
|
|
|
+ }
|
|
|
+
|
|
|
+ void do_enter_biz(uint32_t card_id,double speed,int16_t type)
|
|
|
+ {
|
|
|
+// m_area_hover->m_area->on_enter(card_id,m_area_hover,speed,type);
|
|
|
+ }
|
|
|
+
|
|
|
+ void do_leave_biz(uint32_t card_id,double speed,int16_t type)
|
|
|
+ {
|
|
|
+// m_area_hover->m_area->on_leave(card_id,m_area_hover,speed,type);
|
|
|
+ }
|
|
|
+
|
|
|
+ void change_area(uint32_t card_id,double speed,int16_t type,int32_t new_areaid)
|
|
|
+ {
|
|
|
+#if 0
|
|
|
+ do_leave_biz(card_id,speed,type);
|
|
|
+ auto area = area_list::instance()->get(new_areaid);
|
|
|
+ point pt;
|
|
|
+ m_area_hover.reset(new area_hover(area,pt,speed));
|
|
|
+ do_enter_biz(card_id,speed,type);
|
|
|
+#endif
|
|
|
+ }
|
|
|
};
|
|
|
|
|
|
#endif
|