Quellcode durchsuchen

梳理配置文件导入导出接口

guohui vor 1 Jahr
Ursprung
Commit
7273db1657
5 geänderte Dateien mit 1049 neuen und 1702 gelöschten Zeilen
  1. 0 8
      pro/src/appweb_handle.c
  2. 9 9
      pro/src/common.h
  3. 848 1678
      pro/src/paras.c
  4. 190 7
      pro/src/sqlite_handle.c
  5. 2 0
      pro/src/sqlite_handle.h

+ 0 - 8
pro/src/appweb_handle.c

@@ -5028,15 +5028,11 @@ static void systemManagent(void *conn)
             {
                 new_user->userID = nMaxUserNum + 1;
 
-                new_user->userName = malloc(256);
                 strcpy(new_user->userName, _UserRoleManageRequestInfo.userName);
-                new_user->userPW = malloc(256);
                 strcpy(new_user->userPW, _UserRoleManageRequestInfo.password);
-                new_user->nickName = malloc(256);
                 strcpy(new_user->nickName, _UserRoleManageRequestInfo.nickName);
                 new_user->roleID = _UserRoleManageRequestInfo.roleId; // GetRoleIDByName(_UserRoleManageRequestInfo.roleName,&Role_list);
 
-                new_user->createTime = malloc(64);
                 struct tm *t;
                 struct timeval tv;
                 gettimeofday(&tv, NULL);
@@ -5084,14 +5080,10 @@ static void systemManagent(void *conn)
 
         new_user->product_id =  __globalDeviceManage._globalDevInfo.product.id;
         new_user->userID = _UserRoleManageRequestInfo.userId;
-        new_user->userName = malloc(256);
         strcpy(new_user->userName , _UserRoleManageRequestInfo.userName);
-        new_user->userPW = malloc(256);
         strcpy(new_user->userPW , _UserRoleManageRequestInfo.password);
-        new_user->nickName = malloc(256);
         strcpy(new_user->nickName , _UserRoleManageRequestInfo.nickName);
         new_user->roleID = _UserRoleManageRequestInfo.roleId;
-        new_user->createTime = malloc(64);
         strcpy(new_user->createTime , _UserRoleManageRequestInfo.createTime);
 
         dev_update_user_info(__globalDeviceManage.db, new_user);

+ 9 - 9
pro/src/common.h

@@ -440,8 +440,8 @@ typedef struct
 {
     int                 product_id;
     int                 GroupID;
-    char               GroupName[64];
-    char               GroupChList[512];
+    char                GroupName[64];
+    char                GroupChList[512];
     struct list_head    list;  
 }GroupInfo;
 
@@ -738,11 +738,11 @@ typedef struct
 {
     int                 product_id;
     int                 userID;    				//用户ID
-    char*               userName;               //用户名-登录
-    char*               userPW; 		        //用户密码
-    char*               nickName; 			    //用户名称
+    char                userName[32];           //用户名-登录
+    char                userPW[32]; 		    //用户密码
+    char                nickName[32]; 			//用户名称
     int                 roleID;    		        //角色ID
-    char*               createTime;             //用户创建时间     
+    char                createTime[32];         //用户创建时间     
     struct list_head    list;
 
 }UserInfo;
@@ -751,11 +751,11 @@ typedef struct
 {
     int                 product_id;
     int                 roleID;    				//角色ID
-    char*               roleName;               //角色名称
+    char                roleName[32];           //角色名称
     int                 roleLevel; 		        //角色等级
-    char*               roleAuthority; 			//角色权限
+    char                roleAuthority[32]; 		//角色权限
     int                 roleSort;    		    //显示顺序
-    char*               createTime;             //创建时间     
+    char                createTime[32];         //创建时间     
     struct list_head    list;
 
 }RoleInfo;

Datei-Diff unterdrückt, da er zu groß ist
+ 848 - 1678
pro/src/paras.c


+ 190 - 7
pro/src/sqlite_handle.c

@@ -1390,6 +1390,103 @@ int dev_insert_power_manage_info(sqlite3 *db,int product_id,int product_ch_id,Gl
 }
 
 
+int dev_get_power_info(sqlite3 *db,GlobalPowerManger* pm)
+{
+    int res = 0 ;
+    int rowIndex = 1 ;
+    char *errorMsg = NULL;
+    int nrow = 0;               //满足条件的记录数目
+    int ncolumn = 0;            //每条记录包含的字段数据
+    char** pResult = NULL;  //用来指向sql执行结果的指针
+    char* err_msg=NULL;
+    char select_sql[1024] = {0};
+
+    sprintf(select_sql,"SELECT * FROM Table_PowerManage ORDER BY product_ch_id ASC;");
+    res = sqlite3_get_table(db, select_sql, &pResult, &nrow, &ncolumn, &err_msg);
+    if(res != SQLITE_OK) {
+        log_e("sqlite handle error: %s\n%s\n", err_msg,select_sql); sqlite3_free(err_msg);
+        return -2 ;
+    }
+    //提取数据
+    if(nrow==0) {
+        sqlite3_free_table(pResult);
+        return -1 ; 
+    }
+
+    for (rowIndex=1; rowIndex<=nrow; rowIndex++) {
+        GlobalPowerManger *tmp=(GlobalPowerManger*)calloc(1,sizeof(GlobalPowerManger));
+        if(!tmp) {
+            sqlite3_free_table(pResult);
+            return -1;
+        }
+
+        tmp->product_id = atoi(pResult[rowIndex*ncolumn+0]); 
+        //获取产品ID
+        tmp->product_ch_id = atoi(pResult[rowIndex*ncolumn+1]); 
+        //获取通道名称
+        strcpy(tmp->product_ch_name,pResult[rowIndex*ncolumn+2]);
+        //获取通道类型
+        tmp->product_ch_type = atoi(pResult[rowIndex*ncolumn+3]);
+        //获取通道状态
+        tmp->product_ch_status = atoi(pResult[rowIndex*ncolumn+4]);  
+        //获取通道延时
+        tmp->product_ch_start_delay = atoi(pResult[rowIndex*ncolumn+5]);     
+        //获取通道延时
+        tmp->product_ch_stop_delay = atoi(pResult[rowIndex*ncolumn+6]);       
+        
+        //获取电压超上限使能
+        tmp->global_over_manager.product_vol_upper_enable = atoi(pResult[rowIndex*ncolumn+7]); 
+        //获取电压上限范围
+        tmp->global_over_manager.product_vol_upper_threshold = atof(pResult[rowIndex*ncolumn+8]);
+        //获取电压上限超限动作
+        tmp->global_over_manager.product_vol_over_upper_threshold_ctrl = atoi(pResult[rowIndex*ncolumn+9]);
+        //获取电压上限超限关联参数
+        tmp->global_over_manager.product_vol_over_upper_threshold_ctrl_para = atoi(pResult[rowIndex*ncolumn+10]);
+        //获取电压超下限使能
+        tmp->global_over_manager.product_vol_lower_enable = atoi(pResult[rowIndex*ncolumn+11]); 
+        //获取电压下限范围
+        tmp->global_over_manager.product_vol_lower_threshold = atof(pResult[rowIndex*ncolumn+12]);
+        //获取电压下限超限动作
+        tmp->global_over_manager.product_vol_over_lower_threshold_ctrl = atoi(pResult[rowIndex*ncolumn+13]); 
+        //超限关联参数
+        tmp->global_over_manager.product_vol_over_lower_threshold_ctrl_para = atoi(pResult[rowIndex*ncolumn+14]);
+        //获取电流超上限使能
+        tmp->global_over_manager.product_cur_upper_enable = atoi(pResult[rowIndex*ncolumn+15]); 
+        //获取电流上限范围
+        tmp->global_over_manager.product_cur_upper_threshold = atof(pResult[rowIndex*ncolumn+16]);
+        //获取电流上限超限动作
+        tmp->global_over_manager.product_cur_over_upper_threshold_ctrl = atoi(pResult[rowIndex*ncolumn+17]); 
+        //超限关联参数
+        tmp->global_over_manager.product_cur_over_upper_threshold_ctrl_para = atoi(pResult[rowIndex*ncolumn+18]);
+        //获取功耗超上限使能
+        tmp->global_over_manager.product_pwr_upper_enable = atoi(pResult[rowIndex*ncolumn+19]); 
+        //获取功耗上限范围
+        tmp->global_over_manager.product_pwr_upper_threshold = atof(pResult[rowIndex*ncolumn+20]);
+        //获取功耗上限超限动作
+        tmp->global_over_manager.product_pwr_over_upper_threshold_ctrl = atoi(pResult[rowIndex*ncolumn+21]); 
+        //超限关联参数
+        tmp->global_over_manager.product_pwr_over_upper_threshold_ctrl_para = atoi(pResult[rowIndex*ncolumn+22]);
+        //获取耗电量超上限使能
+        tmp->global_over_manager.product_pwrcon_upper_enable = atoi(pResult[rowIndex*ncolumn+23]); 
+        //获取耗电量上限范围
+        tmp->global_over_manager.product_pwrcon_upper_threshold = atof(pResult[rowIndex*ncolumn+24]);
+        //获取耗电量上限超限动作
+        tmp->global_over_manager.product_pwrcon_over_upper_threshold_ctrl = atoi(pResult[rowIndex*ncolumn+25]); 
+        //超限关联参数
+        tmp->global_over_manager.product_pwrcon_over_upper_threshold_ctrl_para = atoi(pResult[rowIndex*ncolumn+26]); 
+        //获取板ID
+        tmp->product_saddr = atoi(pResult[rowIndex*ncolumn+27]); 
+        //获取板TYPE
+        tmp->product_ch_addr = atoi(pResult[rowIndex*ncolumn+28]);
+
+        list_add_tail(&tmp->list, &pm->list);
+    }
+    sqlite3_free_table(pResult);
+
+    return 0;
+}
+
+
 /// @brief 查询电源通道管理信息
 /// @param db 
 /// @param product_id 
@@ -1538,6 +1635,99 @@ int dev_insert_t_ac_power_manage_info(sqlite3 *db,int product_id,int product_ch_
     return 0;
 }
 
+
+int dev_get_ac_power_info(sqlite3 *db,GlobalTreeACManager* pm)
+{
+    int res = 0 ;
+    int rowIndex = 1 ;
+    char *errorMsg = NULL;
+    int nrow = 0;               //满足条件的记录数目
+    int ncolumn = 0;            //每条记录包含的字段数据
+    char** pResult = NULL;  //用来指向sql执行结果的指针
+    char* err_msg=NULL;
+    char select_sql[1024] = {0};
+
+    sprintf(select_sql,"SELECT * FROM Table_PhasePowerManage ORDER BY product_ch_addr_ch_id ASC;");
+    res = sqlite3_get_table(db, select_sql, &pResult, &nrow, &ncolumn, &err_msg);
+    if(res != SQLITE_OK) {
+        log_e("sqlite handle error: %s\n%s\n", err_msg,select_sql); sqlite3_free(err_msg);
+        return -2 ;
+    }
+    //提取数据
+    if(nrow==0) {
+        sqlite3_free_table(pResult);
+        return -1 ;
+    }
+
+    for (rowIndex=1; rowIndex<=nrow; rowIndex++) {
+        GlobalTreeACManager *tmp=(GlobalTreeACManager*)calloc(1,sizeof(GlobalTreeACManager));
+        if(!tmp) {
+            sqlite3_free_table(pResult);
+            return -1;
+        }
+        tmp->product_id = atoi(pResult[rowIndex*ncolumn+0]); 
+        //获取三相通道ID
+        tmp->product_ph_id = atoi(pResult[rowIndex*ncolumn+1]); 
+        //获取三相通道类型
+        tmp->product_ph_type = atoi(pResult[rowIndex*ncolumn+2]); 
+        //获取绑定通道信息
+        tmp->product_ch_id = atoi(pResult[rowIndex*ncolumn+3]);
+        //获取实际三相通道位置版id
+        tmp->product_saddr = atoi(pResult[rowIndex*ncolumn+4]);  
+        //获取实际三相通道位置偏移
+        tmp->product_ch_addr = atoi(pResult[rowIndex*ncolumn+5]);     
+        //获取电压超上限使能
+        tmp->global_over_manager.product_vol_upper_enable = atoi(pResult[rowIndex*ncolumn+6]); 
+        //获取电压上限范围
+        tmp->global_over_manager.product_vol_upper_threshold = atof(pResult[rowIndex*ncolumn+7]);
+        //获取电压上限超限动作
+        tmp->global_over_manager.product_vol_over_upper_threshold_ctrl = atoi(pResult[rowIndex*ncolumn+8]);
+        //获取电压上限超限关联参数
+        tmp->global_over_manager.product_vol_over_upper_threshold_ctrl_para = atoi(pResult[rowIndex*ncolumn+9]);
+        //获取电压超下限使能
+        tmp->global_over_manager.product_vol_lower_enable = atoi(pResult[rowIndex*ncolumn+10]); 
+        //获取电压下限范围
+        tmp->global_over_manager.product_vol_lower_threshold = atof(pResult[rowIndex*ncolumn+11]);
+        //获取电压下限超限动作
+        tmp->global_over_manager.product_vol_over_lower_threshold_ctrl = atoi(pResult[rowIndex*ncolumn+12]); 
+        //超限关联参数
+        tmp->global_over_manager.product_vol_over_lower_threshold_ctrl_para = atoi(pResult[rowIndex*ncolumn+13]);
+        //获取电流超上限使能
+        tmp->global_over_manager.product_cur_upper_enable = atoi(pResult[rowIndex*ncolumn+14]); 
+        //获取电流上限范围
+        tmp->global_over_manager.product_cur_upper_threshold = atof(pResult[rowIndex*ncolumn+15]);
+        //获取电流上限超限动作
+        tmp->global_over_manager.product_cur_over_upper_threshold_ctrl = atoi(pResult[rowIndex*ncolumn+16]); 
+        //超限关联参数
+        tmp->global_over_manager.product_cur_over_upper_threshold_ctrl_para = atoi(pResult[rowIndex*ncolumn+17]);
+        //获取功耗超上限使能
+        tmp->global_over_manager.product_pwr_upper_enable = atoi(pResult[rowIndex*ncolumn+18]); 
+        //获取功耗上限范围
+        tmp->global_over_manager.product_pwr_upper_threshold = atof(pResult[rowIndex*ncolumn+19]);
+        //获取功耗上限超限动作
+        tmp->global_over_manager.product_pwr_over_upper_threshold_ctrl = atoi(pResult[rowIndex*ncolumn+20]); 
+        //超限关联参数
+        tmp->global_over_manager.product_pwr_over_upper_threshold_ctrl_para = atoi(pResult[rowIndex*ncolumn+21]);
+        //获取耗电量超上限使能
+        tmp->global_over_manager.product_pwrcon_upper_enable = atoi(pResult[rowIndex*ncolumn+22]); 
+        //获取耗电量上限范围
+        tmp->global_over_manager.product_pwrcon_upper_threshold = atof(pResult[rowIndex*ncolumn+23]);
+        //获取耗电量上限超限动作
+        tmp->global_over_manager.product_pwrcon_over_upper_threshold_ctrl = atoi(pResult[rowIndex*ncolumn+24]); 
+        //超限关联参数
+        tmp->global_over_manager.product_pwrcon_over_upper_threshold_ctrl_para = atoi(pResult[rowIndex*ncolumn+25]); 
+        
+        tmp->product_ph_outputType = atoi(pResult[rowIndex*ncolumn+26]); 
+            
+        tmp->product_ph_outputStatus = atoi(pResult[rowIndex*ncolumn+27]); 
+
+        list_add_tail(&tmp->list_Tree_AC, &pm->list_Tree_AC);
+    }
+    sqlite3_free_table(pResult);
+    return 0;
+}
+
+
 /// @brief 获取三项通道基本管理信息
 /// @param db 
 /// @param product_id 
@@ -3262,14 +3452,10 @@ int dev_get_user_info(sqlite3 *db, UserInfo* _globaluserInfo)
         }
         new_user->product_id = __globalDeviceManage._globalDevInfo.product.id;
         new_user->userID =  atoi(pResult[i*ncolumn+1]);
-        new_user->userName = malloc(256);
         strcpy(new_user->userName,pResult[i*ncolumn+2]);
-        new_user->userPW = malloc(256);
         strcpy(new_user->userPW,pResult[i*ncolumn+3]);
-        new_user->nickName = malloc(256);
         strcpy(new_user->nickName,pResult[i*ncolumn+4]);
         new_user->roleID =  atoi(pResult[i*ncolumn+5]);
-        new_user->createTime = malloc(64);
         strcpy(new_user->createTime,pResult[i*ncolumn+6]);
         list_add_tail(&new_user->list, &_globaluserInfo->list);
     }
@@ -3398,13 +3584,10 @@ int dev_get_role_info(sqlite3 *db, RoleInfo* _globalRoleInfo)
         }
         new_role->product_id = __globalDeviceManage._globalDevInfo.product.id;
         new_role->roleID =  atoi(pResult[i*ncolumn+1]);
-        new_role->roleName = malloc(256);
         strcpy(new_role->roleName,pResult[i*ncolumn+2]);
         new_role->roleLevel =  atoi(pResult[i*ncolumn+3]);
-        new_role->roleAuthority = malloc(256);
         strcpy(new_role->roleAuthority,pResult[i*ncolumn+4]);
         new_role->roleSort =  atoi(pResult[i*ncolumn+5]);
-        new_role->createTime = malloc(64);
         strcpy(new_role->createTime,pResult[i*ncolumn+6]);
         list_add_tail(&new_role->list, &_globalRoleInfo->list);
     }

+ 2 - 0
pro/src/sqlite_handle.h

@@ -52,9 +52,11 @@ int dev_search_power_info(sqlite3 *db,
 
 int dev_check_power_manage_info(sqlite3 *db, int cnt);
 int dev_insert_power_manage_info(sqlite3 *db,int product_id,int product_ch_id,GlobalPowerManger* _globalPowerChnManger);
+int dev_get_power_info(sqlite3 *db,GlobalPowerManger* pm);
 int dev_get_power_manage_info(sqlite3 *db,int product_id,int product_addr,int product_ch_id,GlobalPowerManger* _globalPowerChnManger);
 int dev_get_power_manage_info_by_ID(sqlite3 *db,int product_id,int product_addr,int product_ch_id,GlobalPowerManger* _globalPowerChnManger);
 
+int dev_get_ac_power_info(sqlite3 *db,GlobalTreeACManager* pm);
 int dev_get_t_ac_power_manage_info(sqlite3 *db,int product_id,int product_addr,int product_ch_id,int product_ph_type,GlobalTreeACManager* _globalPowerChnManger);
 int dev_insert_t_ac_power_manage_info(sqlite3 *db,int product_id,int product_ch_id,GlobalTreeACManager* _globalPowerChnManger);
 int dev_insert_t_ac_power_info(sqlite3 *db,GlobalTreeACManager* _globalPowerChnInfo,int* nIndex);