Эх сурвалжийг харах

2022-08-16 / Simon Xue

Action:
1. [Fix] Remove Dispenser offlinepolicy local list.
2. [Fix] Authorize Page set to pSysinfo->systemPage.
3. [Fix] Return to IDLE status powerConsumption value not from database.
4. [Add] Send charge info when complete and alarm status.
5. [Fix] ReadCmdline unconditional charging derating current and power.

Files
As the following commit history files.

Image Version: V1.23.XX.XXXX.XX
Simon Xue 2 жил өмнө
parent
commit
34fe1e0c90

+ 9 - 7
EVSE/Projects/DD360/Apps/CSU/RFID.c

@@ -278,16 +278,18 @@ void ScannerCardProcess(void)
         UserScanFunction();
     }
 
-    if (pSysInfo->PageIndex == _LCM_AUTHORIZING) {
+    if (pSysInfo->SystemPage == _LCM_AUTHORIZING) {
         if(!isAuthorizedComplete())
             StartSystemTimeoutDet(Timeout_Authorizing);
 
         //printf("isAuthorizedComplete = %d, %f", isAuthorizedComplete(), ShmSelectGunInfo->PricesInfo[pSysInfo->CurGunSelected].Balance);
         // 確認驗證卡號完成沒
         if (isAuthorizedComplete()
+            /*
 #if !defined DD360 && !defined DD360Audi && !defined DD360ComBox
                 || pSysConfig->OfflinePolicy == _OFFLINE_POLICY_FREE_CHARGING
 #endif //!defined DD360 && !defined DD360Audi && !defined DD360ComBox
+*/
            ) {
                 //StopSystemTimeoutDet();
                 StartSystemTimeoutDet(Timeout_WaitBalance);
@@ -305,26 +307,26 @@ void ScannerCardProcess(void)
                 }
 
             } ClearAuthorizedFlag();
-        } else if (pSysConfig->OfflinePolicy == _OFFLINE_POLICY_LOCAL_LIST) {
+        } /*else if (pSysConfig->OfflinePolicy == _OFFLINE_POLICY_LOCAL_LIST) {
             // 白名單驗證
             for (i = 0; i < 10; i++) {
                 if (strcmp((char *)pSysConfig->LocalWhiteCard[i], "") == EQUAL) {
                     continue;
                 }
-
                 if (strcmp((char *)pSysConfig->LocalWhiteCard[i], (char *)pSysConfig->UserId) == EQUAL) {
+                    log_info("Local White Card [%d]:%s", i, pSysConfig->LocalWhiteCard[i]);
                     pSysInfo->SystemPage = _LCM_AUTHORIZ_COMP;
                     ClearAuthorizedFlag();
                     break;
                 }
             }
-        }
-    } else if (pSysInfo->PageIndex == _LCM_AUTHORIZ_FAIL) {
+        }*/
+    } else if (pSysInfo->SystemPage == _LCM_AUTHORIZ_FAIL) {
         StartSystemTimeoutDet(Timeout_VerifyFail);
         isCardScan = false;
-    } else if (pSysInfo->PageIndex == _LCM_AUTHORIZ_COMP) {
+    } else if (pSysInfo->SystemPage == _LCM_AUTHORIZ_COMP) {
         StartSystemTimeoutDet(Timeout_VerifyComp);
-    } else if (pSysInfo->PageIndex == _LCM_WAIT_FOR_PLUG) {
+    } else if (pSysInfo->SystemPage == _LCM_WAIT_FOR_PLUG) {
         //StartGunInfoTimeoutDet(pSysInfo->CurGunSelected, Timeout_WaitPlug);
     } else {
         isCardScan = false;

+ 6 - 3
EVSE/Projects/DD360/Apps/CSU/main.c

@@ -85,8 +85,8 @@ uint8_t bd0_2_status = 0;
 uint8_t bd1_1_status = 0;
 uint8_t bd1_2_status = 0;
 
-char *fwVersion = "V1.22.00.0000.00"; // "V0.16.00.0000.00";
-char* DebugVersion = "V1.22.0";
+char *fwVersion = "V1.23.00.0000.00"; // "V0.16.00.0000.00";
+char* DebugVersion = "V1.23.1";
 //sqlite3 *localDb;
 bool isDb_ready;
 
@@ -4577,6 +4577,7 @@ int main(void)
     uint8_t evBoardStopState = 0;
     uint8_t _ocppProfileChkFlag;
     uint8_t gunIndex = 0;
+    float powerconsumption;
 
     if (CreateAllCsuShareMemory() == FAIL) {
         log_error("create share memory error");
@@ -4867,8 +4868,10 @@ int main(void)
                     }
                     //Jerry add
                     memset(&ShmSelectGunInfo->PricesInfo[gunIndex], 0, sizeof(PricesInfo));
+                    powerconsumption = ShmDcCommonData->pGunInfo[gunIndex].PowerConsumption;
                     memset(&ShmDcCommonData->pGunInfo[gunIndex], 0, sizeof(GunInfo));
-                    DB_Get_PowerConsumption(gunIndex);
+                    ShmDcCommonData->pGunInfo[gunIndex].PowerConsumption = powerconsumption;
+
                     ShmSelectGunInfo->PricesInfo[gunIndex].Balance = FAIL_BALANCE_PRICES;
                     destroySelGun(gunIndex);
                     ResetDetAlarmStatus(gunIndex); //recovery OVP status code

+ 13 - 6
EVSE/Projects/DD360/Apps/ModuleDoComm/DoComm.c

@@ -2708,16 +2708,16 @@ static void systemStatusProcess(int fd, uint8_t totalGun, uint8_t plugNum, uint8
     case S_MAINTAIN:
     case S_ALARM:
     case S_AUTHORIZING:
-        /*
+        
         if(pDcChargingInfo->SystemStatus == S_ALARM) {
             ftime(&AuthNowTime);
-            if (DiffTimeb(gRegTimeUp[plugNum][REG_READ_CHARGING_TIMESTAMP], AuthNowTime) > (LOOP_RETRY_TIME / 10) ||
-                DiffTimeb(gRegTimeUp[plugNum][REG_READ_CHARGING_TIMESTAMP], AuthNowTime) < 0
+            if (DiffTimeb(gRegTimeUp[plugNum][REG_PRESENT_CHARGING_INFO], AuthNowTime) > LOOP_RETRY_TIME ||
+                DiffTimeb(gRegTimeUp[plugNum][REG_PRESENT_CHARGING_INFO], AuthNowTime) < 0
                 ) {
-                readChargingTimeStamp(fd, gunID);
-                ftime(&gRegTimeUp[plugNum][REG_READ_CHARGING_TIMESTAMP]);
+                writePresentChargingInfo(fd, plugNum, gunID);
+                ftime(&gRegTimeUp[plugNum][REG_PRESENT_CHARGING_INFO]);
             }
-        }*/
+        }
 
         checkAuthorProcess(fd, plugNum);
 
@@ -2926,6 +2926,13 @@ static void systemStatusProcess(int fd, uint8_t totalGun, uint8_t plugNum, uint8
 				writeGroundFaultDetection(fd, 0, gunID);
             ftime(&gRegTimeUp[plugNum][REG_CHARGING_CAP]);
         }
+        ftime(&AuthNowTime);
+        if (DiffTimeb(gRegTimeUp[plugNum][REG_PRESENT_CHARGING_INFO], AuthNowTime) > LOOP_RETRY_TIME ||
+            DiffTimeb(gRegTimeUp[plugNum][REG_PRESENT_CHARGING_INFO], AuthNowTime) < 0
+            ) {
+            writePresentChargingInfo(fd, plugNum, gunID);
+            ftime(&gRegTimeUp[plugNum][REG_PRESENT_CHARGING_INFO]);
+        }
         // 獲得Charging時間
         /*
         ftime(&AuthNowTime);

+ 38 - 21
EVSE/Projects/DD360/Apps/ReadCmdline.c

@@ -763,6 +763,18 @@ static void getChillerTemperature(struct ChargingInfoData* chargingData)
 
 void GetOtpPwrOrCurMethod(struct ChargingInfoData* chargingData, float* pow, float* cur)
 {
+    for(int i = 0 ; i < 4 ; i++) {
+        if (ShmDcCommonData->SystemTemp[i] >= STAGE1_GUN_DERATING_TEMP &&
+            ShmDcCommonData->SystemTemp[i] < STAGE2_GUN_DERATING_TEMP && 
+            chargingData->deratingByConnOtp.deratingIndex < 1) {
+            chargingData->deratingByConnOtp.deratingIndex = 1;
+        } else if (ShmDcCommonData->SystemTemp[i] >= STAGE2_GUN_DERATING_TEMP &&
+            ShmDcCommonData->SystemTemp[i] != UNDEFINED_TEMP &&
+            chargingData->deratingByConnOtp.deratingIndex < 2) {
+            chargingData->deratingByConnOtp.deratingIndex = 2;
+        }
+    }
+    /*
     if (((chargingData->ConnectorTemp >= STAGE1_GUN_DERATING_TEMP &&
         chargingData->ConnectorTemp < STAGE2_GUN_DERATING_TEMP) ||
         (chargingData->ChillerTemp >= STAGE1_GUN_DERATING_TEMP &&
@@ -778,7 +790,7 @@ void GetOtpPwrOrCurMethod(struct ChargingInfoData* chargingData, float* pow, flo
     {
         chargingData->deratingByConnOtp.deratingIndex = 2;
     }
-
+    */
     if (chargingData->deratingByConnOtp.deratingTargetRate[chargingData->deratingByConnOtp.deratingIndex] != 0)
     {
         *pow *= chargingData->deratingByConnOtp.deratingTargetRate[chargingData->deratingByConnOtp.deratingIndex];
@@ -804,6 +816,7 @@ void RunUnconditionalChargeIndex1(char *v1, char *v2, char *v3)
     float deratingCurrent;
     int derating_index = 0;
     uint8_t PreviousSystemStatus[2] = {0xff};
+    int idx;
     char *usageMsg = "Usage:\n"
                      "       strchg <index> <voltage> <current>    ex: strchg 0 150 2\n"
                      "       chg    <voltage> <current>            ex: chg 500 100\n"
@@ -858,6 +871,7 @@ void RunUnconditionalChargeIndex1(char *v1, char *v2, char *v3)
                 pDcChargingInfo->ConnectorPlugIn = 1;
                 printf ("[UnconditionalCharge - S_IDLE]\n");
                 pDcChargingInfo->Type = 9;
+                sleep(1);
 
             }
             if (ShmOCPP16Data->SpMsg.bits.AuthorizeConf == 1) {
@@ -1010,23 +1024,26 @@ void RunUnconditionalChargeIndex1(char *v1, char *v2, char *v3)
 //                      pDcChargingInfo->EvBatterytargetVoltage,
 //                      pDcChargingInfo->EvBatterytargetCurrent);
             //ev task do this
-            if (pDcChargingInfo->deratingByConnOtp.isNeedDerating) {
-                deratingCurrent = pDcChargingInfo->EvBatterytargetCurrent;
-                deratingPower = pDcChargingInfo->AvailableChargingPower;
-
-                getChillerTemperature(pDcChargingInfo);
-                GetOtpPwrOrCurMethod(pDcChargingInfo, &deratingPower, &deratingCurrent);
-                if (derating_index != pDcChargingInfo->deratingByConnOtp.deratingIndex) {
-                    printf("Change Derating Index:%d\n", pDcChargingInfo->deratingByConnOtp.deratingIndex);
-                    derating_index = pDcChargingInfo->deratingByConnOtp.deratingIndex;
-                }
-                if (pDcChargingInfo->EvBatterytargetCurrent != deratingCurrent ||
-                    pDcChargingInfo->AvailableChargingPower != deratingPower) {
-                    pDcChargingInfo->EvBatterytargetCurrent = deratingCurrent;
-                    pDcChargingInfo->AvailableChargingPower = deratingPower;
-                    printf("Derating Current:%.3f Power:%.3f\n", pDcChargingInfo->EvBatterytargetCurrent, pDcChargingInfo->AvailableChargingPower);
+            for (idx = 0; idx < pSysConfig->TotalConnectorCount; idx++) {
+                struct ChargingInfoData* pInfo = (struct ChargingInfoData*)GetDcChargingInfoData(idx);
+                if (pInfo->deratingByConnOtp.isNeedDerating) {
+                    deratingCurrent = pInfo->EvBatterytargetCurrent;
+                    deratingPower = pInfo->AvailableChargingPower;
+
+                    getChillerTemperature(pInfo);
+                    GetOtpPwrOrCurMethod(pInfo, &deratingPower, &deratingCurrent);
+                    if (derating_index != pDcChargingInfo->deratingByConnOtp.deratingIndex) {
+                        printf("Change Derating Index:%d\n", pInfo->deratingByConnOtp.deratingIndex);
+                        derating_index = pInfo->deratingByConnOtp.deratingIndex;
+                    }
+                    if (pInfo->EvBatterytargetCurrent != deratingCurrent ||
+                        pInfo->AvailableChargingPower != deratingPower) {
+                        pInfo->EvBatterytargetCurrent = deratingCurrent;
+                        pInfo->AvailableChargingPower = deratingPower;
+                        printf("Derating Current:%.3f Power:%.3f\n", pInfo->EvBatterytargetCurrent, pInfo->AvailableChargingPower);
+                    }
                 }
-            }
+            } // for
 
             pDcChargingInfo->PresentChargingPower =
                 ((float)((pDcChargingInfo->PresentChargingVoltage) *
@@ -1078,9 +1095,9 @@ void RunUnconditionalChargeIndex1(char *v1, char *v2, char *v3)
             pDcChargingInfo->PresentChargingPower = 0;
 
             if (stopChg == pSysConfig->TotalConnectorCount) {
-                ShmDcCommonData->debugflag = NO;
-                ShmFanModuleData->TestFanSpeed = 0;
                 system("/root/Module_EvComm &");
+                ShmFanModuleData->TestFanSpeed = 0;
+                ShmDcCommonData->debugflag = NO;
                 sleep(3);
 
                 for (_GunIndex = 0; _GunIndex < pSysConfig->TotalConnectorCount; _GunIndex++) {
@@ -1470,7 +1487,7 @@ int main(void)
                      "       lock <index>                      : get gun locked state\n"
                      "       sysid                             : test system ID\n"
                      "       self                              : self test state (x)\n"
-                     "       version | v | -v                  : version of board (407 or relay or other)\n"
+                     "       ver| v | -v                       : version of board (407 or relay or other)\n"
                      "       update                            : update firmware\n"
                      "       ac                                : get ac relay state (x) \n"
                      "       cable <index> <state>             : set ground fault state\n"
@@ -1558,7 +1575,7 @@ int main(void)
         } else if (strcmp(newString[0], "self") == 0) {
             // CSU 自我檢測狀態
             RunSelfProc(newString[1]);
-        } else if (strcmp(newString[0], "version") == 0 ||
+        } else if (strcmp(newString[0], "ver") == 0 ||
                    strcmp(newString[0], "v") == 0 ||
                    strcmp(newString[0], "-v") == 0) {
             //if (strcmp(newString[1], "-1") == 0 || strcmp(newString[1], "") == 0) {

BIN
EVSE/Projects/DD360/Images/ramdisk.gz


BIN
EVSE/Projects/DD360/output/Module_DoComm


BIN
EVSE/Projects/DD360/output/ReadCmdline


BIN
EVSE/Projects/DD360/output/main


+ 9 - 7
EVSE/Projects/DD360Audi/Apps/CSU/RFID.c

@@ -278,16 +278,18 @@ void ScannerCardProcess(void)
         UserScanFunction();
     }
 
-    if (pSysInfo->PageIndex == _LCM_AUTHORIZING) {
+    if (pSysInfo->SystemPage == _LCM_AUTHORIZING) {
         if(!isAuthorizedComplete())
             StartSystemTimeoutDet(Timeout_Authorizing);
 
         //printf("isAuthorizedComplete = %d, %f", isAuthorizedComplete(), ShmSelectGunInfo->PricesInfo[pSysInfo->CurGunSelected].Balance);
         // 確認驗證卡號完成沒
         if (isAuthorizedComplete()
+            /*
 #if !defined DD360 && !defined DD360Audi && !defined DD360ComBox
                 || pSysConfig->OfflinePolicy == _OFFLINE_POLICY_FREE_CHARGING
 #endif //!defined DD360 && !defined DD360Audi && !defined DD360ComBox
+*/
            ) {
                 //StopSystemTimeoutDet();
                 StartSystemTimeoutDet(Timeout_WaitBalance);
@@ -305,26 +307,26 @@ void ScannerCardProcess(void)
                 }
 
             } ClearAuthorizedFlag();
-        } else if (pSysConfig->OfflinePolicy == _OFFLINE_POLICY_LOCAL_LIST) {
+        } /*else if (pSysConfig->OfflinePolicy == _OFFLINE_POLICY_LOCAL_LIST) {
             // 白名單驗證
             for (i = 0; i < 10; i++) {
                 if (strcmp((char *)pSysConfig->LocalWhiteCard[i], "") == EQUAL) {
                     continue;
                 }
-
                 if (strcmp((char *)pSysConfig->LocalWhiteCard[i], (char *)pSysConfig->UserId) == EQUAL) {
+                    log_info("Local White Card [%d]:%s", i, pSysConfig->LocalWhiteCard[i]);
                     pSysInfo->SystemPage = _LCM_AUTHORIZ_COMP;
                     ClearAuthorizedFlag();
                     break;
                 }
             }
-        }
-    } else if (pSysInfo->PageIndex == _LCM_AUTHORIZ_FAIL) {
+        }*/
+    } else if (pSysInfo->SystemPage == _LCM_AUTHORIZ_FAIL) {
         StartSystemTimeoutDet(Timeout_VerifyFail);
         isCardScan = false;
-    } else if (pSysInfo->PageIndex == _LCM_AUTHORIZ_COMP) {
+    } else if (pSysInfo->SystemPage == _LCM_AUTHORIZ_COMP) {
         StartSystemTimeoutDet(Timeout_VerifyComp);
-    } else if (pSysInfo->PageIndex == _LCM_WAIT_FOR_PLUG) {
+    } else if (pSysInfo->SystemPage == _LCM_WAIT_FOR_PLUG) {
         //StartGunInfoTimeoutDet(pSysInfo->CurGunSelected, Timeout_WaitPlug);
     } else {
         isCardScan = false;

+ 6 - 3
EVSE/Projects/DD360Audi/Apps/CSU/main.c

@@ -85,8 +85,8 @@ uint8_t bd0_2_status = 0;
 uint8_t bd1_1_status = 0;
 uint8_t bd1_2_status = 0;
 
-char *fwVersion = "V1.22.00.0000.00"; // "V0.16.00.0000.00";
-char* DebugVersion = "V1.22.0";
+char *fwVersion = "V1.23.00.0000.00"; // "V0.16.00.0000.00";
+char* DebugVersion = "V1.23.1";
 //sqlite3 *localDb;
 bool isDb_ready;
 
@@ -4577,6 +4577,7 @@ int main(void)
     uint8_t evBoardStopState = 0;
     uint8_t _ocppProfileChkFlag;
     uint8_t gunIndex = 0;
+    float powerconsumption;
 
     if (CreateAllCsuShareMemory() == FAIL) {
         log_error("create share memory error");
@@ -4867,8 +4868,10 @@ int main(void)
                     }
                     //Jerry add
                     memset(&ShmSelectGunInfo->PricesInfo[gunIndex], 0, sizeof(PricesInfo));
+                    powerconsumption = ShmDcCommonData->pGunInfo[gunIndex].PowerConsumption;
                     memset(&ShmDcCommonData->pGunInfo[gunIndex], 0, sizeof(GunInfo));
-                    DB_Get_PowerConsumption(gunIndex);
+                    ShmDcCommonData->pGunInfo[gunIndex].PowerConsumption = powerconsumption;
+
                     ShmSelectGunInfo->PricesInfo[gunIndex].Balance = FAIL_BALANCE_PRICES;
                     destroySelGun(gunIndex);
                     ResetDetAlarmStatus(gunIndex); //recovery OVP status code

+ 13 - 6
EVSE/Projects/DD360Audi/Apps/ModuleDoComm/DoComm.c

@@ -2708,16 +2708,16 @@ static void systemStatusProcess(int fd, uint8_t totalGun, uint8_t plugNum, uint8
     case S_MAINTAIN:
     case S_ALARM:
     case S_AUTHORIZING:
-        /*
+        
         if(pDcChargingInfo->SystemStatus == S_ALARM) {
             ftime(&AuthNowTime);
-            if (DiffTimeb(gRegTimeUp[plugNum][REG_READ_CHARGING_TIMESTAMP], AuthNowTime) > (LOOP_RETRY_TIME / 10) ||
-                DiffTimeb(gRegTimeUp[plugNum][REG_READ_CHARGING_TIMESTAMP], AuthNowTime) < 0
+            if (DiffTimeb(gRegTimeUp[plugNum][REG_PRESENT_CHARGING_INFO], AuthNowTime) > LOOP_RETRY_TIME ||
+                DiffTimeb(gRegTimeUp[plugNum][REG_PRESENT_CHARGING_INFO], AuthNowTime) < 0
                 ) {
-                readChargingTimeStamp(fd, gunID);
-                ftime(&gRegTimeUp[plugNum][REG_READ_CHARGING_TIMESTAMP]);
+                writePresentChargingInfo(fd, plugNum, gunID);
+                ftime(&gRegTimeUp[plugNum][REG_PRESENT_CHARGING_INFO]);
             }
-        }*/
+        }
 
         checkAuthorProcess(fd, plugNum);
 
@@ -2926,6 +2926,13 @@ static void systemStatusProcess(int fd, uint8_t totalGun, uint8_t plugNum, uint8
 				writeGroundFaultDetection(fd, 0, gunID);
             ftime(&gRegTimeUp[plugNum][REG_CHARGING_CAP]);
         }
+        ftime(&AuthNowTime);
+        if (DiffTimeb(gRegTimeUp[plugNum][REG_PRESENT_CHARGING_INFO], AuthNowTime) > LOOP_RETRY_TIME ||
+            DiffTimeb(gRegTimeUp[plugNum][REG_PRESENT_CHARGING_INFO], AuthNowTime) < 0
+            ) {
+            writePresentChargingInfo(fd, plugNum, gunID);
+            ftime(&gRegTimeUp[plugNum][REG_PRESENT_CHARGING_INFO]);
+        }
         // 獲得Charging時間
         /*
         ftime(&AuthNowTime);

+ 38 - 21
EVSE/Projects/DD360Audi/Apps/ReadCmdline.c

@@ -763,6 +763,18 @@ static void getChillerTemperature(struct ChargingInfoData* chargingData)
 
 void GetOtpPwrOrCurMethod(struct ChargingInfoData* chargingData, float* pow, float* cur)
 {
+    for(int i = 0 ; i < 4 ; i++) {
+        if (ShmDcCommonData->SystemTemp[i] >= STAGE1_GUN_DERATING_TEMP &&
+            ShmDcCommonData->SystemTemp[i] < STAGE2_GUN_DERATING_TEMP && 
+            chargingData->deratingByConnOtp.deratingIndex < 1) {
+            chargingData->deratingByConnOtp.deratingIndex = 1;
+        } else if (ShmDcCommonData->SystemTemp[i] >= STAGE2_GUN_DERATING_TEMP &&
+            ShmDcCommonData->SystemTemp[i] != UNDEFINED_TEMP &&
+            chargingData->deratingByConnOtp.deratingIndex < 2) {
+            chargingData->deratingByConnOtp.deratingIndex = 2;
+        }
+    }
+    /*
     if (((chargingData->ConnectorTemp >= STAGE1_GUN_DERATING_TEMP &&
         chargingData->ConnectorTemp < STAGE2_GUN_DERATING_TEMP) ||
         (chargingData->ChillerTemp >= STAGE1_GUN_DERATING_TEMP &&
@@ -778,7 +790,7 @@ void GetOtpPwrOrCurMethod(struct ChargingInfoData* chargingData, float* pow, flo
     {
         chargingData->deratingByConnOtp.deratingIndex = 2;
     }
-
+    */
     if (chargingData->deratingByConnOtp.deratingTargetRate[chargingData->deratingByConnOtp.deratingIndex] != 0)
     {
         *pow *= chargingData->deratingByConnOtp.deratingTargetRate[chargingData->deratingByConnOtp.deratingIndex];
@@ -804,6 +816,7 @@ void RunUnconditionalChargeIndex1(char *v1, char *v2, char *v3)
     float deratingCurrent;
     int derating_index = 0;
     uint8_t PreviousSystemStatus[2] = {0xff};
+    int idx;
     char *usageMsg = "Usage:\n"
                      "       strchg <index> <voltage> <current>    ex: strchg 0 150 2\n"
                      "       chg    <voltage> <current>            ex: chg 500 100\n"
@@ -858,6 +871,7 @@ void RunUnconditionalChargeIndex1(char *v1, char *v2, char *v3)
                 pDcChargingInfo->ConnectorPlugIn = 1;
                 printf ("[UnconditionalCharge - S_IDLE]\n");
                 pDcChargingInfo->Type = 9;
+                sleep(1);
 
             }
             if (ShmOCPP16Data->SpMsg.bits.AuthorizeConf == 1) {
@@ -1010,23 +1024,26 @@ void RunUnconditionalChargeIndex1(char *v1, char *v2, char *v3)
 //                      pDcChargingInfo->EvBatterytargetVoltage,
 //                      pDcChargingInfo->EvBatterytargetCurrent);
             //ev task do this
-            if (pDcChargingInfo->deratingByConnOtp.isNeedDerating) {
-                deratingCurrent = pDcChargingInfo->EvBatterytargetCurrent;
-                deratingPower = pDcChargingInfo->AvailableChargingPower;
-
-                getChillerTemperature(pDcChargingInfo);
-                GetOtpPwrOrCurMethod(pDcChargingInfo, &deratingPower, &deratingCurrent);
-                if (derating_index != pDcChargingInfo->deratingByConnOtp.deratingIndex) {
-                    printf("Change Derating Index:%d\n", pDcChargingInfo->deratingByConnOtp.deratingIndex);
-                    derating_index = pDcChargingInfo->deratingByConnOtp.deratingIndex;
-                }
-                if (pDcChargingInfo->EvBatterytargetCurrent != deratingCurrent ||
-                    pDcChargingInfo->AvailableChargingPower != deratingPower) {
-                    pDcChargingInfo->EvBatterytargetCurrent = deratingCurrent;
-                    pDcChargingInfo->AvailableChargingPower = deratingPower;
-                    printf("Derating Current:%.3f Power:%.3f\n", pDcChargingInfo->EvBatterytargetCurrent, pDcChargingInfo->AvailableChargingPower);
+            for (idx = 0; idx < pSysConfig->TotalConnectorCount; idx++) {
+                struct ChargingInfoData* pInfo = (struct ChargingInfoData*)GetDcChargingInfoData(idx);
+                if (pInfo->deratingByConnOtp.isNeedDerating) {
+                    deratingCurrent = pInfo->EvBatterytargetCurrent;
+                    deratingPower = pInfo->AvailableChargingPower;
+
+                    getChillerTemperature(pInfo);
+                    GetOtpPwrOrCurMethod(pInfo, &deratingPower, &deratingCurrent);
+                    if (derating_index != pDcChargingInfo->deratingByConnOtp.deratingIndex) {
+                        printf("Change Derating Index:%d\n", pInfo->deratingByConnOtp.deratingIndex);
+                        derating_index = pInfo->deratingByConnOtp.deratingIndex;
+                    }
+                    if (pInfo->EvBatterytargetCurrent != deratingCurrent ||
+                        pInfo->AvailableChargingPower != deratingPower) {
+                        pInfo->EvBatterytargetCurrent = deratingCurrent;
+                        pInfo->AvailableChargingPower = deratingPower;
+                        printf("Derating Current:%.3f Power:%.3f\n", pInfo->EvBatterytargetCurrent, pInfo->AvailableChargingPower);
+                    }
                 }
-            }
+            } // for
 
             pDcChargingInfo->PresentChargingPower =
                 ((float)((pDcChargingInfo->PresentChargingVoltage) *
@@ -1078,9 +1095,9 @@ void RunUnconditionalChargeIndex1(char *v1, char *v2, char *v3)
             pDcChargingInfo->PresentChargingPower = 0;
 
             if (stopChg == pSysConfig->TotalConnectorCount) {
-                ShmDcCommonData->debugflag = NO;
-                ShmFanModuleData->TestFanSpeed = 0;
                 system("/root/Module_EvComm &");
+                ShmFanModuleData->TestFanSpeed = 0;
+                ShmDcCommonData->debugflag = NO;
                 sleep(3);
 
                 for (_GunIndex = 0; _GunIndex < pSysConfig->TotalConnectorCount; _GunIndex++) {
@@ -1470,7 +1487,7 @@ int main(void)
                      "       lock <index>                      : get gun locked state\n"
                      "       sysid                             : test system ID\n"
                      "       self                              : self test state (x)\n"
-                     "       version | v | -v                  : version of board (407 or relay or other)\n"
+                     "       ver| v | -v                       : version of board (407 or relay or other)\n"
                      "       update                            : update firmware\n"
                      "       ac                                : get ac relay state (x) \n"
                      "       cable <index> <state>             : set ground fault state\n"
@@ -1558,7 +1575,7 @@ int main(void)
         } else if (strcmp(newString[0], "self") == 0) {
             // CSU 自我檢測狀態
             RunSelfProc(newString[1]);
-        } else if (strcmp(newString[0], "version") == 0 ||
+        } else if (strcmp(newString[0], "ver") == 0 ||
                    strcmp(newString[0], "v") == 0 ||
                    strcmp(newString[0], "-v") == 0) {
             //if (strcmp(newString[1], "-1") == 0 || strcmp(newString[1], "") == 0) {