Ver código fonte

1、合并三相进两相出双火线版本代码

liyuezong 1 ano atrás
pai
commit
a4d995f853

+ 11 - 4
pro/src/app.c

@@ -127,7 +127,7 @@ static void* power_thread(void* arg)
                                                 _globalDeviceManager->pCtrlBoard[i]._PowerWarninginfo);
             }
             // 输入总信息(三相)(后续应同步所有类型)
-            if (_globalDeviceManager->pCtrlBoard[i].product_saddr != 0 && _globalDeviceManager->pCtrlBoard[i].product_type == TREE_AC_TYPE)
+            if (_globalDeviceManager->pCtrlBoard[i].product_saddr != 0 && (_globalDeviceManager->pCtrlBoard[i].product_type == TREE_AC_TYPE||_globalDeviceManager->pCtrlBoard[i].product_type ==DOUBLE_AC_TYPE))
             {
                 usleep(usleepTime);
                 ret = g_switch_get_t_ac_in_info(&_globalDeviceManager->_globalRelaySampManger,
@@ -566,6 +566,7 @@ static void* power_thread(void* arg)
                 }
                 break;           
                 case TREE_AC_TYPE:
+                case DOUBLE_AC_TYPE:
                 {     
                     GlobalTreeACManager* _pTreeACPowerPhData = NULL ;  
                     
@@ -574,7 +575,7 @@ static void* power_thread(void* arg)
                     float nchYGpower = 0;
                     list_for_each_entry(_pTreeACPowerMangerTemp, &_globalPowerMangerTemp->list_Tree_AC, list_Tree_AC)
                     {
-                        if (__globalDeviceManage._globalDevInfo.product.pwr_type==SmartPDU_Tree_AC_One&&_pTreeACPowerMangerTemp->product_ph_outputStatus==2)
+                        if ((__globalDeviceManage._globalDevInfo.product.pwr_type==SmartPDU_Tree_AC_One||__globalDeviceManage._globalDevInfo.product.pwr_type==SmartPDU_Tree_AC_Two)&&_pTreeACPowerMangerTemp->product_ph_outputStatus==2)
                         {
                             continue;
                         }                        
@@ -1031,7 +1032,7 @@ static void* power_thread(void* arg)
         }
         //输入数据再处理(三项)
         //memset(_pTreeACPowerMangerTemp,0,sizeof(GlobalTreeACManager));
-        if (__globalDeviceManage._globalDevInfo.product.pwr_type == SmartPDU_Tree_AC_Tree || __globalDeviceManage._globalDevInfo.product.pwr_type == SmartPDU_Tree_AC_One)
+        if (__globalDeviceManage._globalDevInfo.product.pwr_type == SmartPDU_Tree_AC_Tree || __globalDeviceManage._globalDevInfo.product.pwr_type == SmartPDU_Tree_AC_One|| __globalDeviceManage._globalDevInfo.product.pwr_type == SmartPDU_Tree_AC_Two)
         {
             _pTreeACPowerMangerTemp = NULL;
             list_for_each_entry(_pTreeACPowerMangerTemp, &_globalDeviceManager->_globalPowerManger.list_Tree_AC, list_Tree_AC)
@@ -1047,7 +1048,7 @@ static void* power_thread(void* arg)
                 float nTotalYGPower=0;//相总的有功功率
                 for (size_t i = 0; i <= _globalDeviceManager->brdMax; i++)
                 {
-                    if (_globalDeviceManager->pCtrlBoard[i].product_saddr == 0 || _globalDeviceManager->pCtrlBoard[i].product_type != TREE_AC_TYPE)
+                    if (_globalDeviceManager->pCtrlBoard[i].product_saddr == 0 || _globalDeviceManager->pCtrlBoard[i].product_type != TREE_AC_TYPE||_globalDeviceManager->pCtrlBoard[i].product_type != DOUBLE_AC_TYPE)
                     {
                         continue;
                     }
@@ -2278,6 +2279,7 @@ static void* shm_thread(void *arg)
                         int nselectPH = _globalDeviceManager->g_shm_Data->nSelectPh;
                         if ((__globalDeviceManage._globalDevInfo.product.pwr_type == SmartPDU_Tree_AC_Tree ||
                              __globalDeviceManage._globalDevInfo.product.pwr_type == SmartPDU_Tree_AC_One ||
+                             __globalDeviceManage._globalDevInfo.product.pwr_type == SmartPDU_Tree_AC_Two ||
                              __globalDeviceManage._globalDevInfo.product.pwr_type == SmartPDU_Tree_AC_One_B) &&
                             _globalDeviceManager->g_shm_Data->bT_ACType == 1 && nselectPH > 0)
                         {//三项输入数据
@@ -2325,6 +2327,7 @@ static void* shm_thread(void *arg)
                         }
                         if ((__globalDeviceManage._globalDevInfo.product.pwr_type == SmartPDU_Tree_AC_Tree||
                         __globalDeviceManage._globalDevInfo.product.pwr_type == SmartPDU_Tree_AC_One ||
+                        __globalDeviceManage._globalDevInfo.product.pwr_type == SmartPDU_Tree_AC_Two ||
                         __globalDeviceManage._globalDevInfo.product.pwr_type == SmartPDU_Tree_AC_One_B) && 
                         _globalDeviceManager->g_shm_Data->bT_ACType == 1&&nselectPH>0)
                         {
@@ -2374,6 +2377,7 @@ static void* shm_thread(void *arg)
                     _globalDeviceManager->g_shm_Data->nMaxCh = nMaxCh;
                     if ((__globalDeviceManage._globalDevInfo.product.pwr_type == SmartPDU_Tree_AC_Tree||
                         __globalDeviceManage._globalDevInfo.product.pwr_type == SmartPDU_Tree_AC_One ||
+                        __globalDeviceManage._globalDevInfo.product.pwr_type == SmartPDU_Tree_AC_Two ||
                         __globalDeviceManage._globalDevInfo.product.pwr_type == SmartPDU_Tree_AC_One_B))
                     {
                         _globalDeviceManager->g_shm_Data->bT_ACType = 1;
@@ -3074,6 +3078,7 @@ int app_init(void)
     
     if (_globalDeviceManager->_globalDevInfo.product.pwr_type==SmartPDU_Tree_AC_Tree
     ||_globalDeviceManager->_globalDevInfo.product.pwr_type==SmartPDU_Tree_AC_One
+    ||_globalDeviceManager->_globalDevInfo.product.pwr_type== SmartPDU_Tree_AC_Two 
     ||_globalDeviceManager->_globalDevInfo.product.pwr_type==SmartPDU_Tree_AC_One_B
     )
     {
@@ -3186,6 +3191,8 @@ int app_init(void)
     char strLog[200]={"MODBUS"};
     dev_Alarm_Run_message(_globalDeviceManager,language_alarm_Init_Success[0],strLog);
     log_d("GCPDU init begin!");
+
+    paras_PhListInit();
     ResetChmData(0);
 
     ///todo:此信息需要和数据库更新以后在关联

+ 50 - 8
pro/src/appweb_handle.c

@@ -744,6 +744,7 @@ static void overallStatusMonitoring(void* conn)
             //查询数据库总电源信息
             if (__globalDeviceManage._globalDevInfo.product.pwr_type == SmartPDU_Tree_AC_Tree 
             ||__globalDeviceManage._globalDevInfo.product.pwr_type == SmartPDU_Tree_AC_One
+            ||__globalDeviceManage._globalDevInfo.product.pwr_type == SmartPDU_Tree_AC_Two
             ||__globalDeviceManage._globalDevInfo.product.pwr_type == SmartPDU_Tree_AC_One_B
             )
             {
@@ -902,6 +903,7 @@ static void overallStatusMonitoring(void* conn)
         memset(&__globalPowerInfo,0,sizeof(GlobalPowerInfo));
         if (_over_all_sts_monitor.product_pwr_type==SmartPDU_Tree_AC_Tree
         ||_over_all_sts_monitor.product_pwr_type==SmartPDU_Tree_AC_One
+        ||_over_all_sts_monitor.product_pwr_type==SmartPDU_Tree_AC_Two
         ||_over_all_sts_monitor.product_pwr_type==SmartPDU_Tree_AC_One_B)
         {
              ack_str = over_all_data_t_ac_to_json(pall,&_over_all_sts_monitor, TOTAL_VOLTAGE_TYPE);
@@ -973,6 +975,7 @@ static void overallStatusMonitoring(void* conn)
         memset(&__globalPowerInfo,0,sizeof(GlobalPowerInfo));
         if (_over_all_sts_monitor.product_pwr_type==SmartPDU_Tree_AC_Tree
         ||_over_all_sts_monitor.product_pwr_type==SmartPDU_Tree_AC_One
+        ||_over_all_sts_monitor.product_pwr_type==SmartPDU_Tree_AC_Two
         ||_over_all_sts_monitor.product_pwr_type==SmartPDU_Tree_AC_One_B)
         {
             ack_str = over_all_data_t_ac_to_json(pall, &_over_all_sts_monitor, TOTAL_CURRENT_TYPE);
@@ -1038,6 +1041,7 @@ static void overallStatusMonitoring(void* conn)
         memset(&__globalPowerInfo,0,sizeof(GlobalPowerInfo));
         if (_over_all_sts_monitor.product_pwr_type==SmartPDU_Tree_AC_Tree
         ||_over_all_sts_monitor.product_pwr_type==SmartPDU_Tree_AC_One
+        ||_over_all_sts_monitor.product_pwr_type==SmartPDU_Tree_AC_Two
         ||_over_all_sts_monitor.product_pwr_type==SmartPDU_Tree_AC_One_B)
         {
             ack_str = over_all_data_t_ac_to_json(pall, &_over_all_sts_monitor, TOTAL_POWER_TYPE);
@@ -1103,6 +1107,7 @@ static void overallStatusMonitoring(void* conn)
         memset(&__globalPowerInfo,0,sizeof(GlobalPowerInfo));
         if (_over_all_sts_monitor.product_pwr_type==SmartPDU_Tree_AC_Tree
         ||_over_all_sts_monitor.product_pwr_type==SmartPDU_Tree_AC_One
+        ||_over_all_sts_monitor.product_pwr_type==SmartPDU_Tree_AC_Two
         ||_over_all_sts_monitor.product_pwr_type==SmartPDU_Tree_AC_One_B)
         {
             ack_str = over_all_data_t_ac_to_json(pall, &_over_all_sts_monitor, TOTAL_POWER_CONS_TYPE);
@@ -1125,7 +1130,10 @@ static void overallStatusMonitoring(void* conn)
             ack_str = over_all_total_info_to_json(pall, TOTAL_POWER_CONS_TYPE);
         }
         else if (_over_all_sts_monitor.lType && (strcmp(_over_all_sts_monitor.lType,"L1")==0 || strcmp(_over_all_sts_monitor.lType,"L2")==0 || strcmp(_over_all_sts_monitor.lType,"L3")==0)
-        &&(__globalDeviceManage._globalDevInfo.product.pwr_type == SmartPDU_Tree_AC_Tree||__globalDeviceManage._globalDevInfo.product.pwr_type == SmartPDU_Tree_AC_One||__globalDeviceManage._globalDevInfo.product.pwr_type == SmartPDU_Tree_AC_One_B) )
+        &&(__globalDeviceManage._globalDevInfo.product.pwr_type == SmartPDU_Tree_AC_Tree
+        ||__globalDeviceManage._globalDevInfo.product.pwr_type == SmartPDU_Tree_AC_One
+        ||__globalDeviceManage._globalDevInfo.product.pwr_type == SmartPDU_Tree_AC_Two
+        ||__globalDeviceManage._globalDevInfo.product.pwr_type == SmartPDU_Tree_AC_One_B) )
         {
             int ph_id=-1;
             if (strcmp(_over_all_sts_monitor.lType,"L1")==0)
@@ -1234,7 +1242,10 @@ static void overallStatusMonitoring(void* conn)
         memset(&__PowerTrendInfo,0,sizeof(GlobalPowerInfo));
         #if 1
          if (_over_all_sts_monitor.lType && (strcmp(_over_all_sts_monitor.lType,"L1")==0 || strcmp(_over_all_sts_monitor.lType,"L2")==0 || strcmp(_over_all_sts_monitor.lType,"L3")==0)
-           &&(__globalDeviceManage._globalDevInfo.product.pwr_type == SmartPDU_Tree_AC_Tree||__globalDeviceManage._globalDevInfo.product.pwr_type == SmartPDU_Tree_AC_One||__globalDeviceManage._globalDevInfo.product.pwr_type == SmartPDU_Tree_AC_One_B) )
+           &&(__globalDeviceManage._globalDevInfo.product.pwr_type == SmartPDU_Tree_AC_Tree
+           ||__globalDeviceManage._globalDevInfo.product.pwr_type == SmartPDU_Tree_AC_One
+           ||__globalDeviceManage._globalDevInfo.product.pwr_type == SmartPDU_Tree_AC_Two
+           ||__globalDeviceManage._globalDevInfo.product.pwr_type == SmartPDU_Tree_AC_One_B) )
         {
             int ph_id=-1;
             if (strcmp(_over_all_sts_monitor.lType,"L1")==0)
@@ -1346,7 +1357,7 @@ static void channelStatusMonitoring(void* conn)
                     break;
                 if (product_chn_id == _globalPowerMangerTemp->product_ch_id)
                 {
-                    log_d("switch ctrl:%d", _globalPowerMangerTemp->product_ch_id);
+                    log_d("switch ctrl:%d,addr:%d,chaddr:%d,Open", _globalPowerMangerTemp->product_ch_id,_globalPowerMangerTemp->product_saddr,_globalPowerMangerTemp->product_ch_addr);
                     ret = g_switch_set_t_ac_chn_NF_ctrl(&__globalDeviceManage._globalRelaySampManger,
                                                     _globalPowerMangerTemp->product_saddr,
                                                     _globalPowerMangerTemp->product_ch_addr,
@@ -1391,7 +1402,7 @@ static void channelStatusMonitoring(void* conn)
                     break;
                 if (product_chn_id == _globalPowerMangerTemp->product_ch_id)
                 {
-                    log_d("switch ctrl:%d", _globalPowerMangerTemp->product_ch_id);
+                    log_d("switch ctrl:%d,addr:%d,chaddr:%d,Close", _globalPowerMangerTemp->product_ch_id,_globalPowerMangerTemp->product_saddr,_globalPowerMangerTemp->product_ch_addr);
                     ret = g_switch_set_t_ac_chn_NF_ctrl(&__globalDeviceManage._globalRelaySampManger,
                                                     _globalPowerMangerTemp->product_saddr,
                                                     _globalPowerMangerTemp->product_ch_addr,
@@ -1549,7 +1560,7 @@ static void channelStatusMonitoring(void* conn)
                 break;
             if(product_chn_id==_globalPowerMangerTemp->product_ch_id)
             {
-                log_d("switch ctrl:%d",_globalPowerMangerTemp->product_ch_id);
+                log_d("switch ctrl:%d,addr:%d,chaddr:%d,Open", _globalPowerMangerTemp->product_ch_id,_globalPowerMangerTemp->product_saddr,_globalPowerMangerTemp->product_ch_addr);
                 ret=g_switch_set_all_chn_ctrl(&__globalDeviceManage._globalRelaySampManger,_globalPowerMangerTemp,
                 _globalPowerMangerTemp->product_saddr,
                 _globalPowerMangerTemp->product_ch_addr, 
@@ -1600,6 +1611,7 @@ static void channelStatusMonitoring(void* conn)
             if(product_chn_id==_globalPowerMangerTemp->product_ch_id)
             {
                 //log_d("switch ctrl:%d",_globalPowerMangerTemp->product_ch_id);
+                log_d("switch ctrl:%d,addr:%d,chaddr:%d,Close", _globalPowerMangerTemp->product_ch_id,_globalPowerMangerTemp->product_saddr,_globalPowerMangerTemp->product_ch_addr);
                 ret=g_switch_set_all_chn_ctrl(&__globalDeviceManage._globalRelaySampManger,_globalPowerMangerTemp,
                 _globalPowerMangerTemp->product_saddr,
                 _globalPowerMangerTemp->product_ch_addr ,//多版端口余8 
@@ -2018,8 +2030,11 @@ static void channelStatusMonitoring(void* conn)
             }
         }
         if (__globalDeviceManage._globalDevInfo.product.pwr_type == SmartPDU_Tree_AC_One
-            ||__globalDeviceManage._globalDevInfo.product.pwr_type == SmartPDU_Tree_AC_One_B)
+            ||__globalDeviceManage._globalDevInfo.product.pwr_type == SmartPDU_Tree_AC_One_B
+            ||__globalDeviceManage._globalDevInfo.product.pwr_type == SmartPDU_Tree_AC_Two
+            )
         {
+            //1三项2单项3二相
             if (_over_chn_pwr_request.outputType == 1)
             {
                 http_reply(conn, 201, ack_str);
@@ -2043,6 +2058,33 @@ static void channelStatusMonitoring(void* conn)
                         _globalTACManager->product_ph_outputStatus = 2;
                     }
                 }
+                else if (_over_chn_pwr_request.outputType == 3)//两项控制
+                {
+                    //获取板子数据中的左右三项状态
+                    if (_globalTACManager->product_saddr<__globalDeviceManage.brdMax&&_globalTACManager->product_saddr>0)
+                    {                        
+                        if (_globalTACManager->product_ph_type == __globalDeviceManage.pCtrlBoard[_globalTACManager->product_saddr].nLeft_phType 
+                        || _globalTACManager->product_ph_type == __globalDeviceManage.pCtrlBoard[_globalTACManager->product_saddr].nRight_phType)
+                        {
+                            _globalTACManager->product_ph_outputStatus = 1;
+                        }
+                        else
+                        {
+                            _globalTACManager->product_ph_outputStatus = 2;
+                        }
+                    }
+                    else
+                    {
+                        if (_globalTACManager->product_ph_type == 1 || _globalTACManager->product_ph_type == 0)
+                        {
+                            _globalTACManager->product_ph_outputStatus = 1;
+                        }
+                        else
+                        {
+                            _globalTACManager->product_ph_outputStatus = 2;
+                        }
+                    }
+                }
                 else
                 {
                     _globalTACManager->product_ph_outputStatus = 1;
@@ -2997,7 +3039,7 @@ char* setThresholdToCh(_AlarmRequestInfo* _alarm_request_info,int nChID)
     else
         _globalPowerMangerSaveTemp->global_over_manager.product_pwrcon_over_upper_threshold_ctrl = ALARM_CTRL_ALARM_ONLY;
 
-    if (__globalDeviceManage._globalDevInfo.product.pwr_type == SmartPDU_Tree_AC_Tree || __globalDeviceManage._globalDevInfo.product.pwr_type == SmartPDU_Tree_AC_One)
+    if (__globalDeviceManage._globalDevInfo.product.pwr_type == SmartPDU_Tree_AC_Tree || __globalDeviceManage._globalDevInfo.product.pwr_type == SmartPDU_Tree_AC_One|| __globalDeviceManage._globalDevInfo.product.pwr_type == SmartPDU_Tree_AC_Two)
     {
 
         GlobalTreeACManager *_pTreeACPowerMangerTemp = NULL;
@@ -3025,7 +3067,7 @@ char* setThresholdToCh(_AlarmRequestInfo* _alarm_request_info,int nChID)
         log_e("power threshold update error.ret:%d,%s", ret, modbus_strerror(errno));
         /* code */
     }
-    if (__globalDeviceManage._globalDevInfo.product.pwr_type == SmartPDU_Tree_AC_Tree || __globalDeviceManage._globalDevInfo.product.pwr_type == SmartPDU_Tree_AC_One)
+    if (__globalDeviceManage._globalDevInfo.product.pwr_type == SmartPDU_Tree_AC_Tree || __globalDeviceManage._globalDevInfo.product.pwr_type == SmartPDU_Tree_AC_One|| __globalDeviceManage._globalDevInfo.product.pwr_type == SmartPDU_Tree_AC_Two)
     {
         // 写入数据库
         ret = dev_update_power_manage_over_info(__globalDeviceManage.db,

+ 8 - 7
pro/src/cascade.c

@@ -165,7 +165,7 @@ static int slave_get_info(cascade_handle_t *cas)
             info->ch[cnt].stop_delay  = tmp->product_ch_stop_delay;
 
             info->ch[cnt].chinfo = tmp->_PowerInfo;
-            if (tmp->product_ch_type==TREE_AC_TYPE||dm->_globalDevInfo.product.pwr_type == SmartPDU_Tree_AC_One_B) {
+            if (tmp->product_ch_type==TREE_AC_TYPE||tmp->product_ch_type==DOUBLE_AC_TYPE||dm->_globalDevInfo.product.pwr_type == SmartPDU_Tree_AC_One_B) {
                 cnt2 = 0;
                 list_for_each_entry(tmp3, &tmp->list_Tree_AC, list_Tree_AC)
                 {
@@ -1037,7 +1037,7 @@ static int power_clear(cascade_handle_t *cas)
                 continue;
             }
 
-            if (tmp->product_ch_type==TREE_AC_TYPE||__globalDeviceManage._globalDevInfo.product.pwr_type == SmartPDU_Tree_AC_One_B) {
+            if (tmp->product_ch_type==TREE_AC_TYPE||tmp->product_ch_type==DOUBLE_AC_TYPE||__globalDeviceManage._globalDevInfo.product.pwr_type == SmartPDU_Tree_AC_One_B) {
                 if(list_empty(&tmp->list_Tree_AC)) {
                     continue;
                 }
@@ -1104,6 +1104,7 @@ static int power_add(cascade_handle_t *cas)
     //插入总数据
     if(info->prod.product_pwr_type==SmartPDU_Tree_AC_Tree ||
        info->prod.product_pwr_type==SmartPDU_Tree_AC_One ||
+       info->prod.product_pwr_type==SmartPDU_Tree_AC_Two ||
        info->prod.product_pwr_type==SmartPDU_Tree_AC_One_B) {
         for (int TreeACindex = 0; TreeACindex < 3; TreeACindex++)
         {
@@ -1147,7 +1148,7 @@ static int power_add(cascade_handle_t *cas)
         tmp->product_ch_stop_delay = info->ch[i].stop_delay;
 
         tmp->_PowerInfo = info->ch[i].chinfo;
-        if(info->ch[i].product_ch_type==TREE_AC_TYPE||info->prod.product_pwr_type==SmartPDU_Tree_AC_One_B) {
+        if(info->ch[i].product_ch_type==TREE_AC_TYPE||info->ch[i].product_ch_type==DOUBLE_AC_TYPE||info->prod.product_pwr_type==SmartPDU_Tree_AC_One_B) {
             INIT_LIST_HEAD(&tmp->list_Tree_AC);
             for (j=0; j<3; j++) {
                 tmp3 = (GlobalTreeACManager *)malloc(sizeof(GlobalTreeACManager));
@@ -1282,7 +1283,7 @@ static int power_update(cascade_handle_t *cas)
         list_for_each_entry(tmp, &dm2->_globalPowerManger.list, list)
         {
             tmp->_PowerInfo = info->ch[cnt].chinfo;
-            if(tmp->product_ch_type==TREE_AC_TYPE||info->prod.product_pwr_type==SmartPDU_Tree_AC_One_B) {
+            if(tmp->product_ch_type==TREE_AC_TYPE||tmp->product_ch_type==DOUBLE_AC_TYPE||info->prod.product_pwr_type==SmartPDU_Tree_AC_One_B) {
                 if(list_empty(&tmp->list_Tree_AC)) {
                     continue;
                 }
@@ -2053,10 +2054,10 @@ int cascade_get_ch(_OverChnPwrAckInfo *ch)
     GlobalDeviceManager* dm2=get_dm2();
     list_for_each_entry(tmp, &dm2->_globalPowerManger.list, list)
     {
-        if (tmp->product_ch_type==TREE_AC_TYPE||dm2->_globalDevInfo.product.pwr_type == SmartPDU_Tree_AC_One_B){
+        if (tmp->product_ch_type==TREE_AC_TYPE||tmp->product_ch_type==DOUBLE_AC_TYPE||dm2->_globalDevInfo.product.pwr_type == SmartPDU_Tree_AC_One_B){
             int nStatus=-1;//-1则状态不变,0、1则是子状态
             //判断是否三相单输出情况下
-            if(tmp->product_ch_type==TREE_AC_TYPE||dm2->_globalDevInfo.product.pwr_type == SmartPDU_Tree_AC_One_B) {
+            if(tmp->product_ch_type==TREE_AC_TYPE||tmp->product_ch_type==DOUBLE_AC_TYPE||dm2->_globalDevInfo.product.pwr_type == SmartPDU_Tree_AC_One_B) {
                 list_for_each_entry(tmp3, &tmp->list_Tree_AC, list_Tree_AC) {
                     if (2 == tmp3->product_ph_outputType &&1==tmp3->product_ph_outputStatus)
                     {//单项并且状态为输出
@@ -2094,7 +2095,7 @@ int cascade_get_ch(_OverChnPwrAckInfo *ch)
                 pch->ph_consumption = tmp3->_PowerInfo.consumption;
                 pch->ph_outputType   = tmp3->product_ph_outputType;
                 pch->ph_outputStatus = tmp3->product_ph_outputStatus;
-                if ((dm2->_globalDevInfo.product.pwr_type == SmartPDU_Tree_AC_One||dm2->_globalDevInfo.product.pwr_type == SmartPDU_Tree_AC_One_B) && 
+                if ((dm2->_globalDevInfo.product.pwr_type == SmartPDU_Tree_AC_One||dm2->_globalDevInfo.product.pwr_type == SmartPDU_Tree_AC_Two||dm2->_globalDevInfo.product.pwr_type == SmartPDU_Tree_AC_One_B) && 
                     tmp3->product_ph_outputType == 2 && tmp3->product_ph_outputStatus == 2) // 如果是单项输出并且则非输出通道数据为0
                 { 
                     // 3-1模式 单项状态,不输出则数据为空

+ 4 - 0
pro/src/cascade_slave.c

@@ -509,6 +509,7 @@ void cascade_slave_write(uint32_t addr, uint16_t val)
                                     }
                                     if (t_ac_CtrlType == 2&&(__globalDeviceManage._globalDevInfo.product.pwr_type == SmartPDU_Tree_AC_Tree
                                     ||__globalDeviceManage._globalDevInfo.product.pwr_type == SmartPDU_Tree_AC_One
+                                    ||__globalDeviceManage._globalDevInfo.product.pwr_type == SmartPDU_Tree_AC_Two
                                     ||__globalDeviceManage._globalDevInfo.product.pwr_type == SmartPDU_Tree_AC_One_B))
                                     {
                                         if(_globalPowerMangerTemp->product_ch_type == AC_SINGLE_S_TYPE || _globalPowerMangerTemp->product_ch_type == AC_SINGLE_B_TYPE)
@@ -748,6 +749,7 @@ void cascade_slave_write(uint32_t addr, uint16_t val)
                         _globalPowerMangerTemp->product_ch_start_delay = val;
                         if (__globalDeviceManage._globalDevInfo.product.pwr_type == SmartPDU_Tree_AC_Tree
                         ||__globalDeviceManage._globalDevInfo.product.pwr_type == SmartPDU_Tree_AC_One
+                        ||__globalDeviceManage._globalDevInfo.product.pwr_type == SmartPDU_Tree_AC_Two
                         ||__globalDeviceManage._globalDevInfo.product.pwr_type == SmartPDU_Tree_AC_One_B
                         )
                         {
@@ -788,6 +790,7 @@ void cascade_slave_write(uint32_t addr, uint16_t val)
                         _globalPowerMangerTemp->product_ch_stop_delay = val;
                         if (__globalDeviceManage._globalDevInfo.product.pwr_type == SmartPDU_Tree_AC_Tree
                         ||__globalDeviceManage._globalDevInfo.product.pwr_type == SmartPDU_Tree_AC_One
+                        ||__globalDeviceManage._globalDevInfo.product.pwr_type == SmartPDU_Tree_AC_Two
                         ||__globalDeviceManage._globalDevInfo.product.pwr_type == SmartPDU_Tree_AC_One_B)
                         {
                             ret = g_switch_set_t_ac_stop_time_delay(&__globalDeviceManage._globalRelaySampManger, 
@@ -832,6 +835,7 @@ void cascade_slave_write(uint32_t addr, uint16_t val)
                         }
                         if (t_ac_CtrlType == 2&&(__globalDeviceManage._globalDevInfo.product.pwr_type == SmartPDU_Tree_AC_Tree
                         ||__globalDeviceManage._globalDevInfo.product.pwr_type == SmartPDU_Tree_AC_One
+                        ||__globalDeviceManage._globalDevInfo.product.pwr_type == SmartPDU_Tree_AC_Two
                         ||__globalDeviceManage._globalDevInfo.product.pwr_type == SmartPDU_Tree_AC_One_B))
                         {
                             if(_globalPowerMangerTemp->product_ch_type == AC_SINGLE_S_TYPE || _globalPowerMangerTemp->product_ch_type == AC_SINGLE_B_TYPE)

+ 17 - 1
pro/src/common.h

@@ -24,6 +24,7 @@
 #include "hlw8110_habdle.h"
 #include "language_common.h"
 #include <sys/shm.h>
+#include <sys/wait.h>
 #include "cfg.h"
 #include <iconv.h>
 
@@ -40,6 +41,8 @@
 #define SNMP_MIB_NAME       "pduMIB"
 #define INI_FILE_NAME       "smartPDU.ini"
 #define INI_FILE_BAK_NAME   "smartPDU_bak.ini"
+#define PH_INI_FILE_NAME    "smartPDU_PhList.ini"
+
 #define CHANGES_NAME        "changes.txt"
 
 #define SERV_CFG_NAME       "service.ini"
@@ -195,7 +198,8 @@ enum MODBUS_BOARD_TYPE
     DC_OUT_TYPE,
     DC_IN_TYPE,
     DCPDU_TYPE,
-    TREE_AC_TYPE,   //三相进三项出
+    TREE_AC_TYPE, // 三相进三相出,单板最大3通道9相
+    DOUBLE_AC_TYPE, // 两相进两相出,单板最大4通道8相
 };
 
 enum AppProductType
@@ -205,6 +209,7 @@ enum AppProductType
     SmartPDU_Tree_AC_Tree=3,
     SmartPDU_Tree_AC_One=4,
     SmartPDU_Tree_AC_One_B=5,    
+    SmartPDU_Tree_AC_Two=6,    
 };
 
 /// @brief 三相网页数据
@@ -655,6 +660,15 @@ typedef struct
     bool w_phase_lossC;                                           // 缺相报警
 }PowerWarningInfo;
 
+typedef struct 
+{
+    int nBoardID;
+    int nLeftTac;
+    int nRightTac;
+    /* data */
+}TAC_Double_Item;
+
+
 //三项数据
 typedef struct
 {
@@ -724,6 +738,8 @@ typedef struct
     PowerWarningInfo    _PowerWarninginfo[AC_SINGLE_S_MAX_CHN_NUM] ;//存储报警数据     
     struct list_head    list;  //存储具有的通道指针
     GlobalPowerInManger _globalPowerInManger;                       //总输入数据
+    int nLeft_phType;       //左半边相类型
+    int nRight_phType;      //右半边相类型
 }GlobalPowerCtrlBoard;
 ///////////////////////////////////////////////////////////////////////////////////
 ///////////////////////////////////////////////////////////////////////////////////

+ 2 - 3
pro/src/json_handle.c

@@ -2689,8 +2689,7 @@ char* over_chn_pwr_monitor_to_json(_OverChnPwrAckInfo* _over_chn_pwr_back_info)
         cJSON_AddStringToObject(data_filed,"firingInterval",temp);
         sprintf(temp,"%d",_chnPwrTemp->product_ch_stop_delay/1000);     
         cJSON_AddStringToObject(data_filed,"closeInterval",temp);
-
-        if (_chnPwrTemp->product_type==TREE_AC_TYPE||__globalDeviceManage._globalDevInfo.product.pwr_type == SmartPDU_Tree_AC_One_B)
+        if (_chnPwrTemp->product_type==TREE_AC_TYPE||_chnPwrTemp->product_type==DOUBLE_AC_TYPE||__globalDeviceManage._globalDevInfo.product.pwr_type == SmartPDU_Tree_AC_One_B)
         {
             if (_chnPwrTemp->product_phType>=0&&_chnPwrTemp->product_phType<3)
             {
@@ -4512,7 +4511,7 @@ char* ws_chn_status_ack_to_json(int type,_OverChnPwrAckInfo* _over_chn_pwr_back_
         cJSON_AddStringToObject(data_filed, "IPadress",_chnPwrTemp->ip_addr);
 #endif
         
-        if (_chnPwrTemp->product_type == TREE_AC_TYPE||gdm->_globalDevInfo.product.pwr_type == SmartPDU_Tree_AC_One_B)
+        if (_chnPwrTemp->product_type == TREE_AC_TYPE||_chnPwrTemp->product_type == DOUBLE_AC_TYPE||gdm->_globalDevInfo.product.pwr_type == SmartPDU_Tree_AC_One_B)
         {
             if (_chnPwrTemp->product_phType >= 0 && _chnPwrTemp->product_phType < 3)
             {

+ 1 - 1
pro/src/json_handle.h

@@ -154,7 +154,7 @@ typedef struct
     char* ChannelLoadType;
     int productType;
     char* productPhOrder;
-    int outputType;
+    int outputType;//1三项2单项3二相
     char* Zerotype;
     char* strProductChIds;
 }_OverChnPwrRequest;

+ 65 - 0
pro/src/paras.c

@@ -1337,6 +1337,50 @@ quit:
     iniparser_freedict(dic);
     return r;
 }
+static int proc_phList(dictionary *dic, int op,int nAddrIndex)
+{
+    int r = 0;
+    char temp[100];
+    char token1[50],token2[50];
+    char *p=NULL;
+    
+    memset(token1,0,sizeof(token1));
+    memset(token2,0,sizeof(token2));
+    sprintf(token1, "board_%d:left", nAddrIndex);
+    sprintf(token2, "board_%d:right", nAddrIndex);
+    
+    if (nAddrIndex <= __globalDeviceManage.brdMax && nAddrIndex > 0)
+    {
+        if (op == PARAS_READ)
+        {
+            r = iniparser_getint(dic, token1, -1);
+            if (r == -1)
+            {
+                LOGE("___ iniparser_getint %s failed\n", token1);
+                return -1;
+            }
+            else
+            {
+                __globalDeviceManage.pCtrlBoard[nAddrIndex].nLeft_phType=r-1;
+            }
+
+            r = iniparser_getint(dic, token2, -1);
+            if (r == -1)
+            {
+                LOGE("___ iniparser_getint %s failed\n", token2);
+                return -1;
+            }
+            else
+            {
+                __globalDeviceManage.pCtrlBoard[nAddrIndex].nRight_phType=r-1;
+            }
+        }
+        return 0;
+
+    }
+    return -2;
+}
+
 static int proc_snmp(char *path, int op, SNMPManager *snmp)
 {
     int r=0,len=0;
@@ -3782,7 +3826,28 @@ int paras_init(void)
     
     return r;
 }
+int paras_PhListInit(void)
+{
+    int r=0;    
+    lock_s_hold(LOCK_ID_PARAS);
+    char path[200];
+    sys_get_path(path, PH_INI_FILE_NAME);
+    dictionary *dic=iniparser_load(path);
+    if(dic == NULL){
+        return -1;
+    }
+    for (size_t i = 0; i < __globalDeviceManage.brdMax; i++)
+    {
+        proc_phList(dic, PARAS_READ,i+1);
+    }
+    if(r) {
+        LOGE("___proc_prod failed\n");
+    }
 
+    lock_s_release(LOCK_ID_PARAS);
+    
+    return r;
+}
 
 int paras_deinit(void)
 {

+ 2 - 0
pro/src/paras.h

@@ -24,6 +24,8 @@ enum {
 };
 
 int paras_init(void);
+
+int paras_PhListInit(void);
 int paras_deinit(void);
 
 int paras_check(char *path);

+ 4 - 4
pro/src/sqlite_handle.c

@@ -527,16 +527,16 @@ int dev_search_latest_power_All_info(GlobalDeviceManager* globalDeviceManger,_Ov
             /* code */
         }
 
-        if (_globalPowerMangerTemp->product_ch_type==TREE_AC_TYPE||globalDeviceManger->_globalDevInfo.product.pwr_type == SmartPDU_Tree_AC_One_B)
+        if (_globalPowerMangerTemp->product_ch_type==TREE_AC_TYPE||_globalPowerMangerTemp->product_ch_type==DOUBLE_AC_TYPE||globalDeviceManger->_globalDevInfo.product.pwr_type == SmartPDU_Tree_AC_One_B)
         {
             GlobalTreeACManager* _TreeACTemp=NULL;
             int nStatus=-1;//-1则状态不变,0、1则是子状态
             //判断是否三相单输出情况下
-            if(_globalPowerMangerTemp->product_ch_type==TREE_AC_TYPE||globalDeviceManger->_globalDevInfo.product.pwr_type == SmartPDU_Tree_AC_One_B)
+            if(_globalPowerMangerTemp->product_ch_type==TREE_AC_TYPE||_globalPowerMangerTemp->product_ch_type==DOUBLE_AC_TYPE||globalDeviceManger->_globalDevInfo.product.pwr_type == SmartPDU_Tree_AC_One_B)
             {
                 list_for_each_entry(_TreeACTemp, &_globalPowerMangerTemp->list_Tree_AC, list_Tree_AC)
                 {
-                    if (2 == _TreeACTemp->product_ph_outputType &&1==_TreeACTemp->product_ph_outputStatus)
+                    if ((2 == _TreeACTemp->product_ph_outputType||3 == _TreeACTemp->product_ph_outputType ) &&1==_TreeACTemp->product_ph_outputStatus)
                     {//单项并且状态为输出
                         nStatus=_TreeACTemp->_PowerInfo.status;
                     }
@@ -575,7 +575,7 @@ int dev_search_latest_power_All_info(GlobalDeviceManager* globalDeviceManger,_Ov
                 _overChnPwrBackInfoTemp->ph_consumption = _TreeACTemp->_PowerInfo.consumption;
                 _overChnPwrBackInfoTemp->ph_outputType   = _TreeACTemp->product_ph_outputType;
                 _overChnPwrBackInfoTemp->ph_outputStatus = _TreeACTemp->product_ph_outputStatus;
-                if ((globalDeviceManger->_globalDevInfo.product.pwr_type == SmartPDU_Tree_AC_One ||globalDeviceManger->_globalDevInfo.product.pwr_type == SmartPDU_Tree_AC_One_B) && 
+                if ((globalDeviceManger->_globalDevInfo.product.pwr_type == SmartPDU_Tree_AC_One ||globalDeviceManger->_globalDevInfo.product.pwr_type == SmartPDU_Tree_AC_Two ||globalDeviceManger->_globalDevInfo.product.pwr_type == SmartPDU_Tree_AC_One_B) && 
                     _TreeACTemp->product_ph_outputType == 2 && _TreeACTemp->product_ph_outputStatus == 2) // 如果是单项输出并且则非输出通道数据为0
                 { 
                      // 3-1模式 单项状态,不输出则数据为空

+ 308 - 7
pro/src/switch_ctrl.c

@@ -723,7 +723,24 @@ int g_switch_set_all_start_time_delay(void* manger,int ntype,int saddr,unsigned
                 return ret;
             }
         }
-        else
+        else if (__globalDeviceManage._globalDevInfo.product.pwr_type == SmartPDU_Tree_AC_Two)
+        {
+            ret = g_switch_set_t_ac_start_time_delay(manger, saddr, (chn - 1), time / 1000);
+            if (ret < 0)
+            {
+                ret = g_switch_set_t_ac_start_time_delay(manger, saddr, (chn - 1), time / 1000);
+                if (ret < 0)
+                    return ret;
+            }
+            ret = g_switch_set_t_ac_start_time_delay(manger, saddr, (chn - 1) + 1, time / 1000);
+            if (ret < 0)
+            {
+                ret = g_switch_set_t_ac_start_time_delay(manger, saddr, (chn - 1) + 1, time / 1000);
+                if (ret < 0)
+                    return ret;
+            }
+        }
+        else 
         {
             ret = g_switch_set_t_ac_start_time_delay(manger, saddr, (chn - 1), time / 1000);
             if (ret < 0)
@@ -736,6 +753,27 @@ int g_switch_set_all_start_time_delay(void* manger,int ntype,int saddr,unsigned
 
         return 0;
     }
+    case DOUBLE_AC_TYPE:
+    {
+        int ret = 0;
+
+        ret = g_switch_set_t_ac_start_time_delay(manger, saddr, (chn - 1), time / 1000);
+        if (ret < 0)
+        {
+            ret = g_switch_set_t_ac_start_time_delay(manger, saddr, (chn - 1), time / 1000);
+            if (ret < 0)
+                return ret;
+        }
+        ret = g_switch_set_t_ac_start_time_delay(manger, saddr, (chn - 1)  + 4, time / 1000);
+        if (ret < 0)
+        {
+            ret = g_switch_set_t_ac_start_time_delay(manger, saddr, (chn - 1) + 4, time / 1000);
+            if (ret < 0)
+                return ret;
+        }
+
+        return 0;
+    }
     case AC_MULTI_S_TYPE:
     case AC_MULTI_B_TYPE:
     case DC_IN_TYPE:
@@ -800,6 +838,23 @@ int g_switch_set_all_stop_time_delay(void* manger,int ntype,int saddr,unsigned c
                     return ret;
             }
         }
+        else if (__globalDeviceManage._globalDevInfo.product.pwr_type == SmartPDU_Tree_AC_Two)
+        {
+            ret = g_switch_set_t_ac_stop_time_delay(manger, saddr, (chn - 1) * 3, time / 1000);
+            if (ret < 0)
+            {
+                ret = g_switch_set_t_ac_stop_time_delay(manger, saddr, (chn - 1) * 3, time / 1000);
+                if (ret < 0)
+                    return ret;
+            }
+            ret = g_switch_set_t_ac_stop_time_delay(manger, saddr, (chn - 1) * 3 + 1, time / 1000);
+            if (ret < 0)
+            {
+                ret = g_switch_set_t_ac_stop_time_delay(manger, saddr, (chn - 1) * 3 + 1, time / 1000);
+                if (ret < 0)
+                    return ret;
+            }
+        }
         else
         {
             ret = g_switch_set_t_ac_stop_time_delay(manger, saddr, (chn - 1), time / 1000);
@@ -812,6 +867,27 @@ int g_switch_set_all_stop_time_delay(void* manger,int ntype,int saddr,unsigned c
         }
         return 0;
     }
+    case DOUBLE_AC_TYPE:
+    {
+        int ret = 0;
+
+        ret = g_switch_set_t_ac_stop_time_delay(manger, saddr, (chn - 1) , time / 1000);
+        if (ret < 0)
+        {
+            ret = g_switch_set_t_ac_stop_time_delay(manger, saddr, (chn - 1) , time / 1000);
+            if (ret < 0)
+                return ret;
+        }
+        ret = g_switch_set_t_ac_stop_time_delay(manger, saddr, (chn - 1)  + 4, time / 1000);
+        if (ret < 0)
+        {
+            ret = g_switch_set_t_ac_stop_time_delay(manger, saddr, (chn - 1)  + 4, time / 1000);
+            if (ret < 0)
+                return ret;
+        }
+
+        return 0;
+    }
     case AC_MULTI_S_TYPE:
     case AC_MULTI_B_TYPE:
     case DC_IN_TYPE:
@@ -877,6 +953,7 @@ int g_switch_set_all_chn_ctrl(void* manger,GlobalPowerManger* _globalPowerManger
     }
     break;
     case TREE_AC_TYPE:
+    case DOUBLE_AC_TYPE:
     {
         int t_ac_CtrlType=0;
         int nRet = 0;
@@ -885,7 +962,7 @@ int g_switch_set_all_chn_ctrl(void* manger,GlobalPowerManger* _globalPowerManger
         {
             t_ac_CtrlType=_globalTACManager->product_ph_outputType;
         }
-        if (t_ac_CtrlType == 2&&__globalDeviceManage._globalDevInfo.product.pwr_type == SmartPDU_Tree_AC_Tree)
+        if ((t_ac_CtrlType == 2&&__globalDeviceManage._globalDevInfo.product.pwr_type == SmartPDU_Tree_AC_Tree)||(t_ac_CtrlType == 2&&__globalDeviceManage._globalDevInfo.product.pwr_type == SmartPDU_Tree_AC_Two))
         {
             unsigned short phsts=0;
             
@@ -1033,6 +1110,7 @@ int g_switch_set_all_ctrl(void* manger,int ntype,int saddr,unsigned short sts)
     }
     break;
     case TREE_AC_TYPE:
+    case DOUBLE_AC_TYPE:
     {
         return g_switch_set_t_ac_ctrl(manger, saddr,switch_ctrl);
     }
@@ -1083,6 +1161,7 @@ int g_switch_set_all_single_threshold(void* manger,int ntype,int saddr,char chn,
     }
     break;
     case TREE_AC_TYPE:
+    case DOUBLE_AC_TYPE:
     {
         if (chn == 0)
         {
@@ -1175,6 +1254,7 @@ int g_switch_get_all_out_info(void* manger,int ntype,int saddr,int nNumb,PowerIn
         return g_switch_get_dcpdu_all_out_info(manger, saddr, nNumb, _power, _warning);
     }
     break;
+    case DOUBLE_AC_TYPE:
     case TREE_AC_TYPE:
     {
         return g_switch_get_t_ac_all_out_info(manger, saddr, nNumb, _power, _warning);
@@ -1204,6 +1284,7 @@ int g_switch_get_all_reset(void* manger,int ntype,int saddr)
         return g_switch_set_dcpdu_reset(manger, saddr);
     }
     break;
+    case DOUBLE_AC_TYPE:
     case TREE_AC_TYPE:
     {
         return g_switch_set_t_ac_reset(manger, saddr);
@@ -2158,10 +2239,10 @@ int g_switch_set_t_ac_stop_time_delay(void* manger,int saddr,int ch, unsigned in
 int g_switch_set_t_ac_chn_ctrl(void* manger,int saddr,unsigned char chn,unsigned short sts)
 {
     unsigned int offset = 0;
-    if(chn > 3 || chn < 0) return -1;
+    if(chn > 4 || chn < 0) return -1;
     unsigned short data_temp[2]; 
     memset(data_temp,0,sizeof(data_temp));
-    if(chn>=3)
+    if(chn>=4)
         return -1;  
     offset = _SWITCH_T_AC_CH_OUT_ENABLE+chn;   
     data_temp[0]=sts;
@@ -2188,10 +2269,10 @@ int g_switch_set_t_ac_phchn_ctrl(void* manger,int saddr,unsigned char chn,unsign
 {
     //三个一组进行设置
         unsigned int offset = 0;
-    if(chn > 9 || chn < 0) return -1;
+    if(chn > 12 || chn < 0) return -1;
     unsigned short data_temp[2]; 
     memset(data_temp,0,sizeof(data_temp));
-    if(chn>=9)
+    if(chn>=12)
         return -1;  
     offset = _SWITCH_T_AC_OUT_ENABLE+chn;   
     data_temp[0]=sts;
@@ -2618,6 +2699,8 @@ int ResetChmData(int nCtrlType)
     int chn = 1;
     int type = 0;
     int nTac_chn=3;
+    int chnBroad = 1;
+    int nTruePHID = 1;
     GlobalDeviceManager* _globalDeviceManager=&__globalDeviceManage;    
     ProductInfo_t *prod=&_globalDeviceManager->_globalDevInfo.product;
     int nGroups=prod->ch_delay;
@@ -2915,9 +2998,12 @@ int ResetChmData(int nCtrlType)
             }
             break;
             case TREE_AC_TYPE: // 三相供电
+            case DOUBLE_AC_TYPE:
             {
-                log_i("TreeAC_TYPE!\n");
+                log_i("TreeAC_TYPE! nMaxChn=%d\n",nMaxChn);
                 GlobalPowerManger *_globalPowerMangerTemp = NULL;
+                chnBroad=chn;
+                nTruePHID = nTac_chn-3+1;
                 for (size_t j = 0; j < nMaxChn; j++)
                 {
                     if (_globalDeviceManager->_globalDevInfo.product.pwr_type == SmartPDU_Tree_AC_One)
@@ -3041,6 +3127,220 @@ int ResetChmData(int nCtrlType)
                             }
                             nTac_chn += 1;
                         }
+                    }else if (_globalDeviceManager->_globalDevInfo.product.pwr_type == SmartPDU_Tree_AC_Two)
+                    {
+                        log_i("TreeAC_TYPE_3-2!\n");//由于三项全部都会进行输出一个控制板存在A4B4,A4C4,B4C4三种情况。所以同一时间
+                        int m_HalfChn = nMaxChn / 2;
+                        if (j < m_HalfChn)//由于一半通道接L1一半通道接L2所以对半分处理。
+                        {
+                            _globalPowerMangerTemp = (GlobalPowerManger *)malloc(sizeof(GlobalPowerManger));
+                            if (_globalPowerMangerTemp == NULL)
+                            {
+                                log_e("_globalPowerManger malloc error.\n");
+                                return -1;
+                            }
+                            memset(_globalPowerMangerTemp, 0, sizeof(GlobalPowerManger));
+                            INIT_LIST_HEAD(&_globalPowerMangerTemp->list_Tree_AC);
+
+                            // 查询是否由通道信息
+                            ret = dev_get_power_manage_info(_globalDeviceManager->db,
+                                                            _globalDeviceManager->_globalDevInfo.product.id, i,
+                                                            j + 1, // 1*8+j
+                                                            _globalPowerMangerTemp);
+                            _globalPowerMangerTemp->product_ch_addr = j + 1;
+                            // 未查询到信息 则插入
+                            if (ret == -1)
+                            {
+                                _globalPowerMangerTemp->product_id = _globalDeviceManager->_globalDevInfo.product.id;
+                                _globalPowerMangerTemp->product_saddr = i;
+                                _globalPowerMangerTemp->product_ch_id = chn;
+                                _globalPowerMangerTemp->product_ch_addr = j + 1;
+                                sprintf(_globalPowerMangerTemp->product_ch_name, "CH%d", _globalPowerMangerTemp->product_ch_id);
+                                _globalPowerMangerTemp->product_ch_type = type;
+                                _globalPowerMangerTemp->product_ch_status = 0;
+                                _globalPowerMangerTemp->product_ch_NF_status = 0;
+
+                                _globalPowerMangerTemp->product_ch_start_delay = 1000 * (chn % nGroups != 0 ? chn % nGroups : nGroups);
+                                _globalPowerMangerTemp->product_ch_stop_delay = 1000 * (chn % nGroups != 0 ? chn % nGroups : nGroups);
+
+                                if (dev_insert_power_manage_info(_globalDeviceManager->db,
+                                                                 _globalDeviceManager->_globalDevInfo.product.id,
+                                                                 _globalPowerMangerTemp->product_ch_id,
+                                                                 _globalPowerMangerTemp) != 0)
+                                {
+                                    log_e("address %d chn %d data inserted error.\n", i, chn);
+                                    return 0;
+                                }
+                            }
+                            _globalPowerMangerTemp->product_saddr = i;
+                            _globalPowerMangerTemp->product_ch_type = type;
+                            if (nCtrlType)
+                            {
+                                _globalPowerMangerTemp->product_ch_id = chn;
+                                sprintf(_globalPowerMangerTemp->product_ch_name, "CH%d", _globalPowerMangerTemp->product_ch_id);
+                                if (dev_update_power_manage_genera_info_addr(__globalDeviceManage.db, _globalDeviceManager->_globalDevInfo.product.id, _globalPowerMangerTemp->product_saddr, _globalPowerMangerTemp->product_ch_addr, _globalPowerMangerTemp) != 0)
+                                {
+                                    log_e("update pwr general data err.");
+                                }
+                            }
+                            // 添加到队尾
+                            list_add_tail(&_globalPowerMangerTemp->list, &_globalDeviceManager->_globalPowerManger.list);
+                            chn += 1;
+                        }                     
+                        // 初始化三相子通道信息
+                        GlobalTreeACManager *_globalTACManager = NULL;
+                        _globalTACManager = (GlobalTreeACManager *)malloc(sizeof(GlobalTreeACManager));
+                        if (_globalTACManager == NULL)
+                        {
+                            log_e("_globalTACManager malloc error.\n");
+                            return -1;
+                        }
+                        memset(_globalTACManager, 0, sizeof(GlobalTreeACManager));
+                        
+
+                        int nTac_chnTrue=0;
+                        int nTac_ChnTac=nTac_chn-3+1;
+                        int nPhType=_globalDeviceManager->pCtrlBoard[i].nLeft_phType;
+                        //如果是1则A0+B1差C相,如果是2则A0+C2差B相,如果是3则是B1+C2差A相
+                        int sumType = _globalDeviceManager->pCtrlBoard[i].nLeft_phType+_globalDeviceManager->pCtrlBoard[i].nRight_phType;
+                        int nPhOtherType=0;
+                        switch (sumType)
+                        {
+                        case 1:nPhOtherType = 2;break;
+                        case 2:nPhOtherType = 1;break;
+                        case 3:nPhOtherType = 0;break;
+                        }
+                        //为了保证三个通道位置相同顺序是123,456,789进行区分。如果不这么做会存在156,278,3910的情况
+                        if (j >= m_HalfChn)
+                        {
+                            if(j==m_HalfChn)chn=chnBroad;
+                            nTac_chnTrue = (j-m_HalfChn)*3+4+nTruePHID-1;// 2->4,5->7,8->10,11->13()
+                            nPhType=_globalDeviceManager->pCtrlBoard[i].nRight_phType;
+                            chn+=1;
+                        }
+                        else
+                        {
+                            nTac_chnTrue = (j)*3+ 3+nTruePHID-1;// 1->3,4->6,7->9,10->12,13->15,16->18u0
+                        }
+
+                        ret = dev_get_t_ac_power_manage_info(_globalDeviceManager->db,
+                                                             _globalDeviceManager->_globalDevInfo.product.id, i,
+                                                             chn-1, // 1*8+j
+                                                             nTac_chnTrue, // 1*8+j
+                                                             _globalTACManager);                                             
+                        if (ret == -1)
+                        {
+                            _globalTACManager->product_id = _globalDeviceManager->_globalDevInfo.product.id;
+                            _globalTACManager->product_saddr = i;
+                            _globalTACManager->product_ch_id = chn-1;
+                            _globalTACManager->product_ch_addr = j + 1;
+                            _globalTACManager->product_ph_id =nTac_chnTrue;                            
+                            _globalTACManager->product_ph_type = nPhType;
+                            _globalTACManager->product_ph_outputType = 3;   // 1三相2单相3二相
+                            _globalTACManager->product_ph_outputStatus = 1; // 1输出
+                            if (dev_insert_t_ac_power_manage_info(_globalDeviceManager->db,
+                                                                  _globalDeviceManager->_globalDevInfo.product.id,
+                                                                  _globalTACManager->product_ch_id,
+                                                                  _globalTACManager) != 0)
+                            {
+                                log_e("address %d ph_chn %d data inserted error.\n", i, nTac_chnTrue);
+                                return 0;
+                            }
+                        }
+                        // 绑定到三项通道
+                        _globalTACManager->product_saddr = i;
+                        _globalTACManager->product_ph_type =nPhType;
+                        if (nCtrlType)
+                        {
+                            _globalTACManager->product_ph_id = nTac_chnTrue;
+                            _globalTACManager->product_saddr = i;
+                             if (dev_update_t_ac_power_manage_info(__globalDeviceManage.db, _globalTACManager) != 0)
+                            {
+                                log_e("update pwr general data err.");
+                            }
+                        }
+                        // 查询所属的三项通道
+                        _globalPowerMangerTemp = NULL;
+                        list_for_each_entry(_globalPowerMangerTemp, &_globalDeviceManager->_globalPowerManger.list, list)
+                        {
+                            if (_globalPowerMangerTemp && _globalPowerMangerTemp->product_ch_id == _globalTACManager->product_ch_id)
+                            {
+                                break;
+                            }
+                        }
+                        if (_globalPowerMangerTemp)
+                        {
+                            list_add_tail(&_globalTACManager->list_Tree_AC, &_globalPowerMangerTemp->list_Tree_AC);
+                        }
+                        nTac_chn += 1;
+                        if (j>=m_HalfChn)
+                        {
+                            /*
+                            // 由于存在2个已存在通道,只有那个不存在的通道需要额外初始化
+                            _globalTACManager = (GlobalTreeACManager *)malloc(sizeof(GlobalTreeACManager));
+                            int indexT=nPhOtherType;//其他通道是0和1,此处为2
+                            memset(_globalTACManager, 0, sizeof(GlobalTreeACManager));
+                            if (_globalTACManager == NULL)
+                            {
+                                log_e("_globalTACManager malloc error.\n");
+                                return -1;
+                            }
+                            
+                            ret = dev_get_t_ac_power_manage_info(_globalDeviceManager->db,
+                                                                 _globalDeviceManager->_globalDevInfo.product.id, i,
+                                                                chn-1, 
+                                                                 indexT,
+                                                                 _globalTACManager);
+                            _globalTACManager->product_ch_addr = j + 1;
+                            // 未查询到信息 则插入
+                            if (ret == -1)
+                            {
+                                _globalTACManager->product_id = _globalDeviceManager->_globalDevInfo.product.id;
+                                _globalTACManager->product_saddr = i;
+                                _globalTACManager->product_ch_id = chn-1;
+                                _globalTACManager->product_ch_addr = j + 1;
+                                _globalTACManager->product_ph_id = nTac_chnTrue+1;//3,6,7,11;
+                                _globalTACManager->product_ph_type = indexT;
+                                _globalTACManager->product_ph_outputType = 3; // 1三相2单相3二相
+                                _globalTACManager->product_ph_outputStatus = 2; // 1输出2不输出
+                                if (dev_insert_t_ac_power_manage_info(_globalDeviceManager->db,
+                                                                      _globalDeviceManager->_globalDevInfo.product.id,
+                                                                      _globalTACManager->product_ch_id,
+                                                                      _globalTACManager) != 0)
+                                {
+                                    log_e("address %d ph_chn %d data inserted error.\n", i, nTac_chn);
+                                    return 0;
+                                }
+                            }
+                            // 绑定到三项通道
+                            _globalTACManager->product_saddr = i;
+                            _globalTACManager->product_ph_type = indexT;
+                            if (nCtrlType)
+                            {
+                                _globalTACManager->product_ph_id = nTac_chnTrue+1;
+                                _globalTACManager->product_saddr = i;
+                                _globalTACManager->product_ph_type = indexT;
+                                if (dev_update_t_ac_power_manage_info(__globalDeviceManage.db, _globalTACManager) != 0)
+                                {
+                                    log_e("update pwr general data err.");
+                                }
+                            }
+                            //查询所属的三项通道         
+                            _globalPowerMangerTemp=NULL;                   
+                            list_for_each_entry(_globalPowerMangerTemp, &_globalDeviceManager->_globalPowerManger.list, list)
+                            {
+                                if (_globalPowerMangerTemp&&_globalPowerMangerTemp->product_ch_id==_globalTACManager->product_ch_id)
+                                {
+                                    break;
+                                }                                
+                            }
+                            if (_globalPowerMangerTemp)
+                            {
+                                list_add_tail(&_globalTACManager->list_Tree_AC, &_globalPowerMangerTemp->list_Tree_AC);
+                            }
+                            */
+                            nTac_chn += 1;
+                        }                        
                     }
                     else
                     {
@@ -3187,6 +3487,7 @@ int g_switch_get_breaker_info(void* manger,int ntype,int saddr,GlobalBreakerMana
     case DCPDU_TYPE:
     break;
     case TREE_AC_TYPE:
+    case DOUBLE_AC_TYPE:
     {
         return g_switch_get_t_ac_breaker_info(manger, saddr, _breaker);
     }

+ 1 - 0
pro/src/websocket_handle.c

@@ -100,6 +100,7 @@ static int ws_all_update(ws_handle_t *h)
     pwrall_info_t *pall=&h->pwrall;
     if(gdm->_globalDevInfo.product.pwr_type==SmartPDU_Tree_AC_Tree ||
         gdm->_globalDevInfo.product.pwr_type==SmartPDU_Tree_AC_One ||
+        gdm->_globalDevInfo.product.pwr_type==SmartPDU_Tree_AC_Two ||
         gdm->_globalDevInfo.product.pwr_type==SmartPDU_Tree_AC_One_B)
     {
         pall->ph3 = 1;

+ 1 - 0
pro/ui/menu.c

@@ -127,6 +127,7 @@ static int is_ph3_in(menu_handle_t *h)
 {
     if ((h->dm->_globalDevInfo.product.pwr_type == SmartPDU_Tree_AC_Tree ||
          h->dm->_globalDevInfo.product.pwr_type == SmartPDU_Tree_AC_One  ||
+         h->dm->_globalDevInfo.product.pwr_type == SmartPDU_Tree_AC_Two  ||
          h->dm->_globalDevInfo.product.pwr_type == SmartPDU_Tree_AC_One_B)) {
         return 1;
     }