Sfoglia il codice sorgente

整理ini接口,准备导出配置文件

guohui 1 anno fa
parent
commit
1f90c72469
4 ha cambiato i file con 696 aggiunte e 129 eliminazioni
  1. 1 1
      pro/src/common.h
  2. 615 101
      pro/src/paras.c
  3. 79 27
      pro/src/sys.c
  4. 1 0
      pro/src/sys.h

+ 1 - 1
pro/src/common.h

@@ -426,7 +426,7 @@ typedef struct
     int                 trapmode;
 
     crypt_t             crypt;
-     char                nmsIP[64];
+    char                nmsIP[64];
 }SNMPManager;
 SNMPManager _globalSNMPManager;
 

File diff suppressed because it is too large
+ 615 - 101
pro/src/paras.c


+ 79 - 27
pro/src/sys.c

@@ -983,6 +983,15 @@ int sys_get_chip_id(int *id)
     return 0;
 }
 
+
+int sys_ip_check(char *ip)
+{
+    return ip_check(ip);
+}
+
+
+
+
 ///////////////////////////////////////////////////////////////////////
 #define MAX_BUFFER_SIZE 4096
 static void* plug_thread(void *arg)
@@ -1165,41 +1174,71 @@ static int get_range(struct tm *t, time_t *from, time_t *to, int days)
     *to = x2;
     return 0;
 }
-static void send_check(void)
+struct tm* get_curtime(void)
 {
-    int r,cnt,type=0;
+    time_t cur = time(NULL);
+    return localtime(&cur);
+}
+static void send_power_data(struct tm *tm)
+{
+    int r,type=0;
     char path[200],sub[100];
     char tmp1[100],tmp2[100];
-    static uint32_t send_cnt=0;
     GlobalDeviceManager *dm=&__globalDeviceManage;
     static time_t sended_id=0;
+    
+    if(tm->tm_hour==0) {
+        time_t from,to;
+        get_range(tm, &from, &to, 1);
 
-    send_cnt++;
-    if(send_cnt%SEND_PERIOD==0) {
-        time_t cur = time(NULL);
-        struct tm *tm = localtime(&cur);
-        if(tm->tm_hour==0) {
-            time_t from,to;
-            get_range(tm, &from, &to, 1);
-
-            if(sended_id != from) {
-                if(dm->_globalDevInfo.product.pwr_type>=SmartPDU_Tree_AC_Tree) {
-                    type = 1;
-                }
-                get_time_str2(tmp1,sizeof(tmp1),from);
-                get_time_str2(tmp2,sizeof(tmp2),to);
-                sprintf(path, "/tmp/power_%s_%s.csv", tmp1, tmp2);
-                if(!file_exist(path)) {
-                    dev_power_xport(type, from, to, path);
+        if(sended_id != from) {
+            if(dm->_globalDevInfo.product.pwr_type>=SmartPDU_Tree_AC_Tree) {
+                type = 1;
+            }
+            get_time_str2(tmp1,sizeof(tmp1),from);
+            get_time_str2(tmp2,sizeof(tmp2),to);
+            sprintf(path, "/tmp/power_%s_%s.csv", tmp1, tmp2);
+            if(!file_exist(path)) {
+                dev_power_xport(type, from, to, path);
+            }
+
+            if(file_exist(path)) {
+                sprintf(sub, "%s %d power data", dm->_globalDevInfo.product.name, dm->_globalDevInfo.product.id);
+                r = mail_send(sub, NULL, path);
+                if(r==0) {
+                    file_remove(path);
+                    sended_id = from;
                 }
+            }
+        }
+    }
+}
+static void send_log_data(struct tm *tm)
+{
+    int r,type=0;
+    char path[200],sub[100];
+    char tmp1[100],tmp2[100];
+    GlobalDeviceManager *dm=&__globalDeviceManage;
+    static time_t sended_id=0;
+    
+    if(tm->tm_hour==0) {
+        time_t from,to;
+        get_range(tm, &from, &to, 1);
+
+        if(sended_id != from) {
+            get_time_str2(tmp1,sizeof(tmp1),from);
+            get_time_str2(tmp2,sizeof(tmp2),to);
+            //sprintf(path, "/tmp/power_%s_%s.csv", tmp1, tmp2);
+            if(!file_exist(path)) {
+                dev_log_xport(type, from, to, path);
+            }
 
-                if(file_exist(path)) {
-                    sprintf(sub, "%s %d power data", dm->_globalDevInfo.product.name, dm->_globalDevInfo.product.id);
-                    r = mail_send(sub, NULL, path);
-                    if(r==0) {
-                        file_remove(path);
-                        sended_id = from;
-                    }
+            if(file_exist(path)) {
+                //sprintf(sub, "%s %d power data", dm->_globalDevInfo.product.name, dm->_globalDevInfo.product.id);
+                r = mail_send(sub, NULL, path);
+                if(r==0) {
+                    file_remove(path);
+                    sended_id = from;
                 }
             }
         }
@@ -1207,6 +1246,19 @@ static void send_check(void)
 }
 
 
+static void send_check(void)
+{
+    static uint32_t send_cnt=0;
+
+    send_cnt++;
+    if(send_cnt%SEND_PERIOD==0) {
+        struct tm *tm=get_curtime();
+
+        send_power_data(tm);
+    }
+}
+
+
 static void* polling_thread(void *arg)
 {
     thread_handle_t *h=(thread_handle_t*)arg;

+ 1 - 0
pro/src/sys.h

@@ -29,5 +29,6 @@ int sys_get_net(NetworkInfo_t *para, int ipVersion);
 int sys_set_net(NetworkInfo_t *para, int ipVersion);
 int sys_get_mac(char *mac, int maclen);
 int sys_get_chip_id(int *id);
+int sys_ip_check(char *ip);
 
 #endif