Browse Source

deal with compile warning and add system analysis count.

zhengwei 8 years ago
parent
commit
8d35f60d9b

+ 1 - 1
ProcessRemodule.cpp

@@ -43,7 +43,7 @@ BufferUtility* BufferUtility::getInstance()
     {
     	if (instance == NULL)
     	{
-       		instance = new BufferUtility();
+       		instance = new BufferUtility;
     	}
     }
     return instance;

+ 2 - 0
YAServer.cpp

@@ -17,6 +17,8 @@
 #include "./system_basic_info/SystemAnalysis.h"
 #include "./debug_server/debug_server_socket.h"
 
+#pragma warning(disable: 4005)
+
 extern int debug_server_init(void);
 
 #ifdef _DEBUG

+ 4 - 0
YAServerDlg.cpp

@@ -2156,6 +2156,10 @@ void CYAServerDlg::parse_package_data(BYTE* DataBuffer, int nLen, DWORD dwConnID
 					parse_data_locate_card(DataBuffer, nCurPos, reader_id, wChr);
 				}
 			}
+			else
+			{
+			    LOCATION_SYSTEM_BRANCH(LOCATION_SYSTEM_BRANCH_35);
+			}
 			break;
 		}
 	case CHAR_LOCATEDATAHIS:

+ 84 - 80
debug_server/debug_server_socket.cpp

@@ -7,37 +7,42 @@
 
 using namespace std;
 
-#define PORT  6123   
-#define MSGSIZE  1024   
-#pragma comment(lib, "ws2_32.lib")   
-int g_iTotalConn = 0;   
-SOCKET g_CliSocketArr[FD_SETSIZE];   
+#define PORT  6123
+#define MSGSIZE  1024
+
+#pragma warning(disable: 4018)
+#pragma warning(disable: 4996)
+#pragma comment(lib, "ws2_32.lib")
+
+int g_iTotalConn = 0;
+SOCKET g_CliSocketArr[FD_SETSIZE];
 DWORD WINAPI WorkerThread(LPVOID lpParam);
 DWORD WINAPI AcceptThread(LPVOID lpParam);
 int parserMsg(SOCKET s, char *msg);
 SOCKET sListen;
-int debug_server_init(void)   
+int debug_server_init(void)
 {   
 	HANDLE hThread;
-    WSADATA wsaData;   
-    SOCKET  sClient;   
-    SOCKADDR_IN local, client;   
-    int iAddrSize = sizeof(SOCKADDR_IN);   
-    DWORD dwThreadId; 
+    WSADATA wsaData;
+    //SOCKET  sClient;
+    SOCKADDR_IN local;
+	//SOCKADDR_IN client;
+    int iAddrSize = sizeof(SOCKADDR_IN);
+    DWORD dwThreadId;
 	DWORD dwAcceptThreadId;
-    // Initialize windows socket library   
-    WSAStartup(0x0202, &wsaData);   
-    // Create listening socket   
-    sListen = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);   
+    // Initialize windows socket library
+    WSAStartup(0x0202, &wsaData);
+    // Create listening socket
+    sListen = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); 
     // Bind   
-    local.sin_family = AF_INET;   
-    local.sin_addr.S_un.S_addr = htonl(INADDR_ANY);   
-    local.sin_port = htons(PORT);   
-    bind(sListen, (sockaddr*)&local, sizeof(SOCKADDR_IN));   
-    // Listen   
-    listen(sListen, 3);   
-    // Create worker thread   
-    CreateThread(NULL, 0, WorkerThread, NULL, 0, &dwThreadId);   
+    local.sin_family = AF_INET;
+    local.sin_addr.S_un.S_addr = htonl(INADDR_ANY);
+    local.sin_port = htons(PORT);
+    bind(sListen, (sockaddr*)&local, sizeof(SOCKADDR_IN));
+    // Listen
+    listen(sListen, 3);
+    // Create worker thread
+    CreateThread(NULL, 0, WorkerThread, NULL, 0, &dwThreadId);
 	/*
     while (TRUE)    
     {   
@@ -50,62 +55,61 @@ int debug_server_init(void)
 	*/
 	hThread = CreateThread(NULL, 0, AcceptThread, NULL, 0, &dwAcceptThreadId);
 	//WaitForSingleObject(hThread,  INFINITE);
-    return 0;   
+    return 0;
 }   
 DWORD WINAPI AcceptThread(LPVOID lpParam)
 {
 	SOCKET  sClient;
-	SOCKADDR_IN local, client;   
-    int iAddrSize = sizeof(SOCKADDR_IN); 
-	while (TRUE)    
-    {   
+	SOCKADDR_IN client;
+    int iAddrSize = sizeof(SOCKADDR_IN);
+	while (TRUE)
+    {
         // Accept a connection   
-        sClient = accept(sListen, (sockaddr*)&client, &iAddrSize);   
-        printf("Accepted client:%s:%d/n", inet_ntoa(client.sin_addr), ntohs(client.sin_port));   
-        // Add socket to g_CliSocketArr   
-        g_CliSocketArr[g_iTotalConn++] = sClient;   
-    }   
+        sClient = accept(sListen, (sockaddr*)&client, &iAddrSize); 
+        printf("Accepted client:%s:%d/n", inet_ntoa(client.sin_addr), ntohs(client.sin_port));
+        // Add socket to g_CliSocketArr
+        g_CliSocketArr[g_iTotalConn++] = sClient;
+    }
 }
-DWORD WINAPI WorkerThread(LPVOID lpParam)   
-{   
-    int i;   
-    fd_set fdread;   
-    int ret;   
-    struct timeval tv = {1, 0};   
-	  
-    while (TRUE)    
-    {   
-		char szMessage[MSGSIZE] = {0}; 
-        FD_ZERO(&fdread);   
-        for (i = 0; i < g_iTotalConn; i++)    
-        {   
-            FD_SET(g_CliSocketArr[i], &fdread);   
-        }   
-        // We only care read event   
-        ret = select(0, &fdread, NULL, NULL, &tv);   
-        if (ret == 0)    
-        {   
-            // Time expired   
+DWORD WINAPI WorkerThread(LPVOID lpParam)
+{
+    int i;
+    fd_set fdread;
+    int ret;
+    struct timeval tv = {1, 0};
+    while (TRUE)
+    {
+		char szMessage[MSGSIZE] = {0};
+        FD_ZERO(&fdread);
+        for (i = 0; i < g_iTotalConn; i++)
+        {
+            FD_SET(g_CliSocketArr[i], &fdread);
+        }
+        // We only care read event
+        ret = select(0, &fdread, NULL, NULL, &tv);
+        if (ret == 0)
+        {
+            // Time expired
             continue;   
-        }   
-        for (i = 0; i < g_iTotalConn; i++)    
-        {   
-            if (FD_ISSET(g_CliSocketArr[i], &fdread))    
-            {   
-                // A read event happened on g_CliSocketArr   
-                ret = recv(g_CliSocketArr[i], szMessage, MSGSIZE, 0);   
-                if (ret == 0 || (ret == SOCKET_ERROR && WSAGetLastError() == WSAECONNRESET))    
-                {   
-                    // Client socket closed   
-                    printf("Client socket %d closed./n", g_CliSocketArr[i]);   
-                    closesocket(g_CliSocketArr[i]);   
-                    if (i < g_iTotalConn-1)    
-                    {   
-                        g_CliSocketArr[i--] = g_CliSocketArr[--g_iTotalConn];   
-                    }   
-                }    
-                else    
-                {   
+        }
+        for (i = 0; i < g_iTotalConn; i++)
+        {
+            if (FD_ISSET(g_CliSocketArr[i], &fdread))
+            {
+                // A read event happened on g_CliSocketArr
+                ret = recv(g_CliSocketArr[i], szMessage, MSGSIZE, 0);
+                if (ret == 0 || (ret == SOCKET_ERROR && WSAGetLastError() == WSAECONNRESET))
+                {
+                    // Client socket closed
+                    printf("Client socket %d closed./n", g_CliSocketArr[i]);
+                    closesocket(g_CliSocketArr[i]);
+                    if (i < g_iTotalConn-1)
+                    {
+                        g_CliSocketArr[i--] = g_CliSocketArr[--g_iTotalConn];
+                    }
+                }
+                else
+                {
                     // We reveived a message from client
 					if(strlen(szMessage) > 0)
 					{
@@ -114,11 +118,11 @@ DWORD WINAPI WorkerThread(LPVOID lpParam)
 					//char buf[100] = "hello word.\n";
                     //send(g_CliSocketArr[i], buf, strlen(buf), 0);
 					parserMsg(g_CliSocketArr[i], szMessage);
-                }   
-            }   
-        }   
-    }   
-}  
+                }
+            }
+        }
+    }
+}
 
 int parserMsg(SOCKET s, char *msg)
 {
@@ -132,10 +136,10 @@ int parserMsg(SOCKET s, char *msg)
     char *delims=" ";
 	char *next_token = NULL;
 	char localBuf[MAX_CMD_WORD_NUM][MAX_CMD_WORD_LEN] = {0};
-    p=strtok_s(msg, delims, &next_token); 
+    p=strtok_s(msg, delims, &next_token);
     while(p!=NULL)
-	{ 
-       strcpy_s(localBuf[word_num++], p); 
+	{
+       strcpy_s(localBuf[word_num++], p);
        p=strtok_s(NULL, delims, &next_token);
     }
     for(i=0; i<word_num; i++)

+ 1 - 1
debug_server/debug_server_socket.h

@@ -8,7 +8,7 @@
 #define MAX_CMD_WORD_LEN          20
 
 #define    OK        0
-#define    ERROR    -1
+//#define    ERROR    -1
 
 
 extern int debug_server_init(void);

+ 1 - 1
system_basic_info/SystemAnalysis.h

@@ -40,7 +40,7 @@ typedef enum StationSyncBasicBranch
     LOCATION_SYSTEM_BRANCH_32,        //used
     LOCATION_SYSTEM_BRANCH_33,        //used
     LOCATION_SYSTEM_BRANCH_34,        //used
-    LOCATION_SYSTEM_BRANCH_35,
+    LOCATION_SYSTEM_BRANCH_35,        //used
     LOCATION_SYSTEM_BRANCH_36,
     LOCATION_SYSTEM_BRANCH_37,
     LOCATION_SYSTEM_BRANCH_38,