|
@@ -1,4 +1,4 @@
|
|
|
-
|
|
|
+#include <sstream>
|
|
|
#include "card_car.h"
|
|
|
#include "card_message_handle.h"
|
|
|
#include "his_location.h"
|
|
@@ -14,6 +14,7 @@
|
|
|
#include "loc_point.h"
|
|
|
#include "module_service/module_call.h"
|
|
|
#include "ya_setting.h"
|
|
|
+#include "event.h"
|
|
|
|
|
|
car::car(const std::string&type,uint32_t cardid,uint16_t needdisplay,int16_t t,int32_t deptid,
|
|
|
int32_t categoryid, int type_id,int32_t level_id,uint32_t cid)
|
|
@@ -41,7 +42,7 @@ void car::do_business(const std::shared_ptr<site>&site,const point &pt,double ac
|
|
|
m_acc=acc;
|
|
|
m_area_tool->on_point(shared_from_this(),pt);
|
|
|
m_timeval = m_time;
|
|
|
- log_info("[anti_coll] m_id = %d, m_timeval = %lld", m_id, m_timeval);
|
|
|
+ //log_info("[anti_coll] m_id = %d, m_timeval = %lld", m_id, m_timeval);
|
|
|
handle_three_rates(pt);
|
|
|
handle_traffic_light(pt);
|
|
|
if(m_enable_anti_collision){
|
|
@@ -58,11 +59,14 @@ int car::get_vehicle_type_id()
|
|
|
|
|
|
void car::handle_anti_coll(const point& pt, const int& sid)
|
|
|
{
|
|
|
- log_info("[anti_coll] handle anti collision");
|
|
|
+ //log_info("[anti_coll] handle anti collision");
|
|
|
// 车卡下发最紧急的呼叫类型
|
|
|
+ std::map<int, float> cd; // 人卡与车卡的距离,key为人卡id,value为距离
|
|
|
std::map<int, call_card> cards;
|
|
|
auto tmp_cards = card_list::instance()->m_map;
|
|
|
|
|
|
+ double min_d = 9999999.9;
|
|
|
+ double cur_v = 0.0;
|
|
|
for(auto k : CYaSetting::m_sys_setting.mp_anti_collision){
|
|
|
log_info("[anti_coll] key=%d, value=%.2f", k.first, k.second);
|
|
|
for(auto& c : tmp_cards)
|
|
@@ -73,9 +77,22 @@ void car::handle_anti_coll(const point& pt, const int& sid)
|
|
|
bool s = false;
|
|
|
int d = (c.second->m_timeval >= m_timeval ? (c.second->m_timeval - m_timeval) : (m_timeval - c.second->m_timeval)) / 1000.0;
|
|
|
s = ((c.second->m_timeval >= m_timeval ? (c.second->m_timeval - m_timeval) : (m_timeval - c.second->m_timeval)) /1000.0 <= 30);
|
|
|
- if(pt.dist(*c.second) < k.second && s){
|
|
|
+ float dist = pt.dist(*c.second);
|
|
|
+ if(dist < k.second && s){
|
|
|
int call_level = 5 - k.first;
|
|
|
- log_info("[anti_coll] distance=%.3f, level=%d, thre_value=%.3f, time_diff=%d", pt.dist(*c.second), call_level, k.second, d);
|
|
|
+ log_info("[anti_coll] distance=%.3f, level=%d, thre_value=%.3f, time_diff=%d", dist, call_level, k.second, d);
|
|
|
+
|
|
|
+ if(min_d > k.second){
|
|
|
+ min_d = k.second;
|
|
|
+ cur_v = dist;
|
|
|
+ }
|
|
|
+
|
|
|
+ auto itc = cd.find(c.second->m_id);
|
|
|
+ if(itc == cd.end()){
|
|
|
+ cd.insert(std::make_pair(c.second->m_id, dist));
|
|
|
+ }else{
|
|
|
+ itc->second = dist;
|
|
|
+ }
|
|
|
|
|
|
auto it = cards.find(c.second->m_id);
|
|
|
if(it != cards.end()){
|
|
@@ -89,7 +106,28 @@ void car::handle_anti_coll(const point& pt, const int& sid)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+ std::string desc = "";
|
|
|
+ if(cards.size() == 0){
|
|
|
+ // delete event from event_list
|
|
|
+ event_tool::instance()->handle_event(OT_CARD, ET_PERSON_VEHICLE_ANTI_COLLISION, m_id, 0, 0, false);
|
|
|
+ }else{
|
|
|
+ size_t i = 0;
|
|
|
+ for(auto c : cd)
|
|
|
+ {
|
|
|
+ desc += std::to_string(c.first);
|
|
|
+ std::ostringstream buf;
|
|
|
+ buf<<c.second;
|
|
|
+ desc += "," + buf.str();
|
|
|
+ if(i != (cards.size() - 1)){
|
|
|
+ desc += ";";
|
|
|
+ }
|
|
|
+ ++i;
|
|
|
+ }
|
|
|
+ log_info("[anti_coll] the distance's list between person and vehicle : %s", desc.c_str());
|
|
|
+ event_tool::instance()->handle_event(OT_CARD, ET_PERSON_VEHICLE_ANTI_COLLISION, m_id, min_d, cur_v, true, DT_COMMON, desc);
|
|
|
+ }
|
|
|
+
|
|
|
if(cards.size() > 0){
|
|
|
// find the best emengency call
|
|
|
int call_level = 6;
|
|
@@ -129,6 +167,7 @@ void car::handle_traffic_light(const point& p)
|
|
|
cp.x = p.x;
|
|
|
cp.y = p.y;
|
|
|
cp.z = p.z;
|
|
|
+ cp.biz_stat = get_stat();
|
|
|
cp.map_id = m_area_tool->get_mapid();
|
|
|
cp.vibration = m_acc;
|
|
|
put_traffic_light(cp);
|
|
@@ -155,17 +194,13 @@ void car::make_package()
|
|
|
{
|
|
|
YA::_CARD_POS_ cp;
|
|
|
loc_point pt = getSmoothPoint();
|
|
|
- cp.area_info=m_area_tool->m_area_info;
|
|
|
- cp.map_id =m_area_tool->get_mapid();
|
|
|
+ cp.area_info = m_area_tool->m_area_info;
|
|
|
+ cp.map_id = m_area_tool->get_mapid();
|
|
|
|
|
|
- int32_t biz_stat=m_biz_stat;
|
|
|
- cp.biz_stat=biz_stat;
|
|
|
+ cp.biz_stat = get_stat();
|
|
|
cp.down_time = m_mine_tool->get_down_time();
|
|
|
cp.work_time = m_mine_tool->get_work_time();
|
|
|
- uint32_t on_duty=0;
|
|
|
- // if(m_mine_tool->m_is_attendance)
|
|
|
- on_duty=m_mine_tool->is_on_duty();
|
|
|
- cp.is_on_duty=on_duty;
|
|
|
+ cp.is_on_duty= m_mine_tool->is_on_duty();
|
|
|
upt_card_pos(cp,pt);
|
|
|
make_his_location(pt.m_time,pt);
|
|
|
uint64_t _now=tool_time::now_to_ms();
|
|
@@ -175,18 +210,14 @@ void car::make_package()
|
|
|
m_area_tool->on_point(shared_from_this(),pt);
|
|
|
m_biz_stat=get_stat();
|
|
|
}
|
|
|
-
|
|
|
-// if(biz_stat==STATUS_LOST && special_id != -1 && m_display==1)
|
|
|
-// {
|
|
|
-// cp.area_id = special_id;
|
|
|
-// swsClientMgr.SendSpecialAreaProcess(cp);
|
|
|
-// }
|
|
|
}
|
|
|
+
|
|
|
void car::get_card(bool f)
|
|
|
{
|
|
|
if(f)
|
|
|
mine_business::inst()->put(shared_from_this());
|
|
|
}
|
|
|
+
|
|
|
loc_point car::getSmoothPoint()
|
|
|
{
|
|
|
loc_point lp = m_smo_tool->smooth_strategy();
|