Ver código fonte

解决报警配置文件导入导出的bug

guohui 1 ano atrás
pai
commit
55e96d8af2

+ 116 - 0
pro/modbus/inc/modbus-private.h

@@ -0,0 +1,116 @@
+/*
+ * Copyright © 2010-2012 Stéphane Raimbault <stephane.raimbault@gmail.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1+
+ */
+
+#ifndef MODBUS_PRIVATE_H
+#define MODBUS_PRIVATE_H
+
+#ifndef _MSC_VER
+# include <stdint.h>
+# include <sys/time.h>
+#else
+# include "stdint.h"
+# include <time.h>
+typedef int ssize_t;
+#endif
+#include <sys/types.h>
+#include <config.h>
+
+#include "modbus.h"
+
+MODBUS_BEGIN_DECLS
+
+/* It's not really the minimal length (the real one is report slave ID
+ * in RTU (4 bytes)) but it's a convenient size to use in RTU or TCP
+ * communications to read many values or write a single one.
+ * Maximum between :
+ * - HEADER_LENGTH_TCP (7) + function (1) + address (2) + number (2)
+ * - HEADER_LENGTH_RTU (1) + function (1) + address (2) + number (2) + CRC (2)
+ */
+#define _MIN_REQ_LENGTH 12
+
+#define _REPORT_SLAVE_ID 180
+
+#define _MODBUS_EXCEPTION_RSP_LENGTH 5
+
+/* Timeouts in microsecond (0.5 s) */
+#define _RESPONSE_TIMEOUT    500000
+#define _BYTE_TIMEOUT        500000
+
+typedef enum {
+    _MODBUS_BACKEND_TYPE_RTU=0,
+    _MODBUS_BACKEND_TYPE_TCP
+} modbus_backend_type_t;
+
+/*
+ *  ---------- Request     Indication ----------
+ *  | Client | ---------------------->| Server |
+ *  ---------- Confirmation  Response ----------
+ */
+typedef enum {
+    /* Request message on the server side */
+    MSG_INDICATION,
+    /* Request message on the client side */
+    MSG_CONFIRMATION
+} msg_type_t;
+
+/* This structure reduces the number of params in functions and so
+ * optimizes the speed of execution (~ 37%). */
+typedef struct _sft {
+    int slave;
+    int function;
+    int t_id;
+} sft_t;
+
+typedef struct _modbus_backend {
+    unsigned int backend_type;
+    unsigned int header_length;
+    unsigned int checksum_length;
+    unsigned int max_adu_length;
+    int (*set_slave) (modbus_t *ctx, int slave);
+    int (*build_request_basis) (modbus_t *ctx, int function, int addr,
+                                int nb, uint8_t *req);
+    int (*build_response_basis) (sft_t *sft, uint8_t *rsp);
+    int (*prepare_response_tid) (const uint8_t *req, int *req_length);
+    int (*send_msg_pre) (uint8_t *req, int req_length);
+    ssize_t (*send) (modbus_t *ctx, const uint8_t *req, int req_length);
+    int (*receive) (modbus_t *ctx, uint8_t *req);
+    ssize_t (*recv) (modbus_t *ctx, uint8_t *rsp, int rsp_length);
+    int (*check_integrity) (modbus_t *ctx, uint8_t *msg,
+                            const int msg_length);
+    int (*pre_check_confirmation) (modbus_t *ctx, const uint8_t *req,
+                                   const uint8_t *rsp, int rsp_length);
+    int (*connect) (modbus_t *ctx);
+    void (*close) (modbus_t *ctx);
+    int (*flush) (modbus_t *ctx);
+    int (*select) (modbus_t *ctx, fd_set *rset, struct timeval *tv, int msg_length);
+    void (*free) (modbus_t *ctx);
+} modbus_backend_t;
+
+struct _modbus {
+    /* Slave address */
+    int slave;
+    /* Socket or file descriptor */
+    int s;
+    int debug;
+    int error_recovery;
+    struct timeval response_timeout;
+    struct timeval byte_timeout;
+    struct timeval indication_timeout;
+    const modbus_backend_t *backend;
+    void *backend_data;
+};
+
+void _modbus_init_common(modbus_t *ctx);
+void _error_print(modbus_t *ctx, const char *context);
+int _modbus_receive_msg(modbus_t *ctx, uint8_t *msg, msg_type_t msg_type);
+
+#ifndef HAVE_STRLCPY
+size_t strlcpy(char *dest, const char *src, size_t dest_size);
+#endif
+
+MODBUS_END_DECLS
+
+#endif  /* MODBUS_PRIVATE_H */

+ 1 - 0
pro/src/cascade_slave_tcp.h

@@ -13,6 +13,7 @@
 
 #include "modbus-private.h"
 
+
 Modbus_Manger_Tcp* tcp_modbus_init(const char * ip, uint16_t port,uint8_t addr,int power_type);
 void  tcp_modbus_deinit(Modbus_Manger_Tcp **tcp);
 

+ 8 - 8
pro/src/common.h

@@ -580,15 +580,15 @@ typedef struct
 {
     int                 product_id                                 ;//产品ID
     //20240225 add
-    char                product_saddr                              ;//modbus地址记录                       
-    char                product_ch_id                              ;//通道号
-    char                product_ch_addr                            ;//通道号实际地址
+    int                 product_saddr                              ;//modbus地址记录                       
+    int                 product_ch_id                              ;//通道号
+    int                 product_ch_addr                            ;//通道号实际地址
     char                product_ch_name[32]                        ;//通道名称
-    char                product_ch_type                            ;//通道类型
-    char                product_ch_status                          ;//通道状态
-    char                product_ch_NF_status                          ;//通道零线状态(三相)
-    unsigned short      product_ch_start_delay                     ;//通道延时 
-    unsigned short      product_ch_stop_delay                      ;//通道延时
+    int                 product_ch_type                            ;//通道类型
+    int                 product_ch_status                          ;//通道状态
+    int                 product_ch_NF_status                       ;//通道零线状态(三相)
+    int                 product_ch_start_delay                     ;//通道延时 
+    int                 product_ch_stop_delay                      ;//通道延时
 
     GlobalOverManager   global_over_manager                        ;//超限管理
     struct list_head    list_DS;                                    //定时设置      

+ 1 - 0
pro/src/file.c

@@ -183,6 +183,7 @@ int file_append(char *path, void *data, int datalen)
     }
     else {
         LOGE("file_append %s failed, %d, %d\n", path, r, datalen);
+        r = -1;
     }
     fclose(fp);
 

+ 62 - 72
pro/src/paras.c

@@ -2513,7 +2513,7 @@ static int proc_power(char *path, int op, GlobalPowerManger *power)
                     r = ini_rw(dic, token, &tmp->product_ch_addr, sizeof(tmp->product_ch_addr), TYPE_INT, op, 1); if(r) break;
 
                     sprintf(token, "power:channel%d.name",tmp->product_ch_id);
-                    r = ini_rw(dic, token, tmp->product_ch_name, sizeof(tmp->product_ch_name), TYPE_INT, op, 1); if(r) break;
+                    r = ini_rw(dic, token, tmp->product_ch_name, sizeof(tmp->product_ch_name), TYPE_STR, op, 1); if(r) break;
 
                     sprintf(token, "power:channel%d.type",tmp->product_ch_id);
                     r = ini_rw(dic, token, &tmp->product_ch_type, sizeof(tmp->product_ch_type), TYPE_INT, op, 1); if(r) break;
@@ -2649,7 +2649,7 @@ static int proc_power(char *path, int op, GlobalPowerManger *power)
                 r = ini_rw(dic, token, &tmp->product_ch_addr, sizeof(tmp->product_ch_addr), TYPE_INT, op, 1); if(r) break;
 
                 sprintf(token, "power:channel%d.name",tmp->product_ch_id);
-                r = ini_rw(dic, token, tmp->product_ch_name, sizeof(tmp->product_ch_name), TYPE_INT, op, 1); if(r) break;
+                r = ini_rw(dic, token, tmp->product_ch_name, sizeof(tmp->product_ch_name), TYPE_STR, op, 1); if(r) break;
 
                 sprintf(token, "power:channel%d.type",tmp->product_ch_id);
                 r = ini_rw(dic, token, &tmp->product_ch_type, sizeof(tmp->product_ch_type), TYPE_INT, op, 1); if(r) break;
@@ -2763,7 +2763,7 @@ static int proc_power3(char *path, int op, GlobalTreeACManager *power)
         case PARAS_CHECK:
         {
             if(ppower->product_ch_addr<0) {
-                LOGE("___ check power, product_ch_addr %d is invalid, must greater than 0\n", ppower->product_ch_addr);
+                LOGE("___ check power3, product_ch_addr %d is invalid, must greater than 0\n", ppower->product_ch_addr);
                 r = -1; 
             }
             return r;
@@ -2778,7 +2778,7 @@ static int proc_power3(char *path, int op, GlobalTreeACManager *power)
                 return -1;
             }
 
-            fprintf(fp, "[power]\n");
+            fprintf(fp, "[power3]\n");
             fprintf(fp, "\n");
             fclose(fp);
             return 0;
@@ -2798,91 +2798,91 @@ static int proc_power3(char *path, int op, GlobalTreeACManager *power)
                 for(i=1; i<=dm->brdMax*3; i++) {
                     int channelID = i;
 
-                    sprintf(token, "power:channel%d.addr",i);
+                    sprintf(token, "power3:channel%d.addr",i);
                     r = ini_rw(dic, token, &tmp->product_saddr, sizeof(tmp->product_saddr), TYPE_INT, op, 1); if(r) break;
 
                     tmp->product_ph_id = channelID-1;
 
-                    sprintf(token, "power:channel%d.ch_addr",channelID);
+                    sprintf(token, "power3:channel%d.ch_addr",channelID);
                     r = ini_rw(dic, token, &tmp->product_ch_addr, sizeof(tmp->product_ch_addr), TYPE_INT, op, 1); if(r) break;
 
-                    sprintf(token, "power:channel%d.ch_id",channelID);
+                    sprintf(token, "power3:channel%d.ch_id",channelID);
                     r = ini_rw(dic, token, &tmp->product_ch_id, sizeof(tmp->product_ch_id), TYPE_INT, op, 1); if(r) break;
 
-                    sprintf(token, "power:channel%d.ph_type",channelID);
+                    sprintf(token, "power3:channel%d.ph_type",channelID);
                     r = ini_rw(dic, token, &tmp->product_ph_type, sizeof(tmp->product_ph_type), TYPE_INT, op, 1); if(r) break;
 /*
-                    sprintf(token, "power:channel%d.ph_otype",channelID);
+                    sprintf(token, "power3:channel%d.ph_otype",channelID);
                     r = ini_rw(dic, token, &tmp->product_ph_outputType, sizeof(tmp->product_ph_outputType), TYPE_INT, op, 1); if(r) break;
 
-                    sprintf(token, "power:channel%d.ph_ostat",channelID);
+                    sprintf(token, "power3:channel%d.ph_ostat",channelID);
                     r = ini_rw(dic, token, &tmp->product_ph_outputStatus, sizeof(tmp->product_ph_outputStatus), TYPE_INT, op, 1); if(r) break;
 */
                     ///////////voltage//////////
                     GlobalOverManager *pover=&tmp->global_over_manager;
                     //upper
-                    sprintf(token, "power:channel%d.threshold.voltage.up.en",channelID);
+                    sprintf(token, "power3:channel%d.threshold.voltage.up.en",channelID);
                     r = ini_rw(dic, token, &pover->product_vol_upper_enable, sizeof(pover->product_vol_upper_enable), TYPE_INT, op, 1); if(r) break;
 
-                    sprintf(token, "power:channel%d.threshold.voltage.up.val",channelID);
+                    sprintf(token, "power3:channel%d.threshold.voltage.up.val",channelID);
                     r = ini_rw(dic, token, &pover->product_vol_upper_threshold, sizeof(pover->product_vol_upper_threshold), TYPE_FLOAT, op, 1); if(r) break;
 
-                    sprintf(token, "power:channel%d.threshold.voltage.up.act",channelID);
+                    sprintf(token, "power3:channel%d.threshold.voltage.up.act",channelID);
                     r = ini_rw(dic, token, &pover->product_vol_over_upper_threshold_ctrl, sizeof(pover->product_vol_over_upper_threshold_ctrl), TYPE_INT, op, 1); if(r) break;
 
-                    sprintf(token, "power:channel%d.threshold.voltage.up.para",channelID);
+                    sprintf(token, "power3:channel%d.threshold.voltage.up.para",channelID);
                     r = ini_rw(dic, token, &pover->product_vol_over_upper_threshold_ctrl_para, sizeof(pover->product_vol_over_upper_threshold_ctrl_para), TYPE_INT, op, 1); if(r) break;
 
                     //lower
-                    sprintf(token, "power:channel%d.threshold.voltage.lo.en",channelID);
+                    sprintf(token, "power3:channel%d.threshold.voltage.lo.en",channelID);
                     r = ini_rw(dic, token, &pover->product_vol_lower_enable, sizeof(pover->product_vol_lower_enable), TYPE_INT, op, 1); if(r) break;
 
-                    sprintf(token, "power:channel%d.threshold.voltage.lo.val",channelID);
+                    sprintf(token, "power3:channel%d.threshold.voltage.lo.val",channelID);
                     r = ini_rw(dic, token, &pover->product_vol_lower_threshold, sizeof(pover->product_vol_lower_threshold), TYPE_FLOAT, op, 1); if(r) break;
 
-                    sprintf(token, "power:channel%d.threshold.voltage.lo.act",channelID);
+                    sprintf(token, "power3:channel%d.threshold.voltage.lo.act",channelID);
                     r = ini_rw(dic, token, &pover->product_vol_over_lower_threshold_ctrl, sizeof(pover->product_vol_over_lower_threshold_ctrl), TYPE_INT, op, 1); if(r) break;
 
-                    sprintf(token, "power:channel%d.threshold.voltage.lo.para",channelID);
+                    sprintf(token, "power3:channel%d.threshold.voltage.lo.para",channelID);
                     r = ini_rw(dic, token, &pover->product_vol_over_lower_threshold_ctrl_para, sizeof(pover->product_vol_over_lower_threshold_ctrl_para), TYPE_INT, op, 1); if(r) break;
 
                     ///////////current//////////
-                    sprintf(token, "power:channel%d.threshold.current.up.en",channelID);
+                    sprintf(token, "power3:channel%d.threshold.current.up.en",channelID);
                     r = ini_rw(dic, token, &pover->product_cur_upper_enable, sizeof(pover->product_cur_upper_enable), TYPE_INT, op, 1); if(r) break;
 
-                    sprintf(token, "power:channel%d.threshold.current.up.val",channelID);
+                    sprintf(token, "power3:channel%d.threshold.current.up.val",channelID);
                     r = ini_rw(dic, token, &pover->product_cur_upper_threshold, sizeof(pover->product_cur_upper_threshold), TYPE_FLOAT, op, 1); if(r) break;
 
-                    sprintf(token, "power:channel%d.threshold.current.up.act",channelID);
+                    sprintf(token, "power3:channel%d.threshold.current.up.act",channelID);
                     r = ini_rw(dic, token, &pover->product_cur_over_upper_threshold_ctrl, sizeof(pover->product_cur_over_upper_threshold_ctrl), TYPE_INT, op, 1); if(r) break;
 
-                    sprintf(token, "power:channel%d.threshold.current.up.para",channelID);
+                    sprintf(token, "power3:channel%d.threshold.current.up.para",channelID);
                     r = ini_rw(dic, token, &pover->product_cur_over_upper_threshold_ctrl_para, sizeof(pover->product_cur_over_upper_threshold_ctrl_para), TYPE_INT, op, 1); if(r) break;
 
                     ///////////power//////////
-                    sprintf(token, "power:channel%d.threshold.power.up.en",channelID);
+                    sprintf(token, "power3:channel%d.threshold.power.up.en",channelID);
                     r = ini_rw(dic, token, &pover->product_pwr_upper_enable, sizeof(pover->product_pwr_upper_enable), TYPE_INT, op, 1); if(r) break;
 
-                    sprintf(token, "power:channel%d.threshold.power.up.val",channelID);
+                    sprintf(token, "power3:channel%d.threshold.power.up.val",channelID);
                     r = ini_rw(dic, token, &pover->product_pwr_upper_threshold, sizeof(pover->product_pwr_upper_threshold), TYPE_FLOAT, op, 1); if(r) break;
 
-                    sprintf(token, "power:channel%d.threshold.power.up.act",channelID);
+                    sprintf(token, "power3:channel%d.threshold.power.up.act",channelID);
                     r = ini_rw(dic, token, &pover->product_pwr_over_upper_threshold_ctrl, sizeof(pover->product_pwr_over_upper_threshold_ctrl), TYPE_INT, op, 1); if(r) break;
 
-                    sprintf(token, "power:channel%d.threshold.power.up.para",channelID);
+                    sprintf(token, "power3:channel%d.threshold.power.up.para",channelID);
                     r = ini_rw(dic, token, &pover->product_pwr_over_upper_threshold_ctrl_para, sizeof(pover->product_pwr_over_upper_threshold_ctrl_para), TYPE_INT, op, 1); if(r) break;
 
                     ///////////power consumption//////////
-                    sprintf(token, "power:channel%d.threshold.powerc.up.en",channelID);
+                    sprintf(token, "power3:channel%d.threshold.powerc.up.en",channelID);
                     r = ini_rw(dic, token, &pover->product_pwrcon_upper_enable, sizeof(pover->product_pwrcon_upper_enable), TYPE_INT, op, 1); if(r) break;
 
-                    sprintf(token, "power:channel%d.threshold.powerc.up.val",channelID);
+                    sprintf(token, "power3:channel%d.threshold.powerc.up.val",channelID);
                     r = ini_rw(dic, token, &pover->product_pwrcon_upper_threshold, sizeof(pover->product_pwrcon_upper_threshold), TYPE_FLOAT, op, 1); if(r) break;
 
-                    sprintf(token, "power:channel%d.threshold.powerc.up.act",channelID);
+                    sprintf(token, "power3:channel%d.threshold.powerc.up.act",channelID);
                     r = ini_rw(dic, token, &pover->product_pwrcon_over_upper_threshold_ctrl, sizeof(pover->product_pwrcon_over_upper_threshold_ctrl), TYPE_INT, op, 1); if(r) break;
 
-                    sprintf(token, "power:channel%d.threshold.powerc.up.para",channelID);
+                    sprintf(token, "power3:channel%d.threshold.powerc.up.para",channelID);
                     r = ini_rw(dic, token, &pover->product_pwrcon_over_upper_threshold_ctrl_para, sizeof(pover->product_pwrcon_over_upper_threshold_ctrl_para), TYPE_INT, op, 1); if(r) break;
                     
                     if(chk_ok==0) {
@@ -2897,8 +2897,6 @@ static int proc_power3(char *path, int op, GlobalTreeACManager *power)
                         r = get_power(tmp->product_ch_id, &pwr); if(r) break;
 
                         pwr.global_over_manager = tmp->global_over_manager;
-                        r = dev_update_power_manage_over_info(dm->db, 0, pwr.product_ch_id, &pwr);  if(r) break;
-
                         r = dev_update_t_ac_power_manage_over_info(dm->db, tmp);    if(r) break;
 
                         r = g_switch_set_all_single_threshold(&dm->_globalRelaySampManger,
@@ -2942,92 +2940,92 @@ static int proc_power3(char *path, int op, GlobalTreeACManager *power)
 
                 r = proc_power3(path, PARAS_CHECK, tmp); if(r) break;
 
-                sprintf(token, "power:channel%d.addr",channelID);
+                sprintf(token, "power3:channel%d.addr",channelID);
                 r = ini_rw(dic, token, &tmp->product_saddr, sizeof(tmp->product_saddr), TYPE_INT, op, 1); if(r) break;
 
-                sprintf(token, "power:channel%d.ch_id",channelID);
+                sprintf(token, "power3:channel%d.ch_id",channelID);
                 r = ini_rw(dic, token, &tmp->product_ch_id, sizeof(tmp->product_ch_id), TYPE_INT, op, 1); if(r) break;
 
-                sprintf(token, "power:channel%d.ch_addr",channelID);
+                sprintf(token, "power3:channel%d.ch_addr",channelID);
                 r = ini_rw(dic, token, &tmp->product_ch_addr, sizeof(tmp->product_ch_addr), TYPE_INT, op, 1); if(r) break;
 
-                //sprintf(token, "power:channel%d.ph_id",channelID);
+                //sprintf(token, "power3:channel%d.ph_id",channelID);
                 //r = ini_rw(dic, token, &tmp->product_ph_id, sizeof(tmp->product_ph_id), TYPE_INT, op, 1); if(r) break;
 
-                sprintf(token, "power:channel%d.ph_type",channelID);
+                sprintf(token, "power3:channel%d.ph_type",channelID);
                 r = ini_rw(dic, token, &tmp->product_ph_type, sizeof(tmp->product_ph_type), TYPE_INT, op, 1); if(r) break;
 /*
-                sprintf(token, "power:channel%d.ph_otype",channelID);
+                sprintf(token, "power3:channel%d.ph_otype",channelID);
                 r = ini_rw(dic, token, &tmp->product_ph_outputType, sizeof(tmp->product_ph_outputType), TYPE_INT, op, 1); if(r) break;
 
-                sprintf(token, "power:channel%d.ph_ostat",channelID);
+                sprintf(token, "power3:channel%d.ph_ostat",channelID);
                 r = ini_rw(dic, token, &tmp->product_ph_outputStatus, sizeof(tmp->product_ph_outputStatus), TYPE_INT, op, 1); if(r) break;
 */
                 ///////////voltage//////////
                 GlobalOverManager *pover=&tmp->global_over_manager;
                 //upper
-                sprintf(token, "power:channel%d.threshold.voltage.up.en",channelID);
+                sprintf(token, "power3:channel%d.threshold.voltage.up.en",channelID);
                 r = ini_rw(dic, token, &pover->product_vol_upper_enable, sizeof(pover->product_vol_upper_enable), TYPE_INT, op, 1); if(r) break;
 
-                sprintf(token, "power:channel%d.threshold.voltage.up.val",channelID);
+                sprintf(token, "power3:channel%d.threshold.voltage.up.val",channelID);
                 r = ini_rw(dic, token, &pover->product_vol_upper_threshold, sizeof(pover->product_vol_upper_threshold), TYPE_FLOAT, op, 1); if(r) break;
 
-                sprintf(token, "power:channel%d.threshold.voltage.up.act",channelID);
+                sprintf(token, "power3:channel%d.threshold.voltage.up.act",channelID);
                 r = ini_rw(dic, token, &pover->product_vol_over_upper_threshold_ctrl, sizeof(pover->product_vol_over_upper_threshold_ctrl), TYPE_INT, op, 1); if(r) break;
 
-                sprintf(token, "power:channel%d.threshold.voltage.up.para",channelID);
+                sprintf(token, "power3:channel%d.threshold.voltage.up.para",channelID);
                 r = ini_rw(dic, token, &pover->product_vol_over_upper_threshold_ctrl_para, sizeof(pover->product_vol_over_upper_threshold_ctrl_para), TYPE_INT, op, 1); if(r) break;
 
                 //lower
-                sprintf(token, "power:channel%d.threshold.voltage.lo.en",channelID);
+                sprintf(token, "power3:channel%d.threshold.voltage.lo.en",channelID);
                 r = ini_rw(dic, token, &pover->product_vol_lower_enable, sizeof(pover->product_vol_lower_enable), TYPE_INT, op, 1); if(r) break;
 
-                sprintf(token, "power:channel%d.threshold.voltage.lo.val",channelID);
+                sprintf(token, "power3:channel%d.threshold.voltage.lo.val",channelID);
                 r = ini_rw(dic, token, &pover->product_vol_lower_threshold, sizeof(pover->product_vol_lower_threshold), TYPE_FLOAT, op, 1); if(r) break;
 
-                sprintf(token, "power:channel%d.threshold.voltage.lo.act",channelID);
+                sprintf(token, "power3:channel%d.threshold.voltage.lo.act",channelID);
                 r = ini_rw(dic, token, &pover->product_vol_over_lower_threshold_ctrl, sizeof(pover->product_vol_over_lower_threshold_ctrl), TYPE_INT, op, 1); if(r) break;
 
-                sprintf(token, "power:channel%d.threshold.voltage.lo.para",channelID);
+                sprintf(token, "power3:channel%d.threshold.voltage.lo.para",channelID);
                 r = ini_rw(dic, token, &pover->product_vol_over_lower_threshold_ctrl_para, sizeof(pover->product_vol_over_lower_threshold_ctrl_para), TYPE_INT, op, 1); if(r) break;
 
                 ///////////current//////////
-                sprintf(token, "power:channel%d.threshold.current.up.en",channelID);
+                sprintf(token, "power3:channel%d.threshold.current.up.en",channelID);
                 r = ini_rw(dic, token, &pover->product_cur_upper_enable, sizeof(pover->product_cur_upper_enable), TYPE_INT, op, 1); if(r) break;
 
-                sprintf(token, "power:channel%d.threshold.current.up.val",channelID);
+                sprintf(token, "power3:channel%d.threshold.current.up.val",channelID);
                 r = ini_rw(dic, token, &pover->product_cur_upper_threshold, sizeof(pover->product_cur_upper_threshold), TYPE_FLOAT, op, 1); if(r) break;
 
-                sprintf(token, "power:channel%d.threshold.current.up.act",channelID);
+                sprintf(token, "power3:channel%d.threshold.current.up.act",channelID);
                 r = ini_rw(dic, token, &pover->product_cur_over_upper_threshold_ctrl, sizeof(pover->product_cur_over_upper_threshold_ctrl), TYPE_INT, op, 1); if(r) break;
 
-                sprintf(token, "power:channel%d.threshold.current.up.para",channelID);
+                sprintf(token, "power3:channel%d.threshold.current.up.para",channelID);
                 r = ini_rw(dic, token, &pover->product_cur_over_upper_threshold_ctrl_para, sizeof(pover->product_cur_over_upper_threshold_ctrl_para), TYPE_INT, op, 1); if(r) break;
 
                 ///////////power//////////
-                sprintf(token, "power:channel%d.threshold.power.up.en",channelID);
+                sprintf(token, "power3:channel%d.threshold.power.up.en",channelID);
                 r = ini_rw(dic, token, &pover->product_pwr_upper_enable, sizeof(pover->product_pwr_upper_enable), TYPE_INT, op, 1); if(r) break;
 
-                sprintf(token, "power:channel%d.threshold.power.up.val",channelID);
+                sprintf(token, "power3:channel%d.threshold.power.up.val",channelID);
                 r = ini_rw(dic, token, &pover->product_pwr_upper_threshold, sizeof(pover->product_pwr_upper_threshold), TYPE_FLOAT, op, 1); if(r) break;
 
-                sprintf(token, "power:channel%d.threshold.power.up.act",channelID);
+                sprintf(token, "power3:channel%d.threshold.power.up.act",channelID);
                 r = ini_rw(dic, token, &pover->product_pwr_over_upper_threshold_ctrl, sizeof(pover->product_pwr_over_upper_threshold_ctrl), TYPE_INT, op, 1); if(r) break;
 
-                sprintf(token, "power:channel%d.threshold.power.up.para",channelID);
+                sprintf(token, "power3:channel%d.threshold.power.up.para",channelID);
                 r = ini_rw(dic, token, &pover->product_pwr_over_upper_threshold_ctrl_para, sizeof(pover->product_pwr_over_upper_threshold_ctrl_para), TYPE_INT, op, 1); if(r) break;
 
                 ///////////power consumption//////////
-                sprintf(token, "power:channel%d.threshold.powerc.up.en",channelID);
+                sprintf(token, "power3:channel%d.threshold.powerc.up.en",channelID);
                 r = ini_rw(dic, token, &pover->product_pwrcon_upper_enable, sizeof(pover->product_pwrcon_upper_enable), TYPE_INT, op, 1); if(r) break;
 
-                sprintf(token, "power:channel%d.threshold.powerc.up.val",channelID);
+                sprintf(token, "power3:channel%d.threshold.powerc.up.val",channelID);
                 r = ini_rw(dic, token, &pover->product_pwrcon_upper_threshold, sizeof(pover->product_pwrcon_upper_threshold), TYPE_FLOAT, op, 1); if(r) break;
 
-                sprintf(token, "power:channel%d.threshold.powerc.up.act",channelID);
+                sprintf(token, "power3:channel%d.threshold.powerc.up.act",channelID);
                 r = ini_rw(dic, token, &pover->product_pwrcon_over_upper_threshold_ctrl, sizeof(pover->product_pwrcon_over_upper_threshold_ctrl), TYPE_INT, op, 1); if(r) break;
 
-                sprintf(token, "power:channel%d.threshold.powerc.up.para",channelID);
+                sprintf(token, "power3:channel%d.threshold.powerc.up.para",channelID);
                 r = ini_rw(dic, token, &pover->product_pwrcon_over_upper_threshold_ctrl_para, sizeof(pover->product_pwrcon_over_upper_threshold_ctrl_para), TYPE_INT, op, 1); if(r) break;
                 cnt++;
             }
@@ -3509,25 +3507,17 @@ int paras_alarm_xport(char *path, int io)
     int r=-1,pwr3;
     char temp[100];
 
-    pwr3 = is_power3();
+    //pwr3 = is_power3();
     if(io==PARAS_IMPORT) {
-        if(pwr3) {
-            r = proc_power3(path, PARAS_READ, NULL);
-        }
-        else {
-            r = proc_power(path, PARAS_READ, NULL);
-        }
+        r = proc_power(path, PARAS_READ, NULL);
+        r = proc_power3(path, PARAS_READ, NULL);
     }
     else if(io==PARAS_EXPORT) {
         get_curtime_str(temp,sizeof(temp));
         sprintf(path, "/tmp/power_%s.ini", temp);
 
-        if(pwr3) {
-            r = proc_power3(path, PARAS_WRITE, NULL);
-        }
-        else {
-            r = proc_power(path, PARAS_WRITE, NULL);
-        }
+        r = proc_power(path, PARAS_WRITE, NULL);
+        r = proc_power3(path, PARAS_WRITE, NULL);
     }
 
     return r;

+ 1 - 4
pro/src/sqlite_handle.c

@@ -1989,7 +1989,7 @@ int dev_update_t_ac_power_manage_over_info(sqlite3 *db,GlobalTreeACManager* _glo
               _globalPowerChnManger->global_over_manager.product_pwrcon_over_upper_threshold_ctrl_para,
               _globalPowerChnManger->product_ph_outputType,
               _globalPowerChnManger->product_ph_outputStatus);
-    printf("select_sql:%s\n", select_sql);
+    //printf("select_sql:%s\n", select_sql);
     res = sqlite_SQL_RUN(db, select_sql, &pResult, &nrow, &ncolumn, &err_msg);
     if (res != SQLITE_OK)
     {
@@ -5378,7 +5378,6 @@ int dev_alarm_xport(int io_type, char *path)
     GlobalDeviceManager *dm=&__globalDeviceManage;
 
     l = xlist_init(&lc);
-    
     //
 
     for(i=0; i<xlist_size(l); i++) {
@@ -5389,8 +5388,6 @@ int dev_alarm_xport(int io_type, char *path)
 
     }
 
-
-
     sprintf(path, "/tmp/alarm.ini");
     return 0;
 }