Browse Source

update merging

researchman 7 years ago
parent
commit
fa13a280c3
20 changed files with 2087 additions and 787 deletions
  1. 0 1
      MysqlConnPool.cpp
  2. 4 2
      SysSetting.cpp
  3. 1 0
      SysSetting.h
  4. 28 9
      YAServer.cpp
  5. 1 0
      YAServer.h
  6. BIN
      YAServer.rc
  7. 3 0
      YAServer.sln
  8. 1 1
      YAServer.vcxproj
  9. 22 0
      YAServer.vcxproj.filters
  10. 1 1
      YAServer.vcxproj.user
  11. 951 544
      YAServerDlg.cpp
  12. 26 2
      YAServerDlg.h
  13. 637 197
      classdef.cpp
  14. 31 20
      classdef.h
  15. 349 0
      config.ini
  16. 0 1
      constdef.h
  17. 1 1
      debug_server/debug_server_socket.cpp
  18. 1 0
      def.h
  19. 30 8
      locate_algorithm.cpp
  20. BIN
      resource.h

+ 0 - 1
MysqlConnPool.cpp

@@ -216,7 +216,6 @@ DWORD WINAPI CMysqlConnPool::thread_run( LPVOID pdata )
 		WaitForSingleObject(pConPool->m_hHaveData, INFINITE);
 		if (pConPool->IsNeedConnection())
 		{
-			// g_pSvrLog->AddRunLog(LL_DEBUG, _T("Create a new DB connection."));
 			pConPool->InitNewConn();
 		}
 	}

+ 4 - 2
SysSetting.cpp

@@ -11,7 +11,7 @@
 
 IMPLEMENT_DYNAMIC(CSysSetting, CDialogEx)
 
-	CSysSetting::CSysSetting(CWnd* pParent /*=NULL*/)
+CSysSetting::CSysSetting(CWnd* pParent /*=NULL*/)
 	: CDialogEx(CSysSetting::IDD, pParent)
 	, m_host_master(_T(""))
 	, m_recon_server(0)
@@ -26,6 +26,7 @@ IMPLEMENT_DYNAMIC(CSysSetting, CDialogEx)
 	, m_sampling_interval(0)
 	, m_use_filter(FALSE)
 	, m_db_z_offset(0)
+	, m_port(9700)
 {
 	m_host_master = CFunctions::c2wc(theApp.ws_url.c_str());
 	m_host_slave = CFunctions::c2wc(theApp.ws_url_bk.c_str());
@@ -40,6 +41,7 @@ IMPLEMENT_DYNAMIC(CSysSetting, CDialogEx)
 	m_move_error = theApp.move_error;
 	m_use_filter = theApp.use_filter;
 	m_db_z_offset = theApp.z_offset;
+	m_port = theApp.tcp_port;
 }
 
 CSysSetting::~CSysSetting()
@@ -113,7 +115,7 @@ void CSysSetting::OnBnClickedOk()
 	theApp.move_error = m_move_error;
 	theApp.use_filter = m_use_filter;
 	theApp.z_offset = m_db_z_offset;
-
+	theApp.tcp_port = m_port;
 	//将参数写入到配置文件中
 	theApp.save_sys_conf();
 	CDialogEx::OnOK();

+ 1 - 0
SysSetting.h

@@ -35,4 +35,5 @@ public:
 
 	afx_msg void OnBnClickedOk();
 	double m_db_z_offset;
+	int m_port;
 };

+ 28 - 9
YAServer.cpp

@@ -55,11 +55,24 @@ BOOL CYAServerApp::InitInstance()
 	// 如果一个运行在 Windows XP 上的应用程序清单指定要
 	// 使用 ComCtl32.dll 版本 6 或更高版本来启用可视化方式,
 	//则需要 InitCommonControlsEx()。否则,将无法创建窗口。
+<<<<<<< HEAD
 	CreateMutex(NULL, FALSE, _T("MyMux"));
 	if(GetLastError() == ERROR_ALREADY_EXISTS){
 		HWND hWnd = ::FindWindow(NULL, _T("永安信通数据采集系统"));
 		::PostMessage(hWnd, WM_QUIT, 0, 0);
 	}
+=======
+
+	//CreateMutex(NULL, FALSE, _T("MyMux"));
+	//if(GetLastError() == ERROR_ALREADY_EXISTS){
+	//	HWND hWnd = ::FindWindow(NULL, _T("永安信通数据采集系统"));
+	//	::PostMessage(hWnd, WM_QUIT, 0, 0);
+	//	//caption改为你窗口的具体caption
+	//	//::ShowWindow(hWnd,SW_SHOW);
+	//	//::SetForegroundWindow(hWnd); // 激活
+	//	//return FALSE;
+	//}
+>>>>>>> newprotocal
 
 	INITCOMMONCONTROLSEX InitCtrls;
 	InitCtrls.dwSize = sizeof(InitCtrls);
@@ -235,10 +248,20 @@ void CYAServerApp::load_sys_conf()
 {
 	locate_type = 0;
 	IniFile ini;
+	send_json_postion = 1000;
+	send_json_counting = 5000;
+	send_json_alarm = 5000;
+	send_json_device = 10000;
+	ws_connect_interval = 2000;
+	time_send_call = 5000;
+	time_send_help = 5000;
+	tcp_port = PORT_SERVER_MASTER;
+
 	if(ini.open(FILEPATH_SERVER_CONFIG)){
 		ws_url = ini.read(CONF_SECT_SERVER_SETTING, CONF_SERVER_WS_URL);
 		ws_url_bk = ini.read(CONF_SECT_SERVER_SETTING, CONF_SERVER_WS_URL_BK);
 		tcp_host = ini.read(CONF_SECT_SERVER_SETTING, CONF_SERVER_TCP_HOST);
+		tcp_port = atoi(ini.read(CONF_SECT_SERVER_SETTING, CONF_SERVER_TCP_PORT).c_str());
 		use_filter = (atoi(ini.read(CONF_SECT_SERVER_SETTING, CONF_SERVER_USE_FILTER).c_str()) == 0 ? FALSE : TRUE);
 		use_filter_odd = (atoi(ini.read(CONF_SECT_SERVER_SETTING, CONF_SERVER_USE_FILTER_ODD).c_str()) == 0 ? FALSE : TRUE);
 		recon_server = atoi(ini.read(CONF_SECT_SERVER_SETTING, CONF_SERVER_RECON_SERVER).c_str());
@@ -246,20 +269,13 @@ void CYAServerApp::load_sys_conf()
 		reader_lost = atoi(ini.read(CONF_SECT_SERVER_SETTING, CONF_SERVER_READER_LOST).c_str());
 		card_lost = atoi(ini.read(CONF_SECT_SERVER_SETTING, CONF_SERVER_CARD_LOST).c_str());
 		timing_interval = atoi(ini.read(CONF_SECT_SERVER_SETTING, CONF_SERVER_TIMING_INTERVAL).c_str());
-		sampling_interval = atoi(ini.read(CONF_SECT_SERVER_SETTING, CONF_SERVER_SAMPLING_INTERVAL).c_str());
+		sampling_interval = atof(ini.read(CONF_SECT_SERVER_SETTING, CONF_SERVER_SAMPLING_INTERVAL).c_str());
 		coor_error = atof(ini.read(CONF_SECT_SERVER_SETTING, CONF_SERVER_COORDINATE_ERROR).c_str());
 		ranging_error = atof(ini.read(CONF_SECT_SERVER_SETTING, CONF_SERVER_RANGING_ERROR).c_str());
 		move_error = atof(ini.read(CONF_SECT_SERVER_SETTING, CONF_SERVER_MOVING_ERROR).c_str());
 		z_offset = atof(ini.read(CONF_SECT_SERVER_SETTING, CONF_SERVER_Z_OFFSET).c_str());
 		locate_type = atoi(ini.read(CONF_SECT_SERVER_SETTING, CONF_SERVER_LOCATE_TYPE).c_str());
 
-		send_json_postion = 1000;
-		send_json_counting = 5000;
-		send_json_alarm = 5000;
-		send_json_device = 10000;
-		ws_connect_interval = 2000;
-		time_send_call = 5000;
-		time_send_help = 5000;
 		heart_interval = atoi(ini.read(CONF_SECT_SERVER_SETTING,CONF_SERVER_HEART_INTERVAL).c_str());
 		send_json_postion = atoi(ini.read(CONF_SECT_SERVER_SETTING, CONF_SEND_JSON_POSION).c_str());
 		send_json_counting = atoi(ini.read(CONF_SECT_SERVER_SETTING, CONF_SEND_JSON_COUNTING).c_str());
@@ -303,7 +319,7 @@ void CYAServerApp::save_sys_conf()
 	sprintf_s(t, "%d", timing_interval);
 	s = t;
 	writeini(CONF_SECT_SERVER_SETTING, CONF_SERVER_TIMING_INTERVAL, s);
-	sprintf_s(t, "%d", sampling_interval);
+	sprintf_s(t, "%f", sampling_interval);
 	s = t;
 	writeini(CONF_SECT_SERVER_SETTING, CONF_SERVER_SAMPLING_INTERVAL, s);
 	sprintf_s(t, "%f", z_offset);
@@ -318,6 +334,9 @@ void CYAServerApp::save_sys_conf()
 	sprintf_s(t, "%f", move_error);
 	s = t;
 	writeini(CONF_SECT_SERVER_SETTING, CONF_SERVER_MOVING_ERROR, s);
+	sprintf_s(t, "%d", tcp_port);
+	s = t;
+	writeini(CONF_SECT_SERVER_SETTING, CONF_SERVER_TCP_PORT, s);
 }
 
 /*

+ 1 - 0
YAServer.h

@@ -48,6 +48,7 @@ public:
 	string ws_url;	
 	string ws_url_bk;
 	string tcp_host;
+	int tcp_port;
 	BOOL use_filter;
 	BOOL use_filter_odd; // ÆæÊý
 	int recon_server;	

BIN
YAServer.rc


+ 3 - 0
YAServer.sln

@@ -17,4 +17,7 @@ Global
 	GlobalSection(SolutionProperties) = preSolution
 		HideSolutionNode = FALSE
 	EndGlobalSection
+	GlobalSection(Performance) = preSolution
+		HasPerformanceSessions = true
+	EndGlobalSection
 EndGlobal

+ 1 - 1
YAServer.vcxproj

@@ -142,7 +142,7 @@ xcopy "$(SolutionDir)..\config.ini" "D:\0a-share\$(Configuration)\" /Y /C /D /S<
     </PostBuildEvent>
   </ItemDefinitionGroup>
   <ItemGroup>
-    <None Include="..\config.ini" />
+    <None Include="config.ini" />
     <None Include="ReadMe.txt" />
     <None Include="res\YAServer.ico" />
     <None Include="res\YAServer.rc2" />

+ 22 - 0
YAServer.vcxproj.filters

@@ -87,6 +87,7 @@
     <ClInclude Include="Filter\KalmanFilter.h" />
     <ClInclude Include="KNN\KNN.h" />
     <ClInclude Include="LocateRecord.h" />
+<<<<<<< HEAD
     <ClInclude Include="LogSetting.h" />
     <ClInclude Include="log_def.h" />
     <ClInclude Include="log_process_module.h" />
@@ -113,6 +114,27 @@
     <ClInclude Include="YAServer.h" />
     <ClInclude Include="YAServerDlg.h" />
     <ClInclude Include="locate_algorithm.h" />
+=======
+    <ClInclude Include="mylog\ExRollingFileAppender.h">
+      <Filter>mylog</Filter>
+    </ClInclude>
+    <ClInclude Include="mylog\log_module.h">
+      <Filter>mylog</Filter>
+    </ClInclude>
+    <ClInclude Include="mylog\MyLog.h">
+      <Filter>mylog</Filter>
+    </ClInclude>
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="ReadMe.txt" />
+    <None Include="res\YAServer.ico">
+      <Filter>资源文件</Filter>
+    </None>
+    <None Include="res\YAServer.rc2">
+      <Filter>资源文件</Filter>
+    </None>
+    <None Include="config.ini" />
+>>>>>>> newprotocal
   </ItemGroup>
   <ItemGroup>
     <ResourceCompile Include="YAServer.rc" />

+ 1 - 1
YAServer.vcxproj.user

@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="utf-8"?>
 <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
   <PropertyGroup>
-    <ShowAllFiles>true</ShowAllFiles>
+    <ShowAllFiles>false</ShowAllFiles>
   </PropertyGroup>
 </Project>

File diff suppressed because it is too large
+ 951 - 544
YAServerDlg.cpp


+ 26 - 2
YAServerDlg.h

@@ -166,6 +166,10 @@ public:
 	time_t m_time_last_rec; // 最后接收到分站数据的时间
 	bool is_websocket_ok; 
 	bool is_websocket_login;
+	// 多web变量
+	bool is_websocket_login_ex;
+	bool is_websocket_ok_ex;
+
 	bool is_server_ok; 
 	bool is_database_ok; 
 
@@ -240,6 +244,7 @@ public:
 	_SLS sls_setting; // 系统参数配置
 	_DBS m_db_setting; // 数据库参数配置
 	string m_ws_url; // web服务器url
+	string m_ws_url_ex; // 多服务器url
 	CString m_tcp_host; // 本机接收分站数据的ip
 
 	double m_reader_interval_time;
@@ -329,6 +334,11 @@ public:
 	void ws_login();
 	void ws_logout();
 
+	void ws_init_ex();
+	void ws_open_ex();
+	void ws_login_ex();
+	void ws_logout_ex();
+
 	void clear_listener();
 	void clear_all_list();
 	// socket接收数据
@@ -411,7 +421,7 @@ public:
 	string get_json_alarm();
 	string get_json_call_test();
 	string get_json_help();			//求救json
-	string get_json_event();
+	string get_json_event(bool bAll = false);
 	string get_json_call_list();
 	string get_json_new_device_state();
 	string get_json_count_area();	//统计区域人数
@@ -539,6 +549,8 @@ public:
 	time_t GetCurShiftStartTime(int& shift_id);
 	time_t GetCurShiftEndTime();
 	time_t GetLastShiftStartTime(int& shift_id);
+	int GetCurShiftId(struct tm* current_time);
+
 	DIRECTION_TYPE GetDirectionType(_point card_point, _point landmark_point, int map_id);
 
 public:
@@ -562,7 +574,12 @@ public:
 	LRESULT UpdateCardMessage(WPARAM wParam,LPARAM lParam);
 	//std::string get_json_position(std::shared_ptr<Card> pCard);
 	void TestLandmarkRequirement();
+<<<<<<< HEAD
 
+=======
+	void TestCallCard();
+	void TestParseCallCard();
+>>>>>>> newprotocal
 public:
 	std::unique_ptr<client> _io;
 	CListBox m_list_log;
@@ -571,12 +588,19 @@ public:
 	void OnPushMessage();
 	void OnCallMessage(string const& name, message::ptr const& data, bool isAck,message::list &ack_resp); 
 	//void OnCallMessage(string const& name, message::ptr const& data, bool isAck = false,message::list &ack_resp = nullptr); 
-	void OnLoginCallBack(message::list const& msglist = nullptr);
+	//void OnLoginCallBack(message::list const& msglist = nullptr);
 	void OnLogin(string const& name, message::ptr const& data, bool isAck, message::list &ack_resp);
 
 	void OnConnected();
 	void OnClosed(client::close_reason const& reason);
 	void OnFailed();
+
+	// 向多个Web服务器发送数据
+	std::unique_ptr<client> _io_ex;
+	void OnLoginEx(string const& name, message::ptr const& data, bool isAck, message::list &ack_resp);
+	void OnConnectedEx();
+	void OnClosedEx(client::close_reason const& reason);
+	void OnFailedEx();
 protected:
 	afx_msg LRESULT OnRemoveSocket(WPARAM wParam, LPARAM lParam);
 	afx_msg LRESULT OnMsgRefreshIpList(WPARAM wParam, LPARAM lParam);

File diff suppressed because it is too large
+ 637 - 197
classdef.cpp


+ 31 - 20
classdef.h

@@ -29,9 +29,7 @@
 #define READER_SEND_STATE_TIMEOUT 30 // (2* 60 * 60)
 #define OVER_TIME (480 * 60)
 
-//#define CARD_TYPE_ADHOC 3
 #define MAX_SEMACOUNT 64
-//#define INVALID_COORDINATE -1
 
 //算法类型
 //#define ALGORITHM_TYPE_TOF
@@ -78,6 +76,10 @@ const int MAX_READER_TDOA_PATH_NUMS = 10;	//
 const int LIGHT_CTRL_DELAY = 1000;
 const int MAX_REBOUND_COUNTS = 5;
 
+#define OFFSET_THRE_IN_LINE 1	//判断是否在线段上,允许的误差为1米,用于isinline
+#define ZERO_PRECISION 1E-3		//为零的精度
+#define MAX_REBOUND_COUNTS 5
+
 enum ALARM_FLAG{
 	//AF_CARD_OVER_COUNT = 1,
 	//AF_CARD_AREA_OVER_COUNT,
@@ -119,13 +121,6 @@ enum STATUS_DEVICE{
 	STATUS_DEVICE_ERROR
 };
 
-enum STATUS_MOVING
-{
-	STATUS_MOVING_MOTIONLESS = 0,
-	STATUS_MOVING_MOTION,
-	STATUS_MOVING_IDLING
-};
-
 enum STATUS_CARD
 {
 	STATUS_NORMAL = 0,				//正常
@@ -286,6 +281,7 @@ enum ALGO_RETURN_VALUE{
 	DIST_COUNT_LESS_THAN_TWO = 10001,
 	DIST_COUNT_LESS_FOR_TIMESTAMP_ERROR,
 	DIST_COUNT_LESS_FOR_SYNC_NUM_DIFFER_FIVE,
+	DIST_COUNT_CARD_CUR_CT_LESS_LAST,
 
 	ALGO_CALC_SOLUTION = 30001,
 	ALGO_CALC_NO_SOLUTION_WITH_TWO_DATA,
@@ -308,7 +304,7 @@ enum ALGO_RETURN_VALUE{
 
 extern unsigned int g_nAlgoFailedCounts[ALGO_LOC_TOTAL];	//全局的统计所有次数
 extern unsigned int g_nAlgoFailedCycleCounts[ALGO_LOC_TOTAL];	//指定周期内的所有统计次数
-extern ULONGLONG g_ullCurTime;
+extern DWORD g_ullCurTime;
 
 #define ALGORITHM_FAILED(nType) { \
 	g_nAlgoFailedCounts[nType]++; \
@@ -1126,7 +1122,7 @@ public:
 	bool is_hist;
 	bool is_need_cal;
 	bool m_bUseFilter;
-	bool isoutput;	//是否输出到json
+	bool isoutput;				//是否输出到json
 	bool is_red_light;
 
 	bool is_mine_over_time;		// 是否井下超时
@@ -1141,11 +1137,10 @@ public:
 	time_t time_area_over_speed;
 	time_t time_low_power;
 	time_t time_red_light;		//闯红灯时间
-	time_t last_locate_time; // 最后定位时间
+	time_t last_locate_time;	// 最后定位时间
 
 	void reset();
 	void set_reader(std::shared_ptr<Reader> preader);
-	//void set_reader(std::weak_ptr<Reader> preader);
 	void add_dist(_coordinate* dist);
 	void add_dist(std::shared_ptr<_coordinate> dist);
 	void remove_dist_head();
@@ -1169,7 +1164,11 @@ public:
 
 	INT64 m_event_list[CARD_EVENT_COUNT]; // 保存事件Id
 public:
+	//算法相关参数及函数
+	bool is_algo_first_location;		//表示算法的第一次定位
+
 	std::shared_ptr<nspLocate::LocateRecord> locate;
+	std::list<std::shared_ptr<POS>> idle_pos_list;
 
 	void algo_tof(int cnt);
 	void algo_tdoa(int cnt);
@@ -1188,7 +1187,12 @@ public:
 	int ChooseOneSolution(std::shared_ptr<ReceiveDataMap> pRdm, std::vector<std::shared_ptr<POS>> udm_pos, std::shared_ptr<POS>& pos);// 输出唯一解
 	int CheckSolution(std::shared_ptr<POS>& p); // 验证唯一解合法性,如速度、加速度
 	int CheckSulutionByStream(std::shared_ptr<POS> p);	//参数使用非引用,即不可修改其值
+	int GetStream(double x1,double y1,double x2,double y2);		//获得上下行方向
+	int CalcPositionBySpeed(std::shared_ptr<POS>& pos,double v);
+
+	bool CheckStreamUniformity(double x1,double y1,double x2,double y2,int nStream);
 	bool IsExistPath(int left,int right);
+<<<<<<< HEAD
 	int CopySolution(std::shared_ptr<POS> source,std::shared_ptr<POS>& dest);
 	int CalcPositionBySpeed(std::shared_ptr<POS>& pos,double v);
 
@@ -1196,6 +1200,10 @@ public:
 	int GetDeltaT(map<unsigned long long,std::shared_ptr<_coordinate>> dl);
 	int CheckCardStatus();
 
+=======
+	bool IsIdleStatus(std::shared_ptr<POS> pos);
+	bool IsRebound(std::shared_ptr<POS> pos);		//判断是否回退
+>>>>>>> newprotocal
 public:
 	// 滤波算法相关
 	std::unique_ptr<CKalmanFilter> m_pKalmanFilter;
@@ -1220,7 +1228,6 @@ public:
 	void EnableFilter(int nType);
 	int FindDistMap(int cardstamp);
 	int KalmanFilterProcess(std::shared_ptr<POS>& pos);
-	int InitAlgoParam();
 	bool CheckCrossCycle();
 	bool isRebound(std::shared_ptr<POS> pos);			//判断是否回跳
 public:
@@ -1264,6 +1271,8 @@ public:
 	std::shared_ptr<POS> GetPosFromFittingData();						//从拟合数据获取定位坐标
 	int CheckSolutionByFit(int ret,std::shared_ptr<POS>& pos);
 	int CheckSolutionBySpeed(std::shared_ptr<POS>& pos);
+
+	bool CheckCardCtValid();	//检查卡的ct有效性
 private:
 	bool b_long_interval;	//上一次定位的间隔时间差大于10s
 
@@ -1298,15 +1307,14 @@ public: // 
 	double distance_last; // 距离	
 	int64_t flying_time_last; // 飞行时间
 	int power_state_last; // 电量
-
 	int ins_direction;	//上一次的惯导合成方向
 	int direction;		//上下行概念
-
 	int reader_id_last;	//上一次定位时间戳的分站id
 
 	string str_his_time;
 	string str_rec_time;
 
+<<<<<<< HEAD
 public:
 	//格子算法的代码
 	bool bInitalCellPath;
@@ -1376,6 +1384,9 @@ public:
 	//测试函数
 	int OutputCmdLog(int n);
 
+=======
+	public:
+>>>>>>> newprotocal
 	//呼叫信息
 	int call_type;
 	std::vector<int> vt_deal_call_reader_id;
@@ -1396,8 +1407,8 @@ public:
 class Dept
 {
 public:
-	Dept();
-	~Dept();
+	Dept(){};
+	~Dept(){};
 	Dept(int id, string name);
 private:
 public:
@@ -1411,8 +1422,8 @@ public:
 class OccLevel
 {
 public:
-	OccLevel();
-	~OccLevel();
+	OccLevel(){};
+	~OccLevel(){};
 	OccLevel(int id);
 private:
 public:

+ 349 - 0
config.ini

@@ -0,0 +1,349 @@
+[DB]
+host=localhost
+user=root
+password=password
+dbname=yaloc
+encoding=gb2312
+port=3306
+usedb=0
+
+[SERVER_SETTING]
+websocket_url=ws://localhost:8086/
+tcp_host=0.0.0.0
+tcp_port=9700
+interval_send_json_postion=1000
+interval_send_json_counting=10000
+interval_send_json_alarm=10000
+interval_send_json_device=5000
+send_call_interval=3000
+send_help_interval=5000
+heart_interval=5000
+sampling_interval=0
+ws_connect_inteval=2000
+locate_type=1
+websocket_url_bk=
+use_filter=1
+recon_server=0
+recon_db=0
+reader_lost=0
+card_lost=0
+timing_interval=0
+sampling_interval=0
+z_offset=0.000000
+coor_error=0.000000
+ranging_error=0.000000
+moving_error=0.000000
+
+[TESTTOOL]
+write_log=0
+show_data=1
+vehicle_title_count=12
+reader_title_count=7
+reader_synctime_count=11
+card_tdoa_count=13
+card_adhoc_count=6
+
+[TESTTOOL_PAGE]
+page_reader=1
+page_reader_max_rows=4000
+page_card_tof=0
+page_card_tof_max_rows=4000
+page_card_tdoa=1
+page_card_tdoa_max_rows=4000
+page_synctime=1
+page_synctime_max_rows=4000
+page_card_adhoc=0
+page_card_adhoc_max_rows=4000
+
+[TESTTOOL_VEHICLE_COLUMN_0]
+col_title=序号
+col_width=60
+col_field=DESC
+col_visible=1
+
+[TESTTOOL_VEHICLE_COLUMN_1]
+col_title=卡号
+col_width=80
+col_field=card_id
+col_visible=1
+[TESTTOOL_VEHICLE_COLUMN_2]
+col_title=分站
+col_width=40
+col_field=reader_id
+col_visible=1
+[TESTTOOL_VEHICLE_COLUMN_3]
+col_title=天线
+col_width=40
+col_field=antenna_id
+col_visible=0
+[TESTTOOL_VEHICLE_COLUMN_4]
+col_title=分站时间
+col_width=60
+col_field=reader_stamp
+col_visible=1
+[TESTTOOL_VEHICLE_COLUMN_5]
+col_title=卡时间
+col_width=60
+col_field=card_stamp
+col_visible=1
+[TESTTOOL_VEHICLE_COLUMN_6]
+col_title=飞行时间
+col_width=60
+col_field=fly_time
+col_visible=1
+[TESTTOOL_VEHICLE_COLUMN_7]
+col_title=距离(m)
+col_width=80
+col_field=distance
+col_visible=1
+[TESTTOOL_VEHICLE_COLUMN_8]
+col_title=定位方法
+col_width=60
+col_field=ranging_type
+col_visible=1
+[TESTTOOL_VEHICLE_COLUMN_9]
+col_title=电量
+col_width=40
+col_field=power
+col_visible=1
+[TESTTOOL_VEHICLE_COLUMN_10]
+col_title=加速度
+col_width=60
+col_field=acceleration
+col_visible=1
+[TESTTOOL_VEHICLE_COLUMN_11]
+col_title=接收时间
+col_width=150
+col_field=rec_time
+col_visible=1
+
+[TESTTOOL_READER_COLUMN_0]
+col_title=序号
+col_width=60
+col_field=DESC
+col_visible=1
+[TESTTOOL_READER_COLUMN_1]
+col_title=分站号
+col_width=60
+col_field=reader_id
+col_visible=1
+[TESTTOOL_READER_COLUMN_2]
+col_title=分站IP
+col_width=120
+col_field=reader_ip
+col_visible=1
+[TESTTOOL_READER_COLUMN_3]
+col_title=分站时间戳
+col_width=80
+col_field=reader_stamp
+col_visible=1
+[TESTTOOL_READER_COLUMN_4]
+col_title=状态
+col_width=60
+col_field=reader_state
+col_visible=1
+[TESTTOOL_READER_COLUMN_5]
+col_title=接收时间
+col_width=150
+col_field=rec_time
+col_visible=1
+[TESTTOOL_READER_COLUMN_6]
+col_title=分站时间
+col_width=150
+col_field=reader_time
+col_visible=1
+
+[TESTTOOL_SYNCTIME_COLUMN_0]
+col_title=序号
+col_width=60
+col_field=DESC
+col_visible=1
+[TESTTOOL_SYNCTIME_COLUMN_1]
+col_title=本地分站
+col_width=60
+col_field=local_reader
+col_visible=1
+[TESTTOOL_SYNCTIME_COLUMN_2]
+col_title=本地天线
+col_width=60
+col_field=local_antenna
+col_visible=1
+[TESTTOOL_SYNCTIME_COLUMN_3]
+col_title=上级分站
+col_width=60
+col_field=upper_reader
+col_visible=1
+[TESTTOOL_SYNCTIME_COLUMN_4]
+col_title=上级天线
+col_width=60
+col_field=upper_antenna
+col_visible=1
+[TESTTOOL_SYNCTIME_COLUMN_5]
+col_title=同步序号
+col_width=60
+col_field=sync_num
+col_visible=1
+[TESTTOOL_SYNCTIME_COLUMN_6]
+col_title=同步等级
+col_width=60
+col_field=reader_level
+col_visible=1
+[TESTTOOL_SYNCTIME_COLUMN_7]
+col_title=本地发送时间
+col_width=150
+col_field=send_time
+col_visible=1
+[TESTTOOL_SYNCTIME_COLUMN_8]
+col_title=接收上级时间
+col_width=150
+col_field=upper_time
+col_visible=1
+[TESTTOOL_SYNCTIME_COLUMN_9]
+col_title=ROOT分站
+col_width=150
+col_field=root_reader
+col_visible=1
+[TESTTOOL_SYNCTIME_COLUMN_10]
+col_title=ROOT天线
+col_width=150
+col_field=root_antenna
+col_visible=1
+
+[TESTTOOL_TDOA_COLUMN_0]
+col_title=序号
+col_width=60
+col_field=DESC
+col_visible=1
+[TESTTOOL_TDOA_COLUMN_1]
+col_title=卡号
+col_width=80
+col_field=card_id
+col_visible=1
+[TESTTOOL_TDOA_COLUMN_2]
+col_title=分站
+col_width=40
+col_field=reader_id
+col_visible=1
+[TESTTOOL_TDOA_COLUMN_3]
+col_title=天线
+col_width=40
+col_field=antenna_id
+col_visible=0
+[TESTTOOL_TDOA_COLUMN_4]
+col_title=分站时间戳
+col_width=60
+col_field=reader_stamp
+col_visible=1
+[TESTTOOL_TDOA_COLUMN_5]
+col_title=卡时间戳
+col_width=60
+col_field=card_stamp
+col_visible=1
+[TESTTOOL_TDOA_COLUMN_6]
+col_title=TDOA时间
+col_width=150
+col_field=fly_time
+col_visible=1
+[TESTTOOL_TDOA_COLUMN_7]
+col_title=分站同步序号
+col_width=60
+col_field=sync_num
+col_visible=1
+[TESTTOOL_TDOA_COLUMN_8]
+col_title=定位方法
+col_width=60
+col_field=ranging_type
+col_visible=1
+[TESTTOOL_TDOA_COLUMN_9]
+col_title=电量
+col_width=40
+col_field=power
+col_visible=1
+[TESTTOOL_TDOA_COLUMN_10]
+col_title=加速度
+col_width=60
+col_field=acceleration
+col_visible=1
+[TESTTOOL_TDOA_COLUMN_11]
+col_title=卡类型
+col_width=50
+col_field=card_type
+col_visible=1
+[TESTTOOL_TDOA_COLUMN_12]
+col_title=信号强度
+col_width=60
+col_field=strength
+col_visible=1
+[TESTTOOL_TDOA_COLUMN_13]
+col_title=X轴加速度
+col_width=60
+col_field=acc1
+col_visible=1
+[TESTTOOL_TDOA_COLUMN_14]
+col_title=Y轴加速度
+col_width=60
+col_field=acc2
+col_visible=1
+[TESTTOOL_TDOA_COLUMN_15]
+col_title=Z轴加速度
+col_width=60
+col_field=acc3
+col_visible=1
+
+[TESTTOOL_ADHOC_COLUMN_0]
+col_title=序号
+col_width=60
+col_field=DESC
+col_visible=1
+[TESTTOOL_ADHOC_COLUMN_1]
+col_title=源地址
+col_width=60
+col_field=card_id
+col_visible=1
+[TESTTOOL_ADHOC_COLUMN_2]
+col_title=命令字
+col_width=60
+col_field=cmd
+col_visible=1
+[TESTTOOL_ADHOC_COLUMN_3]
+col_title=时间戳
+col_width=60
+col_field=timestamp
+col_visible=1
+[TESTTOOL_ADHOC_COLUMN_4]
+col_title=节点级别
+col_width=60
+col_field=level
+col_visible=1
+[TESTTOOL_ADHOC_COLUMN_5]
+col_title=接收时间
+col_width=120
+col_field=rec_time
+col_visible=1
+
+[MONITOR]
+server_handle=397098
+server_path=E:\git\YaSln\src\win32\..\..\output\Debug\bin\YAServer.exe
+is_default=1
+is_master=0
+heart_interval=15
+server_interval=12
+server_local=-1062731773
+server_remote=-1062731764
+heart_local=167772161
+heart_remote=167772162
+monitor_handle=1706530
+monitor_path=E:\git\YASolution\src\win32\..\..\output\Debug\bin\YAMonitor.exe
+sel_net={7F2753AC-3CAA-4484-B729-8BED4A56C43E}
+
+
+[READER_SET]
+interval_time=200
+
+[SERVER_LOG]
+system_status=0
+raw_data=1	
+parse_data=0
+send_event=1
+rev_event=0
+locate_data=1

+ 0 - 1
constdef.h

@@ -89,7 +89,6 @@
 #define JSON_KEY_CALL_CARD_CALL_TIME "call_time"
 #define JSON_KEY_CALL_CARD_CALL_TYPE "call_type_id"
 #define JSON_KEY_CALL_CARD_USER_NAME "user_name"
-#define JSON_KEY_CALL_CARD_CALL_TIME "call_time"
 #define JSON_KEY_CALL_CARD_STATIONS "stations"
 #define JSON_KEY_CALL_CARD_STATION_ID "stationid"
 #define JSON_KEY_CALL_CARD_CARDS "cards"

+ 1 - 1
debug_server/debug_server_socket.cpp

@@ -44,7 +44,7 @@ int debug_server_init(void)
     listen(sListen, 3);
     // Create worker thread
     CreateThread(NULL, 0, WorkerThread, NULL, 0, &dwThreadId);
-	
+
 	hThread = CreateThread(NULL, 0, AcceptThread, NULL, 0, &dwAcceptThreadId);
 	//WaitForSingleObject(hThread,  INFINITE);
     return 0;

+ 1 - 0
def.h

@@ -25,6 +25,7 @@
 #define CONF_SECT_SERVER_SETTING "SERVER_SETTING"
 #define CONF_SERVER_WS_URL "websocket_url"
 #define CONF_SERVER_TCP_HOST "tcp_host"
+#define CONF_SERVER_TCP_PORT "tcp_port"
 #define CONF_SERVER_WS_URL_BK "websocket_url_bk"
 #define CONF_SERVER_USE_FILTER "use_filter"
 #define CONF_SERVER_USE_FILTER_ODD "use_filter_odd"

+ 30 - 8
locate_algorithm.cpp

@@ -768,9 +768,9 @@ std::unique_ptr<POS> LocateAlgorithm::LocatePos(std::shared_ptr<ReceiveDataMap>
 		_coordinate res[MAX_READER_TDOA_PATH_NUMS];
 		int res_idx = 0;
 		for(int i = 0;i < MAX_READER_TDOA_PATH_NUMS;i++){
-			res[0].x = INVALID_COORDINATE;
-			res[0].y = INVALID_COORDINATE;
-			res[0].z = INVALID_COORDINATE;
+			res[i].x = INVALID_COORDINATE;
+			res[i].y = INVALID_COORDINATE;
+			res[i].z = INVALID_COORDINATE;
 		}
 		//存储无路径的两分站的id和坐标
 		ReceiveData tmp_reader[MAX_READER_TDOA_PATH_NUMS];
@@ -1179,8 +1179,14 @@ std::unique_ptr<POS> LocateAlgorithm::Pos(std::shared_ptr<ReceiveDataMap> pRdm,s
 	f1.y = first->second->y;
 	f1.z = first->second->z;
 
+	//size_t nCount = 0;	//测试两个分站的定位
 	//从第二个开始遍历
 	for(;second != pRdm->end();++second){
+		//if (nCount > 0 && f1.reader_id > 300)
+		//{
+		//	break;
+		//}
+		//nCount++;
 		//获取第二个时间戳
 		ReceiveData f2;
 		f2.antenna_id = second->second->antenna_id;
@@ -1997,7 +2003,12 @@ bool LocateAlgorithm::IsInLine(_point p,_point start_p,_point end_p)
 	d2 = sqrt(pow(p.x - end_p.x,2) + pow(p.y - end_p.y,2));
 	d3 = sqrt(pow(start_p.x - end_p.x,2) + pow(start_p.y - end_p.y,2));
 
+<<<<<<< HEAD
 	if (fabs(d3 - (d1 + d2)) < 1)
+=======
+	double d4 = fabs(d3 - (d1 + d2));
+	if (d4 < OFFSET_THRE_IN_LINE)
+>>>>>>> newprotocal
 	{
 		return true;
 	}
@@ -2380,7 +2391,6 @@ std::shared_ptr<POS> LocateAlgorithm::MappingToPath( std::shared_ptr<POS> pos, s
 
 	std::shared_ptr<POS> p = std::make_shared<POS>();
 
-	p = pos;
 	//获得地图集
 	std::shared_ptr<ReaderPath> pRP = trpm->find(pos->nFirstReader)->second->find(pos->nSecondReader)->second;
 
@@ -2389,10 +2399,12 @@ std::shared_ptr<POS> LocateAlgorithm::MappingToPath( std::shared_ptr<POS> pos, s
 	if(abs(pRP->x[0] - pRP->x[1]) < 1E-6)
 	{
 		p->posx = pRP->x[0];
+		p->posy = pos->posy;
 	}
 	// 水平
 	else if(abs(pRP->y[0] - pRP->y[1]) < 1E-6)
 	{
+		p->posx = pos->posx;
 		p->posy = pRP->y[0];
 	}
 	// 有斜率
@@ -2403,13 +2415,23 @@ std::shared_ptr<POS> LocateAlgorithm::MappingToPath( std::shared_ptr<POS> pos, s
 		double k2 = -1.0 / k1;
 
 		double b1 = pRP->y[0] - k1 * pRP->x[0];
-		double b2 = pos->cy - k2 * pos->cx;	
-	
+		double b2 = pos->posy - k2 * pos->posx;	
+
 		p->posx = (b1 - b2)/(k2 - k1);
 		p->posy = k2 * p->posx + b2;
-	}
 
-	p->posz = 0;
+		//首先,求一系数 k: 设直线的起点和终点分别为A(x1, y1)、B(x2, y2),直线外一点为C(x0, y0),垂足为D;并设k = |AD| / |AB。
+		//则,k * AB = AD = AC + CD,又 AB * CD= 0;所以,k * AB* AB = AC *AB,故 k =AC * AB / (AB * AB)。
+		//带入坐标,即得, k = ( (x0- x1) * (x2 - x1) + (y0 - y1) * (y2 - y1) )  / ( (x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1) ) ;
+		//则 x = x1 + k*(x2 - x1); y = y1 + k*(y2 - y1);		
+
+		//double k = ((pos->posx - pRP->x[0]) * (pRP->x[1] - pRP->x[0]) + (pos->posy - pRP->y[0]) * (pRP->y[1] - pRP->y[0])) /
+		//	((pRP->x[1] - pRP->x[0]) * (pRP->x[1] - pRP->x[0]) + (pRP->y[1] - pRP->y[0]) * (pRP->y[1] - pRP->y[0]));
+
+		//p->posx = pRP->x[0] + k*(pRP->x[1] - pRP->x[0]);
+		//p->posx = pRP->y[0] + k*(pRP->y[1] - pRP->y[0]);
+		//p->posz = 0;
+	}
 
 	return p;
 }

BIN
resource.h