|
@@ -37,7 +37,7 @@ static struct GBTData *ShmGBTData = NULL;
|
|
|
static struct CcsData *ShmCcsData = NULL;
|
|
|
static DcCommonInfo *ShmDcCommonData = NULL;
|
|
|
static SelectGunInfo *ShmSelectGunInfo = NULL;
|
|
|
-
|
|
|
+uint8_t deratingIndex[2];
|
|
|
// 限制最大充電電壓,因應不同 type 槍線來限制
|
|
|
// Chademo : 500V, 125A,
|
|
|
// GB : 750, 120A
|
|
@@ -140,6 +140,131 @@ int InitCanBus(void)
|
|
|
return s0;
|
|
|
}
|
|
|
|
|
|
+void SetNatural200AGunOTPValue(struct DERATING_BY_OTP* deratingByConnOtp)
|
|
|
+{
|
|
|
+ memset(&deratingByConnOtp->deratingTargetRate[0], 200, sizeof(deratingByConnOtp->deratingTargetRate));
|
|
|
+}
|
|
|
+void SetNatural300AGunOTPValue(struct DERATING_BY_OTP* deratingByConnOtp)
|
|
|
+{
|
|
|
+ deratingByConnOtp->deratingTargetCurrent[0] = 500;
|
|
|
+ deratingByConnOtp->deratingTargetCurrent[1] = 300;
|
|
|
+ deratingByConnOtp->deratingTargetCurrent[2] = 100;
|
|
|
+ deratingByConnOtp->deratingTargetCurrent[3] = 100;
|
|
|
+ deratingByConnOtp->deratingTargetCurrent[4] = 100;
|
|
|
+}
|
|
|
+void SetLiquidCoolGunOTPValue(struct DERATING_BY_OTP* deratingByConnOtp)
|
|
|
+{
|
|
|
+ deratingByConnOtp->deratingTargetCurrent[0] = 500;
|
|
|
+ deratingByConnOtp->deratingTargetCurrent[1] = 400;
|
|
|
+ deratingByConnOtp->deratingTargetCurrent[2] = 300;
|
|
|
+ deratingByConnOtp->deratingTargetCurrent[3] = 300;
|
|
|
+ deratingByConnOtp->deratingTargetCurrent[4] = 300;
|
|
|
+}
|
|
|
+void SetCHAdeMoTypeJOTPValue(uint8_t regulation, struct DERATING_BY_OTP* deratingByConnOtp)
|
|
|
+{
|
|
|
+ if (regulation == 'J') {
|
|
|
+ memset(&deratingByConnOtp->deratingTargetRate[0], 125, sizeof(deratingByConnOtp->deratingTargetRate));
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ memset(&deratingByConnOtp->deratingTargetRate[0], 120, sizeof(deratingByConnOtp->deratingTargetRate));
|
|
|
+ }
|
|
|
+}
|
|
|
+void SetCHAdeMoTypeKOTPValue(struct DERATING_BY_OTP* deratingByConnOtp)
|
|
|
+{
|
|
|
+ memset(&deratingByConnOtp->deratingTargetRate[0], 200, sizeof(deratingByConnOtp->deratingTargetRate));
|
|
|
+}
|
|
|
+
|
|
|
+void SetCHAdeMoTypeSJOTPValue(struct DERATING_BY_OTP* deratingByConnOtp)
|
|
|
+{
|
|
|
+ deratingByConnOtp->deratingTargetRate[0] = 1;
|
|
|
+ deratingByConnOtp->deratingTargetRate[1] = 0.8;
|
|
|
+}
|
|
|
+
|
|
|
+static void SetGunTypeOTPValue(void)
|
|
|
+{
|
|
|
+ struct ChargingInfoData* pDcChargingInfo = NULL;
|
|
|
+ uint8_t Gun1Type = 0;
|
|
|
+ uint8_t Gun2Type = 0;
|
|
|
+ int i;
|
|
|
+ if (pSysConfig->TotalConnectorCount == 1) {
|
|
|
+ pDcChargingInfo = (struct ChargingInfoData*)GetDcChargingInfoData(0);
|
|
|
+ Gun1Type = pSysConfig->ModelName[7];
|
|
|
+ Gun2Type = pSysConfig->ModelName[7];
|
|
|
+
|
|
|
+ switch (Gun1Type) {
|
|
|
+ //CHAdeMo
|
|
|
+ case 'J':
|
|
|
+ SetCHAdeMoTypeJOTPValue(pSysConfig->ModelName[3], &pDcChargingInfo->deratingByConnOtp);
|
|
|
+ break;
|
|
|
+ case 'K':
|
|
|
+ SetCHAdeMoTypeKOTPValue(&pDcChargingInfo->deratingByConnOtp);
|
|
|
+ break;
|
|
|
+ case 'S':
|
|
|
+ SetCHAdeMoTypeSJOTPValue(&pDcChargingInfo->deratingByConnOtp);
|
|
|
+ break;
|
|
|
+ // 風冷200A以下
|
|
|
+ case 'U':
|
|
|
+ case 'E':
|
|
|
+ case 'M':
|
|
|
+ case 'N':
|
|
|
+ SetNatural200AGunOTPValue(&pDcChargingInfo->deratingByConnOtp);
|
|
|
+ break;
|
|
|
+ // 風冷300A
|
|
|
+ case 'T':
|
|
|
+ case 'D':
|
|
|
+ SetNatural300AGunOTPValue(&pDcChargingInfo->deratingByConnOtp);
|
|
|
+ break;
|
|
|
+ // 水冷
|
|
|
+ case 'V':
|
|
|
+ case 'F':
|
|
|
+ case 'P':
|
|
|
+ case 'R':
|
|
|
+ SetLiquidCoolGunOTPValue(&pDcChargingInfo->deratingByConnOtp);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ else if (pSysConfig->TotalConnectorCount == 2) {
|
|
|
+ Gun1Type = pSysConfig->ModelName[7];
|
|
|
+ Gun2Type = pSysConfig->ModelName[9];
|
|
|
+ for (i = 0; i < pSysConfig->TotalConnectorCount; i++) {
|
|
|
+ pDcChargingInfo = (struct ChargingInfoData*)GetDcChargingInfoData(i);
|
|
|
+ pDcChargingInfo->deratingByConnOtp.isNeedDerating = GUNOTPDERATING;
|
|
|
+ switch (i == 0 ? Gun1Type : Gun2Type) {
|
|
|
+ //CHAdeMo
|
|
|
+ case 'J':
|
|
|
+ SetCHAdeMoTypeJOTPValue(pSysConfig->ModelName[3], &pDcChargingInfo->deratingByConnOtp);
|
|
|
+ break;
|
|
|
+ case 'K':
|
|
|
+ SetCHAdeMoTypeKOTPValue(&pDcChargingInfo->deratingByConnOtp);
|
|
|
+ break;
|
|
|
+ case 'S':
|
|
|
+ SetCHAdeMoTypeSJOTPValue(&pDcChargingInfo->deratingByConnOtp);
|
|
|
+ break;
|
|
|
+ // 風冷200A以下
|
|
|
+ case 'U':
|
|
|
+ case 'E':
|
|
|
+ case 'M':
|
|
|
+ case 'N':
|
|
|
+ SetNatural200AGunOTPValue(&pDcChargingInfo->deratingByConnOtp);
|
|
|
+ break;
|
|
|
+ // 風冷300A
|
|
|
+ case 'T':
|
|
|
+ case 'D':
|
|
|
+ SetNatural300AGunOTPValue(&pDcChargingInfo->deratingByConnOtp);
|
|
|
+ break;
|
|
|
+ // 水冷
|
|
|
+ case 'V':
|
|
|
+ case 'F':
|
|
|
+ case 'P':
|
|
|
+ case 'R':
|
|
|
+ SetLiquidCoolGunOTPValue(&pDcChargingInfo->deratingByConnOtp);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
float GetMaxChargingVol(uint8_t index)
|
|
|
{
|
|
|
return maxChargingVol[index];
|
|
@@ -337,70 +462,44 @@ static void GetMaxVolAndCurMethod(uint8_t index, float *vol, float *cur)
|
|
|
*cur = pDcChargingInfo->ChargingProfileCurrent;
|
|
|
}
|
|
|
}
|
|
|
-void checkEachGunTypeOTP(int gunIndex, uint8_t Type, int derate_idx, struct DERATING_BY_OTP* deratingByConnOtp)
|
|
|
+
|
|
|
+void GetOtpPwrOrCurMethod(struct ChargingInfoData* chargingData, float* pow, float* cur)
|
|
|
{
|
|
|
- struct ChargingInfoData* pDcChargingInfo = (struct ChargingInfoData*)GetDcChargingInfoData(gunIndex);
|
|
|
- deratingByConnOtp->deratingIndex = derate_idx;
|
|
|
- /*
|
|
|
- log_info("RealMaxCurrent:[%.1f], AvailableChargingCurrent:[%.1f], BatteryTargetCurrent:[%.1f]",
|
|
|
- pDcChargingInfo->RealMaxCurrent,
|
|
|
- pDcChargingInfo->AvailableChargingCurrent,
|
|
|
- pDcChargingInfo->EvBatterytargetCurrent);
|
|
|
-
|
|
|
- log_info("RealMaxPower:[%.1f], AvailableChargingPower:[%.1f], BatteryTargetPower:[%.1f]",
|
|
|
- pDcChargingInfo->RealMaxPower,
|
|
|
- pDcChargingInfo->AvailableChargingPower,
|
|
|
- pDcChargingInfo->EvBatterytargetVoltage * pDcChargingInfo->EvBatterytargetCurrent);
|
|
|
- */
|
|
|
- switch (Type) {
|
|
|
- case 'S':
|
|
|
- // Derate by power
|
|
|
- if (pDcChargingInfo->RealMaxPower > pDcChargingInfo->AvailableChargingPower) {
|
|
|
- pDcChargingInfo->RealMaxPower = pDcChargingInfo->AvailableChargingPower * deratingByConnOtp->deratingTargetRate[derate_idx];
|
|
|
- log_info("Max Power derating to %.1f", pDcChargingInfo->RealMaxPower);
|
|
|
- }
|
|
|
- break;
|
|
|
- default:
|
|
|
- // Derate by current
|
|
|
- if (pDcChargingInfo->RealMaxCurrent > deratingByConnOtp->deratingTargetCurrent[derate_idx]) {
|
|
|
- pDcChargingInfo->RealMaxCurrent = deratingByConnOtp->deratingTargetCurrent[derate_idx];
|
|
|
- log_info("Max Current derating to %.1f", pDcChargingInfo->RealMaxCurrent);
|
|
|
- }
|
|
|
+ if (((chargingData->ConnectorTemp >= STAGE1_GUN_DERATING_TEMP &&
|
|
|
+ chargingData->ConnectorTemp < STAGE2_GUN_DERATING_TEMP) ||
|
|
|
+ (chargingData->ChillerTemp >= STAGE1_GUN_DERATING_TEMP &&
|
|
|
+ chargingData->ChillerTemp < STAGE2_GUN_DERATING_TEMP)) &&
|
|
|
+ chargingData->deratingByConnOtp.deratingIndex < 1)
|
|
|
+ {
|
|
|
+ chargingData->deratingByConnOtp.deratingIndex = 1;
|
|
|
+ }
|
|
|
+ else if ((chargingData->ConnectorTemp >= STAGE2_GUN_DERATING_TEMP ||
|
|
|
+ chargingData->ChillerTemp >= STAGE2_GUN_DERATING_TEMP) &&
|
|
|
+ chargingData->ConnectorTemp != UNDEFINED_TEMP &&
|
|
|
+ chargingData->ChillerTemp != UNDEFINED_TEMP &&
|
|
|
+ chargingData->deratingByConnOtp.deratingIndex < 2)
|
|
|
+ {
|
|
|
+ chargingData->deratingByConnOtp.deratingIndex = 2;
|
|
|
}
|
|
|
-}
|
|
|
-static void CheckGunTypeOTP(void)
|
|
|
-{
|
|
|
- uint8_t GunType = 0;
|
|
|
- int derate_idx;
|
|
|
- int i;
|
|
|
|
|
|
- for (i = 0; i < pSysConfig->TotalConnectorCount; i++) {
|
|
|
- if (pSysConfig->TotalConnectorCount == 1) {
|
|
|
- GunType = pSysConfig->ModelName[7];
|
|
|
- } else if (pSysConfig->TotalConnectorCount == 2) {
|
|
|
- GunType = (i == 0 ? pSysConfig->ModelName[7] : pSysConfig->ModelName[9]);
|
|
|
- }
|
|
|
- struct ChargingInfoData* pDcChargingInfo = (struct ChargingInfoData*)GetDcChargingInfoData(i);
|
|
|
- if (pDcChargingInfo->deratingByConnOtp.isNeedDerating) {
|
|
|
- if (pDcChargingInfo->ConnectorTemp >= _DERATING_85) {
|
|
|
- derate_idx = 2;
|
|
|
- } else if (pDcChargingInfo->ConnectorTemp >= _DERATING_80) {
|
|
|
- derate_idx = 1;
|
|
|
- } else {
|
|
|
- derate_idx = 0;
|
|
|
- }
|
|
|
- if (derate_idx != 0) {
|
|
|
- checkEachGunTypeOTP(i, GunType, derate_idx, &pDcChargingInfo->deratingByConnOtp);
|
|
|
- }
|
|
|
- }
|
|
|
+ if (chargingData->deratingByConnOtp.deratingTargetRate[chargingData->deratingByConnOtp.deratingIndex] != 0)
|
|
|
+ {
|
|
|
+ *pow *= chargingData->deratingByConnOtp.deratingTargetRate[chargingData->deratingByConnOtp.deratingIndex];
|
|
|
}
|
|
|
-}
|
|
|
+ else if (chargingData->deratingByConnOtp.deratingTargetCurrent[chargingData->deratingByConnOtp.deratingIndex] != 0)
|
|
|
+ {
|
|
|
+ if (*cur > chargingData->deratingByConnOtp.deratingTargetCurrent[chargingData->deratingByConnOtp.deratingIndex])
|
|
|
+ *cur = chargingData->deratingByConnOtp.deratingTargetCurrent[chargingData->deratingByConnOtp.deratingIndex];
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
static void SetPresentChargingOutputCap(void)
|
|
|
{
|
|
|
float pow1 = 0, cur1 = 0;
|
|
|
float pow2 = 0, cur2 = 0;
|
|
|
struct ChargingInfoData *chargingData_1 = NULL;
|
|
|
struct ChargingInfoData *chargingData_2 = NULL;
|
|
|
+ struct PrimaryMcuData* ShmPrimaryMcuData = (struct PrimaryMcuData*)GetShmPrimaryMcuData();
|
|
|
|
|
|
if (pSysConfig->TotalConnectorCount == 1) {
|
|
|
chargingData_1 = (struct ChargingInfoData *)GetDcChargingInfoData(0);
|
|
@@ -438,6 +537,14 @@ static void SetPresentChargingOutputCap(void)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ if (chargingData_1->deratingByConnOtp.isNeedDerating) {
|
|
|
+ GetOtpPwrOrCurMethod(chargingData_1, &pow1, &cur1);
|
|
|
+ if (deratingIndex[0] != chargingData_1->deratingByConnOtp.deratingIndex) {
|
|
|
+ log_info("Gun0 Derating Index Set %d", chargingData_1->deratingByConnOtp.deratingIndex);
|
|
|
+ deratingIndex[0] = chargingData_1->deratingByConnOtp.deratingIndex;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
pow2 = chargingData_2->AvailableChargingPower;
|
|
|
cur2 = chargingData_2->AvailableChargingCurrent;
|
|
|
/*
|
|
@@ -462,6 +569,24 @@ static void SetPresentChargingOutputCap(void)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ if (chargingData_2->deratingByConnOtp.isNeedDerating) {
|
|
|
+ GetOtpPwrOrCurMethod(chargingData_2, &pow2, &cur2);
|
|
|
+ if (deratingIndex[1] != chargingData_2->deratingByConnOtp.deratingIndex) {
|
|
|
+ log_info("Gun1 Derating Index Set %d", chargingData_2->deratingByConnOtp.deratingIndex);
|
|
|
+ deratingIndex[1] = chargingData_2->deratingByConnOtp.deratingIndex;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (ShmPrimaryMcuData->InputDet.bits.Ac_Drop == ABNORMAL) {
|
|
|
+ if (cur1 > 1500) {
|
|
|
+ log_info("Gun0 chiller alarm set current less than 150A");
|
|
|
+ cur1 = 1500;
|
|
|
+ }
|
|
|
+ if (cur2 > 1500) {
|
|
|
+ log_info("Gun1 chiller alarm set current less than 150A");
|
|
|
+ cur2 = 1500;
|
|
|
+ }
|
|
|
+ }
|
|
|
//DS60-120 add
|
|
|
if ((LogInfo[0][EV_LOG_OUTPUT_CAP_POW] <= pow1 - 5 ||
|
|
|
LogInfo[0][EV_LOG_OUTPUT_CAP_POW] >= pow1 + 5) ||
|
|
@@ -473,30 +598,29 @@ static void SetPresentChargingOutputCap(void)
|
|
|
LogInfo[1][EV_LOG_OUTPUT_CAP_CUR] >= cur2 + 5)
|
|
|
) {
|
|
|
//log_info("----------------------------------------------------- ");
|
|
|
- log_info("To EV PW_1 = %.1f, Cur_1 = %.1f, Vol_1 = %.1f, PW_2 = %.1f, Cur_2 = %.1f, Vol_2 = %.1f",
|
|
|
- pow1 / 10, cur1 / 10, chargingData_1->FireChargingVoltage, pow2 / 10, cur2 / 10, chargingData_2->FireChargingVoltage);
|
|
|
+ log_info("To EV (Real) Power_1 = %.1f, Cur_1 = %.1f, Power_2 = %.1f, Cur_2 = %.1f",
|
|
|
+ pow1 / 10, cur1 / 10, pow2 / 10, cur2 / 10);
|
|
|
//log_info("----------------------------------------------------- ");
|
|
|
|
|
|
LogInfo[0][EV_LOG_OUTPUT_CAP_POW] = pow1;
|
|
|
LogInfo[0][EV_LOG_OUTPUT_CAP_CUR] = cur1;
|
|
|
LogInfo[1][EV_LOG_OUTPUT_CAP_POW] = pow2;
|
|
|
LogInfo[1][EV_LOG_OUTPUT_CAP_CUR] = cur2;
|
|
|
- }
|
|
|
+ chargingData_1->RealMaxCurrent = cur1;
|
|
|
+ chargingData_1->RealMaxPower = pow1;
|
|
|
|
|
|
- chargingData_1->RealMaxCurrent = cur1;
|
|
|
- chargingData_1->RealMaxPower = pow1;
|
|
|
+ if (pSysConfig->TotalConnectorCount == 2) {
|
|
|
+ chargingData_2->RealMaxCurrent = cur2;
|
|
|
+ chargingData_2->RealMaxPower = pow2;
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
if (pSysConfig->TotalConnectorCount == 2) {
|
|
|
chargingData_2->RealMaxCurrent = cur2;
|
|
|
chargingData_2->RealMaxPower = pow2;
|
|
|
}
|
|
|
|
|
|
- //CheckGunTypeOTP();
|
|
|
-
|
|
|
- SetPresentOutputCapacity(chargingData_1->RealMaxPower,
|
|
|
- chargingData_1->RealMaxCurrent,
|
|
|
- chargingData_2->RealMaxPower,
|
|
|
- chargingData_2->RealMaxCurrent);
|
|
|
+ SetPresentOutputCapacity(pow1, cur1, pow2, cur2);
|
|
|
}
|
|
|
/*
|
|
|
static uint8_t waitPsuVolwithRealyVol(uint8_t gunIndex)
|
|
@@ -794,6 +918,8 @@ int main(int argc, char *argv[])
|
|
|
|
|
|
CANReceiver(CanFd);
|
|
|
|
|
|
+ SetGunTypeOTPValue();
|
|
|
+
|
|
|
rtc = GetRtcInfoForEpoch();
|
|
|
|
|
|
while (isContinue) {
|