优化这段代码 if( DBData[i] >= RT1064KZZ_GL1_ALM && DBData[i] <= RT1064KZZ_KZHL && DBData[i] != RT1064KZZ_MODE && DBData[i] != RT1064KZZ_UAB_CH && DBData[i] != RT1064KZZ_UBC_CH && DBData[i] != RT1064KZZ_FBS && DBData[i] != RT1064KZZ_FBS_MODE) { LCD_DisString((i%9)+1, 20, (char *)gcszOnOff[(int)get_ActionDZInfo_val(UNIT_GAP_RT1064,gapid,DBData[i])]); if (not == 2) { if(draw == (i+1)) { LCD_DisString_Not((i%9)+1, 20, (char *)gcszOnOff[(int)get_ActionDZInfo_val(UNIT_GAP_RT1064,gapid,DBData[i])]); } } } else if(DBData[i] == RT1064KZZ_MODE) { LCD_DisString((i%9)+1, 20, (char *)ModeName[(int)get_ActionDZInfo_val(UNIT_GAP_RT1064,gapid,DBData[i])]); if (not == 2) { if(draw == (i+1)) { LCD_DisString_Not((i%9)+1, 20, (char *)ModeName[(int)get_ActionDZInfo_val(UNIT_GAP_RT1064,gapid,DBData[i])]); } } } else if (DBData[i] == RT1064KZZ_FBS || DBData[i] == RT1064KZZ_FBS_MODE ) { if (DBData[i] == RT1064KZZ_FBS) { LCD_DisString((i%9)+1, 20, (char *)FBS_NAME[(int)get_ActionDZInfo_val(UNIT_GAP_RT1064,gapid,DBData[i])]); if (not == 2) { if(draw == (i+1)) { LCD_DisString_Not((i%9)+1, 20, (char *)FBS_NAME[(int)get_ActionDZInfo_val(UNIT_GAP_RT1064,gapid,DBData[i])]); } } } else if(DBData[i] == RT1064KZZ_FBS_MODE ) { LCD_DisString((i%9)+1, 20, (char *)FBS_MODE_NAME[(int)get_ActionDZInfo_val(UNIT_GAP_RT1064,gapid,DBData[i])]); if (not == 2) { if(draw == (i+1)) { LCD_DisString_Not((i%9)+1, 20, (char *)FBS_MODE_NAME[(int)get_ActionDZInfo_val(UNIT_GAP_RT1064,gapid,DBData[i])]); } } } } else if(DBData[i] == RT1064KZZ_UAB_CH || DBData[i] == RT1064KZZ_UBC_CH || DBData[i] == RT1064_DZ_CHZCS) { sprintf(szVal, "%0.f" , get_ActionDZInfo_val(UNIT_GAP_RT1064,gapid,DBData[i])); LCD_DisString((i%9)+1, 19 , szVal); if(DBData[i] == RT1064_DZ_CHZCS) LCD_DisString((i%9)+1, 24, (char *)"次"); if (not == 2) { if(draw == (i+1)) { len = LCD_BitNot(UNIT_PROTECT,UNIT_GAP_RT1064,gapid,DBData[i],i,bit); } } }

时间: 2024-02-03 14:11:38 浏览: 18
可以考虑将重复的代码抽象成一个函数,然后在需要的地方调用该函数。具体来说,可以把以下部分抽象成一个函数: ``` LCD_DisString((i%9)+1, 20, (char *)gcszOnOff[(int)get_ActionDZInfo_val(UNIT_GAP_RT1064,gapid,DBData[i])]); if (not == 2) { if(draw == (i+1)) { LCD_DisString_Not((i%9)+1, 20, (char *)gcszOnOff[(int)get_ActionDZInfo_val(UNIT_GAP_RT1064,gapid,DBData[i])]); } } ``` 然后可以把其他类似的代码也进行抽象。这样可以大大简化代码,增强可读性。
相关问题

优化这段代码 if( DBData[i] >= RT1064KZZ_GL1_ALM && DBData[i] <= RT1064KZZ_KZHL && DBData[i] != RT1064KZZ_MODE && DBData[i] != RT1064KZZ_UAB_CH && DBData[i] != RT1064KZZ_UBC_CH && DBData[i] != RT1064KZZ_FBS && DBData[i] != RT1064KZZ_FBS_MODE) { (isDraw ? LCD_DisString_Not((i%LISTOFFSET)+1, 20,(char *)gcszOnOff[(int)val]) : LCD_DisString((i%LISTOFFSET)+1, 20,(char *)gcszOnOff[(int)val]) ); } else if(DBData[i] == RT1064KZZ_MODE) { (isDraw ? LCD_DisString_Not((i%LISTOFFSET)+1, 20,(char *)ModeName[(int)val]) : LCD_DisString((i%LISTOFFSET)+1, 20,(char *)ModeName[(int)val]) ); } else if (DBData[i] == RT1064KZZ_FBS || DBData[i] == RT1064KZZ_FBS_MODE ) { (isDraw ? LCD_DisString_Not((i%LISTOFFSET)+1, 20,(char *)FBS_NAME[(int)val]) : LCD_DisString((i%LISTOFFSET)+1, 20,(char *)FBS_NAME[(int)val]) ); } else if(DBData[i] == RT1064KZZ_UAB_CH || DBData[i] == RT1064KZZ_UBC_CH || DBData[i] == RT1064_DZ_CHZCS) { sprintf(szVal, "%0.f" , val); LCD_DisString((i%LISTOFFSET)+1, 19 , szVal); if(DBData[i] == RT1064_DZ_CHZCS) LCD_DisString((i%LISTOFFSET)+1, 24, (char *)"次"); if (isDraw == 1) len = LCD_BitNot(UNIT_PROTECT,UNIT_GAP_RT1064,gapid,DBData[i],i,bit); } else { sprintf(szVal, "%0.3f" , get_ActionDZInfo_val(UNIT_GAP_RT1064,gapid,DBData[i])); LCD_DisString((i%LISTOFFSET)+1, 19, szVal); if (DBData[i] >= RT1064_YS_GL1 && DBData[i] <= RT1064_YS_FBS_JY) LCD_DisString((i%9)+1, 25, (char *)"S"); else if ((DBData[i] >= RT1064_DZ_GL1 && DBData[i] <= RT1064_DZ_I02) || ((DBData[i] >= RT1064_DZ_PHASE_I && DBData[i] <= RT1064_DZ_I0DLT) && DBData[i] != RT1064_DZ_YL_HAR && DBData[i] != RT1064_DZ_LMJ) || DBData[i] == RT1064_DZ_SD || DBData[i] == RT1064_DZ_I0HJS || DBData[i] == RT1064_DZ_FC_CHZ || (DBData[i] >= RT1064_DZ_I03 && DBData[i] <= RT1064_DZ_FBS_I0)|| DBData[i] == RT1064_DZ_FBS_OL) { LCD_DisString((i%LISTOFFSET)+1, 25, (char *)"A"); } else if (DBData[i] == RT1064_DZ_LMJ || DBData[i] == RT1064_DZ_JC || DBData[i] == RT1064_DZ_GYJC) { LCD_DisString((i%LISTOFFSET)+1, 25, (char *)"°"); } else if (DBData[i] == RT1064_DZ_YL_HAR) LCD_DisString((i%LISTOFFSET)+1, 25, (char *)"%"); else if (DBData[i] == RT1064_DZ_IDS ||DBData[i] == RT1064_DZ_OPENCS || (DBData[i] >= RT1064_DZ_I03 && DBData[i] <= RT1064_DZ_FBS_I0)) { LCD_DisString((i%LISTOFFSET)+1, 24, (char *)"次"); } else if (DBData[i] == RT1064_DZ_DP || DBData[i] == RT1064_DZ_GP) { LCD_DisString((i%LISTOFFSET)+1, 25, (char *)"HZ"); } else LCD_DisString((i%LISTOFFSET)+1, 25, (char *)"V"); if (isDraw == 1)len = LCD_BitNot(UNIT_PROTECT,UNIT_GAP_RT1064,gapid,DBData[i],i,bit); }

这段代码可以优化的地方有: 1. 将重复的代码提取出来,避免重复书写。例如,多次调用 `LCD_DisString` 可以提取出来作为一个函数,减少代码重复。 2. 将一些条件语句的判断条件提取出来,避免重复书写。例如,多次使用 `DBData[i]` 的值进行判断,可以将它提取出来,避免重复书写。 3. 使用 switch 语句来替换多个 if-else 语句,使代码更加清晰。 4. 对于 `sprintf(szVal, "%0.3f" , get_ActionDZInfo_val(UNIT_GAP_RT1064,gapid,DBData[i]))` 这一行代码,可以考虑使用 snprintf 函数来避免缓冲区溢出。 下面是一个优化后的代码示例: ``` void displayData(int i, int isDraw, float val, char* szVal, int len) { if (DBData[i] >= RT1064KZZ_GL1_ALM && DBData[i] <= RT1064KZZ_KZHL && DBData[i] != RT1064KZZ_MODE && DBData[i] != RT1064KZZ_UAB_CH && DBData[i] != RT1064KZZ_UBC_CH && DBData[i] != RT1064KZZ_FBS && DBData[i] != RT1064KZZ_FBS_MODE) { displayString(i, isDraw, val, gcszOnOff, (i % LISTOFFSET) + 1, 20); } else if (DBData[i] == RT1064KZZ_MODE) { displayString(i, isDraw, val, ModeName, (i % LISTOFFSET) + 1, 20); } else if (DBData[i] == RT1064KZZ_FBS || DBData[i] == RT1064KZZ_FBS_MODE) { displayString(i, isDraw, val, FBS_NAME, (i % LISTOFFSET) + 1, 20); } else if (DBData[i] == RT1064KZZ_UAB_CH || DBData[i] == RT1064KZZ_UBC_CH || DBData[i] == RT1064_DZ_CHZCS) { snprintf(szVal, sizeof(szVal), "%0.f", val); LCD_DisString((i % LISTOFFSET) + 1, 19, szVal); if (DBData[i] == RT1064_DZ_CHZCS) { LCD_DisString((i % LISTOFFSET) + 1, 24, (char *)"次"); } if (isDraw == 1) { len = LCD_BitNot(UNIT_PROTECT, UNIT_GAP_RT1064, gapid, DBData[i], i, bit); } } else { snprintf(szVal, sizeof(szVal), "%0.3f", get_ActionDZInfo_val(UNIT_GAP_RT1064, gapid, DBData[i])); LCD_DisString((i % LISTOFFSET) + 1, 19, szVal); if (DBData[i] >= RT1064_YS_GL1 && DBData[i] <= RT1064_YS_FBS_JY) { LCD_DisString((i % 9) + 1, 25, (char *)"S"); } else if ((DBData[i] >= RT1064_DZ_GL1 && DBData[i] <= RT1064_DZ_I02) || ((DBData[i] >= RT1064_DZ_PHASE_I && DBData[i] <= RT1064_DZ_I0DLT) && DBData[i] != RT1064_DZ_YL_HAR && DBData[i] != RT1064_DZ_LMJ) || DBData[i] == RT1064_DZ_SD || DBData[i] == RT1064_DZ_I0HJS || DBData[i] == RT1064_DZ_FC_CHZ || (DBData[i] >= RT1064_DZ_I03 && DBData[i] <= RT1064_DZ_FBS_I0)|| DBData[i] == RT1064_DZ_FBS_OL) { LCD_DisString((i % LISTOFFSET) + 1, 25, (char *)"A"); } else if (DBData[i] == RT1064_DZ_LMJ || DBData[i] == RT1064_DZ_JC || DBData[i] == RT1064_DZ_GYJC) { LCD_DisString((i % LISTOFFSET) + 1, 25, (char *)"°"); } else if (DBData[i] == RT1064_DZ_YL_HAR) { LCD_DisString((i % LISTOFFSET) + 1, 25, (char *)"%"); } else if (DBData[i] == RT1064_DZ_IDS || DBData[i] == RT1064_DZ_OPENCS || (DBData[i] >= RT1064_DZ_I03 && DBData[i] <= RT1064_DZ_FBS_I0)) { LCD_DisString((i % LISTOFFSET) + 1, 24, (char *)"次"); } else if (DBData[i] == RT1064_DZ_DP || DBData[i] == RT1064_DZ_GP) { LCD_DisString((i % LISTOFFSET) + 1, 25, (char *)"HZ"); } else { LCD_DisString((i % LISTOFFSET) + 1, 25, (char *)"V"); } if (isDraw == 1) { len = LCD_BitNot(UNIT_PROTECT, UNIT_GAP_RT1064, gapid, DBData[i], i, bit); } } } void displayString(int i, int isDraw, float val, char** stringArray, int x, int y) { (isDraw ? LCD_DisString_Not(x, y, (char *)stringArray[(int)val]) : LCD_DisString(x, y, (char *)stringArray[(int)val])); } ```

帮我优化这段代码 val = get_ActionDZInfo_val(UNIT_GAP_RT1064,gapid,DBData[i]); if( DBData[i] >= RT1064KZZ_GL1_ALM && DBData[i] <= RT1064KZZ_KZHL && DBData[i] != RT1064KZZ_MODE && DBData[i] != RT1064KZZ_UAB_CH && DBData[i] != RT1064KZZ_UBC_CH && DBData[i] != RT1064KZZ_FBS && DBData[i] != RT1064KZZ_FBS_MODE) { displayString(isDraw,gcszOnOff[(int)val],(i%LISTOFFSET)+1,20); } else if(DBData[i] == RT1064KZZ_MODE) { displayString(isDraw,ModeName[(int)val],(i%LISTOFFSET)+1,20); } else if (DBData[i] == RT1064KZZ_FBS || DBData[i] == RT1064KZZ_FBS_MODE ) { displayString(isDraw,(DBData[i] == RT1064KZZ_FBS ?FBS_NAME[(int)val] :FBS_MODE_NAME[(int)val]),(i%LISTOFFSET)+1,20); } else if(DBData[i] == RT1064KZZ_UAB_CH || DBData[i] == RT1064KZZ_UBC_CH || DBData[i] == RT1064_DZ_CHZCS) { sprintf(szVal, "%0.f" , val); LCD_DisString((i%LISTOFFSET)+1, 19 , szVal); if(DBData[i] == RT1064_DZ_CHZCS) LCD_DisString((i%LISTOFFSET)+1, 24, (char *)"次"); if (isDraw == 1) len = LCD_BitNot(UNIT_PROTECT,UNIT_GAP_RT1064,gapid,DBData[i],i,bit); } else { sprintf(szVal, "%0.3f" , get_ActionDZInfo_val(UNIT_GAP_RT1064,gapid,DBData[i])); LCD_DisString((i%LISTOFFSET)+1, 19, szVal); if (DBData[i] >= RT1064_YS_GL1 && DBData[i] <= RT1064_YS_FBS_JY) LCD_DisString((i%9)+1, 25, (char *)"S"); else if ((DBData[i] >= RT1064_DZ_GL1 && DBData[i] <= RT1064_DZ_I02) || ((DBData[i] >= RT1064_DZ_PHASE_I && DBData[i] <= RT1064_DZ_I0DLT) && DBData[i] != RT1064_DZ_YL_HAR && DBData[i] != RT1064_DZ_LMJ) || DBData[i] == RT1064_DZ_SD || DBData[i] == RT1064_DZ_I0HJS || DBData[i] == RT1064_DZ_FC_CHZ || (DBData[i] >= RT1064_DZ_I03 && DBData[i] <= RT1064_DZ_FBS_I0)|| DBData[i] == RT1064_DZ_FBS_OL) { LCD_DisString((i%LISTOFFSET)+1, 25, (char *)"A"); } else if (DBData[i] == RT1064_DZ_LMJ || DBData[i] == RT1064_DZ_JC || DBData[i] == RT1064_DZ_GYJC) { LCD_DisString((i%LISTOFFSET)+1, 25, (char *)"°"); } else if (DBData[i] == RT1064_DZ_YL_HAR) LCD_DisString((i%LISTOFFSET)+1, 25, (char *)"%"); else if (DBData[i] == RT1064_DZ_IDS ||DBData[i] == RT1064_DZ_OPENCS || (DBData[i] >= RT1064_DZ_I03 && DBData[i] <= RT1064_DZ_FBS_I0)) { LCD_DisString((i%LISTOFFSET)+1, 24, (char *)"次"); } else if (DBData[i] == RT1064_DZ_DP || DBData[i] == RT1064_DZ_GP) { LCD_DisString((i%LISTOFFSET)+1, 25, (char *)"HZ"); } else LCD_DisString((i%LISTOFFSET)+1, 25, (char *)"V"); if (isDraw == 1)len = LCD_BitNot(UNIT_PROTECT,UNIT_GAP_RT1064,gapid,DBData[i],i,bit); }

首先,可以看到在代码中有很多重复的部分,比如调用`get_ActionDZInfo_val`函数、调用`sprintf`函数、调用`LCD_DisString`函数等。我们可以将这些重复的部分抽象成一个函数,减少代码的冗余。 其次,可以将一些常量和字符串存储到数组中,这样可以减少代码中的硬编码,提高可读性和可维护性。 最后,可以使用条件语句合并一些相似的逻辑,减少代码重复。 以下是重构后的代码: ``` const char* UNIT_NAME[] = {"V", "A", "S", "°", "%", "次", "HZ"}; const char* FBS_NAME[] = {"常开", "常闭"}; const char* FBS_MODE_NAME[] = {"标准", "反向"}; const char* ModeName[] = {"单相", "三相"}; void displayData(int isDraw, float val, int data, int i, int gapid, int bit) { char szVal[16]; int x = (i % LISTOFFSET) + 1; if (data >= RT1064KZZ_GL1_ALM && data <= RT1064KZZ_KZHL && data != RT1064KZZ_MODE && data != RT1064KZZ_UAB_CH && data != RT1064KZZ_UBC_CH && data != RT1064KZZ_FBS && data != RT1064KZZ_FBS_MODE) { displayString(isDraw, UNIT_NAME[(int)val], x, 20); } else if (data == RT1064KZZ_MODE) { displayString(isDraw, ModeName[(int)val], x, 20); } else if (data == RT1064KZZ_FBS || data == RT1064KZZ_FBS_MODE) { displayString(isDraw, (data == RT1064KZZ_FBS ? FBS_NAME[(int)val] : FBS_MODE_NAME[(int)val]), x, 20); } else if (data == RT1064KZZ_UAB_CH || data == RT1064KZZ_UBC_CH || data == RT1064_DZ_CHZCS) { sprintf(szVal, "%0.f", val); LCD_DisString(x, 19, szVal); if (data == RT1064_DZ_CHZCS) { LCD_DisString(x, 24, "次"); } if (isDraw == 1) { len = LCD_BitNot(UNIT_PROTECT, UNIT_GAP_RT1064, gapid, data, i, bit); } } else { sprintf(szVal, "%0.3f", get_ActionDZInfo_val(UNIT_GAP_RT1064, gapid, data)); LCD_DisString(x, 19, szVal); int index = -1; if (data >= RT1064_YS_GL1 && data <= RT1064_YS_FBS_JY) { index = 2; } else if ((data >= RT1064_DZ_GL1 && data <= RT1064_DZ_I02) || ((data >= RT1064_DZ_PHASE_I && data <= RT1064_DZ_I0DLT) && data != RT1064_DZ_YL_HAR && data != RT1064_DZ_LMJ) || data == RT1064_DZ_SD || data == RT1064_DZ_I0HJS || data == RT1064_DZ_FC_CHZ || (data >= RT1064_DZ_I03 && data <= RT1064_DZ_FBS_I0) || data == RT1064_DZ_FBS_OL) { index = 1; } else if (data == RT1064_DZ_LMJ || data == RT1064_DZ_JC || data == RT1064_DZ_GYJC) { index = 3; } else if (data == RT1064_DZ_YL_HAR) { index = 4; } else if (data == RT1064_DZ_IDS || data == RT1064_DZ_OPENCS || (data >= RT1064_DZ_I03 && data <= RT1064_DZ_FBS_I0)) { LCD_DisString(x, 24, "次"); } else if (data == RT1064_DZ_DP || data == RT1064_DZ_GP) { index = 6; } if (index != -1) { LCD_DisString(x, 25, UNIT_NAME[index]); } if (isDraw == 1) { len = LCD_BitNot(UNIT_PROTECT, UNIT_GAP_RT1064, gapid, data, i, bit); } } } for (int i = 0; i < DBData.size(); i++) { float val = get_ActionDZInfo_val(UNIT_GAP_RT1064, gapid, DBData[i]); displayData(isDraw, val, DBData[i], i, gapid, bit); } ```

相关推荐

优化这段代码 if(i > num - 1) break; isDraw = (not == 2 && (draw == i+1)); if (DBData[i] != RT1064_YS_YYDD && DBData[i] != RT1064KZZ_FC_CHZ ) LCD_DisString((i%LISTOFFSET)+1, 0, gRunPara.gap_ActionDZInfo[gapid][DBData[i]].szName); if (DBData[i] == RT1064KZZ_FC_CHZ) LCD_DisString((i%LISTOFFSET)+1, 0, (char *)"大电流闭锁重合闸"); if (DBData[i] == RT1064_YS_YYDD) LCD_DisString((i%LISTOFFSET)+1, 0, (char *)"重合闸检有压时间"); val = get_ActionDZInfo_val(UNIT_GAP_RT1064,gapid,DBData[i]); if( DBData[i] >= RT1064KZZ_GL1_ALM && DBData[i] <= RT1064KZZ_KZHL && DBData[i] != RT1064KZZ_MODE && DBData[i] != RT1064KZZ_UAB_CH && DBData[i] != RT1064KZZ_UBC_CH && DBData[i] != RT1064KZZ_FBS && DBData[i] != RT1064KZZ_FBS_MODE) { (isDraw ? LCD_DisString_Not((i%LISTOFFSET)+1, 20,(char *)gcszOnOff[(int)val]) : LCD_DisString((i%LISTOFFSET)+1, 20,(char *)gcszOnOff[(int)val]) ); } else if(DBData[i] == RT1064KZZ_MODE) { (isDraw ? LCD_DisString_Not((i%LISTOFFSET)+1, 20,(char *)ModeName[(int)val]) : LCD_DisString((i%LISTOFFSET)+1, 20,(char *)ModeName[(int)val]) ); } else if (DBData[i] == RT1064KZZ_FBS || DBData[i] == RT1064KZZ_FBS_MODE ) { (isDraw ? LCD_DisString_Not((i%LISTOFFSET)+1, 20,(char *)FBS_NAME[(int)val]) : LCD_DisString((i%LISTOFFSET)+1, 20,(char *)FBS_NAME[(int)val]) ); } else if(DBData[i] == RT1064KZZ_UAB_CH || DBData[i] == RT1064KZZ_UBC_CH || DBData[i] == RT1064_DZ_CHZCS) { sprintf(szVal, "%0.f" , val); LCD_DisString((i%LISTOFFSET)+1, 19 , szVal); if(DBData[i] == RT1064_DZ_CHZCS) LCD_DisString((i%LISTOFFSET)+1, 24, (char *)"次"); if (isDraw == 1) len = LCD_BitNot(UNIT_PROTECT,UNIT_GAP_RT1064,gapid,DBData[i],i,bit); }

优化这段代码 if( DBData[i] >= RT1064KZZ_GL1_ALM && DBData[i] <= RT1064KZZ_KZHL && DBData[i] != RT1064KZZ_MODE && DBData[i] != RT1064KZZ_UAB_CH && DBData[i] != RT1064KZZ_UBC_CH && DBData[i] != RT1064KZZ_FBS && DBData[i] != RT1064KZZ_FBS_MODE) { LCD_DisString((i%9)+1, 20, (char *)gcszOnOff[(int)get_ActionDZInfo_val(UNIT_GAP_RT1064,gapid,DBData[i])]); if (not == 2) { if(draw == (i+1)) { LCD_DisString_Not((i%9)+1, 20, (char *)gcszOnOff[(int)get_ActionDZInfo_val(UNIT_GAP_RT1064,gapid,DBData[i])]); } } } else if(DBData[i] == RT1064KZZ_MODE) { LCD_DisString((i%9)+1, 20, (char *)ModeName[(int)get_ActionDZInfo_val(UNIT_GAP_RT1064,gapid,DBData[i])]); if (not == 2) { if(draw == (i+1)) { LCD_DisString_Not((i%9)+1, 20, (char *)ModeName[(int)get_ActionDZInfo_val(UNIT_GAP_RT1064,gapid,DBData[i])]); } } } else if (DBData[i] == RT1064KZZ_FBS || DBData[i] == RT1064KZZ_FBS_MODE ) { if (DBData[i] == RT1064KZZ_FBS) { LCD_DisString((i%9)+1, 20, (char *)FBS_NAME[(int)get_ActionDZInfo_val(UNIT_GAP_RT1064,gapid,DBData[i])]); if (not == 2) { if(draw == (i+1)) { LCD_DisString_Not((i%9)+1, 20, (char *)FBS_NAME[(int)get_ActionDZInfo_val(UNIT_GAP_RT1064,gapid,DBData[i])]); } } } else if(DBData[i] == RT1064KZZ_FBS_MODE ) { LCD_DisString((i%9)+1, 20, (char *)FBS_MODE_NAME[(int)get_ActionDZInfo_val(UNIT_GAP_RT1064,gapid,DBData[i])]); if (not == 2) { if(draw == (i+1)) { LCD_DisString_Not((i%9)+1, 20, (char *)FBS_MODE_NAME[(int)get_ActionDZInfo_val(UNIT_GAP_RT1064,gapid,DBData[i])]); } } } } else if(DBData[i] == RT1064KZZ_UAB_CH || DBData[i] == RT1064KZZ_UBC_CH || DBData[i] == RT1064_DZ_CHZCS) { sprintf(szVal, "%0.f" , get_ActionDZInfo_val(UNIT_GAP_RT1064,gapid,DBData[i])); LCD_DisString((i%9)+1, 19 , szVal); if(DBData[i] == RT1064_DZ_CHZCS) LCD_DisString((i%9)+1, 24, (char *)"次"); if (not == 2) { if(draw == (i+1)) { len = LCD_BitNot(UNIT_PROTECT,UNIT_GAP_RT1064,gapid,DBData[i],i,bit); } } }

sprintf(szVal, "%0.3f" , val); LCD_DisString((i%9)+1, 19, szVal); Pro_szUnit(DBData[i],i); if (isDraw == 1) val = LCD_BitModify(val,draw); ikey = Lcd_Recvfun2(); switch(ikey) { case LCD_KEY_UP: bit = 0; if (not == 2) { if (draw > page + 1 && draw <= line) draw = draw - 1; } break; case LCD_KEY_DOWN: bit = 0; if (not == 2) { if(draw < i) if (draw < line) draw = draw + 1; } break; case LCD_KEY_ADD: break; case LCD_KEY_DECREASE: break; case LCD_KEY_Left: if (not == 1) { change = 0; if(page < 9) continue; if(page >= 9) { page = page - 9; line = line - 9; } } break; case LCD_KEY_RIGHT: if (not == 1) { change = 0; if(line >= num) continue; if(page < num) { page = page + 9; line = line + 9; } } break; case LCD_KEY_ENTER: not = 2; bit = 0; break; case LCD_KEY_CANCEL: change = 0; if(not > 0) --not; draw = 0; if (not == 0) return; break; default: break; } } 这段代码中的LCD_BitModify函数也会运行ikey = Lcd_Recvfun2(); switch(ikey) { case LCD_KEY_UP: bit = 0; if (not == 2) { if (draw > page + 1 && draw <= line) draw = draw - 1; } break; case LCD_KEY_DOWN: bit = 0; if (not == 2) { if(draw < i) if (draw < line) draw = draw + 1; } break; case LCD_KEY_ADD: break; case LCD_KEY_DECREASE: break; case LCD_KEY_Left: if (not == 1) { change = 0; if(page < 9) continue; if(page >= 9) { page = page - 9; line = line - 9; } } break; case LCD_KEY_RIGHT: if (not == 1) { change = 0; if(line >= num) continue; if(page < num) { page = page + 9; line = line + 9; } } break; case LCD_KEY_ENTER: not = 2; bit = 0; break; case LCD_KEY_CANCEL: change = 0; if(not > 0) --not; draw = 0; if (not == 0) return; break; default:break; }怎么使它们互不干扰

在mysql数据里有一张表,建表语句如下: CREATE TABLE audit_bin_info ( BIN_PID int(8) NOT NULL, HOST_NAME varchar(100) DEFAULT NULL , SOCK_ID int(8) DEFAULT NULL , BIN_STS tinyint(2) DEFAULT NULL , BOOT_NAME varchar(100) DEFAULT NULL, CHANNEL_ID tinyint(2) DEFAULT NULL , START_DATE datetime DEFAULT NULL , UPDATE_DATE datetime DEFAULT NULL, MODULE_NAME varchar(100) DEFAULT NULL, BUSI_CONTENT varchar(4000) DEFAULT NULL, TASK_STS smallint(4) DEFAULT NULL , ID bigint(15) NOT NULL AUTO_INCREMENT, PRIMARY KEY (ID) USING BTREE, KEY IDX_BIN_INFO (BOOT_NAME,MODULE_NAME,CHANNEL_ID) USING BTREE ) ENGINE=InnoDB AUTO_INCREMENT=16766000 DEFAULT CHARSET=utf8 帮我写一个c++的函数,函数定义如下: void CMonitorBase::binlogToDb( const AISTD string & strBinName, const AISTD string & strBinType, const CClientList & listClient, const AISTD string &m_strChannelId, otl_connect& ocDbConn) 它需求实现以下功能: 1、使用otl_stream查询audit_bin_info表,查询语句为select id, bin_pid, host_name, sock_id from audit_bin_info where boot_name='"+strBinName+"' and module_name='"+strBinType+"' and channel_id = " + m_strChannelId;将查到数据保存在一个vector结构中; 2、将查到的表数据跟listClient中的数据做比较,比较条件为表数据中的bin_pid, host_name, sock_id分别和CClient结构中的m_iAppId,m_strHostName,m_iSockId,都相等,则认为找到数据。 3、如果在listClient中找到相等的数据,则根据找到的数据update表中的数据,需要更新的字段为BIN_STS, START_DATE, BUSI_CONTENT,TASK_STS,UPDATE_DATE,前4个字段对别对应CClient结构中的m_nClientSts,dtmBoot,m_strBusiContent,m_nTaskSts,UPDATE_DATE取系统时间; 如果在listClient中没找到相等的数据,则根据id值删除audit_bin_info表中的数据; 最后如果是listClient中多出来的数据,需要插入到audit_bin_info表中; 其中CClient和CClientList的定义如下: class CClient { public: long m_idx; int32 m_iSockId; int32 m_iAppId; int64 m_llTaskId; int16 m_nTaskSts; int16 m_nClientSts; int16 m_nMaxTask; int16 m_nChannelId; AISTD string m_strBusiContent; AISTD string m_strHostName; INT64LIST m_listDetail; AISTD string m_strSpecSts; CBSDateTime dtmBoot; AISTD string m_strRetMsg; int16 m_nStatus; int16 m_nDispEsc; CClient() : m_idx(0), m_iSockId(0), m_iAppId(0), m_llTaskId(0), m_nTaskSts(0), m_nClientSts(1), m_nMaxTask(1), m_nChannelId(0), m_strSpecSts("0"), m_nStatus(0), m_nDispEsc(0) { dtmBoot = CBSDateTime::currentDateTime(); }; }; typedef AISTD vector<CClient*> CClientList;

最新推荐

recommend-type

grpcio-1.47.0-cp310-cp310-linux_armv7l.whl

Python库是一组预先编写的代码模块,旨在帮助开发者实现特定的编程任务,无需从零开始编写代码。这些库可以包括各种功能,如数学运算、文件操作、数据分析和网络编程等。Python社区提供了大量的第三方库,如NumPy、Pandas和Requests,极大地丰富了Python的应用领域,从数据科学到Web开发。Python库的丰富性是Python成为最受欢迎的编程语言之一的关键原因之一。这些库不仅为初学者提供了快速入门的途径,而且为经验丰富的开发者提供了强大的工具,以高效率、高质量地完成复杂任务。例如,Matplotlib和Seaborn库在数据可视化领域内非常受欢迎,它们提供了广泛的工具和技术,可以创建高度定制化的图表和图形,帮助数据科学家和分析师在数据探索和结果展示中更有效地传达信息。
recommend-type

小程序项目源码-美容预约小程序.zip

小程序项目源码-美容预约小程序小程序项目源码-美容预约小程序小程序项目源码-美容预约小程序小程序项目源码-美容预约小程序小程序项目源码-美容预约小程序小程序项目源码-美容预约小程序小程序项目源码-美容预约小程序小程序项目源码-美容预约小程序v
recommend-type

MobaXterm 工具

MobaXterm 工具
recommend-type

zigbee-cluster-library-specification

最新的zigbee-cluster-library-specification说明文档。
recommend-type

管理建模和仿真的文件

管理Boualem Benatallah引用此版本:布阿利姆·贝纳塔拉。管理建模和仿真。约瑟夫-傅立叶大学-格勒诺布尔第一大学,1996年。法语。NNT:电话:00345357HAL ID:电话:00345357https://theses.hal.science/tel-003453572008年12月9日提交HAL是一个多学科的开放存取档案馆,用于存放和传播科学研究论文,无论它们是否被公开。论文可以来自法国或国外的教学和研究机构,也可以来自公共或私人研究中心。L’archive ouverte pluridisciplinaire
recommend-type

【实战演练】MATLAB用遗传算法改进粒子群GA-PSO算法

![MATLAB智能算法合集](https://static.fuxi.netease.com/fuxi-official/web/20221101/83f465753fd49c41536a5640367d4340.jpg) # 2.1 遗传算法的原理和实现 遗传算法(GA)是一种受生物进化过程启发的优化算法。它通过模拟自然选择和遗传机制来搜索最优解。 **2.1.1 遗传算法的编码和解码** 编码是将问题空间中的解表示为二进制字符串或其他数据结构的过程。解码是将编码的解转换为问题空间中的实际解的过程。常见的编码方法包括二进制编码、实数编码和树形编码。 **2.1.2 遗传算法的交叉和
recommend-type

openstack的20种接口有哪些

以下是OpenStack的20种API接口: 1. Identity (Keystone) API 2. Compute (Nova) API 3. Networking (Neutron) API 4. Block Storage (Cinder) API 5. Object Storage (Swift) API 6. Image (Glance) API 7. Telemetry (Ceilometer) API 8. Orchestration (Heat) API 9. Database (Trove) API 10. Bare Metal (Ironic) API 11. DNS
recommend-type

JSBSim Reference Manual

JSBSim参考手册,其中包含JSBSim简介,JSBSim配置文件xml的编写语法,编程手册以及一些应用实例等。其中有部分内容还没有写完,估计有生之年很难看到完整版了,但是内容还是很有参考价值的。
recommend-type

"互动学习:行动中的多样性与论文攻读经历"

多样性她- 事实上SCI NCES你的时间表ECOLEDO C Tora SC和NCESPOUR l’Ingén学习互动,互动学习以行动为中心的强化学习学会互动,互动学习,以行动为中心的强化学习计算机科学博士论文于2021年9月28日在Villeneuve d'Asq公开支持马修·瑟林评审团主席法布里斯·勒菲弗尔阿维尼翁大学教授论文指导奥利维尔·皮耶昆谷歌研究教授:智囊团论文联合主任菲利普·普雷教授,大学。里尔/CRISTAL/因里亚报告员奥利维耶·西格德索邦大学报告员卢多维奇·德诺耶教授,Facebook /索邦大学审查员越南圣迈IMT Atlantic高级讲师邀请弗洛里安·斯特鲁布博士,Deepmind对于那些及时看到自己错误的人...3谢谢你首先,我要感谢我的两位博士生导师Olivier和Philippe。奥利维尔,"站在巨人的肩膀上"这句话对你来说完全有意义了。从科学上讲,你知道在这篇论文的(许多)错误中,你是我可以依
recommend-type

【实战演练】时间序列预测用于个体家庭功率预测_ARIMA, xgboost, RNN

![【实战演练】时间序列预测用于个体家庭功率预测_ARIMA, xgboost, RNN](https://img-blog.csdnimg.cn/img_convert/5587b4ec6abfc40c76db14fbef6280db.jpeg) # 1. 时间序列预测简介** 时间序列预测是一种预测未来值的技术,其基于历史数据中的时间依赖关系。它广泛应用于各种领域,例如经济、金融、能源和医疗保健。时间序列预测模型旨在捕捉数据中的模式和趋势,并使用这些信息来预测未来的值。 # 2. 时间序列预测方法 时间序列预测方法是利用历史数据来预测未来趋势或值的统计技术。在时间序列预测中,有许多不