|
@@ -10,6 +10,9 @@
|
|
|
#include"common_tool.h"
|
|
|
#include"log.h"
|
|
|
#include"card.h"
|
|
|
+#include"config_file.h"
|
|
|
+#include"point.h"
|
|
|
+#include"area.h"
|
|
|
|
|
|
struct geofault_data:business_data
|
|
|
{
|
|
@@ -17,18 +20,25 @@ struct geofault_data:business_data
|
|
|
{
|
|
|
m_near_geofault_count=0;
|
|
|
m_far_geofault_count=0;
|
|
|
+ m_is_warning=false;
|
|
|
}
|
|
|
|
|
|
int m_near_geofault_count;
|
|
|
int m_far_geofault_count;
|
|
|
+ bool m_is_warning;
|
|
|
};
|
|
|
|
|
|
std::unordered_map<int, std::vector<point>> area_business_geofault::_area_geofault_map;
|
|
|
int area_business_geofault::_geofault_count_limit;
|
|
|
|
|
|
void area_business_geofault::on_enter(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(!tool_other::is_coal_or_driving(card_ptr->m_type))
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
auto ptr_temp = std::make_shared<geofault_data>();
|
|
|
ptr = ptr_temp;
|
|
|
|
|
@@ -37,20 +47,34 @@ void area_business_geofault::on_enter(const std::shared_ptr<area_hover>&area_hov
|
|
|
{
|
|
|
ptr_temp->m_near_geofault_count++;
|
|
|
}
|
|
|
+ else
|
|
|
+ {
|
|
|
+ ptr_temp->m_far_geofault_count++;
|
|
|
+ }
|
|
|
+
|
|
|
+ auto ev_ptr_temp = event_list::instance()->get_event_card(card_ptr->m_id, card_ptr->m_type, ET_VEHICLE_NEAR_GEOFAULT);
|
|
|
+ ptr_temp->m_is_warning = (nullptr != ev_ptr_temp && !ev_ptr_temp->is_end());
|
|
|
}
|
|
|
|
|
|
void area_business_geofault::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)
|
|
|
{
|
|
|
+ if(!tool_other::is_coal_or_driving(card_ptr->m_type))
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
auto ptr_temp = static_cast<geofault_data*>(ptr.get());
|
|
|
|
|
|
double dist=0;
|
|
|
if(_is_near(area_hover_ptr->m_area, card_ptr->x, card_ptr->y, dist))
|
|
|
{
|
|
|
+ ptr_temp->m_far_geofault_count=0;
|
|
|
ptr_temp->m_near_geofault_count++;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
+ ptr_temp->m_near_geofault_count=0;
|
|
|
ptr_temp->m_far_geofault_count++;
|
|
|
}
|
|
|
|
|
@@ -59,14 +83,13 @@ void area_business_geofault::on_hover(const std::shared_ptr<area_hover>&area_hov
|
|
|
{
|
|
|
ptr_temp->m_near_geofault_count=_geofault_count_limit;
|
|
|
|
|
|
- auto ev_ptr = event_list::instance()->get_event_card(card_ptr->m_id, card_ptr->m_type, ET_VEHICLE_NEAR_GEOFAULT);
|
|
|
- if(!ev_ptr)//从没有告警状态转化为告警状态
|
|
|
+ if(!ptr_temp->m_is_warning)
|
|
|
{
|
|
|
- ptr_temp->m_far_geofault_count=0;
|
|
|
+ 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_VEHICLE_NEAR_GEOFAULT, id,
|
|
|
+ CYaSetting::m_sys_setting.geofault_warn_dis, dist, 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_VEHICLE_NEAR_GEOFAULT, id, CYaSetting::m_sys_setting.geofault_warn_dis, dist, true);
|
|
|
}
|
|
|
|
|
|
//确定正常
|
|
@@ -74,25 +97,46 @@ void area_business_geofault::on_hover(const std::shared_ptr<area_hover>&area_hov
|
|
|
{
|
|
|
ptr_temp->m_far_geofault_count=_geofault_count_limit;
|
|
|
|
|
|
- auto ev_ptr = event_list::instance()->get_event_card(card_ptr->m_id, card_ptr->m_type, ET_VEHICLE_NEAR_GEOFAULT);
|
|
|
- if(ev_ptr && !ev_ptr->is_end())
|
|
|
+ if(ptr_temp->m_is_warning)
|
|
|
{
|
|
|
- ptr_temp->m_near_geofault_count=0;
|
|
|
+ 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_VEHICLE_NEAR_GEOFAULT, id, CYaSetting::m_sys_setting.geofault_warn_dis, dist, false);
|
|
|
+ event_tool::instance()->handle_event(OT_CARD, ET_VEHICLE_NEAR_GEOFAULT, id,
|
|
|
+ CYaSetting::m_sys_setting.geofault_warn_dis, dist, false);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
void area_business_geofault::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)
|
|
|
{
|
|
|
+ if(!tool_other::is_coal_or_driving(card_ptr->m_type))
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
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_VEHICLE_NEAR_GEOFAULT, id, CYaSetting::m_sys_setting.geofault_warn_dis, 1000, false);
|
|
|
}
|
|
|
|
|
|
+void area_business_geofault::init(config_file& config)
|
|
|
+{
|
|
|
+ _geofault_count_limit = std::stoi(config.get("service.geofault_count_limit","10"));
|
|
|
+}
|
|
|
+
|
|
|
+std::string area_business_geofault::_points2str(std::vector<point>& points)
|
|
|
+{
|
|
|
+ std::string str;
|
|
|
+ for(auto&p : points)
|
|
|
+ {
|
|
|
+ char ch[64] = {0};
|
|
|
+ sprintf(ch, "x=%f,y=%f;", p.x, p.y);
|
|
|
+ str.append(ch);
|
|
|
+ }
|
|
|
+
|
|
|
+ return str;
|
|
|
+}
|
|
|
|
|
|
void area_business_geofault::init_geofault_from_db()
|
|
|
{
|
|
@@ -148,8 +192,8 @@ void area_business_geofault::init_geofault_from_db()
|
|
|
for(const auto &p : _area_geofault_map)
|
|
|
{
|
|
|
auto kk = p.second;
|
|
|
- std_debug("init_geofault_from_db:area_id:%d--points: %s",p.first, points2str(kk).c_str());
|
|
|
- log_info("init_geofault_from_db:area_id:%d--points: %s",p.first, points2str(kk).c_str());
|
|
|
+ std_debug("init_geofault_from_db:area_id:%d--points: %s",p.first, _points2str(kk).c_str());
|
|
|
+ log_info("init_geofault_from_db:area_id:%d--points: %s",p.first, _points2str(kk).c_str());
|
|
|
}
|
|
|
}
|
|
|
|