Quellcode durchsuchen

1、添加三相零线状态显示及零线独立控制功能;
2、添加三相零线级联显示及状态控制。

liyuezong vor 2 Jahren
Ursprung
Commit
f2d30566bc

+ 12 - 1
pro/src/app.c

@@ -424,6 +424,7 @@ void* power_thread(void* arg)
                     _globalTotalPowerInfo._power_info.factor = _globalPowerInfo._power_info.factor ;
                     _globalPowerInfo.product_status = _globalPowerInfo._power_info.status ;
                     _globalPowerMangerTemp->product_ch_status = _globalPowerInfo._power_info.status ;
+
                     //累加总电源信息
                     _globalTotalPowerInfo.product_id = _globalDeviceManager->_global_device_info->product_id;
                     _globalTotalPowerInfo.product_ch_id = 0 ; //总电源通道信息为0
@@ -553,6 +554,9 @@ void* power_thread(void* arg)
                             _globalPowerInfo._power_info.status=0;
                         }
                         __globalDeviceManage.triphasic_mmap->pw_o_chn[_chn].chn[k].o_status = _globalPowerInfo._power_info.status;
+
+                        _globalPowerInfo._power_info.NF_status=_pTreeACPowerMangerTemp->_PowerInfo.NF_status;
+
                         k=k+1;
                         time_t now;
                         time(&now);
@@ -622,6 +626,7 @@ void* power_thread(void* arg)
                     _globalTotalPowerInfo._power_info.factor = _globalPowerInfo._power_info.factor ;
                     _globalPowerInfo.product_status = _globalPowerInfo._power_info.status ;
                     _globalPowerMangerTemp->product_ch_status = _globalPowerInfo._power_info.status ;
+                     _globalPowerMangerTemp->product_ch_NF_status = _globalPowerInfo._power_info.NF_status ;
 
                     // tong dao zong ti xin xi
                     __globalDeviceManage.triphasic_mmap->chn_info[_chn].chn_consumption  = _globalTotalPowerInfo._power_info.consumption * 1000;
@@ -907,7 +912,7 @@ void* power_thread(void* arg)
             //sleep(1);
         ///usleep(500*1000);  
         //延时
-        usleep(samp_time*1000);
+        //usleep(samp_time*1000);
     }
     free_hash_table(_globalDeviceManager->_global_alarmLanguage);
     log_e("Error!!!!!!!!!!!!!!Thread End");
@@ -1501,6 +1506,7 @@ int _global_device_manage_init(GlobalDeviceManager* _globalDeviceManager)
         sprintf( _globalDeviceManager->_globalPowerManger.product_ch_name,"ALL_CH");//,_globalDeviceManager->_globalPowerManger.product_ch_id);
         _globalDeviceManager->_globalPowerManger.product_ch_type = type;
         _globalDeviceManager->_globalPowerManger.product_ch_status = 0;
+        _globalDeviceManager->_globalPowerManger.product_ch_NF_status = 0;
         _globalDeviceManager->_globalPowerManger.product_ch_start_delay = 1000;     
         _globalDeviceManager->_globalPowerManger.product_ch_stop_delay = 1000;
         _globalDeviceManager->_globalPowerManger.global_over_manager->product_cur_over_upper_threshold_ctrl =ALARM_CTRL_ALARM_ONLY;//默认超限只报警
@@ -1684,6 +1690,7 @@ int _global_device_manage_init(GlobalDeviceManager* _globalDeviceManager)
                             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);
@@ -1830,6 +1837,7 @@ int _global_device_manage_init(GlobalDeviceManager* _globalDeviceManager)
                             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;
                             _globalPowerMangerTemp->product_ch_stop_delay = 1000;
 
@@ -1901,6 +1909,7 @@ int _global_device_manage_init(GlobalDeviceManager* _globalDeviceManager)
                             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);
@@ -1978,6 +1987,7 @@ int _global_device_manage_init(GlobalDeviceManager* _globalDeviceManager)
                                 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);
@@ -2104,6 +2114,7 @@ int _global_device_manage_init(GlobalDeviceManager* _globalDeviceManager)
                                     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);

+ 102 - 9
pro/src/appweb_handle.c

@@ -355,7 +355,6 @@ static void loginFunc(void* conn)
 /// @param stream 
 static void loginOutFunc(void* conn)
 {
-    __globalDeviceManage.view_page=-1;
 	char* ack_str = NULL ;
     char* g_token;
     mg_stream_t *s=(mg_stream_t*)conn;
@@ -466,9 +465,6 @@ static void overallStatusMonitoring(void* conn)
     //总电压电流信息
     if(strcmp(_over_all_sts_monitor.type,"listQuery")==0)
     {
-        //总信息
-         __globalDeviceManage.view_page = 1 ;
-
         cur_dev_addr = _over_all_sts_monitor.product_id;
         if(cur_dev_addr>0) {
             int r=0;
@@ -897,6 +893,107 @@ static void channelStatusMonitoring(void* conn)
         return;     
     }
 
+    if (_over_chn_pwr_request.Zerotype!=NULL)
+    {
+        if (strcmp(_over_chn_pwr_request.Zerotype, "open") == 0) // 零线开
+        {
+            int ret = 0;
+            int product_chn_id = 0;
+            char buff[256];
+            log_i("channel NF status request:open");
+            product_chn_id = _over_chn_pwr_request.productChId;
+
+            if (cur_dev_addr > 0)
+            {
+                cmd.cmd = CASCADE_CMD_OPEN_NF;
+                cmd.obj = OBJ_CHANNEL;
+                cmd.chId = product_chn_id;
+                cascade_request(&cmd);
+
+                ack_str = ctrl_sts_ack_to_json();
+                goto quit;
+            }
+            GlobalPowerManger *_globalPowerMangerTemp = NULL;
+            list_for_each_entry(_globalPowerMangerTemp, &__globalDeviceManage._globalPowerManger.list, list)
+            {
+                // log_d("channel:%d", _globalPowerMangerTemp->product_ch_id);
+                if (_globalPowerMangerTemp == NULL)
+                    break;
+                if (product_chn_id == _globalPowerMangerTemp->product_ch_id)
+                {
+                    log_d("switch ctrl:%d", _globalPowerMangerTemp->product_ch_id);
+                    ret = g_switch_set_t_ac_chn_NF_ctrl(&__globalDeviceManage._globalRelaySampManger,
+                                                    _globalPowerMangerTemp->product_saddr,
+                                                    _globalPowerMangerTemp->product_ch_addr,
+                                                    1);
+                    if (ret < 0)
+                    {
+                    ret = g_switch_set_t_ac_chn_NF_ctrl(&__globalDeviceManage._globalRelaySampManger,
+                                                    _globalPowerMangerTemp->product_saddr,
+                                                    _globalPowerMangerTemp->product_ch_addr,
+                                                    1);
+                    }
+                    sprintf(buff, "$开启$|$通道$|%d Naught wire!", _globalPowerMangerTemp->product_ch_id);
+                    dev_insert_alarm_ctrl(__globalDeviceManage.db, _globalPowerMangerTemp->product_id, 3, buff);
+                    break;
+                }
+            }
+            ack_str = ctrl_sts_ack_to_json();
+        }
+        else  if (strcmp(_over_chn_pwr_request.Zerotype, "close") == 0) // 零线关
+        {
+            int ret = 0;
+            int product_chn_id = 0;
+            char buff[256];
+            log_i("channel NF status request:open");
+            product_chn_id = _over_chn_pwr_request.productChId;
+
+            if (cur_dev_addr > 0)
+            {
+                cmd.cmd = CASCADE_CMD_CLOSE_NF;
+                cmd.obj = OBJ_CHANNEL;
+                cmd.chId = product_chn_id;
+                cascade_request(&cmd);
+
+                ack_str = ctrl_sts_ack_to_json();
+                goto quit;
+            }
+            GlobalPowerManger *_globalPowerMangerTemp = NULL;
+            list_for_each_entry(_globalPowerMangerTemp, &__globalDeviceManage._globalPowerManger.list, list)
+            {
+                // log_d("channel:%d", _globalPowerMangerTemp->product_ch_id);
+                if (_globalPowerMangerTemp == NULL)
+                    break;
+                if (product_chn_id == _globalPowerMangerTemp->product_ch_id)
+                {
+                    log_d("switch ctrl:%d", _globalPowerMangerTemp->product_ch_id);
+                    ret = g_switch_set_t_ac_chn_NF_ctrl(&__globalDeviceManage._globalRelaySampManger,
+                                                    _globalPowerMangerTemp->product_saddr,
+                                                    _globalPowerMangerTemp->product_ch_addr,
+                                                    0);
+                    if (ret < 0)
+                    {
+                    ret = g_switch_set_t_ac_chn_NF_ctrl(&__globalDeviceManage._globalRelaySampManger,
+                                                    _globalPowerMangerTemp->product_saddr,
+                                                    _globalPowerMangerTemp->product_ch_addr,
+                                                    0);
+                    }
+                    sprintf(buff, "$关闭$|$通道$|%d Naught wire!", _globalPowerMangerTemp->product_ch_id);
+                    dev_insert_alarm_ctrl(__globalDeviceManage.db, _globalPowerMangerTemp->product_id, 3, buff);
+                    break;
+                }
+            }
+            ack_str = ctrl_sts_ack_to_json();
+        }
+    }
+
+    
+
+    if (_over_chn_pwr_request.type==NULL)
+    {
+       goto quit;
+    }
+    
     if(strcmp(_over_chn_pwr_request.type,"listQuery")==0||strcmp(_over_chn_pwr_request.type,"resetChannel")==0)
     {
         //log_i("channel status request:listQuery");
@@ -915,7 +1012,6 @@ static void channelStatusMonitoring(void* conn)
         _OverChnPwrAckInfo _over_chn_pwr_back_info;
         INIT_LIST_HEAD(&_over_chn_pwr_back_info.list);
 
-        __globalDeviceManage.view_page = 2 ; //通道信息
         product_chn_id = _over_chn_pwr_request.productChId;
 
         cur_dev_addr = _over_chn_pwr_request.product_id;
@@ -973,6 +1069,7 @@ static void channelStatusMonitoring(void* conn)
                     _overChnPwrBackInfoTemp->productChName = _globalPowerMangerTemp->product_ch_name;
                     _overChnPwrBackInfoTemp->productChId = _globalPowerMangerTemp->product_ch_id;
                     _overChnPwrBackInfoTemp->status = _powerInfo._power_info.status; 
+                   _overChnPwrBackInfoTemp->NF_status = _powerInfo._power_info.NF_status; 
                     _overChnPwrBackInfoTemp->voltage = _powerInfo._power_info.voltage;
                     _overChnPwrBackInfoTemp->current = _powerInfo._power_info.current;
                     _overChnPwrBackInfoTemp->power = _powerInfo._power_info.power ;
@@ -1380,7 +1477,6 @@ quit:
 /// @param stream 
 static void sensorStatusMonitoring(void* conn)
 {
-    __globalDeviceManage.view_page=-1;
     int ret = -1 ;
     cJSON *cjson;
     _OverSensorRequest _over_all_sensor_request;
@@ -1936,7 +2032,6 @@ static void sensorStatusMonitoring(void* conn)
 /// @param stream 
 static void alarmProtect(void *conn)
 {
-    __globalDeviceManage.view_page=-1;
     int ret = -1 ;
     cJSON *cjson;
     _AlarmRequestInfo _alarm_request_info;
@@ -2587,7 +2682,6 @@ static void communicationManagement(void *conn)
 /// @param stream 
 static void serviceManagement(void *conn)
 {
-    __globalDeviceManage.view_page=-1;
     int ret = -1 ;
     cJSON *cjson;
     _ServiceManageRequestInfo _serviceManageRequestInfo;
@@ -3343,7 +3437,6 @@ static void serviceManagement(void *conn)
 /// @param stream 
 static void systemManagent(void *conn)
 {
-    __globalDeviceManage.view_page=-1;
     int ret = -1 ;
     cJSON *cjson;
     _UserRoleManageInfo _UserRoleManageRequestInfo;

+ 59 - 0
pro/src/cascade.c

@@ -54,6 +54,7 @@ int cur_dev_addr=0;
 static cascade_handle_t casHandle={.inited=0};
 static cascade_handle_t casHandle_breaker={.inited=0};
 static void* cmd_thread(void *arg);
+static void* cmd_NF_thread(void *arg);
 
 //////////////////////////////////////////////////
 static inline GlobalDeviceManager* get_dm(void)
@@ -173,6 +174,7 @@ static int slave_get_info(cascade_handle_t *cas)
             info->ch[cnt].product_ch_addr = tmp->product_ch_addr;
             info->ch[cnt].product_ch_id = tmp->product_ch_id;
             info->ch[cnt].product_ch_status = tmp->product_ch_status;
+            info->ch[cnt].product_ch_NF_status = tmp->product_ch_NF_status;
             info->ch[cnt].start_delay = tmp->product_ch_start_delay;
             info->ch[cnt].stop_delay  = tmp->product_ch_stop_delay;
 
@@ -246,6 +248,7 @@ static int get_pwr_info(int chId, GlobalPowerManger *power)
             strcpy(power->product_ch_name, tmp->product_ch_name);
             power->product_ch_type = tmp->product_ch_type;
             power->product_ch_status = tmp->product_ch_status;
+            power->product_ch_NF_status = tmp->product_ch_NF_status;
             power->product_ch_start_delay = tmp->product_ch_start_delay;
             power->product_ch_stop_delay = tmp->product_ch_stop_delay;
 
@@ -735,6 +738,18 @@ static int mb_receive(cascade_handle_t *cas)
                 }
                 break;
 
+
+              case CASCADE_CMD_OPEN_NF:
+                case CASCADE_CMD_CLOSE_NF:
+                {
+                    cmd_data_t *pcmd=malloc(sizeof(cmd_data_t));
+                    if(pcmd) {
+                        *pcmd = *cmd;
+                        thread_start_simp(cmd_NF_thread, pcmd, 4*MB);
+                    }
+                }
+                break;
+
                 case CASCADE_CMD_SAVE:
                 case CASCADE_CMD_SAVE3:
                 {
@@ -1050,6 +1065,7 @@ static int power_add(cascade_handle_t *cas)
         sprintf(tmp->product_ch_name, "CH%d", tmp->product_ch_id);
         tmp->product_ch_type = info->ch[i].product_ch_type;
         tmp->product_ch_status = info->ch[i].product_ch_status;
+        tmp->product_ch_NF_status = info->ch[i].product_ch_NF_status;
         tmp->product_ch_start_delay = info->ch[i].start_delay;
         tmp->product_ch_stop_delay = info->ch[i].stop_delay;
 
@@ -1283,6 +1299,8 @@ static int master_cmd(cascade_handle_t *cas, cmd_data_t *cmd)
         case CASCADE_CMD_CLOSE:
         case CASCADE_CMD_SAVE:
         case CASCADE_CMD_SAVE3:
+        case CASCADE_CMD_OPEN_NF:
+        case CASCADE_CMD_CLOSE_NF:
         {
             LOGD("____ master CMD: %d\n", cmd->cmd);
 
@@ -1641,6 +1659,47 @@ static void* cmd_thread(void *arg)
 
     pthread_exit(NULL);
 }
+
+static void* cmd_NF_thread(void *arg)
+{
+    int i,t=0;
+    char temp[256];
+    cascade_handle_t *cas=&casHandle;
+    slave_info_t *info=&cas->sInfo;
+    GlobalDeviceManager *dm=get_dm();
+    cmd_data_t *pcmd=(cmd_data_t*)arg;
+
+    if(pcmd->cmd==CASCADE_CMD_OPEN_NF) {
+        LOGD("____ slave CASCADE_CMD_OPEN_NF\n");
+    }
+    else {
+        LOGD("____ slave CASCADE_CMD_CLOSE_NF\n");
+    }
+
+    int flag=(pcmd->cmd==CASCADE_CMD_OPEN_NF)?1:0;
+    if(pcmd->obj == OBJ_CHANNEL) 
+     {
+        GlobalPowerManger *tmp=NULL;
+        list_for_each_entry(tmp, &dm->_globalPowerManger.list, list)
+        {
+            if(tmp->product_ch_id==pcmd->chId) {
+                t = g_switch_set_t_ac_chn_NF_ctrl(&dm->_globalRelaySampManger, tmp->product_saddr, tmp->product_ch_addr, flag);
+                break;
+            }
+        }
+    }
+
+    if(pcmd->cmd==CASCADE_CMD_OPEN_NF) {
+        sprintf(temp, "$开启$|$通道$|%d Naught wire!", pcmd->chId);
+    }
+    else {
+        sprintf(temp, "$关闭$|$通道$|%d Naught wire!", pcmd->chId);
+    }
+    dev_insert_alarm_ctrl(dm->db, dm->_global_device_info->product_id,3,temp);
+    free(pcmd);
+
+    pthread_exit(NULL);
+}
 static int set_modbus(cascade_handle_t *cas, ModbusInfo_t *info)
 {
     int r;

+ 3 - 0
pro/src/cascade.h

@@ -58,6 +58,8 @@ enum {
     CASCADE_CMD_BREAKER_SAVE_ADD,
     CASCADE_CMD_BREAKER_SAVE_UPDATE,
     CASCADE_CMD_BREAKER_SAVE_DELETE,
+    CASCADE_CMD_OPEN_NF,
+    CASCADE_CMD_CLOSE_NF,
 
     CASCADE_CMD_MAX,
 };
@@ -149,6 +151,7 @@ typedef struct {
     uint8_t         product_ch_addr;
     uint8_t         product_ch_id;
     uint8_t         product_ch_status;
+    uint8_t         product_ch_NF_status;
     
     PowerInfo       chinfo;
     power_info_t    pinfo[3];

+ 1 - 0
pro/src/common.c

@@ -51,6 +51,7 @@ void printf_global_power_manage_info(GlobalPowerManger* _globalPowerManger)
     printf("product_ch_name:%s ", _globalPowerManger->product_ch_name);
     printf("product_ch_type:%d ", _globalPowerManger->product_ch_type);
     printf("product_ch_status:%d ", _globalPowerManger->product_ch_status);
+    printf("product_ch_NF_status:%d ", _globalPowerManger->product_ch_NF_status); 
     printf("product_ch_start_delay:%d ", _globalPowerManger->product_ch_start_delay);
     printf("product_ch_stop_delay:%d ", _globalPowerManger->product_ch_stop_delay);
 

+ 3 - 3
pro/src/common.h

@@ -362,7 +362,8 @@ typedef struct
     float           freq                                        ;//频率
     float           consumption                                 ;//耗电量
     float           factor                                      ;//功率因素    
-    unsigned short  status                                      ;//开关状态          
+    unsigned short  status                                      ;//开关状态     
+    unsigned short  NF_status                                      ;//零线状态              
 }PowerInfo;
 
 //电源部分报警信息
@@ -404,6 +405,7 @@ typedef struct
     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                      ;//通道延时 
     GlobalOverManager*  global_over_manager                        ;//超限管理
@@ -879,8 +881,6 @@ typedef struct
     pthread_mutex_t     dbThreadlock;        //写入线程锁 
     pthread_t           appweb_thread;  //appweb线程
     pthread_t           dev_samp_thread;//电源采集与控制线程
- 
-    unsigned char       view_page ; //前端切换页面 1->总体信息 2->通道信息
     pthread_t           dev_update_thread;//电源采集与控制线程
 
     pthread_t           io_thread;  //IO采集线程

+ 18 - 0
pro/src/json_handle.c

@@ -1480,6 +1480,10 @@ cJSON* json_to_chn_pwr_status_monitor(const char* str,_OverChnPwrRequest* _over_
     if(cjson_type!=NULL)
         _over_chn_pwr_request->type = cjson_type->valuestring;
 
+    cJSON* cjson_Zerotype = cJSON_GetObjectItem(cjson,"Zerotype");
+    if(cjson_Zerotype!=NULL)
+        _over_chn_pwr_request->Zerotype = cjson_Zerotype->valuestring;
+
     cJSON* cjson_product_id = cJSON_GetObjectItem(cjson,"productId");
     if(cjson_product_id!=NULL)    //通道
     {
@@ -2391,7 +2395,15 @@ char* over_chn_pwr_monitor_to_json(_OverChnPwrAckInfo* _over_chn_pwr_back_info)
         // cJSON_AddNumberToObject(data_filed,"productChPowerFactor",_over_chn_pwr_back_info->factor);
         sprintf(temp, "%d", _chnPwrTemp->status);
         cJSON_AddStringToObject(data_filed, "productChStatus", temp);
+         sprintf(temp, "%d", _chnPwrTemp->NF_status);
+        cJSON_AddStringToObject(data_filed, "productChZeroStatus", temp);
+
+        cJSON_AddStringToObject(data_filed, "MACadress","A6:77:15:B8:B7:07");
+        cJSON_AddStringToObject(data_filed, "IPadress","192.168.255.255");
+
         cJSON_AddItemToObject(data_root_array, "data", data_filed);        
+
+
     }
     //添加汇总
     cJSON_AddItemToObject(root, "data", data_root_array);
@@ -3611,6 +3623,12 @@ char* ws_chn_status_ack_to_json(int type,_OverChnPwrAckInfo* _over_chn_pwr_back_
         cJSON_AddItemToObject(sub_data_root_array, "data", data_filed);
         sprintf(temp, "%d", _chnPwrTemp->status);
         cJSON_AddStringToObject(data_filed,"productChStatus",temp);
+         sprintf(temp, "%d", _chnPwrTemp->NF_status);
+        cJSON_AddStringToObject(data_filed,"productChZeroStatus",temp);
+    
+        cJSON_AddStringToObject(data_filed, "MACadress","A6:77:15:B8:B7:07");
+        cJSON_AddStringToObject(data_filed, "IPadress","192.168.255.255");
+        
         if (_chnPwrTemp->product_type == TREE_AC_TYPE||gdm->_global_device_info->product_pwr_type == SmartPDU_Tree_AC_One_B)
         {
             if (_chnPwrTemp->product_phType >= 0 && _chnPwrTemp->product_phType < 3)

+ 2 - 0
pro/src/json_handle.h

@@ -153,6 +153,7 @@ typedef struct
     int productType;
     char* productPhOrder;
     int outputType;
+    char* Zerotype;
 }_OverChnPwrRequest;
 
 /// @brief 总体电源返回信息
@@ -164,6 +165,7 @@ typedef struct
     char*           productChName;
     char            productChId;    
     int             status;
+    int             NF_status;
     float           voltage                                     ;//电压
     float           current                                     ;//电流
     float           power                                       ;//功率

+ 2 - 0
pro/src/sqlite_handle.c

@@ -385,6 +385,7 @@ int dev_search_latest_power_info(sqlite3 *db,int product_id,int product_ch_id,Gl
     _globalPowerInfo->_power_info.freq = atof(pResult[nrow*ncolumn+7]);
     _globalPowerInfo->_power_info.consumption = atof(pResult[nrow*ncolumn+8]);
     _globalPowerInfo->_power_info.factor = atof(pResult[nrow*ncolumn+9]);
+    _globalPowerInfo->_power_info.NF_status=0; 
 
     sqlite3_free_table(pResult);
 
@@ -441,6 +442,7 @@ int dev_search_latest_power_All_info(GlobalDeviceManager* globalDeviceManger,_Ov
                 _overChnPwrBackInfoTemp->productChName = _globalPowerMangerTemp->product_ch_name;
                 _overChnPwrBackInfoTemp->productChId = _globalPowerMangerTemp->product_ch_id;
                 _overChnPwrBackInfoTemp->status = _globalPowerMangerTemp->_PowerInfo.status;
+                _overChnPwrBackInfoTemp->NF_status = _globalPowerMangerTemp->_PowerInfo.NF_status;
                 _overChnPwrBackInfoTemp->voltage = _globalPowerMangerTemp->_PowerInfo.voltage;
                 _overChnPwrBackInfoTemp->current = _globalPowerMangerTemp->_PowerInfo.current;
                 _overChnPwrBackInfoTemp->power = _globalPowerMangerTemp->_PowerInfo.power;

+ 54 - 19
pro/src/switch_ctrl.c

@@ -1605,28 +1605,28 @@ int g_switch_get_t_ac_all_out_info(void* manger,int saddr,int nNumb,PowerInfo* _
     offset = _SWITCH_T_AC_OUT_INFO;
     //读取4个寄存器
 
-    int ret = g_modbus_read_x_reg(manger, saddr, offset, 48, data_temp);
+    int ret = g_modbus_read_x_reg(manger, saddr, offset, 80, data_temp);
     if (ret < 0)
     {
         log_w("g_switch_get_T_ac_in_info:%d OffSet:%d Ret=%d:%s", saddr, offset, ret, modbus_strerror(errno));
         return ret;
     }
-    offset = _SWITCH_T_AC_OUT_INFO+24;
-    unsigned short* DataTemp=data_temp+48;
-    ret = g_modbus_read_x_reg(manger, saddr, offset, 48, DataTemp);
+    offset = _SWITCH_T_AC_OUT_INFO+40;
+    unsigned short* DataTemp=data_temp+80;
+    ret = g_modbus_read_x_reg(manger, saddr, offset, 64, DataTemp);
     if (ret < 0)
-    {
-        log_w("g_switch_get_T_ac_in_info:%d OffSet:%d Ret=%d:%s", saddr, offset, ret, modbus_strerror(errno));
-        return ret;
-    }
-    offset = _SWITCH_T_AC_OUT_INFO+48;
-    DataTemp=data_temp+96;
-    ret = g_modbus_read_x_reg(manger, saddr, offset, 48, DataTemp);
-    if (ret < 0)
-    {
-        log_w("g_switch_get_T_ac_in_info:%d OffSet:%d Ret=%d:%s", saddr, offset, ret, modbus_strerror(errno));
-        return ret;
-    }
+   {
+    log_w("g_switch_get_T_ac_in_info:%d OffSet:%d Ret=%d:%s", saddr, offset, ret, modbus_strerror(errno));
+       return ret;
+    }
+    //offset = _SWITCH_T_AC_OUT_INFO+48;
+    //DataTemp=data_temp+96;
+   // ret = g_modbus_read_x_reg(manger, saddr, offset, 48, DataTemp);
+   // if (ret < 0)
+    //{
+    //    log_w("g_switch_get_T_ac_in_info:%d OffSet:%d Ret=%d:%s", saddr, offset, ret, modbus_strerror(errno));
+     //   return ret;
+   // }
     for (size_t i = 0; i < nNumb; i++)
     {
         int Index = i * 16;
@@ -1653,10 +1653,12 @@ int g_switch_get_t_ac_all_out_info(void* manger,int saddr,int nNumb,PowerInfo* _
         val = (data_temp[15+Index] << 16) + data_temp[14+Index];
         _power[i].factor = val / 1023.0;
     }
-    //获取开关状态
+    //获取通道开关状态及零线状态 
+    //_SWITCH_T_AC_OUT_ENABLE +18
+    //_SWITCH_T_AC_NF_STATUS +2
     offset = _SWITCH_T_AC_OUT_ENABLE;
     memset(data_temp,0,sizeof(data_temp));
-    ret = g_modbus_read_x_reg(manger,saddr,offset, 18,data_temp);
+    ret = g_modbus_read_x_reg(manger,saddr,offset, 20,data_temp);
     if (ret < 0)
     {
         log_w("g_switch_get_T_ac_in_info:%d OffSet:%d Ret=%d:%s", saddr, offset, ret, modbus_strerror(errno));
@@ -1666,9 +1668,22 @@ int g_switch_get_t_ac_all_out_info(void* manger,int saddr,int nNumb,PowerInfo* _
     {
         int Index = i * 2;
         _power[i].status = data_temp[0+Index] & BIT_00;
+        _power[i].NF_status = data_temp[18] & BIT_00;
     }
 
-
+    //获取零线状态
+    /*offset = _SWITCH_T_AC_NF_STATUS;
+    memset(data_temp,0,sizeof(data_temp));
+    ret = g_modbus_read_x_reg(manger,saddr,offset, 2,data_temp);
+    if (ret < 0)
+    {
+        log_w("g_switch_get_T_ac_in_info:%d OffSet:%d Ret=%d:%s", saddr, offset, ret, modbus_strerror(errno));
+        return ret;
+    }
+    for (size_t i = 0; i < nNumb; i++)
+    {
+        _power[i].NF_status = data_temp[18] & BIT_00;
+    }*/
     //获取故障状态
     offset = _SWITCH_T_AC_OUT_ERROR;
     memset(data_temp,0,sizeof(data_temp));
@@ -1870,6 +1885,21 @@ int g_switch_set_t_ac_chn_ctrl(void* manger,int saddr,unsigned char chn,unsigned
     data_temp[0]=sts;
     return g_modbus_write_x_reg(manger,saddr,offset, 2, data_temp);
 }
+
+int g_switch_set_t_ac_chn_NF_ctrl(void* manger,int saddr,unsigned char chn,unsigned short sts)
+{
+    unsigned int offset = 0;
+    if(chn > 3 || chn < 0) return -1;
+    unsigned short data_temp[2]; 
+    memset(data_temp,0,sizeof(data_temp));
+    if(chn>=3)
+        return -1;  
+    offset = _SWITCH_T_AC_NF_STATUS;   
+    data_temp[0]=sts;
+    data_temp[1]=0;
+    return g_modbus_write_x_reg(manger,saddr,offset, 2, data_temp);
+}
+
 int g_switch_set_t_ac_phchn_ctrl(void* manger,int saddr,unsigned char chn,unsigned short sts)
 {
     //三个一组进行设置
@@ -2223,6 +2253,7 @@ int ResetChmData()
                         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);
@@ -2354,6 +2385,7 @@ int ResetChmData()
                         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;
                         _globalPowerMangerTemp->product_ch_stop_delay = 1000;
                         if (dev_insert_power_manage_info(_globalDeviceManager->db,
@@ -2414,6 +2446,7 @@ int ResetChmData()
                         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);
@@ -2485,6 +2518,7 @@ int ResetChmData()
                             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);
@@ -2605,6 +2639,7 @@ int ResetChmData()
                                 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);

+ 3 - 1
pro/src/switch_ctrl.h

@@ -68,7 +68,8 @@ enum MODBUS_MODE
 #define _SWITCH_T_AC_IN_INFO               0x1771          //三项交流输入
 #define _SWITCH_T_AC_OUT_INFO              0x177D          //三项交流输出
 #define _SWITCH_T_AC_OUT_ENABLE            0x182E          //三项交流输出按通道开关状态及控制使能
-#define _SWITCH_T_AC_CH_OUT_ENABLE         0x183A          //三项交流输出按插头开关状态及控制使能
+#define _SWITCH_T_AC_NF_STATUS            0x1837          //三项交流零线断路器状态
+#define _SWITCH_T_AC_CH_OUT_ENABLE         0x183A          //三项交流延时时间
 #define _SWITCH_T_AC_IN_ENABLE             0x182D          //三项交流输入超限使能
 #define _SWITCH_T_AC_OUT_ERROR             0x17DE          //三项交流输出故障状态
 #define _SWITCH_T_AC_IN_ERROR              0x17DD          //三项交流输入故障状态
@@ -148,6 +149,7 @@ int g_switch_set_t_ac_max_pwrcon_threshold(void* manger,int saddr,char chn,Globa
 int g_switch_set_t_ac_start_time_delay(void* manger,int saddr,int ch, unsigned int time);
 int g_switch_set_t_ac_stop_time_delay(void* manger,int saddr,int ch, unsigned int time);
 int g_switch_set_t_ac_chn_ctrl(void* manger,int saddr,unsigned char chn,unsigned short sts);
+int g_switch_set_t_ac_chn_NF_ctrl(void* manger,int saddr,unsigned char chn,unsigned short sts);
 int g_switch_set_t_ac_phchn_ctrl(void* manger,int saddr,unsigned char chn,unsigned short sts);
 int g_switch_set_t_ac_ctrl(void* manger,int saddr,unsigned short* sts);