Browse Source

area alarm & mine alarm & log dir &

lixiaoyao 7 years ago
parent
commit
bdf24edf68
6 changed files with 760 additions and 394 deletions
  1. 2 1
      ProcessRemodule.cpp
  2. 677 378
      YAServerDlg.cpp
  3. 3 2
      YAServerDlg.h
  4. 4 0
      classdef.cpp
  5. 55 7
      mylog/MyLog.cpp
  6. 19 6
      mylog/MyLog.h

+ 2 - 1
ProcessRemodule.cpp

@@ -4,7 +4,7 @@
 #include <Windows.h>
 #include <iostream>
 #include <exception> 
-
+#include "mylog/log_module.h"
 #include "log_process_module.h"
 
 #include "./system_basic_info/SystemAnalysis.h"
@@ -386,6 +386,7 @@ int debug_print_syslog(UINT debugLevel, const char* format, ...)
 	vsnprintf_s(buffer, LOG_BUF_SIZE, LOG_BUF_SIZE-1, format, args);
 	va_end (args);
 
+	//Log::write_log(SYS_S,buffer,true);
 	send_sys_log_message(buffer);
 	return 0;
 }

File diff suppressed because it is too large
+ 677 - 378
YAServerDlg.cpp


+ 3 - 2
YAServerDlg.h

@@ -237,7 +237,8 @@ public:
 	std::shared_ptr<CardMap> mp_card_list_over_speed_vehicle; // 超速车辆
 	std::shared_ptr<CardMap> mp_card_list_area_over_time_vehicle; // 区域超时车辆
 	std::shared_ptr<CardMap> mp_card_list_over_count_person; // 人员超员
-	
+	std::shared_ptr<CardMap> mp_card_list_over_count_vehicle; //车辆超员
+
 	std::shared_ptr<AreaMap> mp_area_over_count_person; // 人员超员区域
 	std::shared_ptr<AreaMap> mp_area_over_time_person; // 人员超时区域
 	std::shared_ptr<AreaMap> mp_area_forbidden_person; // 有人限制区域
@@ -460,7 +461,7 @@ public:
 	void deal_alarm_card(std::shared_ptr<Card> card, std::shared_ptr<CardMap> dest_card_list, bool is_alarm, ALARM_FLAG tag);
     void deal_drivingface_alarm(std::shared_ptr<Card> card, bool is_alarm, ALARM_FLAG tag);
 	void deal_drivingface_alarm_all();
-	void deal_alarm_area(std::shared_ptr<Area> area, std::shared_ptr<AreaMap> dest_area_list, bool is_alarm, ALARM_FLAG tag);
+	void deal_alarm_area(std::shared_ptr<Area> area, std::shared_ptr<AreaMap> dest_area_list, bool is_alarm, ALARM_FLAG tag,int tyep);
 	void deal_card_lost_state();
 	int get_special_area_id(shared_ptr<Card> card);
 	int  deal_traffic_lights(std::shared_ptr<Card> card);

+ 4 - 0
classdef.cpp

@@ -20,7 +20,10 @@ unsigned int g_nAlgoFailedCycleCounts[ALGO_LOC_TOTAL] = {0};
 DWORD g_ullCurTime = 0;
 
 Card::Card( string cardid, int cardtype, double z_offset)
+	:m_isWarning(false),m_minDistanceToWarningpoint(DBL_MAX),m_warning_threshold(DBL_MAX),m_CardHasBeenInDrivingfaceAlarm(false),
+	m_DrivingfaceAlarmFlag(-1)
 {
+	m_warning_point_id = -1;
 	BOOL bRet = InitializeCriticalSectionAndSpinCount(&m_csCard, MAXCRITICALSECTIONSPINCOUNT);
 
 	card_type = cardtype;
@@ -92,6 +95,7 @@ Card::Card( string cardid, int cardtype, double z_offset)
 	last_locate.d = last_locate.d_offset = last_locate.v = 0.0;
 	last_locate.x = last_locate.y = last_locate.z = INVALID_COORDINATE;
 	last_x = last_y = last_z = INVALID_COORDINATE;
+	this->driving_face_cur_shift_start_x = this->driving_face_cur_shift_start_y = this->driving_face_cur_shift_start_z= this->driving_face_cur_shift_x= this->driving_face_cur_shift_y=this->driving_face_cur_shift_z = 0;
 
 	locate = nullptr;
 

+ 55 - 7
mylog/MyLog.cpp

@@ -86,7 +86,7 @@ int MyLog::test()
 
 	bRet = IsDirExist(dir);
 	if (!bRet) {
-		CreateDir(dir);
+		CreateDir(dir.c_str());
 	}
 
 	return 0;
@@ -95,9 +95,15 @@ int MyLog::test()
 int MyLog::InitLogConfig()
 {
 	std::string name = my_log_file_name[fileType];
-	std::string filename = strExeDir + "log/" + GetFileName();
+	
 	std::string str_category = my_log_file_name[fileType] + "_category";
 	m_Lasttime = getCurTime();
+	std::string filepath = strExeDir + "log\\" + m_Lasttime + "\\";
+	if (!IsDirExist(filepath))
+	{
+		CreateDir(filepath.c_str());
+	}
+	std::string filename = filepath + GetFileName();
 	pLayout = new log4cpp::PatternLayout();
 	/*
 	%c category;
@@ -156,11 +162,47 @@ bool MyLog::IsDirExist(std::string path)
 	return bRet;
 }
 
-bool MyLog::CreateDir(std::string path)
+bool MyLog::CreateDir(const char * pDir)
 {
-	std::string cmd = "md " + path;
-	system(cmd.c_str());//创建一个文件夹 
-
+	//std::string cmd = "md " + path;
+	//system(cmd.c_str());//创建一个文件夹 
+	int i = 0;  
+	int iRet;  
+	int iLen;  
+	char* pszDir;  
+
+	if(NULL == pDir)  
+	{  
+		return 0;  
+	}  
+
+	pszDir = strdup(pDir);  
+	iLen = strlen(pszDir);  
+
+	// 创建中间目录  
+	for (i = 0;i < iLen;i ++)  
+	{  
+		if (pszDir[i] == '\\' || pszDir[i] == '/')  
+		{   
+			pszDir[i] = '\0';  
+
+			//如果不存在,创建  
+			iRet = ACCESS(pszDir,0);  
+			if (iRet != 0)  
+			{  
+				iRet = MKDIR(pszDir);  
+				if (iRet != 0)  
+				{  
+					return -1;  
+				}   
+			}  
+			//支持linux,将所有\换成/  
+			pszDir[i] = '/';  
+		}   
+	}  
+
+	iRet = MKDIR(pszDir);  
+	free(pszDir);  
 	return true;
 }
 
@@ -188,7 +230,13 @@ std::string MyLog::int2string(int value)
 int MyLog::SetAppender(const char* filename)
 {
 	std::string name = my_log_file_name[fileType];
-	std::string strFileName = strExeDir + "log/" + filename;
+	//std::string strFileName = strExeDir + "log/" + filename;
+	std::string filepath = strExeDir + "log/" + m_Lasttime + "/";
+	if (!IsDirExist(filepath))
+	{
+		CreateDir(filepath.c_str());
+	}
+	std::string strFileName = filepath + filename;
 
 	pCategory->removeAppender(pAppender);
 

+ 19 - 6
mylog/MyLog.h

@@ -19,9 +19,22 @@
 
 #include <log4cpp\RollingFileAppender.hh>
 #include <log4cpp\DailyRollingFileAppender.hh>
-
-
-#define MAX_FILE_SIZE 100*1024*1024
+#ifdef _WIN32  
+#include <direct.h>  
+#include <io.h>  
+#elif _LINUX  
+#include <stdarg.h>  
+#include <sys/stat.h>  
+#endif  
+#ifdef _WIN32  
+#define ACCESS _access  
+#define MKDIR(a) _mkdir((a))  
+#elif _LINUX  
+#define ACCESS access  
+#define MKDIR(a) mkdir((a),0755)  
+#endif  
+
+#define MAX_FILE_SIZE 200*1024*1024
 #define MAX_BACKUP_COUNTS 20
 
 enum FILE_TYPE {
@@ -82,7 +95,7 @@ private:
 	//以下函数考虑移出本类
 	std::string GetExeDir();		//获得exe程序所在目录
 	bool IsDirExist(std::string path);		//检查目录是否存在
-	bool CreateDir(std::string path);		//创建目录
+	bool CreateDir(const char* path);		//创建目录
 	std::string TCHAR2string(TCHAR* tch);
 	std::string int2string(int value);
 	std::string getCurTime();
@@ -109,8 +122,8 @@ private:
 
 	std::string curFileName;
 	int curFileCount;
-	string m_Lasttime;
-	string m_Curtime;
+	std::string m_Lasttime;
+	std::string m_Curtime;
 	log4cpp::Appender* pAppender;
 	log4cpp::PatternLayout* pLayout;
 	log4cpp::Category* pCategory;