|
|
@@ -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);
|
|
|
}
|