Browse Source

Merge branch 'master' of http://local.beijingyongan.com:3000/linux-dev/ya-serv

主要将某些shared_ptr修改为unique_ptr,对于只想做生命周期控制的智能指针,建议使用unique_ptr
zzj 6 years ago
parent
commit
98429810a1
29 changed files with 1969 additions and 1137 deletions
  1. 3 0
      .gitignore
  2. 0 589
      IniFile.cpp
  3. 0 100
      IniFile.h
  4. 17 44
      Makefile
  5. 1 5
      Makefile.am
  6. 1263 0
      Makefile.in
  7. 6 5
      ant.cpp
  8. 2 2
      ant.h
  9. 19 19
      autom4te.cache/requests
  10. 204 47
      card.cpp
  11. 55 8
      card.h
  12. 12 6
      card_path.cpp
  13. 4 4
      db_api/CDBConnPool.cpp
  14. 16 9
      loc_point.cpp
  15. 2 1
      loc_point.h
  16. 11 7
      main.cpp
  17. 0 6
      net-service.cpp
  18. BIN
      path
  19. 7 2
      select_tool.cpp
  20. 330 269
      select_tool.h
  21. BIN
      sio.tar.gz
  22. 1 1
      visit.cpp
  23. 3 3
      websocket/jsonBuilder.cpp
  24. BIN
      websocket/socket.io-client-cpp_test.cpp
  25. 2 2
      websocket/wsClientMgr.h
  26. 2 3
      websocket/wsTimerThread.cpp
  27. 1 1
      websocket/wsTimerThread.h
  28. 5 1
      websocket/ws_common.h
  29. 3 3
      worker.cpp

+ 3 - 0
.gitignore

@@ -1,6 +1,9 @@
 .*
 *.o
 *bak
+*.sh
+*.out
+*.raw
 /.deps/
 /autom4te.cache/
 Makefile

+ 0 - 589
IniFile.cpp

@@ -1,589 +0,0 @@
-#include <assert.h>
-#include <fstream>
-#include <cstring>
-#include <algorithm>
-#include <stdio.h>
-#include "IniFile.h"
-
-#if _MSC_VER >=1400
-	const std::wstring to_wcs( const std::string& src )
-	{
-		std::string prev = setlocale(LC_CTYPE,NULL);	// 保存原来的locale
-		setlocale( LC_CTYPE, "chs" );					// 设置当前locale为chs,这在非简体中文平台上不可缺少
-
-		size_t count1 = mbstowcs(NULL, src.c_str(), 0); // 计算新字符串长度
-		std::wstring des(count1, L' ');
-		size_t count2 = mbstowcs(&des[0], src.c_str(), count1 ); // 转化
-		assert(count1 == count2);
-
-		setlocale( LC_CTYPE, prev.c_str()); // 恢复到原来的locale
-		return des;
-	}
-#endif
-
-	IniFile::IniFile()
-	{
-		m_prevInsertIt = m_lines.end();
-	}
-
-	IniFile::~IniFile (void)
-	{
-		clear();
-	}
-
-	bool IniFile::open(const char* filename)
-	{
-		assert(filename);
-
-		clear();
-#if _MSC_VER >=1400
-		std::wstring wcsfile = to_wcs(filename);
-		std::ifstream fin(wcsfile.c_str());	
-#else
-		std::ifstream fin(filename);
-#endif
-		if(fin.is_open())
-		{
-			while(!fin.eof()) 
-			{
-				std::string tmp;
-				getline(fin, tmp, '\n');
-				
-				if(fin.eof() && tmp.empty())
-					break;
-
-				// if *NIX file format, remove the CR
-				if(tmp.length() >= 1 && tmp[tmp.length()-1] == '\r')
-				{
-					tmp.resize(tmp.length()-1);
-				}
-				parseLine(tmp);
-			}
-			makeIndex();
-			return true;
-		}
-		return false;
-	}
-
-	bool IniFile::save(const char* filename)
-	{
-		assert(filename);
-#if _MSC_VER >=1400
-		std::wstring wcsfile = to_wcs(filename);
-		std::ofstream fout(wcsfile.c_str());
-#else
-		std::ofstream fout(filename);
-#endif
-		if(fout.is_open())
-		{
-			std::list<LineFrame*>::iterator it = m_lines.begin();
-			for(; it != m_lines.end(); ++it)
-			{
-				LineFrame* frame = *it;
-				switch(frame->m_type) 
-				{
-				case TYPE_COMMENT:
-					fout << frame->m_comment << std::endl;
-					break;
-				case TYPE_SECTION:
-					fout << "[" << frame->m_section << "]" << frame->m_comment << std::endl;
-					break;
-				case TYPE_KEYVALUE:
-					{
-						if(frame->m_valueHasComment)
-							fout << frame->m_key << "=\"" << frame->m_value << "\"" << frame->m_comment << std::endl;
-						else
-							fout << frame->m_key << "=" << frame->m_value << frame->m_comment << std::endl;
-						
-					}
-					break;
-				default:
-					break;
-				}
-			}
-			return true;
-		}
-		return false;
-	}
-
-	void IniFile::clear()
-	{
-		std::list<LineFrame*>::iterator it = m_lines.begin();
-		for(; it != m_lines.end(); ++it)
-			delete *it;
-		m_lines.clear();
-		m_lineindex.clear();
-	}
-
-	bool IniFile::readBool(const char* section, const char* key, bool dft)
-	{
-		assert(section);
-		assert(key);
-
-		LineFrame *frame = findNotEmptyFrame(section, key);
-		if(frame)
-		{
-			if(ignoreCaseCompare(frame->m_value,"true"))
-				return true;
-            else if(ignoreCaseCompare(frame->m_value,"false"))
-				return false;
-			else
-				return dft;
-		}
-		return dft;
-	}
-
-	int IniFile::readInt(const char* section, const char* key, int dft)
-	{
-		assert(section);
-		assert(key);
-
-		LineFrame *frame = findNotEmptyFrame(section, key);
-		if(frame)
-		{
-			if ( frame->m_value.length() > 2 && frame->m_value[0] == '0' && frame->m_value[1] == 'x' )
-			{
-				int value = dft;
-				sscanf(frame->m_value.c_str(), "0x%x", &value );
-				return value;
-			}
-			else if ( frame->m_value.length() > 2 && frame->m_value[0] == '0' && frame->m_value[1] == 'X' )
-			{
-				int value = dft;
-				sscanf(frame->m_value.c_str(), "0X%x", &value );
-				return value;
-			}
-			else
-			{
-				int value = dft;
-				sscanf(frame->m_value.c_str(), "%u", &value );
-				return value;
-			}
-		}
-		else
-		{
-			return dft;
-		}
-	}
-
-	double IniFile::readDouble(const char* section, const char* key, double dft)
-	{
-		assert(section);
-		assert(key);
-
-		LineFrame *frame = findNotEmptyFrame(section, key);
-		if(frame)
-		{
-			return atof(frame->m_value.c_str());			
-		}
-		else
-		{
-			return dft;
-		}
-	}
-
-	const char* IniFile::readString(const char* section, const char* key, const char* dft)
-	{
-		assert(section);
-		assert(key);
-
-		LineFrame *frame = findFrame(section, key);
-		if(frame)
-		{
-			return frame->m_value.c_str();
-		}
-		else
-		{
-			return dft;
-		}
-	}
-
-	void IniFile::writeBool(const char* section, const char* key, bool val)
-	{
-		assert(section);
-		assert(key);
-
-		if(val)
-			writeString(section, key, "true");
-		else
-			writeString(section, key, "false");
-	}
-	void IniFile::writeInt(const char* section, const char* key, int val)
-	{
-		assert(section);
-		assert(key);
-
-		char tmp[32];
-		sprintf(tmp, "%d", val);
-		writeString(section, key, tmp);
-	}
-
-	void IniFile::writeHex(const char* section, const char* key, uint32_t val)
-	{
-		assert(section);
-		assert(key);
-
-		char tmp[32];
-		sprintf(tmp, "0x%X", val);
-		writeString(section, key, tmp);
-	}
-
-	void IniFile::writeDouble(const char* section, const char* key, double val)
-	{
-		assert(section);
-		assert(key);
-
-		char tmp[32];
-		sprintf(tmp, "%g", val);
-		writeString(section, key, tmp);
-	}
-
-	void IniFile::writeString(const char* section, const char* key, const char* val)
-	{
-		assert(section);
-		assert(key);
-		assert(val);
-        
-		LineFrame *frame = findFrame(section, key);
-		if(frame)
-		{
-			// already exist, update it!
-			frame->m_value = val;
-			frame->m_valueHasComment = hasComment(val);
-		}
-		else
-		{	
-			std::list<LineFrame*>::iterator it;
-			// try cache, if failed then locate the end of this section
-			if(m_prevSection == section && m_prevInsertIt != m_lines.end())
-				it = m_prevInsertIt;
-			else
-				it = findSectionEnd(section);
-			 
-			// new key insert into near by section, it will speed up all write method;
-			// std::list<LineFrame*>::iterator it = findSection(section);
-			if(it != m_lines.end())
-			{
-				frame = new LineFrame;
-				frame->m_type = TYPE_KEYVALUE;
-				frame->m_key = key;
-				frame->m_value = val;
-				frame->m_valueHasComment = hasComment(val);
-				m_lines.insert(++it, frame);
-
-				m_prevSection = section;
-				m_prevInsertIt = --it;
-			}
-			else
-			{
-				// no section yet! create it!
-				frame = new LineFrame;
-				frame->m_type = TYPE_SECTION;
-				frame->m_section = section;
-				m_lines.push_back(frame);
-
-				frame = new LineFrame;
-				frame->m_type = TYPE_KEYVALUE;
-				frame->m_key = key;
-				frame->m_value = val;
-				frame->m_valueHasComment = hasComment(val);
-				m_lines.push_back(frame);
-			}
-			// update index
-			m_lineindex[section][key] = frame;
-		}
-	}
-
-	bool IniFile::hasSection(const char* section)
-	{
-		return m_lineindex.find(section) != m_lineindex.end();
-	}
-
-	bool IniFile::deleteSection(const char* section)
-	{
-		m_lineindex.erase(section);
-
-		std::list<LineFrame*>::iterator it = findSection(section);
-		if(it != m_lines.end())
-		{
-			// delete the section at first
-			delete *it;
-			m_lines.erase(it++);
-			// and delete all key-value until occurs next section(or end of file)
-			while(it != m_lines.end() && (*it)->m_type != TYPE_SECTION)
-			{
-				delete *it;
-				m_lines.erase(it++);
-			}
-			return true;
-		}
-		return false;
-	}
-	bool IniFile::deleteKey(const char* section, const char* key)
-	{
-		assert(section);
-		assert(key);
-
-		std::list<LineFrame*>::iterator it = findSection(section);
-		if (it == m_lines.end())
-		{
-			return false;
-		}
-		// find from next line
-		++it;
-		for( ; it != m_lines.end(); ++it)
-		{
-			if((*it)->m_type == TYPE_SECTION)
-			{	// occur next section
-				break;
-			}
-			if((*it)->m_type == TYPE_KEYVALUE &&
-                ignoreCaseCompare((*it)->m_key,key))
-			{
-				m_lineindex[section].erase(key);
-				delete *it;
-				m_lines.erase(it);
-				return true;
-			}
-		}
-		return false;
-	}
-
-	void IniFile::readSection(const char* section, std::map<std::string, std::string>& kvset)
-	{
-		assert(section);
-
-		std::list<LineFrame*>::iterator it = findSection(section);
-		if(it != m_lines.end())
-			++it;
-		for( ; it != m_lines.end(); ++it)
-		{
-			if((*it)->m_type == TYPE_SECTION)
-			{	// occur next section
-				break;
-			}
-			if((*it)->m_type == TYPE_KEYVALUE)
-			{
-				kvset.insert(std::make_pair((*it)->m_key, (*it)->m_value));
-			}
-		}
-	}
-
-	void IniFile::parseLine(const std::string& line) 
-	{
-		LineFrame* frame = new LineFrame;
-		m_lines.push_back(frame);
-		frame->m_type = TYPE_COMMENT; // dft is comment
-
-		// 1. check full commented line 
-		if(isCommentLine(line))
-		{
-			frame->m_type = TYPE_COMMENT;
-			frame->m_comment = line;
-			return ;
-		}
-
-		// 2. try the find section
-		std::string::size_type first = line.find('[');
-		std::string::size_type last = line.rfind(']');;
-
-		if(first != std::string::npos && last != std::string::npos && first != last+1)
-		{
-			frame->m_section = line.substr(first+1,last-first-1);
-			if(hasComment(frame->m_section))
-			{
-				frame->m_type = TYPE_COMMENT;
-				frame->m_comment = line;
-			}
-			else
-			{
-				frame->m_type = TYPE_SECTION;
-				// remember the possible comments
-				frame->m_comment = line.substr(last+1);
-			}
-			return ;
-		}
-
-		// 3. find key-value pattern
-		first = line.find('=');
-		if(first == std::string::npos)
-			return ;
-
-		std::string strtmp1 = line.substr(0, first);
-		if(hasComment(strtmp1))
-		{
-			// such case
-			// something # key=value
-			// we consider such meaningless line as comment
-			frame->m_type = TYPE_COMMENT;
-			frame->m_comment = line;
-			return ;
-		}
-
-		std::string key = constTrim(strtmp1);
-		if(key.empty())
-		{
-			// such case
-			// = value
-			frame->m_type = TYPE_COMMENT;
-			frame->m_comment = line;
-			return ;
-		}
-
-		frame->m_type = TYPE_KEYVALUE;
-		// remember the original form
-		frame->m_key = key;
-		std::string strtmp2 = line.substr(first+1);
-		std::string::size_type comment = findComment(strtmp2);
-		std::string value = constTrim(strtmp2.substr(0, comment));
-	
-		if(value.size()>1 && value[0] == '\"' && value[value.size()-1] == '\"')
-		{
-			frame->m_value = value.substr(1, value.size()-2);
-			frame->m_valueHasComment = true;
-		}
-		else
-		{
-			frame->m_value = value;
-		}
-
-		if(comment != std::string::npos)
-			frame->m_comment = constTrim(strtmp2.substr(comment));
-
-		return ;
-	}
-
-	std::string::size_type IniFile::findComment(const std::string& line)
-	{
-		bool inString = false;
-		for(size_t i=0; i<line.size(); i++)
-		{
-			if(line[i] == '\"')
-			{
-				inString = true;
-			}
-			
-			if(inString)
-				continue;
-
-			if(line[i] == '/')
-			{
-				// "//"
-				if(i+1 != line.length() && line[i+1] == '/')
-					return i;
-			}
-			else if(line[i] == '#' || line[i] == ';')
-			{
-				return i;
-			}
-		}
-		return std::string::npos;
-
-	}
-
-	bool IniFile::isCommentLine(const std::string& line)
-	{
-		// skip the space and tab chars
-		std::string::size_type charBegin = line.find_first_not_of("\t ");
-		return charBegin != std::string::npos && charBegin == findComment(line);
-	}
-
-	bool IniFile::hasComment(const std::string& line)
-	{
-		return findComment(line) != std::string::npos;
-	}
-
-	std::list<LineFrame*>::iterator IniFile::findSection(const char* section)
-	{
-		std::list<LineFrame*>::iterator it = m_lines.begin();
-		for( ; it != m_lines.end(); ++it)
-		{
-			LineFrame* frame = *it;
-			if(frame->m_type == TYPE_SECTION 
-				&& ignoreCaseCompare(frame->m_section,section))
-			{
-				break;
-			}
-		}
-		return it;
-	}
-	
-	std::list<LineFrame*>::iterator IniFile::findSectionEnd(const char* section)
-	{
-		std::list<LineFrame*>::iterator it = findSection(section);
-		if(it != m_lines.end())
-		{
-			// find from next line
-			++it;
-			while(it != m_lines.end() && (*it)->m_type != TYPE_SECTION)
-			{
-				++it;
-			}
-			// the end of section is one step back of next section line(or end())
-			--it;
-		}
-		return it;
-	}
-
-	LineFrame* IniFile::findFrame(const char*section, const char* key)
-	{
-		KeyValueIndex::iterator it = m_lineindex.find(section);
-		if(it != m_lineindex.end())
-		{
-			KeyValueMap::iterator it2 = it->second.find(key);
-			if(it2 != it->second.end())
-				return it2->second;
-		}
-		return 0;
-	}
-
-	LineFrame* IniFile::findNotEmptyFrame(const char*section, const char* key)
-	{
-		LineFrame* frame = findFrame(section, key);
-		if(frame && !frame->m_value.empty())
-			return frame;
-		else
-			return 0;
-	}
-
-	void IniFile::makeIndex()
-	{
-		std::list<LineFrame*>::iterator it = m_lines.begin();
-		LineFrame* frame = NULL;
-		KeyValueIndex::iterator kvmit = m_lineindex.end();
-		while(it != m_lines.end())
-		{
-			frame = *it;
-			++it;
-
-			// 找到了一个SECTION的开始
-			if(frame->m_type == TYPE_SECTION)
-			{
-				kvmit = (m_lineindex.insert(std::make_pair(frame->m_section, KeyValueMap()))).first;
-			}
-			else if(frame->m_type == TYPE_KEYVALUE && kvmit != m_lineindex.end())
-			{
-				(kvmit->second)[frame->m_key]= frame;
-			}
-		}
-	}
-#ifdef __TEST
-int main()
-{
-    IniFile ini;
-    ini.open("config.ini");
-    std::string host = ini.readString("db","host","");
-    std::string url = ini.readString("serversetting","web1","");
-    if(!host.empty())
-      printf("%s\n",host.c_str());
-    printf("%s\n",url.c_str());
-    ini.writeInt("dbdb","timeout",123);
-    ini.writeInt("db","a",123123);
-    ini.writeInt("db01","a",123);
-    ini.writeString("xxxx","name","lemon");
-    printf("tol:%d\n",ini.readInt("serversetting","timeout",0));
-    //clear all
-    //ini.clear(); 
-    ini.save("config.ini");
-}
-#endif

+ 0 - 100
IniFile.h

@@ -1,100 +0,0 @@
-#ifndef INCLUDED_CACTI_UTIL_INIFILE_H
-#define INCLUDED_CACTI_UTIL_INIFILE_H
-
-#include <string>
-#include <list>
-#include <map>
-#include <functional>
-
-    enum LINETYPE {
-        TYPE_SECTION    = 1,
-        TYPE_KEYVALUE   = 2,
-        TYPE_COMMENT    = 3,
-    };
-
-    class LineFrame
-    {
-        public:
-            LineFrame()
-                : m_valueHasComment(false)
-            {}
-            LINETYPE m_type;
-            std::string m_section;		// when TYPE_SECTION
-            std::string m_key;			// when TYPE_KEYVALUE
-            std::string m_value;		// when TYPE_KEYVALUE
-            bool m_valueHasComment;		// value 字段是否包含有注释字符,用引号引住的value可以包含注释字符
-            std::string m_comment; 		// all case
-    };
-    typedef std::map<std::string, LineFrame*> KeyValueMap; // key--->frame
-    typedef std::map<std::string, KeyValueMap> KeyValueIndex;
-    class IniFile
-    {		
-        public:
-            IniFile();
-            ~IniFile(void);
-            bool open(const char* filename);
-            bool save(const char* filename);
-            void clear();
-
-            bool readBool(const char* section, const char* key, bool dft);
-            int readInt(const char* section, const char* key, int dft);
-            double readDouble(const char* section, const char* key, double dft);
-            const char* readString(const char* section, const char* key, const char* dft);
-
-            void writeBool(const char* section, const char* key, bool val);
-            void writeInt(const char* section, const char* key, int val);
-            void writeDouble(const char* section, const char* key, double val);
-            void writeString(const char* section, const char* key, const char* val);
-            void writeHex(const char* section, const char* key, std::uint32_t val);
-
-            bool hasSection(const char* section);
-            bool deleteSection(const char* section);
-            bool deleteKey(const char* section, const char* key);
-            void readSection(const char* section, std::map<std::string, std::string>& kvset);
-        private:
-            void parseLine(const std::string& line);
-            std::string::size_type findComment(const std::string& line);
-            std::string::size_type findValueComment(const std::string& line);
-            bool isCommentLine(const std::string& line);
-            bool hasComment(const std::string& line);
-            std::list<LineFrame*>::iterator findSection(const char* section);
-            std::list<LineFrame*>::iterator findSectionEnd(const char* section);
-            LineFrame* findFrame(const char*section, const char* key);
-            LineFrame* findNotEmptyFrame(const char*section, const char* key);
-            void makeIndex();
-            std::string constTrim(const std::string& s) 
-            {
-                if(s.empty())
-                  return s;
-                std::string::size_type b = s.find_first_not_of(" \t");
-                if(b == std::string::npos) // No non-spaces
-                  return "";
-                std::string::size_type e = s.find_last_not_of(" \t");
-                return std::string(s, b, e - b + 1);
-            }
-            bool ignoreCaseCompare(const std::string& left, const std::string& right)
-            {
-                std::string tmpleft = constTrim(left);
-                std::string tmpright= constTrim(right);
-                toUpper(tmpleft);
-                toUpper(tmpright);
-                return tmpleft == tmpright;
-            }
-            void toUpper(std::string& str)
-            {
-                for(size_t i=0; i<str.length(); i++)
-                  str[i] = ::toupper(str[i]);
-            }
-
-            void toLower(std::string& str)
-            {
-                for(size_t i=0; i<str.length(); i++)
-                  str[i] = ::tolower(str[i]);
-            }
-        private:
-            std::list<LineFrame*> m_lines;
-            KeyValueIndex m_lineindex;		// section --> KeyValueMap
-            std::string m_prevSection;
-            std::list<LineFrame*>::iterator m_prevInsertIt;
-    };
-#endif // INCLUDED_CACTI_UTIL_INIFILE_H

+ 17 - 44
Makefile

@@ -49,8 +49,7 @@ NORMAL_UNINSTALL = :
 PRE_UNINSTALL = :
 POST_UNINSTALL = :
 bin_PROGRAMS = yals$(EXEEXT)
-noinst_PROGRAMS = client$(EXEEXT) async$(EXEEXT) test$(EXEEXT) \
-	visit$(EXEEXT)
+noinst_PROGRAMS = client$(EXEEXT) async$(EXEEXT) test$(EXEEXT)
 subdir = .
 DIST_COMMON = $(am__configure_deps) $(srcdir)/Makefile.am \
 	$(srcdir)/Makefile.in $(top_srcdir)/configure COPYING INSTALL \
@@ -82,11 +81,6 @@ test_OBJECTS = $(am_test_OBJECTS)
 test_LDADD = $(LDADD)
 test_LINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(test_LDFLAGS) \
 	$(LDFLAGS) -o $@
-am_visit_OBJECTS = visit-visit.$(OBJEXT)
-visit_OBJECTS = $(am_visit_OBJECTS)
-visit_LDADD = $(LDADD)
-visit_LINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(visit_LDFLAGS) \
-	$(LDFLAGS) -o $@
 am__objects_1 = yals-singleton_test_class1.$(OBJEXT) \
 	yals-wsClient.$(OBJEXT) yals-wsClientMgr.$(OBJEXT) \
 	yals-wsTimerThread.$(OBJEXT) yals-CDBConnect.$(OBJEXT) \
@@ -121,9 +115,9 @@ COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
 CCLD = $(CC)
 LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
 SOURCES = $(async_SOURCES) $(client_SOURCES) $(test_SOURCES) \
-	$(visit_SOURCES) $(yals_SOURCES)
+	$(yals_SOURCES)
 DIST_SOURCES = $(async_SOURCES) $(client_SOURCES) $(test_SOURCES) \
-	$(visit_SOURCES) $(yals_SOURCES)
+	$(yals_SOURCES)
 am__can_run_installinfo = \
   case $$AM_UPDATE_INFO_DIR in \
     n|no|NO) false;; \
@@ -150,20 +144,20 @@ distuninstallcheck_listfiles = find . -type f -print
 am__distuninstallcheck_listfiles = $(distuninstallcheck_listfiles) \
   | sed 's|^\./|$(prefix)/|' | grep -v '$(infodir)/dir$$'
 distcleancheck_listfiles = find . -type f -print
-ACLOCAL = ${SHELL} /home/zzj/ya-src/ya-serv/missing --run aclocal-1.12
+ACLOCAL = ${SHELL} /home/lemon/resource/ya-serv/missing --run aclocal-1.12
 AMTAR = $${TAR-tar}
-AUTOCONF = ${SHELL} /home/zzj/ya-src/ya-serv/missing --run autoconf
-AUTOHEADER = ${SHELL} /home/zzj/ya-src/ya-serv/missing --run autoheader
-AUTOMAKE = ${SHELL} /home/zzj/ya-src/ya-serv/missing --run automake-1.12
+AUTOCONF = ${SHELL} /home/lemon/resource/ya-serv/missing --run autoconf
+AUTOHEADER = ${SHELL} /home/lemon/resource/ya-serv/missing --run autoheader
+AUTOMAKE = ${SHELL} /home/lemon/resource/ya-serv/missing --run automake-1.12
 AWK = gawk
 CC = gcc
 CCDEPMODE = depmode=gcc3
-CFLAGS = -g
+CFLAGS = -g -O2
 CPP = gcc -E
 CPPFLAGS = 
 CXX = g++
 CXXDEPMODE = depmode=gcc3
-CXXFLAGS = -g
+CXXFLAGS = -g -O2
 CYGPATH_W = echo
 DEFS = 
 DEPDIR = .deps
@@ -180,9 +174,9 @@ INSTALL_SCRIPT = ${INSTALL}
 INSTALL_STRIP_PROGRAM = $(install_sh) -c -s
 LDFLAGS = 
 LIBOBJS = 
-LIBS = -lev 
+LIBS = -lzlog -lev 
 LTLIBOBJS = 
-MAKEINFO = ${SHELL} /home/zzj/ya-src/ya-serv/missing --run makeinfo
+MAKEINFO = ${SHELL} /home/lemon/resource/ya-serv/missing --run makeinfo
 MKDIR_P = /bin/mkdir -p
 OBJEXT = o
 PACKAGE = yals
@@ -197,10 +191,10 @@ SET_MAKE =
 SHELL = /bin/sh
 STRIP = 
 VERSION = 1.0
-abs_builddir = /home/zzj/ya-src/ya-serv
-abs_srcdir = /home/zzj/ya-src/ya-serv
-abs_top_builddir = /home/zzj/ya-src/ya-serv
-abs_top_srcdir = /home/zzj/ya-src/ya-serv
+abs_builddir = /home/lemon/resource/ya-serv
+abs_srcdir = /home/lemon/resource/ya-serv
+abs_top_builddir = /home/lemon/resource/ya-serv
+abs_top_srcdir = /home/lemon/resource/ya-serv
 ac_ct_CC = gcc
 ac_ct_CXX = g++
 am__include = include
@@ -220,7 +214,7 @@ host_alias =
 htmldir = ${docdir}
 includedir = ${prefix}/include
 infodir = ${datarootdir}/info
-install_sh = ${SHELL} /home/zzj/ya-src/ya-serv/install-sh
+install_sh = ${SHELL} /home/lemon/resource/ya-serv/install-sh
 libdir = ${exec_prefix}/lib
 libexecdir = ${exec_prefix}/libexec
 localedir = ${datarootdir}/locale
@@ -229,7 +223,7 @@ mandir = ${datarootdir}/man
 mkdir_p = $(MKDIR_P)
 oldincludedir = /usr/include
 pdfdir = ${docdir}
-prefix = /home/zzj/ya-src/ya-serv/../dist
+prefix = /usr/local
 program_transform_name = s,x,x,
 psdir = ${docdir}
 sbindir = ${exec_prefix}/sbin
@@ -261,9 +255,6 @@ client_LDFLAGS = ${AM_LDFLAGS}  -L. -lzlog
 test_SOURCES = test.cpp base64.cpp
 test_CPPFLAGS = ${AM_CPPFLAGS}
 test_LDFLAGS = ${AM_LDFLAGS}  -L. -lzlog -lrt
-visit_SOURCES = visit.cpp 
-visit_CPPFLAGS = ${AM_CPPFLAGS} -D_TEST_
-visit_LDFLAGS = ${AM_LDFLAGS}  
 EXTRA_DIST = message_file.h
 all: all-am
 
@@ -355,9 +346,6 @@ client$(EXEEXT): $(client_OBJECTS) $(client_DEPENDENCIES) $(EXTRA_client_DEPENDE
 test$(EXEEXT): $(test_OBJECTS) $(test_DEPENDENCIES) $(EXTRA_test_DEPENDENCIES) 
 	@rm -f test$(EXEEXT)
 	$(test_LINK) $(test_OBJECTS) $(test_LDADD) $(LIBS)
-visit$(EXEEXT): $(visit_OBJECTS) $(visit_DEPENDENCIES) $(EXTRA_visit_DEPENDENCIES) 
-	@rm -f visit$(EXEEXT)
-	$(visit_LINK) $(visit_OBJECTS) $(visit_LDADD) $(LIBS)
 yals$(EXEEXT): $(yals_OBJECTS) $(yals_DEPENDENCIES) $(EXTRA_yals_DEPENDENCIES) 
 	@rm -f yals$(EXEEXT)
 	$(yals_LINK) $(yals_OBJECTS) $(yals_LDADD) $(LIBS)
@@ -373,7 +361,6 @@ include ./$(DEPDIR)/client-client.Po
 include ./$(DEPDIR)/client-message_file.Po
 include ./$(DEPDIR)/test-base64.Po
 include ./$(DEPDIR)/test-test.Po
-include ./$(DEPDIR)/visit-visit.Po
 include ./$(DEPDIR)/yals-CDBConnPool.Po
 include ./$(DEPDIR)/yals-CDBConnect.Po
 include ./$(DEPDIR)/yals-CDBHelper.Po
@@ -489,20 +476,6 @@ test-base64.obj: base64.cpp
 #	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) \
 #	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o test-base64.obj `if test -f 'base64.cpp'; then $(CYGPATH_W) 'base64.cpp'; else $(CYGPATH_W) '$(srcdir)/base64.cpp'; fi`
 
-visit-visit.o: visit.cpp
-	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(visit_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT visit-visit.o -MD -MP -MF $(DEPDIR)/visit-visit.Tpo -c -o visit-visit.o `test -f 'visit.cpp' || echo '$(srcdir)/'`visit.cpp
-	$(am__mv) $(DEPDIR)/visit-visit.Tpo $(DEPDIR)/visit-visit.Po
-#	source='visit.cpp' object='visit-visit.o' libtool=no \
-#	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) \
-#	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(visit_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o visit-visit.o `test -f 'visit.cpp' || echo '$(srcdir)/'`visit.cpp
-
-visit-visit.obj: visit.cpp
-	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(visit_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT visit-visit.obj -MD -MP -MF $(DEPDIR)/visit-visit.Tpo -c -o visit-visit.obj `if test -f 'visit.cpp'; then $(CYGPATH_W) 'visit.cpp'; else $(CYGPATH_W) '$(srcdir)/visit.cpp'; fi`
-	$(am__mv) $(DEPDIR)/visit-visit.Tpo $(DEPDIR)/visit-visit.Po
-#	source='visit.cpp' object='visit-visit.obj' libtool=no \
-#	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) \
-#	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(visit_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o visit-visit.obj `if test -f 'visit.cpp'; then $(CYGPATH_W) 'visit.cpp'; else $(CYGPATH_W) '$(srcdir)/visit.cpp'; fi`
-
 yals-singleton_test_class1.o: websocket/singleton_test_class1.cpp
 	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(yals_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT yals-singleton_test_class1.o -MD -MP -MF $(DEPDIR)/yals-singleton_test_class1.Tpo -c -o yals-singleton_test_class1.o `test -f 'websocket/singleton_test_class1.cpp' || echo '$(srcdir)/'`websocket/singleton_test_class1.cpp
 	$(am__mv) $(DEPDIR)/yals-singleton_test_class1.Tpo $(DEPDIR)/yals-singleton_test_class1.Po

+ 1 - 5
Makefile.am

@@ -1,5 +1,5 @@
 bin_PROGRAMS=yals 
-noinst_PROGRAMS=client async test visit
+noinst_PROGRAMS=client async test 
 
 SRC_IN= websocket/singleton_test_class1.cpp  websocket/wsClient.cpp websocket/wsClientMgr.cpp websocket/wsTimerThread.cpp db_api/CDBConnect.cpp db_api/CDBConnPool.cpp db_api/CDBHelper.cpp db_api/CDBResultSet.cpp websocket/jsonBuilder.cpp websocket/jsonBuilder.h websocket/thread_safe_map.h
 
@@ -28,10 +28,6 @@ test_SOURCES=test.cpp base64.cpp
 test_CPPFLAGS=${AM_CPPFLAGS}
 test_LDFLAGS=${AM_LDFLAGS}  -L. -lzlog -lrt
 
-visit_SOURCES=visit.cpp 
-visit_CPPFLAGS=${AM_CPPFLAGS} -D_TEST_
-visit_LDFLAGS=${AM_LDFLAGS}  
-
 DEFS= 
 EXTRA_DIST=message_file.h
 

File diff suppressed because it is too large
+ 1263 - 0
Makefile.in


+ 6 - 5
ant.cpp

@@ -64,7 +64,7 @@ void sit_list::read_sit_list(const char*fname)
 		}
 		tmp->m_ant[antid].set(atof(s[4]),-atof(s[5]));
 		instance()->add(id,tmp);
-		std_info("211111 id=%dsize = %d",id,instance()->m_map.size());
+		//std_info("211111 id=%dsize = %d",id,instance()->m_map.size());
 		//m_list[id].m_id=id;
 		//m_list[id].m_ant[antid].set(atof(s[4]),-atof(s[5]));
 	}
@@ -77,7 +77,7 @@ void sit_list::read_sit_list(const char*fname)
 
 		if(sit.m_ant[0]==sit.m_ant[1])
 		{
-			printf("%d分站天线坐标相等.\n",sit.m_id);
+			log_warn("%d分站天线坐标相等.",sit.m_id);
 		}
 
 		sit.set( (sit.m_ant[0].x+sit.m_ant[1].x)/2,(sit.m_ant[0].y+sit.m_ant[1].y)/2);
@@ -164,7 +164,8 @@ void sit_list::read_ant_path(const char*fname)
                 p.m_line[0]=line_v(px,p.m_line[0][1]);
             }
         }
-        std_info("%s",s.to_string().c_str());
+        //std_info("%s",s.to_string().c_str());
+        log_info("%s",s.to_string().c_str());
         //std_info("%f----%f",s.x,s.y);
 	}
 }
@@ -196,8 +197,8 @@ int main()
 	log_init("./log.ini");
     //sit_list *sl = sit_list::instance();
 	sit_list::instance()->load("data_reader_antenna.txt","path_tof.txt");
-	sit_list::instance()->get(219)->solving(0,100);
-	sit_list::instance()->get(219)->solving(1,100.5);
+	sit_list::instance()->get(209)->solving(0,100);
+	sit_list::instance()->get(209)->solving(1,100.5);
     //std_info("---%d",(*sl)[209].m_ant[0].m_path.size());
     //std_info("---%d",(*sl)[209][0].size());
     //std_info("---%s",(*sl)[209][0][0][0].to_string().c_str());

+ 2 - 2
ant.h

@@ -244,9 +244,9 @@ struct sit_list:single_base<sit_list,int,std::shared_ptr<site>>
 		read_ant_path(path_file);
 	}
 
-	static void load_from_db()
+	void load_from_db()
 	{
-	//	load("data_reader_antenna.txt","path_tof.txt");
+		load("data_reader_antenna.txt","path_tof.txt");
 	}
 
 	void read_sit_list(const char*fname);

+ 19 - 19
autom4te.cache/requests

@@ -81,58 +81,58 @@
                         'configure.ac'
                       ],
                       {
-                        'AM_PROG_F77_C_O' => 1,
                         '_LT_AC_TAGCONFIG' => 1,
-                        'm4_pattern_forbid' => 1,
+                        'AM_PROG_F77_C_O' => 1,
                         'AC_INIT' => 1,
-                        '_AM_COND_IF' => 1,
+                        'm4_pattern_forbid' => 1,
                         'AC_CANONICAL_TARGET' => 1,
-                        'AC_SUBST' => 1,
+                        '_AM_COND_IF' => 1,
                         'AC_CONFIG_LIBOBJ_DIR' => 1,
-                        'AC_FC_SRCEXT' => 1,
+                        'AC_SUBST' => 1,
                         'AC_CANONICAL_HOST' => 1,
+                        'AC_FC_SRCEXT' => 1,
                         'AC_PROG_LIBTOOL' => 1,
                         'AM_PROG_MKDIR_P' => 1,
                         'AM_INIT_AUTOMAKE' => 1,
-                        'AM_PATH_GUILE' => 1,
                         'AC_CONFIG_SUBDIRS' => 1,
+                        'AM_PATH_GUILE' => 1,
                         'AM_AUTOMAKE_VERSION' => 1,
                         'LT_CONFIG_LTDL_DIR' => 1,
-                        'AC_CONFIG_LINKS' => 1,
                         'AC_REQUIRE_AUX_FILE' => 1,
-                        'm4_sinclude' => 1,
+                        'AC_CONFIG_LINKS' => 1,
                         'LT_SUPPORTED_TAG' => 1,
+                        'm4_sinclude' => 1,
                         'AM_MAINTAINER_MODE' => 1,
                         'AM_NLS' => 1,
                         'AC_FC_PP_DEFINE' => 1,
                         'AM_GNU_GETTEXT_INTL_SUBDIR' => 1,
-                        'AM_MAKEFILE_INCLUDE' => 1,
                         '_m4_warn' => 1,
+                        'AM_MAKEFILE_INCLUDE' => 1,
                         'AM_PROG_CXX_C_O' => 1,
-                        '_AM_MAKEFILE_INCLUDE' => 1,
                         '_AM_COND_ENDIF' => 1,
+                        '_AM_MAKEFILE_INCLUDE' => 1,
                         'AM_ENABLE_MULTILIB' => 1,
                         'AM_PROG_MOC' => 1,
                         'AM_SILENT_RULES' => 1,
                         'AC_CONFIG_FILES' => 1,
-                        'LT_INIT' => 1,
                         'include' => 1,
-                        'AM_GNU_GETTEXT' => 1,
+                        'LT_INIT' => 1,
                         'AM_PROG_AR' => 1,
+                        'AM_GNU_GETTEXT' => 1,
                         'AC_LIBSOURCE' => 1,
-                        'AM_PROG_FC_C_O' => 1,
                         'AC_CANONICAL_BUILD' => 1,
+                        'AM_PROG_FC_C_O' => 1,
                         'AC_FC_FREEFORM' => 1,
-                        'AH_OUTPUT' => 1,
                         'AC_FC_PP_SRCEXT' => 1,
-                        'AC_CONFIG_AUX_DIR' => 1,
+                        'AH_OUTPUT' => 1,
                         '_AM_SUBST_NOTMAKE' => 1,
-                        'm4_pattern_allow' => 1,
-                        'sinclude' => 1,
+                        'AC_CONFIG_AUX_DIR' => 1,
                         'AM_PROG_CC_C_O' => 1,
-                        'AM_XGETTEXT_OPTION' => 1,
-                        'AC_CANONICAL_SYSTEM' => 1,
+                        'sinclude' => 1,
+                        'm4_pattern_allow' => 1,
                         'AM_CONDITIONAL' => 1,
+                        'AC_CANONICAL_SYSTEM' => 1,
+                        'AM_XGETTEXT_OPTION' => 1,
                         'AC_CONFIG_HEADERS' => 1,
                         'AC_DEFINE_TRACE_LITERAL' => 1,
                         'AM_POT_TOOLS' => 1,

+ 204 - 47
card.cpp

@@ -1,8 +1,6 @@
 #include <memory>
-#include <ant.h>
 #include <log.h>
 #include <zloop.h>
-#include <ev++.h>
 #include "select_tool.h"
 #include "loc_tool.h"
 
@@ -10,40 +8,11 @@
 #include <site_area.h>
 
 #include <card.h>
+#include "config_file.h"
+#include "db_api/CDBConnPool.h"
+#include "websocket/wsTimerThread.h"
 
-enum STA_TYPE
-{
-    STATUS_HELP=0,
-    STATUS_LOW_POWER, 
-};
-struct card_message_handle;
-struct card_location_base
-{
-    std::shared_ptr<select_tool> m_sel_tool=nullptr;
-    std::shared_ptr<smooth_tool> m_smo_tool=nullptr;
-	std::unique_ptr<card_message_handle> m_message_handle=nullptr;
-    card_location_base()=default;
-    card_location_base(std::string type)
-    {
-        select_tool_manage::instance()->create_tool(type,m_sel_tool,m_smo_tool);
-    }
-	virtual void on_message(zloop<task*> * loop,const message_locinfo&loc,bool is_history)=0;
-	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)
-    {
-    }
-	virtual ~card_location_base(){};
-};
-
+extern config_file config;
 //一张卡一个ct的所有不同天线的信息
 struct one_ct_message_handle
 {
@@ -106,7 +75,9 @@ struct one_ct_message_handle
 		{
 			m_msg_list.clear();
 		}
-
+		auto sitPtr = sit_list::instance()->get(loc.m_site_id);
+		if(sitPtr==nullptr)
+		  return;
 		const site &s=*(sit_list::instance()->get(loc.m_site_id));
 		if(m_msg_list.empty())
 		{
@@ -198,8 +169,8 @@ struct card_area
 
 struct person:card_location_base,card_area
 {
-	person(std::string type)
-        :card_location_base(type)
+	person(std::string type,uint32_t cardid,uint16_t needdisplay,int16_t t)
+        :card_location_base(type,cardid,needdisplay,t)
 	{
         m_message_handle.reset(new card_message_handle(this));
 	}
@@ -208,44 +179,230 @@ struct person:card_location_base,card_area
 	{
 		m_message_handle->on_message(loop,loc,is_history);
 	}
+	~person(){}
 };
 
 struct car:card_location_base,card_area
 {
-    car(std::string type)
-        :card_location_base(type)
+	car(std::string type,uint32_t cardid,uint16_t needdisplay,int16_t t)
+        :card_location_base(type,cardid,needdisplay,t)
     {
         m_message_handle.reset(new card_message_handle(this));
     }
+
 	void on_message(zloop<task*> * loop,const message_locinfo&loc,bool is_history)
 	{
 		m_message_handle->on_message(loop,loc,is_history);
 	}
+
+	~car(){}
 };
 
 loc_tool_main one_ct_message_handle::m_loc_tool;
 
+uint64_t card_list::getId(uint32_t cardid,uint64_t type)
+{
+	return type<<32|cardid;
+}
+void card_list::init_vehicle()
+{
+	std::unordered_map<uint64_t,std::shared_ptr<card_location_base>> map;
+	std::string strategy = config.get("person.strategy","car1");
+	const char *sql = "SELECT ve.vehicle_id, ve.card_id, c.card_type_id, \
+						ve.dept_id, ve.group_id, v.vehicle_type_id, vt.vehicle_level_id, \
+						vt.is_railroad AS vt_is_railroad,ve.need_display ,ve.power_alarm,\
+						vt.vehicle_category_id,v.bigger_car_flag,vc.over_speed \
+						FROM dat_vehicle_extend ve \
+						LEFT JOIN dat_vehicle v ON ve.vehicle_id = v.vehicle_id \
+						LEFT JOIN dat_card c ON ve.card_id = c.card_id \
+						LEFT JOIN dat_dept d ON ve.dept_id = d.dept_id \
+						LEFT JOIN dat_group g ON ve.group_id = g.group_id \
+						LEFT JOIN dat_vehicle_type vt ON v.vehicle_type_id = vt.vehicle_type_id \
+						LEFT JOIN dat_vehicle_category vc ON vc.vehicle_category_id = vt.vehicle_category_id \
+						WHERE c.card_type_id = 2 AND c.state_id = 0;";
+	std::string Error;
+	YADB::CDBHelper DBHelper;
+	YADB::CDBResultSet DBRes;
+	sDBConnPool.Query(sql,DBRes,Error);
+	int nCount = DBRes.GetRecordCount( Error );
+	if (nCount > 0)
+	{
+		log_info( "init_staffer. The record count=%d\n", nCount );
+
+		while ( DBRes.GetNextRecod(Error) )
+		{
+			unsigned int vehicle_id  = 0;
+			DBRes.GetField( "vehicle_id",vehicle_id, Error );
+			
+			unsigned int card_type_id  = 0;
+			DBRes.GetField( "card_type_id",card_type_id, Error );
+
+			int dept_id = 0;
+			DBRes.GetField( "dept_id",dept_id, Error );
+
+			int group_id = 0;
+			DBRes.GetField( "group_id",group_id, Error );
+
+			int vehicle_type_id = 0;
+			DBRes.GetField( "vehicle_type_id",vehicle_type_id, Error );
+
+			int vehicle_level_id = 0;
+			DBRes.GetField( "vehicle_level_id",vehicle_level_id, Error );
+
+			int need_display = 0;
+			DBRes.GetField( "need_display",need_display, Error );
+
+			int power_alarm = 0;
+			DBRes.GetField( "power_alarm",power_alarm, Error );
+
+			int vehicle_category_id = 0;
+			DBRes.GetField( "vehicle_category_id",vehicle_category_id, Error );
+
+			int bigger_car_flag= 0;
+			DBRes.GetField( "bigger_car_flag",bigger_car_flag, Error );
+
+			double over_speed= 0;
+			DBRes.GetField( "over_speed",over_speed, Error );
+
+
+			std::shared_ptr<card_location_base> clb = std::make_shared<car>(strategy,vehicle_id,need_display,card_type_id);
+			uint64_t cardid = getId(vehicle_id,2);
+			log_info("cardId:%llu,vehicle_id:%d dept_id:%d,need_display:%d",cardid,vehicle_id,dept_id,need_display);
+			map.insert({cardid,clb});
+		}
+	}
+	
+	card_list::instance()->add(map);
+}
+
+void card_list::init_staffer()
+{
+	std::unordered_map<uint64_t,std::shared_ptr<card_location_base>> map;
+	std::string strategy = config.get("person.strategy","person1");
+	const char *sql = "SELECT staff_id, s.card_id, c.card_type_id, s.dept_id, s.group_id, s.occupation_id, \
+						ol.occupation_level_id,s.worktype_id,s.need_display \
+						FROM dat_staff_extend s \
+						LEFT JOIN dat_card c ON s.card_id = c.card_id \
+						LEFT JOIN dat_occupation o ON s.occupation_id = o.occupation_id \
+						LEFT JOIN dat_occupation_level ol ON ol.occupation_level_id = o.occupation_level_id \
+						WHERE c.card_type_id = 1 AND s.duty_id = 0 AND c.state_id = 0;";
+	std::string Error;
+	YADB::CDBHelper DBHelper;
+	YADB::CDBResultSet DBRes;
+	sDBConnPool.Query(sql,DBRes,Error);
+	int nCount = DBRes.GetRecordCount( Error );
+	if (nCount > 0)
+	{
+		log_info( "init_staffer. The record count=%d\n", nCount );
+
+		while ( DBRes.GetNextRecod(Error) )
+		{
+			unsigned int staff_id  = 0;
+			DBRes.GetField( "staff_id",staff_id, Error );
+
+			unsigned int card_type_id  = 0;
+			DBRes.GetField( "card_type_id",card_type_id, Error );
+			
+			int dept_id = 0;
+			DBRes.GetField( "dept_id",dept_id, Error );
+
+			int group_id = 0;
+			DBRes.GetField( "group_id",group_id, Error );
+
+			int occupation_id = 0;
+			DBRes.GetField( "occupation_id",occupation_id, Error );
+
+			int occupation_level_id = 0;
+			DBRes.GetField( "occupation_level_id",occupation_level_id, Error );
+
+			int need_display = 0;
+			DBRes.GetField( "need_display",need_display, Error );
+
+
+			std::shared_ptr<card_location_base> clb = std::make_shared<person>(strategy,staff_id,need_display,card_type_id);
+			uint64_t cardid = getId(staff_id,1);
+			log_info("cardId:%llu,staff_id:%d dept_id:%d,need_display:%d",cardid,staff_id,dept_id,need_display);
+			map.insert({cardid,clb});
+		}
+	}
+	
+	card_list::instance()->add(map);
+}
+
 void card_list::init_card_from_db()
 {
-	card_list::
-		instance()->add(0,std::make_shared<car>(""));
+	init_staffer();	
+	init_vehicle();
 }
 
 void card_list::on_message(zloop<task*> *loop,const message_locinfo&loc,bool is_history)
 {
-	std::shared_ptr<card_location_base> c=get(loc.long_id());
-
+	//std::shared_ptr<card_location_base>c=get(loc.m_card_id);
+	uint64_t cardid = getId(loc.m_card_id,loc.m_card_type);
+	const auto c=get(cardid);
 	if(c==nullptr)
 	{
-		log_warn("数据库中未定义该卡的信息,type=%d,card_id=%d", loc.m_card_type, loc.m_card_id);
+		log_warn("数据库中未定义该卡的信息,card_id=%d", loc.m_card_id);
 		return;
 	}
-
 	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);
 }
+//-----------------card_location_base..
+card_location_base::card_location_base(std::string type,uint32_t id,uint16_t dis,int16_t t)
+	:card(id,dis,t)
+{
+    select_tool_manage::instance()->create_tool(type,m_sel_tool,m_smo_tool);
+}
+void card_location_base::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)
+		log_info("loc_point,x:%.2f,y:%.2f",pt.x,pt.y);
+
+}
+
+void card_location_base::on_message(zloop<task*> * loop,const message_locinfo&loc,bool is_history)
+{
+	if(m_loop == nullptr && loop != nullptr)
+		set(loop);
+	m_message_handle->on_message(loop,loc,is_history);
+}
+
+void card_location_base::set(ev::dynamic_loop * loop)
+{
+    m_loop = loop;
 
+    m_timer.set(*m_loop);
+    m_timer.set<card_location_base,&card_location_base::on_timer>(this);
+	m_timer.start(1,1);
+}
+
+void card_location_base::on_timer()
+{
+	//push_point..
+    loc_point lp = m_smo_tool->smooth_strategy();
+	m_speed = lp.m_speed;
+	m_stat  = lp.m_stat;
+
+	YA::_CARD_POS_ cp;
+	cp.x = x;
+	cp.y = y;
+	cp.z = z;
+	cp.Type=m_type;
+	cp.ID = m_id;
+	cp.speed = m_speed;
+	cp.stat = m_stat;
+
+	swsTimerThrd.upt_card_pos(cp);
+	//log_info("one seconds............later..............");
+}
+
+
+card_location_base::~card_location_base()
+{
+}
 template<> std::shared_ptr<card_list> 
-single_base<card_list, int64_t, std::shared_ptr<card_location_base>>::m_instance=std::make_shared<card_list>();
+single_base<card_list, uint64_t, std::shared_ptr<card_location_base>>::m_instance=std::make_shared<card_list>();

+ 55 - 8
card.h

@@ -1,21 +1,68 @@
 #ifndef _CARD_HPP_
 #define _CARD_HPP_
 #include <message.h>
-//#include <ev++.h>
-
+#include <ev++.h>
+#include "point.h"
+#include "ant.h"
 
 #include "write-copy.h"
 
-struct card_location_base;
-
 struct task;
 template<typename T> struct zloop;
+struct select_tool;
+struct smooth_tool;
+enum STA_TYPE
+{
+    STATUS_HELP=0,
+    STATUS_LOW_POWER, 
+};
+struct card_message_handle;
+struct card:point
+{
+	card(uint32_t id,uint16_t dis,int16_t type)
+		:m_id(id)
+		,m_type(type)
+		,m_display(dis)
+		,m_speed(0)
+		,m_is_attendance(0)
+		,m_stat(0)
+	{}
+	uint32_t m_id;				//卡号
+	int16_t  m_type;			//类型
+	uint16_t m_display;			//1显示0不显示,往前端推送
+	double   m_speed;			//速度
+	int      m_is_attendance;	//井上井下状态  0初始状态 1 井上 2 井下
+	int		 m_stat;			//运动静止状态
+};
+struct card_location_base:card
+{
+    std::unique_ptr <select_tool> m_sel_tool;
+    std::unique_ptr <smooth_tool> m_smo_tool;
+	std::unique_ptr <card_message_handle> m_message_handle;
+    ev::dynamic_loop * m_loop = nullptr;
+	ev::timer m_timer;
+
+    card_location_base()=default;
+    card_location_base(std::string type,uint32_t id,uint16_t dis,int16_t t);
+	void set(ev::dynamic_loop * loop);
+	void on_timer();
+
+	void on_message(zloop<task*> * loop,const message_locinfo&loc,bool is_history);
+	void on_location(const std::vector<point>&vp,const std::vector<loc_message> &lm );
+    void do_status(STA_TYPE st)
+    {
+    }
+	virtual ~card_location_base();
+};
 
-struct card_list:single_base<card_list,int64_t,std::shared_ptr<card_location_base>>
+struct card_list:single_base<card_list,uint64_t,std::shared_ptr<card_location_base>>
 {
-	virtual void on_message(zloop<task*> *loop,const message_locinfo&loc,bool is_history);
-	virtual void init_card_from_db();
-	virtual ~card_list(){}
+	void init_staffer();
+	void init_vehicle();
+	uint64_t getId(uint32_t cardid,uint64_t);
+	void on_message(zloop<task*> *loop,const message_locinfo&loc,bool is_history);
+	void init_card_from_db();
+	~card_list(){}
 };
 
 #endif

+ 12 - 6
card_path.cpp

@@ -189,7 +189,7 @@ point  base_path::cross(const vertex_list&v, const base_path&o)const
 
 	return l0.crossing(l1);
 }
-
+#ifdef __DEBUG__
 void log_path(const std::vector<base_path>&path,const vertex_list&v_list)
 {
 	printf("%s\n","----------------------------------------------------------------");
@@ -199,6 +199,7 @@ void log_path(const std::vector<base_path>&path,const vertex_list&v_list)
 		printf("base_path %.6lf, %03d,(%d,%s),(%d,%s)\n",c,i,path[i][0],v_list[path[i][0]].to_string().c_str(),path[i][1],v_list[path[i][1]].to_string().c_str());
 	}
 }
+#endif
 struct handle_path :visitor<std::shared_ptr<site>>
 {
 	std::vector<base_path> ret;
@@ -223,7 +224,6 @@ struct handle_path :visitor<std::shared_ptr<site>>
         line_v l010 = s[0][1][0];
         if(l000.is_same(l010))
         {
-            printf("same....%d",s.m_id);
 			int p0=v.add(point::min(s.path(0),s.path(1)),0,s.m_id);
 			int p1=v.add(point::max(s.path(0),s.path(1)),0,s.m_id);
 
@@ -331,14 +331,20 @@ static std::vector<base_path> init_path(std::vector<base_path> & ret,vertex_list
 		}
 	}
 */
+#ifdef __DEBUG__
 	log_path(ret,v);
     printf("++++++++++++++++++++++++++++++++++++++++++++");
+#endif
 	std::sort(ret.begin(),ret.end());
+#ifdef __DEBUG__
 	log_path(ret,v);
     printf("++++++++++++++++++++++++++++++++++++++++++++");
+#endif
 	ret.erase(std::unique(ret.begin(),ret.end()),ret.end());
+#ifdef __DEBUG__
 	log_path(ret,v);
     printf("+++++++++++++++++nnnnn+++++++++++++++++++++++++++");
+#endif
 
 	std::sort(ret.begin(),ret.end(),[&v](const base_path&p1,const base_path&p2){
 		double arg=p1.arg(v)-p2.arg(v);
@@ -351,8 +357,9 @@ static std::vector<base_path> init_path(std::vector<base_path> & ret,vertex_list
 		return arg<0;
 	});
 
+#ifdef __DEBUG__
 	log_path(ret,v);
-
+#endif
 	for(int i=0,len=ret.size();i<len;i++)
 	{
 		line_v li=ret[i].as_line(v);
@@ -640,9 +647,9 @@ struct graph
 			int id=l.size()-1;
 
 			line_v lv(v[from],v[to]);
-
+#ifdef __DEBUG__
 			printf("line:%s\n",lv.to_string().c_str());
-
+#endif
 			double cos=lv.cos_k();
 			double sin=lv.sin_k();
 
@@ -828,7 +835,6 @@ void card_path::init()
 		//std::vector<base_path> opath=init_path(sites,v_list);
 		sit_list::instance()->accept(hp);
 		std::vector<base_path> opath=init_path(hp.ret,hp.v);
-		
 		g_graph.init(hp.v,opath);
 
 		++g_init_flag;

+ 4 - 4
db_api/CDBConnPool.cpp

@@ -15,9 +15,9 @@ namespace YADB
 		Close();
 	}
 
-	CDBConnect * CDBConnPool::__CreateIdleConn( std::string& Error, bool IsTemp )
+	CDBConnect * CDBConnPool::__CreateIdleConn( std::string& ConnErr, bool IsTemp )
 	{
-		std::string ConnErr;
+		//std::string ConnErr;
 
 		_DB_CONN_SETTING_ ConnSetting = static_cast< _DB_CONN_SETTING_ >(__Setting);
 		CDBConnect* pConn = new CDBConnect( IsTemp );
@@ -31,7 +31,7 @@ namespace YADB
 		//如果设置了预处理SQL要准备预处理
 		if ( !ConnSetting.stmtSQL.empty() )
 		{
-			if ( !pConn->Preparestmt( ConnSetting.stmtSQL.c_str(), Error ) )
+			if ( !pConn->Preparestmt( ConnSetting.stmtSQL.c_str(), ConnErr ) )
 			{
 				delete pConn;
 				pConn = 0;
@@ -203,7 +203,7 @@ namespace YADB
 					{
 						my_ulonglong llRes = 0;
 						llRes = __pAsyncDBConn->ExecuteRealSql( pData->SQL.c_str(), Error );
-						if ( -1 == llRes )
+						if ( (my_ulonglong)-1 == llRes )
 						{
 							//Execute failed, write log...
 							printf( "Error,调用ExcuteRealSql失败,Err=%s\n", Error.c_str() );

+ 16 - 9
loc_point.cpp

@@ -2,10 +2,12 @@
 #include <memory.h>
 #include "loc_point.h"
 #include "ant.h"
+#include "log.h"
 
 loc_point::loc_point()
     :m_time(0)
     ,m_ct(-1)
+	,m_cid(-1)
     ,m_sid(-1)
     ,m_acc(0)
     ,m_rav(0)
@@ -42,23 +44,26 @@ inline const char* now(char*date_str,uint64_t time)
     return date_str;
 }
 
-void loc_point::debug_out()const
+void loc_point::debug_out(const char *str)const
 {
     char time_buff[128];
-#if 0
-    printf("t=%s,sit=%d,card=%d,ct=%d,cred=%d,"
+#if 1
+    log_info("[%s]t=%s,sit=%d,card=%d,ct=%d,cred=%d,"
             "tof1=%d,tof2=%d,pt=(%.2lf,"
-            "%.2lf),rsp=%d,acc=%.2f,dist=%.2lf,dist1=%.2lf,dist2=%.2lf,rav=%.2f\n",
-            now(time_buff,m_time), m_sid, m_cid, m_ct, m_cred_level,
+            "%.2lf),rsp=1,acc=%.2f,dist=%.2lf,dist1=%.2lf,dist2=%.2lf,rav=%.2f,speed:%.2f\n",
+            str,now(time_buff,m_time), m_sid, 
+			m_cid,
+			m_ct, m_cred_level,
             m_tof[0], m_tof[1],  x,
-            y ,(int)(m_rsp[0]+m_rsp[1])/2,m_acc,
-            m_dist1,m_dist,m_dist2, m_rav
+            //y ,(int)(m_rsp[0]+m_rsp[1])/2,m_acc,
+            y ,m_acc,
+            m_dist1,m_dist,m_dist2, m_rav,m_speed
           );
 #else
-    printf("t=%s,sit=%d,ct=%d,cred=%d,"
+    printf("[%s]t=%s,sit=%d,ct=%d,cred=%d,"
             "tof1=%d,tof2=%d,pt=(%.2lf,"
             "%.2lf),rsp=,acc=%.2f,dist=%.2lf,dist1=%.2lf,dist2=%.2lf,rav=%.2f,speed=%.2f\n",
-            now(time_buff,m_time), m_sid, m_ct, m_cred_level,
+            str,now(time_buff,m_time), m_sid, m_ct, m_cred_level,
             m_tof[0], m_tof[1],  m_smooth_x,
             m_smooth_y ,m_acc,
             m_dist1,m_dist,m_dist2, m_rav, m_speed
@@ -83,6 +88,7 @@ int loc_point::cl()const
 void loc_point::set_source(const loc_message&li,const loc_message&li2)
 {
     m_sid = li.m_sit.m_id;
+	m_cid = li.m_card_id;
     m_time=std::min(li.m_loc_time,li2.m_loc_time);
     m_ct=li.m_card_ct;
     m_acc=li.m_acc *10;// 1270.;
@@ -94,6 +100,7 @@ void loc_point::set_source(const loc_message&li,const loc_message&li2)
 
 void loc_point::set_source(const loc_message&li)
 {
+	m_cid = li.m_card_id;
     m_sid = li.m_sit.m_id;
     m_time=li.m_loc_time;
     m_ct=li.m_card_ct;

+ 2 - 1
loc_point.h

@@ -10,6 +10,7 @@ struct loc_point:point
 {
 	int64_t m_time;
 	int     m_ct;
+	uint32_t m_cid;
     int     m_sid;
 	float	m_acc;
 	float	m_rav;
@@ -72,7 +73,7 @@ struct loc_point:point
 		return o.m_ct-m_ct;
 	}
 
-	void debug_out()const ;
+	void  debug_out(const char * str="")const ;
 
 	void set_sol(int i,const point&p) ;
 	bool b_50m()const

+ 11 - 7
main.cpp

@@ -16,8 +16,9 @@ struct Init_Setting
 {
 	void init()
 	{
-		std::string url=config.get("service.websocket_url","");
+		std::string url=config.get("service.websocket_url","ws://127.0.0.1:8086");
 		int32_t send_interval =config.get("service.interval_send_json_postion",1000);
+		std_info("json_interval:%d",send_interval);
 		std::vector<std::string> url_list;
 		url_list.push_back(url);
 		wsClientMgr_init(url_list,send_interval);//init websocket
@@ -25,7 +26,7 @@ struct Init_Setting
 		YADB::_DB_POOL_SETTING_ DBSetting;
 
 		DBSetting.Host = config.get("db.host","");
-		DBSetting.User = config.get("db.user","");
+		DBSetting.User = config.get("db.user","root");
 		DBSetting.PWD = config.get("db.passwd","");
 		DBSetting.DBName = config.get("db.dbname","yaxt");
 		DBSetting.CharSet = config.get("db.charset","utf-8");
@@ -33,6 +34,9 @@ struct Init_Setting
 		DBSetting.PoolSize = config.get("db.conn_timeout",30);
 		_mysql_init(DBSetting);
 
+		sit_list::instance()->load_from_db();
+
+		card_list::instance()->init_card_from_db();
 	}
 
 	void _mysql_init(YADB::_DB_POOL_SETTING_ &dps)
@@ -42,7 +46,7 @@ struct Init_Setting
 		//创建连接池
 		if ( !sDBConnPool.Create( dps, Error ) )
 		{
-			log_error("线程池创建失败,Err=%s\n", Error.c_str());
+			log_error("数据库线程池创建失败,Err=%s\n", Error.c_str());
 		}
 	}
 
@@ -59,6 +63,7 @@ struct Init_Setting
 		if ( swsClientMgr.connect() != 0 )
 		{
 			log_error("web socket init failed.");
+			std_error("web socket init failed.");
 			return;
 		}
 	
@@ -84,12 +89,11 @@ int main()
 	log_init("../etc/log.ini");
 	if(config.open("../etc/config.ini"))
 		return -1;
+	Init_Setting is;
+	is.init();
 	
 	atexit(&cleanup);
-	
-	log_info("herer..init from db...");
-	sit_list::instance()->load_from_db();
-	card_list::instance()->init_card_from_db();
+
 	card_path::init();
 	net_service mh;
 

+ 0 - 6
net-service.cpp

@@ -56,13 +56,7 @@ void net_service::on_message(std::shared_ptr<client> clt,const char*data,size_t
 					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);

BIN
path


+ 7 - 2
select_tool.cpp

@@ -424,6 +424,11 @@ fit_result* select_point_object::best_fit_raw(int num_point,int start,int last)
 	return fit;
 }
 
+select_tool::~select_tool()
+{
+	if(m_spo !=nullptr)
+	  delete m_spo;
+}
 
 loc_point select_tool_person_1::select_solution(const std::vector<point> vp,const std::vector<loc_message>&lm)
 {
@@ -432,7 +437,7 @@ loc_point select_tool_person_1::select_solution(const std::vector<point> vp,cons
     if(lm[0].tool_index() == 0)  
     {
 		if(m_spo==nullptr)
-			m_spo = new person_point_filter(); 
+			m_spo = new person_point_filter(this); 
         lp=m_spo->select_solution_impl(vp,lm);
     }
     else if (lm[0].tool_index() == 2)
@@ -453,7 +458,7 @@ loc_point select_tool_car_1::select_solution(const std::vector<point> vp,const s
     if(lm[0].tool_index() == 0)  
     {
 		if(m_spo==nullptr)
-			m_spo = new car_point_filter(); 
+			m_spo = new car_point_filter(this); 
         lp=m_spo->select_solution_impl(vp,lm);
     }
     else if (lm[0].tool_index() == 2)

+ 330 - 269
select_tool.h

@@ -1,5 +1,6 @@
 #ifndef __SELECT_TOOL__H
 #define __SELECT_TOOL__H
+#include <mutex>
 #include "loc_point.h"
 #include "line.h"
 #include <memory>
@@ -32,72 +33,137 @@ struct solpoint:point
 		return m_score;
 	}
 };
+struct push_data_point:point
+{
+	const site *sit;
+	point dstp;
+	int ct;
+	bool valid;	// if valid
+	int stop_cnt;	// if calculate speed
+	loc_point lp;
+};
+
+class select_point_object;
+struct select_tool
+{
+	std::mutex m_mtx;
+	zlist<push_data_point,16> m_push_list;
+	select_point_object *m_spo=nullptr;
+	virtual loc_point  select_solution(const std::vector<point> p,const std::vector<loc_message>&lm)=0;
+	push_data_point getDpt()
+	{
+		push_data_point dpt;
+		std::lock_guard<std::mutex> lock(m_mtx);
+		if (m_push_list.empty())	//empty
+		{
+			return dpt;
+		}
+		else if(m_push_list.size()==1)		//size=1
+		{
+			dpt = m_push_list[0];
+			m_push_list[0].valid=false;
+			if(m_push_list[0].stop_cnt>5)m_push_list[0].stop_cnt=5;
+			if(m_push_list[0].stop_cnt>0)m_push_list[0].stop_cnt--;
+		}
+		else{			//size>1
+			dpt = m_push_list[0];
+			m_push_list.skip(1);
+		}
+		return dpt;
+	}
+	virtual ~select_tool();
 
+};
 
-struct select_point_object
+//--------------person------solution one--------
+struct select_tool_person_1:select_tool
 {
-public:
-    select_point_object()
-        :m_ct(-10)
-    {
-	    att_initiate();
-    }
-    inline int last_ct(){return m_ct;}
-public:
-    const static int max_histime=60;		 //±£Áô×îºó60sµÄÊý¾Ý
-
-	zlist<loc_point,128> m_d;
-	line m_line;
-	int	 m_ct = -10;
-	fit_batch   m_fitk,m_fita;
-	fit_result  m_cur_fit;
-	loc_point*  m_begin;
-	loc_point*  m_last;
-	struct push_data_point:point
+	virtual loc_point  select_solution(const std::vector<point> p,const std::vector<loc_message>&lm);
+	~select_tool_person_1()
+	{
+	}
+};
+
+struct select_tool_person_2:select_tool
+{
+	virtual loc_point  select_solution(const std::vector<point> p,const std::vector<loc_message>&lm)
 	{
-		const site *sit;
-		point dstp;
-		int ct;
-		bool valid;	// if valid
-		int stop_cnt;	// if calculate speed
 		loc_point lp;
-	};
-	zlist<push_data_point,16> m_push_list;
+		return lp;
+	}
 
-public:
-    int find_last(int start);
-    int find_first(int start);
-    void save_k();
-	void att_initiate();
-	void remove_history();
-	bool make_line();
-	point select_solution0(std::vector<point> &vp,const double scale);
-	bool select_solution(const std::vector<point> &vp,const site*sit,loc_point &p);
-    loc_point  select_solution_impl(const std::vector<point> p,const std::vector<loc_message>&lm);
-    fit_result* best_fit_raw(int num_point=0,int start=0,int end=-1);
-    bool filter_by_acc(loc_point&c,std::array<solpoint,4>&v,double a);
-    bool filter_by_fit(loc_point & c,const std::vector<point> & vp,const double scale);
-    void select_one_ant(loc_point &c,const std::vector<point> & vp);
-public:
-    virtual void select_solution1(loc_point &c,const std::vector<point> &vp,const double scale)=0;
-    virtual fit_result * get_best_fit()=0;
-    virtual double getA(const fit_result * fit,const double scale,const double dt)=0;
-    virtual void reset_fit(double d)=0;
-    virtual bool revise_by_history(point & pt, const site*sit, int64_t m_time)=0;
-    virtual ~select_point_object(){}
+};
+//----------------------car----------
+struct select_tool_car_1:select_tool
+{
+	virtual loc_point  select_solution(const std::vector<point> p,const std::vector<loc_message>&lm);
+};
+//---------------------drivingfaceCar
+struct select_tool_drivingface_car_1:select_tool
+{
+	virtual loc_point  select_solution(const std::vector<point> p,const std::vector<loc_message>&lm)
+	{
+		loc_point lp;
+		return lp;
+	}
+};
+//----------------------------------------
+struct select_point_object
+{
+	select_tool * m_owner;
+	public:
+		select_point_object(select_tool * owner)
+			:m_owner(owner)
+			,m_ct(-10)
+		{
+			att_initiate();
+		}
+		inline int last_ct(){return m_ct;}
+	public:
+		const static int max_histime=60;		 //±£Áô×îºó60sµÄÊý¾Ý
+
+		zlist<loc_point,128> m_d;
+		line m_line;
+		int	 m_ct = -10;
+		fit_batch   m_fitk,m_fita;
+		fit_result  m_cur_fit;
+		loc_point*  m_begin;
+		loc_point*  m_last;
+	public:
+		int find_last(int start);
+		int find_first(int start);
+		void save_k();
+		void att_initiate();
+		void remove_history();
+		bool make_line();
+		point select_solution0(std::vector<point> &vp,const double scale);
+		bool select_solution(const std::vector<point> &vp,const site*sit,loc_point &p);
+		loc_point  select_solution_impl(const std::vector<point> p,const std::vector<loc_message>&lm);
+		fit_result* best_fit_raw(int num_point=0,int start=0,int end=-1);
+		bool filter_by_acc(loc_point&c,std::array<solpoint,4>&v,double a);
+		bool filter_by_fit(loc_point & c,const std::vector<point> & vp,const double scale);
+		void select_one_ant(loc_point &c,const std::vector<point> & vp);
+	public:
+		virtual void select_solution1(loc_point &c,const std::vector<point> &vp,const double scale)=0;
+		virtual fit_result * get_best_fit()=0;
+		virtual double getA(const fit_result * fit,const double scale,const double dt)=0;
+		virtual void reset_fit(double d)=0;
+		virtual bool revise_by_history(point & pt, const site*sit, int64_t m_time)=0;
+		virtual ~select_point_object(){}
 };
 struct person_point_filter:select_point_object
 {
-    person_point_filter()
-        :m_filter_man_count(0)
-    {}
+	person_point_filter(select_tool * owner)
+		:select_point_object(owner)
+		,m_filter_man_count(0)
+	{}
 	int m_filter_man_count=0;
-    virtual void reset_fit(double d)
-    {
-        if(d>1)
-			m_filter_man_count++;
+	virtual void reset_fit(double d)
+	{
+		if(d>1)
+		  m_filter_man_count++;
 		else 
-			m_filter_man_count = 0;
+		  m_filter_man_count = 0;
 		if(m_filter_man_count==3)
 		{
 			m_fitk.reset_data();
@@ -107,44 +173,44 @@ struct person_point_filter:select_point_object
 			m_filter_man_count = 0;
 		}
 
-    }
-    virtual void select_solution1(loc_point &c,const std::vector<point> &vp,const double scale)
-    {
-        if(filter_by_fit(c,vp,scale))
-        {
-            c.inc_cl(40);
-        }
-        else if(c.cl()>0 && vp.size()==2)
-        {
-		    c[0]=vp[0];
-		    c[1]=vp[1];
-		    c.inc_cl(10);
-        }
-        else
-        {
-            select_one_ant(c,vp);
-        }
-        
-    }
-    virtual fit_result * get_best_fit()
-    {
-        return best_fit_raw(4,4);
-    }
-    virtual double getA(const fit_result * fit,const double scale,const double dt)
-    {
-        double a=2.5;
+	}
+	virtual void select_solution1(loc_point &c,const std::vector<point> &vp,const double scale)
+	{
+		if(filter_by_fit(c,vp,scale))
+		{
+			c.inc_cl(40);
+		}
+		else if(c.cl()>0 && vp.size()==2)
+		{
+			c[0]=vp[0];
+			c[1]=vp[1];
+			c.inc_cl(10);
+		}
+		else
+		{
+			select_one_ant(c,vp);
+		}
+
+	}
+	virtual fit_result * get_best_fit()
+	{
+		return best_fit_raw(4,4);
+	}
+	virtual double getA(const fit_result * fit,const double scale,const double dt)
+	{
+		double a=2.5;
 		if(fabs(fit->k)<2/(3.6*scale)  && fabs(fit->k)>0.5/(3.6*scale)  && dt<10)
 		{
 			a=0.3;
 		}
-        return a;
-    }
+		return a;
+	}
 
-    virtual bool revise_by_history(point & pt, const site*sit, int64_t timestamp)
-    {
-        point dstp = sit->get_dstp(pt);
-        if(dstp.empty())
-            std_error("error.here....");
+	virtual bool revise_by_history(point & pt, const site*sit, int64_t timestamp)
+	{
+		point dstp = sit->get_dstp(pt);
+		if(dstp.empty())
+		  std_error("error.here....");
 
 		push_data_point dp;
 		dp.sit=sit;
@@ -155,29 +221,32 @@ struct person_point_filter:select_point_object
 		dp.lp=m_d(0);
 		dp.set(pt);
 		{	//don't delete the braces
-			m_push_list.clear();
-			m_push_list.push(dp);
+			std::lock_guard<std::mutex> lock(m_owner->m_mtx);
+			m_owner->m_push_list.clear();
+			m_owner->m_push_list.push(dp);
+			//dp.lp.debug_out("person");
 		}
-        return true;
-    }
+		return true;
+	}
 
 };
 struct car_point_filter:select_point_object
 {
-    car_point_filter()
-        :m_last_fit_valid(false)
-		,m_last_fit_k(0)
-		,m_last_fit_kb(0)
-		,m_last_fit_ka(0)
-		,m_last_fit_xo(0)
-		,m_last_fit_yo(0)
-        ,m_last_fit_md_x(0)
-        ,m_last_fit_md_y(0)
-		,m_last_fit_time_sec(0)
-		,m_last_fit_nearest_time_sec(0)
-		,m_last_time_sec(0)
-        ,m_if_turning(false)
-    {}
+	car_point_filter(select_tool * owner)
+		:select_point_object(owner)
+		,m_last_fit_valid(false)
+		 ,m_last_fit_k(0)
+		 ,m_last_fit_kb(0)
+		 ,m_last_fit_ka(0)
+		 ,m_last_fit_xo(0)
+		 ,m_last_fit_yo(0)
+		 ,m_last_fit_md_x(0)
+		 ,m_last_fit_md_y(0)
+		 ,m_last_fit_time_sec(0)
+		 ,m_last_fit_nearest_time_sec(0)
+		 ,m_last_time_sec(0)
+		 ,m_if_turning(false)
+	{}
 	bool m_last_fit_valid = false;
 	double m_last_fit_k ;
 	double m_last_fit_kb;
@@ -193,60 +262,60 @@ struct car_point_filter:select_point_object
 	bool m_if_turning=false;
 	point m_turning_pt;
 	point m_turning_ept;
-    double m_simple_rec_kx,m_simple_rec_ky;
+	double m_simple_rec_kx,m_simple_rec_ky;
 	const double m_fit_differ=4;
 	const double m_pos_differ=8;
 
 
 
 
-    virtual void reset_fit(double d){}
-    virtual void select_solution1(loc_point &c,const std::vector<point> &vp,const double scale)
-    {
-    	//two ants.
-    	if(c.cl()>0 && vp.size()==2)//m_card->smoothFlag() )
-    	{
-    		c[0]=vp[0];
-    		c[1]=vp[1];
-    		c.inc_cl(50);
-    	}
-    	else if(filter_by_fit(c,vp,scale))
-    	{
-    		c.inc_cl(40);
-    	}
-        else
-        {
-            select_one_ant(c,vp);
-        }
-    
+	virtual void reset_fit(double d){}
+	virtual void select_solution1(loc_point &c,const std::vector<point> &vp,const double scale)
+	{
+		//two ants.
+		if(c.cl()>0 && vp.size()==2)//m_card->smoothFlag() )
+		{
+			c[0]=vp[0];
+			c[1]=vp[1];
+			c.inc_cl(50);
+		}
+		else if(filter_by_fit(c,vp,scale))
+		{
+			c.inc_cl(40);
+		}
+		else
+		{
+			select_one_ant(c,vp);
+		}
 
-    }
+
+	}
 
 	const fit_result* best_fit()const
 	{
 		if(m_cur_fit.k==0 && m_cur_fit.ke==0)
-			return nullptr;
+		  return nullptr;
 
 		return &m_cur_fit;
 	}
 
-    virtual fit_result * get_best_fit()
-    {
-        return best_fit_raw(5);
-    }
-    virtual double getA(const fit_result * fit,const double scale,const double dt)
-    {
-        double a=2.5;
+	virtual fit_result * get_best_fit()
+	{
+		return best_fit_raw(5);
+	}
+	virtual double getA(const fit_result * fit,const double scale,const double dt)
+	{
+		double a=2.5;
 		if(fabs(fit->k)<10/(3.6*scale)  && fabs(fit->k)>1/(3.6*scale)  && dt<20)
 		{
 			a=1;
 		}
 		if(fabs(fit->k)<=1/(3.6*scale)  && dt<20)
 		{
-            a=-1;
+			a=-1;
 		}
-        return a;
-    }
+		return a;
+	}
 
 	void reset_turning()
 	{
@@ -271,9 +340,9 @@ struct car_point_filter:select_point_object
 
 		point sit_location;		//projection
 		//sit_location.set(sit->x,sit->y);
-        sit_location = sit->get_dstp(m_turning_pt);
-        if(sit_location.empty())
-          std_error("get_dstp point error.....");
+		sit_location = sit->get_dstp(m_turning_pt);
+		if(sit_location.empty())
+		  std_error("get_dstp point error.....");
 		double dist1=sit_location.dist(rpt);
 		double dist2=sit_location.dist(m_turning_pt);
 		double dist3=m_turning_pt.dist(rpt);	// dist1 is supposed to be = dist2+dist3
@@ -295,7 +364,7 @@ struct car_point_filter:select_point_object
 
 
 		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.x,rpt.y,turning_x,turning_y,dist1,dist2,dist3);
 
 		rpt.set(turning_x,turning_y);
 	}
@@ -311,9 +380,9 @@ struct car_point_filter:select_point_object
 		{	
 			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);
+						"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;
 		}
 
@@ -321,9 +390,9 @@ struct car_point_filter:select_point_object
 		if(!m_if_turning)
 		{
 			//dstp.set(sit->x,sit->y);
-            dstp = sit->get_dstp(pt);
-            if(dstp.empty())
-              std_error("error.here....");
+			dstp = sit->get_dstp(pt);
+			if(dstp.empty())
+			  std_error("error.here....");
 		}
 		else
 		{
@@ -339,8 +408,10 @@ struct car_point_filter:select_point_object
 		dp.lp=lp;
 		dp.set(rpt);
 		{	//don't delete the braces
-			m_push_list.clear();
-			m_push_list.push(dp);
+			std::lock_guard<std::mutex> lock(m_owner->m_mtx);
+			m_owner->m_push_list.clear();
+			m_owner->m_push_list.push(dp);
+			//dp.lp.debug_out("single point .");
 		}
 	}
 	double estimate_point_by_history(const site*sit, double m_time_sec)
@@ -378,18 +449,18 @@ struct car_point_filter:select_point_object
 		{	
 			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);
+						"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;
 		}
 
 		point dstp;		//projection
 		if(!m_if_turning)
 		{
-            dstp = sit->get_dstp(pt);
-            if(dstp.empty())
-              std_error("error.here....");
+			dstp = sit->get_dstp(pt);
+			if(dstp.empty())
+			  std_error("error.here....");
 			//dstp.set(sit->x,sit->y);
 		}
 		else
@@ -398,7 +469,7 @@ struct car_point_filter:select_point_object
 		}
 
 		int size = 0;
-		push_data_point dp[10];
+		push_data_point dp[13];
 		dp[size].sit=sit;
 		dp[size].dstp.set(dstp);
 		dp[size].ct=ct;
@@ -408,7 +479,7 @@ struct car_point_filter:select_point_object
 		dp[size].set(rpt);
 		double missing_time = m_d(0).m_time/1000.;
 		size++;
-		for(;size<10;size++)
+		for(;size<13;size++)
 		{
 			dp[size].sit=sit;
 			dp[size].dstp.set(dstp);
@@ -431,11 +502,13 @@ struct car_point_filter:select_point_object
 			dp[size].lp.m_sid = sit->m_id;
 			//dp[size].lp.m_cid = m_d(0).m_cid;
 		}
-        {
-			m_push_list.clear();
+		{
+			std::lock_guard<std::mutex> lock(m_owner->m_mtx);
+			m_owner->m_push_list.clear();
 			for(int i=0;i<size;i++)
 			{
-				m_push_list.push(dp[i]);
+				m_owner->m_push_list.push(dp[i]);
+				//dp[i].lp.debug_out("push_list");
 			}
 		}
 	}
@@ -460,7 +533,7 @@ struct car_point_filter:select_point_object
 			m_simple_rec_kx = 0;
 			m_simple_rec_ky = 0;
 		}
-			//printf("convert_pt_to_dist:(%f,%f),%f\n",pt.x,pt.y,dist);
+		//printf("convert_pt_to_dist:(%f,%f),%f\n",pt.x,pt.y,dist);
 		//double dist = sit->dist_direct(pt);
 		//if(dist == 0)return 0;
 		//m_simple_rec_kx = (pt.x - (*sit).x) / dist;
@@ -468,13 +541,11 @@ struct car_point_filter:select_point_object
 		return dist;
 	}
 
-    virtual bool revise_by_history(point & pt, const site*sit, int64_t timestamp)
-    {
-        std_info("revise_____-before:%f,%f,%llu",pt.x,pt.y,timestamp);
-        bool flag =false;
+	virtual bool revise_by_history(point & pt, const site*sit, int64_t 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;
@@ -504,17 +575,13 @@ 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));
-			
+
 			// put m_acccumulate_acc into consideration
 			// fit->k - m_last_fit_k < m_accumulate_acc
 			if(m_last_fit_valid == true && m_last_fit_k * fit->k > -0.6)
-			//if((sit->dist(pt)<20 ||m_last_fit_k * fit->k > -0.6))
+			  //if((sit->dist(pt)<20 ||m_last_fit_k * fit->k > -0.6))
 			{	//if point is too near the sit: do not not judge the backwards
 
 				double est1 = estimate_point_by_history(sit, m_last_fit_time_sec);
@@ -523,10 +590,10 @@ struct car_point_filter:select_point_object
 				//	m_last_fit_nearest_time_sec,est1,m_time_sec,est2,m_time_sec-m_last_fit_nearest_time_sec,est2-est1);
 				//if(fabs(est1-est2)>40)printf("change fit:%f,%f,%f\n",fabs(est1-est2),est1,est2);
 				if(fabs(est1-est2)< (m_time_sec - m_last_fit_time_sec) * 5) // large jump is not allowed
-					if_change_fit=true;
+				  if_change_fit=true;
 			}
 			else if(m_last_fit_valid==false)
-				if_change_fit=true;
+			  if_change_fit=true;
 		}
 		if(if_change_fit)
 		{
@@ -538,7 +605,7 @@ struct car_point_filter:select_point_object
 			m_last_fit_xo = fit->xo;
 			m_last_fit_yo = fit->yo;
 			m_last_fit_nearest_time_sec = m_fitk.x(0);
-			
+
 			int fidx=find_first(0);
 			if(fidx<0)
 			{
@@ -559,17 +626,16 @@ struct car_point_filter:select_point_object
 
 		// revise
 		double estimate_dist = estimate_point_by_history(sit, m_time_sec);
-						//printf("revise:est:%f, d:%f, fitvalid:%d, timesecdiffer:%f\n",
-							//estimate_dist, dist, m_last_fit_valid, m_time_sec - m_last_fit_time_sec);
+		//printf("revise:est:%f, d:%f, fitvalid:%d, timesecdiffer:%f\n",
+		//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;
+			  dist=estimate_dist;
 			else if(fabs(m_last_fit_k) <= 0.5 && fabs(estimate_dist-dist)>m_fit_differ * 2)
-				dist=estimate_dist;
+			  dist=estimate_dist;
 			else flag = true;
-				//m_last_fit_nearest_time_sec = m_time_sec;	//need more tests to uncomment this sentence
+			//m_last_fit_nearest_time_sec = m_time_sec;	//need more tests to uncomment this sentence
 		}
 		else m_last_fit_nearest_time_sec = m_time_sec;
 		m_last_time_sec = m_time_sec;
@@ -583,19 +649,18 @@ 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 && timestamp/1000. - m_last_fit_time_sec < 20 && fabs(m_last_fit_k) > 0.5)
-			generate_list(mpt, sit, true);	//generate the whole list
+		  generate_list(mpt, sit, true);	//generate the whole list
 		else
-			generate_list(mpt, sit, false);	//generate single point
+		  generate_list(mpt, sit, false);	//generate single point
 
 		//turning map
 		turning_mapping(mpt, sit);
 
 		pt = mpt;
-        std_info("revise_____-end:%f,%f,useless:%s",pt.x,pt.y,flag?"true":"false");
 
 
-        return flag; 
-    }
+		return flag; 
+	}
 
 	void detect_turning(point &mpt, const site*sit)
 	{
@@ -626,9 +691,9 @@ struct car_point_filter:select_point_object
 
 		double angle1;
 		if(m_last_fit_k * dist>0)
-			angle1=calc_turning_angle(pt1, mpt);
+		  angle1=calc_turning_angle(pt1, mpt);
 		else
-			angle1=calc_turning_angle(mpt, pt1);
+		  angle1=calc_turning_angle(mpt, pt1);
 		if(angle1<0)return;
 
 		//finding
@@ -643,12 +708,12 @@ struct car_point_filter:select_point_object
 			if(delta<-180)delta=delta+360;
 			if(fabs(delta)<5)continue;
 			if(fabs(delta)>175)continue;
-													//printf("angle:%f, delta:%f. mul:%f\n",angle, delta, delta*detect_para);
+			//printf("angle:%f, delta:%f. mul:%f\n",angle, delta, delta*detect_para);
 			// turning angle must be correct
 			if(angle*delta>0 && fabs(angle)>fabs(delta)*detect_para)
 			{
 				printf("turning:(%.5f,%.5f)(%.5f,%.5f)(%.5f,%.5f),a1:%f,a2:%f,delta:%f,angle:%f\n",
-					pt1.x,pt1.y,l.v[0].x,l.v[0].y,l.v[1].x,l.v[1].y,angle1,angle2,delta,angle);
+							pt1.x,pt1.y,l.v[0].x,l.v[0].y,l.v[1].x,l.v[1].y,angle1,angle2,delta,angle);
 				m_if_turning=true;
 				m_turning_pt.set(l.v[0]);
 				m_turning_ept.set(l.v[1]);
@@ -670,54 +735,11 @@ struct car_point_filter:select_point_object
 	}
 
 };
-struct select_tool
-{
-    select_point_object *m_spo=nullptr;
-    virtual loc_point  select_solution(const std::vector<point> p,const std::vector<loc_message>&lm)=0;
-    virtual ~select_tool()
-    {
-        if(m_spo !=nullptr)
-          delete m_spo;
-    }
-};
-
-//--------------person------solution one--------
-struct select_tool_person_1:select_tool
-{
-    virtual loc_point  select_solution(const std::vector<point> p,const std::vector<loc_message>&lm);
-    ~select_tool_person_1()
-    {
-    }
-};
-
-struct select_tool_person_2:select_tool
-{
-    virtual loc_point  select_solution(const std::vector<point> p,const std::vector<loc_message>&lm)
-    {
-        loc_point lp;
-        return lp;
-    }
-
-};
-//----------------------car----------
-struct select_tool_car_1:select_tool
-{
-    virtual loc_point  select_solution(const std::vector<point> p,const std::vector<loc_message>&lm);
-};
-//---------------------drivingfaceCar
-struct select_tool_drivingface_car_1:select_tool
-{
-    virtual loc_point  select_solution(const std::vector<point> p,const std::vector<loc_message>&lm)
-    {
-        loc_point lp;
-        return lp;
-    }
-};
 //---------------------smooth
 struct smooth_tool
 {
-    std::shared_ptr<select_tool> m_st=nullptr;
-    bool smooth_initial_setting;
+	std::unique_ptr<select_tool>&m_st;
+	bool smooth_initial_setting;
 	double smooth_speed;
 	double smooth_speed_presentation;
 	int smooth_speed_presentation_cnt;
@@ -735,24 +757,24 @@ struct smooth_tool
 	point smooth_halt_position_minus;
 
 
-    smooth_tool()=default;
-    smooth_tool(std::shared_ptr<select_tool> st)
-        :m_st(st)
-        ,smooth_initial_setting(false)
-        ,smooth_speed(0)
-        ,smooth_speed_presentation(0)
-        ,smooth_speed_presentation_cnt(0)
-        ,smooth_last_time_sec(0)
-        ,smooth_halt_condition(0)
-        ,smooth_halt_count(0)
-    {}
+	smooth_tool()=default;
+	smooth_tool(std::unique_ptr<select_tool>&st)
+		:m_st(st)
+		 ,smooth_initial_setting(false)
+		 ,smooth_speed(0)
+		 ,smooth_speed_presentation(0)
+		 ,smooth_speed_presentation_cnt(0)
+		 ,smooth_last_time_sec(0)
+		 ,smooth_halt_condition(0)
+		 ,smooth_halt_count(0)
+	{}
 	void smooth_set_loc_point(double t, int ct, const site*sit, loc_point *lp)
 	{
 		point pt;
 		if(smooth_halt_condition)
-			pt.set(smooth_halt_position);
+		  pt.set(smooth_halt_position);
 		else
-			pt.set(smooth_last_position);
+		  pt.set(smooth_last_position);
 
 		lp->m_dist2=sit->dist_direct(pt);
 		lp->m_smooth_x=pt.x;
@@ -768,9 +790,9 @@ struct smooth_tool
 		{
 			lp->m_speed=smooth_speed_presentation * (3.6*sit->m_scale) ; //(m/s) to (km/h)
 			if(smooth_speed<0)
-				lp->m_speed = -lp->m_speed;
+			  lp->m_speed = -lp->m_speed;
 			if(std::isnan(lp->m_speed))
-				lp->m_speed=0;
+			  lp->m_speed=0;
 			lp->m_stat=1;
 			//if(fabs(smooth_speed_presentation) < 0.1)
 			//	lp->m_speed=0;
@@ -805,17 +827,54 @@ struct smooth_tool
 		smooth_halt_position_minus=pt;
 		return true;
 	}
-
-    virtual void smooth_strategy() = 0;
+	virtual void set(point &pt,loc_point &lp)=0;
+    loc_point smooth_strategy()
+	{
+		loc_point lp;
+		push_data_point dpt = m_st->getDpt();
+		point pt;
+		pt.set(dpt);
+		if(pt.empty())	
+		  return lp;
+		double current_t=time(NULL);
+		if(dpt.valid)
+		{
+			smooth_dist(pt, current_t, dpt.ct, dpt.sit, dpt.dstp, &lp);
+			set(pt,lp);
+
+			dpt.lp.m_dist2=lp.m_dist2;
+			dpt.lp.m_time=lp.m_time;
+			dpt.lp.m_ct=lp.m_ct;	
+			dpt.lp.set(lp);
+			dpt.lp.m_dist=dpt.sit->dist_direct(dpt);
+			dpt.lp.m_speed=lp.m_speed;
+			dpt.lp.m_stat=lp.m_stat;
+			dpt.lp.debug_out("get_point");
+		}
+		else
+		{
+			smooth_set_loc_point(current_t, dpt.ct, dpt.sit, &lp);
+			if(dpt.stop_cnt<=0)
+			{
+				lp.m_speed=0;
+				lp.m_stat=0;
+			}
+			set(pt,lp);
+		}
+		return lp;
+	}
 	virtual void smooth_dist(point &pt, double t, int ct, const site*sit, point dstp, loc_point *m_lp = nullptr)=0;
     virtual ~smooth_tool(){}
 };
 struct smooth_tool_person_1:smooth_tool
 {
-    smooth_tool_person_1(std::shared_ptr<select_tool> m)
+    smooth_tool_person_1(std::unique_ptr<select_tool>&m)
         :smooth_tool(m)
     {}
-    virtual void smooth_strategy(){}
+	virtual void set(point &pt,loc_point &lp)
+	{
+		lp.set(pt);
+	}
 	void smooth_dist(point &pt, double t, int ct, const site*sit, point dstp, loc_point *m_lp = nullptr)
     {
 		if(smooth_line.empty() || !smooth_line.contain(pt,0.1))
@@ -888,10 +947,13 @@ struct smooth_tool_person_1:smooth_tool
 };
 struct smooth_tool_car_1:smooth_tool
 {
-    smooth_tool_car_1(std::shared_ptr<select_tool> m)
+    smooth_tool_car_1(std::unique_ptr<select_tool>&m)
         :smooth_tool(m)
     {}
-    virtual void smooth_strategy(){}
+	virtual void set(point &pt,loc_point &lp)
+	{
+		lp.set(lp.m_smooth_x,lp.m_smooth_y);
+	}
 	void smooth_dist(point &pt, double t, int ct, const site*sit, point dstp, loc_point *m_lp = nullptr)
     {
         point init_pt(pt.x, pt.y);
@@ -1060,37 +1122,36 @@ struct smooth_tool_car_1:smooth_tool
 };
 struct smooth_tool_drivingface_car_1:smooth_tool
 {
-    smooth_tool_drivingface_car_1(std::shared_ptr<select_tool> m)
+    smooth_tool_drivingface_car_1(std::unique_ptr<select_tool>&m)
         :smooth_tool(m)
     {}
-    virtual void smooth_strategy()
-    {}
+	virtual void set(point&p,loc_point&lp){}
 	virtual void smooth_dist(point &pt, double t, int ct, const site*sit, point dstp, loc_point *m_lp = nullptr){}
 };
 //---------------------------------
 struct select_tool_manage
 {
-   void create_tool(const std::string &s,std::shared_ptr<select_tool> &set,std::shared_ptr<smooth_tool> &smt)
+   void create_tool(const std::string &s,std::unique_ptr <select_tool> &set,std::unique_ptr <smooth_tool> &smt)
    {
         if(!s.compare(std::string{"person1"}))
         {
-            set=std::make_shared<select_tool_person_1>();
-            smt=std::make_shared<smooth_tool_person_1>(set);
+			set.reset(new select_tool_person_1());
+			smt.reset(new smooth_tool_person_1(set));
         }
         else if(!s.compare(std::string{"person2"}))
         {
-            set=std::make_shared<select_tool_person_2>();
-            smt=std::make_shared<smooth_tool_person_1>(set);
+			set.reset(new select_tool_person_2());
+			smt.reset(new smooth_tool_person_1(set));
         }
         else if(!s.compare(std::string{"car1"}))
         {
-            set=std::make_shared<select_tool_car_1>();
-            smt=std::make_shared<smooth_tool_car_1>(set);
+			set.reset(new select_tool_car_1());
+			smt.reset(new smooth_tool_car_1(set));
         }
         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);
+			set.reset(new select_tool_drivingface_car_1());
+			smt.reset(new smooth_tool_drivingface_car_1(set));
         }
    }
    static select_tool_manage * instance();

BIN
sio.tar.gz


+ 1 - 1
visit.cpp

@@ -48,7 +48,7 @@ int main()
 {
 	std::vector<std::shared_ptr<card_list>> v;
 	//std::thread th(run);
-	for(int i=0;i<100;i++)
+	for(int i=0;i<10000;i++)
 	{
 		card_list::instance()->add(i,std::make_shared<card>(i));//每次生成一个对象
 		printf("%d  %p\n",i,card_list::instance().get());

+ 3 - 3
websocket/jsonBuilder.cpp

@@ -129,7 +129,7 @@ namespace YA
 			Error = "data::stations is not a valid array!";
 			return false;
 		}
-		for ( int i = 0; i < stations.Size(); ++i )
+		for ( int i = 0; i <(int) stations.Size(); ++i )
 		{
 			rapidjson::Value & v = stations[i];
 			if ( !v.IsObject() )
@@ -160,7 +160,7 @@ namespace YA
 			return false;
 		}
 		rapidjson::Value & cards = Data[JSON_KEY_CALL_CARD_CARDS];
-		for ( int i = 0; i < cards.Size(); ++i )
+		for ( int i = 0; i < (int)cards.Size(); ++i )
 		{
 			rapidjson::Value & v = cards[i];
 			if ( !v.IsObject() )
@@ -193,4 +193,4 @@ namespace YA
 
 		return true;
 	}
-}
+}

BIN
websocket/socket.io-client-cpp_test.cpp


+ 2 - 2
websocket/wsClientMgr.h

@@ -66,7 +66,7 @@ namespace YA
 				return pClient;
 			}
 
-			if ( index < __wsClientList.size() )
+			if ( index <(int) __wsClientList.size() )
 			{
 				pClient = __wsClientList[index];
 			}
@@ -229,4 +229,4 @@ namespace YA
 //µ¥¼þÏà¹Ø¶¨Òå
 typedef boost::serialization::singleton<YA::wsClientMgr> singleton_wsClientMgr;
 #define swsClientMgr singleton_wsClientMgr::get_mutable_instance()
-#define swsClientMgr_const singleton_wsClientMgr::get_const_instance()
+#define swsClientMgr_const singleton_wsClientMgr::get_const_instance()

+ 2 - 3
websocket/wsTimerThread.cpp

@@ -49,9 +49,8 @@ namespace YA
 		while ( pOwner->__Enable )
 		{
 			//do something...
-			std::cout << "doing..." << std::endl;
-
-			boost::this_thread::sleep( boost::posix_time::millisec( 1 ) );
+			printf("doing ....timer thread .......\n");
+			boost::this_thread::sleep( boost::posix_time::millisec( 1000 ) );
 		}
 
 		pOwner->__ExitCond.notify_one();

+ 1 - 1
websocket/wsTimerThread.h

@@ -199,4 +199,4 @@ namespace YA
 //µ¥¼þ¶¨Òå
 typedef boost::serialization::singleton<YA::wsTimerThread> singleton_wsTimerThread;
 #define swsTimerThrd singleton_wsTimerThread::get_mutable_instance()
-#define swsTimerThrd_const singleton_wsTimerThread::get_const_instance()
+#define swsTimerThrd_const singleton_wsTimerThread::get_const_instance()

+ 5 - 1
websocket/ws_common.h

@@ -55,6 +55,8 @@ namespace YA
 		double x;//x×řąę
 		double y;//y×řąę
 		double z;//z×řąę
+		double speed;
+		int    stat;
 		void Clear()
 		{
 			Type = 0;
@@ -62,6 +64,8 @@ namespace YA
 			x    = 0.0;
 			y    = 0.0;
 			z    = 0.0;
+			speed = 0;
+			stat = 0;
 		}
 		_CARD_POS_()
 		{
@@ -70,4 +74,4 @@ namespace YA
 	};
 }
 
-#endif
+#endif

+ 3 - 3
worker.cpp

@@ -25,7 +25,7 @@ struct worker_thread: zloop<task*>
 	void run()
 	{
 		ev::dynamic_loop::run(0);
-		log_info("worker_thread exit.");
+		log_info("worker_thread exit....");
 	}
 
 	virtual void on_async(const std::list<task*>&task_list)
@@ -45,13 +45,13 @@ struct worker_thread: zloop<task*>
 			case 0x863b://tdoa
 				log_info("card loc message%04X",t.m_cmd_code);
 
-				card_list::instance()-> on_message(this,t.body<message_locinfo>(),false);
+				card_list::instance()->on_message(this,t.body<message_locinfo>(),false);
 				//card_message::on_loc_message(this,t.m_param1);
 			break;
 			case 0x853b://tof his
 			case 0x873b://tdoa his
 				log_info("site history message%04X",t.m_cmd_code);
-				card_list::instance()-> on_message(this,t.body<message_locinfo>(),true);
+				card_list::instance()->on_message(this,t.body<message_locinfo>(),true);
 				//site_message::on_sync(this,t.m_param1);
 			break;