#include #include "area_business.h" #if 0 #include "area.h" #include "card.h" #include "ya_event.h" #include "module_service/module_call.h" /* 确定推送人员信息时的区域,每一个明确需要推送的区域,都要推送 */ struct area_business_post_area:area_business { virtual int area_business_type() { return 1; } //将推送区域信息加入人员数据 virtual void on_enter(const std::shared_ptr&a,const std::shared_ptr&c,std::shared_ptr ptr){} virtual void on_hover(const std::shared_ptr&a,const std::shared_ptr&c,std::shared_ptr ptr){} //从人员数据中清除区域信息 virtual void on_leave(const std::shared_ptr&a,const std::shared_ptr&c,std::shared_ptr ptr){} }; /* 判断车辆超速,确定超速后记录日志、数据库并告警 每张卡在每个区域的超速相关的数据信息记录在 area_hover 对象 人员&车辆的代码重用,请自行设计 */ struct area_business_speed_checker:area_business { struct speed_checker_data:business_data { std::vector speed; }; virtual int area_business_type() { return 4; } //在ptr对象中初始化超速检测所需的对象 virtual void on_enter(const std::shared_ptr&a,const std::shared_ptr&c,std::shared_ptr ptr){} //根据超速检测的策略,进行超速判断,超速时进行告警 //建议使用最近M秒内N秒超时进行判断,M=20,N=15,策略数据记录在ptr中..如此:一辆车理想情况下15s才能检测出来。15*4m/s=60mbut.15s内有可能只上来一个超速点。 virtual void on_hover(const std::shared_ptr&a,const std::shared_ptr&c,std::shared_ptr ptr){} //清除超速检测所需的对象 virtual void on_leave(const std::shared_ptr&a,const std::shared_ptr&c,std::shared_ptr ptr){} }; /* 禁区 */ struct area_business_restricted:area_business { virtual int area_business_type() { return 7; } //记录进入时间等信息,生成告警 virtual void on_enter(const std::shared_ptr&a,const std::shared_ptr&c,std::shared_ptr ptr) { #if 0 a->m_enter_point = point(c->x,c->y,c->z); a->m_last_point.set(0,0,0); a->m_last_time = 0; a->m_enter_time = time(nullptr); event_ptr evPtr = event_list::instance()->get_event_card(c->m_id,c->m_type,ET_CARD_AREA_FORBIDDEN_PERSON); if (nullptr == evPtr) { event_ptr evPtr = event_list::create_event_card(c->m_id, c->m_type, ET_CARD_AREA_FORBIDDEN_PERSON); event_list::instance()->copy_event(c, evPtr); event_list::instance()->add(evPtr->get_list_id(), evPtr); } evPtr->m_limit_value = 0; evPtr->m_cur_value = 0; evPtr->m_is_display = true; evPtr->m_status = EVENT_STATUS::ES_START ; evPtr->m_cur_time = std::chrono::system_clock::now(); event_list::save_event(evPtr); //呼叫 module_call::instance()->system_call_apoint(c->m_id,c->m_type); #endif } virtual void on_hover(const std::shared_ptr&a,const std::shared_ptr&c,std::shared_ptr ptr){} //记录退出时间等信息 virtual void on_leave(const std::shared_ptr&a,const std::shared_ptr&c,std::shared_ptr ptr) { #if 0 a->m_last_point = point(c->x,c->y,c->z); a->m_last_time = time(nullptr); // 发送警告 int oldStatus = -1; event_ptr evPtr = event_list::instance()->get_event_card(c->m_id,c->m_type,ET_CARD_AREA_FORBIDDEN_PERSON); if (nullptr == evPtr) { event_ptr evPtr = event_list::create_event_card(c->m_id, c->m_type, ET_CARD_AREA_FORBIDDEN_PERSON); event_list::instance()->copy_event(c, evPtr); event_list::instance()->add(evPtr->get_list_id(), evPtr); oldStatus = EVENT_STATUS::ES_END; } else{ if (evPtr->m_status != EVENT_STATUS::ES_END) { oldStatus = EVENT_STATUS::ES_END; } } evPtr->m_limit_value = 0; evPtr->m_cur_value = 0; evPtr->m_is_display = true; evPtr->m_status = EVENT_STATUS::ES_END ; evPtr->m_cur_time = std::chrono::system_clock::now(); if (oldStatus != -1) { event_list::save_event(evPtr); } //取消呼叫 module_call::instance()->system_cancel_call_apoint(c->m_id,c->m_type); #endif } }; #endif #include "area_business_car_attendance.h" #include "area_business_card_enter_or_leave.h" #include "area_business_count_checker.h" #include "area_business_forbid.h" #include "area_business_person_dwell_checker.h" #include "area_business_person_attendance.h" #include "area_business_post_area.h" #include "area_business_speed_checker.h" struct area_business_factory { void regist(int type,area_business* ab) { if(type>=(int)m_check_list.size()) { m_check_list.resize(type+1); } assert(!m_check_list[type]); m_check_list[type].reset(ab); } std::vector get_check_list(int business_type) { std::vector check_list; for(int i=0;i<32;i++) { if(business_type==0) break; if((business_type&1)==0) continue; business_type >>= 1; check_list.push_back(m_check_list[i].get()); } return std::move(check_list); } static area_business_factory& instance() { static area_business_factory _instance; return _instance; } private: std::vector> m_check_list; area_business_factory() { regist(1,new area_business_post_area); regist(2,new area_business_person_dwell_checker); regist(3,new area_business_count_checker); regist(4,new area_business_speed_checker); regist(5,new area_business_person_attendance); regist(6,new area_business_car_attendance); regist(7,new area_business_forbid); //regist(8,new area_business_monkey_area); regist(9,new area_business_card_enter_or_leave); } }; std::vector area_business::get_instance_list(int business_type) { return area_business_factory::instance().get_check_list(business_type); }