瀏覽代碼

1、添加直流和单相耗电量重置

liyuezong 2 年之前
父節點
當前提交
88766f626a
共有 3 個文件被更改,包括 48 次插入 和 16 次删除
  1. 19 12
      pro/src/appweb_handle.c
  2. 22 3
      pro/src/switch_ctrl.c
  3. 7 1
      pro/src/switch_ctrl.h

+ 19 - 12
pro/src/appweb_handle.c

@@ -1810,34 +1810,41 @@ static void channelStatusMonitoring(void* conn)
                     continue;
                 }
 
-                if(__globalDeviceManage._globalDevInfo.product.pwr_type == SmartPDU_DC) {
-                    //;
+                if (__globalDeviceManage._globalDevInfo.product.pwr_type == SmartPDU_DC)
+                {
+                    if(g_switch_set_dcpdu_chn_reset(&__globalDeviceManage._globalRelaySampManger, _globalPowerMangerTemp->product_saddr, _globalPowerMangerTemp->product_ch_addr-1)<0)
+                    {
+                        log_e("Error: g_switch_set_dcpdu_chn_reset");
+                    }
                 }
-                else {
-                    if(__globalDeviceManage._globalDevInfo.product.pwr_type == SmartPDU_AC) {
-                        if (g_switch_set_t_ac_chn_reset(&__globalDeviceManage._globalRelaySampManger, _globalPowerMangerTemp->product_saddr, _globalPowerMangerTemp->product_ch_addr-1)<0)
+                else
+                {
+                    if (__globalDeviceManage._globalDevInfo.product.pwr_type == SmartPDU_AC)
+                    {
+                        if (g_switch_set_t_ac_chn_reset(&__globalDeviceManage._globalRelaySampManger, _globalPowerMangerTemp->product_saddr, _globalPowerMangerTemp->product_ch_addr - 1) < 0)
                         {
                             log_e("Error: g_switch_set_t_ac_chn_reset");
                         }
-                        usleep(100000);
                     }
-                    else {
+                    else
+                    {
                         GlobalTreeACManager *_globalTACManager = NULL;
                         list_for_each_entry(_globalTACManager, &_globalPowerMangerTemp->list_Tree_AC, list_Tree_AC)
                         {
-                            if(__globalDeviceManage._globalDevInfo.product.pwr_type == SmartPDU_Tree_AC_Tree) {
-                                if (g_switch_set_t_ac_phchn_reset(&__globalDeviceManage._globalRelaySampManger, _globalTACManager->product_saddr, _globalTACManager->product_ch_addr-1) < 0)
+                            if (__globalDeviceManage._globalDevInfo.product.pwr_type == SmartPDU_Tree_AC_Tree)
+                            {
+                                if (g_switch_set_t_ac_phchn_reset(&__globalDeviceManage._globalRelaySampManger, _globalTACManager->product_saddr, _globalTACManager->product_ch_addr - 1) < 0)
                                 {
                                     log_e("Error: g_switch_set_t_ac_phchn_reset");
                                 }
                             }
-                            else {
-                                if (g_switch_set_t_ac_chn_reset(&__globalDeviceManage._globalRelaySampManger, _globalTACManager->product_saddr, _globalTACManager->product_ch_addr-1)<0)
+                            else
+                            {
+                                if (g_switch_set_t_ac_chn_reset(&__globalDeviceManage._globalRelaySampManger, _globalTACManager->product_saddr, _globalTACManager->product_ch_addr - 1) < 0)
                                 {
                                     log_e("Error: g_switch_set_t_ac_chn_reset");
                                 }
                             }
-                            usleep(100000);//延时50ms,等待控制板串口写完
                         }
                     }
                 }

+ 22 - 3
pro/src/switch_ctrl.c

@@ -1638,13 +1638,32 @@ int g_switch_set_dcpdu_max_pwrcon_threshold(void* manger,int saddr,char chn,Glob
     return g_modbus_write_x_reg(manger,saddr,offset,2, data_temp);
 }
 
-
-
 int g_switch_set_dcpdu_reset(void* manger,int saddr)
 {
     return 0;
 }
 
+int g_switch_set_dcpdu_chn_reset(void* manger,int saddr,int nChn)
+{
+    if (saddr <= 0 || saddr >= MAX_CHN_COUNT)
+    {
+        return -1;
+    }
+    unsigned int offset = 0;
+    unsigned short data_temp[2];
+    int ret = 0;
+    
+    offset = _SWITCH_DCPDU_RESET_CONSUMPTION+nChn;
+    data_temp[0] = 1;
+    data_temp[1] = 1;
+    ret = g_modbus_write_x_reg(manger, saddr, offset, 2, data_temp);
+    if (ret < 0)
+    {
+        return ret;
+    }
+    return 0;
+}
+
 int g_switch_get_t_ac_out_info(void* manger,int saddr,unsigned char chn,PowerInfo* _power,PowerWarningInfo* _warning)
 {
     unsigned int offset = 0;
@@ -2146,7 +2165,7 @@ int g_switch_set_t_ac_chn_reset(void *manger, int saddr, int nChn)
     unsigned short data_temp[2];
     int ret = 0;
     
-    offset = _SWITCH_T_AC_RESET_CONSUMPTION_+nChn;
+    offset = _SWITCH_AC_RESET_CONSUMPTION+nChn;
     data_temp[0] = 1;
     data_temp[1] = 1;
     ret = g_modbus_write_x_reg(manger, saddr, offset, 2, data_temp);

+ 7 - 1
pro/src/switch_ctrl.h

@@ -49,6 +49,9 @@ enum MODBUS_MODE
 
 #define _SWITCH_AC_SINGLE_S_KB_VAL  0x1203  //设置单相小电流通道K、B值
 #define _SWITCH_AC_SINGLE_B_KB_VAL  0x124D  //设置单相大电流通道K、B值
+
+#define _SWITCH_AC_RESET_CONSUMPTION    0x1400          //重置单相耗电量
+
 #define _SWITCH_DC_KB_VAL  0x136D  //设置直流通道K、B值
 #define _SWITCH_AC_ALARM_CTRL            0x13EC          //超限动作
 
@@ -69,6 +72,7 @@ enum MODBUS_MODE
 #define _SWITCH_DCPDU_ALL_OPEN_INFO         0x1806          //ALL OPEN直流PDU开关状
 #define _SWITCH_DCPDU_ALL_CLOSE_INFO        0x1807          //ALL OPEN直流PDU开关状
 #define _SWITCH_DCPDU_ALARM_CTRL            0x182E          //超限动作
+#define _SWITCH_DCPDU_RESET_CONSUMPTION   	0x1838         //重置直流耗电量
 
 #define _SWITCH_T_AC_TYPE_CHN_INFO         0x1770          //获取三项类型通道
 #define _SWITCH_T_AC_IN_INFO               0x1771          //三项交流输入
@@ -94,7 +98,7 @@ enum MODBUS_MODE
 #define _SWITCH_T_AC_ALARM_MISSING_PH      0x1856          //缺相报警
 #define _SWITCH_T_AC_ALARM_CTRL            0x1860          //超限动作
 
-#define _SWITCH_T_AC_RESET_CONSUMPTION_    0x1408          //重置PH耗电量
+
 #define _SWITCH_T_AC_RESET_CONSUMPTION_PH  0x189C          //重置PH耗电量
 #define _SWITCH_T_AC_RESET_CONSUMPTION     0x18A5          //重置all耗电量
 
@@ -150,6 +154,8 @@ int g_switch_set_dcpdu_max_power_threshold(void* manger,int saddr,char chn,Globa
 int g_switch_set_dcpdu_max_pwrcon_threshold(void* manger,int saddr,char chn,GlobalOverManager* _global_over_manager);
 int g_switch_set_dcpdu_alarm_ctrl(void* manger,int saddr,char chn,GlobalOverManager* _global_over_manager);
 int g_switch_set_dcpdu_reset(void* manger,int saddr);
+int g_switch_set_dcpdu_chn_reset(void* manger,int saddr,int nChn);
+
 //----------------------------------------------------------------
 int g_switch_get_t_ac_in_info(void* manger,int saddr,PowerInfo* _power,PowerWarningInfo* _warning);
 int g_switch_get_t_ac_out_info(void* manger,int saddr,unsigned char chn,PowerInfo* _power,PowerWarningInfo* _warning);