Browse Source

handle his_location..

lixioayao 6 years ago
parent
commit
3cb767b4b9
11 changed files with 31 additions and 27 deletions
  1. 1 0
      1
  2. 2 2
      Makefile
  3. 2 2
      Makefile.am
  4. 2 2
      Makefile.in
  5. 3 3
      card.cpp
  6. 0 1
      card.h
  7. 1 1
      db_api/CDBConnPool.cpp
  8. 3 1
      his_location.h
  9. 4 4
      select_tool.cpp
  10. 11 11
      select_tool.h
  11. 2 0
      site_area.cpp

+ 1 - 0
1

@@ -0,0 +1 @@
+-fno-stack-protector

+ 2 - 2
Makefile

@@ -253,8 +253,8 @@ crc.cpp crc.h io_buf.h line.h loc_tool.cpp loc_tool.h message.cpp \
 message_file.h message.h net-service.cpp net-service.h point.cpp point.h tdoa_sync.cpp tdoa_sync.h \
 worker.cpp worker.h zio.h zloop.h znet.cpp znet.h zstream.h site_area.cpp  site_area.h area.h area.cpp
 
-AM_CPPFLAGS = -Wall -pthread -m64 -std=c++11 -fPIC -I${prefix}/include -I./src -I/usr/local/mysql/include -I../include/websocketpp -I../include
-AM_LDFLAGS = -fno-stack-protector -Wall -pthread -m64 -std=c++11 -fPIC -L${prefix}/lib  -L/usr/local/mysql/lib
+AM_CPPFLAGS = -Wall -pthread -m64 -std=c++11  -I${prefix}/include -I./src -I/usr/local/mysql/include -I../include/websocketpp -I../include
+AM_LDFLAGS = -Wall -pthread -m64 -std=c++11  -L${prefix}/lib  -L/usr/local/mysql/lib
 yals_SOURCES = ${AM_SOURCES} main.cpp 
 yals_CPPFLAGS = ${AM_CPPFLAGS} 
 yals_LDFLAGS = ${AM_LDFLAGS}  -lzlog -lrt -lboost_chrono -lboost_system -lboost_thread -lmysqlclient -lthree_rates

+ 2 - 2
Makefile.am

@@ -11,8 +11,8 @@ crc.cpp crc.h io_buf.h line.h loc_tool.cpp loc_tool.h message.cpp \
 message_file.h message.h net-service.cpp net-service.h point.cpp point.h tdoa_sync.cpp tdoa_sync.h \
 worker.cpp worker.h zio.h zloop.h znet.cpp znet.h zstream.h site_area.cpp  site_area.h area.h area.cpp
 
-AM_CPPFLAGS=-Wall -pthread -m64 -std=c++11 -fPIC -I${prefix}/include -I./src -I/usr/local/mysql/include -I../include/websocketpp -I../include
-AM_LDFLAGS= -fno-stack-protector -Wall -pthread -m64 -std=c++11 -fPIC -L${prefix}/lib  -L/usr/local/mysql/lib
+AM_CPPFLAGS=-Wall -pthread -m64 -std=c++11  -I${prefix}/include -I./src -I/usr/local/mysql/include -I../include/websocketpp -I../include
+AM_LDFLAGS=  -Wall -pthread -m64 -std=c++11  -L${prefix}/lib  -L/usr/local/mysql/lib
 
 yals_SOURCES=${AM_SOURCES} main.cpp 
 yals_CPPFLAGS=${AM_CPPFLAGS} 

+ 2 - 2
Makefile.in

@@ -253,8 +253,8 @@ crc.cpp crc.h io_buf.h line.h loc_tool.cpp loc_tool.h message.cpp \
 message_file.h message.h net-service.cpp net-service.h point.cpp point.h tdoa_sync.cpp tdoa_sync.h \
 worker.cpp worker.h zio.h zloop.h znet.cpp znet.h zstream.h site_area.cpp  site_area.h area.h area.cpp
 
-AM_CPPFLAGS = -Wall -pthread -m64 -std=c++11 -fPIC -I${prefix}/include -I./src -I/usr/local/mysql/include -I../include/websocketpp -I../include
-AM_LDFLAGS = -fno-stack-protector -Wall -pthread -m64 -std=c++11 -fPIC -L${prefix}/lib  -L/usr/local/mysql/lib
+AM_CPPFLAGS = -Wall -pthread -m64 -std=c++11  -I${prefix}/include -I./src -I/usr/local/mysql/include -I../include/websocketpp -I../include
+AM_LDFLAGS = -Wall -pthread -m64 -std=c++11  -L${prefix}/lib  -L/usr/local/mysql/lib
 yals_SOURCES = ${AM_SOURCES} main.cpp 
 yals_CPPFLAGS = ${AM_CPPFLAGS} 
 yals_LDFLAGS = ${AM_LDFLAGS}  -lzlog -lrt -lboost_chrono -lboost_system -lboost_thread -lmysqlclient -lthree_rates

+ 3 - 3
card.cpp

@@ -3,10 +3,8 @@
 #include <zloop.h>
 #include "select_tool.h"
 #include "loc_tool.h"
-
 #include <area.h>
 #include <site_area.h>
-
 #include <card.h>
 #include "config_file.h"
 #include "db_api/CDBConnPool.h"
@@ -219,7 +217,8 @@ struct person:card_location_base, card_area
 
     void clear()
     {
-        m_site_area.reset(new site_area_hover);
+		log_info("__thread_id reset:%d,%x  [%x]",m_id,std::this_thread::get_id(),m_site_area.get());
+        //m_site_area.reset(new site_area_hover);
         m_area_tool.reset(new area_tool);
         m_mine_tool.reset(new mine_tool);
 
@@ -232,6 +231,7 @@ struct person:card_location_base, card_area
         {
             return;
         }
+		log_info("__thread_id site_hover:%d,%x  [%x]",m_id,std::this_thread::get_id(),m_site_area.get());
         m_site_area->on_point(m_id,sid,nullptr, m_type);
 	}
 

+ 0 - 1
card.h

@@ -3,7 +3,6 @@
 #include <message.h>
 #include <ev++.h>
 #include "point.h"
-
 #include "write-copy.h"
 #include "websocket/ws_common.h"
 #include "common.h"

+ 1 - 1
db_api/CDBConnPool.cpp

@@ -206,7 +206,7 @@ namespace YADB
 						if ( (my_ulonglong)-1 == llRes )
 						{
 							//Execute failed, write log...
-							printf( "Error,调用ExcuteRealSql失败,Err=%s\n", Error.c_str() );
+							printf( "Error,调用ExcuteRealSql失败,Err=%s,[%s]\n", Error.c_str(), pData->SQL.c_str());
 							//如果失败了看是不是数据库断开连接了,尝试重新连接一次
 							if ( __pAsyncDBConn->ConnctionTest( Error ) != 0 )
 							{

+ 3 - 1
his_location.h

@@ -71,7 +71,8 @@ struct location_card
 		if(!is_valid())
 		  return false;
 		point p=m_d.back().p;
-		if(p==pt)return false;
+		//if(p==pt)return false;
+		if(point::eq(p.x,pt.x,0.05) && point::eq(p.y,pt.y,0.05)) return false;
 		double arg = make_arg(pt,p);
 		log_info("his_location:line_changed:%d,%f,m_arg:%f,%s,%f",m_cardid,arg,m_arg, (arg-m_arg > -1e-10 && arg-m_arg<1e-10)?"same":"not same",m_arg-arg);
 		return !point::eq(arg,m_arg,1e-10);
@@ -185,6 +186,7 @@ struct location_card
 		double dist = m_p.dist(p);
 		double t	= timestamp - m_timestamp;
 		double avge_speed= dist/t*1000;
+		if(std::isnan(avge_speed)|| std::isinf(avge_speed))avge_speed=0;
 		snprintf(nsql,512,sql,tabName.c_str(),tool_time::to_str_ex(timestamp).c_str(),avge_speed,m_type,m_cardid,tool_time::to_str_ex(m_timestamp).c_str());
 		log_info("his_location[%d]:%s",m_cardid,nsql);
 		sDBConnPool.PushAsync(nsql);

+ 4 - 4
select_tool.cpp

@@ -198,10 +198,10 @@ bool select_point_object::select_solution(const std::vector<point> &vp,const sit
 	{
 		m_d(0).set_cl(0);
 
-		printf("out of path:t=%ld,sit=%d,ct=%d,"
-		"tof1=%d,tof2=%d,pt=(%f,%f)\n",
-		m_d(0).m_time, m_d(0).m_sid,m_d(0).m_ct,
-		m_d(0).m_tof[0], m_d(0).m_tof[1], pt.x, pt.y);
+		//printf("out of path:t=%ld,sit=%d,ct=%d,"
+		//"tof1=%d,tof2=%d,pt=(%f,%f)\n",
+		//m_d(0).m_time, m_d(0).m_sid,m_d(0).m_ct,
+		//m_d(0).m_tof[0], m_d(0).m_tof[1], pt.x, pt.y);
 		return false;
 	}
 

+ 11 - 11
select_tool.h

@@ -357,7 +357,7 @@ struct car_point_filter:select_point_object
 		{
 			if(dist2-dist1>3||dist1<=dist3)
 			{
-				printf("reset turning\n");
+				//printf("reset turning\n");
 				reset_turning();	// may encounter problems
 			}
 			return;
@@ -370,8 +370,8 @@ struct car_point_filter:select_point_object
 		turning_y=m_turning_pt.y + dist3 * (m_turning_ept.y - m_turning_pt.y) / dist4;
 
 
-		printf("turning mapping:(%.2f,%.2f)->(%.2f,%.2f),d1:%f,d2:%f,d3:%f\n",
-					rpt.x,rpt.y,turning_x,turning_y,dist1,dist2,dist3);
+		//printf("turning mapping:(%.2f,%.2f)->(%.2f,%.2f),d1:%f,d2:%f,d3:%f\n",
+		//			rpt.x,rpt.y,turning_x,turning_y,dist1,dist2,dist3);
 
 		rpt.set(turning_x,turning_y);
 	}
@@ -387,10 +387,10 @@ struct car_point_filter:select_point_object
 		if(!card_path::inst().is_at_path(rpt))	//if point not on the path
 		{	
 			lp.debug_out();
-			printf("out of path:t=%ld,sit=%d,card=l,ct=%d,"
-						"tof1=%d,tof2=%d,pt=(%.2lf,%.2lf)\n",
-						m_d(0).m_time, m_d(0).m_sid,m_d(0).m_ct,
-						m_d(0).m_tof[0], m_d(0).m_tof[1], pt.x, pt.y);
+		//	printf("out of path:t=%ld,sit=%d,card=l,ct=%d,"
+		//				"tof1=%d,tof2=%d,pt=(%.2lf,%.2lf)\n",
+		//				m_d(0).m_time, m_d(0).m_sid,m_d(0).m_ct,
+		//				m_d(0).m_tof[0], m_d(0).m_tof[1], pt.x, pt.y);
 			return;
 		}
 
@@ -456,10 +456,10 @@ struct car_point_filter:select_point_object
 		if(!card_path::inst().is_at_path(pt))	//if point not on the path
 		{	
 			lp.debug_out();
-			printf("out of path:t=%ld,sit=%d,card=0,ct=%d,"
-						"tof1=%d,tof2=%d,pt=(%.2lf,%.2lf)\n",
-						m_d(0).m_time, m_d(0).m_sid,m_d(0).m_ct,
-						m_d(0).m_tof[0], m_d(0).m_tof[1], pt.x, pt.y);
+		//	printf("out of path:t=%ld,sit=%d,card=0,ct=%d,"
+		//				"tof1=%d,tof2=%d,pt=(%.2lf,%.2lf)\n",
+		//				m_d(0).m_time, m_d(0).m_sid,m_d(0).m_ct,
+		//				m_d(0).m_tof[0], m_d(0).m_tof[1], pt.x, pt.y);
 			return;
 		}
 

+ 2 - 0
site_area.cpp

@@ -31,6 +31,8 @@ void site_area_hover::on_point(uint32_t card_id,int site_id,const point*pt,int32
 
         //m_site_id=site_id;
         m_enter_time=m_last_time=time(nullptr);
+
+		log_info("---thread_id onpoint:%d,%x",card_id,std::this_thread::get_id());
         m_enter_point.set(0,0);
         m_last_point.set(0,0);
 	}