Browse Source

Merge branch 'xcjk' of zengminguo/server-l-zmg into xcjk

zengminguo 2 years ago
parent
commit
4dd04206c2
4 changed files with 15 additions and 4 deletions
  1. 1 0
      card_base.cpp
  2. 2 1
      card_car.cpp
  3. 8 3
      event.cpp
  4. 4 0
      event.h

+ 1 - 0
card_base.cpp

@@ -539,6 +539,7 @@ void card_location_base::on_location(const std::vector<point>&vp, const std::vec
 			m_speed = pt.m_speed;
 			m_stat = pt.m_stat;
 			m_cell_index_last = cell_index_current;
+			m_cell_index = cell_index_current;
 			m_avg_speed_last = speed_avg;
 			m_direction_last = pt.m_direction;
 			m_time_tmp_last = lm[0].m_time_tmp;

+ 2 - 1
card_car.cpp

@@ -106,7 +106,8 @@ void car::handle_over_speed()
 	if(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);
+		//event_tool::instance()->handle_event(OT_CARD, ET_CARD_OVER_SPEED, id, 0, 0, status);
+		event_tool::instance()->handle_event(OT_CARD, ET_CARD_OVER_SPEED, id, m_cell_index, m_speed, status);
 	}
 
 	status = true;

+ 8 - 3
event.cpp

@@ -87,6 +87,7 @@ event_tool * event_tool::instance()
  * */
 void event_tool::make_event_object()
 {
+	log_info("handle_alarm_event:make_event_object");
     m_map[OT_MORE_CARD] = std::make_shared<mine_event>();
     m_map[OT_AREA] = std::make_shared<area_event>();
     m_map[OT_DEVICE_READER] = std::make_shared<device_reader_event>();
@@ -180,7 +181,6 @@ void Event::handle_alarm_event(EVENT_TYPE et, uint64_t id, double limit_value, d
             ev_ptr=event_ptr;
         }
     }
-    
 	if(ev_ptr)
     {
         //event_list::save_event(ev_ptr);
@@ -190,6 +190,11 @@ void Event::handle_alarm_event(EVENT_TYPE et, uint64_t id, double limit_value, d
 			event_list::save_event_v(ev_ptr);
 		}else if(ev_ptr->m_ev_type == 8 || ev_ptr->m_ev_type == 21 || ev_ptr->m_ev_type == 41){
 			// 红绿灯失联、人车防碰撞、超速告警这三类保存到his_event_data_v表中
+			if (ev_ptr->m_ev_type == 21)
+			{
+				ev_ptr->m_cell_index = limit_value;
+				ev_ptr->m_speed = cur_value;
+			}
 			event_list::save_event_v(ev_ptr);
 		}else{
 			//其他的人员相关报警保存到his_event_data表中
@@ -355,8 +360,8 @@ void event_list::save_event_v(const std::shared_ptr<ya_event> &ev_ptr)
     std::string _time = tool_time::to_str_ex(ev_ptr->m_cur_time);
 	switch(ev_ptr->m_status){
 		case 0:
-			sprintf(sql, "INSERT IGNORE INTO his_event_data_v(id, event_type_id, obj_id, x, y ,start_time) VALUES(%ld, %d, '%s', %.2f, %.2f, '%s');",
-					ev_ptr->m_ev_id, ev_ptr->m_ev_type, ev_ptr->m_obj_id.c_str(), ev_ptr->x, ev_ptr->y, _time.c_str());
+			sprintf(sql, "INSERT IGNORE INTO his_event_data_v(id, event_type_id, obj_id, x, y ,start_time, speed, cell_index) VALUES(%ld, %d, '%s', %.2f, %.2f, '%s', %.2f, %d);",
+					ev_ptr->m_ev_id, ev_ptr->m_ev_type, ev_ptr->m_obj_id.c_str(), ev_ptr->x, ev_ptr->y, _time.c_str(), ev_ptr->m_speed, ev_ptr->m_cell_index);
 			break;
 		case 100:
 			sprintf(sql, "update his_event_data_v set end_time='%s' where id=%ld;", _time.c_str(), ev_ptr->m_ev_id);

+ 4 - 0
event.h

@@ -74,6 +74,10 @@ public:
     double m_cur_value;
     ///描述
     std::string m_desc;
+	//超速告警所在格子
+	int m_cell_index;
+	//超速告警的实际速度
+	double m_speed;
 
     //是否已经发送 ture bu发送, false推送. 推送完置为true
     bool m_is_sent;