Kaynağa Gözat

test warning

zhuyf 2 yıl önce
ebeveyn
işleme
17533e15d8
4 değiştirilmiş dosya ile 37 ekleme ve 10 silme
  1. 1 2
      card_base.cpp
  2. 2 1
      card_base.h
  3. 24 7
      card_car.cpp
  4. 10 0
      net-service.cpp

+ 1 - 2
card_base.cpp

@@ -8,7 +8,6 @@
 #include "module_service/module_mgr.h"
 #include "websocket/wsClientMgr.h"
 #include "websocket/wsTimerThread.h"
-//#include "three_rates.h"
 #include "his_location.h"
 #include "event.h"
 #include "module_service/module_call.h"
@@ -439,7 +438,7 @@ void card_location_base::on_message(zloop<task*>* loop, message_pdoa_locinfo& lo
     else{
         char sql[1024] = {0};
         snprintf(sql, 1024, "insert into his_distance_reader(card_type, ident, reader_id, dist, dir, cur_time) values(%d, %d, %d, %.2f, %d, '%s')", loc.m_card_type, loc.m_card_id, loc.m_site_id, loc.m_tof*15.65*2.996*1E-4, (tool_other::get_pdoa(loc.m_poa, site_ptr->m_pdoa_offset)>=0?1:-1), tool_time::to_str(time(NULL)).c_str());
-        db_tool::PushAsync(sql);
+        //db_tool::PushAsync(sql);
         log_info("[sql] %s", sql);
 		
 		do_site_locate_event(loc);

+ 2 - 1
card_base.h

@@ -187,7 +187,8 @@ struct card_location_base:card,std::enable_shared_from_this<card_location_base>
 
     static std::shared_ptr<card_location_base> make_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);
-    void set_freq_id(const uint8_t& val)
+    
+	void set_freq_id(const uint8_t& val)
     {
         m_freq_id = val;
     }

+ 24 - 7
card_car.cpp

@@ -53,15 +53,15 @@ void car::set_area_info(int mapid,double scale,int areaid,uint64_t t,int type)
  * */
 void car::do_business(const std::shared_ptr<site>&site,const point &pt,double acc)
 {
-	m_acc=acc;
+	m_acc = acc;
 	m_area_tool->on_point(shared_from_this(),pt);
 	m_timeval = m_time;
-	//handle_three_rates(pt);
     handle_traffic_light(pt, site->m_id);
-    //if(m_enable_anti_collision){
-    if(CYaSetting::m_sys_setting.m_enable_anti_coll){
+    
+	if(CYaSetting::m_sys_setting.m_enable_anti_coll){
         handle_anti_coll(pt, site->m_id);
     }
+	
 	uint64_t id=tool_other::type_id_to_u64(m_type,m_id);
 	mine_business::inst()->make_arg(id,pt,m_time);
 
@@ -99,9 +99,12 @@ void car::handle_over_speed()
 		}
 	}
 
+	uint64_t id = m_type;
+	id = ((id<<32) | m_id);
 	if(status){
 		// 产生告警
-		event_tool::instance()->handle_event(OT_CARD, ET_CARD_OVER_SPEED, m_id, 0, 0, status);
+		log_info("[v_over_speed] %d begin warning...", m_id);
+		event_tool::instance()->handle_event(OT_CARD, ET_CARD_OVER_SPEED, id, 0, 0, status);
 	}
 
 	status = true;
@@ -112,7 +115,8 @@ void car::handle_over_speed()
 	}
 	if(status){
 		// 结束告警
-		event_tool::instance()->handle_event(OT_CARD, ET_CARD_OVER_SPEED, m_id, 0, 0, false);
+		log_info("[v_over_speed] %d end warning...", m_id);
+		event_tool::instance()->handle_event(OT_CARD, ET_CARD_OVER_SPEED, id, 0, 0, false);
 	}	
 }
 
@@ -291,8 +295,21 @@ void car::handle_traffic_light(const point& p, const int& sid)
 
 void car::on_timer()
 {
-    if(!empty())
+   if(!empty())
 	    make_package();
+
+	//1.找到73号卡,如果计数小于100,更新速度为40;计数大于100,更新速度为20
+/*	if(m_cache_nums < 40){
+		m_cache_nums++;
+		m_speed = 40;
+	}else{
+		m_speed = 20;
+	}
+
+	log_info("[v_over_speed] card_id=10004, speed=%.2f", m_speed);
+	handle_over_speed();
+*/
+	//2.调用业务处理
 }
 
 int car::get_area()

+ 10 - 0
net-service.cpp

@@ -230,6 +230,16 @@ void net_service::on_message(const std::shared_ptr<client> &clt,const char*data,
 						site_ptr_v->set_algo(LDT_PDOA);
 					}
 					
+					if(site_id == 73){
+						uint64_t id = 2;
+						id = ((id<<32) | 10004);
+						auto c = card_list::instance()->get(id);
+						log_info("[v_over_speed] %d, object=%s", id, (c==nullptr?"true":"false"));
+						if(c){
+							c->on_timer();
+						}
+					}
+
                     //log_info("[scale_test] %.2f", site_ptr->m_scale);
                     struct timeval tv;
                     gettimeofday(&tv, NULL);