Kaynağa Gözat

timestamp fix buf, test algo tof OK.

lixioayao 6 yıl önce
ebeveyn
işleme
e40f14d728
20 değiştirilmiş dosya ile 389566 ekleme ve 493 silme
  1. 507 0
      1
  2. 388908 0
      1222.raw
  3. 2 2
      Makefile
  4. 1 1
      Makefile.am
  5. 1 1
      Makefile.in
  6. 13 14
      ant.cpp
  7. 4 4
      ant.h
  8. 1 0
      async.cpp
  9. 20 8
      card.cpp
  10. 1 0
      card.h
  11. 12 4
      client.cpp
  12. 31 426
      config.log
  13. 5 5
      config.status
  14. 11 2
      main.cpp
  15. 2 1
      message.cpp
  16. 1 1
      message.h
  17. 15 7
      net-service.cpp
  18. 1 1
      path_tof.txt
  19. 14 6
      select_tool.cpp
  20. 16 10
      select_tool.h

Dosya farkı çok büyük olduğundan ihmal edildi
+ 507 - 0
1


Dosya farkı çok büyük olduğundan ihmal edildi
+ 388908 - 0
1222.raw


+ 2 - 2
Makefile

@@ -174,7 +174,7 @@ INSTALL_SCRIPT = ${INSTALL}
 INSTALL_STRIP_PROGRAM = $(install_sh) -c -s
 LDFLAGS = 
 LIBOBJS = 
-LIBS = -lev 
+LIBS = -lzlog -lev 
 LTLIBOBJS = 
 MAKEINFO = ${SHELL} /home/lemon/resource/ya-serv/missing --run makeinfo
 MKDIR_P = /bin/mkdir -p
@@ -241,7 +241,7 @@ 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
 
-AM_CPPFLAGS = -Wall -pthread -m64 -std=c++11 -fPIC -I${prefix}/include
+AM_CPPFLAGS = -Wall -pthread -m64 -std=c++11 -fPIC -I${prefix}/include -I./src -I$(prefix)/mysql/include -I../include/websocketpp -I../include
 AM_LDFLAGS = -Wall -pthread -m64 -std=c++11 -fPIC -L${prefix}/lib  -L$(prefix)/mysql/lib
 yals_SOURCES = ${AM_SOURCES} main.cpp 
 yals_CPPFLAGS = ${AM_CPPFLAGS} 

+ 1 - 1
Makefile.am

@@ -8,7 +8,7 @@ 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
 
-AM_CPPFLAGS=-Wall -pthread -m64 -std=c++11 -fPIC -I${prefix}/include
+AM_CPPFLAGS=-Wall -pthread -m64 -std=c++11 -fPIC -I${prefix}/include -I./src -I$(prefix)/mysql/include -I../include/websocketpp -I../include
 AM_LDFLAGS= -Wall -pthread -m64 -std=c++11 -fPIC -L${prefix}/lib  -L$(prefix)/mysql/lib
 
 yals_SOURCES=${AM_SOURCES} main.cpp 

+ 1 - 1
Makefile.in

@@ -241,7 +241,7 @@ 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
 
-AM_CPPFLAGS = -Wall -pthread -m64 -std=c++11 -fPIC -I${prefix}/include
+AM_CPPFLAGS = -Wall -pthread -m64 -std=c++11 -fPIC -I${prefix}/include -I./src -I$(prefix)/mysql/include -I../include/websocketpp -I../include
 AM_LDFLAGS = -Wall -pthread -m64 -std=c++11 -fPIC -L${prefix}/lib  -L$(prefix)/mysql/lib
 yals_SOURCES = ${AM_SOURCES} main.cpp 
 yals_CPPFLAGS = ${AM_CPPFLAGS} 

+ 13 - 14
ant.cpp

@@ -12,12 +12,14 @@ int site::index()const
 sit_list*sit_list::instance()
 {
 	static sit_list _impl;
-	_impl.load_from_db();
+	//_impl.load_from_db();
 	return &_impl;
 }
 site::site(int id)
-    :m_id(id)
-     ,m_path_empty(true)
+	:m_algo(0)
+	,m_num_dims(0)
+    ,m_id(id)
+    ,m_path_empty(true)
 {
 
 }
@@ -138,7 +140,7 @@ void sit_list::read_ant_path(const char*fname)
                 a.m_path.push_back(p);
             }
             if(abs(pid)==1)
-              m_list[id].set(p1);
+				 m_list[id].set(p1);
         }
 	}
 	fclose(fp);
@@ -162,10 +164,7 @@ void sit_list::read_ant_path(const char*fname)
             }
         }
         std_info("%s",s.to_string().c_str());
-        std_info("%f----%f",s.x,s.y);
-        log_info("%s",s.to_string().c_str());
-        log_debug("%s",s.to_string().c_str());
-        log_error("%s",s.to_string().c_str());
+        //std_info("%f----%f",s.x,s.y);
 	}
 }
 
@@ -182,12 +181,12 @@ int loc_message::tool_index()const
 
 algo_config site::g_config[]=
 {
-	{ "tof-1",  1, 2, 100, 1000 },
-	{ "tdoa-1", 2, 2, 100, 1000 },
-	{ "tof-2",  2, 3, 100, 1000 },
-	{ "tdoa-2", 3, 3, 100, 1000 },
-	{ "tof-3",  3, 4, 100, 1000 },
-	{ "tdoa-3", 4, 4, 100, 1000 }
+	{ "tof-1",  1, 2, 0.1, 1 },
+	{ "tdoa-1", 2, 2, 0.1, 1 },
+	{ "tof-2",  2, 3, 0.1, 1 },
+	{ "tdoa-2", 3, 3, 0.1, 1 },
+	{ "tof-3",  3, 4, 0.1, 1 },
+	{ "tdoa-3", 4, 4, 0.1, 1 }
 };
 #ifdef _TEST
 int main()

+ 4 - 4
ant.h

@@ -50,8 +50,8 @@ struct algo_config
 	const char*desc;
 	int min_msg_cnt;
 	int best_msg_cnt;
-	int min_wait_time;
-	int max_wait_time;
+	double min_wait_time;
+	double max_wait_time;
 };
 //
 struct ant :point
@@ -185,7 +185,7 @@ struct site:point
 	std::string to_string()const
 	{
         std::stringstream ss;
-        ss<<"site_id:"<<m_id;
+        ss<<"site_id:"<<m_id<<"x:"<<x<<" y: "<<y;
         for(const auto a:m_ant)
         {  
             ss<<"<";
@@ -247,7 +247,7 @@ struct sit_list
 
 	void load_from_db()
 	{
-	
+		load("data_reader_antenna.txt","path_tof.txt");
 	}
 	void read_sit_list(const char*fname);
 	void read_ant_path(const char*fname);

+ 1 - 0
async.cpp

@@ -13,6 +13,7 @@
 #define EV_MULTIPLICITY 1
 #define EV_SIGNAL_ENABLE 1
 #define EV_ASYNC_ENABLE 1
+#define EV_USE_FLOOR 1
 #include <ev++.h>
 
 #include <clock.h>

+ 20 - 8
card.cpp

@@ -26,6 +26,11 @@ struct card_location_base
 	virtual void on_location(const std::vector<point>&vp,const std::vector<loc_message> &lm )
     {
         loc_point pt = m_sel_tool->select_solution(vp,lm);
+		if(pt.m_useless)
+		{
+			std_info("loc_point,x:%.2f,y:%.2f",pt.x,pt.y);
+			log_info("loc_point,x:%.2f,y:%.2f",pt.x,pt.y);
+		}
         m_smo_tool->smooth_strategy();
     }
     void do_status(STA_TYPE st)
@@ -93,7 +98,9 @@ struct one_ct_message_handle
         else if(loop == nullptr)
           return;
    		if(!m_msg_list.empty()&& m_ct!=loc.m_card_ct)
+		{
 			m_msg_list.clear();
+		}
 
 		site s=(*sit_list::instance())[loc.m_site_id];
 		if(m_msg_list.empty())
@@ -102,7 +109,9 @@ struct one_ct_message_handle
 			m_ac=&s.config();
 			m_min_timeout=false;
             //这里构造loc_message 保存数据
-			m_msg_list.push_back(loc_message(s,loc.m_tof,loc.m_time_stamp,loc.m_card_id,loc.m_card_ct,loc.m_card_type,loc.m_ant_id,loc.m_rav,loc.m_acc,loc.m_sync_ct,loc.m_rssi));
+			m_msg_list.push_back(loc_message(s,loc.m_tof,loc.m_time_stamp,loc.m_card_id,
+							loc.m_card_ct,loc.m_card_type,loc.m_ant_id,loc.m_rav,loc.m_acc,
+							loc.m_sync_ct,loc.m_rssi));
 
 			//启动本CT的最小、最大两个定时器
 			m_min_timer.start(m_ac->min_wait_time);
@@ -110,7 +119,9 @@ struct one_ct_message_handle
 			return;
 		}
 
-		m_msg_list.push_back(loc_message(s,loc.m_tof,loc.m_time_stamp,loc.m_card_id,loc.m_card_ct,loc.m_card_type,loc.m_ant_id,loc.m_rav,loc.m_acc,loc.m_sync_ct,loc.m_rssi));
+		m_msg_list.push_back(loc_message(s,loc.m_tof,loc.m_time_stamp,loc.m_card_id,
+						loc.m_card_ct,loc.m_card_type,loc.m_ant_id,loc.m_rav,loc.m_acc,
+						loc.m_sync_ct,loc.m_rssi));
 
 		if(m_min_timeout && (int)m_msg_list.size()>=m_ac->best_msg_cnt)
 		{
@@ -130,13 +141,9 @@ struct one_ct_message_handle
 		reset();
 	}
 };
-//card 类的handle -->on_message..
-//handle message.
 struct card_message_handle
 {
 	card_location_base*m_card;
-	//std::vector<loc_message> m_msg_list;
-    //here handle ct message...one ct one handle operator.
 	std::array<one_ct_message_handle*,16> m_ct_list;
 
 	card_message_handle(card_location_base*card)
@@ -206,6 +213,11 @@ struct card_list_impl:card_list
 
 	void init_card_from_db()
 	{
+		for(int i=0;i<(1<<16);i++)
+		{
+			card_location_base * mp = new car("car1");
+			m_list.push_back(mp);
+		}
 	}
 
 	card_location_base *get(uint64_t card_id)const
@@ -228,8 +240,8 @@ struct card_list_impl:card_list
 			return;
 		}
 
-		log_info("card message:site=%d,ant=%d,card=%d,tof=%lld,rav=%02X,acc=%02X,rssi=%d",
-				loc.m_site_id,loc.m_ant_id,loc.m_card_id,loc.m_tof,loc.m_rav,loc.m_acc,loc.m_rssi);
+		log_info("card message:site=%d,ant=%d,card=%d,tof=%lld,rav=%02X,acc=%02X,rssi=%d,stamp=%llu",
+				loc.m_site_id,loc.m_ant_id,loc.m_card_id,loc.m_tof,loc.m_rav,loc.m_acc,loc.m_rssi,loc.m_time_stamp);
 
 		c->on_message(loop,loc,is_history);
 	}

+ 1 - 0
card.h

@@ -8,6 +8,7 @@ template<typename T> struct zloop;
 struct card_list
 {
 	virtual void on_message(zloop<task*> *loop,const message_locinfo&loc,bool is_history)=0;
+	virtual void init_card_from_db()=0;
 	virtual ~card_list(){}
 
 	//static card_list *instance(zloop<task*>&loop);

+ 12 - 4
client.cpp

@@ -2,12 +2,15 @@
 #include "log.h"
 #include "zio.h"
 #include "message_file.h"
+#include "thread"
+#include "chrono"
 
 int main()
 {
 	int sock=zio::build_stream();
 
 	if(zio::connect(sock,"127.0.0.1",4000))
+	//if(zio::connect(sock,"192.168.8.116",4000))
 	{
 		return -1;
 	}
@@ -18,7 +21,7 @@ int main()
 	int count=0x400+2;
 	char buf[8192];
 	uint64_t time;
-#if 1
+#if 0
 
 	for(int i=0;i<8000;i++)
 	{
@@ -40,16 +43,21 @@ int main()
 #else
 	message_file mf(stdin);
 	count=0;
+	uint64_t time_tmp=0;
 	while(len>0)
 	{
-		while((len=mf.get_line(&time,&buf[count],sizeof(buf)-count)))
+		//while((len=mf.get_line(&time,&buf[count],sizeof(buf)-count)))
 		{
+			std_info("......%lu",time);
 			count+=len;
 			if(count>1024)
 				break;
 		}
-
-		log_info("count=%d",count);
+		len=mf.get_line(&time,&buf[count],sizeof(buf)-count);
+		if(0==time_tmp)	
+		  time_tmp =time;
+		std::this_thread::sleep_for(std::chrono::milliseconds(time-time_tmp));
+		log_info("count=%d,time=%llu buf=%s",len,time,buf);
 		if(count!=zio::writev(sock,buf,count))
 			break;
 

Dosya farkı çok büyük olduğundan ihmal edildi
+ 31 - 426
config.log


+ 5 - 5
config.status

@@ -651,15 +651,15 @@ S["INSTALL_PROGRAM"]="${INSTALL}"
 S["target_alias"]=""
 S["host_alias"]=""
 S["build_alias"]=""
-S["LIBS"]="-lev "
+S["LIBS"]="-lzlog -lev "
 S["ECHO_T"]=""
 S["ECHO_N"]="-n"
 S["ECHO_C"]=""
 S["DEFS"]="-DPACKAGE_NAME=\\\"yals\\\" -DPACKAGE_TARNAME=\\\"yals\\\" -DPACKAGE_VERSION=\\\"1.0\\\" -DPACKAGE_STRING=\\\"yals\\ 1.0\\\" -DPACKAGE_BUGREPORT=\\\"BUG-REPORT-ADDRESS"\
-"\\\" -DPACKAGE_URL=\\\"\\\" -DPACKAGE=\\\"yals\\\" -DVERSION=\\\"1.0\\\" -DHAVE_LIBEV=1 -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H="\
-"1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_ARPA_INET_H=1 -DHAVE_FCNTL_H"\
-"=1 -DHAVE_NETINET_IN_H=1 -DHAVE_STDINT_H=1 -DHAVE_STRING_H=1 -DHAVE_SYS_SOCKET_H=1 -DHAVE_UNISTD_H=1 -DHAVE__BOOL=1 -DHAVE_STDLIB_H=1 -DHAVE_MALLOC="\
-"1 -DHAVE_STDLIB_H=1 -DHAVE_REALLOC=1 -DHAVE_INET_NTOA=1 -DHAVE_MEMSET=1 -DHAVE_SOCKET=1"
+"\\\" -DPACKAGE_URL=\\\"\\\" -DPACKAGE=\\\"yals\\\" -DVERSION=\\\"1.0\\\" -DHAVE_LIBEV=1 -DHAVE_LIBZLOG=1 -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1"\
+" -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_ARPA_INET_H"\
+"=1 -DHAVE_FCNTL_H=1 -DHAVE_NETINET_IN_H=1 -DHAVE_STDINT_H=1 -DHAVE_STRING_H=1 -DHAVE_SYS_SOCKET_H=1 -DHAVE_UNISTD_H=1 -DHAVE__BOOL=1 -DHAVE_STDLIB_H"\
+"=1 -DHAVE_MALLOC=1 -DHAVE_STDLIB_H=1 -DHAVE_REALLOC=1 -DHAVE_INET_NTOA=1 -DHAVE_MEMSET=1 -DHAVE_SOCKET=1"
 S["mandir"]="${datarootdir}/man"
 S["localedir"]="${datarootdir}/locale"
 S["libdir"]="${exec_prefix}/lib"

+ 11 - 2
main.cpp

@@ -4,13 +4,16 @@
 #include "db_api/CDBConnPool.h"
 #include "websocket/wsClientMgr.h"
 #include "websocket/wsTimerThread.h"
+#include "card.h"
+#include "ant.h"
+#include "card_path.h"
 
 struct Init_Setting
 {
 	void init()
 	{
 		YADB::_DB_POOL_SETTING_ DBSetting;
-		log_init("../dist/ect/log.ini");
+		log_init("../dist/etc/log.ini");
 		IniFile ini;
 		ini.open("./config.ini");
 
@@ -73,9 +76,15 @@ struct Init_Setting
 int main()
 {
 	Init_Setting is;
+	log_init("../dist/etc/log.ini");
 	//init log sql websockt.
-	is.init();
+//	is.init();
 
+	log_info("herer..init from db...");
+	sit_list::instance()->load_from_db();
+	card_list::instance()->init_card_from_db();
+	card_path cp;
+	cp.init(*sit_list::instance());
 	net_service mh;
 	service_handle::instance(&mh)->run(4000);
 

+ 2 - 1
message.cpp

@@ -1,6 +1,7 @@
 #include <math.h>
 #include "zstream.h"
 #include "message.h"
+#include "log.h"
 
 void message_locinfo::zero_this()
 {
@@ -17,7 +18,6 @@ void message_locinfo::load(zistream&is,bool tdoa)
 	m_card_type=b;
 	m_batty_status&=0xF;
 
-
 	//角度
 	is>>b;
 	if(m_card_type==1)
@@ -52,6 +52,7 @@ void message_locinfo::load(zistream&is,bool tdoa)
 	uint16_t sp1=0,sp2=0;
 	is>>sp1>>sp2;
 	m_rssi=10*log10(1.*sp1*(1<<17)/pow(sp2-64.,2))-121.74;
+	log_info("timestamp=%llu,type:%d,card_id:%d,ct:%d,status:%d,acc=%d,tof=%llu,ant_id:%d,spq=%d",m_time_stamp,m_card_type,m_card_id,m_card_ct,m_batty_status,m_acc,m_tof,m_ant_id,m_rssi);
 }
 
 void message_tdoasync::zero_this()

+ 1 - 1
message.h

@@ -16,7 +16,7 @@ struct message_locinfo
 	uint32_t m_card_id;
 	uint64_t m_tof;
 	uint16_t m_card_ct;
-	uint16_t m_batty_status;
+	uint8_t m_batty_status;
 	uint8_t  m_callinfo;//0x80-呼救,0x01-一般呼叫,0x02-紧急呼叫
 	uint8_t  m_rav;
 	uint8_t  m_acc;

+ 15 - 7
net-service.cpp

@@ -10,7 +10,7 @@
 #include <log.h>
 #include <znet.h>
 #include <zstream.h>
-
+#include <sys/time.h>
 #include "worker.h"
 #include "tdoa_sync.h"
 #include "net-service.h"
@@ -28,13 +28,7 @@ net_service::~net_service()
 
 void net_service::on_message(std::shared_ptr<client> clt,const char*data,size_t len)
 {
-	//std::vector<char> v(data,data+len);
 	//clt->send(std::move(v));
-
-	//log_info("recv a message ,len=%d",len);
-	//logn_bin(1,"50ms .test",data,len);
-	//return;
-
 	logn_bin(1,"",data,len);//输出二进制日志
 
 	zistream is(data,len-2);
@@ -46,12 +40,26 @@ void net_service::on_message(std::shared_ptr<client> clt,const char*data,size_t
 			{
 				uint32_t site_id;
 				is>>site_id>>skip(12);
+				struct timeval tv;
+				gettimeofday(&tv,NULL);
+				uint64_t t = tv.tv_sec*1000 + tv.tv_usec/1000;
+				int index=0;
 				while(!is.eof())
 				{
+					uint64_t tstamp = t -1000 + 50 + index* 45;
+					index++;
 					task*t=task::alloc<message_locinfo>();
 					message_locinfo&m=t->body<message_locinfo>();
 					m.load(is,cmd==0x863b);
+					m.m_time_stamp=tstamp;
 					m.m_site_id=site_id;
+					if(m.m_card_id != 1222)
+					{
+					  log_error("----error cardid");
+					  continue;
+					}
+
+					std_info("....%llu",m.m_time_stamp);
 					t->m_cmd_code=cmd;
 					t->m_hash_id=m.m_card_id;
 					m_loc_worker->request(t);

+ 1 - 1
path_tof.txt

@@ -35,7 +35,7 @@
 317, 0, 5674.04, 379, 0, 5800.67, 417, 0, 0,NULL, -1
 318, 0, 4727, 89.7, 0, 6144.3, 523, 0, 0,NULL, -1
 320, 0, 4727, 89.7, 0,  6144.3, 523, 0, 0,NULL, -1
-402, 0, 4746.2, -110.8, 0,4746.2, -39.1, 0, 0,NULL, -1
+402, -1, 4746.2, -110.8, 0,4746.2, -39.1, 0, 0,NULL, -1
 501, 0, 2952, 73, 0, 2952, 181.85, 0, 0,NULL, -1
 504, 0, 2952, 114.6, 0, 2952, 226.85, 0, 0,NULL, -1
 505, 0, 2952, 75, 0,2952, 369.85, 0, 0,NULL, -1

+ 14 - 6
select_tool.cpp

@@ -177,6 +177,7 @@ bool select_point_object::select_solution(const std::vector<point> &vp,const sit
 		m_d(0).inc_cl(10);
    }
    point pt = select_solution0(tvp,sit->m_scale);
+   std_info("-----select_solution0:x:%.2f,y:%.2f",pt.x,pt.y);
 	m_d(0).set(pt);
 	if(pt.empty())
 		return false;
@@ -190,6 +191,7 @@ bool select_point_object::select_solution(const std::vector<point> &vp,const sit
 
     //revise_by
     //
+	std_info("revise_by_history:::%llu",m_d(0).m_time);
     bool fg=revise_by_history(pt,sit,m_d(0).m_time);
     if(!card_path::inst().is_at_path(pt))
 	{
@@ -261,10 +263,12 @@ bool select_point_object::select_solution(const std::vector<point> &vp,const sit
 				double tk=(d0-d1)/(t0-t1), tb=d1-tk*t1;		//d1+(d0-d1)/(t0-t1)*(t-t1)
 				for(double ti=tbegin;ti<t0;ti=ti+1)
 				{
+					std_info("add ..seelct");
 					m_fitk.add(ti, tk*ti+tb);
 				}
 			}
 		}
+		m_fitk.add(m_last->m_time/1000.,m_begin->loc_dist(*m_last));
 
 		if(m_d.size()>1)
 		{
@@ -340,12 +344,14 @@ void select_point_object::remove_history()
 					double tk=(d0-d1)/(t0-t1), tb=d1-tk*t1;		//d1+(d0-d1)/(t0-t1)*(t-t1)
 					for(double ti=tbegin;ti<t0;ti=ti+1)
 					{
+						std_info("add remove..");
 						m_fitk.add(ti, tk*ti+tb);
 					}
 				}
 			}
 
 			dist=m_begin->loc_dist(m_d(i)[0]);
+						std_info("add remove..");
 			m_fitk.add(m_d(i).m_time/1000.,dist);
 
 			if(i==len)
@@ -360,13 +366,13 @@ void select_point_object::remove_history()
 }
 void select_point_object::save_k()
 {
+	std_info("save_k()...............");
 	const fit_result*fk=best_fit_raw(0,4);
 	if(!fk)
 	{
 		m_cur_fit.reset();
 		return;
 	}
-
 	m_cur_fit=*fk;
 
 	fit_result&r=m_cur_fit;
@@ -394,7 +400,7 @@ fit_result* select_point_object::best_fit_raw(int num_point,int start,int last)
 	last  =std::min(last,m_fitk.tool_size());
 	if(last==-1)
 		last=m_fitk.tool_size();
-
+	std_info("best_fit_raw :%d:%d",start,last);
 	for(int i=start;i<last;i++)
 	{
 		if(!m_fitk[i].is_valid())
@@ -425,13 +431,14 @@ loc_point select_tool_person_1::select_solution(const std::vector<point> vp,cons
     //select point.
     if(lm[0].tool_index() == 0)  
     {
-        m_spo = new person_point_filter(); 
+		if(m_spo==nullptr)
+			m_spo = new person_point_filter(); 
         lp=m_spo->select_solution_impl(vp,lm);
     }
     else if (lm[0].tool_index() == 2)
     {
         //for now..
-        m_spo = new person_point_filter(); 
+        //m_spo = new person_point_filter(); 
         lp=m_spo->select_solution_impl(vp,lm);
     }
     else
@@ -445,13 +452,14 @@ loc_point select_tool_car_1::select_solution(const std::vector<point> vp,const s
     //select point.
     if(lm[0].tool_index() == 0)  
     {
-        m_spo = new car_point_filter(); 
+		if(m_spo==nullptr)
+			m_spo = new car_point_filter(); 
         lp=m_spo->select_solution_impl(vp,lm);
     }
     else if (lm[0].tool_index() == 2)
     {
         //for now..
-        m_spo = new car_point_filter(); 
+        //m_spo = new car_point_filter(); 
         lp=m_spo->select_solution_impl(vp,lm);
     }
     else

+ 16 - 10
select_tool.h

@@ -140,7 +140,7 @@ struct person_point_filter:select_point_object
         return a;
     }
 
-    virtual bool revise_by_history(point & pt, const site*sit, int64_t m_time)
+    virtual bool revise_by_history(point & pt, const site*sit, int64_t timestamp)
     {
         point dstp = sit->get_dstp(pt);
         if(dstp.empty())
@@ -468,12 +468,13 @@ struct car_point_filter:select_point_object
 		return dist;
 	}
 
-    virtual bool revise_by_history(point & pt, const site*sit, int64_t m_time)
+    virtual bool revise_by_history(point & pt, const site*sit, int64_t timestamp)
     {
-        std_info("revise_____-before:%f,%f",pt.x,pt.y);
+        std_info("revise_____-before:%f,%f,%llu",pt.x,pt.y,timestamp);
         bool flag =false;
 		if(m_line.empty() || !m_line.contain(m_d(0),0.1))
 		{
+			std_info("m_line .empty() ......");
 			m_last_fit_valid = false;
 			m_last_fit_time_sec = 0;
 			m_last_fit_k = 0;
@@ -493,7 +494,7 @@ struct car_point_filter:select_point_object
 
 		// convert pt to distance
 		double dist = convert_pt_to_dist(pt, sit);
-		double m_time_sec = m_time / 1000.;	//second
+		double m_time_sec = timestamp / 1000.;	//second
 		//if(m_time_sec - m_last_fit_nearest_time_sec > 30)m_last_fit_valid = false;
 		if(m_time_sec - m_last_fit_time_sec > 60)m_last_fit_valid = false;
 
@@ -503,6 +504,10 @@ struct car_point_filter:select_point_object
 		// choose data by fit
 		const fit_result*fit=best_fit();
 		bool if_change_fit=false;
+		if(fit !=nullptr)
+		  std_info("fit != nullptr...m_time_sec:%f,fitK.x():%f",m_time_sec,m_fitk.x(0));
+		else 
+		  std_info("fit ==nullptr...");
 		if(fit!=nullptr && fit->ke<=1 && m_time_sec - m_fitk.x(0) <= 15 && fabs(fit->k) < m_pos_differ)
 		{							//printf("change fit time:%f,%f,%f\n",m_time_sec, fit->d.x(0), m_time_sec - fit->d.x(0));
 			
@@ -549,7 +554,7 @@ struct car_point_filter:select_point_object
 			// update acc
 			//m_accumulate_acc=0
 
-			printf("change line, k=%f,ke=%f\n",fit->k,fit->ke);
+			printf("change line------------, k=%f,ke=%f\n",fit->k,fit->ke);
 		}
 
 		// revise
@@ -558,6 +563,7 @@ struct car_point_filter:select_point_object
 							//estimate_dist, dist, m_last_fit_valid, m_time_sec - m_last_fit_time_sec);
 		if(m_last_fit_valid && m_time_sec - m_last_fit_time_sec < 20)
 		{
+			std_info("here ....m_time_sec:%llu,m_last_fit_time_sec:%llu",m_time_sec,m_last_fit_time_sec);
 			if(fabs(m_last_fit_k) > 0.5 && fabs(estimate_dist-dist)>m_fit_differ)
 				dist=estimate_dist;
 			else if(fabs(m_last_fit_k) <= 0.5 && fabs(estimate_dist-dist)>m_fit_differ * 2)
@@ -576,7 +582,7 @@ struct car_point_filter:select_point_object
 
 		// create the list
 		//if(m_accumulate_acc<-10)generate(mpt, sit,false); generate single point
-		if(m_last_fit_valid && m_time/1000. - m_last_fit_time_sec < 20 && fabs(m_last_fit_k) > 0.5)
+		if(m_last_fit_valid && timestamp/1000. - m_last_fit_time_sec < 20 && fabs(m_last_fit_k) > 0.5)
 			generate_list(mpt, sit, true);	//generate the whole list
 		else
 			generate_list(mpt, sit, false);	//generate single point
@@ -1066,22 +1072,22 @@ struct select_tool_manage
 {
    void create_tool(const std::string &s,std::shared_ptr<select_tool> &set,std::shared_ptr<smooth_tool> &smt)
    {
-        if(s.compare(std::string{"person1"}))
+        if(!s.compare(std::string{"person1"}))
         {
             set=std::make_shared<select_tool_person_1>();
             smt=std::make_shared<smooth_tool_person_1>(set);
         }
-        else if(s.compare(std::string{"person2"}))
+        else if(!s.compare(std::string{"person2"}))
         {
             set=std::make_shared<select_tool_person_2>();
             smt=std::make_shared<smooth_tool_person_1>(set);
         }
-        else if(s.compare(std::string{"car1"}))
+        else if(!s.compare(std::string{"car1"}))
         {
             set=std::make_shared<select_tool_car_1>();
             smt=std::make_shared<smooth_tool_car_1>(set);
         }
-        else if(s.compare(std::string{"drivingface1"}))
+        else if(!s.compare(std::string{"drivingface1"}))
         {
             set=std::make_shared<select_tool_drivingface_car_1>();
             smt=std::make_shared<smooth_tool_drivingface_car_1>(set);